/* ========================================
   layer-2.wiki — Design System
   A Reference Archive for Layer-2 Protocols
   1970s NASA / CRT / Declassified Archive
   ======================================== */

/* ---- CSS Custom Properties ---- */
:root {
    --bg-primary: #1A0A0F;
    --bg-secondary: #2D1520;
    --text-primary: #E8C4C4;
    --text-secondary: #BFA8A8;
    --accent-amber: #D4A054;
    --accent-structural: #6B3A3A;
    --highlight-green: #4A7A5A;
    --font-display: 'Space Mono', monospace;
    --font-body: 'IBM Plex Mono', monospace;
    --font-accent: 'Share Tech Mono', monospace;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: clamp(14px, 1.2vw, 17px);
    line-height: 1.85;
    font-weight: 400;
    overflow-x: hidden;
    position: relative;
}

/* ---- CRT Scan-line Overlay ---- */
.scanline-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 2px,
        rgba(26, 10, 15, 0.03) 2px,
        rgba(26, 10, 15, 0.03) 4px
    );
}

/* ---- Fixed Background Grid (Isometric) ---- */
.bg-grid {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    opacity: 0.3;
    pointer-events: none;
}

.bg-grid line {
    stroke: var(--accent-structural);
    stroke-width: 0.5;
    opacity: 0.4;
}

/* ---- Foreground Decorative Layer ---- */
.foreground-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 2;
    pointer-events: none;
    opacity: 0.15;
}

.fg-circuit {
    position: absolute;
    width: 30%;
    height: 100%;
}

.fg-circuit-1 {
    left: 2%;
    top: 0;
}

.fg-circuit-2 {
    right: 2%;
    top: 0;
}

.fg-circuit .circuit-path {
    opacity: 0.6;
}

/* ---- Stratum Sections ---- */
.stratum {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 10vh 0;
}

.stratum-00 {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* ---- 12-Column Grid ---- */
.stratum-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 0;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    width: 100%;
    position: relative;
}

/* ---- Column Placement Classes ---- */
.col-2-6 {
    grid-column: 2 / 7;
}

.col-3-8 {
    grid-column: 3 / 9;
}

.col-2-5 {
    grid-column: 2 / 6;
}

.col-6-10 {
    grid-column: 6 / 11;
}

.col-3-7 {
    grid-column: 3 / 8;
}

.col-7-11 {
    grid-column: 7 / 12;
}

.col-4-9 {
    grid-column: 4 / 10;
}

.col-3-10 {
    grid-column: 3 / 11;
}

/* ---- Typography ---- */
.stratum-label {
    font-family: var(--font-display);
    font-size: clamp(12px, 1vw, 14px);
    font-weight: 400;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--accent-structural);
    display: block;
    margin-bottom: 8px;
}

.stratum-title {
    font-family: var(--font-display);
    font-size: clamp(32px, 5vw, 72px);
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-primary);
    margin-bottom: 32px;
    line-height: 1.1;
}

.domain-name {
    font-family: var(--font-display);
    font-size: clamp(42px, 6vw, 84px);
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--text-primary);
    margin-bottom: 16px;
    line-height: 1.1;
}

.tagline {
    font-family: var(--font-body);
    font-size: clamp(14px, 1.2vw, 17px);
    color: var(--text-secondary);
    letter-spacing: 0.05em;
}

.body-text {
    font-family: var(--font-body);
    font-size: clamp(14px, 1.2vw, 17px);
    line-height: 1.85;
    font-weight: 400;
    color: var(--text-secondary);
    max-width: 65ch;
    margin-bottom: 24px;
}

.code-ref {
    font-family: var(--font-accent);
    color: var(--highlight-green);
    font-size: 0.95em;
}

.protocol-label {
    font-family: var(--font-accent);
    font-size: 11px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--accent-amber);
    display: block;
    margin-bottom: 12px;
}

/* ---- Ma (negative space) ---- */
.ma-space {
    height: 40vh;
    position: relative;
    z-index: 1;
}

.ma-space-final {
    height: 20vh;
}

/* ---- Topology Blocks (Stratum 02) ---- */
.topology-block {
    padding: 32px;
    margin-bottom: 24px;
    background-color: var(--bg-secondary);
    border: 1px solid transparent;
    transition: border-color 0.6s ease;
    position: relative;
}

.topology-block:hover {
    border-color: var(--accent-structural);
}

.topo-1 { grid-row: 2; }
.topo-2 { grid-row: 3; }
.topo-3 { grid-row: 4; }
.topo-4 { grid-row: 5; }

/* ---- Fade Stagger Animation ---- */
.fade-stagger {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.fade-stagger.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ---- Section Circuit SVGs ---- */
.section-circuit {
    grid-column: 1 / -1;
    width: 100%;
    max-height: 300px;
    margin: 40px 0;
    opacity: 0.6;
}

.circuit-01 {
    grid-column: 7 / 12;
    max-height: 250px;
}

.circuit-02 {
    grid-row: 6;
    max-height: 200px;
    opacity: 0.4;
}

.circuit-04 {
    grid-column: 3 / 11;
    max-height: 200px;
    margin-top: 60px;
}

/* ---- Path Draw Animation ---- */
.path-draw {
    stroke-dasharray: var(--path-length, 1000);
    stroke-dashoffset: var(--path-length, 1000);
    transition: stroke-dashoffset 3s cubic-bezier(0.4, 0, 0.2, 1);
}

.path-draw.visible {
    stroke-dashoffset: 0;
}

/* ---- Stratum Dividers ---- */
.stratum-divider {
    width: 100%;
    height: 40px;
    margin-top: 60px;
    opacity: 0.5;
}

/* ---- Timeline (Stratum 03) ---- */
.timeline-container {
    position: relative;
    padding: 40px 0;
    grid-row: 2;
}

.timeline-line {
    position: absolute;
    left: 50%;
    top: 0;
    width: 20px;
    height: 100%;
    transform: translateX(-50%);
    opacity: 0.6;
}

.timeline-entry {
    position: relative;
    width: 45%;
    padding: 20px 24px;
    margin-bottom: 32px;
    background-color: var(--bg-secondary);
    border: 1px solid transparent;
    transition: border-color 0.6s ease;
    opacity: 0;
    transform: translateY(15px);
    transition: opacity 0.6s ease, transform 0.6s ease, border-color 0.6s ease;
}

.timeline-entry:hover {
    border-color: var(--accent-structural);
}

.timeline-entry.visible {
    opacity: 1;
    transform: translateY(0);
}

.timeline-left {
    margin-right: auto;
    margin-left: 0;
}

.timeline-right {
    margin-left: auto;
    margin-right: 0;
}

.timeline-date {
    font-family: var(--font-accent);
    font-size: 11px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--accent-amber);
    display: block;
    margin-bottom: 8px;
}

.timeline-desc {
    font-family: var(--font-body);
    font-size: clamp(13px, 1.1vw, 15px);
    line-height: 1.75;
    color: var(--text-secondary);
    margin: 0;
}

/* ---- Redaction Blocks ---- */
.redaction-block {
    grid-column: 9 / 12;
    position: relative;
    overflow: hidden;
    padding: 12px 16px;
    margin-top: 40px;
    align-self: end;
}

.redaction-03 {
    grid-column: 2 / 5;
    grid-row: 3;
}

.redacted-text {
    font-family: var(--font-accent);
    font-size: 9px;
    letter-spacing: 0.15em;
    color: var(--bg-secondary);
    word-break: break-all;
    display: block;
    line-height: 1.8;
}

.redaction-bar {
    position: absolute;
    top: 25%;
    left: 0;
    width: 100%;
    height: 50%;
    background-color: var(--bg-primary);
}

/* ---- Footer Domain ---- */
.footer-domain {
    grid-column: 5 / 9;
    text-align: center;
    margin-top: 80px;
    padding: 40px 0;
}

.footer-text {
    font-family: var(--font-display);
    font-size: clamp(14px, 1.5vw, 18px);
    font-weight: 400;
    letter-spacing: 0.2em;
    color: var(--accent-structural);
    text-transform: lowercase;
}

/* ---- Section Headers ---- */
.stratum-header {
    margin-bottom: 40px;
}

/* ---- Content blocks hover ---- */
.stratum-content {
    padding: 32px 0;
    border: 1px solid transparent;
    transition: border-color 0.6s ease;
    padding: 32px;
}

.stratum-content:hover {
    border-color: var(--accent-structural);
}

/* ---- Archive Note ---- */
.archive-note {
    font-size: clamp(11px, 0.9vw, 13px);
    color: var(--accent-structural);
    margin-top: 32px;
}

/* ---- Stratum Fade-In ---- */
.stratum {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 1s ease, transform 1s ease;
}

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

/* ---- Circuit Nodes Pulse ---- */
.circuit-node {
    opacity: 0;
    transition: opacity 1.5s ease 2s;
}

.path-draw.visible ~ .circuit-node,
.visible .circuit-node {
    opacity: 1;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .col-2-6,
    .col-3-8,
    .col-2-5,
    .col-6-10,
    .col-3-7,
    .col-7-11,
    .col-4-9,
    .col-3-10 {
        grid-column: 1 / -1;
    }

    .stratum-grid {
        padding: 0 16px;
    }

    .topology-block {
        grid-column: 1 / -1 !important;
    }

    .topo-1, .topo-2, .topo-3, .topo-4 {
        grid-row: auto;
    }

    .timeline-left,
    .timeline-right {
        width: 85%;
        margin-left: auto;
        margin-right: auto;
    }

    .timeline-line {
        left: 10px;
    }

    .redaction-block {
        grid-column: 1 / -1;
    }

    .section-circuit {
        grid-column: 1 / -1;
    }

    .circuit-01 {
        grid-column: 1 / -1;
    }

    .footer-domain {
        grid-column: 1 / -1;
    }

    .ma-space {
        height: 25vh;
    }

    .domain-name {
        font-size: clamp(28px, 8vw, 48px);
    }

    .fg-circuit {
        display: none;
    }
}

@media (max-width: 480px) {
    .stratum-title {
        font-size: clamp(24px, 7vw, 40px);
    }

    .stratum {
        padding: 5vh 0;
    }
}