/* === RESET & BASE === */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --deep-chassis: #0f0e0b;
    --panel-surface: #1a1710;
    --warm-amber: #c29b48;
    --cool-phosphor: #48a89c;
    --hot-signal: #d4723c;
    --muted-label: #8a7d65;
    --narrative-text: #d8ceb8;
    --bright-data: #7ec492;
    --border-default: #3a3427;
    --candle-intensity: 0.08;
}

html { font-size: 16px; }

body {
    background: var(--deep-chassis);
    color: var(--narrative-text);
    font-family: 'Source Serif 4', Georgia, serif;
    overflow-x: hidden;
    min-height: 100vh;
}

/* === BOOT SEQUENCE === */
#boot-overlay {
    position: fixed;
    inset: 0;
    background: var(--deep-chassis);
    z-index: 1000;
    pointer-events: none;
    transition: opacity 0.6s ease-out;
}
#boot-overlay.fade-out { opacity: 0; }

#boot-ring {
    position: fixed;
    top: 50%;
    left: 50%;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--warm-amber), transparent);
    transform: translate(-50%, -50%) scale(0);
    z-index: 1001;
    pointer-events: none;
    transition: transform 1.2s ease-out, opacity 0.8s ease-out 0.8s;
}
#boot-ring.expand {
    transform: translate(-50%, -50%) scale(200);
    opacity: 0;
}

/* === TUNING DIAL === */
#tuning-dial {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    z-index: 100;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.6s ease-out;
}
#tuning-dial.visible { opacity: 1; }
#tuning-dial svg { animation: dial-idle 120s linear infinite; }
@keyframes dial-idle { to { transform: rotate(360deg); } }
body.scrolling #tuning-dial svg { animation-duration: 30s; }

/* === PARTICLE CANVAS === */
#particle-canvas {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
}

/* === DASHBOARD GRID === */
#dashboard {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-auto-rows: minmax(80px, auto);
    gap: 6px;
    padding: 6px;
    min-height: 100vh;
}

/* Block placement */
.block-identity          { grid-column: 1 / 5;   grid-row: 1 / 3; }
.block-narrative-primary  { grid-column: 1 / 8;   grid-row: 3 / 7; }
.block-viz-1             { grid-column: 5 / 10;  grid-row: 1 / 3; }
.block-instrument-1      { grid-column: 10 / 13; grid-row: 1 / 2; }
.block-instrument-2      { grid-column: 10 / 13; grid-row: 2 / 3; }
.block-instrument-3      { grid-column: 8 / 10;  grid-row: 3 / 5; }
.block-viz-2             { grid-column: 8 / 13;  grid-row: 5 / 7; }
.block-narrative-secondary { grid-column: 1 / 7;  grid-row: 7 / 10; }
.block-instrument-4      { grid-column: 10 / 13; grid-row: 3 / 5; }
.block-instrument-5      { grid-column: 7 / 10;  grid-row: 7 / 10; }

/* === BLOCK BASE === */
.block {
    background: var(--panel-surface);
    padding: 16px 18px;
    position: relative;
    overflow: hidden;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}
.block.illuminated {
    opacity: 1;
    transform: translateY(0);
}

/* Candle-atmospheric gradient */
.block::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 50% 0%, rgba(194, 155, 72, var(--candle-intensity)) 0%, transparent 70%);
    pointer-events: none;
    transition: --candle-intensity 0.3s;
}

/* Block label */
.block-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.65rem, 1.2vw, 0.85rem);
    font-weight: 400;
    color: var(--muted-label);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    line-height: 1;
}

.block-rule {
    height: 1px;
    background: var(--border-default);
    margin: 8px 0 12px;
}

/* === IDENTITY BLOCK === */
#site-title {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 700;
    font-size: clamp(2.2rem, 5vw, 4rem);
    color: var(--warm-amber);
    line-height: 1.1;
    overflow: hidden;
}
#site-title .char {
    display: inline-block;
    opacity: 0;
    transition: opacity 0.15s ease-out;
}
#site-title .char.visible { opacity: 1; }

#site-suffix {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.85rem, 1.5vw, 1.1rem);
    color: var(--cool-phosphor);
    letter-spacing: 0.1em;
    display: block;
    margin-top: 4px;
    opacity: 0;
    transition: opacity 0.4s ease-out;
}
#site-suffix.visible { opacity: 1; }

/* === NARRATIVE TEXT === */
.narrative-text p {
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.2rem);
    line-height: 1.72;
    color: var(--narrative-text);
    margin-bottom: 1em;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}
.narrative-text p.revealed {
    opacity: 1;
    transform: translateY(0);
}

.pull-quote {
    font-family: 'Barlow Condensed', sans-serif !important;
    font-weight: 600 !important;
    font-size: clamp(1.2rem, 2.2vw, 1.6rem) !important;
    line-height: 1.4 !important;
    border-left: 3px solid var(--hot-signal);
    padding-left: 16px;
}

/* === STORY ARC VISUALIZATIONS === */
.story-arc {
    width: 100%;
    height: 120px;
    display: block;
    filter: drop-shadow(0 0 4px rgba(72, 168, 156, 0.5));
}

.arc-path {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 2s ease-out;
    animation: arc-breathe 4s ease-in-out infinite;
}
.arc-path.drawn { stroke-dashoffset: 0; }

@keyframes arc-breathe {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

.arc-data {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 24px;
    margin-top: 10px;
}

.data-item {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.65rem, 1.2vw, 0.85rem);
    text-transform: uppercase;
    letter-spacing: 0.15em;
}

.data-label { color: var(--muted-label); }
.data-value { color: var(--cool-phosphor); }

/* === INSTRUMENT BLOCKS === */
.instrument-single { text-align: center; padding-top: 12px; }

.instrument-number {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(2rem, 4vw, 3.2rem);
    color: var(--warm-amber);
    font-weight: 400;
    letter-spacing: 0.05em;
}

.instrument-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.6rem, 1vw, 0.75rem);
    color: var(--muted-label);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin-top: 6px;
}

.instrument-coord {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.9rem, 1.5vw, 1.1rem);
    color: var(--cool-phosphor);
    letter-spacing: 0.1em;
}

/* Gauge */
.instrument-gauge { text-align: center; }
.gauge-svg { width: 80px; height: 80px; margin: 0 auto; display: block; }
.gauge-fill { transition: stroke-dashoffset 1.5s ease-out; }
.gauge-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.6rem;
    color: var(--muted-label);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin-top: 6px;
}
.gauge-value {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 1rem;
    color: var(--warm-amber);
    margin-top: 2px;
}

/* Bars */
.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 80px;
    padding: 0 4px;
}
.bar {
    flex: 1;
    background: var(--bright-data);
    height: 0;
    transition: height 1s ease-out;
    border-radius: 1px 1px 0 0;
}
.bar.grown { height: var(--bar-height); }

.bars-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.6rem;
    color: var(--muted-label);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin-top: 8px;
    text-align: center;
}

/* Status */
.instrument-status { padding-top: 8px; }
.status-row {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.65rem, 1vw, 0.78rem);
    color: var(--narrative-text);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}
.status-dot.active { background: var(--bright-data); box-shadow: 0 0 6px rgba(126, 196, 146, 0.6); }
.status-dot.warning { background: var(--hot-signal); box-shadow: 0 0 6px rgba(212, 114, 60, 0.6); animation: blink 2s ease-in-out infinite; }
@keyframes blink { 0%,100%{ opacity:1; } 50%{ opacity:0.3; } }

/* === RESPONSIVE === */
@media (max-width: 900px) {
    #dashboard {
        grid-template-columns: repeat(6, 1fr);
    }
    .block-identity          { grid-column: 1 / 4; grid-row: auto; }
    .block-viz-1             { grid-column: 4 / 7; grid-row: auto; }
    .block-instrument-1      { grid-column: 1 / 3; grid-row: auto; }
    .block-instrument-2      { grid-column: 3 / 5; grid-row: auto; }
    .block-instrument-3      { grid-column: 5 / 7; grid-row: auto; }
    .block-narrative-primary  { grid-column: 1 / 7; grid-row: auto; }
    .block-viz-2             { grid-column: 1 / 7; grid-row: auto; }
    .block-narrative-secondary { grid-column: 1 / 7; grid-row: auto; }
    .block-instrument-4      { grid-column: 1 / 3; grid-row: auto; }
    .block-instrument-5      { grid-column: 3 / 7; grid-row: auto; }
}

@media (max-width: 560px) {
    #dashboard { grid-template-columns: 1fr 1fr; }
    .block-identity,
    .block-narrative-primary,
    .block-viz-1,
    .block-viz-2,
    .block-narrative-secondary,
    .block-instrument-5 { grid-column: 1 / -1; }
    .block-instrument-1 { grid-column: 1 / 2; }
    .block-instrument-2 { grid-column: 2 / 3; }
    .block-instrument-3 { grid-column: 1 / -1; }
    .block-instrument-4 { grid-column: 1 / -1; }
}
