/* layer2.wiki — Avant-Garde Technical Encyclopedia */

:root {
    --obsidian-folio: #1A1A2E;
    --charcoal-margin: #2D2D44;
    --sapphire: #2563EB;
    --ruby: #BE185D;
    --emerald: #059669;
    --amethyst: #7C3AED;
    --topaz: #D97706;
    --parchment: #E8E0D4;
    --slate: #94A3B8;
}

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

body {
    font-family: 'Source Sans 3', sans-serif;
    font-weight: 400;
    color: var(--parchment);
    background: var(--obsidian-folio);
    line-height: 1.72;
    letter-spacing: 0.005em;
    overflow-x: hidden;
}

/* ---- Halftone background ---- */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: 0.03;
    background-image: radial-gradient(circle, var(--parchment) 1px, transparent 1px);
    background-size: 8px 8px;
}

/* ---- Scenes ---- */
.scene {
    position: relative;
    z-index: 1;
}

/* ---- Reveal ---- */
[data-reveal] {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94), transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

[data-reveal].revealed {
    opacity: 1;
    transform: translateY(0);
}

/* ---- Registration marks ---- */
.registration-mark {
    position: absolute;
    width: 8px;
    height: 8px;
    z-index: 5;
}

.registration-mark::before,
.registration-mark::after {
    content: '';
    position: absolute;
    background: var(--slate);
    opacity: 0.3;
    border-radius: 50%;
}

.registration-mark::before { width: 2px; height: 2px; top: 0; left: 0; }
.registration-mark::after { width: 2px; height: 2px; top: 0; left: 6px; }

.rm-tl { top: 2rem; left: 2rem; }
.rm-tr { top: 2rem; right: 2rem; }
.rm-bl { bottom: 2rem; left: 2rem; }
.rm-br { bottom: 2rem; right: 2rem; }

/* ---- Scene heading ---- */
.scene-heading {
    font-family: 'Roboto Slab', serif;
    font-weight: 400;
    font-size: clamp(1.6rem, 3.2vw, 2.8rem);
    letter-spacing: 0.01em;
    line-height: 1.15;
    color: var(--parchment);
    margin-bottom: 2rem;
    border-bottom: 2px solid var(--section-jewel, var(--sapphire));
    padding-bottom: 0.5rem;
    display: inline-block;
}

/* ---- Body text ---- */
.body-text {
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.72;
    color: var(--parchment);
    margin-bottom: 1.5rem;
    max-width: 42em;
}

/* ============ SCENE 1: TITLE PAGE ============ */
.scene-title {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 4rem 2rem;
}

.hero-icon {
    margin-bottom: 2rem;
    animation: pulseAttention 3s ease-in-out infinite;
}

@keyframes pulseAttention {
    0%, 100% { transform: scale(1); opacity: 0.85; }
    50% { transform: scale(1.08); opacity: 1; }
}

.hero-title {
    font-family: 'Roboto Slab', serif;
    font-weight: 700;
    font-size: clamp(3rem, 7vw, 5.5rem);
    letter-spacing: -0.01em;
    line-height: 1.08;
    color: var(--parchment);
    margin-bottom: 1rem;
}

.hero-sub {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 1rem;
    color: var(--parchment);
    opacity: 0.7;
    margin-bottom: 3rem;
}

.hero-line {
    opacity: 0.6;
}

.draw-line {
    stroke-dasharray: 120;
    stroke-dashoffset: 120;
    animation: drawDown 2s ease forwards 0.5s;
}

@keyframes drawDown {
    to { stroke-dashoffset: 0; }
}

/* ============ SCENE 2: TABLE OF CONTENTS ============ */
.scene-toc {
    padding: clamp(4rem, 8vw, 8rem) clamp(2rem, 4vw, 6rem);
    display: flex;
    gap: 2rem;
}

.gutter {
    position: sticky;
    top: 2rem;
    flex: 0 0 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    padding-top: 4rem;
}

.gutter-icon {
    color: var(--jewel, var(--slate));
    opacity: 0.4;
    transition: opacity 0.3s ease;
}

.gutter-icon.gi-active {
    opacity: 1;
    animation: pulseAttention 3s ease-in-out infinite;
}

.toc-content {
    flex: 1;
}

.toc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.toc-card {
    background: var(--charcoal-margin);
    padding: 2rem;
    border: 1px solid rgba(148, 163, 184, 0.15);
    outline: 1px solid var(--section-jewel);
    outline-offset: 4px;
    outline-width: 1px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    position: relative;
    transition: outline-color 0.3s ease;
}

.toc-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        repeating-linear-gradient(45deg, transparent, transparent 4px, var(--section-jewel) 4px, var(--section-jewel) 5px),
        repeating-linear-gradient(-45deg, transparent, transparent 4px, var(--section-jewel) 4px, var(--section-jewel) 5px);
    opacity: 0.04;
    pointer-events: none;
}

.toc-card:hover {
    outline-color: var(--section-jewel);
}

.toc-card:hover .toc-icon {
    transform: scale(1.05);
}

.toc-icon {
    display: block;
    margin-bottom: 1rem;
    transition: transform 0.3s ease;
}

.toc-title {
    font-family: 'Roboto Slab', serif;
    font-weight: 400;
    font-size: 1.2rem;
    color: var(--parchment);
    margin-bottom: 0.5rem;
}

.toc-desc {
    font-size: 0.9rem;
    color: var(--slate);
    line-height: 1.5;
}

/* ============ SCENE 3: CHAPTERS ============ */
.scene-chapter {
    padding-bottom: 4rem;
}

.breakout {
    width: 100%;
    min-height: 60vh;
    background: var(--charcoal-margin);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    margin-bottom: 3rem;
    position: relative;
}

.breakout::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        repeating-linear-gradient(45deg, transparent, transparent 4px, var(--section-jewel) 4px, var(--section-jewel) 5px),
        repeating-linear-gradient(-45deg, transparent, transparent 4px, var(--section-jewel) 4px, var(--section-jewel) 5px);
    opacity: 0.03;
    pointer-events: none;
}

.breakout-diagram {
    width: 100%;
    max-width: 600px;
    height: auto;
}

.diagram-draw {
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    transition: stroke-dashoffset 1.5s ease;
}

.breakout-inner.revealed .diagram-draw {
    stroke-dashoffset: 0;
}

.diagram-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    fill: var(--parchment);
    letter-spacing: 0.1em;
}

.diagram-label-sm {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 8px;
    fill: var(--parchment);
    letter-spacing: 0.08em;
}

.chapter-content {
    padding: 0 clamp(2rem, 4vw, 6rem);
    padding-left: clamp(6rem, 12vw, 12rem);
}

.chapter-band {
    max-width: 700px;
}

/* ============ SCENE 4: COLOPHON ============ */
.scene-colophon {
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 4rem 2rem;
}

.colophon-text {
    font-family: 'Roboto Slab', serif;
    font-weight: 300;
    font-size: clamp(1.2rem, 2vw, 1.6rem);
    color: var(--parchment);
    margin-bottom: 2rem;
}

.colophon-marks {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.dot-mark {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--slate);
    opacity: 0.4;
}

.dash-mark {
    width: 24px;
    height: 1px;
    background: var(--slate);
    opacity: 0.3;
}

.colophon-icons {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* ---- Mobile ---- */
@media (max-width: 767px) {
    .scene-toc {
        flex-direction: column;
    }

    .gutter {
        position: static;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        padding-top: 0;
    }

    .toc-grid {
        grid-template-columns: 1fr;
    }

    .chapter-content {
        padding-left: clamp(2rem, 4vw, 4rem);
    }

    .hero-icon svg {
        width: 120px;
        height: 120px;
    }
}

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

    [data-reveal] {
        opacity: 1;
        transform: none;
    }

    .draw-line {
        stroke-dashoffset: 0;
    }

    .diagram-draw {
        stroke-dashoffset: 0;
    }

    .hero-icon {
        animation: none;
    }

    .gutter-icon.gi-active {
        animation: none;
    }
}
