/* Tutorial da Torre do CD. Palco verde-noite (06:15, antes do sol), acento laranja Cantu
   só no que se move: o dedo, o foco e a barra de progresso. */
:root {
  --palco: #063B2A;
  --palco-2: #0A4733;
  --tinta: #F1F6F2;
  --tinta-2: #B9CFC0;
  --linha: rgba(241, 246, 242, .16);
  --laranja: #FD7D00;
  --laranja-txt: #FFA244;
  --sobre-laranja: #2A1500;
  --barra: #5F9A72;
  --trilho: rgba(241, 246, 242, .12);
  --corpo-aparelho: #0D1511;
  --sombra: 0 24px 60px rgba(0, 0, 0, .35), 0 4px 14px rgba(0, 0, 0, .25);
  --veu: rgba(4, 22, 14, .58);
  --slab: "Roboto Slab", Georgia, serif;
  --sans: Roboto, system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --palco: #E8EFE9;
    --palco-2: #DCE7DE;
    --tinta: #10291B;
    --tinta-2: #45604F;
    --linha: rgba(16, 41, 27, .16);
    --laranja-txt: #A04B00;
    --barra: #3F7A52;
    --trilho: rgba(16, 41, 27, .10);
    --sombra: 0 24px 50px rgba(16, 41, 27, .22), 0 4px 12px rgba(16, 41, 27, .14);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --palco: #E8EFE9; --palco-2: #DCE7DE; --tinta: #10291B; --tinta-2: #45604F; --linha: rgba(16, 41, 27, .16);
  --laranja-txt: #A04B00; --barra: #3F7A52; --trilho: rgba(16, 41, 27, .10);
  --sombra: 0 24px 50px rgba(16, 41, 27, .22), 0 4px 12px rgba(16, 41, 27, .14); color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--palco);
  color: var(--tinta);
  font: 400 16px/1.5 var(--sans);
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--laranja); color: var(--sobre-laranja); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--laranja); outline-offset: 3px; border-radius: 6px; }
.ic { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- topo ---------- */
.topo {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 24px; border-bottom: 1px solid var(--linha);
}
.topo p { margin: 0; }
.topo__nome { font: 600 18px/1.2 var(--slab); letter-spacing: -.01em; }
.topo__sub { font: 400 14px/1.2 var(--sans); color: var(--tinta-2); margin-left: 10px; }
.selo {
  flex: none; font-size: 13px; font-weight: 500; line-height: 1;
  padding: 7px 12px; border-radius: 999px; border: 1px solid var(--laranja-txt); color: var(--laranja-txt);
}

/* ---------- palco ---------- */
.palco {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 500px);
  gap: clamp(24px, 5vw, 88px);
  padding: 20px clamp(24px, 6vw, 112px);
  align-items: center;
}
.aparelho-area { position: relative; height: 100%; min-height: 0; display: grid; place-items: center; }
.aparelho {
  /* tamanho real 390 x 844 + moldura; o JS aplica a escala */
  position: absolute; left: 50%; top: 50%;
  width: 412px; height: 866px; padding: 11px;
  border-radius: 54px; background: var(--corpo-aparelho);
  box-shadow: var(--sombra), inset 0 0 0 1.5px rgba(255, 255, 255, .08);
  transform-origin: 50% 50%;
  transform: translate(-50%, -50%) scale(var(--escala, .8));
  cursor: pointer;
}
.tela { position: relative; width: 390px; height: 844px; border-radius: 44px; overflow: hidden; background: var(--corpo-aparelho); isolation: isolate; }
.tela iframe { display: block; width: 390px; height: 844px; border: 0; pointer-events: none; background: #F4F6F3; }

.foco { position: absolute; inset: 0; width: 390px; height: 844px; pointer-events: none; opacity: 0; transition: opacity .35s ease; }
.foco.ligado { opacity: 1; }
.foco__veu { fill: var(--veu); }
#foco-bordas rect { fill: none; stroke: var(--laranja); stroke-width: 3; }

/* o dedo: um anel laranja que aparece, afunda e solta uma onda */
.toque {
  position: absolute; left: 0; top: 0; width: 56px; height: 56px; margin: -28px 0 0 -28px;
  border-radius: 50%; pointer-events: none; opacity: 0;
  background: rgba(253, 125, 0, .28); border: 3px solid var(--laranja);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .25);
}
.toque__onda { position: absolute; inset: -3px; border-radius: 50%; border: 3px solid var(--laranja); opacity: 0; }
.toque.vai { animation: dedo .9s cubic-bezier(.16, 1, .3, 1) forwards; }
.toque.vai .toque__onda { animation: onda .7s .28s cubic-bezier(.16, 1, .3, 1) forwards; }
@keyframes dedo {
  0% { opacity: 0; transform: scale(1.5); }
  25% { opacity: 1; transform: scale(1); }
  38% { transform: scale(.8); background: rgba(253, 125, 0, .55); }
  55% { transform: scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: scale(1); }
}
@keyframes onda { 0% { opacity: .9; transform: scale(1); } 100% { opacity: 0; transform: scale(2.4); } }

.inicio {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 5;
  display: flex; align-items: center; gap: 12px; padding: 14px 22px 14px 16px; min-height: 56px;
  border: 0; border-radius: 999px; background: var(--laranja); color: var(--sobre-laranja);
  font: 500 17px/1.2 var(--sans); white-space: nowrap; cursor: pointer; box-shadow: 0 10px 30px rgba(0, 0, 0, .3);
  transition: transform .15s ease, box-shadow .15s ease;
}
.inicio .ic { width: 28px; height: 28px; fill: currentColor; stroke: none; }
.inicio small { display: block; font-size: 13px; font-weight: 400; opacity: .85; }
.inicio span { text-align: left; }
.inicio:hover { transform: translate(-50%, -50%) scale(1.03); }
.inicio[hidden] { display: none; }

/* ---------- lado: título, legenda, capítulos ---------- */
.lado { min-width: 0; max-height: 100%; display: flex; flex-direction: column; gap: 14px; overflow: auto; padding: 4px; }
.cena-titulo { margin: 0; font: 600 clamp(28px, 2.6vw, 40px)/1.12 var(--slab); letter-spacing: -.02em; text-wrap: balance; }
.legenda { margin: 0; font-size: clamp(17px, 1.35vw, 20px); line-height: 1.5; max-width: 34em; min-height: 4.5em; color: var(--tinta); text-wrap: pretty; }
.legenda.troca { animation: legenda .45s cubic-bezier(.16, 1, .3, 1); }
@keyframes legenda { from { opacity: 0; transform: translateY(6px); } }

.placar {
  margin: 0; display: inline-flex; align-self: flex-start; align-items: baseline; gap: 10px;
  padding: 8px 14px; border-radius: 12px; background: var(--palco-2); border: 1px solid var(--linha);
}
.placar span { color: var(--tinta-2); font-size: 15px; }
.placar strong { font: 600 22px/1.2 var(--slab); font-variant-numeric: tabular-nums; color: var(--tinta); }
.placar.sobe strong { animation: sobe .6s cubic-bezier(.16, 1, .3, 1); }
@keyframes sobe { 0% { color: var(--laranja-txt); } 100% { color: var(--tinta); } }
.placar[hidden] { display: none; }

.capitulos { list-style: none; margin: 10px 0 0; padding: 0; border-top: 1px solid var(--linha); }
.capitulos li { border-bottom: 1px solid var(--linha); }
.capitulos button {
  width: 100%; display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 10px;
  min-height: 46px; padding: 6px 4px; background: none; border: 0; text-align: left; cursor: pointer; color: var(--tinta-2);
}
.capitulos .n { font-variant-numeric: tabular-nums; font-weight: 500; }
.capitulos .t { font-size: 15px; }
.capitulos .d { font-size: 13px; font-variant-numeric: tabular-nums; }
.capitulos button:hover { color: var(--tinta); }
.capitulos [aria-current="step"] { color: var(--tinta); }
.capitulos [aria-current="step"] .n { color: var(--laranja-txt); }
.capitulos [aria-current="step"] .t { font-weight: 500; }

/* ---------- fechamento ---------- */
.fecho { display: flex; flex-direction: column; gap: 14px; }
.fecho[hidden] { display: none; }
.fecho__valor { margin: 0; font-size: 18px; line-height: 1.45; max-width: 30em; }
.fecho__valor strong { display: block; font: 600 clamp(40px, 4vw, 56px)/1.05 var(--slab); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.fecho__titulo { margin: 8px 0 0; font: 500 17px/1.3 var(--sans); }
.barras { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.barras li { display: grid; grid-template-columns: 96px 1fr 88px; align-items: center; gap: 10px; font-size: 15px; }
.barras__rot { color: var(--tinta-2); }
.barras__trilho { height: 22px; background: var(--trilho); border-radius: 4px; overflow: hidden; }
.barras__barra { display: block; height: 100%; width: var(--w, 0%); background: var(--barra); border-radius: 0 4px 4px 0; transition: width .9s cubic-bezier(.16, 1, .3, 1); }
.barras__val { font-variant-numeric: tabular-nums; text-align: right; font-weight: 500; }
.barras .provavel .barras__rot, .barras .provavel .barras__val { color: var(--tinta); font-weight: 700; }
.barras .provavel .barras__barra { background: var(--laranja); }
.fecho__nota { margin: 0; font-size: 14px; line-height: 1.5; color: var(--tinta-2); max-width: 36em; }

/* ---------- controles ---------- */
.controles { padding: 0 24px 14px; border-top: 1px solid var(--linha); }
.trilha { display: flex; gap: 4px; height: 20px; align-items: center; }
.trilha button {
  position: relative; flex: var(--peso, 1) 1 0; height: 20px; padding: 0; border: 0; background: none; cursor: pointer;
}
.trilha button::before, .trilha button::after { content: ""; position: absolute; left: 0; top: 8px; height: 4px; border-radius: 2px; }
.trilha button::before { right: 0; background: var(--trilho); }
.trilha button::after { width: calc(var(--p, 0) * 100%); background: var(--laranja); }
.trilha button:hover::before { background: var(--linha); }
.controles__linha { display: flex; align-items: center; gap: 8px; }
.ctl {
  display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%;
  border: 1px solid var(--linha); background: transparent; cursor: pointer;
}
.ctl:hover { background: var(--palco-2); }
.ctl:disabled { opacity: .4; cursor: default; }
.ctl--tocar { width: 56px; height: 56px; background: var(--laranja); color: var(--sobre-laranja); border: 0; }
.ctl--tocar:hover { background: #FF8F22; }
.ctl--tocar .ic { width: 26px; height: 26px; }
.ctl--tocar .ic--tocar { fill: currentColor; stroke: none; }
.ctl--tocar .ic--pausar { stroke-width: 3; }
.ctl--tocar .ic--pausar, .ctl--tocar .ic--repetir { display: none; }
.ctl--tocar[data-estado="tocando"] .ic--tocar, .ctl--tocar[data-estado="fim"] .ic--tocar { display: none; }
.ctl--tocar[data-estado="tocando"] .ic--pausar { display: block; }
.ctl--tocar[data-estado="fim"] .ic--repetir { display: block; stroke-width: 2.2; }
.tempo { margin: 0 0 0 12px; display: flex; gap: 14px; font-size: 14px; color: var(--tinta-2); font-variant-numeric: tabular-nums; }

/* ---------- celular (até 820 px) ---------- */
@media (max-width: 820px) {
  .topo { padding: 10px 16px; }
  .topo__nome { font-size: 16px; }
  .topo__sub { display: none; }
  .selo { font-size: 12px; padding: 6px 10px; }
  .palco { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; gap: 10px; padding: 10px 16px 6px; align-items: stretch; }
  .lado { gap: 8px; overflow: visible; padding: 0; min-height: 132px; position: relative; }
  .cena-titulo { font-size: 20px; }
  .legenda { font-size: 15px; min-height: 4.5em; }
  .capitulos { display: none; }
  .placar { position: absolute; right: 0; top: -2px; padding: 4px 10px; }
  .placar span { display: none; }
  .placar strong { font-size: 17px; }
  .fecho {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; max-height: 82dvh; overflow: auto;
    padding: 20px 16px 132px; background: var(--palco); border-top: 1px solid var(--linha);
    border-radius: 20px 20px 0 0; box-shadow: 0 -16px 40px rgba(0, 0, 0, .3);
    animation: fecho-sobe .5s cubic-bezier(.16, 1, .3, 1);
  }
  .controles { position: relative; z-index: 11; background: var(--palco); padding: 0 16px calc(10px + env(safe-area-inset-bottom)); }
  .barras li { grid-template-columns: 84px 1fr 80px; font-size: 14px; }
  .tempo { margin-left: auto; flex-direction: column; gap: 0; text-align: right; font-size: 13px; }
}
@keyframes fecho-sobe { from { transform: translateY(40%); opacity: 0; } }

/* ---------- menos movimento ---------- */
@media (prefers-reduced-motion: reduce) {
  .toque.vai, .toque.vai .toque__onda { animation: none; }
  .toque.vai { opacity: 1; }
  .legenda.troca, .placar.sobe strong, .fecho { animation: none; }
  .foco, .barras__barra { transition: none; }
  .inicio, .inicio:hover { transition: none; }
}
@media (forced-colors: active) {
  .toque, .toque__onda { border-color: Highlight; }
  #foco-bordas rect { stroke: Highlight; }
  .trilha button::after { background: Highlight; }
}
