/* Apple product-page palette. Semantic tokens below are the only ones components use. */
:root {
  --color-bg: #f5f5f7; /* Apple's film off-white */
  --color-text: #1d1d1f;
  --color-text-muted: #6e6e73;
  --color-accent: #0071e3;
  --color-ring: #0071e3;

  /* iPhone 17: 402x874 pt. The live screen keeps this size; device.js scales it onto the 3D display. */
  --screen-w: 402px;
  --screen-h: 874px;
  --screen-r: 55px;
  --nav-h: 52px; /* read by device.js */

  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--color-ring); outline-offset: 2px; }

/* Local nav: glass bar, product name left, actions right. */
.localnav {
  position: fixed; inset: 0 0 auto; z-index: 10; height: var(--nav-h);
  background: rgb(245 245 247 / 0.72);
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid rgb(0 0 0 / 0.08);
}
.localnav-inner {
  max-width: 1024px; height: 100%; margin: 0 auto; padding: 0 22px;
  display: flex; align-items: center; justify-content: space-between;
}
.localnav-title { font-size: 21px; font-weight: 600; letter-spacing: 0.011em; }
.pill {
  display: inline-flex; align-items: center; height: 28px; padding: 0 14px; border-radius: 980px;
  font-size: 12px; font-weight: 400; letter-spacing: -0.01em; text-decoration: none;
  transition: background-color 0.2s, scale 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.pill:active { scale: 0.97; }
.pill-outline { border: 1px solid var(--color-text); }
.pill-outline:hover { background: var(--color-text); color: #fff; }

/* Stage: one screen. The wordmark shows alone, then fades as the phone turns in (device.js sets data-phase). */
.stage { position: relative; height: 100dvh; }
.sticky { position: relative; height: 100%; overflow: hidden; }

.wordmark {
  position: absolute; inset: 0; z-index: 1; margin: 0; padding: 0 22px;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; column-gap: 0.25em;
  font-size: clamp(40px, 7vw, 88px); line-height: 1.05; letter-spacing: -0.02em; text-align: center;
  pointer-events: none;
  transition: opacity 0.45s cubic-bezier(0.4, 0, 0.2, 1), scale 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}
.wm-a { font-weight: 600; animation: wm-in 0.7s 0.2s cubic-bezier(0.16, 1, 0.3, 1) both; }
/* "Prototype" writes itself in left to right, like the script word in Apple's product films. */
.wm-b { font-weight: 300; color: var(--color-accent); animation: wm-write 1s 0.7s cubic-bezier(0.65, 0, 0.35, 1) both; }
@keyframes wm-in { from { opacity: 0; translate: 0 12px; } }
@keyframes wm-write { from { clip-path: inset(-10% 100% -10% 0); } to { clip-path: inset(-10% -2% -10% 0); } }
.stage:is([data-phase="phone"], [data-phase="done"]) .wordmark { opacity: 0; scale: 0.98; }

.device { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; transition: opacity 0.6s; }
.stage:is([data-phase="phone"], [data-phase="done"]) .device { opacity: 1; }

/* Live screen. Positioned by device.js (translate + scale from its top-left corner). */
.screen {
  position: absolute; left: 0; top: 0; z-index: 2; overflow: hidden;
  width: var(--screen-w); height: var(--screen-h); border-radius: var(--screen-r);
  transform-origin: 0 0; opacity: 0; pointer-events: none;
  background: linear-gradient(160deg, #3a4a6b 0%, #6b5b8a 45%, #c98f7a 100%);
  isolation: isolate;
}
.stage[data-awake] .screen { pointer-events: auto; }

/* Status bar + Dynamic Island, drawn by the hub (insets are 0 inside the iframe). */
.status {
  position: absolute; inset: 0 0 auto; height: 54px; z-index: 3; pointer-events: none;
  display: flex; align-items: center; justify-content: space-between; padding: 6px 30px 0 46px;
  font-size: 17px; font-weight: 600; color: #fff;
}
.screen[data-state="app"] .status { color: #000; } /* shortcut: assumes light app UI; let apps post their bar style if a dark app appears */
.status svg { fill: currentColor; display: block; }
.glyphs { display: flex; gap: 6px; align-items: center; }
.island {
  position: absolute; top: 11px; left: 50%; translate: -50% 0;
  width: 124px; height: 36px; border-radius: 18px; background: #000;
}

.home { position: absolute; inset: 62px 0 34px; padding: 12px 24px; }
.grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(4, 1fr); row-gap: 24px; justify-items: center;
}
.icon { display: grid; justify-items: center; gap: 6px; width: 72px; }
.icon img {
  width: 62px; height: 62px; border-radius: 14px; object-fit: cover;
  background: rgb(255 255 255 / 0.25); box-shadow: 0 1px 3px rgb(0 0 0 / 0.2);
}
.icon span {
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 12px; color: #fff; text-shadow: 0 1px 2px rgb(0 0 0 / 0.35);
}
.icon:active img { filter: brightness(0.8); }
.empty { margin: 40% 0 0; text-align: center; color: rgb(255 255 255 / 0.85); font-size: 15px; }

.app { position: absolute; inset: 0; z-index: 2; background: #fff; }
.app iframe { width: 100%; height: 100%; border: 0; display: block; }
.splash { position: absolute; inset: 0; display: grid; place-items: center; background: #fff; }
.splash img { width: 96px; height: 96px; border-radius: 22px; }
.app:not([hidden]) { animation: open 0.28s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes open { from { opacity: 0; transform: scale(0.9); } }

.home-bar {
  position: absolute; bottom: 8px; left: 50%; translate: -50% 0; z-index: 3;
  width: 140px; height: 5px; border-radius: 3px; background: #fff; opacity: 0.9;
}
.screen[data-state="app"] .home-bar { background: #000; }
.home-bar::before { content: ""; position: absolute; inset: -12px -20px; } /* larger hit area */

/* Credit sits over the stage so the page stays one screen. */
.footer {
  position: fixed; right: 22px; bottom: 14px; z-index: 3;
  font-size: 11px; line-height: 1.33; color: var(--color-text-muted);
}
.footer p { margin: 0; }
.footer a { text-decoration: none; color: var(--color-text); }
.footer a:hover { text-decoration: underline; }

/* No WebGL or the model failed: a flat CSS phone, no scroll scrub. */
.stage.flat { height: auto; }
.stage.flat .sticky { height: auto; overflow: visible; padding: calc(var(--nav-h) + 40px) 22px 64px; display: grid; justify-items: center; }
.stage.flat .wordmark, .stage.flat .device { display: none; }
.stage.flat .screen {
  position: relative; opacity: 1; pointer-events: auto; transform: none;
  zoom: 0.8; /* shortcut: fixed size in the fallback; fit to viewport height if the fallback ever matters */
  outline: 12px solid #1d1d1f; box-shadow: 0 0 0 13px #3a3a3c, 0 40px 80px -30px rgb(0 0 0 / 0.4);
}

@media (prefers-reduced-motion: reduce) {
  .app:not([hidden]), .wm-a, .wm-b { animation: none; }
}

/* Real phone: no page, no 3D, the home screen fills the display; hub.js opens apps top-level. */
@media (max-width: 600px) and (pointer: coarse) {
  .localnav, .wordmark, .device, .footer { display: none; }
  .stage, .stage.flat { height: 100dvh; }
  .sticky, .stage.flat .sticky { height: 100dvh; padding: 0; }
  .screen, .stage.flat .screen {
    position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 0; opacity: 1; pointer-events: auto;
    transform: none; zoom: 1; outline: 0; box-shadow: none;
  }
  .status, .home-bar { display: none; }
  .home { inset: env(safe-area-inset-top, 0) 0 env(safe-area-inset-bottom, 0); padding-top: 24px; }
}
