/* Global Design System */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;700&display=swap');

:root {
    --bg-color: #020408;
    /* Updated to match Chapter 5 dark theme */
    --bg-gradient: radial-gradient(circle at 50% 0%, #1a1a2e 0%, #050507 100%);
    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --accent-primary: #00f0ff;
    --accent-secondary: #7000ff;
    --accent-success: #00ff9d;
    --accent-warning: #ffb800;
    --accent-danger: #ff0055;

    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-highlight: rgba(255, 255, 255, 0.1);

    --font-heading: 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --font-display: 'Space Grotesk', sans-serif;

    --sidebar-width: 280px;
    --header-height: 60px;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-heading);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    /* Ensure pseduo-elements are positioned relative to body if needed, though fixed works too */
}

/* GLOBAL BACKGROUND: Cyber Grid & Particles (From Chapter 5) */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        linear-gradient(180deg, rgba(2, 4, 8, 0) 0%, rgba(0, 240, 255, 0.03) 100%),
        repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.03) 0px, rgba(255, 255, 255, 0.03) 1px, transparent 1px, transparent 40px),
        repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.03) 0px, rgba(255, 255, 255, 0.03) 1px, transparent 1px, transparent 40px);
    z-index: -2;
    mask-image: radial-gradient(circle at 50% 50%, black 40%, transparent 100%);
    perspective: 1000px;
    transform-style: preserve-3d;
    animation: gridPulse 10s infinite alternate;
    pointer-events: none;
}

@keyframes gridPulse {
    0% {
        transform: scale(1);
        opacity: 0.5;
    }

    100% {
        transform: scale(1.05);
        opacity: 0.8;
    }
}

body::after {
    content: '';
    position: fixed;
    top: 50%;
    left: 50%;
    width: 60vw;
    height: 60vh;
    background: radial-gradient(circle, rgba(0, 240, 255, 0.08), transparent 70%);
    transform: translate(-50%, -50%);
    z-index: -3;
    pointer-events: none;
}

a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: all 0.2s ease;
}

a:hover {
    color: var(--accent-secondary);
    text-shadow: 0 0 8px var(--accent-secondary);
}

/* Layout Grid */
.app-container {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    min-height: 100vh;
}

/* Sidebar: High-Tech Glass */
.sidebar {
    background: rgba(5, 5, 8, 0.6);
    /* Deep void glass */
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    padding: 2rem 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
}

.logo-area {
    padding: 0 1.5rem 2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    /* Thinner border */
    margin-bottom: 1.5rem;
}

.logo-text {
    font-size: 1.2rem;
    /* Slightly smaller, sharper */
    font-weight: 700;
    color: #fff;
    font-family: var(--font-display);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.nav-links {
    display: flex;
    flex-direction: column;
    gap: 4px;
    /* Tighter gap */
    padding: 0 1rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    border: 1px solid transparent;
    font-family: var(--font-heading);
    position: relative;
    overflow: hidden;
}

/* Hover State: Glass Highlight */
.nav-item:hover {
    background: rgba(255, 255, 255, 0.03);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.08);
    transform: translateX(4px);
}

/* Active State: Neon Glow */
.nav-item.active {
    background: rgba(0, 240, 255, 0.05);
    border-color: rgba(0, 240, 255, 0.2);
    color: #fff;
}

.nav-item.active .nav-id {
    color: var(--accent-primary);
    text-shadow: 0 0 8px rgba(0, 240, 255, 0.4);
}

/* Active Indicator Line */
.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--accent-primary);
    box-shadow: 2px 0 10px rgba(0, 240, 255, 0.3);
}

/* Tech ID (The Number) */
.nav-id {
    font-family: var(--font-mono);
    color: #555;
    /* Dimmed by default */
    font-size: 0.75rem;
    width: 24px;
    /* Fixed width alignment */
    transition: color 0.3s;
}

.nav-item:hover .nav-id {
    color: var(--accent-primary);
}

.nav-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}


/* Main Content */
.content-area {
    padding: 4rem 6rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.chapter-header {
    margin-bottom: 3rem;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 1rem;
}

.chapter-number {
    font-family: var(--font-mono);
    color: var(--accent-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
    display: block;
}

h1 {
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: -1px;
    margin-bottom: 0.5rem;
    background: linear-gradient(to right, #fff, #ccc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

h2 {
    font-size: 1.8rem;
    margin-top: 3rem;
    margin-bottom: 1.5rem;
    color: #fff;
    display: flex;
    align-items: center;
}

h2::before {
    content: '';
    display: block;
    width: 4px;
    height: 24px;
    background: var(--accent-primary);
    margin-right: 12px;
    border-radius: 2px;
}

h3 {
    font-size: 1.4rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

p {
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
    font-size: 1.05rem;
    line-height: 1.8;
}

ul,
ol {
    margin-bottom: 1.5rem;
    padding-left: 1.5rem;
    color: var(--text-secondary);
}

li {
    margin-bottom: 0.5rem;
}

/* Glass Cards for Info/Concepts */
.glass-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 2rem;
    margin: 2rem 0;
    backdrop-filter: blur(10px);
}

.glass-card h4 {
    color: var(--accent-primary);
    margin-bottom: 1rem;
}

/* Visuals Container */
.visual-container {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 2rem;
    margin: 3rem 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    overflow: hidden;
    min-height: 300px;
}

.visual-label {
    position: absolute;
    top: 1rem;
    left: 1rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.5);
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid var(--glass-border);
}

/* Mermaid overrides for Dark Mode */
.mermaid {
    background: transparent !important;
    display: flex;
    justify-content: center;
    margin: 2rem 0;
}

/* Code Blocks */
pre,
code {
    font-family: var(--font-mono);
    font-size: 0.9em;
}

pre {
    background: #0d0d12;
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    overflow-x: auto;
    margin-bottom: 1.5rem;
}

/* Responsive */
@media (max-width: 900px) {
    .app-container {
        grid-template-columns: 1fr;
    }

    .sidebar {
        height: auto;
        position: relative;
        border-bottom: 1px solid var(--glass-border);
        border-right: none;
        padding: 1rem;
    }

    .content-area {
        padding: 2rem;
    }
}

/* ... existing code ... */

/* Documentation App Layout Enhancements */

/* 1. Content Card System */
.content-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 2.5rem;
    margin-bottom: 2rem;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.content-card:hover {
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.03);
}

/* 2. Section Headers within Cards */
.content-card h2 {
    margin-top: 0;
    margin-bottom: 1.5rem;
    font-size: 1.6rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    /* Separator */
    padding-bottom: 1rem;
    width: 100%;
}

.content-card h2::before {
    display: none;
    /* Remove the heavy sidebar accent for card headers */
}

/* 3. Alert / Warning Components */
.alert-box {
    background: rgba(255, 184, 0, 0.05);
    border: 1px solid rgba(255, 184, 0, 0.2);
    border-left: 4px solid var(--accent-warning);
    border-radius: 8px;
    padding: 1.5rem;
    margin: 1.5rem 0;
    color: #ffdcb0;
}

.alert-box.danger {
    background: rgba(255, 0, 85, 0.05);
    border-color: rgba(255, 0, 85, 0.2);
    border-left-color: var(--accent-danger);
    color: #ffb0c5;
}

.alert-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #fff;
}

/* 4. Info / Meta Panels */
.info-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    background: rgba(0, 240, 255, 0.05);
    border: 1px solid rgba(0, 240, 255, 0.15);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.info-item {
    display: flex;
    flex-direction: column;
}

.info-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--accent-primary);
    margin-bottom: 0.25rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.info-value {
    color: #fff;
    font-family: var(--font-mono);
    font-size: 0.95rem;
}

/* 5. List Components */
.feature-list {
    list-style: none;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.feature-item {
    background: rgba(255, 255, 255, 0.03);
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.feature-item:hover {
    border-color: var(--glass-highlight);
    background: rgba(255, 255, 255, 0.05);
}

.feature-title {
    color: #fff;
    font-weight: 600;
    margin-bottom: 0.5rem;
    display: block;
}

/* 6. Math / Notation Blocks */
.math-block {
    background: #0a0a0f;
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 2rem;
    display: flex;
    justify-content: center;
    margin: 2rem 0;
    font-size: 1.1rem;
}

/* 7. Page Title Area (Overrides .chapter-header) */
.chapter-header {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.02) 0%, rgba(255, 255, 255, 0) 100%);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 3rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.chapter-header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 100%;
    background: radial-gradient(circle, rgba(0, 240, 255, 0.15) 0%, rgba(0, 0, 0, 0) 70%);
    filter: blur(50px);
    pointer-events: none;
}

.chapter-number {
    position: relative;
    display: inline-block;
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 12px;
    border-radius: 20px;
    margin-bottom: 1.5rem;
    font-size: 0.8rem;
    letter-spacing: 1px;
}

/* =========================================
   System Risk Interface (Chapter 00 Special)
   ========================================= */

.system-risk-wrapper {
    position: relative;
    padding-bottom: 4rem;
}

/* Background Atmosphere - Cold, Technical */
.system-risk-wrapper::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background:
        radial-gradient(circle at 10% 10%, rgba(20, 30, 40, 0.95), transparent 70%),
        radial-gradient(circle at 90% 90%, rgba(10, 15, 20, 0.98), transparent 70%);
    z-index: -1;
    pointer-events: none;
}

.system-risk-wrapper::after {
    content: '';
    position: fixed;
    top: 20%;
    right: 10%;
    width: 600px;
    height: 400px;
    background: radial-gradient(ellipse, rgba(0, 120, 255, 0.04), transparent 60%);
    filter: blur(80px);
    z-index: -1;
    pointer-events: none;
    animation: systemBreathe 10s infinite alternate ease-in-out;
}

@keyframes systemBreathe {
    0% {
        opacity: 0.5;
        transform: scale(0.95);
    }

    100% {
        opacity: 0.8;
        transform: scale(1.05);
    }
}

/* Typography Hierarchy */
.sys-header-area {
    margin-bottom: 4rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 2rem;
}

.sys-id-tag {
    font-family: var(--font-mono);
    color: var(--accent-secondary);
    font-size: 0.8rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 1rem;
    display: block;
    opacity: 0;
    animation: fadeSlideRight 0.8s ease forwards 0.2s;
}

.sys-title {
    font-size: 3.5rem;
    margin: 0;
    background: linear-gradient(90deg, #fff, #889);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    opacity: 0;
    animation: fadeSlideUp 0.8s ease forwards 0.3s;
}

.sys-subtitle {
    margin-top: 1rem;
    font-size: 1.1rem;
    color: var(--text-secondary);
    max-width: 600px;
    font-family: var(--font-mono);
    opacity: 0;
    animation: fadeSlideUp 0.8s ease forwards 0.4s;
}

/* Risk Grid Layout */
.risk-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
    margin-top: 3rem;
}

.risk-card {
    background: rgba(15, 20, 25, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    /* Rigid system look */
    padding: 2rem;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;

    /* Staggered Entry */
    opacity: 0;
    transform: translateY(20px);
    animation: fadeSlideUp 0.6s ease forwards;
}

.risk-card:nth-child(1) {
    animation-delay: 0.5s;
}

.risk-card:nth-child(2) {
    animation-delay: 0.6s;
}

.risk-card:nth-child(3) {
    animation-delay: 0.7s;
}

.risk-card:hover {
    background: rgba(20, 25, 30, 0.8);
    border-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

/* Risk Level Indicators */
.risk-indicator {
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
}

.risk-card.execution .risk-indicator {
    background: var(--accent-primary);
}

.risk-card.settlement .risk-indicator {
    background: var(--accent-secondary);
}

.risk-card.oracle .risk-indicator {
    background: var(--accent-warning);
}

.risk-title {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-family: var(--font-mono);
    font-size: 0.95rem;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 1.5rem;
}

.risk-icon {
    font-size: 1.2rem;
    opacity: 0.8;
}

/* Hard Boundary Alert */
.hard-boundary-alert {
    margin-top: 4rem;
    background: repeating-linear-gradient(45deg,
            rgba(255, 0, 85, 0.05),
            rgba(255, 0, 85, 0.05) 10px,
            rgba(255, 0, 85, 0.02) 10px,
            rgba(255, 0, 85, 0.02) 20px);
    border: 1px solid rgba(255, 0, 85, 0.2);
    border-radius: 4px;
    padding: 2rem;
    position: relative;
    opacity: 0;
    animation: fadeIn 1s ease forwards 1s;
}

.boundary-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: #ff507a;
    font-family: var(--font-mono);
    font-weight: 700;
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Animations */
@keyframes fadeSlideRight {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}