/* =========================================================
   SEÇÃO — 400 KM/H
   sequência de alta velocidade e odómetro
   ========================================================= */

.sr-section {
    --sr-green: #00ff66;
    --sr-alert: #ff1f3d;
    --sr-cyan: #00e5ff;
    --sr-ash: #8f8f96;

    position: relative;
    width: 100%;
    background: #000;
}

.sr-stage {
    position: relative;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    background: #000;
}

/* wrapper do shake — inset negativo evita borda preta no tremor */
.sr-shake {
    position: absolute;
    inset: -4%;
    will-change: transform;
}

.sr-frames {
    position: absolute;
    inset: 0;
}

.sr-frame {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    opacity: 0;
    will-change: opacity, transform, filter;
}

.sr-vignette {
    position: absolute;
    inset: 0;
    background: radial-gradient(
        circle at 50% 55%,
        transparent 28%,
        rgba(0, 0, 0, 0.72) 88%
    );
    pointer-events: none;
}

.sr-scanlines {
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0.035) 0 1px,
        transparent 1px 3px
    );
    mix-blend-mode: overlay;
    opacity: 0.7;
    pointer-events: none;
}

.sr-flash {
    position: absolute;
    inset: 0;
    background: #fff;
    opacity: 0;
    pointer-events: none;
    mix-blend-mode: screen;
}

/* ---------- ODÔMETRO ---------- */
.sr-odo {
    position: absolute;
    right: clamp(1rem, 3vw, 3rem);
    bottom: clamp(1rem, 3vw, 3rem);
    z-index: 40;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    padding: 18px 22px;

    /* Largura FIXA: a caixa não muda de tamanho quando o número muda.
       Os dígitos são alinhados à direita dentro dessa largura, então
       000, 137 e 400 ocupam exatamente o mesmo espaço. */
    width: clamp(180px, 20vw, 240px);

    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(6px);
    clip-path: polygon(
        14px 0,
        100% 0,
        100% calc(100% - 14px),
        calc(100% - 14px) 100%,
        0 100%,
        0 14px
    );
    transition:
        border-color 0.3s ease,
        box-shadow 0.3s ease;
}

.sr-odo__label {
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.58rem;
    letter-spacing: 0.32em;
    text-transform: uppercase;
    color: var(--sr-ash);
    white-space: nowrap;
}

.sr-odo__digits {
    display: block;
    width: 100%;
    text-align: right;
    white-space: nowrap;
    font-family: "Syncopate", sans-serif;
    font-size: clamp(2.4rem, 6vw, 4.2rem);
    font-weight: 700;
    line-height: 1;
    letter-spacing: -2px;

    /* figuras tabulares + algarismos de mesma altura: se a Syncopate
       não tiver tnum, o alinhamento à direita acima já segura a caixa */
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1, "lnum" 1;

    color: #fff;
    text-shadow: 0 0 24px rgba(0, 255, 102, 0.25);
}

.sr-odo__unit {
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.66rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--sr-ash);
    white-space: nowrap;
}

.sr-odo__bar {
    display: block;
    width: 100%;
    height: 3px;
    margin-top: 10px;
    background: rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

.sr-odo__fill {
    display: block;
    width: 100%;
    height: 100%;
    background: var(--sr-green);
    transform: scaleX(0);
    transform-origin: left center;
    box-shadow: 0 0 12px rgba(0, 255, 102, 0.8);
}

/* estado 400: pisca em vermelho */
.sr-odo.is-max {
    border-color: rgba(255, 31, 61, 0.7);
    box-shadow:
        0 0 34px rgba(255, 31, 61, 0.28),
        inset 0 0 22px rgba(255, 31, 61, 0.12);
}

.sr-odo.is-max .sr-odo__digits {
    color: var(--sr-alert);
    text-shadow:
        0 0 26px rgba(255, 31, 61, 0.9),
        2px 0 0 rgba(0, 229, 255, 0.55),
        -2px 0 0 rgba(0, 255, 102, 0.45);
    animation: sr-alarm 0.32s steps(1, end) infinite;
}

.sr-odo.is-max .sr-odo__fill {
    background: var(--sr-alert);
    box-shadow: 0 0 14px rgba(255, 31, 61, 0.9);
}

@keyframes sr-alarm {
    0%,
    49% {
        opacity: 1;
    }
    50%,
    100% {
        opacity: 0.28;
    }
}

/* ---------- FRASES ---------- */
.sr-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;

    /* simétrico: as frases ficam centralizadas de verdade */
    padding: 0 clamp(1.5rem, 6vw, 6rem);
    pointer-events: none;
}

.sr-line {
    position: absolute;
    max-width: 22ch;
    text-align: center;
    font-family: "Syncopate", sans-serif;
    font-weight: 700;
    font-size: clamp(1.4rem, 4.4vw, 3.4rem);
    line-height: 1.18;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0;
    visibility: hidden;

    /* --sr-g: intensidade da aberração cromática (0 limpo, 1 rasgado).
       Custom property para o GSAP interpolar e o scrub reverter. */
    --sr-g: 0;
}

/* Agrupa as letras de uma MESMA palavra num caixa indivisível.
   Sem isso cada .sr-ch é um inline-block isolado e o navegador quebra
   a linha no meio das palavras ("HORSE" vira "H" / "ORSE").
   O espaço entre palavras continua sendo um nó de texto normal,
   então a quebra de linha só acontece ENTRE palavras. */
.sr-word {
    display: inline-block;
    white-space: nowrap;
}

.sr-ch {
    position: relative;
    display: inline-block;
    white-space: pre;
}

/* medidor invisível: dá a caixa da letra sem precisar de JS medir */
.sr-ch__sizer {
    display: block;
    visibility: hidden;
}

/* cada tira recorta uma fatia horizontal da letra (clip-path em %) */
.sr-ch__strip {
    position: absolute;
    inset: 0;
    display: block;
    backface-visibility: hidden;

    /* aberração cromática proporcional a --sr-g */
    text-shadow:
        calc(var(--sr-g, 0) * 5px) 0 rgba(255, 31, 61, var(--sr-g, 0)),
        calc(var(--sr-g, 0) * -5px) 0 rgba(0, 229, 255, var(--sr-g, 0)),
        0 0 18px rgba(0, 255, 102, calc(var(--sr-g, 0) * 0.5));
}

/* barramento de rasgo que atravessa a frase no impacto */
.sr-tearline {
    position: absolute;
    left: -12%;
    width: 124%;
    height: 2px;
    top: 50%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.95) 22%,
        var(--sr-green) 50%,
        rgba(255, 255, 255, 0.95) 78%,
        transparent
    );
    box-shadow:
        0 0 18px rgba(0, 255, 102, 0.9),
        0 0 44px rgba(0, 255, 102, 0.5);
    opacity: 0;
    pointer-events: none;
}

.sr-line--final .sr-ch__strip {
    color: #fff;
    text-shadow:
        0 0 20px rgba(0, 255, 102, 0.55),
        2px 0 rgba(255, 31, 61, 0.4),
        -2px 0 rgba(0, 229, 255, 0.4);
}

@media (max-width: 768px) {
    .sr-odo {
        right: 1rem;
        bottom: 1rem;
        align-items: flex-end;
        padding: 12px 16px;

        /* mesma largura fixa: não pode pular ao mudar o número */
        width: clamp(168px, 50vw, 220px);
    }

    .sr-line {
        max-width: 15ch;
    }
}

@media (prefers-reduced-motion: reduce) {
    .sr-odo.is-max .sr-odo__digits {
        animation: none;
    }

    .sr-scanlines {
        display: none;
    }
}
