/* ========================================
   layer-2.wiki — Styles
   Magazine-spread reading experience
   ======================================== */

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

:root {
    --cream: #ece3d4;
    --burnt-sienna: #c75b2a;
    --ink-dark: #2a1f1a;
    --amber: #e8a24e;
    --terracotta: #d4784a;
    --espresso: #3d2e24;
    --sage: #8a9a7e;
    --parchment: #f7f0e6;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    background-color: var(--cream);
    color: var(--ink-dark);
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    line-height: 1.65;
    overflow-x: hidden;
}

/* --- Spine Navigation --- */
#spine {
    position: fixed;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 4px;
    transform: translateX(-50%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.spine-title {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Space Mono', monospace;
    font-size: 0.65rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--espresso);
    opacity: 0.5;
    pointer-events: none;
}

.spine-chapters {
    display: flex;
    flex-direction: column;
    gap: 16px;
    pointer-events: auto;
}

.spine-dot {
    display: block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 1.5px solid var(--espresso);
    background: var(--cream);
    transition: background 0.3s ease, transform 0.3s ease;
    cursor: pointer;
}

.spine-dot.active {
    background: var(--burnt-sienna);
    border-color: var(--burnt-sienna);
    transform: scale(1.3);
}

.spine-dot:hover {
    transform: scale(1.4);
}

/* --- Spread Layout --- */
.spread {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 100vh;
    position: relative;
}

.spread::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 5%;
    bottom: 5%;
    width: 1px;
    background: linear-gradient(
        to bottom,
        transparent,
        var(--terracotta) 20%,
        var(--terracotta) 80%,
        transparent
    );
    opacity: 0.2;
    transform: translateX(-50%);
    z-index: 1;
}

.page {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6vh 4vw;
    position: relative;
}

.page-left {
    justify-content: flex-end;
    padding-right: clamp(2rem, 4vw, 5rem);
}

.page-right {
    justify-content: flex-start;
    padding-left: clamp(2rem, 4vw, 5rem);
}

.page-content {
    max-width: 480px;
    width: 100%;
}

/* Paper texture on right pages */
.page-right::before {
    content: '';
    position: absolute;
    inset: 3vh 3vw;
    background: var(--parchment);
    border-radius: 2px;
    opacity: 0.5;
    z-index: -1;
}

/* --- Typography --- */
h1, h2, h3 {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: 0.01em;
    color: var(--ink-dark);
}

h1 {
    font-size: clamp(2.5rem, 5.5vw, 5rem);
    margin-bottom: 1.5rem;
}

h1 em, h2 em {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-weight: 500;
    color: var(--burnt-sienna);
}

h2 {
    font-size: clamp(1.8rem, 4.5vw, 4rem);
    margin-bottom: 1.5rem;
}

h3 {
    font-size: clamp(1.3rem, 2.5vw, 2rem);
    margin-bottom: 1rem;
    font-weight: 500;
}

.chapter-number {
    display: block;
    font-family: 'Space Mono', monospace;
    font-size: 0.7rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--burnt-sienna);
    margin-bottom: 0.75rem;
    opacity: 0.8;
}

.body-text {
    font-family: 'Inter', sans-serif;
    font-size: clamp(0.9rem, 1.1vw, 1.05rem);
    line-height: 1.7;
    color: var(--espresso);
    margin-bottom: 1.25rem;
}

.body-text strong {
    font-weight: 500;
    color: var(--ink-dark);
}

.pull-quote {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-weight: 500;
    font-size: clamp(1.1rem, 1.8vw, 1.5rem);
    color: var(--burnt-sienna);
    border-left: 2px solid var(--amber);
    padding-left: 1.25rem;
    margin: 1.75rem 0;
    line-height: 1.4;
}

/* --- Lists --- */
.text-list {
    margin: 1.25rem 0;
}

.list-item {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    font-size: clamp(0.9rem, 1.1vw, 1.05rem);
    color: var(--espresso);
    line-height: 1.6;
}

.list-marker {
    color: var(--burnt-sienna);
    flex-shrink: 0;
    margin-top: 0.1em;
}

/* --- Cover --- */
.cover-spread {
    min-height: 100vh;
}

.cover-subtitle {
    font-family: 'Inter', sans-serif;
    font-size: clamp(0.95rem, 1.2vw, 1.1rem);
    line-height: 1.7;
    color: var(--espresso);
    margin-bottom: 2rem;
    max-width: 380px;
}

.cover-meta {
    font-family: 'Space Mono', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--terracotta);
    opacity: 0.7;
}

.meta-divider {
    margin: 0 0.5rem;
}

/* --- Illustrations --- */
.illustration-container {
    display: flex;
    align-items: center;
    justify-content: center;
}

.hero-diagram,
.chapter-diagram {
    width: 100%;
    max-width: 420px;
    height: auto;
}

.diagram-label {
    font-family: 'Space Mono', monospace;
}

.diagram-label.annotation {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
}

/* --- Ink line draw animation --- */
.ink-line {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
}

.ink-line.draw-in {
    animation: drawLine 1.5s ease-out forwards;
}

.ink-line.draw-in-scroll {
    /* activated via JS IntersectionObserver */
    transition: stroke-dashoffset 1.2s ease-out;
}

.ink-line.draw-in-scroll.visible {
    stroke-dashoffset: 0 !important;
}

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

/* --- Interstitials --- */
.interstitial {
    padding: 2rem 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.interstitial-line {
    width: 100%;
    height: 60px;
}

/* --- Colophon --- */
.colophon {
    min-height: 50vh;
    border-top: 1px solid rgba(42, 31, 26, 0.08);
}

.colophon h3 {
    color: var(--burnt-sienna);
}

.colophon-meta {
    font-family: 'Space Mono', monospace;
    font-size: 0.7rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--terracotta);
    opacity: 0.6;
    margin-top: 1rem;
}

.colophon-mark {
    width: 120px;
    height: 120px;
    opacity: 0.6;
}

/* --- Responsive: Mobile --- */
@media (max-width: 1024px) {
    .spread {
        grid-template-columns: 1fr;
        min-height: auto;
    }

    .spread::before {
        display: none;
    }

    .page-left,
    .page-right {
        justify-content: center;
        padding: 4vh 6vw;
    }

    .page-right::before {
        inset: 1vh 2vw;
    }

    #spine {
        left: auto;
        right: 12px;
        width: auto;
        transform: none;
    }

    .spine-title {
        display: none;
    }

    .hero-diagram,
    .chapter-diagram {
        max-width: 340px;
    }
}

@media (max-width: 600px) {
    .page-left,
    .page-right {
        padding: 3vh 5vw;
    }

    h1 {
        font-size: 2.2rem;
    }

    h2 {
        font-size: 1.8rem;
    }

    .spine-chapters {
        gap: 12px;
    }

    .spine-dot {
        width: 8px;
        height: 8px;
    }
}

/* --- Page fade-in on scroll --- */
.page {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

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

/* Stagger right pages */
.page-right {
    transition-delay: 0.15s;
}
