/* longitude.quest — Navigational Chronometer Instrument */
/* Palette: Brass & Vellum Duotone
   #1a0f07 #2c1810 #f5e6c8 #e8d5b0 #daa520 #b8860b #8b6914 #6b1d1d #5c4033 #3d2b1f */

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

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

body {
    background: #1a0f07;
    color: #3d2b1f;
    font-family: 'Lora', serif;
    overflow-x: hidden;
    min-height: 100vh;
}

/* ===== BEZEL FRAME ===== */
#bezel-frame {
    position: fixed;
    inset: 0;
    z-index: 100;
    pointer-events: none;
}

.bezel-top,
.bezel-bottom {
    position: absolute;
    left: 0;
    right: 0;
    height: 24px;
    background: repeating-linear-gradient(135deg, #daa520, #b8860b 2px, #8b6914 4px, #b8860b 6px, #daa520 8px);
}

.bezel-top {
    top: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bezel-bottom {
    bottom: 0;
}

.bezel-left,
.bezel-right {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 24px;
    background: repeating-linear-gradient(135deg, #daa520, #b8860b 2px, #8b6914 4px, #b8860b 6px, #daa520 8px);
}

.bezel-left {
    left: 0;
}

.bezel-right {
    right: 0;
}

.bezel-title {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: 0.7rem;
    letter-spacing: 0.3em;
    color: #1a0f07;
    text-transform: uppercase;
    text-shadow: 0 1px 0 rgba(218, 165, 32, 0.5);
}

/* Corner ornaments */
.corner {
    position: absolute;
    z-index: 101;
    width: 60px;
    height: 60px;
}

.corner-tl { top: 0; left: 0; }
.corner-tr { top: 0; right: 0; }
.corner-bl { bottom: 0; left: 0; }
.corner-br { bottom: 0; right: 0; }

.corner svg {
    display: block;
}

/* ===== MERIDIAN SPINE ===== */
#meridian-spine {
    position: fixed;
    top: 24px;
    bottom: 24px;
    left: 50%;
    width: 1px;
    background: #8b6914;
    box-shadow: 0 0 6px rgba(218, 165, 32, 0.3);
    z-index: 50;
    opacity: 0;
    transition: opacity 600ms ease;
}

#meridian-spine.visible {
    opacity: 1;
}

/* Spine markers */
#spine-markers {
    position: fixed;
    top: 24px;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    width: 12px;
    z-index: 51;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
    align-items: center;
}

.spine-marker {
    width: 8px;
    height: 8px;
    border: 1px solid #8b6914;
    transform: rotate(45deg);
    background: transparent;
    transition: background 300ms ease, box-shadow 300ms ease;
}

.spine-marker.active {
    background: #daa520;
    box-shadow: 0 0 6px rgba(218, 165, 32, 0.5);
}

/* ===== CONTENT VIEWPORT ===== */
#content-viewport {
    position: relative;
    padding: 100vh 0;
    z-index: 10;
}

/* ===== INSTRUMENT PANELS ===== */
.instrument-panel {
    position: relative;
    width: 55%;
    max-width: 680px;
    min-height: 300px;
    margin: 15vh auto;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 500ms ease-out, transform 500ms ease-out;
}

.instrument-panel.visible {
    opacity: 1;
    transform: translateY(0);
}

.instrument-panel.panel-left {
    margin-left: 8%;
    margin-right: auto;
    transform: translateX(-30px);
}

.instrument-panel.panel-left.visible {
    transform: translateX(0);
}

.instrument-panel.panel-right {
    margin-left: auto;
    margin-right: 8%;
    transform: translateX(30px);
}

.instrument-panel.panel-right.visible {
    transform: translateX(0);
}

.instrument-panel.panel-center {
    margin-left: auto;
    margin-right: auto;
}

.panel-inner {
    background: #f5e6c8;
    background-image:
        radial-gradient(ellipse at 10% 10%, rgba(26, 15, 7, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 90% 90%, rgba(26, 15, 7, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(26, 15, 7, 0.03) 0%, transparent 80%);
    border: 2px solid #b8860b;
    border-radius: 12px;
    padding: clamp(2rem, 4vw, 3.5rem);
    box-shadow:
        0 4px 16px rgba(26, 15, 7, 0.3),
        inset 0 1px 0 rgba(245, 230, 200, 0.5),
        inset 0 -2px 4px rgba(26, 15, 7, 0.15);
    position: relative;
    overflow: hidden;
}

/* Subtle noise texture via pseudo-element */
.panel-inner::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='256' height='256' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
    background-size: 256px 256px;
    pointer-events: none;
    border-radius: 12px;
}

/* ===== TYPOGRAPHY ===== */
.chapter-title {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: clamp(2rem, 5vw, 4.5rem);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: #2c1810;
    line-height: 1.15;
    margin-bottom: 1rem;
    text-align: center;
}

h2.chapter-title {
    font-size: clamp(1.5rem, 3.5vw, 2.8rem);
    margin-bottom: 0.75rem;
}

.coordinates {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.75rem, 1.2vw, 0.95rem);
    letter-spacing: 0.08em;
    color: #5c4033;
    text-align: center;
    margin-bottom: 0.75rem;
}

.subtitle {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 500;
    font-size: clamp(0.7rem, 1vw, 0.85rem);
    letter-spacing: 0.12em;
    color: #8b6914;
    text-align: center;
    text-transform: uppercase;
    margin-bottom: 1.5rem;
}

.body-text {
    font-family: 'Lora', serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.25rem);
    line-height: 1.75;
    color: #3d2b1f;
    max-width: 60ch;
    margin: 0 auto 1.5em;
    text-indent: 1.5em;
}

.body-text:first-of-type {
    text-indent: 0;
}

.accent-text {
    color: #6b1d1d;
    font-weight: 600;
}

/* ===== CRYSTALLINE DIVIDERS ===== */
.crystalline-divider {
    text-align: center;
    margin: 1.5rem 0;
    opacity: 0.7;
}

/* ===== BRASS DIAL STAT ===== */
.brass-dial-stat {
    position: relative;
    width: 180px;
    height: 180px;
    margin: 0 auto 1.5rem;
}

.brass-dial-stat .dial-frame {
    display: block;
}

.brass-dial-stat .dial-content {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.dial-value {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: 1.8rem;
    color: #daa520;
    letter-spacing: 0.05em;
}

.dial-label {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 0.7rem;
    color: #b8860b;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-top: 0.3rem;
}

/* ===== ENGRAVINGS ===== */
.engraving {
    text-align: center;
    margin: 1.5rem auto;
    transition: filter 300ms ease;
}

.engraving:hover {
    filter: sepia(0.1) brightness(1.05);
}

.engraving svg {
    display: inline-block;
    max-width: 100%;
    height: auto;
}

.engrave-line {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 2s ease;
}

.engrave-line.drawn {
    stroke-dashoffset: 0;
}

/* ===== CHRONOMETER DIAL ===== */
#chronometer-dial {
    position: fixed;
    bottom: 40px;
    right: 40px;
    width: 200px;
    height: 200px;
    z-index: 200;
    cursor: pointer;
    opacity: 0;
    transition: opacity 500ms ease;
}

#chronometer-dial.visible {
    opacity: 1;
}

#chronometer-dial svg {
    display: block;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.5));
}

.dial-ring-outer,
.dial-ring-inner {
    opacity: 0;
    transition: opacity 300ms ease;
}

#chronometer-dial.assembled .dial-ring-outer,
#chronometer-dial.assembled .dial-ring-inner {
    opacity: 1;
}

.dial-tick {
    cursor: pointer;
    transition: filter 200ms ease;
}

.dial-tick:hover .tick-glow {
    opacity: 1;
}

.tick-glow {
    opacity: 0;
    transition: opacity 200ms ease;
}

.dial-tick-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 8px;
    fill: #b8860b;
    text-anchor: middle;
    dominant-baseline: middle;
    pointer-events: none;
}

#dial-hand {
    transform-origin: 100px 100px;
    transition: transform 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ===== MERIDIAN PULSE ===== */
@keyframes meridianPulse {
    0%, 100% { box-shadow: 0 0 6px rgba(218, 165, 32, 0.3); }
    50% { box-shadow: 0 0 12px rgba(218, 165, 32, 0.6); }
}

#meridian-spine.pulse {
    animation: meridianPulse 800ms ease;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .bezel-top, .bezel-bottom { height: 16px; }
    .bezel-left, .bezel-right { width: 16px; }
    .corner { width: 40px; height: 40px; }
    .corner svg { width: 40px; height: 40px; }

    .instrument-panel {
        width: 85%;
        margin-left: auto !important;
        margin-right: auto !important;
    }

    .instrument-panel.panel-left,
    .instrument-panel.panel-right {
        transform: translateY(20px);
    }

    .instrument-panel.panel-left.visible,
    .instrument-panel.panel-right.visible {
        transform: translateY(0);
    }

    #chronometer-dial {
        width: 120px;
        height: 120px;
        bottom: 24px;
        right: 24px;
    }

    #meridian-spine {
        display: none;
    }

    #spine-markers {
        display: none;
    }
}

@media (max-width: 480px) {
    .instrument-panel {
        width: 92%;
    }

    .panel-inner {
        padding: 1.5rem;
    }

    #chronometer-dial {
        width: 90px;
        height: 90px;
        bottom: 20px;
        right: 20px;
    }
}
