/* ==========================================================================
   Há Uma Luz — Nuno Sá | www.nunosa.com
   Estilos custom (efeitos analógicos, glassmorphism, glitch, social bar)
   Tokens de marca: design_system_e_branding_nuno_s.html
   ========================================================================== */

:root {
    --bg: #020001;
    --blue: #3AB4FF;
    --red: #D31826;
    --ink: #F6F4EE;
    --blue-deep: #071A33;
}

body {
    background-color: var(--bg);
    color: #e5e5e5;
    font-family: 'Space Mono', monospace;
    overflow: hidden;
    margin: 0;
    padding: 0;
    cursor: crosshair;
}

body.hover-screen {
    cursor: pointer !important;
}

/* Palco: 100dvh resolve a barra de endereço do iOS Safari (fallback 100vh) */
.stage {
    height: 100vh;
    height: 100dvh;
}

h1,
h2,
h3,
.font-syne {
    font-family: 'Syne', sans-serif;
}

/* --------------------------------------------------------------------------
   Efeitos Analógicos: CRT (scanlines) + Vignette
   -------------------------------------------------------------------------- */

.crt-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-image: repeating-linear-gradient(0deg,
            transparent,
            transparent 2px,
            rgba(0, 0, 0, 0.4) 2px,
            rgba(0, 0, 0, 0.4) 4px);
    pointer-events: none;
    z-index: 40;
    opacity: 0.6;
}

.vignette {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at center, transparent 28%, rgba(0, 0, 0, 0.9) 100%);
    pointer-events: none;
    z-index: 39;
}

/* Scrim de proteção do hero: contraste garantido no centro, túnel intacto nas margens */
.hero-scrim {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 5;
    background: radial-gradient(ellipse 62% 50% at 50% 48%, rgba(2, 0, 1, 0.75), transparent 74%);
}

/* --------------------------------------------------------------------------
   Glitch nos títulos (clip + text-shadow vermelho/azul de marca)
   -------------------------------------------------------------------------- */

/* Tamanho fluido em CSS estático: nunca transborda o viewport nem depende
   do JIT do Tailwind CDN em runtime (evita FOUC/overflow no primeiro frame) */
.glitch-text {
    position: relative;
    display: inline-block;
    font-size: clamp(2.25rem, 8.5vw, 6.5rem);
    line-height: 0.95;
    /* Ancora o título ao fundo mesmo com a luz do túnel atrás */
    text-shadow: 0 2px 18px rgba(2, 0, 1, 0.85);
}

/* Data de lançamento sob o título */
.release-tag {
    color: var(--ink);
    text-shadow: 0 0 10px rgba(246, 244, 238, 0.25);
}

/* --------------------------------------------------------------------------
   Proteção de legibilidade sobre a luz do túnel
   -------------------------------------------------------------------------- */

/* Véu quase impercetível atrás do bloco de CTAs: desfoca e escurece
   ligeiramente o brilho do fundo, com bordas dissolvidas por máscara radial */
.cta-cluster {
    position: relative;
}

.cta-cluster::before {
    content: '';
    position: absolute;
    inset: -16px -28px;
    z-index: -1;
    pointer-events: none;
    backdrop-filter: blur(2.5px) brightness(0.88);
    -webkit-backdrop-filter: blur(2.5px) brightness(0.88);
    -webkit-mask-image: radial-gradient(ellipse at center, black 55%, transparent 100%);
    mask-image: radial-gradient(ellipse at center, black 55%, transparent 100%);
}

#manifesto-display {
    text-shadow: 0 1px 8px rgba(2, 0, 1, 0.9);
}

.glitch-text::before,
.glitch-text::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.65;
}

.glitch-text::before {
    left: 1px;
    text-shadow: -1px 0 var(--red);
    clip: rect(24px, 550px, 90px, 0);
    animation: glitch-anim-2 5s infinite linear alternate-reverse;
}

.glitch-text::after {
    left: -1px;
    text-shadow: -1px 0 var(--blue);
    clip: rect(85px, 550px, 140px, 0);
    animation: glitch-anim 4s infinite linear alternate-reverse;
}

/* Falhas breves de sinal: a maior parte do ciclo fica parada (translate 0),
   com pequenos saltos de posição só nas janelas curtas de glitch — leve
   e discreto, não um efeito constante. */
@keyframes glitch-anim {
    0% {
        clip: rect(10px, 9999px, 44px, 0);
        transform: translate(0, 0);
    }

    4% {
        clip: rect(80px, 9999px, 12px, 0);
        transform: translate(-7px, 0);
    }

    8% {
        clip: rect(10px, 9999px, 44px, 0);
        transform: translate(0, 0);
    }

    50% {
        clip: rect(10px, 9999px, 44px, 0);
        transform: translate(0, 0);
    }

    52% {
        clip: rect(33px, 9999px, 88px, 0);
        transform: translate(7px, 0);
    }

    54% {
        clip: rect(90px, 9999px, 22px, 0);
        transform: translate(-5px, 0);
    }

    56% {
        clip: rect(33px, 9999px, 88px, 0);
        transform: translate(0, 0);
    }

    100% {
        clip: rect(44px, 9999px, 99px, 0);
        transform: translate(0, 0);
    }
}

@keyframes glitch-anim-2 {
    0% {
        clip: rect(65px, 9999px, 100px, 0);
        transform: translate(0, 0);
    }

    3% {
        clip: rect(12px, 9999px, 44px, 0);
        transform: translate(7px, 0);
    }

    6% {
        clip: rect(65px, 9999px, 100px, 0);
        transform: translate(0, 0);
    }

    60% {
        clip: rect(65px, 9999px, 100px, 0);
        transform: translate(0, 0);
    }

    62% {
        clip: rect(88px, 9999px, 11px, 0);
        transform: translate(-7px, 0);
    }

    64% {
        clip: rect(33px, 9999px, 90px, 0);
        transform: translate(5px, 0);
    }

    66% {
        clip: rect(65px, 9999px, 100px, 0);
        transform: translate(0, 0);
    }

    100% {
        clip: rect(22px, 9999px, 5px, 0);
        transform: translate(0, 0);
    }
}

/* --------------------------------------------------------------------------
   Painéis de vidro (glassmorphism escuro, bordas azul/vermelho subtis)
   -------------------------------------------------------------------------- */

.terminal-panel,
.hud-panel {
    background: rgba(4, 8, 14, 0.9);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(58, 180, 255, 0.3);
    box-shadow: 0 0 60px rgba(58, 180, 255, 0.15), inset 0 0 20px rgba(0, 0, 0, 1);
}

.hud-panel {
    border-left: 4px solid var(--red);
}

/* --------------------------------------------------------------------------
   Botões e ligações
   -------------------------------------------------------------------------- */

.social-link {
    position: relative;
    display: inline-block;
    padding: 0.5rem 1rem;
    color: #555;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    font-size: 0.75rem;
    background: none;
    border: none;
    font-family: inherit;
    transition: all 0.3s ease;
    cursor: pointer;
}

.social-link:hover {
    color: var(--ink);
    text-shadow: 0 0 8px rgba(246, 244, 238, 0.8);
    letter-spacing: 0.3em;
}

.ai-btn {
    position: relative;
    overflow: hidden;
    color: var(--ink);
    border: 1px solid rgba(211, 24, 38, 0.45);
    background: rgba(10, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: all 0.4s ease;
    cursor: pointer;
    animation: cta-breathe 4.5s ease-in-out infinite;
}

@keyframes cta-breathe {
    50% {
        box-shadow: 0 0 28px rgba(211, 24, 38, 0.25);
    }
}

.ai-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: radial-gradient(circle, rgba(211, 24, 38, 0.3) 0%, transparent 70%);
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
    z-index: -1;
    border-radius: 50%;
}

.ai-btn:hover {
    border-color: rgba(211, 24, 38, 0.8);
    color: var(--ink);
    box-shadow: 0 0 20px rgba(211, 24, 38, 0.4);
}

.ai-btn:hover::before {
    width: 300%;
    height: 300%;
}

/* --------------------------------------------------------------------------
   Barra de ícones sociais (SVG com glow cyberpunk)
   -------------------------------------------------------------------------- */

.social-bar {
    display: flex;
    align-items: center;
    gap: 1.75rem;
}

.social-icon {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    color: #8f8f8f;
    padding: 10px;
    /* alvo tátil ≥ 44px */
    text-decoration: none;
    transition: color 0.35s ease, transform 0.35s ease;
}

.social-icon svg {
    width: 34px;
    height: 34px;
    /* Saída do glitch: o sinal estabiliza suavemente */
    transition: filter 0.5s ease, transform 0.5s ease, opacity 0.5s ease;
}

.social-icon .social-label {
    font-size: 8px;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    opacity: 0;
    transform: translateY(-2px);
    transition: opacity 0.35s ease, transform 0.35s ease;
}

.social-icon:hover {
    color: var(--ink);
    transform: translateY(-2px);
}

.social-icon:hover .social-label {
    opacity: 0.7;
    transform: translateY(0);
}

.social-icon.glow-blue:hover svg {
    filter: drop-shadow(0 0 8px var(--blue)) drop-shadow(0 0 20px rgba(58, 180, 255, 0.4));
}

.social-icon.glow-red:hover svg {
    filter: drop-shadow(0 0 8px var(--red)) drop-shadow(0 0 20px rgba(211, 24, 38, 0.4));
}

/* --------------------------------------------------------------------------
   Glitch analógico no hover — falha de sinal CRT
   Entrada abrupta (transition: none + animação steps), saída suave via
   transition declarada no estado base ("o sinal estabiliza").
   -------------------------------------------------------------------------- */

.social-icon {
    position: relative;
}

/* Ruído estático sobre o ícone durante a falha */
.social-icon::before {
    content: '';
    position: absolute;
    inset: 6px;
    pointer-events: none;
    background:
        repeating-linear-gradient(0deg, rgba(246, 244, 238, 0.13) 0 1px, transparent 1px 3px),
        repeating-linear-gradient(90deg, rgba(211, 24, 38, 0.07) 0 2px, transparent 2px 5px);
    mix-blend-mode: screen;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.social-icon:hover svg {
    transition: none;
    /* entrada: 0ms */
    animation: icon-glitch 0.42s steps(1) infinite;
}

.social-icon:hover::before {
    transition: none;
    opacity: 1;
    animation: static-noise 0.28s steps(2) infinite;
}

/* RGB split direcional + rasgões horizontais (slice/tear) + queda de opacidade */
@keyframes icon-glitch {
    0% {
        filter: drop-shadow(-2px 0 rgba(211, 24, 38, 0.95)) drop-shadow(2px 0 rgba(58, 180, 255, 0.95));
        transform: translateX(0);
        clip-path: inset(0);
        opacity: 0.85;
    }

    12% {
        filter: drop-shadow(-3px 0 rgba(211, 24, 38, 0.95)) drop-shadow(3px 0 rgba(58, 180, 255, 0.95));
        transform: translateX(-2.5px) skewX(-8deg);
        clip-path: inset(14% 0 58% 0);
        opacity: 0.75;
    }

    24% {
        filter: drop-shadow(3px 0 rgba(211, 24, 38, 0.95)) drop-shadow(-3px 0 rgba(58, 180, 255, 0.95));
        transform: translateX(2px);
        clip-path: inset(0);
        opacity: 0.7;
    }

    38% {
        filter: drop-shadow(2px 0 rgba(211, 24, 38, 0.95)) drop-shadow(-2px 0 rgba(58, 180, 255, 0.95));
        transform: translateX(3px) skewX(6deg);
        clip-path: inset(55% 0 10% 0);
        opacity: 0.8;
    }

    52% {
        filter: drop-shadow(-1.5px 0 rgba(211, 24, 38, 0.9)) drop-shadow(1.5px 0 rgba(58, 180, 255, 0.9));
        transform: translateX(-1px);
        clip-path: inset(0);
        opacity: 0.95;
    }

    70% {
        filter: drop-shadow(-2.5px 0 rgba(211, 24, 38, 0.95)) drop-shadow(2.5px 0 rgba(58, 180, 255, 0.95));
        transform: translateX(1.5px) skewX(-4deg);
        clip-path: inset(30% 0 34% 0);
        opacity: 0.75;
    }

    86% {
        filter: drop-shadow(1px 0 rgba(211, 24, 38, 0.9)) drop-shadow(-1px 0 rgba(58, 180, 255, 0.9));
        transform: translateX(-2px);
        clip-path: inset(0);
        opacity: 0.9;
    }

    100% {
        filter: drop-shadow(-2px 0 rgba(211, 24, 38, 0.95)) drop-shadow(2px 0 rgba(58, 180, 255, 0.95));
        transform: translateX(0);
        clip-path: inset(0);
        opacity: 0.85;
    }
}

@keyframes static-noise {
    0% {
        transform: translateY(0);
        opacity: 0.9;
    }

    50% {
        transform: translateY(1px);
        opacity: 0.45;
    }

    100% {
        transform: translateY(-1px);
        opacity: 0.8;
    }
}

/* Variante em destaque, logo após o título */
.social-bar-hero {
    justify-content: center;
    gap: clamp(1.5rem, 5vw, 3rem);
}

.social-bar-hero .social-icon {
    color: #c4c4c4;
}

.social-bar-hero .social-icon svg {
    width: 42px;
    height: 42px;
}

.social-bar-hero .social-icon .social-label {
    font-size: 9px;
}

/* --------------------------------------------------------------------------
   Terminal: texto, cursor de escrita e modais
   -------------------------------------------------------------------------- */

.terminal-text {
    color: var(--blue);
    text-shadow: 0 0 8px rgba(58, 180, 255, 0.4);
}

/* Placeholder legível (~6.5:1) — o gray-800 original media 1.43:1 */
#user-input::placeholder {
    color: rgba(246, 244, 238, 0.38);
}

/* --------------------------------------------------------------------------
   3.º ato — informação objetiva (lançamento / onde ouvir)
   -------------------------------------------------------------------------- */

.info-strip {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 0.5rem;
}

.info-label {
    font-size: 9px;
    letter-spacing: 0.35em;
    text-transform: uppercase;
    color: #8f8f8f;
}

.presave-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    border: 1px solid rgba(58, 180, 255, 0.4);
    color: var(--blue);
    padding: 0.55rem 1.4rem;
    font-size: 10px;
    letter-spacing: 0.35em;
    text-transform: uppercase;
    text-decoration: none;
    background: rgba(2, 0, 1, 0.5);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transition: all 0.3s ease;
}

.presave-btn:hover {
    color: var(--ink);
    border-color: var(--blue);
    box-shadow: 0 0 18px rgba(58, 180, 255, 0.35);
}

.typing-cursor::after {
    content: ' ▌';
    animation: blink 1s step-start infinite;
}

@keyframes blink {
    50% {
        opacity: 0;
    }
}

#ai-modal,
#fragment-hud {
    transition: opacity 0.4s ease;
}

.modal-hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-visible {
    opacity: 1;
    pointer-events: auto;
}

/* --------------------------------------------------------------------------
   Ajustes mobile e movimento reduzido
   -------------------------------------------------------------------------- */

/* Em ecrãs pequenos, o ruído CRT penaliza demasiado a legibilidade do texto */
@media (max-width: 640px) {
    .crt-overlay {
        opacity: 0.35;
    }
}

@media (prefers-reduced-motion: reduce) {

    .glitch-text::before,
    .glitch-text::after {
        animation: none;
        opacity: 0.25;
    }

    .ai-btn {
        animation: none;
    }

    /* Sem glitch nos ícones: mantém-se apenas o glow estático */
    .social-icon:hover svg,
    .social-icon:hover::before {
        animation: none;
    }
}

/* Acessibilidade: rótulos apenas para leitores de ecrã */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}