/* ui.css — iPhone frame, screen layout, swipe UI, pause overlay.
   Scene animations live in style.css. */

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  height: 100%;
  background: #111;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #f5f5f5;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
}

.iphone {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.frame {
  position: relative;
  width: 100%; height: 100%;
  background: #000;
  overflow: hidden;
}

body.dev-frame .iphone {
  width: min(390px, 100vw);
  height: min(844px, 100vh);
}
body.dev-frame .frame {
  border-radius: 44px;
  box-shadow: 0 0 0 6px #1a1a1a, 0 20px 60px #000a;
}

@media (min-width: 700px) {
  body:not(.dev-frame) .iphone {
    width: min(560px, 100vw);
  }
}
.dynamic-island {
  position: absolute;
  top: 12px; left: 50%;
  transform: translateX(-50%);
  width: 110px; height: 32px;
  background: #000;
  border-radius: 20px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 10px;
}
#mute-btn {
  background: transparent;
  border: 0;
  padding: 4px;
  cursor: pointer;
  color: #fff;
  display: flex;
  align-items: center;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: #0a0a10;
  touch-action: pan-x;
}

.text-area {
  position: relative;
  flex: 0 0 66%;
  padding:
    calc(60px + env(safe-area-inset-top))
    calc(24px + env(safe-area-inset-right))
    16px
    calc(24px + env(safe-area-inset-left));
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.chapter-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #8a8a98;
  margin-bottom: 12px;
}
.card-body {
  flex: 1;
  font-size: clamp(16px, 4.5vw, 22px);
  line-height: 1.5;
  color: #f5f5f5;
}
.card-body em { color: #e8c070; font-style: italic; }
.card-body q  { color: #e8c070; }
.speaker-label {
  margin-top: 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #e8c070;
  min-height: 14px;
}

.animation-canvas {
  flex: 1;
  position: relative;
  background: #000;
  overflow: hidden;
  transition: opacity .3s ease;
}
.animation-canvas.fading { opacity: 0; }
/* `.scn` wrapper injected by Scenes.get() must fill the canvas so absolutely-
   positioned per-scene child elements have a sized reference frame. */
.animation-canvas .scn { position: absolute !important; inset: 0 !important; overflow: hidden; }

/* EXP14 continuity overlays — composable modifiers stacked on top of the
   base .scn-<location>. App.js sets mod-time-*, mod-season-*, mod-weather-*,
   mod-lighting-* on .animation-canvas based on card meta. Each modifier
   contributes a fixed-position overlay layer (color tint, particles, etc).
   Modifiers compose (a card can be night + winter + snowstorm). Pointer
   events disabled so overlays never block touch. */
.animation-canvas { position: relative; }
.animation-canvas[class*="mod-"]::before,
.animation-canvas[class*="mod-"]::after {
  content: ''; position: absolute; inset: 0;
  pointer-events: none; z-index: 5;
}
/* time-of-day tints (::before is the time tint) */
.animation-canvas.mod-time-dawn::before    { background: linear-gradient(180deg, rgba(255,180,140,.35), rgba(255,220,180,.10) 60%, transparent); }
.animation-canvas.mod-time-morning::before { background: linear-gradient(180deg, rgba(255,235,200,.20), transparent); }
.animation-canvas.mod-time-noon::before    { background: rgba(255,250,230,.05); }
.animation-canvas.mod-time-afternoon::before { background: linear-gradient(180deg, rgba(255,210,170,.18), transparent); }
.animation-canvas.mod-time-dusk::before    { background: linear-gradient(180deg, rgba(120,60,120,.30), rgba(220,120,80,.20) 60%, transparent); }
.animation-canvas.mod-time-night::before   { background: radial-gradient(ellipse at 50% 30%, rgba(20,30,60,.45), rgba(5,10,30,.75)); }
/* season + weather (::after is the particle/atmosphere layer) */
.animation-canvas.mod-season-winter::after  { background: linear-gradient(180deg, rgba(220,235,255,.15), rgba(180,210,240,.05)); }
.animation-canvas.mod-season-summer::after  { background: radial-gradient(ellipse at 70% 20%, rgba(255,240,180,.20), transparent 60%); }
.animation-canvas.mod-season-autumn::after  { background: linear-gradient(180deg, rgba(180,100,40,.15), transparent); }
.animation-canvas.mod-season-spring::after  { background: linear-gradient(180deg, rgba(180,255,200,.10), transparent); }
.animation-canvas.mod-weather-snowstorm::after,
.animation-canvas.mod-weather-snow::after {
  background-image:
    radial-gradient(2px 2px at 20% 30%, white, transparent),
    radial-gradient(2px 2px at 70% 60%, white, transparent),
    radial-gradient(1px 1px at 40% 80%, white, transparent),
    radial-gradient(2px 2px at 85% 20%, white, transparent);
  background-size: 200px 200px;
  animation: mod-snowdrift 8s linear infinite;
  opacity: .75;
}
.animation-canvas.mod-weather-rain::after {
  background-image: linear-gradient(180deg, rgba(180,200,220,.6) 0%, transparent 4%);
  background-size: 2px 24px;
  animation: mod-rainfall 0.6s linear infinite;
  opacity: .55;
}
.animation-canvas.mod-weather-fog::after {
  background: linear-gradient(180deg, rgba(220,220,225,.55), rgba(200,200,210,.35) 50%, rgba(180,180,190,.25));
  filter: blur(2px);
}
@keyframes mod-snowdrift { 0% { background-position: 0 0; } 100% { background-position: 100px 200px; } }
@keyframes mod-rainfall  { 0% { background-position: 0 0; } 100% { background-position: 0 24px; } }
/* mod-lighting (overrides season tint when both present) */
.animation-canvas.mod-lighting-firelit::before { background: radial-gradient(ellipse at 50% 70%, rgba(255,140,60,.30), transparent 60%); }
.animation-canvas.mod-lighting-moonlit::before { background: radial-gradient(ellipse at 50% 30%, rgba(160,180,220,.30), rgba(20,30,60,.50)); }
.animation-canvas.mod-lighting-candlelit::before { background: radial-gradient(circle at 50% 60%, rgba(255,180,80,.30), transparent 50%); }
.animation-canvas.mod-lighting-sunlit::before { background: radial-gradient(ellipse at 70% 20%, rgba(255,240,180,.25), transparent 70%); }

@media (prefers-reduced-motion: reduce) {
  .text-area, .animation-canvas { transition: none !important; animation: none !important; }
}

.progress {
  position: absolute;
  bottom: calc(8px + env(safe-area-inset-bottom)); left: 16px; right: 16px;
  height: 3px;
  background: #ffffff20;
  border-radius: 2px;
  overflow: hidden;
}
#progress-bar {
  height: 100%;
  width: 0%;
  background: #e8c070;
  transition: width .25s ease;
}

.splash {
  position: absolute; inset: 0;
  z-index: 100;
  background: #0a0a10;
  display: flex; align-items: center; justify-content: center;
  transition: opacity .5s ease;
}
.splash.hidden {
  opacity: 0;
  pointer-events: none;
}
.splash-inner {
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
}
.splash-icon {
  width: 80px; height: 80px; border-radius: 20px;
}
.splash-title {
  font-size: 22px; font-weight: 600; line-height: 1.3;
  color: #f5f5f5;
}
.splash-author {
  font-size: 14px; color: #8a8a98;
  font-style: italic;
}
.splash-status {
  font-size: 13px; color: #8a8e9a;
  font-family: ui-monospace, monospace;
}
.splash-tap {
  margin-top: 12px; font-size: 15px; color: #e8c070;
  animation: pulse-tap 2s ease-in-out infinite;
}
@keyframes pulse-tap {
  0%,100% { opacity: .6; }
  50% { opacity: 1; }
}

/* Card transition — vertical (downward-swipe to advance) */
.text-area.swipe-out-up   { animation: swipeOutUp   .25s ease forwards; }
.text-area.swipe-out-down { animation: swipeOutDown .25s ease forwards; }
.text-area.swipe-in-down  { animation: swipeInDown  .25s ease forwards; }
.text-area.swipe-in-up    { animation: swipeInUp    .25s ease forwards; }

@keyframes swipeOutUp   { to { transform: translateY(-30%); opacity: 0; } }
@keyframes swipeOutDown { to { transform: translateY( 30%); opacity: 0; } }
@keyframes swipeInDown  { from { transform: translateY( 30%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes swipeInUp    { from { transform: translateY(-30%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ═══════════════════════════════════════════════════
   PAUSE OVERLAY
   ═══════════════════════════════════════════════════ */
.pause-overlay {
  position: absolute; inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity .3s ease;
}
.pause-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}
.pause-scrim {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, .65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.pause-content {
  position: relative;
  z-index: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 0 16px;
}

/* Transport buttons */
.transport {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 32px;
}
.transport-btn {
  background: rgba(255,255,255,.1);
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s ease, transform .15s ease;
}
.transport-btn:active {
  transform: scale(.9);
  background: rgba(255,255,255,.2);
}
.transport-btn.play-btn {
  width: 72px; height: 72px;
  background: rgba(232, 192, 112, .25);
  border: 2px solid rgba(232, 192, 112, .5);
}
.transport-btn.play-btn:active {
  background: rgba(232, 192, 112, .4);
}
.transport-btn:not(.play-btn) {
  width: 48px; height: 48px;
}

/* Autoplay (robot) toggle — sits below the transport row */
.autoplay-btn {
  display: flex; align-items: center; justify-content: center;
  width: 56px; height: 56px;
  margin: 12px auto 0;
  border-radius: 50%;
  border: 2px solid rgba(232, 192, 112, .3);
  background: rgba(255, 255, 255, .05);
  color: #b0b0c8;
  cursor: pointer;
  transition: background .2s ease, color .2s ease, border-color .2s ease, transform .2s ease;
}
.autoplay-btn:hover { background: rgba(255, 255, 255, .12); }
.autoplay-btn:active { transform: scale(.92); }
.autoplay-btn.active {
  background: rgba(232, 192, 112, .25);
  border-color: rgba(232, 192, 112, .9);
  color: #e8c070;
  box-shadow: 0 0 12px rgba(232, 192, 112, .35);
}
.autoplay-btn.active svg { animation: autoplay-bob 2.4s ease-in-out infinite; }
@keyframes autoplay-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

/* Section label */
.section-label {
  font-size: 12px;
  color: #8a8a98;
  letter-spacing: 1px;
  text-transform: uppercase;
  text-align: center;
}

/* ═══ Section carousel — overlapping 3D stack ═══ */
.section-carousel {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 20px 0;
  /* No edge mask — cards overlap and peek from the sides */
}
.section-carousel::-webkit-scrollbar { display: none; }

.section-track {
  display: flex;
  /* Negative gap creates the overlap effect */
  gap: -40px;
  padding: 0 calc(50% - 120px); /* center the active card */
  width: max-content;
  align-items: center;
}

.section-card {
  flex-shrink: 0;
  width: 240px;
  height: 168px;
  background: rgba(30, 28, 40, .92);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 16px;
  cursor: pointer;
  overflow: hidden;
  position: relative;
  /* Overlap: each card peeks from behind the next */
  margin-right: -40px;
  /* Receded state by default */
  transform: scale(.82);
  opacity: .55;
  z-index: 1;
  transition: transform .35s cubic-bezier(.4,0,.2,1),
              opacity .35s ease,
              z-index 0s,
              background .3s ease,
              border-color .3s ease,
              box-shadow .35s ease;
  box-shadow: 0 4px 20px rgba(0,0,0,.3);
}
.section-card:last-child {
  margin-right: 0;
}
.section-card:active {
  transform: scale(.78);
}

/* Active (center) card — pops forward and grows */
.section-card.active {
  transform: scale(1);
  opacity: 1;
  z-index: 10;
  background: rgba(40, 35, 55, .95);
  border-color: rgba(232, 192, 112, .5);
  box-shadow: 0 8px 40px rgba(0,0,0,.5), 0 0 20px rgba(232, 192, 112, .1);
}
.section-card.active:active {
  transform: scale(.96);
}

/* Neighbors of active — slightly more visible than distant cards */
.section-card.near-active {
  transform: scale(.88);
  opacity: .7;
  z-index: 5;
}

.section-card .sc-num {
  font-size: 16px;
  font-weight: 700;
  color: #e8c070;
  letter-spacing: .5px;
}
.section-card .sc-title {
  font-size: 17px;
  color: #bbb;
  text-align: center;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
}
.section-card.active .sc-num {
  font-size: 18px;
}
.section-card.active .sc-title {
  color: #e8c070;
  font-size: 18px;
}

/* ---------------------------------------------------------------- */
/* Tier toggle (3-switch) — inserted by app.js into the pause       */
/* overlay only when running a 3-switch bundle (versions.json       */
/* present + TierSwitch loaded). Tablet-shaped horizontal pill row  */
/* near the top of the pause overlay.                                */
/* ---------------------------------------------------------------- */
.tier-toggle {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: stretch;
  gap: 8px;
  margin: 12px auto 18px;
  padding: 6px;
  width: min(92%, 540px);
  background: rgba(20, 20, 28, 0.85);
  border: 1px solid rgba(232, 192, 112, 0.35);
  border-radius: 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}
.tier-btn {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 10px 8px;
  background: rgba(40, 40, 50, 0.6);
  color: #cfcfd6;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  cursor: pointer;
  transition: background 180ms ease, color 180ms ease,
              border-color 180ms ease, transform 100ms ease;
  font-family: inherit;
}
.tier-btn:hover {
  background: rgba(60, 60, 75, 0.75);
  color: #fff;
}
.tier-btn:active {
  transform: scale(0.97);
}
.tier-btn .tier-letter {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: inherit;
}
.tier-btn .tier-name {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  opacity: 0.85;
}
.tier-btn .tier-count {
  font-size: 10px;
  opacity: 0.65;
  margin-top: 2px;
}
.tier-btn.active {
  background: linear-gradient(180deg, #4a3520 0%, #6b4a2a 100%);
  color: #ffe4b5;
  border-color: #e8c070;
  box-shadow: inset 0 -2px 0 rgba(232, 192, 112, 0.65),
              0 2px 8px rgba(232, 192, 112, 0.18);
}
.tier-btn.active .tier-letter {
  color: #ffd97a;
}
.tier-btn.active .tier-name {
  color: #ffe4b5;
  opacity: 1;
}

/* End-of-book outro scene — synthetic last card appended by app.js
   appendOutroCard(). Card body shows the "This concludes…" text; canvas
   renders an ambient Swipe-N glow with the same 3s slow-sway language as
   story scenes. No text inside the canvas. */
.animation-canvas .scn-swipe-n-outro {
  background:
    radial-gradient(ellipse at 50% 35%, rgba(255, 220, 140, 0.35), transparent 55%),
    radial-gradient(ellipse at 50% 80%, rgba(120, 80, 40, 0.45), transparent 60%),
    linear-gradient(180deg, #1a1228 0%, #2a1a3a 55%, #14102a 100%);
}
.animation-canvas .scn-swipe-n-outro::before {
  content: '';
  position: absolute;
  inset: 30% 30% 30% 30%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 230, 170, 0.55), rgba(255, 200, 110, 0.25) 45%, transparent 70%);
  filter: blur(8px);
  animation: swipe-n-outro-breathe 6s ease-in-out infinite alternate;
}
.animation-canvas .scn-swipe-n-outro::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(2px 2px at 18% 22%, rgba(255, 230, 170, 0.5), transparent),
    radial-gradient(2px 2px at 78% 30%, rgba(255, 230, 170, 0.4), transparent),
    radial-gradient(2px 2px at 30% 75%, rgba(255, 230, 170, 0.45), transparent),
    radial-gradient(2px 2px at 70% 80%, rgba(255, 230, 170, 0.35), transparent),
    radial-gradient(1px 1px at 50% 50%, rgba(255, 230, 170, 0.5), transparent);
  animation: swipe-n-outro-drift 24s linear infinite;
}
@keyframes swipe-n-outro-breathe {
  from { transform: scale(0.96); opacity: 0.75; }
  to   { transform: scale(1.04); opacity: 1; }
}
@keyframes swipe-n-outro-drift {
  from { transform: translate3d(0, 0, 0); }
  to   { transform: translate3d(0, -8px, 0); }
}
