:root {
  --bg: #0b0d1c;
  --bg-2: #12152b;
  --surface: #181c38;
  --text: #f5f0e6;
  --muted: #aaa6c4;
  --faint: #6f6c8f;
  --gold: #ffd27d;
  --gold-deep: #f2b84b;
  --lilac: #b9a7ff;
  --ring: 0 0 0 3px var(--bg), 0 0 0 6px var(--gold);
  --radius: 14px;
  --gutter: clamp(16px, 4vw, 64px);
  --display: 'Baloo 2', 'Nunito', system-ui, sans-serif;
  --body: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html {
  font-size: clamp(15px, 0.55vw + 10px, 22px);
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }
a { color: inherit; -webkit-tap-highlight-color: transparent; }

:focus { outline: none; }
:focus-visible { outline: none; box-shadow: var(--ring); }

/* ---------- Bara de sus ---------- */

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  height: calc(4.2rem + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(var(--gutter), env(safe-area-inset-right)) 0 max(var(--gutter), env(safe-area-inset-left));
  background: linear-gradient(to bottom, rgba(11, 13, 28, 0.85), rgba(11, 13, 28, 0));
  pointer-events: none;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  white-space: nowrap;
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.7rem;
  letter-spacing: 0.01em;
  color: var(--gold);
  text-decoration: none;
  pointer-events: auto;
  border-radius: 10px;
  padding: 0.1rem 0.4rem;
}

.logo svg { width: 1.6rem; height: 1.6rem; fill: var(--gold); flex: none; }
.logo span { overflow: hidden; text-overflow: ellipsis; }

/* Pentru cine sunt poveștile */
.who {
  position: relative;
  flex: none;
  margin-left: auto;
  pointer-events: auto;
}

.who-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.6rem;
  padding: 0 1rem 0 0.8rem;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
  backdrop-filter: blur(6px);
}

.who-btn svg { width: 1.1rem; height: 1.1rem; fill: var(--gold); }
.who-label { color: var(--muted); font-weight: 700; }
.who-btn:hover { background: rgba(255, 255, 255, 0.18); }

.who-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.5rem);
  display: flex;
  flex-direction: column;
  min-width: 12rem;
  padding: 0.4rem;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
}

.who-menu[hidden] { display: none; }

.who-menu button {
  padding: 0.65rem 0.9rem;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--text);
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.who-menu button:hover { background: rgba(255, 255, 255, 0.08); }
.who-menu button[aria-pressed='true'] { color: var(--gold); }
.who-menu button[aria-pressed='true']::after { content: ' ✓'; }

/* ---------- Hero ---------- */

.hero {
  position: relative;
  height: min(86vh, 56.25vw + 4rem);
  min-height: 26rem;
  overflow: hidden;
  isolation: isolate;
}

.hero-stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -2;
  background: var(--bg-2);
}

.hero-stage canvas {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity 1.2s ease;
}

.hero-stage canvas.ready { opacity: 1; }

.hero::before,
.hero::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

.hero::before {
  background: linear-gradient(90deg, rgba(11, 13, 28, 0.92) 0%, rgba(11, 13, 28, 0.6) 34%, rgba(11, 13, 28, 0) 64%);
}

.hero::after {
  background: linear-gradient(to top, var(--bg) 0%, rgba(11, 13, 28, 0.55) 18%, rgba(11, 13, 28, 0) 42%);
}

.hero-content {
  position: absolute;
  left: var(--gutter);
  bottom: clamp(3.5rem, 12vh, 8rem);
  max-width: min(36rem, 88vw);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.4rem;
  font-weight: 800;
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
}

.eyebrow::before {
  content: '';
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 12px var(--gold);
}

.hero-title {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(2.6rem, 5.4vw, 5rem);
  line-height: 0.98;
  letter-spacing: -0.01em;
  text-wrap: balance;
  text-shadow: 0 4px 30px rgba(0, 0, 0, 0.45);
}

.hero-tagline {
  margin: 0.5rem 0 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.35rem;
  color: #ffe7b8;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.9rem;
  margin: 0.8rem 0 0;
  padding: 0;
  list-style: none;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--muted);
}

.meta li + li::before {
  content: '·';
  margin-right: 0.9rem;
  color: var(--faint);
}

.meta .age {
  padding: 0 0.45rem;
  border: 1.5px solid var(--muted);
  border-radius: 6px;
  line-height: 1.4;
}

.hero-desc {
  margin: 0.9rem 0 0;
  font-size: 1.05rem;
  color: #dcd7ea;
  max-width: 34rem;
  text-wrap: pretty;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-top: 1.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  min-height: 3.2rem;
  padding: 0 1.6rem 0 1.3rem;
  border: 0;
  border-radius: 999px;
  font-weight: 800;
  font-size: 1.1rem;
  cursor: pointer;
  transition: transform 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease;
}

.btn svg { width: 1.3rem; height: 1.3rem; fill: currentColor; flex: none; }

.btn-primary {
  background: var(--gold);
  color: #2a1d05;
}

.btn-primary:hover { background: #ffdd99; }

.btn-ghost {
  background: rgba(255, 255, 255, 0.14);
  color: var(--text);
  backdrop-filter: blur(6px);
}

.btn-ghost:hover { background: rgba(255, 255, 255, 0.22); }

.btn:focus-visible { transform: scale(1.06); }

.btn .progress-pill {
  font-weight: 700;
  font-size: 0.85rem;
  opacity: 0.8;
}

/* ---------- Rânduri de povești ---------- */

.rows {
  position: relative;
  z-index: 2;
  margin-top: -2.5rem;
  padding-bottom: 4rem;
}

.row { margin: 0 0 2.2rem; }

.row-title {
  margin: 0 var(--gutter) 0.7rem;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.45rem;
}

.row-track {
  display: flex;
  gap: clamp(0.8rem, 1.4vw, 1.3rem);
  overflow-x: auto;
  overflow-y: visible;
  padding: 0.9rem var(--gutter) 1.2rem;
  scroll-padding-inline: var(--gutter);
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}

.row-track::-webkit-scrollbar { display: none; }

.card {
  position: relative;
  flex: none;
  width: clamp(15rem, 24vw, 24rem);
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  scroll-snap-align: start;
  transition: transform 0.22s ease, box-shadow 0.22s ease;
}

.card-art {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius) var(--radius) 0 0;
  overflow: hidden;
  background: var(--bg-2);
}

.card-art canvas,
.card-art img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-art::after {
  content: '';
  position: absolute;
  inset: 45% 0 0;
  background: linear-gradient(to top, rgba(11, 13, 28, 0.85), rgba(11, 13, 28, 0));
}

.card-badge {
  position: absolute;
  z-index: 1;
  top: 0.6rem;
  left: 0.6rem;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  background: rgba(11, 13, 28, 0.72);
  font-weight: 800;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gold);
}

.card-duration {
  position: absolute;
  z-index: 1;
  right: 0.7rem;
  bottom: 0.5rem;
  font-weight: 800;
  font-size: 0.85rem;
  color: #fff;
}

.card-body {
  display: block;
  padding: 0.7rem 0.9rem 0.9rem;
}

.card-title {
  display: block;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.2rem;
  line-height: 1.2;
}

.card-tagline {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.card-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
}

.card-progress i {
  display: block;
  height: 100%;
  background: var(--gold);
}

.card:focus-visible {
  transform: scale(1.06);
  z-index: 3;
}

@media (hover: hover) {
  .card:hover {
    transform: scale(1.06);
    z-index: 3;
  }
}

.card:focus-visible { box-shadow: var(--ring), 0 18px 40px rgba(0, 0, 0, 0.5); }

.empty-note {
  margin: 0 var(--gutter);
  color: var(--muted);
}

/* ---------- Player ---------- */

.player {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: #000;
  cursor: none;
  animation: fade-in 0.5s ease;
}

.player.show-chrome { cursor: default; }

.player canvas.stage {
  display: block;
  background: #000;
}

.player .dimmer {
  position: absolute;
  inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.player .blackout {
  position: absolute;
  inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
}

.subtitles {
  position: absolute;
  left: 50%;
  bottom: 9%;
  transform: translateX(-50%);
  width: min(56rem, 88vw);
  text-align: center;
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(1.1rem, 2.2vw, 1.8rem);
  line-height: 1.3;
  color: #fff7e6;
  text-shadow: 0 2px 4px #000, 0 0 18px rgba(0, 0, 0, 0.9);
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.player:not(.subs-on) .subtitles { display: none; }

.chrome {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.player.show-chrome .chrome {
  opacity: 1;
  pointer-events: auto;
}

.chrome-top,
.chrome-bottom {
  padding: 1.2rem max(var(--gutter), env(safe-area-inset-right)) 1.2rem max(var(--gutter), env(safe-area-inset-left));
}

.chrome-top { padding-top: max(1.2rem, env(safe-area-inset-top)); }
.chrome-bottom { padding-bottom: max(1.2rem, env(safe-area-inset-bottom)); }

.chrome-top {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0));
}

.chrome-title {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.4rem;
  line-height: 1.15;
}

.chrome-title small {
  display: block;
  font-family: var(--body);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--muted);
}

.chrome-bottom {
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0));
  padding-top: 3rem;
}

.icon-btn {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 3rem;
  height: 3rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.15s ease;
}

.icon-btn:hover { background: rgba(255, 255, 255, 0.24); }
.icon-btn:focus-visible { transform: scale(1.1); }
.icon-btn svg { width: 1.45rem; height: 1.45rem; fill: currentColor; }
.icon-btn.big { width: 3.8rem; height: 3.8rem; background: var(--gold); color: #2a1d05; }
.icon-btn.big svg { width: 1.8rem; height: 1.8rem; }
.icon-btn[aria-pressed='true'] { background: rgba(255, 210, 125, 0.3); color: var(--gold); }

.scrubber {
  position: relative;
  height: 1.6rem;
  cursor: pointer;
  touch-action: none;
}

.scrubber-track {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 6px;
  margin-top: -3px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.22);
  overflow: hidden;
}

.scrubber-fill {
  height: 100%;
  width: 0;
  background: var(--gold);
}

.scrubber-tick {
  position: absolute;
  top: 50%;
  width: 3px;
  height: 10px;
  margin: -5px 0 0 -1.5px;
  border-radius: 2px;
  background: rgba(11, 13, 28, 0.9);
}

.scrubber-knob {
  position: absolute;
  top: 50%;
  width: 1.1rem;
  height: 1.1rem;
  margin: -0.55rem 0 0 -0.55rem;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 4px rgba(255, 210, 125, 0.25);
}

.controls {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-top: 0.6rem;
}

.controls .spacer { flex: 1; }

.time {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  min-width: 7.5rem;
  white-space: nowrap;
}

/* „Întoarce telefonul” — doar pe telefon ținut vertical */
.rotate-hint {
  position: absolute;
  top: 16%;
  left: 50%;
  display: none;
  align-items: center;
  gap: 0.7rem;
  max-width: 88vw;
  padding: 0.7rem 1.1rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: #ffe7b8;
  font-weight: 800;
  font-size: 0.95rem;
  transform: translateX(-50%);
  pointer-events: none;
}

.rotate-hint svg { width: 1.6rem; height: 1.6rem; fill: currentColor; flex: none; }

@media (orientation: portrait) and (pointer: coarse) {
  .rotate-hint { display: flex; }
}

.chapter-name {
  font-weight: 700;
  color: #fff;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.center-state {
  position: absolute;
  left: 50%;
  top: 50%;
  display: grid;
  place-items: center;
  width: 6.5rem;
  height: 6.5rem;
  margin: -3.25rem 0 0 -3.25rem;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}

.center-state svg { width: 3rem; height: 3rem; fill: #fff; }
.player.paused .center-state { opacity: 1; transform: scale(1); }

.toast {
  position: absolute;
  top: 12%;
  left: 50%;
  padding: 0.6rem 1.2rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.65);
  font-weight: 800;
  transform: translate(-50%, -10px);
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}

.toast.on { opacity: 1; transform: translate(-50%, 0); }

.end-card {
  position: absolute;
  inset: auto 0 12% 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 1.5s ease;
}

.player.ended .end-card {
  opacity: 1;
  pointer-events: auto;
}

.end-card p {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.6rem;
  color: rgba(255, 231, 184, 0.75);
}

.end-card .actions { margin: 0; }
.end-card .btn { opacity: 0.8; }

.loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 700;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

body.playing { overflow: hidden; }
body.playing #app { visibility: hidden; }

@media (max-width: 640px) {
  .hero { height: 78vh; min-height: 32rem; }
  .hero::before { background: linear-gradient(to top, rgba(11, 13, 28, 0.95) 10%, rgba(11, 13, 28, 0.2) 70%); }
  .hero-content { right: var(--gutter); bottom: 3rem; }
  .actions .btn { flex: 1 1 auto; }
  .controls { gap: 0.5rem; }
  .time { min-width: 0; font-size: 0.85rem; }
  .chapter-name { display: none; }
}

/* telefon ținut vertical: logo mai mic, comenzile pe două rânduri */
@media (max-width: 480px) {
  .logo { font-size: 1.35rem; }
  .who-label { display: none; }
  .who-btn { min-height: 2.4rem; padding: 0 0.85rem 0 0.7rem; }
  .controls { flex-wrap: wrap; row-gap: 0.7rem; }
  .controls .spacer { flex-basis: 100%; height: 0; }
  .controls .icon-btn { width: 2.9rem; height: 2.9rem; }
  .controls .icon-btn.big { width: 3.4rem; height: 3.4rem; }
}

/* ecran jos (telefon ținut orizontal): hero-ul încape fără descrierea lungă */
@media (max-height: 520px) {
  .hero { height: 100vh; height: 100svh; min-height: 0; }
  .hero-content { bottom: 1.4rem; }
  .hero-title { font-size: clamp(1.9rem, 5vw, 2.8rem); }
  .hero-tagline { margin-top: 0.2rem; font-size: 1.05rem; }
  .meta { margin-top: 0.4rem; }
  .hero-desc { display: none; }
  .actions { margin-top: 0.9rem; }
  .btn { min-height: 2.8rem; }
  .rows { margin-top: 0; }
  .chrome-bottom { padding-top: 1.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
