/* ============================================================
   graphers.dev - Data as Fine Art
   Aesthetic: minimalist | Layout: portfolio-grid | Typography: humanist
   Palette: high-contrast | Patterns: fade-reveal | Imagery: data-viz
   ============================================================ */

/* CSS Custom Properties - Palette from DESIGN.md */
:root {
    --bg-canvas: #FAFBFC;
    --text-primary: #111827;
    --text-secondary: #4B5563;
    --text-muted: #9CA3AF;
    --grid-dots: #E5E7EB;
    --accent: #4F46E5;
    --accent-hover: #3730A3;
    --accent-light: #EEF2FF;
    --alert: #EF4444;
    --success: #0D9488;
    --border-light: #D1D5DB;
    --border-muted: #6B7280;

    --font-heading: 'Source Serif 4', Georgia, 'Times New Roman', serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'IBM Plex Mono', 'Courier New', monospace;
    --font-accent: 'Fraunces', Georgia, serif;

    --gutter: 24px;
    --datum-bar-height: 48px;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-canvas);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* Dot Grid Background - graph paper effect at 48px intervals */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: radial-gradient(circle, var(--grid-dots) 1px, transparent 1px);
    background-size: 48px 48px;
    opacity: 0.4;
    pointer-events: none;
    z-index: 0;
}

/* ============================================================
   The Datum Bar - 48px anchored top bar
   ============================================================ */
#datum-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--datum-bar-height);
    background-color: var(--bg-canvas);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    padding: 0 var(--gutter);
    z-index: 1000;
    gap: 12px;
}

.wordmark {
    font-family: var(--font-body);
    font-weight: 500;
    font-size: 0.95rem;
    letter-spacing: 0.02em;
    color: var(--text-primary);
}

.dot-separator {
    color: var(--text-muted);
    font-size: 1.2rem;
    line-height: 1;
}

.nav-links {
    display: flex;
    gap: 24px;
    margin-left: auto;
}

.nav-link {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    text-decoration: none;
    transition: color 400ms ease;
}

.nav-link:hover,
.nav-link.active {
    color: var(--accent);
}

/* ============================================================
   Chapters - General
   ============================================================ */
.chapter {
    position: relative;
    z-index: 1;
}

/* ============================================================
   Chapter 1: The Observatory
   Full-viewport scatter plot - data IS the hero
   ============================================================ */
#observatory {
    height: 100vh;
    width: 100%;
    position: relative;
    overflow: hidden;
    padding-top: var(--datum-bar-height);
}

.observatory-tagline {
    position: absolute;
    top: calc(var(--datum-bar-height) + 32px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    text-align: center;
}

.tagline-text {
    font-family: var(--font-accent);
    font-weight: 900;
    font-variation-settings: 'WONK' 1;
    font-size: clamp(1.8rem, 3.5vw, 3.2rem);
    color: var(--text-primary);
    letter-spacing: 0.005em;
    line-height: 1.15;
}

#scatter-canvas {
    position: absolute;
    top: var(--datum-bar-height);
    left: 0;
    width: 100%;
    height: calc(100% - var(--datum-bar-height));
    cursor: crosshair;
}

.scatter-tooltip {
    position: absolute;
    display: none;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-secondary);
    background-color: var(--bg-canvas);
    border: 1px solid var(--text-muted);
    padding: 4px 8px;
    pointer-events: none;
    z-index: 20;
    white-space: nowrap;
    letter-spacing: 0.04em;
}

/* ============================================================
   Bar Chart Section Transitions
   Horizontal bars growing left-to-right with staggered reveal
   ============================================================ */
.bar-transition-container {
    position: relative;
    width: 100%;
    height: 24px;
    overflow: hidden;
}

.bar-transition {
    position: absolute;
    left: 0;
    height: 3px;
    transform-origin: left center;
    transform: scaleX(0);
    transition: transform 800ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.bar-transition.is-visible {
    transform: scaleX(1);
}

/* Stagger delays for bar transitions */
.bar-transition-container .bar-transition:nth-child(1) { transition-delay: 0ms; }
.bar-transition-container .bar-transition:nth-child(2) { transition-delay: 100ms; }
.bar-transition-container .bar-transition:nth-child(3) { transition-delay: 200ms; }
.bar-transition-container .bar-transition:nth-child(4) { transition-delay: 300ms; }

/* ============================================================
   Chapter 2: The Specimens
   Portfolio grid with golden-ratio modulated cells
   ============================================================ */
#specimens {
    min-height: 300vh;
    padding: 120px var(--gutter) 80px;
    max-width: 1280px;
    margin: 0 auto;
}

.section-heading {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: clamp(1.8rem, 3.5vw, 3.2rem);
    letter-spacing: 0.005em;
    line-height: 1.15;
    color: var(--text-primary);
    margin-bottom: 64px;
}

.specimen-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: var(--gutter);
}

/* Specimen base - 1px border, sharp corners, no shadows */
.specimen {
    position: relative;
    border: 1px solid var(--text-muted);
    background-color: var(--bg-canvas);
    transition: border-width 400ms ease, border-color 400ms ease;
    overflow: visible;
}

.specimen:hover {
    border: 2px solid var(--text-primary);
}

/* Golden ratio modulated cells */
.specimen-landscape {
    grid-column: span 7;
    aspect-ratio: 1.618 / 1;
}

.specimen-square {
    grid-column: span 5;
    aspect-ratio: 1 / 1;
}

.specimen-portrait {
    grid-column: span 5;
    aspect-ratio: 1 / 1.618;
}

.specimen-wide {
    grid-column: span 12;
    aspect-ratio: 2.618 / 1;
}

/* Specimen axis labels - 10px IBM Plex Mono small caps */
.specimen-axes {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

.axis-label {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 400;
    letter-spacing: 0.04em;
    color: var(--border-muted);
    text-transform: uppercase;
    position: absolute;
}

.axis-y {
    left: 8px;
    top: 50%;
    transform: rotate(-90deg) translateX(-50%);
    transform-origin: left center;
}

.axis-x {
    bottom: 8px;
    right: 12px;
}

/* Specimen content - positioned at bottom */
.specimen-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: flex-end;
    padding: 28px 24px 20px;
    z-index: 1;
}

.specimen-inner {
    width: 100%;
}

.specimen-title {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: clamp(1.1rem, 2vw, 1.5rem);
    letter-spacing: 0.005em;
    line-height: 1.15;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.specimen-desc {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(0.875rem, 1.2vw, 1.05rem);
    letter-spacing: 0.01em;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 16px;
    max-width: 480px;
}

/* Line chart signatures - SVG path animation */
.line-signature {
    width: 100%;
    height: 64px;
    display: block;
}

.sig-path {
    stroke-dasharray: 1200;
    stroke-dashoffset: 1200;
    transition: stroke-dashoffset 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.specimen.is-visible .sig-path {
    stroke-dashoffset: 0;
}

/* Annotation layer - hairline connected labels */
.annotation-layer {
    position: absolute;
    top: -24px;
    right: -120px;
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0;
    transition: opacity 400ms ease;
    pointer-events: none;
    z-index: 10;
}

.specimen:hover .annotation-layer {
    opacity: 1;
}

.annotation-line {
    width: 60px;
    height: 0.5px;
    background-color: var(--border-muted);
}

.annotation-text {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 400;
    letter-spacing: 0.04em;
    color: var(--border-muted);
    white-space: nowrap;
}

/* ============================================================
   Chapter 3: The Method
   Annotated diagram layout - text as chart captions
   ============================================================ */
#method {
    min-height: 100vh;
    padding: 120px var(--gutter);
    max-width: 1280px;
    margin: 0 auto;
}

.method-diagram {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-template-rows: auto;
    gap: var(--gutter);
    grid-template-areas:
        "a a a a a a a a . . . ."
        ". b b b b b . c c c c c"
        "d d d d d . . . . . . ."
        ". . . . e e e e e e . ."
        "f f f f . g g g g . h h";
}

.method-fragment {
    padding: 24px 0;
}

.method-heading {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: clamp(1.8rem, 3.5vw, 3.2rem);
    letter-spacing: 0.005em;
    line-height: 1.15;
    color: var(--text-primary);
}

.method-text {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(0.875rem, 1.2vw, 1.05rem);
    letter-spacing: 0.01em;
    color: var(--text-secondary);
    line-height: 1.7;
}

.highlight {
    color: var(--accent);
    font-weight: 500;
}

.method-datum {
    display: block;
    font-family: var(--font-mono);
    font-size: clamp(2rem, 4vw, 3.5rem);
    font-weight: 400;
    color: var(--accent);
    letter-spacing: 0.04em;
    position: relative;
    padding-top: 8px;
}

.method-datum::after {
    content: attr(data-label);
    display: block;
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 400;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ============================================================
   Chapter 4: The Coordinates
   Contact as coordinate readout in IBM Plex Mono
   ============================================================ */
#coordinates {
    min-height: 50vh;
    padding: 120px var(--gutter);
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.coordinates-readout {
    width: 100%;
    max-width: 640px;
}

.coordinates-heading {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: clamp(1.8rem, 3.5vw, 3.2rem);
    letter-spacing: 0.005em;
    line-height: 1.15;
    color: var(--text-primary);
    margin-bottom: 48px;
}

.coordinate-entries {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.coordinate-entry {
    display: flex;
    align-items: baseline;
    gap: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--grid-dots);
}

.coord-label {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    min-width: 100px;
}

.coord-value {
    font-family: var(--font-mono);
    font-size: clamp(0.95rem, 1.5vw, 1.2rem);
    font-weight: 400;
    letter-spacing: 0.04em;
    color: var(--text-primary);
    text-decoration: none;
    transition: color 400ms ease;
}

a.coord-value:hover {
    color: var(--accent);
}

/* ============================================================
   Footer Axis - horizontal line with tick marks
   ============================================================ */
#footer-axis {
    position: relative;
    padding: 0 var(--gutter) 48px;
    max-width: 1280px;
    margin: 0 auto;
    z-index: 1;
}

.axis-line-footer {
    width: 100%;
    height: 1px;
    background-color: var(--text-primary);
    margin-bottom: 24px;
}

.footer-ticks {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.footer-tick {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.tick-mark {
    width: 1px;
    height: 12px;
    background-color: var(--text-primary);
}

.tick-label {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 400;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

/* ============================================================
   Fade Reveal Animation
   opacity:0 translateY(12px) -> opacity:1 translateY(0)
   600ms cubic-bezier(0.25, 0.46, 0.45, 0.94)
   ============================================================ */
.fade-reveal {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 600ms cubic-bezier(0.25, 0.46, 0.45, 0.94),
                transform 600ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

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

/* ============================================================
   Decorative Axis Lines - subtle pulse on 4s cycle
   ============================================================ */
.axis-line-decorative {
    position: absolute;
    left: 0;
    width: 100%;
    height: 1px;
    background-color: var(--grid-dots);
    z-index: 0;
    pointer-events: none;
    animation: axisPulse 4s ease-in-out infinite;
}

@keyframes axisPulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.4; }
}

/* ============================================================
   Active specimen highlight - coral red border for featured
   ============================================================ */
.specimen.is-featured {
    border-color: var(--alert);
    border-width: 2px;
}

/* ============================================================
   Responsive - 4-column collapse on mobile
   ============================================================ */
@media (max-width: 768px) {
    .specimen-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .specimen-landscape,
    .specimen-square,
    .specimen-portrait,
    .specimen-wide {
        grid-column: span 4;
    }

    .specimen-portrait {
        aspect-ratio: 1 / 1.2;
    }

    .specimen-wide {
        aspect-ratio: 1.618 / 1;
    }

    .nav-links {
        gap: 16px;
    }

    .nav-link {
        font-size: 0.7rem;
    }

    .annotation-layer {
        display: none;
    }

    .method-diagram {
        grid-template-columns: 1fr;
        grid-template-areas:
            "a"
            "b"
            "c"
            "d"
            "e"
            "f"
            "g"
            "h";
    }

    .coordinate-entry {
        flex-direction: column;
        gap: 4px;
    }

    .footer-ticks {
        flex-direction: column;
        gap: 16px;
        align-items: flex-start;
    }

    .footer-tick {
        flex-direction: row;
    }

    .tick-mark {
        width: 12px;
        height: 1px;
    }
}

@media (max-width: 480px) {
    .observatory-tagline {
        top: calc(var(--datum-bar-height) + 20px);
    }

    .tagline-text {
        font-size: 1.6rem;
    }

    .nav-links {
        gap: 12px;
    }
}
