/* ============================================================
   Historic.day - Generative Data-Theater CSS
   ============================================================ */

:root {
    /* Palette Colors */
    --bg-primary: #0E0E2C;
    --bg-panel: #1B1B3A;
    --bg-surface: #2D2D5E;
    --text-primary: #FFFBF0;
    --text-secondary: #B8B8D4;
    --accent-pink: #FF6B9D;
    --accent-orange: #FFB347;
    --accent-teal: #4ECDC4;
    --accent-chartreuse: #C3F73A;
    --accent-violet: #A855F7;
    --signal-coral: #FF6F61;

    /* Typography */
    --font-display: 'Outfit', sans-serif;
    --font-secondary: 'Syne', sans-serif;
    --font-body: 'Nunito Sans', sans-serif;
    --font-mono: 'Inconsolata', monospace;

    /* Layout */
    --era-width: 280px;
    --monitor-width: 200px;
    --signal-height: 72px;
}

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

html, body {
    width: 100%;
    height: 100%;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-body);
    overflow: hidden;
}

/* ============================================================
   Dashboard Layout
   ============================================================ */

.dashboard {
    display: grid;
    grid-template-columns: var(--era-width) 1fr var(--monitor-width);
    grid-template-rows: var(--signal-height) 1fr;
    grid-template-areas:
        "signal signal signal"
        "selector theater monitor";
    width: 100%;
    height: 100vh;
    gap: 0;
}

/* Signal Bar */
.signal-bar {
    grid-area: signal;
    background-color: var(--bg-panel);
    border-bottom: 1px solid var(--bg-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

#signalCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* Era Selector */
.era-selector {
    grid-area: selector;
    background-color: var(--bg-panel);
    border-right: 1px solid var(--bg-surface);
    overflow-y: auto;
    padding: 16px 12px;
    scroll-behavior: smooth;
}

.era-selector::-webkit-scrollbar {
    width: 4px;
}

.era-selector::-webkit-scrollbar-track {
    background: transparent;
}

.era-selector::-webkit-scrollbar-thumb {
    background: var(--accent-chartreuse);
    border-radius: 2px;
}

.era-tiles-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.era-tile {
    background-color: var(--bg-surface);
    border: 1px solid var(--bg-surface);
    border-left: 3px solid transparent;
    border-radius: 6px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s ease-out;
    animation: slideInTile 0.3s ease-out backwards;
}

.era-tile:nth-child(1) { animation-delay: 0ms; }
.era-tile:nth-child(2) { animation-delay: 60ms; }
.era-tile:nth-child(3) { animation-delay: 120ms; }
.era-tile:nth-child(4) { animation-delay: 180ms; }
.era-tile:nth-child(5) { animation-delay: 240ms; }
.era-tile:nth-child(6) { animation-delay: 300ms; }

@keyframes slideInTile {
    from {
        transform: translateX(-20px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.era-tile:hover {
    background-color: #3A3A6A;
    border-left-color: var(--accent-chartreuse);
    box-shadow: 0 0 12px rgba(195, 247, 58, 0.2);
}

.era-tile:hover .era-label {
    letter-spacing: 2px;
}

.era-icon {
    width: 48px;
    height: 48px;
    display: block;
    margin: 0 auto 8px;
}

.era-label {
    font-family: var(--font-secondary);
    font-size: 0.9rem;
    font-weight: 700;
    text-align: center;
    color: var(--text-primary);
    transition: letter-spacing 0.2s ease;
    margin-bottom: 6px;
}

.progress-bar {
    height: 2px;
    background-color: var(--accent-chartreuse);
    border-radius: 1px;
    transition: width 0.3s ease;
}

.era-tile.active {
    background-color: var(--bg-surface);
    border-left-color: var(--accent-chartreuse);
    box-shadow: 0 0 20px rgba(195, 247, 58, 0.3);
}

/* Theater Stage */
.theater-stage {
    grid-area: theater;
    background-color: var(--bg-primary);
    overflow-y: scroll;
    scroll-behavior: smooth;
    position: relative;
}

.theater-stage::-webkit-scrollbar {
    width: 6px;
}

.theater-stage::-webkit-scrollbar-track {
    background: transparent;
}

.theater-stage::-webkit-scrollbar-thumb {
    background: var(--accent-teal);
    border-radius: 3px;
}

.scene {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.background-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

.scene-content {
    position: relative;
    z-index: 1;
    max-width: 700px;
    margin: 0 auto;
    padding: 60px 40px;
    text-align: center;
}

/* Headlines - Kinetic Typography */
.headline {
    font-family: var(--font-display);
    font-size: 3.5rem;
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 40px;
    letter-spacing: -0.02em;
}

.char {
    display: inline-block;
    animation: wave 0.8s ease-in-out forwards;
}

@keyframes wave {
    0% {
        transform: translateY(12px);
        opacity: 0;
    }
    50% {
        transform: translateY(-4px);
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Color cycling for characters */
.scene:nth-child(1) .char:nth-child(1) { color: var(--accent-pink); animation-delay: calc(var(--i) * 30ms); }
.scene:nth-child(1) .char:nth-child(2) { color: var(--accent-orange); animation-delay: calc(var(--i) * 30ms); }
.scene:nth-child(1) .char:nth-child(3) { color: var(--accent-teal); animation-delay: calc(var(--i) * 30ms); }
.scene:nth-child(1) .char:nth-child(4) { color: var(--accent-chartreuse); animation-delay: calc(var(--i) * 30ms); }
.scene:nth-child(1) .char:nth-child(5) { color: var(--accent-violet); animation-delay: calc(var(--i) * 30ms); }

.scene:nth-child(2) .char { color: var(--accent-orange); animation-delay: calc(var(--i) * 30ms); }
.scene:nth-child(3) .char { color: var(--accent-teal); animation-delay: calc(var(--i) * 30ms); }
.scene:nth-child(4) .char { color: var(--accent-chartreuse); animation-delay: calc(var(--i) * 30ms); }
.scene:nth-child(5) .char { color: var(--accent-violet); animation-delay: calc(var(--i) * 30ms); }
.scene:nth-child(6) .char { color: var(--accent-pink); animation-delay: calc(var(--i) * 30ms); }

/* Icon Cluster */
.icon-cluster {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 40px;
    margin: 40px 0;
    position: relative;
}

.icon {
    width: 96px;
    height: 96px;
    stroke: currentColor;
    color: var(--accent-pink);
    animation: pulse 3s ease-in-out infinite;
    opacity: 1;
}

.scene:nth-child(1) .icon:nth-child(1) { color: var(--accent-pink); }
.scene:nth-child(1) .icon:nth-child(2) { color: var(--accent-orange); }
.scene:nth-child(1) .icon:nth-child(3) { color: var(--accent-teal); }

.scene:nth-child(2) .icon { color: var(--accent-orange); }
.scene:nth-child(3) .icon { color: var(--accent-teal); }
.scene:nth-child(4) .icon { color: var(--accent-chartreuse); }
.scene:nth-child(5) .icon { color: var(--accent-violet); }
.scene:nth-child(6) .icon { color: var(--accent-pink); }

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.04);
    }
}

/* Narrative Text */
.narrative {
    font-family: var(--font-body);
    font-size: 1.05rem;
    line-height: 1.7;
    color: var(--text-secondary);
    margin-bottom: 20px;
    animation: fadeUp 0.6s ease-out forwards;
}

.narrative:nth-of-type(1) { animation-delay: 0.2s; }
.narrative:nth-of-type(2) { animation-delay: 0.4s; }

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Wave Divider */
.wave-divider {
    height: 40px;
    margin-top: 60px;
    position: relative;
    background: linear-gradient(to bottom, rgba(65, 65, 130, 0.3), transparent);
}

/* Waveform Monitor */
.waveform-monitor {
    grid-area: monitor;
    background-color: var(--bg-panel);
    border-left: 1px solid var(--bg-surface);
    padding: 16px 12px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.waveform-monitor::-webkit-scrollbar {
    width: 4px;
}

.waveform-monitor::-webkit-scrollbar-track {
    background: transparent;
}

.waveform-monitor::-webkit-scrollbar-thumb {
    background: var(--accent-violet);
    border-radius: 2px;
}

.readout {
    background-color: var(--bg-surface);
    border: 1px solid #3A3A6A;
    border-radius: 4px;
    padding: 8px;
    flex: 1;
    min-height: 80px;
    animation: bootUp 0.5s ease-out forwards;
    opacity: 0;
}

.readout:nth-child(1) { animation-delay: 0ms; }
.readout:nth-child(2) { animation-delay: 500ms; }
.readout:nth-child(3) { animation-delay: 1000ms; }

@keyframes bootUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.readout canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* ============================================================
   Responsive Design
   ============================================================ */

@media (max-width: 1024px) {
    .dashboard {
        grid-template-columns: var(--era-width) 1fr;
        grid-template-areas:
            "signal signal"
            "selector theater";
    }

    .waveform-monitor {
        display: none;
    }
}

@media (max-width: 768px) {
    :root {
        --era-width: 0px;
        --signal-height: 36px;
    }

    .dashboard {
        grid-template-columns: 1fr;
        grid-template-areas:
            "signal"
            "theater";
    }

    .era-selector {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        background-color: var(--bg-panel);
        border: none;
        border-top: 1px solid var(--bg-surface);
        max-height: 60vh;
        z-index: 100;
        padding: 12px;
    }

    .headline {
        font-size: 2rem;
    }

    .scene-content {
        padding: 40px 20px;
    }

    .icon-cluster {
        gap: 20px;
    }

    .icon {
        width: 64px;
        height: 64px;
    }
}

/* ============================================================
   Utility Styles
   ============================================================ */

body.idle .signal-bar {
    filter: drop-shadow(0 0 20px rgba(195, 247, 58, 0.5));
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Selection styling */
::selection {
    background-color: var(--accent-chartreuse);
    color: var(--bg-primary);
}
