/* ============================================================
   Editorial layer — apple.com anatomy (Appendix A3/A4)
   + learner components (cards, quiz, progress, rails).
   The CONTENT layer: photography, jewel gradients, big Didot.
   ============================================================ */

* { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  font-size: var(--text-body);
  line-height: 1.5;
  color: var(--ink);
  background: var(--ground);
  min-height: 100dvh;
  /* clear the fixed nav */
  padding-bottom: calc(var(--tabbar-h) + 28px);
}
@media (min-width: 768px) {
  body { padding-bottom: 0; padding-top: calc(var(--nav-h) + 28px); }
}
img, video { max-width: 100%; display: block; }
button { font: inherit; cursor: pointer; }

.wrap { max-width: var(--content-max); margin: 0 auto; padding: 0 var(--section-x); }

h1, h2, .display {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.08;
}
h1 { font-size: var(--text-title); }
.hero-title { font-size: var(--text-hero); color: #fff; text-wrap: balance; }
.eyebrow {
  font-family: var(--font-body);
  font-size: var(--text-caption);
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--accent-text);
}
.secondary { color: var(--ink-secondary); }
.footnote { font-size: 12px; line-height: 1.55; color: var(--ink-secondary); }

/* ---------- Sections ---------- */
.section { padding: var(--section-y) var(--section-x); }
.section--alt { background: var(--ground-alt); }

/* ---------- Hero (background layer + overlay + Didot) ---------- */
.hero {
  position: relative;
  min-height: 46dvh;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: var(--sp-7) var(--section-x) var(--sp-6);
  background-size: cover;
  background-position: center;
  overflow: hidden;
}
.hero::before { content: ""; position: absolute; inset: 0; background: var(--hero-overlay); }
.hero > * { position: relative; }
.hero .eyebrow { color: var(--gold-light); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px 26px;
  border: none;
  border-radius: var(--r-pill);
  background: var(--accent);
  color: var(--ink-on-accent);
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none;
  transition: transform var(--dur-micro) var(--ease-spring), filter var(--dur-micro);
}
.btn:active { transform: scale(.97); }
@media (hover: hover) and (pointer: fine) { .btn:hover { filter: brightness(1.08); transform: scale(1.03); } }
.btn--quiet { background: transparent; color: var(--accent-text); border: 1px solid var(--glass-border); }

/* ---------- Progress ---------- */
.progress {
  height: 8px;
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--ink) 12%, transparent);
  overflow: hidden;
}
.progress > i {
  display: block; height: 100%;
  width: var(--value, 0%);
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold-deep), var(--accent));
  transition: width .5s var(--ease-out);
}
.progress-pill {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%) translateZ(0);
  z-index: 150;
  padding: 8px 18px;
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .04em;
}

/* ---------- Packet cards (App-Store-Today style) ---------- */
.packet-card {
  display: block;
  position: relative;
  border-radius: var(--r-card);
  overflow: hidden;
  aspect-ratio: 16 / 10;
  text-decoration: none;
  color: #fff;
  box-shadow: 0 10px 30px rgba(12, 35, 64, .18);
  background-size: cover;
  background-position: center;
}
.packet-card::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to bottom, rgba(4,10,20,.06) 30%, rgba(4,10,20,.62) 100%);
}
.packet-card .meta {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: var(--sp-3) var(--sp-4);
}
.packet-card .meta h3 { font-family: var(--font-display); font-size: var(--text-card-title); letter-spacing: -0.01em; }
.packet-card .meta .sub { font-size: .8rem; opacity: .85; margin-top: 2px; display: flex; gap: 10px; align-items: center; }
.packet-card .done-tick { color: var(--gold-light); font-weight: 700; }
@media (hover: hover) and (pointer: fine) {
  .packet-card { transition: transform var(--dur-micro) var(--ease-spring), box-shadow var(--dur-micro); }
  .packet-card:hover { transform: scale(1.02); box-shadow: 0 20px 44px rgba(12,35,64,.28); }
}

/* ---------- Rails (horizontal carousels) ---------- */
.rail {
  display: flex;
  gap: var(--sp-4);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding: var(--sp-2) var(--section-x) var(--sp-4);
  scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }
.rail > * { flex: 0 0 clamp(260px, 72vw, 380px); scroll-snap-align: start; }
@media (min-width: 768px) { .rail > * { flex-basis: clamp(280px, 30vw, 400px); } }

.grid { display: grid; gap: var(--sp-4); }
@media (min-width: 768px) { .grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); } }

/* ---------- Learning cards (the calm surface) ---------- */
.learn-stage {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: calc(var(--sp-7)) var(--section-x) calc(var(--tabbar-h) + var(--sp-6));
  position: relative;
}
.learn-card {
  width: min(560px, 100%);
  padding: var(--sp-5) var(--sp-5) var(--sp-6);
  text-align: left;
}
.learn-card .card-img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: var(--r-inner);
  margin-bottom: var(--sp-4);
}
.learn-card h2 { font-size: var(--text-card-title); margin-bottom: var(--sp-2); }
.learn-card .body { font-size: 1.09rem; line-height: 1.55; }
.deeper-btn {
  position: absolute;
  right: var(--sp-4); bottom: var(--sp-4);
  min-width: 44px; min-height: 44px;
  border-radius: var(--r-pill);
  border: 1px solid var(--glass-border);
  background: transparent;
  color: var(--accent-text);
  font-weight: 700;
  font-size: .85rem;
  padding: 8px 16px;
}

/* Depth sheet content */
.sheet h3 { font-family: var(--font-display); font-size: 1.3rem; margin-bottom: var(--sp-2); }
.sheet .sci-toggle {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-top: 1px solid var(--glass-border);
  margin-top: var(--sp-4);
  padding: var(--sp-3) 0 0;
  color: var(--accent-text);
  font-weight: 700;
}
.sheet .sci-body { display: none; padding-top: var(--sp-2); }
.sheet .sci-body.open { display: block; }

/* Player chrome */
.stage-controls {
  position: fixed;
  left: 0; right: 0;
  bottom: max(14px, env(safe-area-inset-bottom));
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 var(--sp-4);
  z-index: 150;
  pointer-events: none;
}
.stage-controls > * { pointer-events: auto; }

/* ---------- Video ---------- */
.video-shell { width: min(560px, 100%); margin: 0 auto; position: relative; }
.video-frame {
  position: relative;
  border-radius: var(--r-card);
  overflow: hidden;
  background: #000;
  box-shadow: 0 18px 50px rgba(4, 10, 20, .4);
}
.video-frame.ratio-16x9 { aspect-ratio: 16 / 9; }
.video-frame.ratio-9x16 { aspect-ratio: 9 / 16; max-width: min(400px, 88vw); margin: 0 auto; }
.video-frame iframe, .video-frame video {
  position: absolute; inset: 0; width: 100%; height: 100%; border: 0;
}
/* desktop ambient echo behind vertical video */
@media (min-width: 1024px) {
  .video-shell.vertical::before {
    content: "";
    position: absolute; inset: -12% -34%;
    background: var(--ambient, linear-gradient(160deg, var(--navy), var(--gold-deep)));
    filter: blur(48px) saturate(140%);
    opacity: .55;
    border-radius: 48px;
    z-index: -1;
  }
}

/* ---------- Quiz ---------- */
.quiz-choice {
  display: block;
  width: 100%;
  text-align: left;
  min-height: 52px;
  padding: 14px 18px;
  margin-bottom: var(--sp-2);
  border-radius: var(--r-inner);
  border: 1.5px solid var(--glass-border);
  background: color-mix(in srgb, var(--ground) 55%, transparent);
  color: var(--ink);
  font-size: 1rem;
  transition: border-color var(--dur-micro), background var(--dur-micro);
}
.quiz-choice.correct { border-color: #2E7F73; background: color-mix(in srgb, #2E7F73 16%, transparent); }
.quiz-choice.wrong { border-color: var(--jewel-ruby); background: color-mix(in srgb, #A6192E 12%, transparent); }
.quiz-feedback { margin: var(--sp-3) 0; font-weight: 600; min-height: 1.4em; }

/* ---------- Chips (interest picker, search zero-state) ---------- */
.chip {
  display: inline-flex; align-items: center;
  min-height: 44px;
  padding: 10px 20px;
  border-radius: var(--r-pill);
  border: 1.5px solid var(--glass-border);
  background: transparent;
  color: var(--ink);
  font-weight: 600;
  margin: 0 8px 10px 0;
  transition: all var(--dur-micro) var(--ease-gentle);
}
.chip[aria-pressed="true"] {
  background: var(--accent);
  color: var(--ink-on-accent);
  border-color: var(--accent);
}

/* ---------- Scroll reveal ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: none; } }
.reveal { opacity: 0; }
.reveal.in-view { animation: rise var(--dur-enter) var(--ease-out) forwards; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; }
  .reveal.in-view { animation: none; }
}

/* ---------- Forms ---------- */
.field {
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  border-radius: var(--r-inner);
  border: 1.5px solid var(--glass-border);
  background: color-mix(in srgb, var(--ground) 70%, transparent);
  color: var(--ink);
  font: inherit;
}
.field:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: block; font-size: .85rem; font-weight: 700; margin: var(--sp-3) 0 6px; }

/* honeypot — visually gone, present for bots */
.hp-field { position: absolute; left: -9999px; opacity: 0; height: 0; overflow: hidden; }

.sr-only { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; }

/* ============================================================
   DETAIL LAYER — the Apple micro-detail pass (Phase 2).
   Cross-page transitions, staggered reveals, specular hover
   physics, sticky local-nav, shimmer, selection & focus.
   ============================================================ */

/* Cross-fade between pages (progressive enhancement, Chromium/Safari 18+) */
@view-transition { navigation: auto; }
html { scroll-behavior: smooth; }

::selection { background: color-mix(in srgb, var(--gold) 35%, transparent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* Staggered entrance — delay set per element by revealOnScroll() in api.js */
.reveal { animation-delay: var(--stagger, 0s); }

/* Specular sheen sweep across packet cards on hover (pointer devices) */
.packet-card::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,.18) 50%, transparent 60%);
  transform: translateX(-120%);
  pointer-events: none;
}
@media (hover: hover) and (pointer: fine) {
  .packet-card:hover::after { transition: transform calc(.9s * var(--motion-scale, 1)) var(--ease-out); transform: translateX(120%); }
}

/* Progress bars get a soft moving sheen while under 100% */
.progress > i { position: relative; overflow: hidden; }
.progress > i::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.35), transparent);
  transform: translateX(-100%);
  animation: shimmer calc(2.6s * var(--motion-scale, 1)) var(--ease-gentle) infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) { .progress > i::after { animation: none; } }

/* Sticky local-nav (apple.com product-nav): hidden until you scroll past the hero */
.local-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 120;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-3);
  height: 52px;
  padding: 0 var(--section-x);
  background: color-mix(in srgb, var(--ground) 78%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  backdrop-filter: blur(14px) saturate(160%);
  border-bottom: 1px solid color-mix(in srgb, var(--ink) 10%, transparent);
  transform: translateY(-100%);
  transition: transform calc(.45s * var(--motion-scale, 1)) var(--ease-out);
}
.local-nav.pinned { transform: translateY(0); }
.local-nav .ln-title { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; color: var(--ink); }
.local-nav .btn { min-height: 34px; padding: 6px 16px; font-size: .85rem; }
@media (max-width: 767px) { .local-nav { top: 0; } }

/* Hero eyebrow underline flourish */
.hero .eyebrow::after {
  content: "";
  display: block;
  width: 42px; height: 2px;
  margin-top: 8px;
  background: linear-gradient(90deg, var(--gold-light), transparent);
}

/* Footer */
.site-footer {
  margin-top: var(--sp-7);
  padding: var(--sp-6) var(--section-x) calc(var(--sp-7));
  border-top: 1px solid color-mix(in srgb, var(--ink) 10%, transparent);
}
.site-footer .footnote { max-width: 62ch; }
