/* luminous.day --- a silent observatory for the passage of light
 * forensic-mineral-meditative chrome on charcoal
 *
 * Modular scale: 8 -> 13 -> 21 -> 34 -> 55 -> 89 -> 144 -> 233 (golden 1.618)
 * Master heartbeat: 6s breath cycle (3s inhale, 3s exhale)
 */

:root {
    /* Chrome-metallic palette */
    --abyssal-graphite: #0E0F11;
    --gunmetal-substrate: #1A1D21;
    --brushed-nickel: #5A6068;
    --machined-aluminum: #8A929C;
    --polished-steel: #C8CCD0;
    --cold-platinum: #E8EAEC;
    --titanium-oxide: #7A8A9A;
    --instrument-grey: #9DA4AC;

    /* Modular spacing, golden-seeded */
    --space-1: 8px;
    --space-2: 13px;
    --space-3: 21px;
    --space-4: 34px;
    --space-5: 55px;
    --space-6: 89px;
    --space-7: 144px;
    --space-8: 233px;

    /* Typography */
    --font-display: "Jost", "Futura", "Inter", system-ui, sans-serif;
    --font-headline: "Sora", "Inter", system-ui, sans-serif;
    --font-body: "Inter", system-ui, sans-serif;
    --font-mono: "JetBrains Mono", "Menlo", monospace;

    /* Heartbeat clock */
    --heartbeat: 6s;
    --heartbeat-half: 3s;
    --heartbeat-double: 12s;
    --heartbeat-quad: 24s;

    /* Easing (forensic, not bouncy) */
    --ease-instrument: cubic-bezier(0.77, 0, 0.175, 1);

    /* Hairline */
    --hairline-x: 38.2%;
    --left-rail: 12.5%;
}

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

html {
    scroll-behavior: smooth;
    background-color: var(--abyssal-graphite);
}

body {
    font-family: var(--font-body);
    font-size: 1.0625rem;
    line-height: 1.7;
    color: var(--polished-steel);
    background-color: var(--abyssal-graphite);
    overflow-x: hidden;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "kern" 1, "liga" 1;
}

/* ----- Grain overlay canvas (top of stack, mix-blend overlay) ----- */
#grain-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 9999;
    mix-blend-mode: overlay;
    opacity: 0.18;
}

/* ----- The vertical hairline (38.2% from left) ----- */
.vertical-hairline {
    position: fixed;
    top: 0;
    bottom: 0;
    left: var(--hairline-x);
    width: 1px;
    background-color: var(--polished-steel);
    opacity: 0.32;
    z-index: 5;
    pointer-events: none;
}

/* ----- Header (12px sliver) ----- */
.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: linear-gradient(180deg, rgba(14, 15, 17, 0.96) 0%, rgba(14, 15, 17, 0.6) 80%, rgba(14, 15, 17, 0) 100%);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: opacity var(--heartbeat-half) var(--ease-instrument);
}

.header-inner {
    height: 36px;
    padding: 0 var(--space-4);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    letter-spacing: 0.18em;
    color: var(--instrument-grey);
    text-transform: uppercase;
}

.monogram {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    color: var(--polished-steel);
    text-transform: uppercase;
}

.mono-dot {
    color: var(--cold-platinum);
    font-weight: 800;
    transform: translateY(-2px);
    margin: 0 1px;
}

.header-readout {
    display: inline-flex;
    align-items: baseline;
    gap: var(--space-2);
}

.readout-label {
    font-size: 0.625rem;
    letter-spacing: 0.22em;
    color: var(--brushed-nickel);
}

.readout-value {
    color: var(--cold-platinum);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.06em;
}

.header-hairline {
    height: 1px;
    background-color: var(--polished-steel);
    opacity: 0.18;
}

/* ----- Plates: each is a full-viewport composition ----- */
main#stage {
    position: relative;
    z-index: 1;
}

.plate {
    position: relative;
    min-height: 100vh;
    width: 100%;
    background-color: var(--abyssal-graphite);
    overflow: hidden;
    transition: background-color var(--heartbeat-double) var(--ease-instrument);
}

.plate-substrate {
    background-color: var(--gunmetal-substrate);
}

.plate-grid {
    position: relative;
    width: 100%;
    min-height: 100vh;
    display: grid;
    grid-template-columns: var(--hairline-x) 1fr;
    align-items: center;
}

.plate-form {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.plate-svg,
.hero-svg {
    width: clamp(36vmin, 48vmin, 720px);
    height: clamp(36vmin, 48vmin, 720px);
    display: block;
    overflow: visible;
    transition: transform var(--heartbeat-quad) linear;
}

.plate-text {
    position: relative;
    padding-left: var(--space-5);
    padding-right: var(--space-6);
    max-width: 56ch;
    opacity: 0;
    transform: translateY(34px);
    transition:
        opacity var(--heartbeat) var(--ease-instrument),
        transform var(--heartbeat) var(--ease-instrument);
}

.plate.in-view .plate-text {
    opacity: 1;
    transform: translateY(0);
}

.plate-numeral {
    display: block;
    font-family: var(--font-headline);
    font-weight: 500;
    font-size: 1.125rem;
    letter-spacing: -0.01em;
    color: var(--brushed-nickel);
    margin-bottom: var(--space-3);
    font-variant-numeric: tabular-nums;
}

.plate-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2.5rem, 4.8vw, 4.236rem);
    line-height: 1.05;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--polished-steel);
    margin-bottom: var(--space-4);
}

.plate-prose {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 1.0625rem;
    line-height: 1.7;
    color: var(--machined-aluminum);
    margin-bottom: var(--space-4);
}

.plate-tick {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 0.875rem;
    letter-spacing: 0.06em;
    color: var(--instrument-grey);
    font-variant-numeric: tabular-nums;
    padding-top: var(--space-2);
    border-top: 1px solid rgba(200, 204, 208, 0.18);
    padding-left: var(--space-2);
    padding-right: var(--space-2);
}

/* ----- Hero plate (130vh, dominant) ----- */
.hero {
    min-height: 130vh;
    padding-top: 36px;
}

.hero .plate-grid {
    min-height: calc(130vh - 36px);
}

.hero-text {
    opacity: 1;
    transform: none;
}

.hero-glyph {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: clamp(3.5rem, 7vw, 6.854rem);
    line-height: 0.95;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--cold-platinum);
    margin-bottom: var(--space-3);
    text-shadow: 0 0 1px rgba(232, 234, 236, 0.18);
}

.hero-subline {
    font-family: var(--font-headline);
    font-weight: 400;
    font-size: 1.125rem;
    line-height: 1.55;
    letter-spacing: 0.005em;
    color: var(--machined-aluminum);
    margin-bottom: var(--space-5);
    max-width: 38ch;
}

.hero-coords {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    letter-spacing: 0.06em;
    color: var(--instrument-grey);
    font-variant-numeric: tabular-nums;
    display: inline-flex;
    gap: var(--space-2);
    align-items: baseline;
}

.coord-key {
    color: var(--brushed-nickel);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.18em;
}

.coord-val {
    color: var(--polished-steel);
}

.coord-sep {
    color: var(--brushed-nickel);
}

.hero-scroll-indicator {
    position: absolute;
    bottom: var(--space-5);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    font-family: var(--font-mono);
    font-size: 0.625rem;
    letter-spacing: 0.32em;
    color: var(--brushed-nickel);
    text-transform: uppercase;
    animation: scrollPulse var(--heartbeat) ease-in-out infinite;
}

.scroll-line {
    width: 1px;
    height: 34px;
    background: linear-gradient(180deg, var(--polished-steel) 0%, transparent 100%);
}

@keyframes scrollPulse {
    0%, 100% { opacity: 0.42; }
    50% { opacity: 0.92; }
}

/* ----- Final plate ----- */
.plate-final {
    background-color: var(--gunmetal-substrate);
}

.final-readout {
    margin-top: var(--space-4);
    padding-top: var(--space-3);
    border-top: 1px solid rgba(200, 204, 208, 0.22);
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.readout-key {
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    letter-spacing: 0.22em;
    color: var(--brushed-nickel);
    text-transform: uppercase;
}

.readout-digit {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: clamp(2rem, 3.6vw, 2.618rem);
    color: var(--cold-platinum);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.04em;
    text-shadow: 0 0 14px rgba(232, 234, 236, 0.18);
    animation: digitBreathe var(--heartbeat) ease-in-out infinite;
}

@keyframes digitBreathe {
    0%, 100% { opacity: 0.86; }
    50% { opacity: 1; }
}

/* ----- SVG primitives (paths and shapes set in JS) ----- */
.primitive-group {
    transform-origin: 50% 50%;
    transform-box: fill-box;
    animation: slowRotate var(--heartbeat-quad) linear infinite;
}

.plate[data-primitive="square"] .primitive-group { animation-duration: 48s; }
.plate[data-primitive="triangle"] .primitive-group { animation-duration: 36s; }
.plate[data-primitive="parallelogram"] .primitive-group { animation-duration: 24s; }
.plate[data-primitive="circle"] .primitive-group { animation-duration: 96s; }
.plate[data-primitive="hexagon"] .primitive-group { animation-duration: 60s; }
.plate[data-primitive="ellipse"] .primitive-group { animation-duration: 18s; }
.plate[data-primitive="vesica"] .primitive-group { animation-duration: 72s; }

@keyframes slowRotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

#heroDiscGroup {
    transform-origin: 50% 50%;
    transform-box: fill-box;
    animation: heroBreathe var(--heartbeat) ease-in-out infinite, slowRotate 144s linear infinite;
}

@keyframes heroBreathe {
    0%, 100% { filter: brightness(0.96); }
    50% { filter: brightness(1.06); }
}

.crosshair-group {
    opacity: 0.62;
}

.crosshair-line {
    stroke: var(--polished-steel);
    stroke-width: 1;
    stroke-linecap: butt;
    fill: none;
    vector-effect: non-scaling-stroke;
}

.crosshair-dot {
    fill: var(--cold-platinum);
}

.highlight-streak {
    fill: url(#streakGradient);
    opacity: 0.7;
    mix-blend-mode: screen;
}

.disc-bevel {
    fill: url(#bevelGradient);
}

/* ----- Footer ----- */
.site-footer {
    position: relative;
    z-index: 50;
    width: 100%;
    padding: var(--space-5) var(--space-4) var(--space-4);
    border-top: 1px solid rgba(200, 204, 208, 0.18);
    background-color: var(--abyssal-graphite);
}

.footer-line {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.875rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--brushed-nickel);
    text-align: center;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: var(--space-2);
}

.footer-text {
    color: var(--machined-aluminum);
}

.footer-sep {
    color: var(--brushed-nickel);
    opacity: 0.6;
}

.footer-timestamp {
    font-family: var(--font-mono);
    font-weight: 400;
    color: var(--instrument-grey);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.06em;
    text-transform: none;
}

/* ----- Responsive: smaller viewports collapse the hairline grid ----- */
@media (max-width: 880px) {
    :root {
        --hairline-x: 50%;
    }

    .vertical-hairline {
        display: none;
    }

    .plate-grid {
        grid-template-columns: 1fr;
        grid-template-rows: 60vh 1fr;
        gap: var(--space-3);
    }

    .plate-form {
        height: 60vh;
    }

    .plate-text {
        padding-left: var(--space-4);
        padding-right: var(--space-4);
        padding-bottom: var(--space-5);
    }

    .hero {
        min-height: 130vh;
    }

    .hero .plate-grid {
        grid-template-rows: 55vh 1fr;
    }

    .hero-glyph {
        font-size: clamp(3rem, 12vw, 4.5rem);
    }
}

@media (max-width: 520px) {
    .header-inner {
        padding: 0 var(--space-2);
        font-size: 0.625rem;
    }

    .readout-label {
        display: none;
    }

    .plate-text {
        padding-left: var(--space-3);
        padding-right: var(--space-3);
    }

    .plate-title {
        font-size: clamp(2rem, 8vw, 3rem);
    }
}

/* ----- Reduced motion: freeze rotations and grain ----- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }

    #grain-canvas {
        opacity: 0.12;
    }

    .plate-text {
        opacity: 1;
        transform: none;
    }
}
