/* Abertura dourada do tetra da Libertadores (só entra na home quando tools/tetra.mjs está ativo).
   Coreografia: escudo surge (0,15s), anéis se desenham (0,5s), louros brotam (1s), três estrelas (1,9s),
   a quarta acende com clarão e confete (2,75s), TETRA sobe letra a letra (2,2s), textos e letreiro. */
.tetra {
  --escudo: clamp(190px, 56vw, 300px);
  --ouro-claro: #FFF3C4;
  position: relative; overflow: clip; isolation: isolate;
  min-height: calc(100svh - var(--topo));
  display: grid; grid-template-rows: 1fr auto;
  background:
    var(--grao-claro),
    radial-gradient(52% 48% at 50% 34%, rgb(233 196 106 / .22), transparent 72%),
    radial-gradient(90% 70% at 50% 112%, rgb(0 100 55 / .6), transparent 72%),
    var(--noite);
  border-bottom: 1px solid rgb(201 160 58 / .4);
}
.tetra-confete { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 2; pointer-events: none; }
.tetra-palco {
  position: relative; z-index: 1;
  display: grid; justify-items: center; align-content: center; text-align: center;
  padding: var(--e-4) var(--margem) var(--e-6);
}

/* ——— medalha: escudo, halo, raios, anéis, louros e estrelas ——— */
.tetra-medalha {
  position: relative; width: var(--escudo); aspect-ratio: 1;
  margin: calc(var(--escudo) * .34) auto calc(var(--escudo) * .3);
  animation: flutua-t 7s ease-in-out 3s infinite;
}
.tetra-medalha::before {
  content: ''; position: absolute; inset: -38%; border-radius: 50%;
  background: radial-gradient(closest-side, rgb(255 228 150 / .5), rgb(201 160 58 / .16) 58%, transparent 100%);
  opacity: 0; animation: aparece-t 1.6s .2s forwards, respira-t 5s ease-in-out 2s infinite;
}
.tetra-raios {
  position: absolute; inset: -78%; border-radius: 50%;
  background: repeating-conic-gradient(from 0deg, rgb(246 218 134 / .13) 0deg 2.2deg, transparent 2.2deg 9deg);
  -webkit-mask: radial-gradient(closest-side, #000 24%, transparent 100%);
  mask: radial-gradient(closest-side, #000 24%, transparent 100%);
  opacity: 0; animation: aparece-t 2.4s .4s forwards, gira-t 180s linear infinite;
}
.tetra-ornato { position: absolute; left: -50%; top: -50%; width: 200%; height: 200%; max-width: none; overflow: visible; pointer-events: none; }
.tetra-escudo { position: relative; z-index: 1; width: 100%; height: 100%; animation: escudo-t 1.5s var(--curva) .15s both; }
.tetra-escudo img {
  width: 100%; height: 100%;
  filter: drop-shadow(0 0 2px rgb(255 236 170 / .9)) drop-shadow(0 0 26px rgb(255 210 100 / .45)) drop-shadow(0 24px 36px rgb(0 0 0 / .55));
}
.tetra-reflexo {
  position: absolute; inset: 0;
  background: linear-gradient(112deg, transparent 38%, rgb(255 248 222 / .72) 50%, transparent 62%) 140% 0 / 320% 100% no-repeat;
  -webkit-mask: url(../img/marca/escudo-palmeiras-520.webp) center / contain no-repeat;
  mask: url(../img/marca/escudo-palmeiras-520.webp) center / contain no-repeat;
  animation: reflexo-t 9s ease-in-out 2.4s infinite;
}
.tetra-medalha[role="button"] { cursor: pointer; }
.tetra-medalha[role="button"]:focus-visible { outline: 1px solid var(--ouro); outline-offset: calc(var(--escudo) * .2); border-radius: 50%; }

.tetra-ornato .anel { fill: none; stroke: url(#t-ouro); }
.tetra-ornato .anel-forte { stroke-width: 3.2; stroke-dasharray: 1; stroke-dashoffset: 1; animation: traca-t 1.7s var(--curva) .5s forwards; }
.tetra-ornato .anel-fino { stroke-width: 1.2; stroke-dasharray: 1; stroke-dashoffset: 1; opacity: .6; animation: traca-t 2.4s var(--curva) .9s forwards; }
.tetra-ornato .anel-serrilha {
  stroke-width: 8; stroke-dasharray: 1.4 6; opacity: 0;
  transform-box: view-box; transform-origin: 0 0;
  animation: aparece-t 1.2s 1.3s forwards, gira-t 140s linear infinite;
}
.tetra-ornato .caule { fill: none; stroke: url(#t-ouro); stroke-width: 3.6; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 1; animation: traca-t 1.5s var(--curva) 1s forwards; }
.tetra-ornato .folha { transform-box: fill-box; transform-origin: 0% 50%; transform: scale(0); animation: brota-t .6s var(--curva) calc(1.1s + var(--i) * 40ms) forwards; }
.tetra-ornato .folha path { fill: url(#t-ouro); }
.tetra-ornato .folha .nervura { fill: none; stroke: rgb(92 62 10 / .5); stroke-width: 1.3; }
.tetra-ornato .baga { fill: url(#t-estrela); transform-box: fill-box; transform-origin: center; transform: scale(0); animation: brota-t .5s var(--curva) calc(1.4s + var(--i) * 40ms) forwards; }
.tetra-ornato .estrela { transform-box: fill-box; transform-origin: center; transform: scale(0) rotate(-120deg); animation: estrela-t .75s cubic-bezier(.34, 1.56, .64, 1) calc(1.9s + var(--i) * 190ms) forwards; }
.tetra-ornato .estrela path:last-child { fill: url(#t-estrela); stroke: #7A5A14; stroke-width: 1; }
.tetra-ornato .estrela.quarta { animation-delay: 2.75s; animation-duration: 1s; }
.tetra-ornato .clarao { fill: rgb(255 246 210 / .9); transform-box: fill-box; transform-origin: center; opacity: 0; animation: clarao-t 4.5s ease-out 2.95s infinite; }
.tetra-ornato .brilho { fill: #FFF7DC; transform-box: fill-box; transform-origin: center; transform: scale(0); animation: cintila-t 4s ease-in-out calc(3.2s + var(--d)) infinite; }

/* ——— texto ——— */
.tetra-texto { display: grid; justify-items: center; gap: var(--e-3); }
.tetra-kicker { color: var(--ouro); animation: sobe-t .9s var(--curva) 2.1s both; }
.tetra-titulo { display: grid; justify-items: center; }
.tetra-palavra {
  display: flex;
  font: 700 clamp(5rem, 25vw, 11rem)/.86 var(--f-display);
  font-variation-settings: 'opsz' 40;
  letter-spacing: .015em; text-transform: uppercase;
  filter: drop-shadow(0 3px 0 #4A3206) drop-shadow(0 0 30px rgb(240 190 70 / .32));
}
.tetra-palavra span {
  display: block; padding-block: .04em;
  background-image:
    linear-gradient(100deg, transparent 42%, rgb(255 255 255 / .95) 50%, transparent 58%),
    linear-gradient(180deg, #FFF7D6 0%, #F6D77C 22%, #D9AA3C 44%, #8C6213 55%, #C2922B 68%, #F4D888 84%, #FFF2C0 100%);
  background-size: 320% 100%, 100% 100%;
  background-position: 140% 0, 0 0;
  background-repeat: no-repeat;
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  animation: letra-t 1s var(--curva) calc(2.2s + var(--i) * 90ms) both, reluz-t 7s ease-in-out calc(3.5s + var(--i) * 80ms) infinite;
}
.tetra-sub {
  font: italic 400 var(--t-3)/1.1 var(--f-display); font-variation-settings: var(--opsz-display);
  color: var(--papel); margin-top: .35em;
  animation: sobe-t .9s var(--curva) 2.8s both;
}
.tetra-anos { list-style: none; margin: var(--e-2) 0 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: var(--e-2) var(--e-4); color: var(--papel-2); }
.tetra-anos li { display: flex; align-items: center; gap: .45em; animation: sobe-t .7s var(--curva) calc(3s + var(--i) * 120ms) both; }
.tetra-anos li::before { content: '★'; color: var(--ouro); font-size: .95em; }
.tetra-anos .agora { color: var(--ouro-claro); font-weight: 600; text-shadow: 0 0 14px rgb(255 214 110 / .6); }
.tetra-placar {
  color: var(--papel-2); padding-top: var(--e-3);
  border-top: 1px solid rgb(201 160 58 / .35);
  display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 1.1em;
  animation: sobe-t .8s var(--curva) 3.4s both;
}
.tetra-placar span { white-space: nowrap; }
.tetra-placar .tetra-score { color: var(--papel); }
.tetra-frase { font: italic 400 var(--t-4)/1.45 var(--f-texto); max-width: 36ch; color: var(--papel); animation: sobe-t .8s var(--curva) 3.6s both; }
.tetra-botao {
  display: inline-flex; align-items: center; gap: .7em; margin-top: var(--e-2);
  padding: 15px 22px; border: 1px solid var(--ouro);
  font: 500 var(--t-meta)/1 var(--f-mono); letter-spacing: .08em; text-transform: uppercase;
  color: var(--ouro-claro); text-decoration: none;
  background: linear-gradient(180deg, rgb(201 160 58 / .18), rgb(201 160 58 / .04));
  transition: background .3s, color .3s;
  animation: sobe-t .8s var(--curva) 3.8s both;
}
.tetra-botao:hover { background: rgb(201 160 58 / .3); color: #fff; }

/* ——— letreiro ——— */
.tetra-letreiro {
  position: relative; z-index: 1; overflow: hidden;
  border-block: 1px solid rgb(201 160 58 / .45);
  background: linear-gradient(180deg, rgb(201 160 58 / .13), rgb(201 160 58 / .03));
  padding-block: 13px;
  animation: aparece-t 1s 3.2s both;
}
.tetra-letreiro .trilho {
  display: flex; width: max-content;
  font: 500 clamp(.875rem, 1.4vw, 1.0625rem)/1 var(--f-mono); letter-spacing: .16em; text-transform: uppercase;
  color: #F3D27A; white-space: nowrap;
  animation: corre-t 42s linear infinite;
}
.tetra-letreiro .trilho > span { padding-right: 1.5em; }
.tetra-letreiro .sep { color: var(--ouro); }

@media (min-width: 1024px) {
  .tetra { --escudo: clamp(280px, min(44vh, 30vw), 440px); }
  .tetra-palco {
    grid-template-columns: 1.1fr 1fr; align-items: center; column-gap: var(--e-6);
    justify-items: stretch; text-align: left;
    width: 100%; max-width: var(--largura); margin-inline: auto;
    padding-block: var(--e-5);
  }
  .tetra-medalha { margin: calc(var(--escudo) * .34) auto; }
  .tetra-texto, .tetra-titulo { justify-items: start; }
  .tetra-anos, .tetra-placar { justify-content: start; }
  .tetra-palavra { font-size: clamp(7rem, 10.5vw, 12rem); }
}

@keyframes aparece-t { to { opacity: 1; } }
@keyframes traca-t { to { stroke-dashoffset: 0; } }
@keyframes gira-t { to { transform: rotate(1turn); } }
@keyframes respira-t { 50% { transform: scale(1.06); opacity: .8; } }
@keyframes flutua-t { 50% { transform: translateY(-6px); } }
@keyframes escudo-t { from { opacity: 0; transform: scale(.8); filter: blur(10px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes reflexo-t { 0% { background-position: 140% 0; } 22%, 100% { background-position: -40% 0; } }
@keyframes brota-t { to { transform: scale(1); } }
@keyframes estrela-t { to { transform: scale(1) rotate(0deg); } }
@keyframes clarao-t {
  0% { opacity: 0; transform: scale(.2) rotate(0deg); }
  10% { opacity: 1; transform: scale(1.15) rotate(30deg); }
  45%, 100% { opacity: 0; transform: scale(.5) rotate(90deg); }
}
@keyframes cintila-t {
  0%, 100% { transform: scale(0) rotate(0deg); opacity: 0; }
  45% { transform: scale(1) rotate(45deg); opacity: 1; }
  70% { transform: scale(0) rotate(90deg); opacity: 0; }
}
@keyframes letra-t { from { opacity: 0; transform: translateY(.3em) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes reluz-t { 0% { background-position: 140% 0, 0 0; } 28%, 100% { background-position: -40% 0, 0 0; } }
@keyframes sobe-t { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes corre-t { to { transform: translateX(-50%); } }

@media (prefers-reduced-motion: reduce) {
  .tetra *, .tetra *::before, .tetra *::after { animation: none !important; }
  .tetra-medalha::before, .tetra-raios, .tetra-ornato .anel-serrilha { opacity: 1; }
  .tetra-ornato .anel, .tetra-ornato .caule { stroke-dashoffset: 0; }
  .tetra-ornato .folha, .tetra-ornato .baga, .tetra-ornato .estrela { transform: none; }
  .tetra-ornato .brilho { transform: scale(.6); }
}
