/* ==========================================================================
   opensource.bar — holographic formalism
   palette: analogous (blue / violet / magenta on near-black)
   typography: Libre Baskerville (literary) + Space Mono (technical)
   ========================================================================== */

@property --holo-angle {
    syntax: '<angle>';
    inherits: false;
    initial-value: 0deg;
}

:root {
    --base-dark: #0D0D14;
    --surface-dark: #161622;
    --spec-violet: #7B5EA7;
    --spec-blue: #4A6FA5;
    --spec-magenta: #A5547B;
    --text-primary: #D4D0E0;
    --text-secondary: #8A85A0;
    --holo-highlight: #C4B5E3;

    --sidebar-w: 280px;
    --content-pad-x: 80px;
    --content-max: 720px;

    --font-serif: "Libre Baskerville", "Source Serif Pro", Georgia, serif;
    --font-mono: "Space Mono", "JetBrains Mono", "IBM Plex Mono", ui-monospace, monospace;

    --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--base-dark);
    color: var(--text-primary);
    font-family: var(--font-serif);
    font-size: 18px;
    line-height: 1.72;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

body {
    min-height: 100vh;
    position: relative;
}

/* Holographic shimmer environmental layer */
body::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    background: conic-gradient(
        from var(--holo-angle),
        var(--spec-violet),
        var(--spec-blue),
        var(--spec-magenta),
        var(--holo-highlight),
        var(--spec-violet)
    );
    background-size: 200% 200%;
    background-position: center;
    opacity: 0.04;
    mix-blend-mode: overlay;
    animation: holoRotate 30s linear infinite;
}

@keyframes holoRotate {
    from { --holo-angle: 0deg; }
    to   { --holo-angle: 360deg; }
}

/* fallback: no @property -> animate via background-position */
@supports not (background: paint(something)) {
    body::after {
        background: conic-gradient(from 135deg, var(--spec-violet), var(--spec-blue), var(--spec-magenta), var(--holo-highlight), var(--spec-violet));
        animation: holoShift 30s linear infinite;
    }
    @keyframes holoShift {
        from { transform: rotate(0deg); }
        to { transform: rotate(360deg); }
    }
}

::selection {
    background: rgba(196, 181, 227, 0.3);
    color: var(--holo-highlight);
}

.svg-defs {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* ==========================================================================
   Sidebar — the bar counter
   ========================================================================== */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--base-dark);
    z-index: 50;
    border-right: 1px solid var(--spec-violet);
    border-image: linear-gradient(
        to bottom,
        var(--spec-violet) 0%,
        var(--spec-blue) 50%,
        var(--spec-magenta) 100%
    ) 1;
    animation: spectralBorder 20s linear infinite;
    overflow: hidden;
}

@keyframes spectralBorder {
    0%   { border-image-source: linear-gradient(to bottom, var(--spec-violet), var(--spec-blue), var(--spec-magenta)); }
    33%  { border-image-source: linear-gradient(to bottom, var(--spec-blue), var(--spec-magenta), var(--spec-violet)); }
    66%  { border-image-source: linear-gradient(to bottom, var(--spec-magenta), var(--spec-violet), var(--spec-blue)); }
    100% { border-image-source: linear-gradient(to bottom, var(--spec-violet), var(--spec-blue), var(--spec-magenta)); }
}

.sidebar::before {
    content: "";
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.92' numOctaves='2' stitchTiles='stitch' seed='3'/><feColorMatrix values='0 0 0 0 0.77 0 0 0 0 0.71 0 0 0 0 0.89 0 0 0 0.08 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
    background-size: 240px 240px;
    opacity: 0.5;
    pointer-events: none;
    mix-blend-mode: screen;
}

.sidebar-inner {
    position: relative;
    z-index: 1;
    height: 100%;
    padding: 32px 24px 24px;
    display: flex;
    flex-direction: column;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-primary);
    margin-bottom: 40px;
}

.brand-mark {
    width: 36px;
    height: 18px;
    flex-shrink: 0;
    overflow: visible;
}

.brand-mark path {
    transition: stroke 0.6s var(--ease);
}

.brand:hover .brand-mark path:nth-child(1) {
    stroke: var(--holo-highlight);
}

.brand-text {
    font-family: var(--font-serif);
    font-weight: 700;
    font-size: 17px;
    letter-spacing: -0.01em;
    line-height: 1;
}

.brand-dot {
    color: var(--spec-magenta);
    font-weight: 700;
}

.sidenav {
    flex: 0 0 auto;
}

.sidenav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidenav li {
    margin-bottom: 4px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 10px;
    text-decoration: none;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border-left: 1px solid transparent;
    transition: color 0.25s var(--ease), border-color 0.25s var(--ease), background 0.25s var(--ease);
    position: relative;
}

.nav-link:hover {
    color: var(--text-primary);
    border-left-color: var(--spec-blue);
    background: linear-gradient(90deg, rgba(123, 94, 167, 0.08) 0%, transparent 80%);
}

.nav-link.active {
    color: var(--holo-highlight);
    border-left-color: var(--spec-violet);
    background: linear-gradient(90deg, rgba(123, 94, 167, 0.16) 0%, transparent 80%);
}

.wave-glyph {
    width: 24px;
    height: 12px;
    color: var(--spec-blue);
    flex-shrink: 0;
    overflow: visible;
}

.nav-link.active .wave-glyph {
    color: var(--holo-highlight);
    animation: glyphPulse 2.4s ease-in-out infinite;
}

.nav-link:hover .wave-glyph {
    color: var(--spec-violet);
}

.nav-link:hover .wave-sine path {
    d: path("M0 6 L3 6 L3 1 L9 1 L9 11 L15 11 L15 1 L21 1 L21 6 L24 6");
    transition: d 0.3s var(--ease);
}

@keyframes glyphPulse {
    0%, 100% { transform: scaleY(1); opacity: 1; }
    50%      { transform: scaleY(1.4); opacity: 0.8; }
}

.nav-label {
    font-weight: 400;
}

/* scrollscope (mini waveform tracking scroll depth) */
.sidebar-scrollscope {
    margin-top: auto;
    margin-bottom: 24px;
    padding: 16px 4px;
    border-top: 1px solid rgba(196, 181, 227, 0.1);
    border-bottom: 1px solid rgba(196, 181, 227, 0.1);
}

.scrollscope-label {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.scrollscope-wave {
    width: 100%;
    height: 36px;
    display: block;
}

.scrollscope-wave path {
    transition: stroke 0.6s var(--ease);
}

.scrollscope-readout {
    margin-top: 6px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--holo-highlight);
    letter-spacing: 0.08em;
}

.scrollscope-readout span {
    display: inline-block;
    min-width: 32px;
}

/* status indicator */
.sidebar-status {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-top: 16px;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--holo-highlight);
    box-shadow: 0 0 0 0 rgba(196, 181, 227, 0.6);
    animation: statusPulse 2s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes statusPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(196, 181, 227, 0.55);
        background: var(--holo-highlight);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(196, 181, 227, 0);
        background: var(--spec-violet);
    }
}

.status-label {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--holo-highlight);
}

.status-meta {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-secondary);
    letter-spacing: 0.05em;
    margin-top: 2px;
}

/* mobile bottom-bar nav */
.mobilenav {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 56px;
    background: var(--base-dark);
    border-top: 1px solid var(--spec-violet);
    z-index: 60;
    justify-content: space-around;
    align-items: center;
    padding: 0 8px;
}

.mnav-link {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    width: 44px;
    height: 44px;
    transition: color 0.2s var(--ease);
}

.mnav-link svg {
    width: 26px;
    height: 14px;
}

.mnav-link.active {
    color: var(--holo-highlight);
}

/* ==========================================================================
   Main content
   ========================================================================== */

.content {
    margin-left: var(--sidebar-w);
    width: calc(100vw - var(--sidebar-w));
    position: relative;
    z-index: 1;
}

.chapter {
    position: relative;
    min-height: 100vh;
    padding: 120px 64px 100px var(--content-pad-x);
    display: flex;
    flex-direction: column;
    justify-content: center;
    isolation: isolate;
}

.chapter-noise {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    mix-blend-mode: screen;
}

.chapter[data-noise="fine"] .chapter-noise {
    background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='320' height='320'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.92' numOctaves='2' stitchTiles='stitch' seed='3'/><feColorMatrix values='0 0 0 0 0.77 0 0 0 0 0.71 0 0 0 0 0.89 0 0 0 0.08 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
    background-size: 320px 320px;
    opacity: 0.55;
}

.chapter[data-noise="medium"] .chapter-noise {
    background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='320' height='320'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='2' stitchTiles='stitch' seed='7'/><feColorMatrix values='0 0 0 0 0.77 0 0 0 0 0.71 0 0 0 0 0.89 0 0 0 0.12 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
    background-size: 320px 320px;
    opacity: 0.7;
}

.chapter[data-noise="coarse"] .chapter-noise {
    background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='320' height='320'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.40' numOctaves='3' stitchTiles='stitch' seed='11'/><feColorMatrix values='0 0 0 0 0.77 0 0 0 0 0.71 0 0 0 0 0.89 0 0 0 0.18 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
    background-size: 320px 320px;
    opacity: 0.85;
}

.chapter-inner {
    position: relative;
    z-index: 2;
    max-width: var(--content-max);
    width: 100%;
}

.chapter-projects .chapter-inner,
.chapter-community .chapter-inner,
.chapter-terminal .chapter-inner {
    max-width: 880px;
}

/* chapter meta header */
.chapter-meta {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 40px;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.meta-num {
    color: var(--spec-violet);
}

.meta-divider {
    flex: 0 0 60px;
    height: 1px;
    background: linear-gradient(to right, var(--spec-violet), transparent);
}

/* chapter title shared */
.chapter-title {
    font-family: var(--font-serif);
    font-weight: 700;
    font-size: clamp(36px, 4.5vw, 56px);
    line-height: 1.12;
    letter-spacing: -0.02em;
    margin: 0 0 32px;
    color: var(--text-primary);
}

.lede {
    font-size: 21px;
    line-height: 1.6;
    color: var(--text-secondary);
    margin: 0 0 56px;
    max-width: 640px;
}

/* ==========================================================================
   Chapter 00 — Hero
   ========================================================================== */

.chapter-hero {
    overflow: hidden;
}

.hero-bgwave {
    position: absolute;
    top: 50%;
    left: -10%;
    width: 220%;
    height: 60%;
    transform: translateY(-50%);
    z-index: 0;
    pointer-events: none;
    animation: heroDrift 60s linear infinite;
}

@keyframes heroDrift {
    from { transform: translate(0, -50%); }
    to   { transform: translate(-15%, -50%); }
}

.hero-title {
    font-family: var(--font-serif);
    font-weight: 700;
    font-size: clamp(64px, 11vw, 144px);
    line-height: 0.92;
    letter-spacing: -0.04em;
    margin: 0 0 24px;
    background: linear-gradient(
        110deg,
        var(--holo-highlight) 0%,
        var(--spec-violet) 30%,
        var(--spec-blue) 55%,
        var(--spec-magenta) 80%,
        var(--holo-highlight) 100%
    );
    background-size: 200% 200%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    animation: heroHolo 12s ease-in-out infinite;
    text-shadow: none;
    display: inline-block;
}

@keyframes heroHolo {
    0%, 100% { background-position: 0% 50%; }
    50%      { background-position: 100% 50%; }
}

.hero-line {
    display: inline;
}

.hero-dot {
    display: inline-block;
    background: var(--spec-magenta);
    -webkit-text-fill-color: var(--spec-magenta);
    color: var(--spec-magenta);
    -webkit-background-clip: initial;
    background-clip: initial;
    text-shadow: 0 0 14px rgba(165, 84, 123, 0.55);
    margin: 0 -0.04em;
}

.hero-tagline {
    font-family: var(--font-serif);
    font-style: italic;
    font-size: clamp(20px, 2.4vw, 28px);
    line-height: 1.55;
    color: var(--holo-highlight);
    max-width: 620px;
    margin: 0 0 48px;
}

.hero-blurb {
    max-width: 600px;
    margin-bottom: 64px;
}

.hero-blurb p {
    margin: 0;
    font-size: 18px;
    line-height: 1.78;
    color: var(--text-primary);
}

.hero-foot {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 32px;
    max-width: 720px;
    padding-top: 32px;
    border-top: 1px solid rgba(196, 181, 227, 0.14);
}

.foot-col {
    font-family: var(--font-mono);
}

.foot-label {
    font-size: 10px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.foot-value {
    font-size: 13px;
    color: var(--holo-highlight);
    letter-spacing: 0.02em;
}

/* ==========================================================================
   Chapter dividers (waveform bands between chapters)
   ========================================================================== */

.chapter-divider {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 60px;
    pointer-events: none;
    z-index: 3;
    overflow: hidden;
}

.chapter-divider svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* ==========================================================================
   Chapter 01 — Philosophy
   ========================================================================== */

.prose p {
    font-size: 18px;
    line-height: 1.78;
    color: var(--text-primary);
    margin: 0 0 24px;
    max-width: 640px;
}

.prose p:last-child {
    margin-bottom: 0;
}

.pullquote {
    margin: 56px 0;
    padding: 8px 36px;
    border-left: 2px solid var(--spec-magenta);
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 28px;
    line-height: 1.55;
    color: var(--holo-highlight);
    max-width: 640px;
    position: relative;
}

.pullquote::after {
    content: "";
    position: absolute;
    left: -2px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(to bottom, var(--spec-violet), var(--spec-magenta), var(--spec-blue));
    background-size: 100% 200%;
    animation: quoteBorder 8s linear infinite;
}

@keyframes quoteBorder {
    0%, 100% { background-position: 0% 0%; }
    50%      { background-position: 0% 100%; }
}

.tenets {
    margin-top: 72px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 28px;
    border-top: 1px solid rgba(196, 181, 227, 0.12);
    padding-top: 40px;
}

@media (min-width: 720px) {
    .tenets {
        grid-template-columns: 1fr 1fr;
        gap: 40px 56px;
    }
}

.tenet {
    display: flex;
    gap: 18px;
    align-items: flex-start;
}

.tenet-num {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--spec-violet);
    letter-spacing: 0.04em;
    padding-top: 6px;
    min-width: 28px;
}

.tenet-body h3 {
    font-family: var(--font-serif);
    font-weight: 700;
    font-size: 19px;
    line-height: 1.3;
    color: var(--holo-highlight);
    margin: 0 0 8px;
    letter-spacing: -0.01em;
}

.tenet-body p {
    margin: 0;
    font-size: 15px;
    line-height: 1.65;
    color: var(--text-primary);
}

/* ==========================================================================
   Chapter 02 — Projects
   ========================================================================== */

.projects {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
    border-top: 1px solid rgba(196, 181, 227, 0.12);
}

.project {
    border-bottom: 1px solid rgba(196, 181, 227, 0.12);
    transition: background 0.3s var(--ease);
}

.project-row {
    display: grid;
    grid-template-columns: 100px 1fr;
    gap: 32px;
    padding: 32px 0;
    align-items: flex-start;
}

@media (max-width: 720px) {
    .project-row {
        grid-template-columns: 64px 1fr;
        gap: 20px;
        padding: 24px 0;
    }
}

.project-mark {
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

.project-mark svg {
    width: 80px;
    height: 40px;
    overflow: visible;
}

.project-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.proj-id {
    color: var(--spec-violet);
}

.proj-version {
    color: var(--spec-magenta);
    margin-left: auto;
}

.project-title {
    font-family: var(--font-serif);
    font-weight: 700;
    font-size: 32px;
    line-height: 1.2;
    letter-spacing: -0.02em;
    margin: 0 0 12px;
    color: var(--holo-highlight);
    position: relative;
    transition: color 0.2s var(--ease);
}

.project-desc {
    font-size: 17px;
    line-height: 1.7;
    color: var(--text-primary);
    margin: 0 0 16px;
    max-width: 600px;
}

.project-foot {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.04em;
}

.proj-stat {
    color: var(--spec-blue);
    background: rgba(74, 111, 165, 0.08);
    padding: 6px 10px;
    border-left: 2px solid var(--spec-blue);
}

.proj-link {
    color: var(--text-secondary);
    margin-left: auto;
    transition: color 0.2s var(--ease);
}

/* glitch hover (RGB-channel split) */
.project:hover {
    background: rgba(123, 94, 167, 0.04);
}

.project:hover .project-title {
    animation: titleGlitch 240ms steps(2, end) 1;
    color: var(--holo-highlight);
}

@keyframes titleGlitch {
    0% {
        text-shadow: 0 0 0 transparent;
        transform: translateX(0);
    }
    20% {
        text-shadow: -2px 0 0 var(--spec-magenta), 2px 0 0 var(--spec-blue);
        transform: translateX(-1px);
    }
    40% {
        text-shadow: 2px 0 0 var(--spec-violet), -2px 0 0 var(--spec-blue);
        transform: translateX(1px);
    }
    60% {
        text-shadow: -3px 0 0 var(--spec-magenta), 3px 0 0 var(--holo-highlight);
        transform: translateX(-1px);
    }
    80% {
        text-shadow: 1px 0 0 var(--spec-blue), -1px 0 0 var(--spec-magenta);
        transform: translateX(0.5px);
    }
    100% {
        text-shadow: 0 0 0 transparent;
        transform: translateX(0);
    }
}

.project:hover .proj-link {
    color: var(--holo-highlight);
}

.project:hover .project-mark svg path {
    stroke: var(--holo-highlight);
}

/* ==========================================================================
   Chapter 03 — Community
   ========================================================================== */

.contributors {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 32px 40px;
    margin-bottom: 80px;
}

.contributor {
    display: flex;
    gap: 18px;
    align-items: flex-start;
}

.avatar {
    width: 64px;
    height: 64px;
    flex-shrink: 0;
    background: var(--surface-dark);
    padding: 4px;
    border: 1px solid rgba(196, 181, 227, 0.1);
    transition: border-color 0.3s var(--ease);
}

.contributor:hover .avatar {
    border-color: var(--spec-violet);
}

.contrib-handle {
    font-family: var(--font-mono);
    font-size: 14px;
    color: var(--holo-highlight);
    letter-spacing: 0.02em;
    margin-bottom: 4px;
}

.contrib-role {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.14em;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.contrib-line {
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 15px;
    line-height: 1.55;
    color: var(--text-primary);
    margin: 0;
}

.discussion {
    border: 1px solid rgba(196, 181, 227, 0.12);
    background: var(--surface-dark);
    padding: 28px 32px;
    position: relative;
}

.discussion::before {
    content: "";
    position: absolute;
    top: -1px;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--spec-violet), var(--spec-blue), var(--spec-magenta), transparent);
}

.discussion-head {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.disc-label {
    color: var(--spec-blue);
}

.thread-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.thread {
    display: grid;
    grid-template-columns: 60px 140px 1fr;
    gap: 16px;
    align-items: baseline;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.5;
    padding: 6px 0;
    border-bottom: 1px dashed rgba(196, 181, 227, 0.08);
}

.thread:last-child {
    border-bottom: none;
}

.thread-time {
    color: var(--spec-blue);
    font-size: 12px;
    letter-spacing: 0.04em;
}

.thread-author {
    color: var(--spec-violet);
}

.thread-msg {
    color: var(--text-primary);
    font-family: var(--font-serif);
    font-size: 16px;
    line-height: 1.55;
}

@media (max-width: 720px) {
    .thread {
        grid-template-columns: 50px 1fr;
    }
    .thread-author {
        grid-column: 2;
    }
    .thread-msg {
        grid-column: 1 / -1;
    }
}

/* ==========================================================================
   Chapter 04 — Terminal
   ========================================================================== */

.terminal {
    background: var(--surface-dark);
    border: 1px solid rgba(196, 181, 227, 0.14);
    border-radius: 0;
    margin: 16px 0 56px;
    overflow: hidden;
    position: relative;
    box-shadow:
        inset 0 0 60px rgba(13, 13, 20, 0.6),
        0 24px 60px -24px rgba(0, 0, 0, 0.6);
}

.terminal::before {
    content: "";
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0,
        transparent 2px,
        rgba(196, 181, 227, 0.025) 2px,
        rgba(196, 181, 227, 0.025) 3px
    );
    pointer-events: none;
    z-index: 2;
}

.term-chrome {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--base-dark);
    border-bottom: 1px solid rgba(196, 181, 227, 0.1);
    position: relative;
    z-index: 3;
}

.term-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dot-violet { background: var(--spec-violet); }
.dot-blue   { background: var(--spec-blue); }
.dot-mag    { background: var(--spec-magenta); }

.term-title {
    margin-left: 16px;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
}

.term-screen {
    padding: 24px 28px 32px;
    font-family: var(--font-mono);
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-primary);
    position: relative;
    z-index: 1;
    min-height: 280px;
}

.term-line {
    margin-bottom: 4px;
    word-break: break-word;
}

.term-prompt {
    color: var(--spec-violet);
}

.term-sep {
    color: var(--text-secondary);
}

.term-path {
    color: var(--spec-blue);
}

.term-cmd {
    color: var(--holo-highlight);
}

.term-out {
    color: var(--text-primary);
    padding-left: 0;
}

.term-out kbd {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 11px;
    background: rgba(123, 94, 167, 0.14);
    color: var(--holo-highlight);
    padding: 2px 6px;
    border: 1px solid rgba(123, 94, 167, 0.4);
    margin: 0 2px;
    letter-spacing: 0.04em;
}

.term-cursor {
    display: inline-block;
    color: var(--holo-highlight);
    margin-left: 2px;
    animation: cursorBlink 1.06s step-end infinite;
    font-size: 14px;
    line-height: 1;
    transform: translateY(-1px);
}

@keyframes cursorBlink {
    0%, 50% { opacity: 1; }
    50.01%, 100% { opacity: 0; }
}

.closing {
    border-top: 1px solid rgba(196, 181, 227, 0.12);
    padding-top: 32px;
    margin-top: 24px;
}

.closing-line {
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 22px;
    line-height: 1.55;
    color: var(--holo-highlight);
    margin: 0 0 24px;
    max-width: 600px;
}

.closing-meta {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.closing-build {
    color: var(--spec-blue);
}

/* ==========================================================================
   Reveal animation (scroll-triggered)
   ========================================================================== */

.reveal {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 600ms var(--ease), transform 600ms var(--ease);
    will-change: opacity, transform;
}

.reveal.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* scroll micro-glitch — 100ms horizontal jitter as element enters */
.reveal.is-glitching {
    animation: microGlitch 100ms steps(2, end) 1;
}

@keyframes microGlitch {
    0%   { transform: translate(0, 20px); }
    50%  { transform: translate(2px, 10px); }
    100% { transform: translate(0, 0); }
}

/* ==========================================================================
   Page transition glitch overlay
   ========================================================================== */

.page-glitch {
    position: fixed;
    inset: 0;
    z-index: 200;
    pointer-events: none;
    opacity: 0;
    background:
        repeating-linear-gradient(
            to bottom,
            rgba(123, 94, 167, 0.08) 0,
            rgba(123, 94, 167, 0.08) 2px,
            transparent 2px,
            transparent 5px
        ),
        linear-gradient(180deg, rgba(196, 181, 227, 0.08) 0%, rgba(165, 84, 123, 0.06) 50%, rgba(74, 111, 165, 0.06) 100%);
    mix-blend-mode: screen;
    transition: opacity 60ms linear;
}

.page-glitch.is-firing {
    animation: pageGlitchSweep 150ms steps(3, end) 1;
}

@keyframes pageGlitchSweep {
    0%   { opacity: 0; transform: translateY(-100%); }
    20%  { opacity: 1; transform: translateY(-40%); }
    50%  { opacity: 0.85; transform: translateY(0); }
    80%  { opacity: 0.5; transform: translateY(40%); }
    100% { opacity: 0; transform: translateY(100%); }
}

/* ==========================================================================
   Responsive — sidebar collapses to bottom bar under 768px
   ========================================================================== */

@media (max-width: 880px) {
    :root {
        --content-pad-x: 32px;
    }
    .chapter {
        padding: 96px 32px 88px 32px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        display: none;
    }
    .mobilenav {
        display: flex;
    }
    .content {
        margin-left: 0;
        width: 100%;
        padding-bottom: 56px;
    }
    .chapter {
        padding: 96px 24px 80px;
    }
    .hero-foot {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    .pullquote {
        font-size: 22px;
        padding: 4px 24px;
    }
    .project-title {
        font-size: 26px;
    }
    .closing-line {
        font-size: 18px;
    }
    .term-screen {
        font-size: 12px;
        padding: 20px 18px 28px;
    }
}
