/* rational.quest - Alchemist Terminal Dashboard */

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

:root {
    --deep-twilight: #0E0A14;
    --ink-void: #1C1520;
    --candlelit-vellum: #F0E6D4;
    --candle-amber: #E8A838;
    --ember-rose: #8B3A4A;
    --twilight-violet: #4A2860;
    --night-sage: #2A4A3A;
    --phosphor-green: #A8D8A0;
    --sepia-ink: #3A2A1A;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Crimson Pro', serif;
    font-weight: 400;
    font-size: 1rem;
    line-height: 1.75;
    background-color: var(--deep-twilight);
    color: var(--phosphor-green);
    overflow-x: hidden;
}

/* === Gradient Mesh Background === */
#gradient-mesh {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    background:
        radial-gradient(ellipse at 25% 30%, rgba(139, 58, 74, 0.25), transparent 50%),
        radial-gradient(ellipse at 75% 60%, rgba(74, 40, 96, 0.3), transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(42, 74, 58, 0.25), transparent 50%),
        radial-gradient(ellipse at 30% 15%, rgba(232, 168, 56, 0.1), transparent 40%);
    background-color: var(--deep-twilight);
    animation: meshBreathe 40s ease-in-out infinite;
}

@keyframes meshBreathe {
    0% { background-position: 0% 0%, 0% 0%, 0% 0%, 0% 0%; }
    25% { background-position: 2% -1%, -1% 2%, 1% -1%, -2% 1%; }
    50% { background-position: -1% 2%, 2% -2%, -1% 2%, 1% -1%; }
    75% { background-position: 1% -1%, -2% 1%, 2% -1%, -1% 2%; }
    100% { background-position: 0% 0%, 0% 0%, 0% 0%, 0% 0%; }
}

/* === Sidebar Navigation === */
#sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 160px;
    height: 100vh;
    z-index: 100;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 2rem 1rem;
}

.sidebar-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.chapter-link {
    font-family: 'Fira Code', monospace;
    font-weight: 300;
    font-size: 0.75rem;
    color: var(--phosphor-green);
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
    opacity: 0.5;
    transition: opacity 0.3s, color 0.3s;
    padding: 0;
}

.chapter-link.active {
    opacity: 1;
}

.chapter-link.active .ch-num {
    color: var(--candle-amber);
}

.chapter-link:hover {
    opacity: 0.8;
}

.ch-num {
    color: var(--phosphor-green);
    transition: color 0.3s;
}

/* === Dashboard === */
#dashboard {
    position: relative;
    z-index: 5;
    margin-left: 160px;
    padding: 2rem;
    max-width: 1200px;
}

.dashboard-row {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
    min-height: 50vh;
    align-content: start;
}

/* === Panel Base === */
.panel {
    position: relative;
    padding: 1.5rem;
    border-radius: 4px;
    min-height: 180px;
    opacity: 0;
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.panel.visible {
    opacity: 1;
}

/* Span classes */
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }
.span-6 { grid-column: span 6; }
.span-12 { grid-column: span 12; }

/* === Terminal Panels === */
.terminal-panel {
    background-color: var(--ink-void);
    border: 1px solid rgba(232, 168, 56, 0.2);
    transform: translateY(0);
}

.terminal-chrome {
    height: 8px;
    margin: -1.5rem -1.5rem 1rem -1.5rem;
    padding: 0 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(90deg, rgba(232, 168, 56, 0.6), transparent);
    border-radius: 4px 4px 0 0;
}

.chrome-dot {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background-color: var(--candle-amber);
    opacity: 0.4;
}

.terminal-body {
    font-family: 'Fira Code', monospace;
    font-weight: 400;
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--phosphor-green);
    white-space: pre-wrap;
}

/* === Candle Cursor === */
.candle-cursor {
    display: inline-block;
    width: 8px;
    height: 14px;
    position: relative;
    margin-left: 2px;
    vertical-align: middle;
}

.candle-cursor::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%) rotate(180deg);
    width: 8px;
    height: 12px;
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    background: linear-gradient(to bottom, var(--candle-amber), transparent);
    animation: candleFlicker 0.6s ease-in-out infinite;
}

.candle-serif {
    display: block;
    margin-top: 1rem;
}

@keyframes candleFlicker {
    0% { transform: translateX(-50%) rotate(180deg) scale(1.0); opacity: 1.0; }
    25% { transform: translateX(-50%) rotate(180deg) scale(0.95); opacity: 0.8; }
    50% { transform: translateX(-50%) rotate(180deg) scale(1.02); opacity: 1.0; }
    75% { transform: translateX(-50%) rotate(180deg) scale(0.97); opacity: 0.9; }
    100% { transform: translateX(-50%) rotate(180deg) scale(1.0); opacity: 1.0; }
}

/* === Scroll Panels === */
.scroll-panel {
    background-color: var(--candlelit-vellum);
    color: var(--sepia-ink);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    transform: translateY(15px);
    background-image:
        repeating-linear-gradient(45deg, transparent, transparent 7px, rgba(58, 42, 26, 0.01) 7px, rgba(58, 42, 26, 0.01) 8px);
}

.scroll-panel.visible {
    transform: translateY(0);
}

.scroll-text {
    font-family: 'Crimson Pro', serif;
    font-weight: 400;
    font-size: 1rem;
    line-height: 1.75;
    color: var(--sepia-ink);
}

.scroll-text em {
    font-style: italic;
}

/* === Gradient Panels === */
.gradient-panel {
    background:
        radial-gradient(ellipse at 30% 40%, rgba(139, 58, 74, 0.4), transparent 60%),
        radial-gradient(ellipse at 70% 60%, rgba(74, 40, 96, 0.4), transparent 60%),
        radial-gradient(ellipse at 50% 80%, rgba(42, 74, 58, 0.3), transparent 50%);
    background-color: var(--ink-void);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    filter: grayscale(1);
    transition: filter 1.2s ease, opacity 0.6s ease;
}

.gradient-panel.visible {
    filter: grayscale(0);
}

.gradient-statement {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: clamp(2rem, 5vw, 4rem);
    color: var(--candlelit-vellum);
    text-align: center;
    max-width: 800px;
    line-height: 1.2;
}

.gradient-statement em {
    font-family: 'Playfair Display', serif;
    font-weight: 400;
    font-style: italic;
    font-size: clamp(1.25rem, 2.5vw, 2rem);
    line-height: 1.4;
}

.revelation-panel {
    min-height: 400px;
}

/* === Responsive === */
@media (max-width: 768px) {
    #sidebar {
        display: none;
    }

    #dashboard {
        margin-left: 0;
        padding: 1rem;
    }

    .dashboard-row {
        grid-template-columns: 1fr;
    }

    .span-2, .span-3, .span-4, .span-6, .span-12 {
        grid-column: span 1;
    }

    .gradient-statement {
        font-size: clamp(1.5rem, 5vw, 2.5rem);
    }
}
