/* ============================
   Domain - Signal Decay Artifact
   Design: aurora-gradient + glitch archaeology
   ============================ */

:root {
    /* Background */
    --bg-deep: #0a0a14;
    --bg-drift: #0e0e1c;

    /* Text */
    --text-headline: #e8e0ff;
    --text-body: #a0a0c0;
    --text-annotation: #5a5a80;

    /* Aurora accents */
    --aurora-1: #00e5a0;
    --aurora-2: #8b5cf6;
    --aurora-3: #22d3ee;
    --aurora-4: #f472b6;

    /* Structural */
    --wire-color: #2a2a4a;
    --glitch-red: #ff3366;

    /* Timeline position */
    --timeline-x: 8vw;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-deep);
    color: var(--text-body);
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 300;
    font-size: clamp(0.875rem, 1.2vw, 1.1rem);
    line-height: 1.75;
    letter-spacing: 0.02em;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ---- Scan Lines Overlay ---- */
.scan-lines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    background: repeating-linear-gradient(
        to bottom,
        transparent,
        transparent 3px,
        rgba(42, 42, 74, 0.03) 3px,
        rgba(42, 42, 74, 0.03) 4px
    );
    animation: scanScroll 8s linear infinite;
}

@keyframes scanScroll {
    0% { background-position: 0 0; }
    100% { background-position: 0 -200px; }
}

/* ---- Aurora Background Layers ---- */
.aurora-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    opacity: 0;
    transition: opacity 2s ease;
}

.aurora-layer--1 {
    background: linear-gradient(135deg, var(--aurora-1), var(--aurora-2), var(--aurora-3));
    opacity: 0.06;
    animation: auroraDrift1 30s ease-in-out infinite;
}

.aurora-layer--2 {
    background: linear-gradient(225deg, var(--aurora-4), var(--aurora-1), var(--aurora-2));
    opacity: 0.04;
    animation: auroraDrift2 45s ease-in-out infinite;
}

.aurora-layer--3 {
    background: linear-gradient(315deg, var(--aurora-3), var(--aurora-4), var(--aurora-1));
    opacity: 0.03;
    animation: auroraDrift3 60s ease-in-out infinite;
}

@keyframes auroraDrift1 {
    0%, 100% { filter: hue-rotate(0deg); transform: scale(1); }
    50% { filter: hue-rotate(30deg); transform: scale(1.05); }
}

@keyframes auroraDrift2 {
    0%, 100% { filter: hue-rotate(0deg); transform: translateX(0); }
    50% { filter: hue-rotate(-20deg); transform: translateX(5%); }
}

@keyframes auroraDrift3 {
    0%, 100% { filter: hue-rotate(0deg); opacity: 0.03; }
    50% { filter: hue-rotate(15deg); opacity: 0.05; }
}

/* ---- Signal Trace (Timeline Wire) ---- */
.signal-trace {
    position: fixed;
    top: 0;
    left: var(--timeline-x);
    width: 1px;
    height: 100vh;
    background: var(--wire-color);
    z-index: 5;
    opacity: 0;
    transition: opacity 0.8s ease;
    box-shadow: 0 0 8px rgba(0, 229, 160, 0.1);
}

.signal-trace.visible {
    opacity: 1;
}

.signal-trace.fading {
    opacity: 0.2;
    width: 0.5px;
    transition: opacity 2s ease, width 2s ease;
}

/* ---- Ghost Data Fragments ---- */
.ghost-data {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

.ghost-fragment {
    position: absolute;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.65rem;
    font-weight: 400;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-annotation);
    white-space: pre;
    line-height: 1.6;
    mix-blend-mode: screen;
}

.ghost-fragment--1 {
    top: 15%;
    left: 55%;
    opacity: 0.06;
    transform: rotate(-2deg);
}

.ghost-fragment--2 {
    top: 35%;
    right: 10%;
    opacity: 0.04;
    transform: rotate(1.5deg);
}

.ghost-fragment--3 {
    top: 55%;
    left: 20%;
    opacity: 0.07;
    transform: rotate(-3deg);
}

.ghost-fragment--4 {
    top: 70%;
    right: 25%;
    opacity: 0.05;
    transform: rotate(2deg);
}

.ghost-fragment--5 {
    top: 85%;
    left: 45%;
    opacity: 0.04;
    transform: rotate(-1deg);
}

.ghost-fragment--6 {
    top: 10%;
    left: 75%;
    opacity: 0.05;
    transform: rotate(3deg);
}

/* ---- Glitch Line ---- */
.glitch-line {
    position: fixed;
    left: 0;
    width: 100vw;
    height: 2px;
    background: var(--glitch-red);
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    top: 50%;
}

.glitch-line.flash {
    opacity: 1;
    animation: glitchFlash 30ms linear forwards;
}

@keyframes glitchFlash {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

/* ---- The Totem (Hero) ---- */
.section--totem {
    position: relative;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.totem {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}

.totem-letter {
    font-family: 'Righteous', cursive;
    font-size: clamp(6rem, 20vw, 18rem);
    line-height: 0.9;
    letter-spacing: 0.04em;
    color: var(--text-headline);
    display: block;
    opacity: 0;
    transform: scale(0.3) translateY(-20px);
}

.totem-letter.entered {
    opacity: 1;
    transform: scale(1) translateY(0);
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1),
                opacity 0.3s ease;
}

.totem-meta {
    margin-top: 3rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    opacity: 0;
    transition: opacity 1s ease 1s;
}

.totem-meta.visible {
    opacity: 1;
}

.totem-meta__label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
    font-weight: 400;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-annotation);
}

.totem-meta__value {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
    font-weight: 400;
    letter-spacing: 0.06em;
    color: var(--text-body);
}

/* ---- Sticky Collapsed Totem ---- */
.totem-sticky {
    position: fixed;
    top: 1.5rem;
    left: var(--timeline-x);
    z-index: 100;
    display: flex;
    gap: 0.05em;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
    transform: translateX(1rem);
}

.totem-sticky.visible {
    opacity: 1;
}

.totem-sticky span {
    font-family: 'Righteous', cursive;
    font-size: 0.8rem;
    color: var(--text-headline);
    letter-spacing: 0.04em;
    opacity: 0.6;
}

/* ---- Drift Zones ---- */
.drift-zone {
    position: relative;
    height: 60vh;
    z-index: 2;
    overflow: hidden;
}

.drift-zone--1 {
    background: linear-gradient(135deg,
        rgba(0, 229, 160, 0.08),
        rgba(139, 92, 246, 0.06),
        rgba(34, 211, 238, 0.04)
    );
    animation: driftShift1 30s ease-in-out infinite;
}

.drift-zone--2 {
    background: linear-gradient(225deg,
        rgba(139, 92, 246, 0.06),
        rgba(34, 211, 238, 0.08),
        rgba(244, 114, 182, 0.04)
    );
    animation: driftShift2 35s ease-in-out infinite;
}

.drift-zone--3 {
    background: linear-gradient(315deg,
        rgba(34, 211, 238, 0.06),
        rgba(244, 114, 182, 0.08),
        rgba(0, 229, 160, 0.04)
    );
    animation: driftShift3 40s ease-in-out infinite;
}

.drift-zone--4 {
    background: linear-gradient(45deg,
        rgba(244, 114, 182, 0.04),
        rgba(0, 229, 160, 0.03),
        rgba(139, 92, 246, 0.05)
    );
    animation: driftShift4 50s ease-in-out infinite;
}

@keyframes driftShift1 {
    0%, 100% { filter: hue-rotate(0deg); background-position: 0% 0%; }
    50% { filter: hue-rotate(20deg); background-position: 100% 100%; }
}

@keyframes driftShift2 {
    0%, 100% { filter: hue-rotate(0deg); }
    50% { filter: hue-rotate(-15deg); }
}

@keyframes driftShift3 {
    0%, 100% { filter: hue-rotate(0deg); }
    50% { filter: hue-rotate(25deg); }
}

@keyframes driftShift4 {
    0%, 100% { filter: hue-rotate(0deg); }
    50% { filter: hue-rotate(-10deg); }
}

.packet-fragment {
    position: absolute;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.65rem;
    font-weight: 400;
    letter-spacing: 0.08em;
    color: var(--text-annotation);
    opacity: 0.05;
}

.drift-zone .packet-fragment {
    top: 30%;
    left: 15%;
}

.drift-zone .packet-fragment--2 {
    top: 60%;
    right: 12%;
    left: auto;
}

/* ---- Timeline Sections (General) ---- */
.section {
    position: relative;
    z-index: 10;
    min-height: 80vh;
    display: grid;
    grid-template-columns: var(--timeline-x) 1fr;
    align-items: start;
    padding: 8vh 5vw 8vh 0;
}

.section--totem {
    display: flex;
    grid-template-columns: none;
    padding: 0;
}

/* ---- Timeline Nodes ---- */
.timeline-node {
    position: relative;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    padding-top: 1.5rem;
    height: 100%;
}

.timeline-node__marker {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--wire-color);
    position: relative;
    right: -3px;
    box-shadow: 0 0 0 rgba(0, 229, 160, 0);
    animation: nodeGlow 12s ease-in-out infinite;
}

.timeline-node__marker--decay {
    animation: nodeGlowDecay 8s ease-in-out infinite;
}

.timeline-node__marker--dead {
    background: var(--glitch-red);
    box-shadow: 0 0 10px rgba(255, 51, 102, 0.4);
    animation: none;
}

.timeline-node__marker--rebirth {
    background: var(--aurora-1);
    animation: nodeGlowRebirth 6s ease-in-out infinite;
}

@keyframes nodeGlow {
    0%, 100% { box-shadow: 0 0 8px rgba(0, 229, 160, 0.3); }
    25% { box-shadow: 0 0 12px rgba(139, 92, 246, 0.4); }
    50% { box-shadow: 0 0 8px rgba(34, 211, 238, 0.3); }
    75% { box-shadow: 0 0 12px rgba(244, 114, 182, 0.4); }
}

@keyframes nodeGlowDecay {
    0%, 100% { box-shadow: 0 0 6px rgba(255, 51, 102, 0.2); }
    50% { box-shadow: 0 0 15px rgba(255, 51, 102, 0.5); }
}

@keyframes nodeGlowRebirth {
    0%, 100% { box-shadow: 0 0 10px rgba(0, 229, 160, 0.4); }
    50% { box-shadow: 0 0 20px rgba(0, 229, 160, 0.7); }
}

.timeline-node__hairline {
    position: absolute;
    top: calc(1.5rem + 3px);
    right: 0;
    height: 1px;
    width: 0;
    background: var(--wire-color);
    transition: width 0.3s ease 0.2s;
    transform-origin: left;
}

.section.in-view .timeline-node__hairline {
    width: calc(100% + 2rem);
}

/* ---- Section Content ---- */
.section-content {
    padding-left: 2rem;
    max-width: 60vw;
    opacity: 0;
    transform: translateY(20px);
}

.section-content--wide {
    max-width: 80vw;
}

.section-content.animate-in {
    opacity: 1;
    transform: translateY(0);
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1),
                opacity 0.4s ease;
}

/* ---- Section Dates ---- */
.section-date {
    display: flex;
    gap: 1.5rem;
    align-items: baseline;
    margin-bottom: 0.5rem;
}

.date-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
    font-weight: 400;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-annotation);
}

.date-status {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--aurora-1);
}

.date-status--warning {
    color: var(--aurora-4);
}

.date-status--dead {
    color: var(--glitch-red);
}

.date-status--new {
    color: var(--aurora-1);
}

/* ---- Section Titles ---- */
.section-title {
    font-family: 'Righteous', cursive;
    font-size: clamp(3rem, 8vw, 7rem);
    line-height: 0.9;
    letter-spacing: 0.04em;
    color: var(--text-headline);
    margin-bottom: 2rem;
}

.section-title--decay {
    color: var(--aurora-4);
    opacity: 0.8;
}

.section-title--expired {
    color: var(--glitch-red);
    opacity: 0.6;
}

.section-title--rebirth {
    color: var(--aurora-1);
}

/* ---- Data Blocks ---- */
.data-block {
    margin-bottom: 1.5rem;
    padding: 1rem 0;
    border-left: 1px solid var(--wire-color);
    padding-left: 1rem;
}

.data-block--corrupted {
    border-left-color: var(--glitch-red);
    position: relative;
}

.data-block--corrupted::before {
    content: '';
    position: absolute;
    top: 0;
    left: -1px;
    width: 1px;
    height: 100%;
    background: var(--glitch-red);
    opacity: 0.4;
    animation: corruptPulse 2s ease-in-out infinite;
}

@keyframes corruptPulse {
    0%, 100% { opacity: 0.2; }
    50% { opacity: 0.8; }
}

.data-line {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    font-weight: 400;
    letter-spacing: 0.04em;
    color: var(--text-body);
    line-height: 2;
}

.data-key {
    color: var(--text-annotation);
}

.data-val {
    color: var(--text-body);
}

.data-val--active {
    color: var(--aurora-1);
}

.data-val--warning {
    color: var(--aurora-4);
}

.data-val--expired {
    color: var(--glitch-red);
}

.data-val--glitch {
    color: var(--glitch-red);
    animation: textGlitch 3s step-end infinite;
}

@keyframes textGlitch {
    0%, 95% { opacity: 1; }
    96% { opacity: 0; }
    97% { opacity: 1; transform: translateX(2px); }
    98% { transform: translateX(-1px); }
    99% { transform: translateX(0); }
}

/* ---- Section Body Text ---- */
.section-body {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 300;
    font-size: clamp(0.875rem, 1.2vw, 1.1rem);
    line-height: 1.75;
    letter-spacing: 0.02em;
    color: var(--text-body);
    max-width: 55ch;
}

/* ---- Propagation Grid ---- */
.propagation-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.prop-node {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
    font-weight: 400;
    letter-spacing: 0.04em;
    color: var(--text-annotation);
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--wire-color);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.4s ease;
}

.prop-node.visible {
    opacity: 1;
    transform: translateY(0);
    box-shadow: 0 0 8px rgba(0, 229, 160, 0.15);
}

/* ---- Traffic Visualization ---- */
.traffic-vis {
    margin-bottom: 1.5rem;
    height: 120px;
    position: relative;
}

.traffic-vis canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* ---- Decay Bar ---- */
.decay-bar {
    position: relative;
    width: 100%;
    max-width: 400px;
    height: 4px;
    background: var(--wire-color);
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.decay-bar__fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--aurora-4), var(--glitch-red));
    transition: width 2s ease;
}

.decay-bar__glitch {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--glitch-red);
    opacity: 0;
    animation: decayGlitch 4s step-end infinite;
}

@keyframes decayGlitch {
    0%, 92% { opacity: 0; }
    93% { opacity: 0.6; transform: translateX(-3px); }
    94% { opacity: 0; }
    95% { opacity: 0.4; transform: translateX(2px); }
    96%, 100% { opacity: 0; transform: translateX(0); }
}

/* ---- WHOIS Block ---- */
.whois-block {
    margin-bottom: 1.5rem;
    position: relative;
}

.whois-text {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
    font-weight: 400;
    letter-spacing: 0.04em;
    line-height: 1.8;
    color: var(--text-annotation);
    padding: 1.5rem;
    border: 1px solid var(--wire-color);
    background: rgba(10, 10, 20, 0.6);
    overflow-x: auto;
}

/* ---- Coda Section ---- */
.section--coda {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 10vh 5vw;
    text-align: center;
}

.coda-text {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 6rem;
}

.coda-line {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 300;
    font-size: clamp(1rem, 2vw, 1.5rem);
    line-height: 1.6;
    color: var(--text-body);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 1s ease, transform 1s ease;
}

.coda-line.visible {
    opacity: 1;
    transform: translateY(0);
}

.coda-line--dim {
    color: var(--text-annotation);
}

.coda-timestamp {
    margin-top: 4rem;
}

.coda-expiry {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    font-weight: 400;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #1a1a3a;
    opacity: 0;
    transition: opacity 3s ease;
}

.coda-expiry.visible {
    opacity: 0.5;
}

/* ---- Void End ---- */
.void-end {
    height: 50vh;
    background: var(--bg-deep);
}

/* ---- Body Glitch Effect ---- */
body.glitching {
    transform: translateX(3px);
    transition: transform 50ms step-end;
}

body.glitch-letter-space .section-content {
    letter-spacing: 0.3em;
    transition: letter-spacing 70ms step-end;
}

/* ---- Circuit Trace Decorations ---- */
.circuit-trace {
    position: absolute;
    left: var(--timeline-x);
    height: 1px;
    background: var(--wire-color);
    opacity: 0.2;
    z-index: 4;
}

.circuit-trace__terminal {
    position: absolute;
    right: 0;
    top: -2px;
    width: 4px;
    height: 4px;
    background: var(--wire-color);
    opacity: 0.3;
}

.circuit-trace__terminal--circle {
    border-radius: 50%;
    width: 3px;
    height: 3px;
    top: -1px;
}

/* ---- Scroll Progress ---- */
@media (max-width: 768px) {
    :root {
        --timeline-x: 12vw;
    }

    .section-content {
        max-width: 85vw;
        padding-left: 1rem;
    }

    .section-content--wide {
        max-width: 85vw;
    }

    .totem-letter {
        font-size: clamp(4rem, 18vw, 10rem);
    }

    .section-title {
        font-size: clamp(2rem, 10vw, 5rem);
    }

    .ghost-fragment {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .scan-lines {
        animation: none;
    }

    .totem-letter {
        opacity: 1;
        transform: none;
    }

    .section-content {
        opacity: 1;
        transform: none;
    }

    .coda-line {
        opacity: 1;
        transform: none;
    }
}
