/* ==========================================================
   archetypic.dev
   Midnight Candlelight / Anti-Design / Condensed Tension
   ========================================================== */

:root {
    --bg-deep:       #070B1A;   /* Abyssal Blue */
    --bg-mid:        #0D1B3E;   /* Midnight Ink */
    --text-primary:  #C8D0E0;   /* Lunar Silver */
    --text-secondary:#3A4F7A;   /* Dim Channel */
    --accent-warm:   #FFEAB6;   /* Candle Glow */
    --accent-hot:    #C93545;   /* Archetype Red */
    --violet:        #2A1B4E;   /* Deep Violet */
    --smoke-glass:   rgba(13, 27, 62, 0.7);

    --col-width: 680px;

    --font-display: "Barlow Condensed", "Inter", sans-serif;
    --font-body:    "Source Serif 4", "Lora", Georgia, serif;
    --font-mono:    "JetBrains Mono", "Space Mono", monospace;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    background-color: var(--bg-deep);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 18px;
    line-height: 1.65;
    min-height: 100%;
    overflow-x: hidden;
}

body {
    position: relative;
    background-image:
        radial-gradient(ellipse 900px 600px at 20% 15%, rgba(42, 27, 78, 0.35), transparent 70%),
        radial-gradient(ellipse 1100px 700px at 85% 85%, rgba(13, 27, 62, 0.55), transparent 70%),
        linear-gradient(180deg, #050814 0%, #070B1A 50%, #050814 100%);
    background-attachment: fixed;
}

/* ----------------------------------------------------------
   Global overlays: scanlines + vignette
   ---------------------------------------------------------- */

.scanlines {
    position: fixed;
    inset: 0;
    z-index: 50;
    pointer-events: none;
    background-image: repeating-linear-gradient(
        to bottom,
        transparent 0,
        transparent 1px,
        rgba(7, 11, 26, 0.28) 1px,
        rgba(7, 11, 26, 0.28) 2px
    );
    mix-blend-mode: multiply;
    opacity: 0.75;
}

.vignette {
    position: fixed;
    inset: 0;
    z-index: 51;
    pointer-events: none;
    background: radial-gradient(ellipse at center, transparent 30%, rgba(7, 11, 26, 0.65) 100%);
}

/* ----------------------------------------------------------
   Flicker engine
   ---------------------------------------------------------- */

@keyframes flicker {
    0%   { opacity: 0.98; transform: scale(1.00); }
    12%  { opacity: 0.72; transform: scale(0.995); }
    23%  { opacity: 0.91; transform: scale(1.01); }
    37%  { opacity: 0.61; transform: scale(0.99); }
    48%  { opacity: 1.00; transform: scale(1.015); }
    59%  { opacity: 0.83; transform: scale(1.005); }
    71%  { opacity: 0.55; transform: scale(0.985); }
    84%  { opacity: 0.94; transform: scale(1.02); }
    100% { opacity: 0.78; transform: scale(1.00); }
}

[data-flame] {
    animation: flicker 3.7s infinite ease-in-out;
    animation-delay: var(--flame-delay, 0s);
    will-change: opacity, transform;
}

@keyframes sigil-rotate {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* ----------------------------------------------------------
   Sections
   ---------------------------------------------------------- */

.section {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12vh 24px;
    overflow: hidden;
}

.section.chamber {
    min-height: 85vh;
}

.threshold {
    min-height: 100vh;
    padding-top: 20vh;
    padding-bottom: 20vh;
}

.column {
    position: relative;
    z-index: 2;
    max-width: var(--col-width);
    width: 100%;
    margin: 0 auto;
}

/* ----------------------------------------------------------
   Candle bloom
   ---------------------------------------------------------- */

.bloom {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 480px;
    height: 360px;
    background: radial-gradient(
        ellipse at center,
        rgba(255, 234, 182, 0.10) 0%,
        rgba(255, 234, 182, 0.04) 35%,
        transparent 72%
    );
    pointer-events: none;
    z-index: 1;
    filter: blur(6px);
}

.bloom--large {
    width: 780px;
    height: 560px;
    background: radial-gradient(
        ellipse at center,
        rgba(255, 234, 182, 0.12) 0%,
        rgba(201, 53, 69, 0.05) 30%,
        rgba(42, 27, 78, 0.3) 55%,
        transparent 80%
    );
}

/* ----------------------------------------------------------
   Typography — Display
   ---------------------------------------------------------- */

.display {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(3rem, 8vw, 7rem);
    line-height: 0.92;
    letter-spacing: -0.03em;
    text-transform: uppercase;
    color: var(--text-primary);
    margin-bottom: 0.6em;
    position: relative;
    text-shadow: 0 0 0 transparent, 0 0 0 transparent, 0 0 0 transparent;
    transition: text-shadow 0.3s cubic-bezier(.2,.8,.3,1);
}

.display .char {
    display: inline-block;
    transform: translateY(calc(var(--jitter, 0) * 1px));
    transition: transform 0.6s cubic-bezier(.2,.8,.3,1);
    will-change: transform;
}

.display .char--space {
    display: inline-block;
    width: 0.25em;
}

/* RGB split on hover/active */
.display:hover,
.display.is-split {
    text-shadow:
        -3px 0 0 rgba(201, 53, 69, 0.85),
         3px 0 0 rgba(120, 200, 230, 0.75),
         0 2px 0 rgba(255, 234, 182, 0.25);
}

/* ----------------------------------------------------------
   Body
   ---------------------------------------------------------- */

.kicker {
    font-family: var(--font-mono);
    font-weight: 300;
    font-size: 11px;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 2.2em;
}

.chamber-number {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.4rem;
    letter-spacing: 0.2em;
    color: var(--accent-warm);
    opacity: 0.6;
    margin-bottom: 0.6em;
}

.subline {
    font-family: var(--font-body);
    font-weight: 300;
    font-style: italic;
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin: 0.2em 0 2.2em 0;
    max-width: 520px;
}

.body-copy {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: 1.05rem;
    line-height: 1.75;
    color: var(--text-primary);
    margin-bottom: 1.6em;
    text-wrap: pretty;
}

.body-copy--lede {
    font-weight: 400;
    font-size: 1.15rem;
    color: #D8DEEC;
}

.aside {
    border-left: 1px solid rgba(58, 79, 122, 0.6);
    padding: 0.3em 0 0.3em 1.4em;
    margin-top: 2.4em;
    font-family: var(--font-body);
    font-style: italic;
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.7;
}

.aside .mono {
    font-family: var(--font-mono);
    font-style: normal;
    font-size: 10px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--accent-hot);
    opacity: 0.7;
    margin-right: 0.4em;
}

/* ----------------------------------------------------------
   Sigils
   ---------------------------------------------------------- */

.sigil {
    width: 72px;
    height: 72px;
    margin-bottom: 2.2em;
    opacity: 0.55;
    animation: sigil-rotate 120s linear infinite, flicker 4.3s infinite ease-in-out;
    filter: drop-shadow(0 0 6px rgba(255, 234, 182, 0.08));
}

.sigil svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* ----------------------------------------------------------
   Annotations (off-axis marginalia)
   ---------------------------------------------------------- */

.annotation {
    position: absolute;
    font-family: var(--font-mono);
    font-weight: 300;
    font-size: 9px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--text-secondary);
    transform: rotate(var(--rot, 0deg));
    pointer-events: none;
    z-index: 3;
    white-space: nowrap;
    opacity: 0.75;
}

.annotation--tl { top: 6vh;  left: 4vw;  }
.annotation--tr { top: 8vh;  right: 4vw; }
.annotation--ml { top: 50%;  left: 3vw;  transform: rotate(var(--rot, 0deg)) translateY(-50%); }
.annotation--mr { top: 50%;  right: 3vw; transform: rotate(var(--rot, 0deg)) translateY(-50%); }
.annotation--bl { bottom: 7vh; left: 5vw;  }
.annotation--br { bottom: 9vh; right: 5vw; }

/* ----------------------------------------------------------
   Glitch bands (between sections)
   ---------------------------------------------------------- */

.glitch-band {
    position: relative;
    width: 100%;
    height: 5px;
    background: var(--bg-deep);
    overflow: hidden;
}

.glitch-band::before,
.glitch-band::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    height: 100%;
    opacity: 0;
}

.glitch-band::before { top: 0; }
.glitch-band::after  { top: 0; }

@keyframes corrupt-a {
    0%   { background: var(--bg-deep);   opacity: 0; transform: translateX(0); }
    10%  { background: var(--accent-warm); opacity: 0.9; transform: translateX(-12px); }
    22%  { background: var(--accent-hot);  opacity: 1;   transform: translateX(8px); }
    34%  { background: var(--bg-mid);      opacity: 0.8; transform: translateX(-4px); }
    48%  { background: var(--accent-warm); opacity: 1;   transform: translateX(14px); }
    60%  { background: var(--accent-hot);  opacity: 0.7; transform: translateX(-10px); }
    72%  { background: var(--violet);      opacity: 0.6; transform: translateX(2px); }
    86%  { background: var(--bg-mid);      opacity: 0.4; transform: translateX(-3px); }
    100% { background: var(--bg-deep);     opacity: 0;   transform: translateX(0); }
}

@keyframes corrupt-b {
    0%   { background: var(--bg-deep);     opacity: 0; }
    15%  { background: var(--accent-hot);  opacity: 0.6; }
    33%  { background: var(--accent-warm); opacity: 0.9; }
    55%  { background: var(--violet);      opacity: 0.5; }
    80%  { background: var(--bg-mid);      opacity: 0.35; }
    100% { background: var(--bg-deep);     opacity: 0; }
}

.glitch-band.is-firing {
    height: 6px;
}

.glitch-band.is-firing::before {
    animation: corrupt-a 0.42s steps(12, end) 1;
}

.glitch-band.is-firing::after {
    animation: corrupt-b 0.42s steps(9, end) 1;
}

/* At rest, a faint baseline line so the band is never invisible */
.glitch-band {
    border-top: 1px solid rgba(58, 79, 122, 0.18);
    border-bottom: 1px solid rgba(58, 79, 122, 0.12);
}

/* ----------------------------------------------------------
   Threshold specific
   ---------------------------------------------------------- */

.threshold .column {
    text-align: left;
    position: relative;
}

.threshold .sigil {
    margin-bottom: 3em;
}

.threshold .display {
    font-size: clamp(4rem, 14vw, 12rem);
    letter-spacing: -0.04em;
    line-height: 0.85;
}

/* ----------------------------------------------------------
   Dissolution
   ---------------------------------------------------------- */

.dissolution {
    min-height: 120vh;
    padding-top: 18vh;
    padding-bottom: 30vh;
}

.column--dissolve .dissolve-line {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 1.6em;
    transition: letter-spacing 0.8s ease, transform 0.8s ease, opacity 0.8s ease, line-height 0.8s ease;
    transform: translateX(calc(var(--drift, 0) * 1px));
    letter-spacing: calc(var(--spacing, 0) * 0.01em);
    line-height: calc(1.6 + var(--extra-lh, 0));
    opacity: calc(1 - var(--fade, 0) * 0.6);
}

.dissolve-line--last {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-top: 3em;
}

/* ----------------------------------------------------------
   Reveal-on-intersect (subtle fade-in from dark)
   ---------------------------------------------------------- */

.chamber .column,
.threshold .column,
.dissolution .column {
    opacity: 0.0;
    transform: translateY(14px);
    transition: opacity 1.2s ease, transform 1.2s cubic-bezier(.2,.8,.3,1);
}

.section.is-visible .column {
    opacity: 1;
    transform: translateY(0);
}

/* ----------------------------------------------------------
   Atmospheric shadow on column text (swaying candle)
   ---------------------------------------------------------- */

@keyframes sway {
    0%   { filter: drop-shadow(0 20px 40px rgba(7,11,26,0.75)); }
    50%  { filter: drop-shadow(3px 22px 45px rgba(7,11,26,0.85)); }
    100% { filter: drop-shadow(-2px 20px 40px rgba(7,11,26,0.75)); }
}

.display {
    animation: sway 11s infinite ease-in-out;
}

/* ----------------------------------------------------------
   Responsive
   ---------------------------------------------------------- */

@media (max-width: 768px) {
    html, body { font-size: 16px; line-height: 1.6; }

    .section { padding: 10vh 18px; }

    .display { font-size: clamp(2.4rem, 11vw, 4.6rem); }
    .threshold .display { font-size: clamp(3rem, 18vw, 6rem); }

    .body-copy { font-size: 1rem; line-height: 1.7; }
    .body-copy--lede { font-size: 1.05rem; }

    .annotation {
        position: static;
        display: inline-block;
        transform: none !important;
        margin: 0 6px 8px 0;
        padding: 3px 10px;
        border: 1px solid rgba(58, 79, 122, 0.45);
        border-radius: 100px;
        font-size: 8.5px;
        letter-spacing: 0.18em;
        background: rgba(13, 27, 62, 0.5);
    }

    .column::before {
        content: "";
        display: block;
        height: 8px;
    }

    .glitch-band.is-firing { height: 2px; }
    .glitch-band { height: 2px; }

    .display .char { transform: none !important; }

    .bloom { width: 90vw; height: 60vw; }
    .bloom--large { width: 120vw; height: 90vw; }

    .sigil { width: 52px; height: 52px; margin-bottom: 1.6em; }
}

@media (max-width: 480px) {
    .threshold .display { font-size: clamp(2.6rem, 16vw, 4.5rem); }
}

/* ----------------------------------------------------------
   Selection
   ---------------------------------------------------------- */

::selection {
    background: var(--accent-hot);
    color: var(--accent-warm);
}
