/* ============================================================
   valuator.dev - Precision Valuation Engine
   Isometric-analytical design language
   ============================================================ */

/* --- CSS Custom Properties (Design Tokens) --- */
:root {
    /* Backgrounds */
    --bg-primary: #0E1419;         /* Instrument Black */
    --bg-secondary: #1A242E;       /* Gauge Dark */
    --bg-tertiary: #2C3A4A;        /* Panel Slate */

    /* Text */
    --text-primary: #E8ECF0;       /* Readout White */
    --text-secondary: #8A9BB0;     /* Scale Gray */

    /* Accents */
    --accent-teal: #00B4A6;        /* Vernier Teal */
    --accent-amber: #D4A843;       /* Dial Amber */
    --accent-blue: #3D7EC7;        /* Micrometer Blue */

    /* Status */
    --error-red: #C74B4B;          /* Variance Red */
    --success-green: #4BC77A;      /* Precision Green */
    --muted: #5A6E82;

    /* Typography */
    --font-display: 'Space Grotesk', sans-serif;
    --font-body: 'IBM Plex Sans', sans-serif;
    --font-mono: 'IBM Plex Mono', monospace;

    /* Easing */
    --ease-mechanical: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

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

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

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1rem, 1.1vw, 1.15rem);
    line-height: 1.72;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Isometric Grid Background --- */
#iso-grid-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity 800ms ease-out;
}

#iso-grid-bg.visible {
    opacity: 0.03;
}

/* --- Station (Section) Base --- */
.station {
    position: relative;
    min-height: 100svh;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    padding: 4rem 2rem;
}

.station-inner {
    max-width: 1100px;
    width: 100%;
    margin: 0 auto;
    position: relative;
}

/* --- Typography --- */
.section-heading {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(1.8rem, 4vw, 4.5rem);
    letter-spacing: 0.02em;
    line-height: 1.1;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
}

.body-text {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1rem, 1.1vw, 1.15rem);
    line-height: 1.72;
    color: var(--text-primary);
    max-width: 62ch;
    margin-bottom: 1.2rem;
}

.mono-text {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: clamp(0.75rem, 0.85vw, 0.875rem);
    letter-spacing: 0.01em;
    color: var(--text-secondary);
}

/* ============================================================
   STATION I: CALIBRATION
   ============================================================ */
#station-calibration {
    min-height: 100svh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.calibration-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 900px;
}

/* Tick marks */
.tick-marks {
    position: absolute;
    opacity: 0;
    transition: opacity 600ms ease-out;
}

.tick-marks.animate-in {
    opacity: 1;
}

.tick-marks-horizontal {
    top: 50%;
    left: 0;
    right: 0;
    height: 20px;
    transform: translateY(-50%);
}

.tick-marks-horizontal svg {
    width: 100%;
    height: 20px;
    transform: scaleX(0);
    transition: transform 800ms var(--ease-mechanical) 400ms;
}

.tick-marks-horizontal.animate-in svg {
    transform: scaleX(1);
}

.tick-marks-vertical {
    top: 0;
    bottom: 0;
    left: 50%;
    width: 20px;
    transform: translateX(-50%);
}

.tick-marks-vertical svg {
    width: 20px;
    height: 100%;
    transform: scaleY(0);
    transition: transform 800ms var(--ease-mechanical) 600ms;
}

.tick-marks-vertical.animate-in svg {
    transform: scaleY(1);
}

/* Crosshair */
.crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 400ms ease-out 1200ms;
}

.crosshair.animate-in {
    opacity: 1;
}

/* Calibration title */
.calibration-title {
    font-family: var(--font-display);
    font-weight: 300;
    font-size: clamp(3rem, 8vw, 10rem);
    letter-spacing: 0.06em;
    line-height: 1.1;
    color: var(--text-primary);
    position: relative;
    z-index: 2;
    white-space: nowrap;
}

.title-char {
    display: inline-block;
    opacity: 0;
    transform: scale(1.02);
    transition: opacity 80ms ease-out, transform 120ms var(--ease-mechanical);
}

.title-char.visible {
    opacity: 1;
    transform: scale(1.0);
}

/* Calibration subtitle */
.calibration-subtitle {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: clamp(0.85rem, 1.2vw, 1.1rem);
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    margin-top: 1rem;
    opacity: 0;
    transition: opacity 600ms ease-out;
    position: relative;
    z-index: 2;
}

.calibration-subtitle.visible {
    opacity: 1;
}

/* Coordinate readouts */
.coordinate-readout {
    position: absolute;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity 400ms ease-out 2800ms;
    z-index: 2;
}

.coordinate-readout.animate-in {
    opacity: 0.5;
}

.readout-top-left {
    top: 0;
    left: 0;
}

.readout-bottom-right {
    bottom: 0;
    right: 0;
    text-align: right;
}

/* ============================================================
   STATION II: THE THESIS
   ============================================================ */
.thesis-block {
    width: 100%;
    max-width: 700px;
    margin: 0 auto;
    position: relative;
    transform-style: preserve-3d;
    perspective: 1000px;
}

.isometric-block {
    position: relative;
    transform-style: preserve-3d;
}

.iso-face {
    position: relative;
}

.iso-top {
    background: var(--bg-secondary);
    padding: 3rem;
    border: 1px solid var(--bg-tertiary);
    transform: perspective(800px) rotateX(5deg);
    position: relative;
    z-index: 2;
}

.iso-left {
    background: var(--bg-tertiary);
    padding: 2rem;
    border: 1px solid rgba(90, 110, 130, 0.3);
    display: inline-block;
    width: 48%;
    vertical-align: top;
}

.iso-right {
    background: var(--bg-primary);
    padding: 2rem;
    border: 1px solid var(--bg-tertiary);
    display: inline-block;
    width: 48%;
    vertical-align: top;
    margin-left: 2%;
}

.iso-face-content {
    position: relative;
}

/* Mini gauge in thesis block */
.mini-gauge {
    width: 100%;
    max-width: 120px;
    display: block;
    margin: 0 auto;
}

.mini-sparkline {
    width: 100%;
    max-width: 120px;
    display: block;
    margin: 0 auto;
}

/* ============================================================
   STATION III-V: CAPABILITY LAYERS
   ============================================================ */

/* Two-column layout */
.two-column {
    display: grid;
    grid-template-columns: 1fr 0.4fr;
    gap: 3rem;
    align-items: start;
}

.column-main {
    position: relative;
}

.column-annotations {
    position: relative;
    padding-top: 4rem;
}

/* Annotations */
.annotation {
    position: relative;
    margin-bottom: 2rem;
    padding-left: 1.5rem;
    opacity: 0;
    transform: translateX(10px);
    transition: opacity 500ms var(--ease-mechanical), transform 500ms var(--ease-mechanical);
}

.annotation.revealed {
    opacity: 1;
    transform: translateX(0);
}

.annotation-line {
    position: absolute;
    left: 0;
    top: 0;
    width: 1px;
    height: 100%;
    background: var(--muted);
    opacity: 0.4;
    transform: rotate(0deg);
}

.annotation-text {
    display: block;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Isometric bar chart */
.iso-bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 1.5rem;
    margin-top: 2.5rem;
    padding: 2rem 0;
    min-height: 280px;
}

.iso-bar {
    position: relative;
    width: 60px;
    height: 0;
    transform-style: preserve-3d;
    transition: height 800ms var(--ease-mechanical);
}

.iso-bar.revealed {
    height: var(--height);
}

.bar-face {
    position: absolute;
}

.bar-top {
    top: 0;
    left: 0;
    width: 60px;
    height: 30px;
    background: var(--bg-secondary);
    border: 1px solid var(--bg-tertiary);
    transform: translateY(-30px) skewX(-30deg);
}

.bar-left {
    top: 0;
    left: 0;
    width: 60px;
    height: 100%;
    background: var(--bg-tertiary);
    border: 1px solid rgba(90, 110, 130, 0.3);
}

.bar-right {
    top: 0;
    left: 30px;
    width: 60px;
    height: 100%;
    background: var(--bg-primary);
    border: 1px solid var(--bg-tertiary);
    transform: skewY(-30deg);
    transform-origin: top left;
}

.bar-label {
    position: absolute;
    bottom: -2rem;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    color: var(--text-secondary);
    font-size: 0.7rem;
}

/* Measurement marks decoration */
.measurement-marks {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 3rem;
    opacity: 0.4;
}

.ruler-marks {
    width: 200px;
    height: 20px;
}

.dimension-label {
    font-size: 0.7rem;
    color: var(--muted);
}

/* ============================================================
   STATION IV: GAUGE SYSTEM
   ============================================================ */
.gauge-system {
    display: flex;
    justify-content: center;
    margin: 3rem 0;
}

.gauge-rings {
    width: 100%;
    max-width: 300px;
}

.gauge-ring {
    transition: stroke-dashoffset 1500ms var(--ease-mechanical);
}

.gauge-ring-outer.animate {
    stroke-dashoffset: 245; /* ~70% fill */
}

.gauge-ring-middle.animate {
    stroke-dashoffset: 125; /* ~80% fill */
}

.gauge-ring-inner.animate {
    stroke-dashoffset: 44;  /* ~90% fill */
}

/* ============================================================
   STATION V: NETWORK
   ============================================================ */
.iso-network {
    margin: 2rem 0;
}

.network-svg {
    width: 100%;
    max-width: 500px;
    display: block;
    margin: 0 auto;
}

.network-node {
    opacity: 0;
    transition: opacity 400ms var(--ease-mechanical);
}

.iso-network.revealed .network-node {
    opacity: 1;
}

.iso-network.revealed .network-node:nth-child(n+10) {
    transition-delay: 0ms;
}

.iso-network.revealed .network-node:nth-child(n+11) {
    transition-delay: 200ms;
}

.iso-network.revealed .network-node:nth-child(n+12) {
    transition-delay: 300ms;
}

.iso-network.revealed .network-node:nth-child(n+13) {
    transition-delay: 400ms;
}

.iso-network.revealed .network-node:nth-child(n+14) {
    transition-delay: 100ms;
}

.iso-network.revealed .network-node:nth-child(n+15) {
    transition-delay: 200ms;
}

.iso-network.revealed .network-node:nth-child(n+16) {
    transition-delay: 300ms;
}

.iso-network.revealed line {
    stroke-dasharray: 300;
    stroke-dashoffset: 300;
    animation: drawLine 800ms var(--ease-mechanical) forwards;
}

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

/* ============================================================
   STATION VI: THE OUTPUT
   ============================================================ */
#station-output {
    min-height: 100svh;
}

.output-heading {
    text-align: center;
    margin-bottom: 3rem;
    color: var(--accent-amber);
}

.output-prism-container {
    display: flex;
    justify-content: center;
    perspective: 1200px;
    margin-bottom: 3rem;
}

.output-prism {
    position: relative;
    width: 360px;
    height: 360px;
    transform-style: preserve-3d;
    animation: rotateY 60s linear infinite;
}

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

.prism-face {
    position: absolute;
    width: 360px;
    height: 360px;
    display: flex;
    align-items: center;
    justify-content: center;
    backface-visibility: hidden;
}

.prism-top {
    background: var(--bg-secondary);
    border: 1px solid var(--bg-tertiary);
    transform: rotateX(90deg) translateZ(180px);
}

.prism-front {
    background: var(--bg-secondary);
    border: 1px solid var(--bg-tertiary);
    transform: translateZ(180px);
}

.prism-left {
    background: var(--bg-tertiary);
    border: 1px solid rgba(90, 110, 130, 0.3);
    transform: rotateY(-90deg) translateZ(180px);
}

.prism-right-side {
    background: var(--bg-primary);
    border: 1px solid var(--bg-tertiary);
    transform: rotateY(90deg) translateZ(180px);
}

.output-metric {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.output-gauge {
    width: 120px;
    height: 120px;
}

.output-gauge-fill {
    transition: stroke-dashoffset 1500ms var(--ease-mechanical);
}

.output-gauge-fill.animate {
    stroke-dashoffset: 31.4; /* ~90% fill */
}

.output-value {
    font-family: var(--font-mono);
    font-size: 1.8rem;
    font-weight: 500;
    color: var(--accent-amber);
    letter-spacing: 0.02em;
}

.output-label {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-secondary);
    letter-spacing: 0.06em;
}

.prism-label {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-secondary);
    letter-spacing: 0.08em;
}

/* Vernier scale */
.vernier-scale {
    max-width: 600px;
    margin: 2rem auto;
    opacity: 0.4;
}

.vernier-svg {
    width: 100%;
    height: 30px;
}

/* ============================================================
   STATION VII: THE CODA
   ============================================================ */
#station-coda {
    min-height: 60svh;
}

.coda-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2rem;
}

.coda-domain {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: clamp(0.85rem, 1vw, 1rem);
    color: var(--text-secondary);
    letter-spacing: 0.08em;
    opacity: 0;
    transition: opacity 800ms ease-out;
}

.coda-domain.visible {
    opacity: 0.6;
}

.coda-crosshair {
    opacity: 0;
    transition: opacity 800ms ease-out 200ms;
}

.coda-crosshair.visible {
    opacity: 0.4;
}

.coda-status {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 0.7rem;
    color: var(--text-secondary);
    letter-spacing: 0.1em;
    opacity: 0;
    transition: opacity 800ms ease-out 400ms;
}

.coda-status.visible {
    opacity: 0.3;
}

/* ============================================================
   SPARKLINE DIVIDERS
   ============================================================ */
.sparkline-divider {
    position: relative;
    z-index: 1;
    padding: 1rem 2rem;
    max-width: 1100px;
    margin: 0 auto;
}

.sparkline-divider svg {
    width: 100%;
    height: 6px;
    display: block;
}

.sparkline-path {
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    transition: stroke-dashoffset 1200ms var(--ease-mechanical);
}

.sparkline-divider.revealed .sparkline-path {
    stroke-dashoffset: 0;
}

/* ============================================================
   SCROLL REVEAL (base states)
   ============================================================ */
.station {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 600ms var(--ease-mechanical), transform 600ms var(--ease-mechanical);
}

.station.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* Station I has its own animation sequence */
#station-calibration {
    opacity: 1;
    transform: none;
}

/* ============================================================
   RESPONSIVE: Below 768px
   ============================================================ */
@media (max-width: 768px) {
    .two-column {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .column-annotations {
        padding-top: 1rem;
        padding-left: 1rem;
        border-left: 1px solid var(--bg-tertiary);
    }

    .annotation {
        padding-left: 1rem;
    }

    .iso-left, .iso-right {
        display: block;
        width: 100%;
        margin-left: 0;
    }

    .iso-bar-chart {
        gap: 0.75rem;
        overflow-x: auto;
        padding-bottom: 2.5rem;
    }

    .iso-bar {
        width: 45px;
        min-width: 45px;
    }

    .bar-top {
        width: 45px;
    }

    .bar-right {
        width: 45px;
    }

    .output-prism {
        width: 260px;
        height: 260px;
    }

    .prism-face {
        width: 260px;
        height: 260px;
    }

    .prism-top {
        transform: rotateX(90deg) translateZ(130px);
    }

    .prism-front {
        transform: translateZ(130px);
    }

    .prism-left {
        transform: rotateY(-90deg) translateZ(130px);
    }

    .prism-right-side {
        transform: rotateY(90deg) translateZ(130px);
    }

    .station {
        padding: 3rem 1.25rem;
    }

    .calibration-title {
        letter-spacing: 0.03em;
    }

    .gauge-rings {
        max-width: 240px;
    }

    .network-svg {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .calibration-title {
        font-size: clamp(2rem, 10vw, 4rem);
    }

    .section-heading {
        font-size: clamp(1.5rem, 6vw, 2.5rem);
    }

    .output-prism {
        width: 200px;
        height: 200px;
    }

    .prism-face {
        width: 200px;
        height: 200px;
    }

    .prism-top {
        transform: rotateX(90deg) translateZ(100px);
    }

    .prism-front {
        transform: translateZ(100px);
    }

    .prism-left {
        transform: rotateY(-90deg) translateZ(100px);
    }

    .prism-right-side {
        transform: rotateY(90deg) translateZ(100px);
    }

    .output-value {
        font-size: 1.3rem;
    }

    .output-gauge {
        width: 80px;
        height: 80px;
    }
}
