:root {
    --bg-dark: #0a0a0c;
    --bg-panel: #141418;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --accent-gold: #ffd700;
    --accent-blue: #00bfff;
    --border-color: #2a2a30;
    --font-main: 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-main);
    line-height: 1.6;
    overflow-x: hidden;
}

a {
    color: var(--accent-blue);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--accent-gold);
}

/* Citation Styles */


.citation-ref:hover {
    color: var(--accent-gold);
    text-decoration: underline;
    cursor: pointer;
}

/* Standard Bibliography List */
/* Lists */
ol,
ul {
    margin-left: 2rem;
    margin-bottom: 2rem;
    color: var(--text-primary);
}

ol li,
ul li {
    padding-left: 0.5rem;
    margin-bottom: 0.5rem;
}

ol li:target,
ul li:target {
    background: rgba(255, 215, 0, 0.1);
    /* Highlight when clicked */
    padding: 0.5rem;
    border-radius: 4px;
    border-left: 3px solid var(--accent-gold);
}

/* Layout */
.layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    /* Widened from 280px */
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    background-color: var(--bg-panel);
    border-right: 1px solid var(--border-color);
    padding: 2rem;
    position: sticky;
    top: 60px;
    /* Offset for top-nav */
    height: calc(100vh - 60px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 2rem 0;
    font-size: 0.9rem;
    /* Slightly smaller text */
    display: block;
    /* Allows overflow-x on the table element itself if needed, or wrap in div */
    overflow-x: auto;
    /* Scroll horizontal if too wide */
    white-space: normal;
}

th,
td {
    padding: 0.75rem;
    /* Reduced from default if large */
    border: 1px solid var(--border-color);
    text-align: left;
    vertical-align: top;
    min-width: 120px;
    /* Prevent crushing columns */
}

th {
    background-color: var(--bg-panel);
    color: var(--accent-gold);
    font-weight: 600;
}

tr:nth-child(even) {
    background-color: rgba(255, 255, 255, 0.02);
}

/* Sidebar */
.toc a {
    color: var(--text-secondary);
    display: block;
    white-space: normal;
    /* Was nowrap */
    overflow: visible;
    /* Was hidden */
    text-overflow: clip;
    /* Was ellipsis */
    line-height: 1.4;
    font-size: 0.85rem;
}

/* Fix overlaps if header is fixed */
.sidebar {
    background-color: var(--bg-panel);
    border-right: 1px solid var(--border-color);
    padding: 2rem;
    position: sticky;
    top: 60px;
    /* Offset for top-nav overlap */
    height: calc(100vh - 60px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.brand h1 {
    font-size: 2.5rem;
    color: var(--accent-gold);
    font-weight: 800;
    letter-spacing: -2px;
}

.book-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 2rem 0;
}

.nav-item {
    color: var(--text-secondary);
    padding: 0.5rem;
    border-radius: 4px;
}

.nav-item:hover,
.nav-item.active {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.toc-container {
    flex-grow: 1;
    font-size: 0.9rem;
}

.toc ul {
    list-style: none;
}

.toc li {
    margin-bottom: 0.5rem;
}

/* Main Content */
.content {
    padding: 4rem 10%;
    max-width: 1200px;
    margin: 0 auto;
}

/* Home Page Specific */
.home-body {
    background: radial-gradient(circle at top center, #1a1a20 0%, #0a0a0c 100%);
}

.hero-section {
    min-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
}

.hero-content h1 {
    font-size: 5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #fff 0%, #a0a0a0 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    font-size: 1.5rem;
    color: var(--accent-gold);
    margin-bottom: 1rem;
    letter-spacing: 2px;
}

.tagline {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 4rem;
}

.book-grid {
    display: flex;
    gap: 2rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 4rem;
}

.book-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 2.5rem;
    border-radius: 12px;
    width: 320px;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-align: left;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.book-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05), transparent);
    transition: 0.5s;
}

.book-card:hover::before {
    left: 100%;
}

.book-card:hover {
    transform: translateY(-10px) scale(1.02);
    background: rgba(255, 255, 255, 0.07);
    border-color: var(--accent-gold);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.3), 0 0 15px rgba(255, 215, 0, 0.1);
}

.book-icon {
    font-size: 2.5rem;
    color: var(--accent-blue);
    margin-bottom: 1.5rem;
    transition: transform 0.3s;
}

.book-card:hover .book-icon {
    transform: scale(1.1);
    color: var(--accent-gold);
}

.book-card h3 {
    margin-bottom: 0.8rem;
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: 700;
}

.book-card p {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.btn-primary {
    background: var(--accent-gold);
    color: #000;
    padding: 0.8rem 2rem;
    border-radius: 4px;
    font-weight: 600;
}

.btn-secondary {
    border: 1px solid var(--text-secondary);
    color: var(--text-primary);
    padding: 0.8rem 2rem;
    border-radius: 4px;
}

/* Tables */


tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* Top Navigation */
.top-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: rgba(10, 10, 12, 0.7);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding: 1.2rem 3rem;
    z-index: 1000;
    display: flex;
    justify-content: space-between;
    align-items: center;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    transition: background 0.3s;
}

.top-nav:hover {
    background: rgba(10, 10, 12, 0.9);
}

.nav-links {
    display: flex;
    gap: 2rem;
}

.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s;
}

.nav-links a:hover {
    color: var(--accent-gold);
}

.nav-logo {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    color: #fff;
    text-decoration: none;
    font-size: 1.2rem;
}

/* Main Content */
.content {
    padding: 6rem 10% 4rem;
    max-width: 1200px;
    margin: 0 auto;
}

.chapter-header {
    margin-bottom: 3rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 2rem;
}

.chapter-header h1 {
    font-size: 3.5rem;
    font-weight: 800;
    color: var(--accent-gold);
    letter-spacing: -1px;
    border-bottom: none;
    display: inline-block;
    /* Minimalist: Solid Color, No Gradient */
}

/* Volume Description / Intro - "Arte" */
/* Volume Description / Intro - Minimalist */
.text-content>p:first-of-type {
    font-size: 1.25rem;
    line-height: 1.7;
    color: #e0e0e0;
    padding: 1.5rem 0 1.5rem 2rem;
    border-left: 2px solid var(--accent-gold);
    margin: 0 0 3rem 0;
    font-style: italic;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
}

.text-content>p:first-of-type::before {
    /* Remove giant quote for clean look */
    content: none;
}

/* Home Page */
.home-body {
    background: radial-gradient(circle at center, #1b1b22 0%, #0a0a0c 100%);
    position: relative;
    overflow-x: hidden;
}

#beta-simulator {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    opacity: 0.6;
    /* Matched to inline style */
}

.hero-section {
    position: relative;
    z-index: 1;
    min-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
    pointer-events: none;
    /* Allow clicks to pass through to canvas */
}

/* Re-enable clicks on content */
.hero-content>* {
    pointer-events: auto;
}

/* UI Toggle Button */
#ui-toggle {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 2000;
    background: rgba(255, 215, 0, 0.1);
    border: 1px solid var(--accent-gold);
    color: var(--accent-gold);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    backdrop-filter: blur(5px);
    transition: all 0.3s;
    pointer-events: auto;
}

#ui-toggle:hover {
    background: var(--accent-gold);
    color: #000;
    transform: scale(1.1);
}

.ui-hidden .hero-content,
.ui-hidden .top-nav {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

.hero-content h1 {
    font-size: 6rem;
    font-weight: 800;
    margin-bottom: 1rem;
    color: #fff;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
    animation: fadeIn 1.5s ease-out;
}

.subtitle {
    font-size: 1.8rem;
    color: var(--accent-gold);
    margin-bottom: 1rem;
    letter-spacing: 3px;
    text-transform: uppercase;
    animation: slideUp 1.5s ease-out;
}

.tagline {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 4rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.6;
}

/* Blocks & Quotes */
blockquote {
    border-left: 4px solid var(--accent-gold);
    background: rgba(255, 215, 0, 0.05);
    padding: 1.5rem;
    margin: 2rem 0;
    font-style: italic;
    border-radius: 0 8px 8px 0;
}

.alert-important {
    border-left: 4px solid #ff4d4d;
    background: rgba(255, 77, 77, 0.1);
    color: #ffcccc;
}

.alert-note {
    border-left: 4px solid var(--accent-blue);
    background: rgba(0, 191, 255, 0.1);
}

.ascii-art pre {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    line-height: 1.2;
    color: var(--accent-gold);
    background: #000;
    padding: 1rem;
    border: 1px dashed var(--border-color);
    overflow-x: auto;
    white-space: pre;
}

pre {
    background: #1e1e24;
    padding: 1.5rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 2rem 0;
    border: 1px solid var(--border-color);
}

code {
    font-family: var(--font-mono);
    color: #aaddff;
}

/* Math Containers */
.math-block {
    overflow-x: auto;
    padding: 2rem;
    text-align: center;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin: 2.5rem 0;
    font-size: 1.3rem;
    color: var(--accent-blue);
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
}

.math-block mjx-container {
    outline: none !important;
}

/* Citations */
.citation-ref {
    color: var(--accent-gold);
    border-bottom: none;
    font-size: 0.8em;
    padding: 0 2px;
}

/* Keyframes */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.text-content {
    font-size: 1.1rem;
    text-align: justify;
}

.text-content h1,
.text-content h2,
.text-content h3 {
    color: var(--text-primary);
    margin-top: 3rem;
    margin-bottom: 1.5rem;
}

.text-content p {
    margin-bottom: 1.5rem;
}

.text-content ul {
    margin-left: 2rem;
    margin-bottom: 1.5rem;
}

/* Citations & Links */
.text-content a {
    border-bottom: 1px dotted var(--accent-blue);
}

/* Mobile */
@media (max-width: 768px) {
    .layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        height: auto;
        position: relative;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .content {
        padding: 2rem;
    }
}

.mermaid {
    text-align: center;
    margin: 2rem 0;
    background: rgba(0, 0, 0, 0.2);
    padding: 1rem;
    border-radius: 8px;
    display: flex;
    justify-content: center;
}

/* Glassmorphism Utility */
.glass {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.intro-box {
    margin: 3rem auto;
    max-width: 800px;
    text-align: justify;
    padding: 2.5rem;
    border-radius: 12px;
}

/* Glitch Effect */
.glitch {
    position: relative;
    display: inline-block;
}

.glitch::before,
.glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-dark);
}

.glitch::before {
    left: 2px;
    text-shadow: -1px 0 var(--accent-gold);
    clip: rect(44px, 450px, 56px, 0);
    animation: glitch-anim-1 5s infinite linear alternate-reverse;
}

.glitch::after {
    left: -2px;
    text-shadow: -1px 0 var(--accent-blue);
    clip: rect(44px, 450px, 56px, 0);
    animation: glitch-anim-2 5s infinite linear alternate-reverse;
}

@keyframes glitch-anim-1 {
    0% {
        clip: rect(30px, 9999px, 10px, 0);
    }

    5% {
        clip: rect(70px, 9999px, 90px, 0);
    }

    10% {
        clip: rect(55px, 9999px, 15px, 0);
    }

    15% {
        clip: rect(10px, 9999px, 40px, 0);
    }

    20% {
        clip: rect(80px, 9999px, 5px, 0);
    }

    25% {
        clip: rect(35px, 9999px, 60px, 0);
    }

    100% {
        clip: rect(30px, 9999px, 10px, 0);
    }
}

@keyframes glitch-anim-2 {
    0% {
        clip: rect(15px, 9999px, 70px, 0);
    }

    5% {
        clip: rect(50px, 9999px, 30px, 0);
    }

    10% {
        clip: rect(25px, 9999px, 85px, 0);
    }

    15% {
        clip: rect(60px, 9999px, 20px, 0);
    }

    20% {
        clip: rect(5px, 9999px, 65px, 0);
    }

    25% {
        clip: rect(90px, 9999px, 45px, 0);
    }

    100% {
        clip: rect(15px, 9999px, 70px, 0);
    }
}

/* Scroll Indicator */
.scroll-indicator {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    animation: bounce 2s infinite;
    opacity: 0.7;
    cursor: pointer;
}

.scroll-indicator i {
    font-size: 2rem;
    color: var(--text-secondary);
}

@keyframes bounce {

    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translate(-50%, 0);
    }

    40% {
        transform: translate(-50%, -10px);
    }

    60% {
        transform: translate(-50%, -5px);
    }
}

/* Index Columns Grid */
.index-columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.index-col {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    border-radius: 8px;
    transition: 0.3s;
}

.index-col:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--accent-gold);
}

.index-col h3 a {
    color: var(--accent-gold);
    font-size: 1.2rem;
    display: block;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.index-col ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.index-col li {
    margin-bottom: 0.5rem;
    padding-left: 0;
}

.index-col li a {
    color: var(--text-secondary);
    font-size: 0.9rem;
    transition: 0.2s;
}

.index-col li a:hover {
    color: var(--text-primary);
    padding-left: 5px;
}

/* --- Trigger Overlay (Phase 2) --- */
#trigger-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    /* Let clicks pass to canvas */
    z-index: 5;
    /* Above canvas (0) and hero (1), below Nav (1000) */
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.trigger-text {
    font-family: var(--font-mono);
    font-weight: 800;
    font-size: 3rem;
    color: rgba(255, 255, 255, 0.9);
    text-transform: uppercase;
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.8);
    position: absolute;
    opacity: 0;
    transition: opacity 0.3s ease;
    text-align: center;
}

.trigger-text.active {
    opacity: 1;
}

/* Individual Trigger Styles */
.trigger-entropy {
    color: #ff4d4d;
    /* Red for Chaos */
    font-size: 4rem;
    letter-spacing: -2px;
}

.trigger-density {
    color: var(--accent-gold);
    /* Gold for Unity */
    font-size: 2.5rem;
    letter-spacing: 5px;
    background: rgba(0, 0, 0, 0.5);
    padding: 1rem 2rem;
    backdrop-filter: blur(4px);
}

.trigger-cursor {
    font-size: 1rem;
    pointer-events: none;
    position: absolute;
    /* Controlled by JS */
    color: var(--accent-blue);
    border: 1px solid var(--accent-blue);
    padding: 0.2rem 0.5rem;
    background: rgba(0, 0, 0, 0.8);
    white-space: nowrap;
    white-space: nowrap;
}

/* --- Web Vitals & UX Tools --- */

/* Reading Progress Bar */
#reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-gold), var(--accent-blue));
    z-index: 1000;
    transition: width 0.1s ease;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

/* Back to Top Button */
#back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: rgba(10, 10, 12, 0.8);
    border: 1px solid var(--accent-gold);
    border-radius: 50%;
    color: var(--accent-gold);
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 999;
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
}

#back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

#back-to-top:hover {
    background: var(--accent-gold);
    color: var(--bg-dark);
    transform: translateY(-5px);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.4);
}