/* iPhone frame, home screen, widgets, icons, dock. */

.iphone {
  width: 340px;
  height: 700px;
  background: #0a0a0c;
  border-radius: 54px;
  padding: 10px;
  box-shadow:
    0 0 0 2px #2a2a2e,
    0 0 0 4px #17171a,
    0 30px 80px rgba(0, 0, 0, 0.5),
    0 10px 30px rgba(0, 0, 0, 0.4);
  position: relative;
}

/* side buttons */
.iphone::before {
  content: "";
  position: absolute;
  left: -6px; top: 150px;
  width: 4px; height: 100px;
  background: linear-gradient(#3a3a3e, #232327 30%, #232327 70%, #3a3a3e);
  border-radius: 2px 0 0 2px;
  box-shadow: 0 -46px 0 -32px #232327;
}
.iphone::after {
  content: "";
  position: absolute;
  right: -6px; top: 190px;
  width: 4px; height: 68px;
  background: linear-gradient(#3a3a3e, #232327 30%, #232327 70%, #3a3a3e);
  border-radius: 0 2px 2px 0;
}

.iphone-screen {
  width: 100%;
  height: 100%;
  border-radius: 44px;
  overflow: hidden;
  position: relative;
  background: #101014;
}

.wallpaper {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 90% at 80% -10%, #3e3229 0%, transparent 55%),
    radial-gradient(120% 100% at 10% 110%, #2a2320 0%, transparent 60%),
    linear-gradient(180deg, #201b18 0%, #171412 55%, #131110 100%);
  transition: background 0.6s ease;
}
.wallpaper.wp-slate {
  background:
    radial-gradient(120% 90% at 80% -10%, #2a3140 0%, transparent 55%),
    radial-gradient(120% 100% at 10% 110%, #1d222e 0%, transparent 60%),
    linear-gradient(180deg, #171b24 0%, #12151c 55%, #0f1116 100%);
}
.wallpaper.wp-forest {
  background:
    radial-gradient(120% 90% at 80% -10%, #26362c 0%, transparent 55%),
    radial-gradient(120% 100% at 10% 110%, #1b2820 0%, transparent 60%),
    linear-gradient(180deg, #151f19 0%, #101812 55%, #0e130f 100%);
}

/* ---- Status bar ---- */
.statusbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 26px 0;
  color: #f5f2ee;
  font-size: 13.5px;
  font-weight: 600;
  z-index: 30;
  pointer-events: none;
}
.island {
  position: absolute;
  left: 50%; top: 12px;
  transform: translateX(-50%);
  width: 96px; height: 26px;
  background: #000;
  border-radius: 14px;
}
.sb-right { display: flex; align-items: center; gap: 5px; }
.sb-5g { font-size: 11px; font-weight: 700; letter-spacing: 0.02em; }
.sb-ico { display: block; }

/* ---- Home screen ---- */
.homescreen {
  position: absolute;
  inset: 0;
  padding: 58px 18px 14px;
  display: flex;
  flex-direction: column;
  transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.35s ease, filter 0.4s ease, visibility 0s;
}
/* Once an app has zoomed in, stop drawing the home screen behind it at all:
   a blurred full-screen layer under a scrolling app costs frames. */
.homescreen.zoomed {
  transform: scale(1.08);
  opacity: 0;
  filter: blur(8px);
  pointer-events: none;
  visibility: hidden;
  transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.35s ease, filter 0.4s ease, visibility 0s linear 0.4s;
}

/* ---- Widgets ---- */
.widget-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px 16px;
  margin-bottom: 20px;
}
.widget {
  aspect-ratio: 1;
  border-radius: 22px;
  position: relative;
  cursor: pointer;
  border: none;
  padding: 0;
  text-align: left;
  font-family: inherit;
  transition: transform 0.15s ease;
  background: none;
}
.widget:active { transform: scale(0.95); }
.widget-face {
  position: absolute;
  inset: 0;
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
.widget-label {
  position: absolute;
  bottom: -19px;
  left: 0; right: 0;
  text-align: center;
  font-size: 10.5px;
  color: rgba(245, 242, 238, 0.8);
  font-weight: 500;
  pointer-events: none;
}
.widget-row { margin-bottom: 34px; }

/* GitHub widget */
.w-github .widget-face {
  background: #17181c;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}
.gh-grid {
  display: grid;
  grid-template-columns: repeat(13, 1fr);
  gap: 2.5px;
  width: 100%;
}
.gh-cell {
  aspect-ratio: 1;
  border-radius: 2px;
  background: #24262c;
}
.gh-cell.l1 { background: #0e4429; }
.gh-cell.l2 { background: #006d32; }
.gh-cell.l3 { background: #26a641; }
.gh-cell.l4 { background: #39d353; }

/* Spotify widget */
.w-spotify .widget-face {
  background: linear-gradient(150deg, #7a3b2e 0%, #4a2620 55%, #2e1a17 100%);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: #fff;
}
.sp-top { display: flex; justify-content: space-between; align-items: flex-start; }
.sp-art {
  width: 52px; height: 52px;
  border-radius: 8px;
  background: linear-gradient(140deg, #e0a458, #a4494c 60%, #4b2a4e);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,0.85);
}
.sp-track {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 12px; font-weight: 700; line-height: 1.25;
}
/* Title sits right under the cover; the play button stays in the bottom corner. */
.sp-bottom { flex: 1; display: flex; align-items: flex-start; justify-content: space-between; gap: 6px; }
.sp-play {
  align-self: flex-end;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: #fff;
  color: #191414;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* Weather widget (medium, spans both columns) */
.w-weather {
  grid-column: 1 / -1;
  aspect-ratio: auto;
  height: 74px;
}
.w-weather .widget-face {
  background:
    radial-gradient(130% 160% at 15% 0%, #3d6ea8 0%, #29496f 55%, #1b3350 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  color: #fff;
}
.wx-left { display: flex; flex-direction: column; }
.wx-city { font-size: 12.5px; font-weight: 600; }
.wx-temp { font-size: 27px; font-weight: 400; line-height: 1.1; }
.wx-right { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; }
.wx-ico svg { display: block; }
.wx-cond { font-size: 11px; font-weight: 500; opacity: 0.9; }
.wx-hl { font-size: 10px; opacity: 0.65; }
.app-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px 12px;
  align-content: start;
}
.app {
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  transition: transform 0.15s ease;
}
.app:active { transform: scale(0.88); }
.app-icon {
  width: 54px; height: 54px;
  border-radius: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}
.app-icon svg { display: block; }
.app-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: inherit;
  -webkit-user-drag: none;
}

/* ---- Liquid glass ---- */
.glass {
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.14) 0%, rgba(255, 255, 255, 0.045) 45%, rgba(255, 255, 255, 0.1) 100%);
  backdrop-filter: blur(22px) saturate(1.7);
  -webkit-backdrop-filter: blur(22px) saturate(1.7);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    inset 0 -1px 1px rgba(255, 255, 255, 0.06),
    0 8px 24px rgba(0, 0, 0, 0.22);
}
.app-name {
  font-size: 10.5px;
  color: rgba(245, 242, 238, 0.8);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 68px;
}

/* ---- Search pill ---- */
.search-pill {
  margin: auto auto 14px;
  display: flex;
  align-items: center;
  gap: 5px;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.16) 0%, rgba(255, 255, 255, 0.06) 50%, rgba(255, 255, 255, 0.12) 100%);
  backdrop-filter: blur(18px) saturate(1.7);
  -webkit-backdrop-filter: blur(18px) saturate(1.7);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 4px 14px rgba(0, 0, 0, 0.18);
  color: rgba(245, 242, 238, 0.9);
  font-size: 11.5px;
  font-weight: 500;
  font-family: inherit;
  padding: 6px 13px;
  border-radius: 999px;
  cursor: pointer;
}

/* ---- Dock ---- */
.dock {
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.13) 0%, rgba(255, 255, 255, 0.04) 50%, rgba(255, 255, 255, 0.09) 100%);
  backdrop-filter: blur(26px) saturate(1.8);
  -webkit-backdrop-filter: blur(26px) saturate(1.8);
  border: 1px solid rgba(255, 255, 255, 0.13);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    inset 0 -1px 1px rgba(255, 255, 255, 0.05),
    0 10px 30px rgba(0, 0, 0, 0.25);
  border-radius: 28px;
  padding: 12px;
  display: flex;
  justify-content: center;
  gap: 22px;
}
.dock .app { gap: 0; }
.dock .app-name { display: none; }

/* ---- App view (open app) ---- */
.appview {
  position: absolute;
  inset: 0;
  z-index: 20;
  border-radius: 44px;
  overflow: hidden;
  transform-origin: center 60%; /* main.js sets this to the tapped icon */
  will-change: transform, opacity;
  animation: appOpen 0.4s cubic-bezier(0.32, 0.72, 0, 1);
}
.appview.closing {
  animation: appClose 0.3s cubic-bezier(0.4, 0, 0.6, 1) forwards;
}
@keyframes appOpen {
  0%   { transform: scale(0.25); opacity: 0; }
  30%  { opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes appClose {
  from { transform: scale(1); opacity: 1; }
  to   { transform: scale(0.3); opacity: 0; }
}
.appview-inner {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
}
.appview-inner::-webkit-scrollbar { display: none; }
.appview-inner.swap { animation: pageSwap 0.32s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes pageSwap {
  from { opacity: 0; transform: translateY(12px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

.home-indicator {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 110px;
  height: 20px;
  border: none;
  background: none;
  cursor: pointer;
  z-index: 40;
  padding: 0;
}
.home-indicator::after {
  content: "";
  display: block;
  width: 110px; height: 4.5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.85);
  margin: 12px auto 0;
  transition: transform 0.2s;
}
.home-indicator:hover::after { transform: scaleX(1.12); }

/* ---- Search overlay ---- */
.searchview {
  position: absolute;
  inset: 0;
  z-index: 25;
  background: rgba(18, 16, 15, 0.72);
  backdrop-filter: blur(24px);
  padding: 64px 20px 20px;
  animation: fadeIn 0.25s ease;
}
@keyframes fadeIn { from { opacity: 0; } }
.searchview input {
  width: 100%;
  background: rgba(255, 255, 255, 0.12);
  border: none;
  border-radius: 12px;
  padding: 10px 14px;
  color: #fff;
  font-size: 15px;
  font-family: inherit;
  outline: none;
}
.searchview input::placeholder { color: rgba(255, 255, 255, 0.45); }
#searchResults { margin-top: 14px; display: flex; flex-direction: column; gap: 4px; }
.sr-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 12px;
  border: none;
  background: none;
  color: #f0ede9;
  font-size: 13.5px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
}
.sr-item:hover { background: rgba(255, 255, 255, 0.1); }
.sr-item .app-icon { width: 32px; height: 32px; border-radius: 8px; box-shadow: none; }
.sr-item .app-icon svg { transform: scale(0.6); }
.sr-sub { color: rgba(240, 237, 233, 0.5); font-size: 11.5px; font-weight: 400; margin-left: auto; }

@media (max-width: 900px) {
  .iphone { width: min(340px, calc(100vw - 48px)); height: auto; aspect-ratio: 340 / 700; }
}

/* Full-screen photo viewer hides the status bar, like iOS */
.statusbar { transition: opacity 0.25s ease; }
#screen.immersive .statusbar { opacity: 0; }
