/* ============================================================================
   aulas — player no formato cinema.
   Tela cheia, fundo sempre preto, sem moldura 16:9 e sem cabeçalho.
   A arte vem das cenas (canvas 2D, uma por cena); aqui ficam tipografia,
   cartela, legenda, chrome e a textura de projeção.
   ========================================================================== */

@font-face {
  font-family: "Bricolage Grotesque";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("./fonts/bricolage-latin.woff2") format("woff2");
}
@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("./fonts/space-grotesk-latin.woff2") format("woff2");
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("./fonts/jetbrains-mono-latin.woff2") format("woff2");
}

:root {
  color-scheme: dark;

  --preto: #05060c;
  --noite: #0b0c16;
  --creme: #fbf1de;
  --coral: #ff6a4d;
  --ambar: #ffc24b;
  --turquesa: #12bda1;
  --indigo: #4b5bff;
  --lilas: #b79cff;

  --fonte-titulo: "Bricolage Grotesque", "Trebuchet MS", system-ui, sans-serif;
  --fonte-texto: "Space Grotesk", "Trebuchet MS", system-ui, sans-serif;
  --fonte-mono: "JetBrains Mono", ui-monospace, "Courier New", monospace;

  /* --zona-altura: faixa reservada no rodapé para a legenda. O app.js escreve
     aqui o mesmo valor de cenas/_kit.js (ZONA), então arte e legenda nunca
     discordam do tamanho da faixa. */
  --zona-altura: 112px;
  --chrome-altura: 52px;

  --foco: var(--ambar);
  --respiro: clamp(14px, 3.2vw, 30px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--preto);
  color: var(--creme);
  font-family: var(--fonte-texto);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  position: fixed;
  inset: 0;
}

body[data-ocioso="1"] {
  cursor: none;
}

::selection {
  background: var(--coral);
  color: var(--noite);
}

:focus-visible {
  outline: 2px solid var(--foco);
  outline-offset: 3px;
  border-radius: 3px;
}

/* ------------------------------------------------------------------ palco - */

.tela {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
  background: var(--preto);
  isolation: isolate;
  touch-action: manipulation;
}

/* as cenas são empilhadas aqui; a de cima cobre a de baixo */
.palco {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.cena {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 380ms cubic-bezier(0.22, 0.61, 0.36, 1);
  will-change: opacity;
}

.cena--visivel {
  opacity: 1;
}

/* congelado (?t=) e movimento reduzido: sem transição, sem flash */
html[data-congelado="1"] .cena,
html[data-reduzido="1"] .cena {
  transition: none;
}

/* --------------------------------------------------------- textura de filme - */

.grao {
  position: absolute;
  inset: -20%;
  z-index: 4;
  pointer-events: none;
  opacity: 0.05;
  mix-blend-mode: soft-light;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.86' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 220px 220px;
}

.vinheta {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  background:
    radial-gradient(120% 95% at 50% 48%, rgba(5, 6, 12, 0) 46%, rgba(5, 6, 12, 0.3) 78%, rgba(3, 4, 9, 0.72) 100%),
    linear-gradient(to top, rgba(3, 4, 9, 0.6) 0%, rgba(3, 4, 9, 0) 22%);
}

/* ----------------------------------------------------------------- cartela - */

.cartela {
  position: absolute;
  inset: 0;
  z-index: 9;
  display: flex;
  align-items: flex-end;
  padding: clamp(26px, 6.5vw, 96px);
  padding-bottom: clamp(84px, 18vh, 190px);
  pointer-events: none;
  background: linear-gradient(
    90deg,
    rgba(4, 5, 11, 0.975) 0%,
    rgba(4, 5, 11, 0.95) 32%,
    rgba(4, 5, 11, 0.74) 62%,
    rgba(4, 5, 11, 0.32) 100%
  );
  opacity: 0;
}

.cartela[hidden] {
  display: none;
}

.cartela__bloco {
  max-width: min(74vw, 900px);
}

.cartela__olho {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 clamp(12px, 2vh, 22px);
  color: var(--ambar);
  font-family: var(--fonte-mono);
  font-size: clamp(9px, 0.82vw, 11px);
  font-weight: 500;
  letter-spacing: 0.2em;
  line-height: 1;
  text-transform: uppercase;
}

.cartela__risco {
  display: block;
  width: clamp(30px, 4.5vw, 64px);
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left center;
}

.cartela__titulo {
  margin: 0;
  color: var(--creme);
  font-family: var(--fonte-titulo);
  font-size: clamp(46px, 7.5vw, 112px);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 0.9;
}

.cartela__pe {
  margin: clamp(16px, 2.4vh, 28px) 0 0;
  color: rgba(251, 241, 222, 0.48);
  font-family: var(--fonte-mono);
  font-size: clamp(9px, 0.8vw, 11px);
  font-weight: 400;
  letter-spacing: 0.18em;
  line-height: 1;
  text-transform: uppercase;
}

/* ----------------------------------------------------------------- legenda - */

.legenda {
  position: absolute;
  left: 50%;
  bottom: calc(var(--chrome-altura) + 8px);
  z-index: 8;
  width: min(92vw, 780px);
  transform: translateX(-50%);
  pointer-events: none;
  text-align: center;
  opacity: 0;
}

.legenda p {
  margin: 0;
  color: rgba(251, 241, 222, 0.86);
  font-family: var(--fonte-texto);
  font-size: clamp(12.5px, 1.02vw, 15px);
  font-weight: 400;
  letter-spacing: 0.002em;
  line-height: 1.42;
  text-wrap: balance;
  text-shadow: 0 1px 14px rgba(3, 4, 9, 0.9), 0 0 3px rgba(3, 4, 9, 0.7);
}

/* ------------------------------------------------------------------- erro - */

.erro {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 11;
  width: min(88vw, 520px);
  padding: clamp(20px, 3vw, 32px);
  transform: translate(-50%, -50%);
  border: 1px solid rgba(251, 241, 222, 0.14);
  border-radius: 4px;
  background: rgba(6, 7, 14, 0.86);
  color: var(--creme);
  text-align: center;
  backdrop-filter: blur(10px);
}

.erro[hidden] {
  display: none;
}

.erro h2 {
  margin: 0;
  font-family: var(--fonte-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  line-height: 1;
  text-transform: uppercase;
  color: var(--coral);
}

.erro p {
  margin: 14px 0 0;
  font-family: var(--fonte-texto);
  font-size: 14px;
  line-height: 1.5;
  color: rgba(251, 241, 222, 0.78);
  overflow-wrap: anywhere;
}

.erro code {
  font-family: var(--fonte-mono);
  font-size: 12px;
  color: var(--ambar);
}

/* ----------------------------------------------------------------- chrome - */

.chrome {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 12;
  display: flex;
  align-items: center;
  gap: clamp(9px, 1.4vw, 16px);
  height: calc(var(--chrome-altura) + env(safe-area-inset-bottom));
  padding: 0 var(--respiro);
  padding-bottom: env(safe-area-inset-bottom);
  background: linear-gradient(to top, rgba(3, 4, 9, 0.9) 0%, rgba(3, 4, 9, 0.55) 46%, rgba(3, 4, 9, 0) 100%);
  transition: opacity 0.34s ease, transform 0.34s ease;
}

.chrome[data-oculto="1"] {
  opacity: 0;
  transform: translateY(9px);
  pointer-events: none;
}

.botao-play {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  padding: 0;
  border: 1px solid rgba(251, 241, 222, 0.24);
  border-radius: 50%;
  background: rgba(251, 241, 222, 0.06);
  color: var(--creme);
  cursor: pointer;
  transition: background-color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.botao-play:hover {
  background: rgba(251, 241, 222, 0.14);
  border-color: rgba(251, 241, 222, 0.42);
}

.botao-play:active {
  transform: scale(0.94);
}

.botao-play .icone {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.botao-play .icone--pause {
  display: none;
}

.botao-play[data-tocando="1"] .icone--play {
  display: none;
}

.botao-play[data-tocando="1"] .icone--pause {
  display: block;
}

.trilha {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  height: 30px;
  display: flex;
  align-items: center;
  cursor: pointer;
  touch-action: none;
}

.trilha__base {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 2px;
  transform: translateY(-50%);
  border-radius: 1px;
  background: rgba(251, 241, 222, 0.18);
}

.trilha__preenche {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 2px;
  transform: translateY(-50%) scaleX(0);
  transform-origin: left center;
  border-radius: 1px;
  background: var(--coral);
}

.trilha__cabo {
  position: absolute;
  left: 0;
  top: 50%;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border-radius: 50%;
  background: var(--creme);
  box-shadow: 0 0 0 3px rgba(251, 241, 222, 0.12);
  transform: translateX(0);
  opacity: 0.9;
}

.trilha:hover .trilha__base,
.trilha:focus-visible .trilha__base {
  height: 3px;
}

.tempo {
  flex: none;
  color: rgba(251, 241, 222, 0.55);
  font-family: var(--fonte-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.06em;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.botao-legenda {
  flex: none;
  padding: 5px 3px;
  border: 0;
  border-radius: 2px;
  background: transparent;
  color: rgba(251, 241, 222, 0.4);
  font-family: var(--fonte-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.18s ease;
}

.botao-legenda:hover {
  color: rgba(251, 241, 222, 0.78);
}

.botao-legenda[aria-pressed="true"] {
  color: var(--ambar);
}

/* ------------------------------------------------------------------ debug - */

.debug {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 13;
  margin: 0;
  padding: 10px 12px;
  border-radius: 3px;
  background: rgba(3, 4, 9, 0.82);
  color: rgba(251, 241, 222, 0.82);
  font-family: var(--fonte-mono);
  font-size: 10px;
  line-height: 1.6;
  white-space: pre;
  pointer-events: none;
}

.debug[hidden] {
  display: none;
}

/* ------------------------------------------------------------- responsivo - */

@media (max-width: 620px) {
  :root {
    --zona-altura: 92px;
    --chrome-altura: 46px;
  }

  .cartela {
    padding: 22px;
    padding-bottom: 15vh;
    background: linear-gradient(180deg, rgba(4, 5, 11, 0.9) 0%, rgba(4, 5, 11, 0.72) 58%, rgba(4, 5, 11, 0.5) 100%);
  }

  .cartela__bloco {
    max-width: 100%;
  }

  .cartela__titulo {
    font-size: clamp(40px, 13.4vw, 62px);
  }

  .legenda {
    width: 90vw;
    bottom: calc(var(--chrome-altura) + 6px);
  }

  .legenda p {
    font-size: 12.5px;
  }

  .chrome {
    gap: 9px;
  }

  .botao-play {
    width: 30px;
    height: 30px;
  }

  .tempo {
    font-size: 9px;
    letter-spacing: 0.02em;
  }
}

@media (max-height: 520px) {
  .legenda {
    bottom: calc(var(--chrome-altura) + 4px);
  }

  .legenda p {
    font-size: 11.5px;
  }

  .cartela {
    padding-bottom: 12vh;
  }
}

@media (prefers-reduced-motion: reduce) {
  .chrome {
    transition-duration: 0.01s;
  }

  .grao {
    display: none;
  }
}
