/* === Custom Properties === */
:root {
    --bg-primary: #F4F5F7;
    --bg-secondary: #E8EAEF;
    --text-primary: #1C2533;
    --text-secondary: #3A4554;
    --text-tertiary: #5A6A7A;
    --ui-accent: #6B7B8D;
    --highlight: #2E5BFF;
    --mesh-warm: #A8B4C6;
    --mesh-cool: #7889A0;
    --rule-border: #B0B8C4;
    --dark-bg: #1C2533;
    --dark-text: #D4DAE2;
}

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

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

body {
    background-color: var(--bg-primary);
    color: var(--text-secondary);
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 400;
    line-height: 1.72;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* === Navigation / Plate Counter === */
.plate-counter {
    position: fixed;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.plate-number {
    font-family: 'DM Mono', monospace;
    font-weight: 400;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    color: var(--ui-accent);
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transition: color 150ms ease;
}

.plate-number:hover {
    color: var(--text-secondary);
}

.progress-track {
    width: 2px;
    height: 120px;
    background-color: var(--rule-border);
    position: relative;
}

.progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--highlight);
    transform: scaleY(0);
    transform-origin: top;
    transition: transform 100ms linear;
}

/* === Plates (General) === */
.plate {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* === Plate Spacers === */
.plate-spacer {
    height: 20vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-primary);
    padding: 0 10%;
}

.spacer-rule {
    border: none;
    height: 1px;
    background-color: var(--rule-border);
    width: 100%;
}

/* === Gradient Meshes === */
.gradient-mesh {
    position: absolute;
    inset: 0;
    z-index: 0;
}

.mesh-hero {
    background:
        radial-gradient(ellipse 60% 50% at 30% 40%, var(--mesh-warm) 0%, transparent 70%),
        radial-gradient(ellipse 40% 40% at 70% 60%, var(--mesh-cool) 0%, transparent 60%),
        var(--bg-primary);
    animation: meshBreathe 12s ease-in-out infinite;
}

@keyframes meshBreathe {
    0%, 100% {
        background:
            radial-gradient(ellipse 60% 50% at 30% 40%, var(--mesh-warm) 0%, transparent 70%),
            radial-gradient(ellipse 40% 40% at 70% 60%, var(--mesh-cool) 0%, transparent 60%),
            var(--bg-primary);
    }
    50% {
        background:
            radial-gradient(ellipse 60% 50% at 35% 45%, var(--mesh-warm) 0%, transparent 70%),
            radial-gradient(ellipse 40% 40% at 65% 55%, var(--mesh-cool) 0%, transparent 60%),
            var(--bg-primary);
    }
}

.mesh-visual-1 {
    background:
        radial-gradient(ellipse 50% 50% at 25% 30%, var(--mesh-warm) 0%, transparent 60%),
        radial-gradient(ellipse 60% 40% at 75% 70%, var(--mesh-cool) 0%, transparent 50%),
        radial-gradient(ellipse 30% 30% at 50% 50%, var(--bg-secondary) 0%, transparent 70%),
        var(--bg-primary);
}

.mesh-visual-2 {
    background:
        radial-gradient(ellipse 50% 50% at 40% 35%, rgba(46, 91, 255, 0.08) 0%, transparent 60%),
        radial-gradient(ellipse 60% 50% at 70% 65%, rgba(46, 91, 255, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse 80% 60% at 50% 50%, rgba(120, 137, 160, 0.3) 0%, transparent 70%),
        var(--dark-bg);
}

.mesh-visual-3 {
    background:
        radial-gradient(ellipse 45% 45% at 60% 40%, var(--mesh-cool) 0%, transparent 60%),
        radial-gradient(ellipse 55% 50% at 30% 65%, var(--mesh-warm) 0%, transparent 50%),
        radial-gradient(ellipse 35% 35% at 80% 25%, var(--bg-secondary) 0%, transparent 70%),
        conic-gradient(from 180deg at 50% 50%, var(--bg-primary) 0deg, var(--bg-secondary) 120deg, var(--bg-primary) 240deg, var(--bg-primary) 360deg);
}

/* === Grid Overlay === */
.grid-overlay {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background:
        repeating-linear-gradient(0deg, transparent, transparent 47px, rgba(176, 184, 196, 0.15) 47px, rgba(176, 184, 196, 0.15) 48px),
        repeating-linear-gradient(90deg, transparent, transparent 47px, rgba(176, 184, 196, 0.15) 47px, rgba(176, 184, 196, 0.15) 48px);
}

.grid-dark {
    background:
        repeating-linear-gradient(0deg, transparent, transparent 47px, rgba(212, 218, 226, 0.06) 47px, rgba(212, 218, 226, 0.06) 48px),
        repeating-linear-gradient(90deg, transparent, transparent 47px, rgba(212, 218, 226, 0.06) 47px, rgba(212, 218, 226, 0.06) 48px);
}

/* === Data Points === */
.data-points {
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
}

.data-point {
    position: absolute;
    width: 6px;
    height: 6px;
    border: 1px solid var(--ui-accent);
    border-radius: 50%;
    background: transparent;
    transition: border-color 150ms ease, background-color 150ms ease;
    pointer-events: all;
    cursor: default;
}

.data-point:hover {
    border-color: var(--highlight);
    background-color: rgba(46, 91, 255, 0.15);
}

.data-point-tooltip {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    font-family: 'DM Mono', monospace;
    font-size: 0.65rem;
    font-weight: 400;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    background-color: var(--bg-primary);
    border: 1px solid var(--rule-border);
    padding: 2px 6px;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 150ms ease;
    pointer-events: none;
}

.data-point:hover .data-point-tooltip {
    opacity: 1;
}

.plate-dark .data-point {
    border-color: rgba(212, 218, 226, 0.3);
}

.plate-dark .data-point:hover {
    border-color: var(--highlight);
    background-color: rgba(46, 91, 255, 0.15);
}

.plate-dark .data-point-tooltip {
    background-color: var(--dark-bg);
    border-color: rgba(212, 218, 226, 0.2);
    color: var(--dark-text);
}

/* Data point pulse effect */
.data-point-pulse {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: transparent;
    border: 1px solid var(--highlight);
    pointer-events: none;
    animation: pointPulse 1s ease-out forwards;
}

@keyframes pointPulse {
    0% {
        transform: scale(1);
        opacity: 0.4;
    }
    100% {
        transform: scale(3.3);
        opacity: 0;
    }
}

/* === Hero Plate === */
.plate-hero {
    background-color: var(--bg-primary);
}

.hero-content {
    position: relative;
    z-index: 1;
    text-align: center;
    padding-top: 5vh;
}

.hero-title {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-weight: 700;
    font-size: clamp(2.4rem, 6vw, 5rem);
    color: var(--text-primary);
    letter-spacing: -0.02em;
    line-height: 1.1;
    opacity: 0;
    animation: fadeInUp 800ms ease-out 400ms forwards;
}

.hero-subtitle {
    font-family: 'DM Mono', monospace;
    font-weight: 300;
    font-size: 0.85rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ui-accent);
    margin-top: 1.5rem;
    opacity: 0;
    animation: fadeInUp 800ms ease-out 700ms forwards;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* === Visual Plates === */
.plate-visual {
    background-color: var(--bg-primary);
}

.plate-dark {
    background-color: var(--dark-bg);
}

.visual-quote-wrap {
    position: relative;
    z-index: 3;
    max-width: 800px;
    padding: 0 2rem;
}

.visual-quote {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-weight: 400;
    font-style: italic;
    font-size: clamp(1.8rem, 4vw, 3.2rem);
    color: var(--text-primary);
    line-height: 1.4;
    letter-spacing: -0.02em;
    text-align: center;
}

.quote-light {
    color: var(--dark-text);
}

/* === Text Plates / Editorial Grid === */
.plate-text {
    align-items: flex-start;
    padding: 12vh 0 10vh;
    min-height: 100vh;
}

.editorial-grid {
    display: grid;
    grid-template-columns: 2fr 6fr 4fr;
    gap: 24px;
    max-width: 1200px;
    width: 100%;
    padding: 0 3rem 0 60px;
    position: relative;
    z-index: 1;
}

.margin-annotations {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-top: 0.5rem;
}

.annotation {
    font-family: 'DM Mono', monospace;
    font-weight: 400;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--ui-accent);
    line-height: 1.4;
}

.reading-column {
    max-width: 640px;
}

.section-heading {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-weight: 400;
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    color: var(--text-tertiary);
    line-height: 1.3;
    letter-spacing: -0.02em;
    margin-bottom: 1.5rem;
}

.rule-divider {
    height: 1px;
    background-color: var(--rule-border);
    margin-bottom: 2rem;
}

.rule-divider.partial {
    width: 60%;
}

.body-text {
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.72;
    color: var(--text-secondary);
    max-width: 38em;
    text-align: left;
    margin-bottom: 1.5rem;
}

.pull-quote {
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 300;
    font-style: italic;
    font-size: 1.6rem;
    line-height: 1.5;
    color: var(--text-secondary);
    padding-left: 2em;
    border-left: 3px solid #8E9CAD;
    margin: 2.5rem 0;
}

/* === Offset / Notation Elements === */
.offset-element {
    display: flex;
    align-items: flex-start;
    padding-top: 4rem;
}

.notation-mark {
    color: var(--ui-accent);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
}

.notation-svg {
    width: 40px;
    height: 80px;
}

.notation-label {
    font-family: 'DM Mono', monospace;
    font-weight: 400;
    font-size: 0.65rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--ui-accent);
    writing-mode: vertical-rl;
    text-orientation: mixed;
}

/* === Coda (End Section) === */
.plate-coda {
    position: absolute;
    bottom: 8vh;
    left: 0;
    width: 100%;
    text-align: center;
    padding: 0 2rem;
}

.coda-rule {
    border: none;
    height: 1px;
    background-color: var(--rule-border);
    width: 120px;
    margin: 0 auto 2rem;
}

.coda-text {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
}

.coda-label {
    font-family: 'DM Mono', monospace;
    font-weight: 300;
    font-size: 0.7rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ui-accent);
}

/* === Reveal Animation States === */
.reveal-element {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 500ms cubic-bezier(0.25, 0.46, 0.45, 0.94),
                transform 500ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

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

/* === Responsive === */
@media (max-width: 768px) {
    .editorial-grid {
        grid-template-columns: 1fr;
        padding: 0 1.5rem 0 50px;
        gap: 16px;
    }

    .margin-annotations {
        flex-direction: row;
        gap: 1.5rem;
        padding-top: 0;
        margin-bottom: 1rem;
    }

    .offset-element {
        padding-top: 2rem;
    }

    .notation-label {
        writing-mode: horizontal-tb;
    }

    .plate-counter {
        left: 8px;
    }

    .visual-quote {
        font-size: clamp(1.4rem, 5vw, 2.4rem);
    }

    .pull-quote {
        font-size: 1.2rem;
        padding-left: 1.2em;
    }
}

@media (max-width: 480px) {
    .editorial-grid {
        padding: 0 1rem 0 44px;
    }

    .margin-annotations {
        flex-direction: column;
        gap: 0.5rem;
    }
}

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

    .reveal-element {
        opacity: 1;
        transform: none;
    }

    .hero-title,
    .hero-subtitle {
        opacity: 1;
        transform: none;
    }
}
