:root {
    --parchment: #f0e8d8;
    --ink: #2a2420;
    --copper: #c47a38;
    --solder: #8a8880;
    --pcb-green: #2d4a3a;
    --signal-red: #9a3a30;
    --reverse-ground: #1a1814;
    --annotation-yellow: #e8d068;
    --grid-line: #d4c8b0;
}

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

body {
    background-color: var(--parchment);
    color: var(--ink);
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.2vw, 1.1rem);
    line-height: 1.75;
    overflow-x: hidden;
}

/* Grid paper background */
.grid-paper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background-image:
        repeating-linear-gradient(rgba(212, 200, 176, 0.15) 0 1px, transparent 1px 40px),
        repeating-linear-gradient(90deg, rgba(212, 200, 176, 0.15) 0 1px, transparent 1px 40px),
        repeating-linear-gradient(rgba(212, 200, 176, 0.05) 0 1px, transparent 1px 10px),
        repeating-linear-gradient(90deg, rgba(212, 200, 176, 0.05) 0 1px, transparent 1px 10px);
}

/* Sections */
.section {
    position: relative;
    padding: clamp(40px, 6vh, 80px) clamp(20px, 5vw, 60px);
}

/* Section labels */
.section-label {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: clamp(1.5rem, 3vw, 2.8rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink);
    margin-bottom: 40px;
}

/* Split layout */
.split-layout {
    display: grid;
    grid-template-columns: 62% 30%;
    gap: 8%;
}

.split-reversed {
    grid-template-columns: 30% 62%;
}

/* ================================================
   Cover Plate
   ================================================ */
.section-cover {
    min-height: 100vh;
    display: flex;
    align-items: flex-end;
    justify-content: flex-start;
    overflow: hidden;
}

.part-number {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: clamp(1.5rem, 3vw, 2.8rem);
    letter-spacing: 0.08em;
    color: var(--ink);
    position: absolute;
    left: 40%;
    top: 70%;
    z-index: 5;
}

.cover-panel {
    position: absolute;
    background-color: var(--parchment);
    z-index: 10;
    transition: transform 1s ease-out;
    border: 0.5px solid var(--grid-line);
}

.panel-tl { top: 0; left: 0; width: 50%; height: 50%; }
.panel-tr { top: 0; right: 0; width: 50%; height: 50%; }
.panel-bl { bottom: 0; left: 0; width: 50%; height: 50%; }
.panel-br { bottom: 0; right: 0; width: 50%; height: 50%; }

.cover-opened .panel-tl { transform: translate(-105%, -105%); }
.cover-opened .panel-tr { transform: translate(105%, -105%); }
.cover-opened .panel-bl { transform: translate(-105%, 105%); }
.cover-opened .panel-br { transform: translate(105%, 105%); }

.fracture-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 11;
    pointer-events: none;
}

.fracture-line {
    stroke: var(--copper);
    stroke-width: 0.3;
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
    transition: stroke-dashoffset 0.8s ease;
}

.cover-opened .fracture-line {
    stroke-dashoffset: 0;
}

/* ================================================
   Annotation Column
   ================================================ */
.annotation-column {
    background-color: rgba(245, 240, 229, 0.5);
    border-left: 1px dashed var(--copper);
    padding: 20px;
}

.annotation-left {
    border-left: none;
    border-right: 1px dashed var(--copper);
}

.annotation-title {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: 0.9rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink);
    margin-bottom: 24px;
}

/* Callouts */
.callout {
    margin-bottom: 24px;
    padding-left: 8px;
}

.callout-number {
    font-family: 'Caveat', cursive;
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--copper);
    margin-right: 8px;
}

.callout-text {
    font-family: 'Caveat', cursive;
    font-weight: 400;
    font-size: clamp(0.85rem, 1vw, 1rem);
    color: var(--ink);
    line-height: 1.5;
}

.light-annotation {
    color: var(--parchment);
}

/* ================================================
   Chest Cavity
   ================================================ */
.section-chest {
    min-height: 180vh;
}

.circuit-heart {
    display: flex;
    justify-content: center;
    padding: 40px 0;
}

.heart-svg {
    width: 100%;
    max-width: 300px;
    height: auto;
}

/* ================================================
   Wiring Diagram
   ================================================ */
.section-wiring {
    min-height: 140vh;
    background-color: var(--parchment);
}

.schematic {
    padding: 20px 0;
}

.schematic-svg {
    width: 100%;
    max-width: 400px;
    height: auto;
}

/* State flow */
.state-flow {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.state-box {
    font-family: 'Space Mono', monospace;
    font-weight: 400;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
    color: var(--ink);
    border: 1px solid var(--copper);
    border-radius: 4px;
    padding: 8px 16px;
    text-align: center;
    width: 160px;
}

.state-grief {
    border-color: var(--signal-red);
    color: var(--signal-red);
}

.state-arrow {
    font-family: 'Space Mono', monospace;
    font-size: 0.8rem;
    color: var(--copper);
}

/* ================================================
   Test Points
   ================================================ */
.section-test {
    min-height: 100vh;
    padding-top: 80px;
}

.test-points {
    display: flex;
    gap: clamp(20px, 3vw, 60px);
    flex-wrap: wrap;
}

.test-point {
    flex: 0 0 auto;
    width: clamp(120px, 15vw, 180px);
}

.test-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--copper);
    margin-bottom: 16px;
    transition: background-color 0.3s ease;
}

.test-point:hover .test-circle {
    background-color: var(--copper);
}

.test-point.pulsing .test-circle {
    animation: test-pulse 2s ease-in-out infinite;
}

@keyframes test-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.test-label {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--ink);
    display: block;
    margin-bottom: 8px;
}

.test-desc {
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--ink);
    opacity: 0.8;
}

/* ================================================
   Solder Side
   ================================================ */
.section-solder {
    background-color: var(--reverse-ground);
    min-height: 120vh;
    color: var(--parchment);
}

.light-label {
    color: var(--parchment);
}

.solder-text {
    color: var(--parchment);
    margin-bottom: 24px;
    opacity: 0.85;
}

.solder-dots {
    position: relative;
    height: 200px;
}

.solder-dot {
    position: absolute;
    border-radius: 50%;
    background-color: var(--solder);
    clip-path: polygon(10% 0%, 90% 5%, 100% 45%, 95% 95%, 5% 100%, 0% 50%);
}

/* ================================================
   Maintenance Log
   ================================================ */
.section-log {
    min-height: 80vh;
    display: flex;
    justify-content: center;
    padding-top: 80px;
    padding-bottom: 120px;
}

.log-column {
    max-width: 45%;
    margin-left: 35%;
}

.log-entry {
    margin-bottom: 20px;
    font-family: 'Space Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.8rem, 0.9vw, 0.95rem);
    line-height: 1.6;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.log-entry.visible {
    opacity: 1;
}

.log-time {
    color: var(--solder);
    display: block;
}

.log-msg {
    color: var(--ink);
    display: block;
}

/* ================================================
   Mobile
   ================================================ */
@media (max-width: 768px) {
    .split-layout,
    .split-reversed {
        grid-template-columns: 1fr;
        gap: 40px;
    }

    .annotation-column {
        border-left: none;
        border-top: 1px dashed var(--copper);
        padding: 16px 0;
    }

    .annotation-left {
        border-right: none;
        border-bottom: 1px dashed var(--copper);
    }

    .test-points {
        flex-direction: column;
    }

    .test-point {
        width: 100%;
    }

    .log-column {
        max-width: 90%;
        margin-left: 5%;
    }

    .part-number {
        left: 10%;
    }
}
