/* ================================================================
   TWITCHER WORKBENCH — Splash screen
   Brand moment on launch: nucleotide scramble + brand lock-in.
   Uses the same tokens as 00-base-shell-header.css and adapts to
   the active theme (dark / light) via the shared CSS variables.
   ================================================================ */

/* ── Overlay ─────────────────────────────────────────────────── */
.splash {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: opacity 0.6s ease, visibility 0.6s ease;

    /* Theme-aware accent helpers (auto-adapt to light/dark). */
    --splash-accent: var(--accent);
    --splash-accent-soft: color-mix(in srgb, var(--accent) 12%, transparent);
    --splash-accent-glow: color-mix(in srgb, var(--accent) 50%, transparent);
    --splash-grid: color-mix(in srgb, var(--accent) 4%, transparent);
}

.splash.hide {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* No-JS fallback: hide the splash so the app stays usable. */
.splash {
    animation: splash-auto-hide 0.6s ease 6.5s forwards;
}

@keyframes splash-auto-hide {
    to {
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
    }
}

/* ── Background ──────────────────────────────────────────────── */
.splash-bg-grid {
    position: absolute;
    inset: 0;
    background-image: linear-gradient(var(--splash-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--splash-grid) 1px, transparent 1px);
    background-size: 44px 44px;
    -webkit-mask-image: radial-gradient(ellipse 70% 70% at 50% 50%, #000 30%, transparent 78%);
    mask-image: radial-gradient(ellipse 70% 70% at 50% 50%, #000 30%, transparent 78%);
}

.splash-glow {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse 60% 50% at 50% 45%, var(--splash-accent-soft) 0%, transparent 65%);
}

/* ── Content ────────────────────────────────────────────────── */
.splash-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 2rem;
}

.splash-content > * {
    opacity: 0;
    animation: splash-fade 0.6s ease forwards;
}

.splash-logo { animation-delay: 0.1s; }
.splash-word { animation-delay: 0.25s; }

/* Tagline, divider, and workbench are revealed in sequence by JS
   after the TWITCHER scramble completes. */
.splash-tagline,
.splash-divider,
.splash-workbench {
    animation: none;
    opacity: 0;
}

.splash-tagline.reveal,
.splash-divider.reveal,
.splash-workbench.reveal {
    animation: splash-fade 0.5s ease forwards;
}

@keyframes splash-fade {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Logo ───────────────────────────────────────────────────── */
.splash-logo {
    position: relative;
    width: 84px;
    height: 84px;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.splash-logo svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 0 18px var(--splash-accent-glow));
}

.splash-logo-ring {
    position: absolute;
    inset: -16px;
    border-radius: 50%;
    border: 1px solid var(--splash-accent-soft);
    animation: splash-ring 2.4s ease-out infinite;
}

@keyframes splash-ring {
    0% {
        transform: scale(0.55);
        opacity: 0;
    }
    40% {
        opacity: 0.7;
    }
    100% {
        transform: scale(1.45);
        opacity: 0;
    }
}

/* ── Word (nucleotide scramble) ─────────────────────────────── */
.splash-word {
    font-family: 'Syne', system-ui, sans-serif;
    font-weight: 800;
    font-size: clamp(3rem, 12vw, 6.5rem);
    letter-spacing: 0.08em;
    line-height: 1;
    color: var(--accent);
    display: flex;
    gap: 0.02em;
    user-select: none;
}

.splash-char {
    display: inline-block;
    /* No color transition: the scramble snaps instantly so no
       nucleotide colour lingers once a letter locks in. */
    transition: text-shadow 0.25s ease, transform 0.25s ease;
}

/* Standard bioinformatics nucleotide colouring (A/T/G/C). */
.splash-char.nuc-A { color: #4caf50; } /* Adenine  — green  */
.splash-char.nuc-T { color: #f44336; } /* Thymine  — red    */
.splash-char.nuc-G { color: #ff9800; } /* Guanine  — orange */
.splash-char.nuc-C { color: #2196f3; } /* Cytosine — blue   */

/* Locked letters match the rest of the brand word (theme text
   colour) — no nucleotide colour remains after the scramble. */
.splash-char.locked {
    color: var(--text);
    text-shadow: 0 0 26px var(--splash-accent-glow);
    animation: splash-lock-pop 0.3s ease;
}

@keyframes splash-lock-pop {
    0% {
        transform: scale(1.25);
    }
    100% {
        transform: scale(1);
    }
}

/* ── Tagline ────────────────────────────────────────────────── */
.splash-tagline {
    margin-top: 1.1rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: clamp(0.8rem, 2.4vw, 1.05rem);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--text-mid);
}

/* The letters that spell TWITCHER (T · WITCH · ER) are highlighted
   and pop in order after the scramble completes. */
.tag-hl {
    color: var(--accent);
    font-weight: 600;
    opacity: 0.25;
    transition: opacity 0.3s ease, text-shadow 0.3s ease, transform 0.3s ease;
}

.tag-hl.pop {
    opacity: 1;
    text-shadow: 0 0 18px var(--splash-accent-glow);
    animation: tag-pop 0.4s ease;
}

@keyframes tag-pop {
    0% {
        transform: scale(1.45);
    }
    100% {
        transform: scale(1);
    }
}

/* ── Divider + Workbench chip ───────────────────────────────── */
.splash-divider {
    width: 1px;
    height: 34px;
    background: linear-gradient(var(--accent), transparent);
    margin: 1.4rem 0;
}

.splash-workbench {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.45rem;
}

.splash-workbench-label {
    font-family: 'Syne', system-ui, sans-serif;
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--text);
    padding: 0.45rem 1.2rem;
    border: 1px solid var(--border-mid);
    border-radius: 999px;
    background: var(--surface-2);
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.4);
    transition: color 0.4s ease;
}

/* Once revealed, the Workbench chip pulses with the brand accent so
   it clearly reads as the sub-tool. */
.splash-workbench.reveal .splash-workbench-label {
    color: var(--accent);
    animation: wb-glow 1.8s ease-in-out infinite;
}

@keyframes wb-glow {
    0%, 100% {
        border-color: var(--border-mid);
        box-shadow: 0 0 0 transparent;
    }
    50% {
        border-color: var(--splash-accent-soft);
        box-shadow: 0 0 28px var(--splash-accent-glow);
    }
}

.splash-workbench-sub {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    color: var(--text-dim);
    letter-spacing: 0.08em;
}

/* ── Scrolling DNA sequence strip ───────────────────────────── */
.splash-sequence {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 5.5rem;
    z-index: 1;
    overflow: hidden;
    height: 2rem;
    display: flex;
    align-items: center;
    opacity: 0.5;
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 15%, #000 85%, transparent);
    mask-image: linear-gradient(90deg, transparent, #000 15%, #000 85%, transparent);
}

.splash-sequence-inner {
    display: flex;
    gap: 0.9rem;
    white-space: nowrap;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    letter-spacing: 0.1em;
    color: var(--text-dim);
    animation: seq-scroll 24s linear infinite;
}

@keyframes seq-scroll {
    from {
        transform: translateX(0);
    }
    to {
        transform: translateX(-50%);
    }
}

/* ── Footer ─────────────────────────────────────────────────── */
.splash-footer {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2;
    padding: 1.5rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.splash-progress {
    height: 2px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.splash-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent), var(--splash-accent));
    box-shadow: 0 0 12px var(--splash-accent-glow);
}

.splash-footer-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.68rem;
    color: var(--text-dim);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    text-align: center;
}

/* ── Zoom-into-the-eye exit (Netflix-style) ─────────────────── */
/* The whole splash zooms in as one unit — every element stays
   visible and rushes toward the viewer / into the eye. Meanwhile
   the main page is revealed underneath, starting small (far away)
   and settling into its regular place. Both run in lockstep so the
   transition is continuous — no disappearance/appearance pop. */
.splash.zoom-out {
    animation: splash-zoom-in 1.1s cubic-bezier(0.956, 0.079, 0.14, 1) forwards;
}

@keyframes splash-zoom-in {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(20);
        opacity: 0;
    }
}

/* The main page starts small in the distance and grows into place,
   so the user flies through the eye into the app. */
.app-shell.zoom-in {
    animation: app-zoom-in 1.1s cubic-bezier(0.956, 0.079, 0.14, 1) forwards;
}

@keyframes app-zoom-in {
    0% {
        transform: scale(0.05);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ── Reduced motion ─────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .splash-content > * {
        animation: none;
        opacity: 1;
    }

    .splash-logo-ring,
    .splash-sequence-inner {
        animation: none;
    }
}
