/* ============================================
   lunatic.dev — Styles
   A luxury command center on the lunar surface
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --void-bg: #0B0E2D;
    --primary-bg: #1A1B2F;
    --instrument-brass: #C9A84C;
    --polished-gold: #E8C84A;
    --pale-selenite: #D6D1C4;
    --ash-quartz: #8A8578;
    --dust-parchment: #E8DFC8;
    --copper-flare: #B86E3A;
}

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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    font-family: 'DM Sans', sans-serif;
    font-weight: 400;
    color: var(--pale-selenite);
    background: var(--void-bg);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Typography --- */
.section-heading {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-style: italic;
    font-size: clamp(3rem, 7vw, 6rem);
    letter-spacing: 0.04em;
    color: var(--instrument-brass);
    line-height: 1.1;
}

.section-subheading {
    font-family: 'DM Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.5vw, 1.25rem);
    line-height: 1.75;
    color: var(--ash-quartz);
    margin-top: 1rem;
}

/* --- Scroll Progress Indicator --- */
#scroll-progress {
    position: fixed;
    top: 0;
    right: 0;
    width: 2px;
    height: 0%;
    background: var(--instrument-brass);
    z-index: 1000;
    transition: height 0.1s linear;
}

/* --- HUD Overlay Readouts --- */
#hud-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
}

.hud-readout {
    position: absolute;
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.65rem, 0.9vw, 0.8rem);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ash-quartz);
    opacity: 0.7;
}

#hud-top-right {
    top: 2rem;
    right: 2rem;
}

#hud-bottom-left {
    bottom: 2rem;
    left: 2rem;
}

#hud-top-left {
    top: 2rem;
    left: 2rem;
}

#hud-bottom-right {
    bottom: 2rem;
    right: 2rem;
}

.hud-label {
    color: var(--instrument-brass);
}

.hud-value {
    color: var(--pale-selenite);
    margin-left: 0.5em;
}

/* --- Section Navigation --- */
#section-nav {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    z-index: 200;
}

.nav-ring {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    transition: transform 0.3s ease;
}

.nav-ring svg {
    display: block;
}

.nav-ring .nav-ring-fill {
    opacity: 0.2;
    transition: opacity 0.4s ease;
}

.nav-ring.active .nav-ring-fill {
    opacity: 1;
}

.nav-ring:hover {
    transform: scale(1.2);
}

.nav-ring circle:not(.nav-ring-fill) {
    transition: stroke 0.3s ease;
}

.nav-ring:hover circle:not(.nav-ring-fill) {
    stroke: var(--polished-gold);
}

/* --- Fullscreen Sections --- */
.fullscreen-section {
    position: relative;
    min-height: 100vh;
    width: 100%;
    overflow: hidden;
}

/* ===========================================
   SECTION 0: THE FIRMAMENT
   =========================================== */
#section-firmament {
    background: var(--void-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 4;
}

.firmament-void {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* The Moon */
#the-moon {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: radial-gradient(
        circle at 40% 35%,
        #F5F0E1 0%,
        #D6D1C4 30%,
        #B8B3A4 55%,
        #8A8578 75%,
        #6B665A 100%
    );
    box-shadow:
        0 0 60px rgba(232, 200, 74, 0.15),
        0 0 120px rgba(201, 168, 76, 0.08),
        inset -20px -10px 40px rgba(11, 14, 45, 0.4);
    transition: transform 1.5s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                width 1.5s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                height 1.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    z-index: 1;
}

/* Orbiting Text */
.orbit-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.orbit-ring-1 {
    width: 400px;
    height: 400px;
    animation: orbit-spin 120s linear infinite;
}

.orbit-ring-2 {
    width: 520px;
    height: 520px;
    animation: orbit-spin 100s linear infinite reverse;
}

.orbit-ring-3 {
    width: 640px;
    height: 640px;
    animation: orbit-spin 140s linear infinite;
}

.orbit-text {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%) rotate(0deg);
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.55rem, 0.8vw, 0.7rem);
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--instrument-brass);
    opacity: 0.5;
    white-space: nowrap;
}

@keyframes orbit-spin {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

.firmament-title {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-style: italic;
    font-size: clamp(4rem, 10vw, 9rem);
    letter-spacing: 0.04em;
    color: var(--instrument-brass);
    position: relative;
    z-index: 2;
    text-shadow: 0 0 80px rgba(201, 168, 76, 0.2);
}

.firmament-subtitle {
    font-family: 'DM Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(0.9rem, 1.4vw, 1.2rem);
    line-height: 1.75;
    color: var(--ash-quartz);
    position: relative;
    z-index: 2;
    margin-top: 1rem;
    letter-spacing: 0.08em;
}

/* Filigree Corners */
.filigree {
    position: absolute;
    z-index: 3;
    opacity: 0;
    transition: opacity 1s ease;
}

.filigree.visible {
    opacity: 1;
}

.filigree-top-left { top: 2rem; left: 2rem; }
.filigree-top-right { top: 2rem; right: 2rem; }
.filigree-bottom-left { bottom: 2rem; left: 2rem; }
.filigree-bottom-right { bottom: 2rem; right: 2rem; }

.filigree-path {
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    transition: stroke-dashoffset 2.5s ease;
}

.filigree.visible .filigree-path {
    stroke-dashoffset: 0;
}

/* ===========================================
   SECTION 1: THE CRATER MAP
   =========================================== */
#section-cratermap {
    background: var(--primary-bg);
    z-index: 3;
    padding: 8vh 4vw;
    display: flex;
    align-items: center;
    justify-content: center;
}

.crater-parallax-layer {
    width: 100%;
    max-width: 1200px;
    text-align: center;
}

.hex-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2.5rem;
    margin-top: 4rem;
    padding: 0 2rem;
}

.hex-cell {
    position: relative;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: rgba(201, 168, 76, 0.04);
    border: none;
    aspect-ratio: 1 / 1.1547;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                background 0.3s ease;
    cursor: default;
    animation: hex-float 6s ease-in-out infinite;
}

.hex-cell:nth-child(1) { animation-delay: 0s; }
.hex-cell:nth-child(2) { animation-delay: -1s; }
.hex-cell:nth-child(3) { animation-delay: -2s; }
.hex-cell:nth-child(4) { animation-delay: -3s; }
.hex-cell:nth-child(5) { animation-delay: -4s; }
.hex-cell:nth-child(6) { animation-delay: -5s; }

@keyframes hex-float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-5px); }
}

.hex-cell:hover {
    background: rgba(201, 168, 76, 0.08);
}

.hex-content {
    padding: 25%;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.hex-text h3 {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-style: italic;
    font-size: clamp(1rem, 1.8vw, 1.4rem);
    color: var(--instrument-brass);
    margin-bottom: 0.6rem;
}

.hex-text p {
    font-family: 'DM Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(0.7rem, 1vw, 0.85rem);
    line-height: 1.6;
    color: var(--pale-selenite);
    opacity: 0.8;
}

.hex-svg,
.hex-filigree {
    padding: 15%;
}

.crater-svg,
.filigree-pattern-svg {
    width: 100%;
    height: 100%;
}

/* ===========================================
   SECTION 2: THE INSTRUMENT PANEL
   =========================================== */
#section-instruments {
    background: var(--void-bg);
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.instrument-layer {
    position: relative;
    width: 100%;
    max-width: 900px;
    padding: 8vh 4vw;
    margin: 0 auto;
}

/* Reticles */
.reticle {
    position: absolute;
    pointer-events: none;
}

.reticle-main {
    width: 80vmin;
    height: 80vmin;
    max-width: 600px;
    max-height: 600px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 0.5s ease;
}

.reticle-secondary {
    width: 40vmin;
    height: 40vmin;
    max-width: 300px;
    max-height: 300px;
    top: 10%;
    right: -5%;
    opacity: 0;
    transition: opacity 0.5s ease;
}

#section-instruments.hud-active .reticle {
    opacity: 1;
}

/* Reticle arc drawing animation */
.reticle-arc {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 0.8s ease;
}

#section-instruments.hud-active .reticle-outer {
    stroke-dashoffset: 0;
    transition-duration: 0.8s;
    transition-delay: 0s;
}

#section-instruments.hud-active .reticle-mid {
    stroke-dashoffset: 0;
    transition-duration: 0.6s;
    transition-delay: 0.2s;
}

#section-instruments.hud-active .reticle-inner {
    stroke-dashoffset: 0;
    transition-duration: 0.6s;
    transition-delay: 0.4s;
}

/* Tick marks */
.reticle-tick {
    opacity: 0;
    transition: opacity 0.3s ease;
}

#section-instruments.hud-active .reticle-tick {
    opacity: 1;
    transition-delay: 0.4s;
}

/* Reticle rotation */
#section-instruments.hud-active .reticle-main {
    animation: reticle-rotate-cw 120s linear infinite;
}

#section-instruments.hud-active .reticle-secondary {
    animation: reticle-rotate-ccw 90s linear infinite;
}

@keyframes reticle-rotate-cw {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

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

/* Scan Line */
.scan-line {
    position: absolute;
    top: 0;
    left: 5%;
    right: 5%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--instrument-brass), transparent);
    opacity: 0;
    transform: translateY(-100%);
    pointer-events: none;
}

#section-instruments.hud-active .scan-line {
    animation: scan-sweep 4s ease-in-out 0.6s infinite;
}

@keyframes scan-sweep {
    0% { top: 0%; opacity: 0; }
    5% { opacity: 0.6; }
    95% { opacity: 0.6; }
    100% { top: 100%; opacity: 0; }
}

/* Instrument Content */
.instrument-content {
    position: relative;
    z-index: 5;
    max-width: 700px;
    margin: 0 auto;
}

.instrument-content .section-heading {
    margin-bottom: 2rem;
}

.instrument-body {
    font-family: 'DM Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.5vw, 1.25rem);
    line-height: 1.75;
    color: var(--pale-selenite);
    margin-bottom: 1.5rem;
}

.instrument-data-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(201, 168, 76, 0.15);
}

.data-label {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.65rem, 0.9vw, 0.8rem);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ash-quartz);
}

.data-value {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.65rem, 0.9vw, 0.8rem);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--instrument-brass);
    opacity: 0;
    transition: opacity 0.5s ease;
}

#section-instruments.hud-active .data-value {
    opacity: 1;
    transition-delay: 0.6s;
}

/* ===========================================
   SECTION 3: THE REGOLITH
   =========================================== */
#section-regolith {
    background: var(--dust-parchment);
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    position: relative;
}

.grain-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0.06;
}

.regolith-content {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 4rem;
    max-width: 1000px;
    padding: 8vh 4vw;
    position: relative;
    z-index: 2;
}

.regolith-text {
    max-width: 500px;
    text-align: center;
}

.regolith-heading {
    color: var(--primary-bg);
    margin-bottom: 2rem;
}

.regolith-body {
    font-family: 'DM Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.5vw, 1.15rem);
    line-height: 1.8;
    color: var(--primary-bg);
    margin-bottom: 1.5rem;
    opacity: 0.85;
}

.regolith-coda {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-style: italic;
    font-size: clamp(1.1rem, 1.6vw, 1.3rem);
    color: var(--copper-flare);
    opacity: 1;
    line-height: 1.6;
    margin-top: 2rem;
}

/* Crystal Diagrams */
.crystal-diagram {
    flex-shrink: 0;
    width: 120px;
    opacity: 0.7;
    transition: opacity 0.8s ease;
}

.crystal-left {
    margin-top: 6rem;
}

.crystal-right {
    margin-top: 4rem;
}

/* ===========================================
   DATA VALUE TYPEWRITER EFFECT
   =========================================== */
.data-value.typewriter {
    overflow: hidden;
    border-right: 1px solid var(--instrument-brass);
    white-space: nowrap;
    animation: blink-caret 0.75s step-end infinite;
}

.data-value.typewriter-done {
    border-right: none;
    animation: none;
}

@keyframes blink-caret {
    from, to { border-color: transparent; }
    50% { border-color: var(--instrument-brass); }
}

/* ===========================================
   RESPONSIVE
   =========================================== */
@media (max-width: 900px) {
    .hex-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }

    .regolith-content {
        flex-direction: column;
        align-items: center;
    }

    .crystal-diagram {
        width: 80px;
        margin-top: 0 !important;
    }

    .crystal-left {
        order: -1;
    }

    .orbit-ring-1 { width: 280px; height: 280px; }
    .orbit-ring-2 { width: 360px; height: 360px; }
    .orbit-ring-3 { width: 440px; height: 440px; }

    .firmament-title {
        font-size: clamp(3rem, 12vw, 6rem);
    }

    #hud-top-left,
    #hud-bottom-right {
        display: none;
    }
}

@media (max-width: 600px) {
    .hex-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        max-width: 300px;
        margin-left: auto;
        margin-right: auto;
    }

    .orbit-ring {
        display: none;
    }

    .reticle-secondary {
        display: none;
    }

    .regolith-content {
        gap: 2rem;
    }

    #section-nav {
        bottom: 1rem;
        right: 1rem;
        gap: 0.6rem;
    }

    .hud-readout {
        font-size: 0.6rem;
    }
}
