/* =====================================================================
   Página da t-shirt (São Silvestre) — complementa site.css.
   Usa as variáveis e os componentes do site; aqui só o que é novo:
   o palco da revelação, o botão de acender e os comandos da peça 3D.
   ===================================================================== */

/* ---------- Palco ---------- */
.ts-palco {
  --noite: #141928;
  --cx: 50%;   /* centro horizontal da peça (muda nos ecrãs largos) */
  position: relative; isolation: isolate; overflow: hidden;
  height: calc(100svh - var(--topo-h)); min-height: 600px; max-height: 980px;
  background: var(--noite); color: var(--branco);
  display: grid; grid-template-rows: auto 1fr auto;
  transition: background-color 1.1s ease;
}
.ts-palco[data-estado="revelada"] { background: var(--ss-escuro); }

/* foco de luz atrás da peça (acende na revelação) */
.ts-palco::before {
  content: ""; position: absolute; z-index: -3; left: var(--cx); top: 48%;
  width: min(120vw, 1100px); aspect-ratio: 1; transform: translate(-50%, -50%) scale(.6);
  background: radial-gradient(closest-side, rgba(150,213,210,.34), rgba(150,213,210,.1) 55%, transparent 72%);
  opacity: calc(var(--p, 0) * .5); transition: opacity .8s ease, transform 1.2s var(--mola);
  pointer-events: none;
}
.ts-palco[data-estado="revelada"]::before { opacity: 1; transform: translate(-50%, -50%) scale(1); }
/* tracejado da estrada, como no resto da página da prova */
.ts-palco::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 8px; background: repeating-linear-gradient(90deg, var(--ss-claro) 0 40px, transparent 40px 70px); opacity: .0; transition: opacity .8s ease .3s; }
.ts-palco[data-estado="revelada"]::after { opacity: 1; }

/* número gigante em contorno, por trás da peça */
.ts-fundo {
  position: absolute; z-index: -2; left: var(--cx); top: 47%; transform: translate(-50%, -50%);
  font-size: clamp(11rem, 5rem + 30vw, 34rem); font-weight: 900; font-stretch: 125%; line-height: .8; letter-spacing: -.04em;
  color: transparent; -webkit-text-stroke: 2px rgba(150,213,210,.0); white-space: nowrap;
  pointer-events: none; user-select: none; transition: -webkit-text-stroke-color 1.2s ease .2s;
}
.ts-palco[data-estado="revelada"] .ts-fundo { -webkit-text-stroke-color: rgba(150,213,210,.2); }

/* a peça 3D */
.ts-cena { position: absolute; inset: 0; z-index: -1; padding: 1.2rem 0 9.2rem 0; }
.ts-palco[data-estado="escuro"] .ts-cena { padding-bottom: 12.4rem; }
.ts-tela { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: pan-y; cursor: grab; outline: none; -webkit-tap-highlight-color: transparent; }
.a-arrastar .ts-tela { cursor: grabbing; }
.ts-cena__img { position: absolute; inset: 8% 0; margin: auto; width: auto; height: 84%; max-width: 92%; object-fit: contain; }
.ts-cena__msg { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 2rem; color: #cfd6e6; font-size: var(--t-peq); }

/* clarão no momento de acender */
.ts-clarao { position: absolute; inset: 0; z-index: 3; background: radial-gradient(circle at var(--cx) 48%, #fff 0%, #dff6f4 38%, rgba(150,213,210,.0) 78%); opacity: 0; pointer-events: none; }
.ts-clarao.is-on { animation: ts-clarao .9s ease-out both; }
@keyframes ts-clarao { 0% { opacity: 0; } 12% { opacity: .95; } 100% { opacity: 0; } }

/* ---------- Texto do palco ---------- */
.ts-topo { padding-top: clamp(1.2rem, .8rem + 2vw, 2.6rem); display: grid; gap: .8rem; justify-items: start; pointer-events: none; transition: opacity .35s ease; }
/* com zoom, o título sai da frente da peça */
.ts-palco:has(.ts-cena.tem-zoom) .ts-topo { opacity: 0; }
.ts-titulo { font-size: clamp(2.3rem, 1.2rem + 4.6vw, 5.4rem); font-weight: 900; font-stretch: 125%; text-transform: uppercase; letter-spacing: -.03em; line-height: .88; display: grid; }
.ts-titulo > span { grid-area: 1 / 1; transition: opacity .5s ease, transform .7s var(--mola); }
.ts-titulo em { font-style: normal; color: var(--acc); }
.ts-titulo [data-depois] { opacity: 0; transform: translateY(18px); }
.ts-palco[data-estado="revelada"] .ts-titulo [data-antes] { opacity: 0; transform: translateY(-18px); }
.ts-palco[data-estado="revelada"] .ts-titulo [data-depois] { opacity: 1; transform: none; transition-delay: .35s; }
.ts-sub { max-width: 22rem; color: #cfd6e6; font-size: clamp(.95rem, .9rem + .25vw, 1.1rem); line-height: 1.45; opacity: 0; transform: translateY(12px); transition: opacity .6s ease .6s, transform .8s var(--mola) .6s; }
.ts-palco[data-estado="revelada"] .ts-sub { opacity: 1; transform: none; }

/* ---------- Base: botão de acender ou comandos ---------- */
.ts-base { grid-row: 3; padding-bottom: calc(1.4rem + env(safe-area-inset-bottom, 0px)); display: grid; justify-items: center; }
.ts-base > * { grid-area: 1 / 1; }

.ts-acender { display: grid; justify-items: center; gap: .7rem; text-align: center; transition: opacity .35s ease, transform .5s var(--mola); }
.ts-palco[data-estado="revelada"] .ts-acender { opacity: 0; transform: scale(.8); pointer-events: none; visibility: hidden; transition: opacity .35s ease, transform .5s var(--mola), visibility 0s .4s; }
.ts-luz {
  --p: 0;
  position: relative; width: 92px; height: 92px; border-radius: 50%; border: 0; padding: 0;
  background: var(--amarelo); color: var(--tinta); cursor: pointer;
  display: grid; place-items: center;
  box-shadow: 0 0 0 0 rgba(239,180,9,.55), 0 14px 34px rgba(0,0,0,.45);
  transform: scale(calc(1 - var(--p) * .08));
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
  animation: ts-pulso 2.2s ease-out infinite;
}
.ts-luz.is-a-premir { animation: none; background: var(--amarelo-vivo); }
.ts-luz svg.ts-luz__ico { width: 34px; height: 34px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.ts-luz__anel { position: absolute; inset: -9px; width: calc(100% + 18px); height: calc(100% + 18px); transform: rotate(-90deg); pointer-events: none; }
.ts-luz__anel circle { fill: none; stroke-width: 4; }
.ts-luz__anel .a { stroke: rgba(255,255,255,.16); }
.ts-luz__anel .b { stroke: var(--branco); stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: calc(100 - var(--p) * 100); }
@keyframes ts-pulso { 0% { box-shadow: 0 0 0 0 rgba(239,180,9,.55), 0 14px 34px rgba(0,0,0,.45); } 70%, 100% { box-shadow: 0 0 0 26px rgba(239,180,9,0), 0 14px 34px rgba(0,0,0,.45); } }
.ts-acender__txt { font-size: .82rem; font-weight: 800; font-stretch: 112%; letter-spacing: .14em; text-transform: uppercase; }
.ts-saltar { background: none; border: 0; padding: .4rem .6rem; min-height: 44px; color: #aeb7cc; font-size: .8rem; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.ts-saltar:hover { color: var(--branco); }

.ts-comandos { display: grid; gap: .7rem; justify-items: center; width: 100%; opacity: 0; transform: translateY(20px); pointer-events: none; visibility: hidden; transition: opacity .5s ease .7s, transform .7s var(--mola) .7s, visibility 0s .7s; }
.ts-palco[data-estado="revelada"] .ts-comandos { opacity: 1; transform: none; pointer-events: auto; visibility: visible; }
.ts-barra { display: flex; align-items: center; gap: .5rem; padding: 5px; border-radius: 999px; background: rgba(20,24,38,.9); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border: 1px solid rgba(150,213,210,.24); }
.ts-lados { display: grid; grid-template-columns: 1fr 1fr; border: 0; padding: 0; margin: 0; min-width: 0; }
.ts-lados .seg span { min-height: 46px; padding: .4rem 1.15rem; border-radius: 999px; font-size: .78rem; font-weight: 800; font-stretch: 110%; letter-spacing: .1em; text-transform: uppercase; color: var(--branco); }
.ts-lados .seg input:checked + span { color: var(--ss-escuro); }
.ts-ico { width: 46px; height: 46px; border-radius: 50%; border: 0; background: transparent; color: var(--branco); display: grid; place-items: center; cursor: pointer; transition: background-color .2s, color .2s; }
.ts-ico:hover { background: rgba(150,213,210,.18); }
.ts-ico:disabled { opacity: .35; cursor: default; background: transparent; }
.ts-ico svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.ts-sep { width: 1px; height: 24px; background: rgba(255,255,255,.18); }
.ts-pormenores { display: flex; flex-wrap: wrap; justify-content: center; gap: .4rem; }
.ts-pilula { min-height: 44px; padding: .45rem 1rem; border-radius: 999px; border: 1px solid rgba(150,213,210,.3); background: rgba(20,24,38,.88); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); color: var(--branco); font-size: .74rem; font-weight: 800; font-stretch: 110%; letter-spacing: .1em; text-transform: uppercase; cursor: pointer; transition: background-color .2s, color .2s, border-color .2s; }
.ts-pilula:hover { border-color: var(--acc); }
.ts-pilula[aria-pressed="true"] { background: var(--amarelo); color: var(--tinta); border-color: var(--amarelo); }
.ts-dica { font-size: .78rem; color: #aeb7cc; text-align: center; }

/* legenda do pormenor em foco */
.ts-legenda { position: absolute; z-index: 2; left: var(--gutter); right: var(--gutter-r); bottom: 11.5rem; margin-inline: auto; width: fit-content; max-width: min(30rem, calc(100% - 2 * var(--gutter))); padding: .7rem 1rem; border-radius: var(--raio-peq); background: rgba(20,24,38,.78); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border-left: 4px solid var(--amarelo); font-size: .9rem; line-height: 1.4; opacity: 0; transform: translateY(10px); transition: opacity .3s ease, transform .4s var(--mola); pointer-events: none; }
.ts-legenda.is-on { opacity: 1; transform: none; }
.ts-legenda b { display: block; font-size: .74rem; font-weight: 800; font-stretch: 112%; letter-spacing: .12em; text-transform: uppercase; color: var(--acc); margin-bottom: .15rem; }

/* ---------- Ecrãs largos: título à esquerda, peça à direita ---------- */
@media (min-width: 961px) {
  .ts-palco { --cx: 66%; }
  .ts-cena { padding-left: 32%; }
  .ts-topo { align-content: center; grid-row: 1 / 3; padding-bottom: 6rem; }
  .ts-titulo { max-width: 6.2em; }
  .ts-base { margin: 0 0 0 32%; width: 68%; max-width: none; padding-inline: 0; }
  .ts-legenda { left: max(var(--gutter), calc((100vw - var(--max)) / 2)); right: auto; bottom: auto; top: 44%; margin: 0; max-width: 21rem; font-size: 1rem; padding: 1rem 1.2rem; }
}
/* ---------- Telemóvel: a peça ocupa o meio, comandos ao alcance do polegar ---------- */
@media (max-width: 960px) {
  .ts-palco { min-height: 560px; }
  .ts-cena { padding: clamp(6rem, 17svh, 9rem) 0 clamp(8.6rem, 21svh, 10.5rem) 0; }
  .ts-palco[data-estado="escuro"] .ts-cena { padding-bottom: clamp(11rem, 28svh, 13.5rem); }
  .ts-sub { display: none; }
  .ts-luz { width: 84px; height: 84px; }
  .ts-barra { gap: .2rem; }
  .ts-lados .seg span { padding-inline: .9rem; }
  .ts-dica { display: none; }
  .ts-pormenores { flex-wrap: nowrap; }
  .ts-pilula { padding-inline: .8rem; font-size: .7rem; white-space: nowrap; }
  .ts-legenda { bottom: 12.4rem; }
}
@media (max-width: 380px) {
  .ts-pilula { padding-inline: .6rem; font-size: .66rem; letter-spacing: .06em; }
}

/* ---------- Telemóvel deitado (pouca altura): título e comandos à esquerda, peça à direita ---------- */
@media (orientation: landscape) and (max-height: 520px) {
  .ts-palco { --cx: 71%; height: calc(100svh - var(--topo-h)); min-height: 300px; max-height: none; grid-template-rows: auto 1fr; }
  .ts-cena, .ts-palco[data-estado="escuro"] .ts-cena { padding: .6rem 0 .6rem 44%; }
  .ts-topo { grid-row: 1; grid-column: 1; width: 44%; margin: 0; padding-top: .9rem; gap: .3rem; }
  .ts-topo .rotulo { display: none; }
  .ts-titulo { font-size: clamp(1.6rem, 1rem + 3.2vh, 2.4rem); }
  .ts-base { grid-row: 2; align-self: end; width: 44%; margin: 0; padding-bottom: calc(.8rem + env(safe-area-inset-bottom, 0px)); justify-items: start; }
  .ts-acender, .ts-comandos { justify-items: start; text-align: left; }
  .ts-acender { grid-template-columns: auto 1fr; align-items: center; column-gap: 1rem; row-gap: 0; }
  .ts-luz { grid-row: 1 / 3; width: 72px; height: 72px; }
  .ts-saltar { justify-self: start; padding-left: 0; }
  .ts-comandos { gap: .5rem; }
  .ts-pormenores { justify-content: flex-start; flex-wrap: nowrap; }
  .ts-pilula { padding-inline: .7rem; font-size: .66rem; letter-spacing: .06em; white-space: nowrap; }
  .ts-legenda { display: none; }
  .ts-fundo { font-size: 46vh; }
}

@media (prefers-reduced-motion: reduce) {
  .ts-luz { animation: none; }
  .ts-clarao.is-on { animation-duration: .01s; }
  .ts-palco, .ts-palco::before, .ts-titulo > span, .ts-comandos, .ts-acender { transition-duration: .01s !important; transition-delay: 0s !important; }
}

/* ---------- Ficha (por baixo do palco) ---------- */
.ts-ficha { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 2rem clamp(2rem, 1rem + 5vw, 6rem); align-items: start; }
.ts-ficha__txt { display: grid; gap: 1.1rem; justify-items: start; }
.ts-ficha__acoes { display: flex; flex-wrap: wrap; gap: .7rem; margin-top: .4rem; }
.ts-ficha .dados div { grid-template-columns: minmax(0, 9rem) minmax(0, 1fr); }
.factos__lista b { text-wrap: balance; }
@media (max-width: 960px) { .ts-ficha { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 620px) { .ts-ficha__acoes .btn { flex: 1 1 100%; } }
