/* CSS Variables for Dark Theme */
:root {
    --bg-dark: #ffffff;
    --bg-sidebar: #edf0f2;
    --bg-surface: #f8f9fa;

    --text-main: #404040;
    --text-muted: #777777;

    --accent-primary: #2980b9;
    --accent-glow: rgba(41, 128, 185, 0.1);
    --accent-warning: #e67e22;
    --accent-success: #27ae60;

    --border-color: #e1e4e5;

    --font-sans: 'Lato', 'proxima-nova', 'Helvetica Neue', Arial, sans-serif;
    --font-mono: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", Courier, monospace;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-sans);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    position: fixed;
    height: 100vh;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-header {
    margin-bottom: 3rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.5px;
}

.logo-icon {
    color: var(--accent-primary);
    filter: drop-shadow(0 0 8px var(--accent-glow));
}

.subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
    font-weight: 500;
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-links li a {
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 500;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    display: block;
    transition: all 0.2s ease;
}

.nav-links li a:hover {
    background-color: var(--bg-surface);
    color: var(--text-main);
}

.nav-links li a.active {
    background-color: rgba(59, 130, 246, 0.1);
    color: var(--accent-primary);
    border-left: 3px solid var(--accent-primary);
}

/* Main Content */
.content-area {
    flex: 1;
    margin-left: 280px;
    padding: 4rem 6rem;
    max-width: 1000px;
}

/* Typography & Content Structure */
.chapter {
    margin-bottom: 6rem;
    opacity: 0;
    transform: translateY(20px);
    animation: fadeUp 0.6s forwards;
}

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

.chapter-badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--accent-primary);
    background: rgba(59, 130, 246, 0.1);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    margin-bottom: 1rem;
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 1.5rem;
    letter-spacing: -1px;
    line-height: 1.2;
}

p {
    font-size: 1.05rem;
    margin-bottom: 1.5rem;
    color: var(--text-main);
}

.intro-text {
    font-size: 1.25rem;
    color: var(--text-main);
    font-weight: 300;
    line-height: 1.8;
}

strong {
    color: var(--text-main);
    font-weight: 600;
}

ol {
    margin: 1.5rem 0 1.5rem 2rem;
    font-size: 1.05rem;
}

ol li {
    margin-bottom: 0.75rem;
}

/* Callouts */
.callout {
    padding: 1.5rem;
    border-radius: 12px;
    background-color: var(--bg-surface);
    border-left: 4px solid var(--border-color);
    margin: 2rem 0;
    font-size: 0.95rem;
}

.callout strong {
    display: block;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.callout.warning {
    border-left-color: var(--accent-warning);
    background: rgba(245, 158, 11, 0.05);
}

.callout.warning strong {
    color: var(--accent-warning);
}

.callout.tip {
    border-left-color: var(--accent-success);
    background: rgba(16, 185, 129, 0.05);
}

.callout.tip strong {
    color: var(--accent-success);
}

/* Code Blocks */
pre {
    background-color: var(--bg-sidebar) !important;
    padding: 1.5rem !important;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    margin: 2rem 0;
    overflow-x: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

code {
    font-family: var(--font-mono) !important;
    font-size: 0.9rem !important;
    line-height: 1.5 !important;
}

/* Responsive */
@media (max-width: 1024px) {
    .content-area {
        padding: 3rem 4rem;
    }
}

@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        padding: 1.5rem;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .content-area {
        margin-left: 0;
        padding: 2rem;
    }

    h1 {
        font-size: 2rem;
    }
}

/* Tooltips */
.glossary-term {
    border-bottom: 1px dashed var(--text-muted);
    cursor: help;
    position: relative;
    color: var(--accent-primary);
}

.glossary-term::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 150%;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--bg-sidebar);
    color: var(--text-main);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 400;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border-color);
    z-index: 100;
    pointer-events: none;
}

.glossary-term::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px;
    border-style: solid;
    border-color: var(--border-color) transparent transparent transparent;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 100;
}

.glossary-term:hover::after,
.glossary-term:hover::before {
    opacity: 1;
    visibility: visible;
    bottom: calc(100% + 6px);
    /* adjusting for the arrow */
}

/* Interactive Widgets */
.interactive-widget {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 2rem;
    margin: 3rem 0;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.interactive-widget h3 {
    margin-bottom: 0.5rem;
    color: var(--text-main);
    font-size: 1.5rem;
}

.widget-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.control-group label {
    font-size: 0.95rem;
    color: var(--text-main);
}

.control-group input[type="range"] {
    width: 100%;
    accent-color: var(--accent-primary);
}

.widget-result {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1rem;
}

.result-box {
    flex: 1;
    background: var(--bg-sidebar);
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    text-align: center;
    transition: all 0.3s ease;
}

.result-box.highlighted {
    border-color: var(--accent-primary);
    background: rgba(59, 130, 246, 0.05);
}

.result-box.danger {
    border-color: var(--accent-warning);
    background: rgba(245, 158, 11, 0.05);
}

.result-box.danger h4,
.result-box.danger .result-value {
    color: var(--accent-warning);
}

.result-box h4 {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
}

.result-value {
    font-size: 2.25rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text-main);
    transition: color 0.3s ease;
}

.widget-status {
    text-align: center;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--accent-success);
    padding: 0.75rem;
    border-radius: 6px;
    background: rgba(16, 185, 129, 0.1);
    transition: all 0.3s ease;
}

/* CFO Simulator */
.cost-comparison {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.cost-bar-container {
    display: flex;
    align-items: center;
    gap: 1rem;
    position: relative;
    padding-top: 1.5rem;
}

.cost-label {
    position: absolute;
    top: 0;
    left: 0;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.cost-bar {
    height: 36px;
    border-radius: 6px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.static-bar {
    background: var(--border-color);
}

.hpa-bar {
    background: var(--accent-warning);
}

.inferscale-bar {
    background: var(--accent-primary);
}

.cost-value {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 1.1rem;
    min-width: 100px;
    text-align: right;
}

.highlight-value {
    color: var(--accent-success);
    font-size: 1.4rem;
    font-weight: 700;
}

.widget-status.unstable {
    color: var(--accent-warning);
    background: rgba(245, 158, 11, 0.1);
}

.glossary-term:hover::before {
    bottom: calc(100% + 1px);
}

/* Animated Race Simulator */
.race-widget {
    background: var(--bg-surface);
    overflow: hidden;
}

.race-track-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    margin-top: 1rem;
}

.race-track {
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
}

.track-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    background: rgba(255, 255, 255, 0.05);
}

.btn-primary {
    background: var(--accent-primary);
    color: var(--text-main);
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-sans);
}

.btn-primary:focus {
    outline: none;
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.timeline {
    height: 60px;
    position: relative;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

/* Base Markers */
.traffic-marker,
.forecast-marker,
.ready-marker,
.ready-marker-inf {
    position: absolute;
    top: 0;
    height: 100%;
    display: flex;
    align-items: center;
    padding: 0 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    border-left: 2px solid;
    white-space: nowrap;
    opacity: 0;
}

.boot-bar,
.boot-bar-inf {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    height: 30px;
    background: repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.1) 10px, transparent 10px, transparent 20px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: var(--text-main);
    border-radius: 4px;
    opacity: 0;
}

/* Positions & Colors */
.traffic-marker {
    border-color: #ef4444;
    color: #ef4444;
    left: 60%;
}

.forecast-marker {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    left: 10%;
}

.ready-marker {
    border-color: var(--accent-warning);
    color: var(--accent-warning);
    left: 95%;
}

.ready-marker-inf {
    border-color: var(--accent-success);
    color: var(--accent-success);
    left: 55%;
}

.boot-bar {
    left: 60%;
    background-color: var(--accent-warning);
    width: 35%;
}

.boot-bar-inf {
    left: 10%;
    background-color: var(--accent-primary);
    width: 45%;
}

/* Animation Classes */
.animate-hpa-traffic {
    animation: fadeIn 0.5s forwards 1s;
}

.animate-hpa-boot {
    animation: expandRight 3s linear forwards 1.5s;
}

.animate-hpa-ready {
    animation: fadeIn 0.5s forwards 4.5s;
}

.animate-hpa-fail {
    animation: flashRed 1s infinite 1.5s;
}

.animate-inf-forecast {
    animation: fadeIn 0.5s forwards 0.5s;
}

.animate-inf-boot {
    animation: expandRight 2.5s linear forwards 1s;
}

.animate-inf-ready {
    animation: fadeIn 0.5s forwards 3.5s;
}

.animate-inf-traffic {
    animation: fadeIn 0.5s forwards 4s;
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

@keyframes expandRight {
    0% {
        width: 0;
        opacity: 1;
    }

    100% {
        width: 35%;
        opacity: 1;
    }
}

.boot-bar-inf.animate-inf-boot {
    animation: expandRightInf 2.5s linear forwards 1s;
}

@keyframes expandRightInf {
    0% {
        width: 0;
        opacity: 1;
    }

    100% {
        width: 45%;
        opacity: 1;
    }
}

@keyframes flashRed {

    0%,
    100% {
        background-color: rgba(239, 68, 68, 0.2);
    }

    50% {
        background-color: rgba(239, 68, 68, 0.4);
    }
}

/* Pipeline Visualizer */
.pipeline-widget {
    background: var(--bg-surface);
}

.pipeline-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: relative;
    padding-left: 1.5rem;
}

.pipeline-container::before {
    content: '';
    position: absolute;
    left: 27px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border-color);
    z-index: 1;
}

.pipeline-step {
    display: flex;
    gap: 1.5rem;
    position: relative;
    z-index: 2;
    opacity: 0.3;
    /* Dimmed by default */
    transform: translateX(-10px);
    transition: all 0.4s ease;
}

.pipeline-step.active {
    opacity: 1;
    transform: translateX(0);
}

.step-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bg-sidebar);
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    flex-shrink: 0;
    transition: all 0.4s ease;
}

.pipeline-step.active .step-icon {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: #fff;
    box-shadow: 0 0 10px var(--accent-glow);
}

.step-content {
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.25rem;
    flex: 1;
}

.step-content h4 {
    margin-bottom: 0.75rem;
    color: var(--text-main);
    font-size: 1.1rem;
}

.step-content p {
    margin-bottom: 0.25rem;
    font-size: 0.95rem;
}

.step-data {
    color: var(--text-muted);
}

.step-action {
    font-family: var(--font-mono);
    color: var(--text-main);
    margin: 0.75rem 0;
    padding-left: 0.75rem;
    border-left: 2px solid var(--border-color);
}

.step-result {
    font-weight: 600;
}