/* ============================================================
   scientific.quest -- Encrypted Archive
   Palette:
     --void-navy: #0A0E1A  (primary background)
     --grid-blue: #1A2744  (panel surfaces)
     --neon-teal: #00E5CC  (accents / links)
     --deco-gold: #C5A55A  (borders / ornaments)
     --silver:    #7A8599  (body text)
     --warm-white:#E8E0D4  (headings)
     --alert:     #FF3366  (error / shake trigger color)
     --pure-white:#FFFFFF  (scanline tint)
   Fonts:
     Poiret One    -- display / headings
     Rajdhani      -- body
     Share Tech Mono -- metadata / codes
   ============================================================ */

:root {
    --void-navy:  #0A0E1A;
    --grid-blue:  #1A2744;
    --neon-teal:  #00E5CC;
    --deco-gold:  #C5A55A;
    --silver:     #7A8599;
    --warm-white: #E8E0D4;
    --alert:      #FF3366;
    --pure-white: #FFFFFF;

    --col-max:    880px;
    --chamfer:    12px;

    --f-display:  "Poiret One", "Inter", sans-serif;
    --f-body:     "Rajdhani", "Inter", sans-serif;
    --f-mono:     "Share Tech Mono", "Space Mono", monospace;
}

/* ------------------------------------------------------------
   Reset
   ------------------------------------------------------------ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    background-color: var(--void-navy);
}

body {
    min-height: 100vh;
    background-color: var(--void-navy);
    color: var(--silver);
    font-family: var(--f-body);
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.68;
    font-weight: 400;
    overflow-x: hidden;
    position: relative;
    letter-spacing: 0.01em;
}

/* Opening choreography: everything but the gate stays hidden
   until the body class is flipped. */
body.pre-enter .terminal-index,
body.pre-enter .terminal-depth,
body.pre-enter .terminal-cipher {
    opacity: 0;
    transform: translateY(24px);
}

/* ------------------------------------------------------------
   Scanline overlay (CRT atmosphere)
   ------------------------------------------------------------ */
.scanlines {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 40;
    background-image: repeating-linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0.03) 0,
        rgba(255, 255, 255, 0.03) 1px,
        transparent 1px,
        transparent 3px
    );
    opacity: 0;
    transition: opacity 900ms ease 1200ms;
    mix-blend-mode: screen;
}
body.entered .scanlines {
    opacity: 1;
}

.vignette {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 30;
    background:
        radial-gradient(ellipse at center, transparent 45%, rgba(10, 14, 26, 0.85) 100%),
        linear-gradient(180deg, rgba(26, 39, 68, 0.25) 0%, transparent 20%, transparent 80%, rgba(26, 39, 68, 0.25) 100%);
}

/* Low-key grid wash sitting below everything */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    background-image:
        linear-gradient(rgba(26, 39, 68, 0.45) 1px, transparent 1px),
        linear-gradient(90deg, rgba(26, 39, 68, 0.45) 1px, transparent 1px);
    background-size: 80px 80px;
    opacity: 0.35;
    mask-image: radial-gradient(ellipse at center, #000 0%, transparent 75%);
    -webkit-mask-image: radial-gradient(ellipse at center, #000 0%, transparent 75%);
}

/* ------------------------------------------------------------
   Shared terminal section layout
   ------------------------------------------------------------ */
.terminal {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: var(--col-max);
    margin: 0 auto;
    padding: 120px 32px;
}

.terminal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    padding-bottom: 18px;
    margin-bottom: 48px;
    border-bottom: 1px solid rgba(197, 165, 90, 0.35);
    flex-wrap: wrap;
}

.terminal-title {
    font-family: var(--f-display);
    color: var(--warm-white);
    font-size: clamp(2.2rem, 4.5vw, 3.6rem);
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    order: 2;
    flex: 1 1 100%;
    text-align: center;
    margin-top: 18px;
}

.terminal-header > .mono:first-of-type { order: 1; }
.terminal-header > .mono:last-of-type  { order: 3; }

.terminal-lede {
    max-width: 620px;
    margin: 0 auto 56px;
    text-align: center;
    color: var(--silver);
    font-size: clamp(1rem, 1.15vw, 1.1rem);
}

/* ------------------------------------------------------------
   Monospace metadata text style
   ------------------------------------------------------------ */
.mono {
    font-family: var(--f-mono);
    font-size: 0.78rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--deco-gold);
}

.mono-dot {
    color: var(--deco-gold);
    font-size: 0.55rem;
    opacity: 0.7;
}

.inline-tag {
    display: inline-block;
    padding: 2px 8px;
    margin: 0 2px;
    background-color: rgba(197, 165, 90, 0.08);
    border: 1px solid rgba(197, 165, 90, 0.45);
    color: var(--deco-gold);
    font-size: 0.72rem;
    letter-spacing: 0.15em;
    vertical-align: middle;
}

/* ============================================================
   TERMINAL I -- THE GATE
   ============================================================ */
.terminal-gate {
    min-height: 100vh;
    max-width: 100%;
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.gate-inner {
    position: relative;
    text-align: center;
    max-width: 720px;
    width: 100%;
    padding: 48px 16px;
}

.gate-lines {
    position: absolute;
    inset: 0;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}
.gate-line {
    position: absolute;
    top: 50%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--deco-gold) 40%, var(--deco-gold) 60%, transparent);
    width: 0;
    transition: width 1100ms cubic-bezier(0.2, 0.9, 0.2, 1) 1000ms;
}
.gate-line-left  { right: 50%; }
.gate-line-right { left: 50%; }
body.entered .gate-line-left,
body.entered .gate-line-right {
    width: 46vw;
}

.gate-meta {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 18px;
    color: var(--deco-gold);
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 700ms ease 1800ms, transform 700ms ease 1800ms;
}
.gate-meta-bottom { transition-delay: 2100ms; }
body.entered .gate-meta {
    opacity: 1;
    transform: translateY(0);
}

.monogram-frame {
    position: relative;
    display: inline-block;
    padding: 42px 64px 28px;
    margin: 36px auto;
}

.corner-bracket {
    position: absolute;
    width: 32px;
    height: 32px;
    opacity: 0;
    transition: opacity 700ms ease 1500ms;
}
body.entered .corner-bracket { opacity: 1; }
.corner-tl { top: 0; left: 0; }
.corner-tr { top: 0; right: 0; }
.corner-bl { bottom: 0; left: 0; }
.corner-br { bottom: 0; right: 0; }

.monogram {
    font-family: var(--f-display);
    color: var(--warm-white);
    font-size: clamp(3rem, 7vw, 6rem);
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    line-height: 1;
    opacity: 0;
    transform: scale(0.96);
    transition: opacity 800ms ease 500ms, transform 800ms ease 500ms;
    text-shadow:
        0 0 20px rgba(0, 229, 204, 0.18),
        0 0 3px rgba(232, 224, 212, 0.6);
}
body.entered .monogram {
    opacity: 1;
    transform: scale(1);
}

.mono-letter {
    display: inline-block;
}

.monogram-sub {
    font-family: var(--f-mono);
    color: var(--deco-gold);
    font-size: 0.85rem;
    letter-spacing: 0.35em;
    text-transform: uppercase;
    margin-top: 14px;
    opacity: 0;
    transition: opacity 700ms ease 1600ms;
}
body.entered .monogram-sub { opacity: 1; }

.gate-title {
    font-family: var(--f-mono);
    font-size: clamp(0.82rem, 1vw, 0.95rem);
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--warm-white);
    margin-top: 38px;
    opacity: 0;
    transition: opacity 700ms ease 2000ms;
}
body.entered .gate-title { opacity: 1; }
body.entered .gate-title.shake {
    animation: shake 280ms linear;
    color: var(--alert);
}

/* ============================================================
   CHEVRON DIVIDERS
   ============================================================ */
.chevron-divider {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 72px auto 0;
    width: 100%;
}
.chevron-svg {
    width: 180px;
    height: 56px;
    overflow: visible;
}
.chv {
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 500ms ease, transform 500ms ease;
}
.chevron-divider.in-view .chv-1 { opacity: 0.95; transform: translateY(0); transition-delay: 0ms; }
.chevron-divider.in-view .chv-2 { opacity: 0.8;  transform: translateY(0); transition-delay: 150ms; }
.chevron-divider.in-view .chv-3 { opacity: 0.65; transform: translateY(0); transition-delay: 300ms; }

/* Also light chevrons inside the gate once entered */
body.entered .terminal-gate .chv-1 { opacity: 0.95; transform: translateY(0); transition-delay: 2200ms; }
body.entered .terminal-gate .chv-2 { opacity: 0.8;  transform: translateY(0); transition-delay: 2350ms; }
body.entered .terminal-gate .chv-3 { opacity: 0.65; transform: translateY(0); transition-delay: 2500ms; }

/* ============================================================
   REVEAL ANIMATION (intersection observer)
   ============================================================ */
.reveal {
    opacity: 0;
    transform: translateY(32px);
    transition: opacity 900ms ease, transform 900ms ease;
}
.reveal.in-view {
    opacity: 1;
    transform: translateY(0);
}

/* ============================================================
   TERMINAL II -- THE INDEX
   ============================================================ */
.index-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.index-item {
    position: relative;
    display: grid;
    grid-template-columns: 90px 1fr auto;
    align-items: center;
    gap: 24px;
    padding: 22px 28px;
    background-color: rgba(26, 39, 68, 0.55);
    color: var(--warm-white);
    cursor: pointer;
    transition: background-color 260ms ease, color 260ms ease, transform 200ms ease;
    clip-path: polygon(
        12px 0,
        calc(100% - 12px) 0,
        100% 12px,
        100% calc(100% - 12px),
        calc(100% - 12px) 100%,
        12px 100%,
        0 calc(100% - 12px),
        0 12px
    );
}

/* Simulated chamfered gold border using a layered background */
.index-item {
    background-image:
        linear-gradient(var(--grid-blue), var(--grid-blue)),
        linear-gradient(135deg, var(--deco-gold), rgba(197, 165, 90, 0.25) 40%, var(--deco-gold));
    background-origin: border-box;
    background-clip: content-box, padding-box;
    border: 1px solid var(--deco-gold);
}

.index-item::before {
    content: "";
    position: absolute;
    left: 14px;
    top: 50%;
    width: 6px;
    height: 6px;
    background-color: var(--deco-gold);
    transform: translateY(-50%) rotate(45deg);
    opacity: 0.9;
    transition: background-color 260ms ease;
}

.index-code {
    color: var(--deco-gold);
    padding-left: 14px;
}

.index-name {
    font-family: var(--f-body);
    font-weight: 600;
    font-size: clamp(1rem, 1.25vw, 1.2rem);
    letter-spacing: 0.03em;
    color: var(--warm-white);
}

.index-tag {
    color: var(--deco-gold);
    opacity: 0.85;
}

.index-item:hover {
    background-image:
        linear-gradient(rgba(0, 229, 204, 0.08), rgba(0, 229, 204, 0.08)),
        linear-gradient(var(--grid-blue), var(--grid-blue)),
        linear-gradient(135deg, var(--neon-teal), rgba(0, 229, 204, 0.35) 40%, var(--neon-teal));
    background-origin: border-box;
    background-clip: content-box, content-box, padding-box;
    animation: shake 260ms linear;
    color: var(--neon-teal);
}
.index-item:hover .index-name { color: var(--neon-teal); }
.index-item:hover .index-code,
.index-item:hover .index-tag  { color: var(--neon-teal); }
.index-item:hover::before     { background-color: var(--neon-teal); }

.index-item.error-flash {
    animation: shake 260ms linear;
    color: var(--alert) !important;
}
.index-item.error-flash .index-name,
.index-item.error-flash .index-code,
.index-item.error-flash .index-tag {
    color: var(--alert);
}
.index-item.error-flash::before {
    background-color: var(--alert);
}

/* ============================================================
   TERMINAL III -- THE DEPTH
   ============================================================ */
.depth-article {
    max-width: 680px;
    margin: 0 auto;
}

.depth-para {
    margin-bottom: 32px;
    color: var(--silver);
    font-size: clamp(1rem, 1.2vw, 1.12rem);
    line-height: 1.78;
}

.pullquote {
    position: relative;
    margin: 56px auto;
    padding: 56px 48px 48px;
    background-color: rgba(26, 39, 68, 0.4);
    border-top: 1px solid rgba(197, 165, 90, 0.35);
    border-bottom: 1px solid rgba(197, 165, 90, 0.35);
}

.pullquote p {
    font-family: var(--f-display);
    color: var(--warm-white);
    font-size: clamp(1.4rem, 2.4vw, 2.1rem);
    line-height: 1.45;
    letter-spacing: 0.04em;
    text-align: center;
}

.pq-bracket {
    position: absolute;
    width: 40px;
    height: 40px;
}
.pq-tl { top: 12px; left: 12px; }
.pq-br { bottom: 12px; right: 12px; }

.pq-cite {
    display: block;
    margin-top: 28px;
    text-align: center;
    color: var(--deco-gold);
    font-size: 0.78rem;
    letter-spacing: 0.22em;
    font-style: normal;
}

/* ============================================================
   TERMINAL IV -- THE CIPHER
   ============================================================ */
.terminal-cipher {
    text-align: center;
    padding-bottom: 160px;
}

.cipher-emblem {
    display: flex;
    justify-content: center;
    margin: 24px auto 48px;
}
.emblem-svg {
    width: 280px;
    height: auto;
    overflow: visible;
    filter: drop-shadow(0 0 6px rgba(0, 229, 204, 0.15));
}

.cipher-line {
    font-family: var(--f-display);
    font-size: clamp(1.4rem, 2.6vw, 2.2rem);
    color: var(--warm-white);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    margin-bottom: 22px;
}

.cipher-sub {
    color: var(--deco-gold);
    letter-spacing: 0.3em;
}

.terminal-foot {
    margin-top: 120px;
    padding-top: 28px;
    border-top: 1px solid rgba(197, 165, 90, 0.35);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
}

/* ============================================================
   KEYFRAMES
   ============================================================ */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    15% { transform: translateX(-2px); }
    30% { transform: translateX(2px); }
    45% { transform: translateX(-2px); }
    60% { transform: translateX(2px); }
    75% { transform: translateX(-1px); }
    90% { transform: translateX(1px); }
}

@keyframes pulse-teal {
    0%, 100% { opacity: 0.6; }
    50%      { opacity: 1; }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 680px) {
    .terminal {
        padding: 80px 20px;
    }

    .terminal-header {
        flex-direction: column;
        text-align: center;
        gap: 8px;
    }
    .terminal-header > .mono:first-of-type,
    .terminal-header > .mono:last-of-type {
        order: unset;
    }
    .terminal-title {
        order: unset;
        margin-top: 4px;
    }

    .index-item {
        grid-template-columns: 70px 1fr;
        gap: 12px;
        padding: 18px 22px;
    }
    .index-tag {
        grid-column: 1 / -1;
        text-align: right;
    }

    .pullquote {
        padding: 48px 28px 36px;
    }

    .monogram-frame {
        padding: 32px 36px 20px;
    }

    .gate-meta {
        gap: 10px;
        flex-wrap: wrap;
        font-size: 0.7rem;
    }
}
