/**
 * Splash Page Styles
 * Animated colored stripes - matches Flutter splash.dart animation
 */

#splash-page {
    position: absolute; top: 0; left: 0;
    width: 1920px; height: 1080px;
    overflow: hidden;
    background: var(--brand-gradient);
}

/* Color stripes that slide in from left */
.splash-stripe {
    position: absolute;
    top: 0; bottom: 0; left: 0;
    right: 100%; /* starts off-screen right */
    transition: right 0.2s ease;
}

.splash-stripe-0 { z-index: 1; }
.splash-stripe-1 { z-index: 2; }
.splash-stripe-2 { z-index: 3; }
.splash-stripe-3 { z-index: 4; }
.splash-stripe-4 { z-index: 5; }
.splash-stripe-5 { z-index: 6; }
.splash-stripe-6 { z-index: 7; }

/* Center brand panel — fills the entire screen in brand color once the
 * stripe animation completes (matches Flutter _p_9 expanding to left:0,
 * right:0). The logo + divider + boot text are centered inside it. */
#splash-center {
    position: absolute; top: 0; right: 0; bottom: 0; left: 0;
    display: flex; align-items: center; justify-content: center;
    z-index: 20;
    opacity: 0;
    background: var(--brand-gradient);
    transition: opacity 0.3s ease;
    pointer-events: none;
}
#splash-center.visible { opacity: 1; }

.splash-center-content {
    display: flex; align-items: center; gap: 40px;
    padding: 60px 80px;
}

#splash-logo {
    max-width: 450px; max-height: 150px;   /* ~1.5x for the 1080 canvas */
    object-fit: contain;
    opacity: 0;
    transition: opacity 0.4s ease;
}
#splash-logo.visible { opacity: 1; }

#splash-divider {
    width: 1px; height: 150px;
    background: rgba(255,255,255,0.4);
    opacity: 0;
    transition: opacity 0.3s ease;
}
#splash-divider.visible { opacity: 1; }

#splash-boot-text {
    font-family: var(--font-brand);
    font-size: 32px; font-weight: 900;
    color: var(--text-primary);
    white-space: pre-line;
    max-width: 400px;
    opacity: 0;
    transform: translateX(-30px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}
#splash-boot-text.visible {
    opacity: 1;
    transform: translateX(0);
}

/* Telco/Redmi composition. Kept behind the flavor attribute so the existing
   Nexora animation remains byte-for-byte in behavior and appearance. */
.splash-telco-ambient,
.mastv-signal-stage,
#splash-wordmark,
#splash-subtitle,
.splash-progress { display: none; }

/* MasTV signal ident. Everything is gated to mastv so legacy and telco keep
   their existing composition. The 1920x1080 coordinates intentionally match
   the fixed TV canvas and are released by the responsive layer. */
html[data-brand="mastv"] #splash-page {
    background:
        radial-gradient(circle at 50% 48%, var(--brand-surface2) 0, var(--brand-navy2) 24%, var(--brand-navy) 62%),
        var(--brand-navy);
}
html[data-brand="mastv"] .splash-stripe { display: none; }
html[data-brand="mastv"] .mastv-signal-stage {
    display: block;
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    z-index: 8;
    overflow: hidden;
    pointer-events: none;
}
html[data-brand="mastv"] .mastv-grid {
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    opacity: .12;
    background-image:
        linear-gradient(rgba(197,241,58,.12) 1px, transparent 1px),
        linear-gradient(90deg, rgba(197,241,58,.12) 1px, transparent 1px);
    background-size: 72px 72px;
    transform: perspective(520px) rotateX(58deg) scale(1.8) translateY(210px);
    transform-origin: 50% 100%;
    animation: mastv-grid-breathe 4.8s ease-in-out infinite;
}
html[data-brand="mastv"] .mastv-scanline {
    position: absolute;
    left: 0; top: -30%;
    width: 100%; height: 25%;
    opacity: .16;
    background: linear-gradient(to bottom, transparent, rgba(197,241,58,.42), transparent);
    animation: mastv-scan 3.4s linear infinite;
}
html[data-brand="mastv"] .mastv-signal-beam {
    position: absolute;
    left: 50%; top: 50%;
    width: 1180px; height: 2px;
    margin-left: -590px;
    background: linear-gradient(90deg, transparent, var(--brand-accent-color), var(--brand-focus), var(--brand-accent-color), transparent);
    box-shadow: 0 0 18px var(--brand-focus-glow);
    opacity: 0;
    transform-origin: 50% 50%;
}
html[data-brand="mastv"] .mastv-signal-beam-a {
    transform: rotate(12deg) scaleX(.2);
    animation: mastv-beam-a 2.4s cubic-bezier(.2,.78,.2,1) .25s forwards;
}
html[data-brand="mastv"] .mastv-signal-beam-b {
    transform: rotate(-12deg) scaleX(.2);
    animation: mastv-beam-b 2.4s cubic-bezier(.2,.78,.2,1) .35s forwards;
}
html[data-brand="mastv"] .mastv-orbit,
html[data-brand="mastv"] .mastv-play-pulse {
    position: absolute;
    left: 50%; top: 50%;
    border: 2px solid rgba(197,241,58,.34);
    border-radius: 50%;
    opacity: 0;
    transform: translate(-50%, -50%) scale(.2);
}
html[data-brand="mastv"] .mastv-orbit-a {
    width: 410px; height: 410px;
    animation: mastv-wave 2.7s cubic-bezier(.18,.8,.2,1) .55s infinite;
}
html[data-brand="mastv"] .mastv-orbit-b {
    width: 620px; height: 620px;
    border-color: rgba(164,207,8,.18);
    animation: mastv-wave 2.7s cubic-bezier(.18,.8,.2,1) 1.15s infinite;
}
html[data-brand="mastv"] .mastv-play-pulse {
    width: 116px; height: 116px;
    border: 0;
    opacity: 1;
    background: var(--brand-focus);
    box-shadow: 0 0 34px var(--brand-focus-glow), 0 0 100px var(--brand-accent-soft);
    animation: mastv-core 2.2s cubic-bezier(.2,.8,.2,1) .35s forwards;
}
html[data-brand="mastv"] .mastv-equalizer {
    position: absolute;
    left: 50%; top: 50%;
    width: 360px; height: 84px;
    margin-left: -180px; margin-top: -260px;
    text-align: center;
    opacity: 0;
    animation: mastv-eq-reveal .45s ease 1.85s forwards;
}
html[data-brand="mastv"] .mastv-equalizer i {
    display: inline-block;
    width: 5px; height: 14px;
    margin: 0 9px;
    vertical-align: middle;
    border-radius: 4px;
    background: var(--brand-focus);
    box-shadow: 0 0 12px var(--brand-focus-glow);
    animation: mastv-eq 1.05s ease-in-out infinite alternate;
}
html[data-brand="mastv"] .mastv-equalizer i:nth-child(2),
html[data-brand="mastv"] .mastv-equalizer i:nth-child(8) { animation-delay: -.72s; }
html[data-brand="mastv"] .mastv-equalizer i:nth-child(3),
html[data-brand="mastv"] .mastv-equalizer i:nth-child(7) { animation-delay: -.46s; }
html[data-brand="mastv"] .mastv-equalizer i:nth-child(4),
html[data-brand="mastv"] .mastv-equalizer i:nth-child(6) { animation-delay: -.18s; }
html[data-brand="mastv"] #splash-center {
    z-index: 20;
    background: transparent;
    transition: opacity .35s ease;
}
html[data-brand="mastv"] .splash-center-content {
    position: absolute;
    left: 960px; top: 350px;
    width: 1040px;
    margin-left: -520px;
    padding: 44px 0 54px;
    display: block;
    text-align: center;
    border-radius: 46px;
    background: radial-gradient(ellipse at 50% 44%, rgba(197,241,58,.09), rgba(24,34,15,.18) 45%, transparent 72%);
}
html[data-brand="mastv"] .mastv-logo-window {
    position: relative;
    width: 680px; height: 280px;
    margin: 0 auto;
    overflow: hidden;
    border: 1px solid rgba(197,241,58,.22);
    border-radius: 42px;
    opacity: 0;
    transform: translateY(18px) scale(.94);
    background: linear-gradient(112deg, rgba(255,255,255,.96), rgba(238,246,231,.86));
    box-shadow: 0 28px 80px rgba(0,0,0,.38), 0 0 48px rgba(164,207,8,.10);
    transition: opacity .6s ease, transform .8s cubic-bezier(.18,.85,.22,1);
}
html[data-brand="mastv"] .mastv-logo-window.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    animation: mastv-logo-settle .9s ease 1;
}
html[data-brand="mastv"] #splash-logo {
    position: absolute;
    display: block;
    left: 100px; top: 0;
    width: 1185px; height: 280px;
    max-width: none; max-height: none;
    margin: 0;
    opacity: 1;
    transform: none;
    filter: none;
    transition: none;
}
html[data-brand="mastv"] #splash-logo.visible {
    opacity: 1;
    transform: none;
    animation: none;
}
html[data-brand="mastv"] #splash-divider {
    width: 0; height: 3px;
    margin: 18px auto 0;
    border-radius: 3px;
    opacity: 0;
    background: linear-gradient(90deg, transparent, var(--brand-accent-color), var(--brand-focus), var(--brand-accent-color), transparent);
    box-shadow: 0 0 18px var(--brand-focus-glow);
    transition: width .7s cubic-bezier(.18,.85,.22,1), opacity .3s ease;
}
html[data-brand="mastv"] #splash-divider.visible { width: 460px; opacity: .86; }
html[data-brand="mastv"] #splash-boot-text {
    max-width: none;
    margin-top: 24px;
    font-family: var(--font-brand);
    font-size: 30px;
    font-weight: 700;
    letter-spacing: 5px;
    color: var(--brand-muted);
    opacity: 0;
    transform: translateY(14px);
    transition: opacity .55s ease, transform .55s ease;
}
html[data-brand="mastv"] #splash-boot-text.visible { opacity: 1; transform: translateY(0); }

@keyframes mastv-grid-breathe {
    0%, 100% { opacity: .08; }
    50% { opacity: .16; }
}
@keyframes mastv-scan {
    0% { top: -30%; }
    100% { top: 115%; }
}
@keyframes mastv-beam-a {
    0% { opacity: 0; transform: rotate(12deg) scaleX(.2); }
    38% { opacity: .72; }
    100% { opacity: 0; transform: rotate(0) scaleX(1); }
}
@keyframes mastv-beam-b {
    0% { opacity: 0; transform: rotate(-12deg) scaleX(.2); }
    38% { opacity: .58; }
    100% { opacity: 0; transform: rotate(0) scaleX(1); }
}
@keyframes mastv-wave {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(.2); }
    24% { opacity: .55; }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(1.32); }
}
@keyframes mastv-core {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(.2); }
    40% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    72% { opacity: .84; transform: translate(-50%, -50%) scale(.82); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(1.5); }
}
@keyframes mastv-eq-reveal { to { opacity: .65; } }
@keyframes mastv-eq {
    from { height: 8px; opacity: .42; }
    to { height: 48px; opacity: 1; }
}
@keyframes mastv-logo-settle {
    0%, 100% { box-shadow: 0 28px 80px rgba(0,0,0,.38), 0 0 48px rgba(164,207,8,.10); }
    45% { box-shadow: 0 28px 80px rgba(0,0,0,.38), 0 0 58px var(--brand-focus-glow); }
}

@media (max-width: 1599px) {
    html[data-brand="mastv"] .splash-center-content {
        left: 50vw; top: 30vh;
        width: 88vw;
        margin-left: -44vw;
        padding: 4vh 0;
    }
    html[data-brand="mastv"] .mastv-logo-window {
        width: 68vw; max-width: 680px;
        height: 28vw; max-height: 280px;
    }
    html[data-brand="mastv"] #splash-logo {
        left: 10vw;
        width: 118.5vw; max-width: 1185px;
        height: 28vw; max-height: 280px;
    }
    html[data-brand="mastv"] #splash-divider.visible { width: 38vw; max-width: 460px; }
    html[data-brand="mastv"] .mastv-equalizer { top: 50%; margin-top: -30vw; }
}

@media (prefers-reduced-motion: reduce) {
    html[data-brand="mastv"] .mastv-grid,
    html[data-brand="mastv"] .mastv-scanline,
    html[data-brand="mastv"] .mastv-signal-beam,
    html[data-brand="mastv"] .mastv-orbit,
    html[data-brand="mastv"] .mastv-play-pulse,
    html[data-brand="mastv"] .mastv-equalizer,
    html[data-brand="mastv"] .mastv-equalizer i,
    html[data-brand="mastv"] .mastv-logo-window.visible { animation: none; }
    html[data-brand="mastv"] .mastv-grid { opacity: .08; }
    html[data-brand="mastv"] .mastv-scanline,
    html[data-brand="mastv"] .mastv-signal-beam,
    html[data-brand="mastv"] .mastv-orbit,
    html[data-brand="mastv"] .mastv-play-pulse { display: none; }
    html[data-brand="mastv"] .mastv-equalizer { opacity: .45; }
    html[data-brand="mastv"] .mastv-equalizer i { height: 18px; }
}

html[data-brand="telco"] #splash-page {
    background:
        radial-gradient(circle at 50% 42%, rgba(122,63,242,.16) 0, transparent 34%),
        radial-gradient(circle at 50% 50%, var(--brand-navy) 0, var(--brand-navy2) 100%);
}
html[data-brand="telco"] .splash-stripe { display: none; }
html[data-brand="telco"] .splash-telco-ambient {
    display: block;
    position: absolute;
    left: 50%; top: 50%;
    width: 720px; height: 720px;
    border: 2px solid rgba(247,147,30,.18);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 90px rgba(122,63,242,.18), inset 0 0 90px rgba(247,147,30,.08);
}
html[data-brand="telco"] #splash-center {
    background: transparent;
}
/* Centrado a prueba del Chromium viejo de webOS: NO usar inset:0 (no soportado,
   deja #splash-center en 0x0). Posición explícita 960/540 + translate -50%. */
html[data-brand="telco"] .splash-center-content {
    position: absolute;
    left: 960px; top: 540px;
    transform: translate(-50%, -50%);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    width: auto;
    padding: 0;
}
/* El logo (lockup Zorro + "telco") ya trae el wordmark, así que se muestra
   centrado y el #splash-wordmark de texto se oculta para no duplicar "telco". */
html[data-brand="telco"] #splash-logo {
    width: auto;
    height: 420px;
    max-width: 1280px;
    max-height: 48vh;
    filter: drop-shadow(0 22px 54px rgba(0,0,0,.42));
}
html[data-brand="telco"] #splash-divider,
html[data-brand="telco"] #splash-boot-text,
html[data-brand="telco"] #splash-wordmark { display: none; }
html[data-brand="telco"] #splash-subtitle,
html[data-brand="telco"] .splash-progress { display: block; }
html[data-brand="telco"] #splash-wordmark {
    font-family: var(--font-brand);
    font-size: 72px;
    line-height: 1;
    font-weight: 800;
    letter-spacing: 12px;
    color: #FFFFFF;
    opacity: 0;
    transform: translateY(16px);
    transition: opacity .5s ease, transform .5s ease;
}
html[data-brand="telco"] #splash-subtitle {
    margin-top: 12px;
    font-family: var(--font);
    font-size: 28px;
    font-weight: 500;
    letter-spacing: 1.1px;
    color: var(--brand-muted);
    opacity: 0;
    transition: opacity .5s ease .08s;
}
html[data-brand="telco"] #splash-wordmark.visible,
html[data-brand="telco"] #splash-subtitle.visible { opacity: 1; transform: translateY(0); }
html[data-brand="telco"] .splash-progress {
    width: 520px;
    height: 8px;
    margin-top: 28px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255,255,255,.12);
}
html[data-brand="telco"] .splash-progress-bar {
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--brand-amber), var(--brand-accent), var(--brand-magenta));
}
html[data-brand="telco"] #splash-center.visible .splash-progress-bar {
    animation: telco-splash-progress 4.55s linear forwards;
}
@keyframes telco-splash-progress { to { width: 100%; } }

/* Chrome 79 flex-gap fallback. */
html.no-flex-gap .splash-center-content > * + * { margin-left: 40px; }
html.no-flex-gap[data-brand="mastv"] .splash-center-content > * + * { margin-left: auto; }
