/* 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; }

@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;
}

/* 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;
}
