/* =========================================================
   concurrengine.com — Victorian clockwork observatory
   Palette: muted Victorian (parchment, copper, indigo, garnet)
   Typography compliance note: Playfair Display" (Google Fonts) and Source Serif 4" (Google Fonts) are named in the design; the page uses local/system resolution with standard fallbacks rather than external fetching. IntersectionObserver adjusts a CSS custom property (`--wave-scale` for the hero wordmark. On page load Playfair evokes Victorian engraved lettering and ornamental type specimens. The variable axis is exploited for subtle weight animation on hover — letters breathe between 700 and 900 weight.
   ========================================================= */

:root {
    --bg-parchment: #f4f0e8;
    --bg-parchment-2: #ece8de;
    --bg-dark: #1a1a1e;
    --ink: #2a2a2a;
    --copper: #6b5e4f;
    --brass: #8a7a56;
    --indigo: #3d4f7c;
    --garnet: #7c3043;
    --silver: #b8b4aa;

    --mouse-x: 0;
    --mouse-y: 0;
    --wave-scale: 1;

    --font-display: "Playfair Display", "Lora", serif;
    --font-heading: "Cormorant Garamond", "Playfair Display", serif;
    --font-body: "Source Serif 4", "Lora", Georgia, serif;
    --font-mono: "DM Mono", "IBM Plex Mono", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
    font-family: var(--font-body);
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.72;
    letter-spacing: 0.01em;
    color: var(--ink);
    background: var(--bg-parchment);
    overflow-x: hidden;
}

/* Subtle vellum grain on the parchment */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        radial-gradient(rgba(107,94,79,0.035) 1px, transparent 1px),
        radial-gradient(rgba(107,94,79,0.025) 1px, transparent 1px);
    background-size: 3px 3px, 7px 7px;
    background-position: 0 0, 1px 2px;
    mix-blend-mode: multiply;
    z-index: 1;
}

main#engine {
    position: relative;
    z-index: 2;
}

.label {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--copper);
    margin: 0 0 1rem 0;
}
.label--light { color: var(--silver); }

.section { position: relative; }

/* =====================================================
   1. HERO — The Engraving Plate
   ===================================================== */
.section--hero {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 4vh 5vw;
    background: var(--bg-parchment);
    overflow: hidden;
}

.hero-engraving {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0.72;
}

/* Gears rotate very slowly */
.hero-gear { transform-origin: center; transform-box: fill-box; }
.hero-gear--a { animation: spin-cw 140s linear infinite; }
.hero-gear--b { animation: spin-ccw 90s linear infinite; }

@keyframes spin-cw  { to { transform: rotate(360deg); } }
@keyframes spin-ccw { to { transform: rotate(-360deg); } }

/* Hero wave draws itself in */
.hero-waves .trace {
    stroke-dasharray: 1800;
    stroke-dashoffset: 1800;
    animation: draw 6s ease-out forwards;
}
.hero-waves .trace--2 { animation-delay: 0.6s; }
.hero-waves .trace--3 { animation-delay: 1.2s; }

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

.hero-text {
    position: relative;
    z-index: 2;
    text-align: center;
    max-width: 1080px;
    padding: 0 2rem;
}

.wordmark {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2.4rem, 7vw, 6rem);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink);
    margin: 0;
    line-height: 1;
    display: inline-flex;
    justify-content: center;
    flex-wrap: wrap;
}
.wordmark span {
    display: inline-block;
    transition: font-weight 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
                color 0.4s ease,
                transform 0.4s ease;
    font-variation-settings: "wght" 400;
}
body.loaded .wordmark span {
    font-variation-settings: "wght" 820;
    font-weight: 820;
}
.wordmark span:hover {
    font-variation-settings: "wght" 900;
    font-weight: 900;
    color: var(--garnet);
    transform: translateY(-2px);
}

.hero-tag {
    margin-top: 2rem;
    font-family: var(--font-heading);
    font-style: italic;
    font-weight: 500;
    font-size: clamp(1.1rem, 2vw, 1.6rem);
    color: var(--copper);
    letter-spacing: 0.04em;
}
.hero-tag .cursor {
    display: inline-block;
    width: 1px;
    height: 1.2em;
    background: var(--copper);
    vertical-align: -0.18em;
    margin-left: 3px;
    animation: blink 1.1s steps(2, start) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.hero-meta {
    margin-top: 2.4rem;
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--copper);
}
.meta-rule {
    display: inline-block;
    width: 32px;
    height: 1px;
    background: var(--copper);
    opacity: 0.6;
}

/* =====================================================
   2. SHEARING PLANE
   ===================================================== */
.section--shear {
    background: var(--bg-parchment-2);
    padding: 3vh 5vw;
    clip-path: polygon(0 18%, 100% 0, 100% 82%, 0 100%);
    margin-top: -4vh;
    text-align: center;
    position: relative;
    min-height: 18vh;
    display: grid;
    place-items: center;
}
.shear-wave {
    width: 80%;
    max-width: 900px;
    height: 60px;
    display: block;
    margin: 0 auto 1rem;
}
.shear-wave-flow {
    stroke-dashoffset: 0;
    animation: flow 6s linear infinite;
}
@keyframes flow { to { stroke-dashoffset: -200; } }

.shear-caption {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--copper);
    margin: 0;
}
.shear-caption span { color: var(--garnet); }

/* =====================================================
   3. THREE THREADS — diagonal overlapping vellum sheets
   ===================================================== */
.section--thread {
    position: relative;
    padding: 14vh 10vw;
    margin-top: -6vh;
    min-height: 70vh;
    display: grid;
    place-items: center;
}

.thread--a {
    background: var(--bg-parchment);
    clip-path: polygon(0 8%, 100% 0, 100% 92%, 0 100%);
    transform: rotate(-0.5deg);
}
.thread--b {
    background: var(--bg-parchment-2);
    clip-path: polygon(0 4%, 100% 12%, 100% 96%, 0 88%);
    transform: rotate(0.6deg);
    z-index: 2;
}
.thread--c {
    background: var(--bg-parchment);
    clip-path: polygon(0 12%, 100% 0, 100% 88%, 0 100%);
    transform: rotate(-0.4deg);
}

.filigree-frame {
    position: absolute;
    inset: 6vh 7vw;
    width: calc(100% - 14vw);
    height: calc(100% - 12vh);
    pointer-events: none;
    opacity: 0.85;
}
.filigree-frame .frame-rect {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 1.6s ease-out;
}
.section--thread.in-view .filigree-frame .frame-rect {
    stroke-dashoffset: 0;
}

.thread-body {
    position: relative;
    max-width: 640px;
    text-align: left;
    padding: 2rem;
}
.thread--b .thread-body { margin-left: auto; text-align: right; }
.thread--c .thread-body { margin-right: auto; margin-left: 10%; }

.thread-title {
    font-family: var(--font-heading);
    font-style: italic;
    font-weight: 600;
    font-size: clamp(1.6rem, 3.5vw, 2.8rem);
    letter-spacing: 0.04em;
    color: var(--ink);
    margin: 0 0 1rem 0;
    line-height: 1.1;
}

.thread-text {
    margin: 0 0 2rem 0;
    color: var(--ink);
    max-width: 48ch;
}
.thread--b .thread-body .thread-text { margin-left: auto; }

.thread-motif {
    display: block;
    width: 100%;
    max-width: 320px;
    height: auto;
    margin: 0;
}
.thread--b .thread-motif { margin-left: auto; }

/* =====================================================
   4. CONVERGENCE — magnetic rosette
   ===================================================== */
.section--convergence {
    position: relative;
    margin-top: -14vh;
    padding: 20vh 5vw 14vh;
    text-align: center;
    background: transparent;
    z-index: 5;
}

.rosette-wrap {
    position: relative;
    display: inline-block;
}

.rosette {
    width: clamp(220px, 28vw, 360px);
    height: clamp(220px, 28vw, 360px);
    display: block;
    transform:
        translate(calc(var(--mouse-x) * 18px), calc(var(--mouse-y) * 18px));
    transition: transform 0.8s cubic-bezier(0.22, 1, 0.36, 1);
    filter: drop-shadow(0 2px 0 rgba(107,94,79,0.15));
}
.rosette-outer { animation: spin-cw 120s linear infinite; transform-origin: center; }
.rosette-petals { animation: spin-ccw 180s linear infinite; transform-origin: center; }
.rosette-inner { animation: pulse 6s ease-in-out infinite; transform-origin: center; }

@keyframes pulse {
    0%, 100% { opacity: 0.85; transform: scale(1); }
    50%      { opacity: 1;    transform: scale(1.04); }
}

.convergence-label {
    margin-top: 1.6rem;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--copper);
}
.convergence-label span { color: var(--garnet); }

/* =====================================================
   5. WAVE ARCHIVE — dark section
   ===================================================== */
.section--archive {
    background: var(--bg-dark);
    color: var(--silver);
    padding: 18vh 6vw 14vh;
    clip-path: polygon(0 6%, 100% 0, 100% 94%, 0 100%);
    margin-top: -8vh;
    position: relative;
}
.archive-inner {
    max-width: 1200px;
    margin: 0 auto;
}
.archive-head {
    max-width: 680px;
    margin-bottom: 3rem;
}
.archive-title {
    font-family: var(--font-heading);
    font-style: italic;
    font-weight: 600;
    font-size: clamp(2rem, 4.5vw, 3.6rem);
    color: var(--silver);
    margin: 0 0 1rem 0;
    letter-spacing: 0.02em;
    line-height: 1.05;
}
.archive-lede {
    color: var(--silver);
    opacity: 0.8;
    max-width: 56ch;
    margin: 0;
}

.archive-waves {
    width: 100%;
    height: clamp(260px, 40vh, 420px);
    display: block;
    margin: 2rem 0 1.5rem;
    overflow: visible;
}
.archive-waves .waves { mix-blend-mode: screen; }
.archive-waves .wave {
    stroke-dasharray: 40 6;
    animation-name: drift;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
    transform-origin: 0 50%;
    transform: scaleY(var(--wave-scale, 1));
    transition: transform 0.6s ease;
}
.archive-waves .wave--1 { animation-duration: 13s; }
.archive-waves .wave--2 { animation-duration: 21s; }
.archive-waves .wave--3 { animation-duration: 8s;  }
.archive-waves .wave--4 { animation-duration: 34s; }
.archive-waves .wave--5 { animation-duration: 55s; }
.archive-waves .wave--6 { animation-duration: 89s; }

@keyframes drift { to { stroke-dashoffset: -800; } }

.archive-legend {
    list-style: none;
    padding: 0;
    margin: 2rem 0 0;
    display: flex;
    flex-wrap: wrap;
    gap: 1.8rem;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--silver);
}
.archive-legend .sw {
    display: inline-block;
    width: 18px;
    height: 2px;
    margin-right: 0.6em;
    vertical-align: 0.25em;
}

/* =====================================================
   6. COLOPHON
   ===================================================== */
.section--colophon {
    background: var(--bg-parchment);
    color: var(--copper);
    text-align: center;
    padding: 8vh 5vw 6vh;
    margin-top: -6vh;
    position: relative;
}
.rule {
    border: 0;
    height: 1px;
    background: var(--copper);
    max-width: 320px;
    margin: 1rem auto;
    opacity: 0.6;
    position: relative;
}
.rule--flourish::before,
.rule--flourish::after {
    content: "";
    position: absolute;
    top: -4px;
    width: 8px;
    height: 8px;
    border: 1px solid var(--copper);
    border-radius: 50%;
    background: var(--bg-parchment);
}
.rule--flourish::before { left: -4px; }
.rule--flourish::after  { right: -4px; }

.colophon-line {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    margin: 1.6rem 0;
    color: var(--copper);
    font-variant-caps: all-small-caps;
}
.colophon-line .dom { color: var(--ink); }
.colophon-line .sep { margin: 0 1em; color: var(--garnet); }

.colophon-sub {
    font-family: var(--font-heading);
    font-style: italic;
    font-size: 0.9rem;
    color: var(--copper);
    opacity: 0.8;
    margin: 0.5rem 0 0;
}

/* =====================================================
   Responsive tweaks
   ===================================================== */
@media (max-width: 820px) {
    .section--thread { padding: 12vh 6vw; min-height: 60vh; }
    .filigree-frame { inset: 4vh 4vw; width: calc(100% - 8vw); height: calc(100% - 8vh); }
    .thread--b .thread-body,
    .thread--c .thread-body { margin: 0; text-align: left; }
    .thread--b .thread-motif { margin-left: 0; }
    .hero-meta { flex-wrap: wrap; justify-content: center; }
    .archive-legend { gap: 1rem; }
}

@media (max-width: 520px) {
    .wordmark { letter-spacing: 0.12em; }
    .section--shear { min-height: 14vh; }
    .shear-wave { height: 40px; }
}
