/* ======================================================
   lune.dev — Brass & Vellum Instrument Aesthetic
   ====================================================== */

:root {
    --vellum: #f5ead0;
    --walnut: #2c2416;
    --ink: #3c3122;
    --sepia: #5a4e3a;
    --brass: #b8943e;
    --copper: #c47832;
    --bronze: #6b5a3e;
    --vermillion: #8b4513;
    --parchment: #ede2c8;
    --letterpress: #4a3f2e;
    --annotation: #8b7d6b;
    --highlight: #d4c5a0;
}

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

html {
    scroll-behavior: smooth;
    scroll-snap-type: y mandatory;
}

body {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.2vw, 1.1rem);
    line-height: 1.75;
    color: var(--ink);
    background-color: var(--vellum);
    cursor: crosshair;
    overflow-x: hidden;
}

/* ---- Noise Texture Overlay ---- */
#noise-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.04;
    filter: url(#noiseFilter);
}

/* ---- Navigation Dial ---- */
#nav-dial {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

#nav-dial-trigger {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--brass);
    cursor: pointer;
    box-shadow:
        inset 0 1px 0 rgba(245, 234, 208, 0.4),
        0 2px 4px rgba(44, 36, 22, 0.3),
        0 4px 8px rgba(44, 36, 22, 0.15);
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

#nav-dial-trigger:hover {
    transform: translateY(-1px);
    box-shadow:
        inset 0 1px 0 rgba(245, 234, 208, 0.5),
        0 3px 6px rgba(44, 36, 22, 0.35),
        0 6px 12px rgba(44, 36, 22, 0.2);
}

#nav-dial-trigger:active {
    transform: translateY(0);
    box-shadow:
        inset 0 2px 4px rgba(44, 36, 22, 0.3),
        inset 0 1px 0 rgba(44, 36, 22, 0.1);
}

#nav-dial-menu {
    position: absolute;
    top: -52px;
    right: -52px;
    width: 120px;
    height: 120px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

#nav-dial:hover #nav-dial-menu {
    opacity: 1;
    pointer-events: auto;
}

#nav-dial-menu svg {
    display: block;
}

.nav-tick {
    cursor: pointer;
    transition: stroke-width 0.15s ease;
}

.nav-tick:hover {
    stroke-width: 4;
}

.nav-tick.active {
    stroke-width: 4;
    stroke: var(--copper);
}

.nav-label {
    position: absolute;
    font-family: 'Cutive Mono', monospace;
    font-size: 0.65rem;
    color: var(--sepia);
    cursor: pointer;
}

.nav-label[data-plate='0'] { top: -2px; left: 50%; transform: translateX(-50%); }
.nav-label[data-plate='1'] { top: 50%; right: -2px; transform: translateY(-50%); }
.nav-label[data-plate='2'] { bottom: -2px; left: 50%; transform: translateX(-50%); }
.nav-label[data-plate='3'] { top: 50%; left: -2px; transform: translateY(-50%); }

/* ---- Plates (Full-Bleed Sections) ---- */
.plate {
    width: 100%;
    min-height: 100vh;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    scroll-snap-align: start;
    overflow: hidden;
}

.plate-1 {
    background-color: var(--vellum);
}

.plate-2 {
    background-color: var(--walnut);
    color: var(--vellum);
}

.plate-3 {
    background-color: var(--vellum);
}

.plate-4 {
    background-color: var(--walnut);
    color: var(--vellum);
}

.plate-content {
    width: 100%;
    max-width: 900px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    justify-content: center;
    position: relative;
}

/* ---- Plate Rules (Separators) ---- */
.plate-rule {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    z-index: 10;
}

.plate-rule::before,
.plate-rule::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--bronze);
}

.rule-ornament {
    margin: 0 12px;
    flex-shrink: 0;
}

/* ---- PLATE 1: The Face Plate ---- */
.instrument-dial {
    width: clamp(300px, 60vw, 500px);
    height: auto;
    margin-bottom: 2rem;
}

#lunar-hand-group {
    transform-origin: 300px 300px;
    animation: lunarRotate 28s linear infinite;
}

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

.logotype {
    font-family: 'Share Tech Mono', monospace;
    font-weight: 400;
    font-size: clamp(2rem, 5vw, 4.5rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink);
    text-shadow:
        0 -1px 0 #4a3f2e,
        0 1px 0 #d4c5a0;
    text-align: center;
}

.logotype-subtitle {
    font-family: 'Cutive Mono', monospace;
    font-size: 0.8rem;
    color: var(--annotation);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    margin-top: 0.5rem;
    transform: rotate(-1deg);
}

/* ---- PLATE 2: The Mechanism ---- */
.mechanism-layout {
    position: relative;
    max-width: 100%;
    width: 100%;
    padding: 2rem;
}

.gear-system {
    width: clamp(320px, 70vw, 700px);
    height: auto;
    margin: 0 auto;
    display: block;
}

.rotating-gear {
    animation: gearSpin 20s linear infinite;
}

.rotating-gear-reverse {
    animation: gearSpinReverse 13s linear infinite;
}

#gear-large {
    transform-origin: 400px 300px;
}

#gear-medium {
    transform-origin: 590px 175px;
}

#gear-small {
    transform-origin: 215px 425px;
}

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

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

.leader-line {
    stroke: var(--bronze);
    stroke-width: 0.5;
}

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

.mechanism-label {
    position: absolute;
    max-width: 220px;
    text-align: center;
}

.label-top {
    top: 5%;
    left: 50%;
    transform: translateX(-50%);
}

.label-right {
    top: 50%;
    right: 3%;
    transform: translateY(-50%);
    text-align: left;
}

.label-left {
    top: 50%;
    left: 3%;
    transform: translateY(-50%);
    text-align: right;
}

.label-bottom {
    bottom: 5%;
    left: 50%;
    transform: translateX(-50%);
}

.label-tag {
    display: block;
    font-family: 'Cutive Mono', monospace;
    font-size: 0.7rem;
    color: var(--brass);
    letter-spacing: 0.1em;
    margin-bottom: 0.25rem;
}

.label-text {
    display: block;
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(0.9rem, 1.5vw, 1.2rem);
    color: var(--vellum);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.label-desc {
    display: block;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    color: var(--parchment);
    opacity: 0.7;
    line-height: 1.5;
    margin-top: 0.3rem;
}

/* ---- PLATE 3: The Observation Log ---- */
.ledger-layout {
    max-width: 800px;
}

.compass-rose {
    margin-bottom: 1.5rem;
}

.plate-title {
    font-family: 'Share Tech Mono', monospace;
    font-weight: 400;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink);
    text-shadow:
        0 -1px 0 #4a3f2e,
        0 1px 0 #d4c5a0;
    margin-bottom: 2rem;
    text-align: center;
}

.ledger {
    width: 100%;
    max-width: 700px;
}

.ledger-header {
    display: flex;
    gap: 1rem;
    padding: 0.5rem 0;
    border-bottom: 2px solid var(--bronze);
    margin-bottom: 0.25rem;
}

.ledger-header .ledger-col {
    font-family: 'Cutive Mono', monospace;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #8b7d6b;
}

.ledger-entry {
    display: flex;
    gap: 1rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid rgba(107, 90, 62, 0.2);
    box-shadow: inset 0 1px 0 rgba(44, 36, 22, 0.08);
}

.ledger-col {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.85rem;
    color: var(--ink);
}

.col-date {
    flex: 0 0 120px;
}

.col-phase {
    flex: 1;
}

.col-illum {
    flex: 0 0 100px;
    text-align: right;
}

.col-status {
    flex: 0 0 120px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.col-status svg {
    flex-shrink: 0;
    vertical-align: middle;
}

.lunar-phases-row {
    margin-top: 2.5rem;
    width: 100%;
    max-width: 640px;
    overflow-x: auto;
}

.phase-circles {
    width: 100%;
    height: auto;
}

/* ---- PLATE 4: The Plate Mark (Colophon) ---- */
.colophon-layout {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.plate-mark {
    padding: 3rem 2.5rem;
    max-width: 500px;
    position: relative;
    box-shadow:
        0 0 0 1px rgba(184, 148, 62, 0.2),
        4px 4px 12px rgba(44, 36, 22, 0.3),
        8px 8px 24px rgba(44, 36, 22, 0.15);
}

.colophon-content {
    text-align: center;
}

.colophon-title {
    font-family: 'Share Tech Mono', monospace;
    font-size: 1.2rem;
    letter-spacing: 0.2em;
    color: var(--brass);
    margin-bottom: 1.5rem;
}

.colophon-rule {
    width: 60px;
    height: 1px;
    background: var(--bronze);
    margin: 1.5rem auto;
}

.colophon-text {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.85rem;
    color: var(--parchment);
    line-height: 1.8;
    margin-bottom: 1rem;
}

.colophon-highlight {
    color: var(--brass);
    font-weight: 600;
}

.colophon-date {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.9rem;
    letter-spacing: 0.15em;
    color: var(--brass);
    margin-top: 1rem;
}

.colophon-mark {
    margin-top: 1.5rem;
}

/* ---- SVG Path Drawing States ---- */
.svg-draw {
    opacity: 0;
}

.svg-draw.drawn {
    opacity: 1;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .mechanism-label {
        max-width: 150px;
    }

    .label-desc {
        display: none;
    }

    .ledger-header,
    .ledger-entry {
        gap: 0.5rem;
    }

    .col-date {
        flex: 0 0 90px;
    }

    .col-illum {
        flex: 0 0 70px;
    }

    .col-status {
        flex: 0 0 90px;
    }

    .plate-mark {
        margin: 1rem;
        padding: 2rem 1.5rem;
    }
}

@media (max-width: 480px) {
    .col-illum {
        display: none;
    }

    .mechanism-label {
        max-width: 100px;
        font-size: 0.7rem;
    }
}
