/* ============================================================
   graphers.dev -- Brutalist Academic Monograph
   ============================================================ */

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

:root {
    --ground: #F5F0E8;
    --ground-alt: #EDE7DB;
    --text-primary: #2B2520;
    --text-secondary: #3D3630;
    --text-tertiary: #8C7E72;
    --accent-rose: #C4616A;
    --accent-blue: #4A6E8C;
    --rule-lines: #B8AFA5;
    --highlight-gold: #D4B876;
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--ground);
    color: var(--text-secondary);
    font-family: 'Source Serif 4', 'Georgia', serif;
    font-weight: 400;
    font-size: clamp(1.05rem, 1.8vw, 1.2rem);
    line-height: 1.72;
    letter-spacing: 0.005em;
    overflow-x: hidden;
    position: relative;
}

/* --- Coordinate Grid Background --- */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    background:
        repeating-linear-gradient(
            to right,
            rgba(184, 175, 165, 0.04) 0px,
            rgba(184, 175, 165, 0.04) 1px,
            transparent 1px,
            transparent 80px
        ),
        repeating-linear-gradient(
            to bottom,
            rgba(184, 175, 165, 0.04) 0px,
            rgba(184, 175, 165, 0.04) 1px,
            transparent 1px,
            transparent 80px
        ),
        repeating-linear-gradient(
            to right,
            rgba(184, 175, 165, 0.015) 0px,
            rgba(184, 175, 165, 0.015) 1px,
            transparent 1px,
            transparent 16px
        ),
        repeating-linear-gradient(
            to bottom,
            rgba(184, 175, 165, 0.015) 0px,
            rgba(184, 175, 165, 0.015) 1px,
            transparent 1px,
            transparent 16px
        );
    opacity: 0;
    transition: opacity 0.8s ease;
}

body.grid-visible::before {
    opacity: 1;
}

/* --- Scan Lines --- */
.scan-lines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 200%;
    pointer-events: none;
    z-index: 9998;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 1px,
        rgba(0, 0, 0, 0.02) 1px,
        rgba(0, 0, 0, 0.02) 2px
    );
    animation: scanDrift 20s linear infinite;
}

@keyframes scanDrift {
    0% { transform: translateY(0); }
    100% { transform: translateY(-50%); }
}

/* --- CRT Vignette --- */
.crt-vignette {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9997;
    background: radial-gradient(
        ellipse at center,
        transparent 60%,
        rgba(0, 0, 0, 0.05) 100%
    );
}

/* --- Progress Bar --- */
.progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    z-index: 10000;
    background: transparent;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background-color: var(--accent-rose);
    transition: width 50ms linear;
}

.progress-ticks {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.progress-tick {
    position: absolute;
    top: 0;
    width: 1px;
    height: 6px;
    background-color: var(--text-tertiary);
    opacity: 0.5;
}

/* ============================================================
   HERO SECTION
   ============================================================ */

.hero {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: var(--ground);
    overflow: hidden;
}

.hero-grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background:
        repeating-linear-gradient(
            to right,
            rgba(184, 175, 165, 0.04) 0px,
            rgba(184, 175, 165, 0.04) 1px,
            transparent 1px,
            transparent 80px
        ),
        repeating-linear-gradient(
            to bottom,
            rgba(184, 175, 165, 0.04) 0px,
            rgba(184, 175, 165, 0.04) 1px,
            transparent 1px,
            transparent 80px
        ),
        repeating-linear-gradient(
            to right,
            rgba(184, 175, 165, 0.015) 0px,
            rgba(184, 175, 165, 0.015) 1px,
            transparent 1px,
            transparent 16px
        ),
        repeating-linear-gradient(
            to bottom,
            rgba(184, 175, 165, 0.015) 0px,
            rgba(184, 175, 165, 0.015) 1px,
            transparent 1px,
            transparent 16px
        );
    opacity: 0;
    transition: opacity 0.8s ease;
}

.hero-grid-overlay.visible {
    opacity: 1;
}

.hero-curve {
    position: absolute;
    width: 60vmin;
    height: 60vmin;
    max-width: 500px;
    max-height: 500px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.hero-curve.visible {
    opacity: 1;
}

.hero-text {
    position: relative;
    z-index: 2;
    text-align: center;
    margin-top: 5vmin;
}

.hero-title {
    font-family: 'Cormorant Garamond', 'Georgia', serif;
    font-weight: 300;
    font-size: 8vw;
    letter-spacing: 0.15em;
    color: var(--text-primary);
    opacity: 0;
    transition: opacity 0.6s ease;
}

.hero-title.visible {
    opacity: 1;
}

.hero-subtitle {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 0.9rem;
    color: var(--text-tertiary);
    letter-spacing: 0.04em;
    margin-top: 1rem;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.hero-subtitle.visible {
    opacity: 1;
}

/* ============================================================
   MANUSCRIPT BODY
   ============================================================ */

.manuscript {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 4rem 2rem;
}

/* --- Section Structure --- */
.ms-section {
    display: grid;
    grid-template-columns: 200px 1fr 200px;
    gap: 0 2rem;
    margin-bottom: clamp(4rem, 8vh, 8rem);
    position: relative;
}

.section-rule {
    border: none;
    border-top: 1px solid var(--rule-lines);
    margin: 0 auto clamp(4rem, 8vh, 8rem);
    max-width: 1040px;
    width: calc(100% - 4rem);
}

/* --- Left Margin --- */
.section-margin-left {
    position: relative;
    text-align: right;
    padding-right: 1.5rem;
    padding-top: 0.5rem;
}

.section-number-watermark {
    display: block;
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 3.6rem;
    color: var(--text-primary);
    opacity: 0.15;
    line-height: 1;
    letter-spacing: 0.02em;
    position: absolute;
    top: -0.5rem;
    right: 1.5rem;
}

.section-number-functional {
    display: block;
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.7rem, 1.1vw, 0.85rem);
    color: var(--text-tertiary);
    letter-spacing: 0.04em;
    margin-bottom: 1rem;
    position: relative;
    z-index: 2;
}

.margin-marks {
    margin-top: 2rem;
    display: flex;
    justify-content: flex-end;
    padding-right: 0.5rem;
}

/* --- Section Content --- */
.section-content {
    max-width: 640px;
}

.section-header {
    position: relative;
    margin-bottom: 2rem;
}

.section-curve {
    display: block;
    width: 100%;
    height: 80px;
    margin-bottom: 1rem;
    overflow: visible;
}

.curve-path {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 1.5s ease-in-out;
}

.curve-path.drawn {
    stroke-dashoffset: 0;
}

.section-content h2 {
    font-family: 'Playfair Display', 'Georgia', serif;
    font-weight: 600;
    font-size: clamp(1.6rem, 3vw, 2.4rem);
    color: var(--text-primary);
    letter-spacing: -0.03em;
    line-height: 1.2;
    opacity: 0;
    transition: opacity 0.6s ease;
}

.section-content h2.visible {
    opacity: 1;
}

.section-content p {
    margin-bottom: 1.5rem;
}

.section-content p:last-child {
    margin-bottom: 0;
}

.pullquote {
    font-family: 'Cormorant Garamond', 'Georgia', serif;
    font-weight: 500;
    font-size: clamp(1.3rem, 2.2vw, 1.6rem);
    color: var(--text-primary);
    line-height: 1.5;
    padding: 1.5rem 0;
    border-top: 1px solid var(--rule-lines);
    border-bottom: 1px solid var(--rule-lines);
    margin: 2rem 0;
    font-style: italic;
}

/* --- Right Margin --- */
.section-margin-right {
    padding-left: 1.5rem;
    padding-top: 4rem;
}

.margin-annotation {
    position: relative;
}

.annotation-marker {
    display: block;
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 1.2rem;
    color: var(--accent-rose);
    cursor: default;
    margin-bottom: 0.5rem;
}

.annotation-text {
    display: block;
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.7rem, 1.1vw, 0.85rem);
    color: var(--text-tertiary);
    letter-spacing: 0.04em;
    line-height: 1.5;
}

.annotation-text em {
    font-style: italic;
}

/* --- Magnetic Element Hover --- */
.magnetic-element {
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    display: inline-block;
}

/* --- Hyperlinks --- */
a {
    color: var(--accent-rose);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.3s ease, color 0.3s ease;
}

a:hover {
    border-bottom-color: var(--accent-rose);
}

/* ============================================================
   FOOTER
   ============================================================ */

.site-footer {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem 4rem;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding-top: 2rem;
}

.footer-mark {
    font-family: 'Cormorant Garamond', 'Georgia', serif;
    font-weight: 300;
    font-size: 1.2rem;
    color: var(--text-primary);
    letter-spacing: 0.1em;
}

.footer-caption {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.7rem, 1.1vw, 0.85rem);
    color: var(--text-tertiary);
    letter-spacing: 0.04em;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* Below 1080px: margins collapse */
@media (max-width: 1080px) {
    .ms-section {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .section-margin-left {
        text-align: left;
        padding-right: 0;
        padding-bottom: 0.5rem;
        display: flex;
        align-items: baseline;
        gap: 1rem;
    }

    .section-number-watermark {
        display: none;
    }

    .section-number-functional {
        margin-bottom: 0;
        display: inline;
    }

    .margin-marks {
        display: none;
    }

    .section-content {
        max-width: 100%;
    }

    .section-margin-right {
        padding-left: 0;
        padding-top: 1.5rem;
        border-top: 1px dashed var(--rule-lines);
        margin-top: 1.5rem;
    }

    .manuscript {
        max-width: 740px;
    }

    .section-rule {
        width: 100%;
    }
}

/* Below 640px: grid removed, proportional scaling */
@media (max-width: 640px) {
    .hero-title {
        font-size: 12vw;
    }

    .hero-curve {
        width: 80vmin;
        height: 80vmin;
    }

    .manuscript {
        padding: 2rem 1.5rem;
    }

    .section-rule {
        margin-left: 0;
        margin-right: 0;
    }

    .footer-content {
        flex-direction: column;
        gap: 0.5rem;
    }
}
