/* historical.quest - Retro-Futuristic Chrono-Instrument Panel */

/* Animatable custom property for era accent color */
@property --era-accent {
    syntax: '<color>';
    inherits: true;
    initial-value: #f5c4a1;
}

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

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

body {
    font-family: 'DM Sans', sans-serif;
    background: #f5f0e8;
    color: #2d1b3d;
    min-height: 100vh;
    overflow-x: hidden;
    --era-accent: #f5c4a1;
    transition: --era-accent 1.2s ease;
}

/* ===== SKELETON LOADING ===== */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.bento-tile.skeleton .tile-content {
    opacity: 0;
    filter: blur(4px);
}

.bento-tile.skeleton::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, #ede6f2 25%, #f5f0e8 50%, #ede6f2 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: inherit;
    z-index: 2;
}

.bento-tile.revealed .tile-content {
    opacity: 1;
    filter: blur(0);
    transition: opacity 0.6s ease, filter 0.6s ease;
}

.bento-tile.revealed::before {
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

/* ===== BUBBLE CONTAINER ===== */
#bubble-container {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.bubble {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.6), transparent 60%),
                radial-gradient(circle at 50% 50%, var(--bubble-color, rgba(126,232,199,0.15)), transparent 70%);
    animation: float-up var(--duration, 12s) linear forwards;
    opacity: 0;
}

@keyframes float-up {
    0% {
        transform: translateY(0) translateX(0);
        opacity: 0;
    }
    10% {
        opacity: 0.7;
    }
    90% {
        opacity: 0.5;
    }
    100% {
        transform: translateY(-110vh) translateX(var(--drift, 15px));
        opacity: 0;
    }
}

/* ===== BENTO GRID ===== */
#bento-grid {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-auto-rows: minmax(60px, auto);
    gap: 2px;
    padding: 8px;
    min-height: 100vh;
    max-width: 1400px;
    margin: 0 auto;
}

/* ===== TILE BASE ===== */
.bento-tile {
    position: relative;
    background: rgba(237, 230, 242, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid #c8b8d4;
    border-radius: 3px;
    overflow: hidden;
    transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1),
                box-shadow 0.3s ease,
                border-color 0.3s ease;
}

.bento-tile:hover {
    transform: scale(1.015);
    box-shadow: 0 4px 20px rgba(45, 27, 61, 0.08);
    border-color: var(--era-accent, #7ee8c7);
    z-index: 5;
}

.tile-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 12px;
    position: relative;
}

/* ===== TILE PLACEMENTS (12-col bento) ===== */

/* Wordmark: 3 cols x 1 row, top-left */
.tile-wordmark {
    grid-column: 1 / 4;
    grid-row: 1 / 2;
}

/* Oscilloscope: 2 cols x 2 rows */
.tile-oscilloscope {
    grid-column: 4 / 6;
    grid-row: 1 / 3;
}

/* Status: 4 cols x 1 row */
.tile-status {
    grid-column: 6 / 10;
    grid-row: 1 / 2;
}

/* Era selector: 3 cols x 1 row, top-right */
.tile-era-selector {
    grid-column: 10 / 13;
    grid-row: 1 / 2;
}

/* Main narrative: 6 cols x 4 rows */
.tile-main {
    grid-column: 1 / 7;
    grid-row: 2 / 6;
}

/* Timeline: 2 cols x 4 rows */
.tile-timeline {
    grid-column: 7 / 9;
    grid-row: 2 / 6;
}

/* Crosshair: 2 cols x 2 rows */
.tile-crosshair {
    grid-column: 9 / 11;
    grid-row: 2 / 4;
}

/* Coordinates: 2 cols x 1 row */
.tile-coordinates {
    grid-column: 11 / 13;
    grid-row: 2 / 3;
}

/* Compass: 2 cols x 2 rows */
.tile-compass {
    grid-column: 11 / 13;
    grid-row: 3 / 5;
}

/* Signal: 3 cols x 1 row */
.tile-signal {
    grid-column: 9 / 12;
    grid-row: 4 / 5;
}

/* Era readout: 3 cols x 1 row */
.tile-era-readout {
    grid-column: 9 / 13;
    grid-row: 5 / 6;
}

/* Frequency: 4 cols x 2 rows */
.tile-frequency {
    grid-column: 1 / 5;
    grid-row: 6 / 8;
}

/* Datastream: 2 cols x 2 rows */
.tile-datastream {
    grid-column: 5 / 7;
    grid-row: 6 / 8;
}

/* Topo: 6 cols x 1 row */
.tile-topo {
    grid-column: 7 / 13;
    grid-row: 6 / 7;
}

/* ===== WORDMARK ===== */
.wordmark {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.12em;
    color: #2d1b3d;
    text-transform: uppercase;
}

/* ===== DATA LABELS ===== */
.data-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    font-weight: 400;
    letter-spacing: 0.08em;
    color: #9b8fad;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.data-value {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: 13px;
    letter-spacing: 0.06em;
    color: #2d1b3d;
    text-transform: uppercase;
}

.data-mono {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0.08em;
    color: #9b8fad;
}

/* ===== ERA SELECTOR ===== */
.era-indicators {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
}

.era-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1.5px solid #c8b8d4;
    background: transparent;
    cursor: pointer;
    transition: all 0.4s ease;
    padding: 0;
}

.era-dot.active {
    background: var(--era-accent, #7ee8c7);
    border-color: var(--era-accent, #7ee8c7);
    box-shadow: 0 0 8px var(--era-accent, rgba(126, 232, 199, 0.5));
}

.era-dot:hover {
    border-color: var(--era-accent, #7ee8c7);
}

@keyframes pulse-dot {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.7; }
}

.era-dot.active {
    animation: pulse-dot 2s ease-in-out infinite;
}

/* ===== MAIN CONTENT ===== */
.tile-main .tile-content {
    justify-content: flex-start;
    align-items: flex-start;
    padding: 0;
}

.main-scroll-content {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    padding: 20px 24px;
    scrollbar-width: thin;
    scrollbar-color: #c8b8d4 transparent;
}

.main-scroll-content::-webkit-scrollbar {
    width: 4px;
}

.main-scroll-content::-webkit-scrollbar-track {
    background: transparent;
}

.main-scroll-content::-webkit-scrollbar-thumb {
    background: #c8b8d4;
    border-radius: 2px;
}

.era-section {
    padding: 20px 0 40px;
    border-bottom: 1px solid #c8b8d4;
}

.era-section:last-child {
    border-bottom: none;
    padding-bottom: 20px;
}

.era-tag {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0.08em;
    color: #9b8fad;
    display: block;
    margin-bottom: 12px;
}

.era-title {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 28px;
    letter-spacing: 0.06em;
    line-height: 1.1;
    color: #2d1b3d;
    text-transform: uppercase;
    margin-bottom: 16px;
}

.era-body {
    font-family: 'DM Sans', sans-serif;
    font-size: 15px;
    line-height: 1.65;
    font-weight: 400;
    color: #2d1b3d;
    margin-bottom: 12px;
    letter-spacing: 0.01em;
}

.era-data-block {
    margin-top: 16px;
    padding: 10px 14px;
    background: rgba(26, 15, 46, 0.04); /* #1a0f2e at 4% */
    border-radius: 3px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Scroll-triggered fade-up for era sections */
.era-section {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s cubic-bezier(0.22, 1, 0.36, 1),
                transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.era-section.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ===== OSCILLOSCOPE ===== */
.oscilloscope-svg {
    width: 80%;
    height: 80%;
    opacity: 0.7;
}

/* ===== TIMELINE ===== */
.tile-timeline .tile-content {
    justify-content: flex-start;
    align-items: flex-start;
    padding: 16px;
}

.timeline-track {
    display: flex;
    flex-direction: column;
    gap: 0;
    width: 100%;
    flex: 1;
    justify-content: space-between;
    padding: 8px 0;
}

.timeline-marker {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    transition: opacity 0.3s ease;
}

.timeline-year {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.08em;
    color: #9b8fad;
    min-width: 65px;
}

.timeline-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #c8b8d4;
    transition: all 0.4s ease;
}

.timeline-marker.active .timeline-dot {
    background: var(--era-accent, #7ee8c7);
    box-shadow: 0 0 8px var(--era-accent, rgba(126, 232, 199, 0.5));
}

.timeline-marker.active .timeline-year {
    color: #2d1b3d;
}

/* ===== CROSSHAIR ===== */
.crosshair {
    width: 40px;
    height: 40px;
    position: relative;
}

.crosshair::before,
.crosshair::after {
    content: '';
    position: absolute;
    background: #c8b8d4;
}

.crosshair::before {
    width: 1px;
    height: 100%;
    left: 50%;
    top: 0;
}

.crosshair::after {
    width: 100%;
    height: 1px;
    top: 50%;
    left: 0;
}

/* ===== COMPASS ===== */
.compass-svg {
    width: 70%;
    height: 70%;
    opacity: 0.8;
}

/* ===== SIGNAL BARS ===== */
.signal-bars {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 24px;
    margin-top: 4px;
}

.signal-bar {
    width: 6px;
    background: var(--era-accent, #7ee8c7);
    border-radius: 1px;
    transition: height 0.4s ease, background 0.4s ease;
}

.bar-1 { height: 6px; }
.bar-2 { height: 10px; }
.bar-3 { height: 14px; }
.bar-4 { height: 18px; }
.bar-5 { height: 22px; }

@keyframes signal-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.signal-bar {
    animation: signal-pulse 2s ease-in-out infinite;
}

.bar-1 { animation-delay: 0s; }
.bar-2 { animation-delay: 0.15s; }
.bar-3 { animation-delay: 0.3s; }
.bar-4 { animation-delay: 0.45s; }
.bar-5 { animation-delay: 0.6s; }

/* ===== ERA READOUT ===== */
.era-readout-text {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: 13px;
    letter-spacing: 0.06em;
    color: var(--era-accent, #7ee8c7);
    text-transform: uppercase;
    transition: color 1.2s ease;
}

/* ===== FREQUENCY VISUALIZATION ===== */
.tile-frequency .tile-content {
    justify-content: flex-start;
    align-items: flex-start;
    padding: 16px;
}

.frequency-svg {
    width: 100%;
    flex: 1;
    margin-top: 8px;
}

#freq-wave {
    stroke: var(--era-accent, #7ee8c7);
    transition: stroke 1.2s ease;
}

/* ===== DATASTREAM ===== */
.tile-datastream .tile-content {
    justify-content: flex-start;
    align-items: flex-start;
    padding: 12px;
}

.datastream-lines {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-top: 4px;
    width: 100%;
    overflow: hidden;
}

.stream-line {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.05em;
    color: #9b8fad;
    opacity: 0.7;
    transition: opacity 0.3s ease;
    white-space: nowrap;
}

.stream-line:first-child {
    color: var(--era-accent, #7ee8c7);
    opacity: 1;
}

/* ===== TOPO ===== */
.topo-svg {
    width: 100%;
    height: 100%;
}

/* ===== RESPONSIVE: Single column below 768px ===== */
@media (max-width: 768px) {
    #bento-grid {
        grid-template-columns: repeat(4, 1fr);
        grid-auto-rows: minmax(50px, auto);
        gap: 2px;
        padding: 4px;
    }

    .tile-wordmark {
        grid-column: 1 / 3;
        grid-row: auto;
    }

    .tile-oscilloscope {
        grid-column: 3 / 5;
        grid-row: auto;
        min-height: 100px;
    }

    .tile-status {
        grid-column: 1 / 3;
        grid-row: auto;
    }

    .tile-era-selector {
        grid-column: 3 / 5;
        grid-row: auto;
    }

    .tile-main {
        grid-column: 1 / -1;
        grid-row: auto;
        min-height: 400px;
    }

    .tile-timeline {
        grid-column: 1 / -1;
        grid-row: auto;
    }

    .tile-crosshair {
        grid-column: 1 / 3;
        grid-row: auto;
        min-height: 80px;
    }

    .tile-coordinates {
        grid-column: 3 / 5;
        grid-row: auto;
    }

    .tile-compass {
        grid-column: 1 / 3;
        grid-row: auto;
        min-height: 100px;
    }

    .tile-signal {
        grid-column: 3 / 5;
        grid-row: auto;
    }

    .tile-era-readout {
        grid-column: 1 / -1;
        grid-row: auto;
    }

    .tile-frequency {
        grid-column: 1 / -1;
        grid-row: auto;
        min-height: 100px;
    }

    .tile-datastream {
        grid-column: 1 / 3;
        grid-row: auto;
        min-height: 120px;
    }

    .tile-topo {
        grid-column: 3 / 5;
        grid-row: auto;
    }

    .era-title {
        font-size: 22px;
    }

    .wordmark {
        font-size: 11px;
    }

    .timeline-track {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
    }
}

/* ===== DARK ACCENT & CORNFLOWER ===== */
/* Midnight Aubergine #1a0f2e - high contrast pull quotes */
.era-section .era-title::first-letter {
    color: #1a0f2e;
}

/* Pale Cornflower #a8c4f0 - cool-era decorative */
.tile-oscilloscope:hover .oscilloscope-svg circle:first-child {
    stroke: #a8c4f0;
    transition: stroke 0.4s ease;
}
