/* ========================================
   xanadu.wiki - styles.css
   Palette:
     Terminal Dark:    #0A0E14
     Reading Surface:  #FAFAF6
     Sidebar Warm:     #F0EDE4
     Ink Black:        #1C1E22
     Link Blue:        #4A90D9
     Highlight Amber:  #D4A84A
     Active Green:     #4ACA6A
     Muted Reference:  #6B7280
   Fonts: JetBrains Mono 500, Merriweather 400/i, Space Grotesk 500
======================================== */

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Merriweather', Georgia, serif;
    font-weight: 400;
    color: #1C1E22;
    background: #FAFAF6;
    line-height: 1.75;
    font-size: 1rem;
    overflow-x: hidden;
}

/* ---- SCROLL PROGRESS BAR ---- */

.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    background: #4ACA6A;
    z-index: 1000;
    width: 0%;
    transition: width 0.1s linear;
}

/* ---- BOOT HEADER ---- */

.boot-header {
    background: #0A0E14;
    padding: 3rem 2rem;
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: min-height 0.3s ease, padding 0.3s ease;
}

.boot-header.collapsed {
    min-height: 48px;
    padding: 0.5rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.boot-header.collapsed .boot-line {
    display: none;
}

.boot-header.collapsed .line-1 {
    display: inline;
    font-size: 0.85rem;
    animation: none;
    width: auto;
}

.boot-sequence {
    max-width: 600px;
}

.boot-line {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 500;
    color: #4ACA6A;
    font-size: 0.85rem;
    letter-spacing: 0.02em;
    overflow: hidden;
    white-space: nowrap;
    width: 0;
}

.line-1 {
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    animation: type 1.5s steps(11) 0.2s forwards;
}

.line-2 {
    animation: type 1s steps(28) 1.8s forwards;
    color: #6B7280;
}

.line-3 {
    animation: type 1.2s steps(32) 2.9s forwards;
    color: #6B7280;
}

.line-4 {
    animation: type 0.5s steps(6) 4.2s forwards;
}

@keyframes type {
    from { width: 0; }
    to { width: 100%; }
}

.cursor-blink {
    display: inline-block;
    width: 0.6em;
    height: 1em;
    border-right: 2px solid #4ACA6A;
    animation: blink 1s step-end infinite 4.8s;
    vertical-align: text-bottom;
}

@keyframes blink {
    0%, 100% { border-color: #4ACA6A; }
    50% { border-color: transparent; }
}

/* ---- LINK OVERLAY ---- */

.link-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
}

/* ---- BROWSER LAYOUT ---- */

.browser {
    display: flex;
    max-width: 1200px;
    margin: 0 auto;
    min-height: 340vh;
}

/* ---- SIDEBAR ---- */

.sidebar {
    width: 280px;
    flex-shrink: 0;
    background: #F0EDE4;
    padding: 2rem 1.5rem;
    position: sticky;
    top: 48px;
    height: calc(100vh - 48px);
    overflow-y: auto;
    border-right: 1px solid rgba(200, 200, 192, 0.5);
}

.toc-list {
    list-style: none;
}

.toc-item {
    display: block;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 500;
    font-size: 0.85rem;
    letter-spacing: 0.02em;
    color: #6B7280;
    text-decoration: none;
    padding: 0.75rem 0.75rem;
    border-left: 3px solid transparent;
    transition: color 0.2s ease, border-color 0.2s ease;
}

.toc-item:hover {
    color: #1C1E22;
}

.toc-item.active {
    color: #4ACA6A;
    border-left-color: #4ACA6A;
}

/* ---- READING PANE ---- */

.reading-pane {
    flex: 1;
    padding: 3rem clamp(2rem, 4vw, 4rem);
}

.wiki-section {
    margin-bottom: 1rem;
}

.section-title {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: clamp(1.5rem, 3vw, 2.2rem);
    color: #1C1E22;
    margin-bottom: 1.5rem;
    letter-spacing: 0.02em;
}

.subsection-title {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: 1.1rem;
    color: #1C1E22;
    margin: 1.5rem 0 0.75rem;
    letter-spacing: 0.02em;
}

.reading-pane p {
    margin-bottom: 1.5em;
    font-size: 1rem;
    line-height: 1.75;
}

/* ---- TERM HIGHLIGHTS ---- */

.term-highlight {
    background: linear-gradient(transparent 60%, rgba(212, 168, 74, 0.25) 60%);
    padding: 0 2px;
}

/* ---- CROSS-REFERENCES ---- */

.cross-ref {
    color: #4A90D9;
    text-decoration: none;
    border-bottom: 1px solid #4A90D9;
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease;
}

.cross-ref:hover {
    color: #3070b8;
    border-bottom-color: #3070b8;
}

/* ---- PRIMARY SOURCES ---- */

.primary-source {
    font-style: italic;
    border-left: 3px solid #D4A84A;
    padding: 1rem 1.5rem;
    margin: 1.5rem 0 1.5rem 1rem;
    color: #1C1E22;
    background: rgba(212, 168, 74, 0.05);
    font-size: 0.95rem;
    line-height: 1.7;
}

.primary-source cite {
    font-style: normal;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: 0.85rem;
}

/* ---- SEE ALSO ---- */

.see-also {
    margin-top: 1.5rem;
    padding: 1rem;
    background: rgba(240, 237, 228, 0.5);
    border: 1px solid rgba(200, 200, 192, 0.3);
}

.see-also-label {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: 0.8rem;
    color: #6B7280;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-right: 0.5rem;
}

/* ---- PERFORATED DIVIDER ---- */

.perforated-divider {
    border-top: 2px dashed #C8C8C0;
    margin: 3rem 0;
    position: relative;
}

.perforated-divider::before,
.perforated-divider::after {
    content: '';
    position: absolute;
    top: -5px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #FAFAF6;
    border: 1px solid #C8C8C0;
}

.perforated-divider::before { left: -4px; }
.perforated-divider::after { right: -4px; }

/* ---- COLOPHON ---- */

.colophon {
    background: #0A0E14;
    padding: 3rem 2rem;
}

.colophon-divider {
    border-top-color: #2a2e34;
    margin-bottom: 2rem;
}

.colophon-divider::before,
.colophon-divider::after {
    background: #0A0E14;
    border-color: #2a2e34;
}

.colophon-content {
    max-width: 600px;
    margin: 0 auto;
    text-align: center;
}

.colophon-line {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 500;
    font-size: 0.75rem;
    color: #6B7280;
    letter-spacing: 0.02em;
    margin-bottom: 0.3rem;
}

.colophon-line.muted {
    color: rgba(107, 114, 128, 0.5);
    margin-top: 1rem;
}

/* ---- RESPONSIVE ---- */

@media (max-width: 900px) {
    .browser {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        position: static;
        height: auto;
        border-right: none;
        border-bottom: 1px solid rgba(200, 200, 192, 0.5);
        padding: 1.5rem;
    }

    .toc-list {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .toc-item {
        border-left: none;
        border-bottom: 2px solid transparent;
        padding: 0.5rem 0.75rem;
    }

    .toc-item.active {
        border-bottom-color: #4ACA6A;
        border-left: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .boot-line {
        width: 100%;
    }
}
