/* Motion and component unification layer — Apple glass & motion (2026-08). */
:root {
  --motion-ease: cubic-bezier(.16, 1, .3, 1);
  --motion-snap: cubic-bezier(.2, .9, .15, 1.2);
}

/* Home opens with a short cinematic intro, then hands off to the first surface. */
.library-intro {
  position: fixed;
  z-index: 120;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #000;
  color: #f5f5f7;
}
.library-intro::before {
  position: absolute;
  inset: 0;
  content: "";
  opacity: .5;
  background: radial-gradient(42% 38% at 50% 45%, rgba(41, 151, 255, 0.16), transparent 70%);
}
.library-intro-copy { position: relative; z-index: 1; width: min(680px, calc(100vw - 48px)); text-align: center; }
.library-intro-copy > p { margin: 0 0 18px; color: #2997ff; font: 12px var(--font-mono); letter-spacing: .14em; opacity: 0; animation: intro-copy .42s .68s var(--motion-ease) both; }
.library-intro-mark { display: inline-flex; align-items: baseline; gap: .35em; color: #f5f5f7; font-family: var(--font-display); font-size: clamp(56px, 12vw, 156px); line-height: .85; letter-spacing: -.08em; }
.library-intro-mark span { color: #000; -webkit-text-stroke: 2px #2997ff; opacity: 0; transform: translateX(-.18em); animation: intro-mark .62s .86s var(--motion-ease) both; }
.library-intro-mark strong { --intro-start: .18em; font: inherit; opacity: 0; transform: translateX(.18em); animation: intro-mark .62s 1s var(--motion-ease) both; }
.library-intro-copy small { display: block; margin-top: 24px; color: #86868b; font: 13px var(--font-mono); letter-spacing: .05em; opacity: 0; animation: intro-copy .42s 1.25s var(--motion-ease) both; }
.library-intro-line { position: absolute; display: block; background: #2997ff; box-shadow: 0 0 22px rgba(41, 151, 255, 0.4); }
.library-intro-line.line-top, .library-intro-line.line-bottom { right: 7vw; left: 7vw; height: 2px; transform: scaleX(0); }
.library-intro-line.line-left, .library-intro-line.line-right { top: 13vh; bottom: 13vh; width: 2px; transform: scaleY(0); }
.library-intro-line.line-top { top: 13vh; transform-origin: left; animation: intro-line-x .58s .08s var(--motion-ease) both; }
.library-intro-line.line-bottom { bottom: 13vh; transform-origin: right; animation: intro-line-x .58s .28s var(--motion-ease) both; }
.library-intro-line.line-left { left: 7vw; transform-origin: bottom; animation: intro-line-y .58s .18s var(--motion-ease) both; }
.library-intro-line.line-right { right: 7vw; transform-origin: top; animation: intro-line-y .58s .38s var(--motion-ease) both; }
.library-intro-skip { position: absolute; z-index: 2; top: 28px; right: 32px; padding: 8px 0; border-bottom: 1px solid #2997ff; color: #86868b; font: 11px var(--font-mono); letter-spacing: .08em; }
.library-intro.is-leaving { pointer-events: none; animation: intro-exit .54s var(--motion-ease) both; }
@keyframes intro-line-x { to { transform: scaleX(1); } }
@keyframes intro-line-y { to { transform: scaleY(1); } }
@keyframes intro-copy { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes intro-mark { from { opacity: 0; transform: translateX(var(--intro-start, -.18em)); } to { opacity: 1; transform: translateX(0); } }
@keyframes intro-exit { to { opacity: 0; transform: scale(1.035); visibility: hidden; } }

.pointer-ink { position: fixed; z-index: 110; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%; background: #2997ff; pointer-events: none; animation: pointer-ink .62s var(--motion-ease) forwards; }
@keyframes pointer-ink { to { opacity: 0; transform: scale(3.3); } }

/* First-view rhythm */
body.motion-running .shelf-kicker,
body.motion-running .shelf-hero h1,
body.motion-running .shelf-hero .lead,
body.motion-running .shelf-hero .actions-row,
body.motion-running .outcome-note,
body.motion-running .page-hero > * { opacity: 0; }

body.motion-ready .shelf-kicker,
body.motion-ready .shelf-hero h1,
body.motion-ready .shelf-hero .lead,
body.motion-ready .shelf-hero .actions-row,
body.motion-ready .outcome-note,
body.motion-ready .page-hero > * {
  animation: reader-rise .72s var(--motion-ease) both;
}

body.motion-ready .shelf-hero h1,
body.motion-ready .page-hero h1 { animation-delay: .08s; }
body.motion-ready .shelf-hero .lead,
body.motion-ready .page-hero .lead { animation-delay: .18s; }
body.motion-ready .shelf-hero .actions-row { animation-delay: .27s; }
body.motion-ready .outcome-note { animation-delay: .25s; }

@keyframes reader-rise {
  from { opacity: 0; transform: translate3d(0, 24px, 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}

/* Scroll-revealed reading sections */
.motion-reveal { opacity: 0; transform: translate3d(0, 28px, 0); transition: opacity .62s var(--motion-ease), transform .62s var(--motion-ease); }
.motion-reveal.motion-visible { opacity: 1; transform: translate3d(0, 0, 0); }

/* The card picker: volumes settle in one at a time. */
.shelf-frame { position: relative; overflow: hidden; }
.shelf-frame::before {
  position: absolute;
  inset: 0;
  z-index: 0;
  content: "";
  background: linear-gradient(104deg, transparent 0 40%, rgba(0, 113, 227, 0.06) 46%, transparent 54% 100%);
  transform: translateX(-115%);
  pointer-events: none;
}
.shelf-frame.motion-visible::before { animation: shelf-glint 1.15s .18s var(--motion-ease) both; }
.shelf-frame > * { position: relative; z-index: 1; }
.shelf-frame.motion-visible .shelf-book { animation: book-settle .72s var(--motion-snap) both; }
.shelf-frame.motion-visible .shelf-book:nth-child(1) { animation-delay: .04s; }
.shelf-frame.motion-visible .shelf-book:nth-child(2) { animation-delay: .11s; }
.shelf-frame.motion-visible .shelf-book:nth-child(3) { animation-delay: .18s; }
.shelf-frame.motion-visible .shelf-book:nth-child(4) { animation-delay: .25s; }
.shelf-frame.motion-visible .shelf-book:nth-child(5) { animation-delay: .32s; }
.shelf-frame.motion-visible .shelf-book:nth-child(6) { animation-delay: .39s; }
.shelf-book.is-activated { animation: book-pull .42s var(--motion-snap) both !important; }
.shelf-detail.is-selected { animation: spread-open .48s var(--motion-ease) both; }

@keyframes shelf-glint { from { transform: translateX(-115%); } to { transform: translateX(115%); } }
@keyframes book-settle {
  0% { opacity: 0; transform: translate3d(0, 26px, 0) scale(.98); }
  72% { opacity: 1; transform: translate3d(0, -3px, 0) scale(1); }
  100% { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
}
@keyframes book-pull {
  0% { transform: translateY(-6px) scaleX(1); }
  48% { transform: translateY(-14px) scaleX(1.015); }
  100% { transform: translateY(-6px) scaleX(1); }
}
@keyframes spread-open {
  from { opacity: 0; clip-path: inset(0 48% 0 48%); transform: translateY(-12px); }
  to { opacity: 1; clip-path: inset(0 0 0 0); transform: translateY(0); }
}

/* Tabbed route pages use the same opened-spread gesture. */
.route-tab { position: relative; overflow: hidden; }
.route-tab::after { position: absolute; inset: 0 auto 0 0; width: 4px; content: ""; background: var(--accent); transform: scaleY(0); transform-origin: bottom; transition: transform .24s var(--motion-ease); }
.route-tab:hover::after, .route-tab.is-selected::after { transform: scaleY(1); }
.route-panel.is-selected { animation: route-spread .44s var(--motion-ease) both; }
@keyframes route-spread {
  from { opacity: 0; transform: translateX(20px); clip-path: inset(0 0 0 16%); }
  to { opacity: 1; transform: translateX(0); clip-path: inset(0); }
}

/* The nine-step practice: a clean Apple lab surface. */
.lab-shell {
  margin-top: 42px;
  margin-bottom: 72px;
  padding: 0;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
}
.lab-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 21px 24px;
  background: var(--bg-elevated);
  color: var(--fg);
  border-bottom: 1px solid var(--border);
}
.lab-header h1 { font-family: var(--font-display); font-size: clamp(25px, 3vw, 36px); letter-spacing: -0.02em; }
.progress-pill { border-radius: 980px; border: 1px solid var(--border-strong); background: var(--bg); color: var(--fg-2); font-family: var(--font-mono); }
.progress-pill .dot { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); }
.step-rail { border: 0; border-right: 1px solid var(--border); border-radius: 0; background: var(--bg-soft); box-shadow: none; }
.step-rail ol { padding: 8px 0; }
.step-rail button { border-radius: 8px; color: var(--muted); transition: background .2s var(--motion-ease), color .2s var(--motion-ease), transform .2s var(--motion-ease); }
.step-rail button:hover { color: var(--fg); background: rgba(0, 0, 0, 0.05); transform: translateX(4px); }
.step-rail button.is-active { color: var(--accent); background: var(--accent-soft); font-weight: 500; }
.step-rail button.is-done { color: var(--ok); }
.step-rail button.is-done .n { opacity: 1; }
.teach { background: var(--bg-elevated); }
.teach-panel { border: 0; border-radius: 0; background: transparent; box-shadow: none; }
.step-view:not([hidden]) { animation: route-spread .42s var(--motion-ease) both; }
.teach-panel h2 { font-family: var(--font-display); font-size: clamp(31px, 4vw, 46px); letter-spacing: -0.025em; }
.teach-panel .sub { color: var(--fg-2); font-size: 17px; }
.choice-grid { gap: 10px; }
.choice {
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  box-shadow: none;
  transition: transform .18s var(--motion-ease), background .18s var(--motion-ease), box-shadow .18s var(--motion-ease), border-color .18s ease;
}
.choice:hover { border-color: var(--border-strong); background: var(--bg); transform: translateX(4px); }
.choice.is-selected { border-color: var(--accent); background: var(--accent-soft); }
.choice .mark { border-radius: 50%; color: var(--accent); }
.choice.is-selected .mark { color: #fff; background: var(--accent); border-color: var(--accent); }
.hint-box, .rec-card { border-radius: 12px; border-left: 4px solid var(--accent); background: var(--bg-soft); }
.actions-row { gap: 12px; }
.side-panel { align-self: stretch; border: 0; border-left: 1px solid var(--border); border-radius: 0; background: var(--bg-soft); color: var(--fg-2); box-shadow: none; }
.side-panel h3 { color: var(--fg); font-family: var(--font-mono); }
.side-panel .meta { color: var(--meta); }
.side-panel .perm-list { gap: 0; border-top: 1px solid var(--border); }
.side-panel .perm-row { padding: 10px 0; border-bottom: 1px solid var(--border); }
.side-panel .perm-row .k { color: var(--meta); font-weight: 600; }
.side-panel .perm-row .v { color: var(--fg); font-weight: 500; }
.side-panel .risk-badge { border-color: var(--border-strong); }
.side-panel .risk-view { background: var(--ok-soft); color: var(--ok); }
.side-panel .risk-edit { background: var(--warn-soft); color: var(--warn); }
.side-panel .risk-net { background: var(--accent-soft); color: var(--accent); }
.side-panel .risk-high { background: var(--danger-soft); color: var(--danger); }
.side-panel .btn-secondary { color: var(--fg); border-color: var(--border-strong); }
.side-panel .btn-secondary:hover { background: var(--fg); color: #fff; }

/* The long guide: Apple dark — deep black surfaces, bright blue accent. */
body.is-archive-guide {
  --bg: #000000;
  --surface: #1d1d1f;
  --surface-warm: #242426;
  --surface-2: #1a1a1c;
  --surface-3: #2a2a2d;
  --fg: #f5f5f7;
  --fg-2: #d2d2d7;
  --muted: #a1a1a6;
  --meta: #86868b;
  --border: #2e2e30;
  --border-soft: #232325;
  --accent: #2997ff;
  --accent-on: #000000;
  --accent-hover: #47a8ff;
  --accent-active: #0a84ff;
  --success: #30d158;
  --warn: #ffd60a;
  --danger: #ff453a;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
}
body.is-archive-guide > div[style*="position:sticky"] { background: rgba(0, 0, 0, 0.8) !important; color: #d2d2d7 !important; border-bottom-color: #2e2e30 !important; font-family: var(--font-body) !important; backdrop-filter: saturate(180%) blur(20px); }
body.is-archive-guide > div[style*="position:sticky"] a { color: #2997ff !important; }
body.is-archive-guide .studio-intro { background: #000; }
body.is-archive-guide .comic-wipe { background: #2997ff; }
body.is-archive-guide .topnav { background: rgba(0, 0, 0, 0.8); border-bottom-color: #2e2e30; }
body.is-archive-guide .topnav a:hover, body.is-archive-guide .topnav a.is-active { color: #fff; background: rgba(41, 151, 255, 0.16); }

@media (max-width: 980px) {
  .lab-shell { grid-template-columns: 1fr; }
  .step-rail { border-right: 0; border-bottom: 1px solid var(--border); }
  .step-rail ol { padding: 8px; }
  .side-panel { border-left: 0; border-top: 1px solid var(--border); }
}

@media (max-width: 560px) {
  .library-intro-skip { top: 18px; right: 18px; }
  .library-intro-line.line-top, .library-intro-line.line-bottom { right: 24px; left: 24px; }
  .library-intro-line.line-left, .library-intro-line.line-right { top: 15vh; bottom: 15vh; }
  .library-intro-line.line-left { left: 24px; }
  .library-intro-line.line-right { right: 24px; }
  .lab-shell { margin-top: 24px; margin-inline: 0; border-radius: 16px; }
  .lab-header { align-items: flex-start; flex-direction: column; padding: 18px; }
  .progress-pill { font-size: 11px; }
  .teach-panel { padding: 24px 18px; }
  .step-rail button { min-width: 112px; }
  .shelf-detail.is-selected { animation-name: reader-rise; }
}

@media (prefers-reduced-motion: reduce) {
  .motion-reveal { opacity: 1; transform: none; transition: none; }
  .shelf-frame::before, .shelf-plinth::before, .route-tab.is-selected::before { display: none; }
  .library-intro { display: none; }
  body::after { animation: none; }
  .shelf-book:hover, .shelf-book.is-selected { transform: none; box-shadow: none; }
  .btn-primary::after { display: none; }
  .shelf-book.is-selected::before { display: none; }
  .progress-pill .dot { animation: none; }
  .motion-visible .check-list li, .motion-visible .rec-card li,
  .motion-visible .reader-checklist > div, .motion-visible .chapter-card,
  .motion-visible .symptom-card, .motion-visible .route-spec div,
  .choice.is-selected .mark { animation: none; opacity: 1; transform: none; }
}

/* ============================================================
   Animation richness pass (Apple translation, 2026-08)
   Soft light blooms and staggered entrances, in Apple's
   restrained blue-on-neutral language.
   ============================================================ */

/* Ambient light: a faint cool bloom drifts slowly behind the page. */
body::after {
  position: fixed;
  z-index: -1;
  inset: -20%;
  content: "";
  pointer-events: none;
  background:
    radial-gradient(42% 38% at 30% 28%, rgba(0, 113, 227, 0.05), transparent 70%),
    radial-gradient(36% 32% at 74% 62%, rgba(29, 29, 31, 0.04), transparent 70%);
  animation: ambient-drift 46s var(--motion-ease) infinite alternate;
  will-change: transform;
}
@keyframes ambient-drift {
  from { transform: translate3d(-2.5%, -1.5%, 0) scale(1); }
  to   { transform: translate3d(2.5%, 2%, 0) scale(1.06); }
}

/* Selected card keeps a soft breathing glow. */
.shelf-book.is-selected::before {
  position: absolute;
  top: -1px;
  left: 50%;
  width: 26px;
  height: 3px;
  content: "";
  border-radius: 999px;
  background: var(--accent);
  transform: translateX(-50%);
  box-shadow: 0 0 12px 2px rgba(0, 113, 227, 0.5);
  animation: lamp-breathe 3.2s var(--motion-ease) infinite;
  opacity: 0;
}
.shelf-book.is-selected::before { opacity: 1; }
@keyframes lamp-breathe {
  0%, 100% { box-shadow: 0 0 8px 1px rgba(0, 113, 227, 0.35); }
  50% { box-shadow: 0 0 16px 4px rgba(0, 113, 227, 0.6); }
}

/* Picking a card feels alive: a slight lift plus a deeper shadow. */
.shelf-book {
  transition: flex-basis .24s ease, transform .24s var(--motion-snap), box-shadow .24s ease, border-color .24s ease;
}
.shelf-book:hover {
  transform: translateY(-6px);
  box-shadow: 0 18px 26px -14px rgba(0, 0, 0, 0.28);
}
.shelf-book.is-selected {
  transform: translateY(-8px);
  box-shadow: 0 24px 34px -16px rgba(0, 0, 0, 0.3);
}

/* Primary buttons catch a cool gleam as they are hovered. */
.btn-primary { position: relative; overflow: hidden; }
.btn-primary::after {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -60%;
  width: 45%;
  content: "";
  background: linear-gradient(105deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  transform: skewX(-18deg);
  transition: left .55s var(--motion-ease);
}
.btn-primary:hover::after { left: 125%; }
.btn-primary:active::after { transition: none; left: 125%; }

/* Checklist ticks pop in as the section scrolls into view. */
.motion-visible .check-list li,
.motion-visible .rec-card li {
  animation: tick-pop .4s var(--motion-snap) both;
}
.motion-visible .check-list li:nth-child(2) { animation-delay: .06s; }
.motion-visible .check-list li:nth-child(3) { animation-delay: .12s; }
.motion-visible .check-list li:nth-child(4) { animation-delay: .18s; }
.motion-visible .check-list li:nth-child(5) { animation-delay: .24s; }
.motion-visible .rec-card li:nth-child(2) { animation-delay: .06s; }
.motion-visible .rec-card li:nth-child(3) { animation-delay: .12s; }
@keyframes tick-pop {
  0% { opacity: 0; transform: translateX(-8px); }
  70% { opacity: 1; transform: translateX(2px); }
  100% { opacity: 1; transform: translateX(0); }
}

/* Reader checklist columns enter left to right. */
.motion-visible .reader-checklist > div {
  animation: page-in .5s var(--motion-ease) both;
}
.motion-visible .reader-checklist > div:nth-child(2) { animation-delay: .1s; }
.motion-visible .reader-checklist > div:nth-child(3) { animation-delay: .2s; }
@keyframes page-in {
  from { opacity: 0; transform: translate3d(0, 18px, 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}

/* Rule cards cascade like cards being dealt. */
.motion-visible .chapter-card {
  animation: card-deal .52s var(--motion-snap) both;
}
.motion-visible .chapter-card:nth-child(2) { animation-delay: .09s; }
.motion-visible .chapter-card:nth-child(3) { animation-delay: .18s; }
@keyframes card-deal {
  0% { opacity: 0; transform: translate3d(0, 26px, 0) rotate(1.2deg); }
  65% { opacity: 1; transform: translate3d(0, -4px, 0) rotate(-0.4deg); }
  100% { opacity: 1; transform: translate3d(0, 0, 0) rotate(0); }
}

/* Symptom cards rise softly and lift a little more on hover. */
.symptom-card {
  transition: transform .22s var(--motion-ease), box-shadow .22s var(--motion-ease);
}
.motion-visible .symptom-card { animation: page-in .5s var(--motion-ease) both; }
.motion-visible .symptom-card:nth-child(2) { animation-delay: .07s; }
.motion-visible .symptom-card:nth-child(3) { animation-delay: .14s; }
.motion-visible .symptom-card:nth-child(4) { animation-delay: .21s; }
.motion-visible .symptom-card:nth-child(5) { animation-delay: .28s; }
.motion-visible .symptom-card:nth-child(6) { animation-delay: .35s; }
.symptom-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 26px -14px rgba(0, 0, 0, 0.28);
}

/* Route spec cells tick in one by one. */
.motion-visible .route-spec div { animation: page-in .42s var(--motion-ease) both; }
.motion-visible .route-spec div:nth-child(2) { animation-delay: .06s; }
.motion-visible .route-spec div:nth-child(3) { animation-delay: .12s; }

/* Progress dot breathes while the wizard waits for input. */
.progress-pill .dot { animation: dot-breathe 2.6s var(--motion-ease) infinite; }
@keyframes dot-breathe {
  0%, 100% { box-shadow: 0 0 0 3px rgba(52, 199, 89, 0.14); }
  50% { box-shadow: 0 0 0 6px rgba(52, 199, 89, 0.28); }
}

/* Route tabs get a subtle sheen sweep when selected. */
.route-tab.is-selected { position: relative; overflow: hidden; }
.route-tab.is-selected::before {
  position: absolute;
  inset: 0;
  content: "";
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.4) 50%, transparent 70%);
  transform: translateX(-120%);
  animation: tab-sheen 2.8s 1.2s var(--motion-ease) infinite;
}
@keyframes tab-sheen {
  0% { transform: translateX(-120%); }
  60%, 100% { transform: translateX(120%); }
}

/* Selected choice marks settle with a small bounce. */
.choice.is-selected .mark { animation: mark-settle .38s var(--motion-snap) both; }
@keyframes mark-settle {
  0% { transform: scale(.4); }
  70% { transform: scale(1.18); }
  100% { transform: scale(1); }
}
