:root {
    --bg: #0B0C0F;
    --bg-alt: #111318;
    --bg-raised: #15181E;
    --text-primary: #EAEAEA;
    --text-secondary: #9CA3AF;
    --text-muted: #6B7280;
    --accent: #8B1E2D;
    --accent-bright: #C0394D;
    --accent-soft: rgba(139, 30, 45, 0.16);
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border: rgba(255, 255, 255, 0.11);

    --serif: 'Libre Baskerville', Georgia, serif;
    --sans: 'Inter', system-ui, sans-serif;
    --gutter: 48px;
}

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

html {
    scroll-behavior: smooth;
}

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

a {
    color: inherit;
}

::selection {
    background: var(--accent);
    color: #fff;
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: 12px;
    z-index: 200;
    background: var(--accent);
    color: #fff;
    padding: 8px 14px;
    border-radius: 4px;
}

.skip-link:focus {
    left: 12px;
}

/* ---------- Header ---------- */

.site-header {
    width: 100%;
    padding: 22px var(--gutter);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    position: fixed;
    top: 0;
    background: rgba(11, 12, 15, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-subtle);
    z-index: 100;
}

.logo {
    font-family: var(--serif);
    font-size: 20px;
    letter-spacing: 0.5px;
    text-decoration: none;
    white-space: nowrap;
}

.site-header nav {
    display: flex;
    gap: 28px;
}

.site-header nav a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    white-space: nowrap;
    padding: 4px 0;
    border-bottom: 1px solid transparent;
    transition: color 0.2s, border-color 0.2s;
}

.site-header nav a:hover {
    color: var(--text-primary);
}

.site-header nav a[aria-current="page"] {
    color: var(--text-primary);
    border-bottom-color: var(--accent-bright);
}

/* ---------- Home hero ---------- */

.hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 120px 24px 80px;
    position: relative;
    overflow: hidden;
}

.hero::before,
.hero::after,
.page-hero::before {
    content: "";
    position: absolute;
    inset: -30%;
    pointer-events: none;
    z-index: 0;
}

/* Primary moving layer */
.hero::before {
    background:
        radial-gradient(circle at 20% 30%, rgba(180, 40, 60, 0.2), transparent 35%),
        radial-gradient(circle at 75% 25%, rgba(150, 30, 50, 0.2), transparent 40%),
        radial-gradient(circle at 60% 70%, rgba(170, 35, 55, 0.2), transparent 40%);
    filter: blur(100px);
    animation: driftOne 30s ease-in-out infinite alternate,
        fadeOne 18s ease-in-out infinite alternate;
}

/* Secondary layer */
.hero::after {
    background:
        radial-gradient(circle at 35% 65%, rgba(160, 30, 50, 0.75), transparent 30%),
        radial-gradient(circle at 80% 60%, rgba(140, 25, 45, 0.65), transparent 35%),
        radial-gradient(circle at 50% 40%, rgba(170, 35, 55, 0.70), transparent 30%);
    filter: blur(130px);
    animation: driftTwo 42s ease-in-out infinite alternate,
        fadeTwo 24s ease-in-out infinite alternate;
}

/* Motion */
@keyframes driftOne {
    0% {
        transform: translate(0%, 0%) scale(1);
    }

    50% {
        transform: translate(-6%, 5%) scale(1.12);
    }

    100% {
        transform: translate(5%, -6%) scale(1.05);
    }
}

@keyframes driftTwo {
    0% {
        transform: translate(0%, 0%) scale(1);
    }

    50% {
        transform: translate(6%, -5%) scale(1.15);
    }

    100% {
        transform: translate(-5%, 6%) scale(1.07);
    }
}

/* Stronger breathing */
@keyframes fadeOne {
    0% {
        opacity: 0.5;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.6;
    }
}

@keyframes fadeTwo {
    0% {
        opacity: 0.4;
    }

    50% {
        opacity: 0.85;
    }

    100% {
        opacity: 0.5;
    }
}

.hero-content {
    position: relative;
    max-width: 880px;
    z-index: 2;
}

.eyebrow {
    display: inline-block;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.hero h1 {
    font-family: var(--serif);
    font-size: 46px;
    font-weight: 400;
    line-height: 1.25;
    letter-spacing: -0.5px;
    margin-bottom: 28px;
    text-shadow:
        0 4px 6px rgba(0, 0, 0, 0.6),
        0 0 25px rgba(0, 0, 0, 0.25);
}

.hero p {
    font-size: 18px;
    color: var(--text-secondary);
    max-width: 720px;
    margin: 0 auto;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

.hero-actions {
    margin-top: 40px;
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

.button {
    display: inline-block;
    padding: 12px 22px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    border: 1px solid var(--border);
    background: rgba(11, 12, 15, 0.45);
    transition: background 0.2s, border-color 0.2s;
}

.button:hover {
    border-color: rgba(255, 255, 255, 0.3);
}

.button-primary {
    background: var(--accent);
    border-color: var(--accent);
}

.button-primary:hover {
    background: var(--accent-bright);
    border-color: var(--accent-bright);
}

/* ---------- Inner page hero ---------- */

.page-hero {
    position: relative;
    overflow: hidden;
    padding: 168px var(--gutter) 72px;
    border-bottom: 1px solid var(--border-subtle);
}

.page-hero::before {
    background:
        radial-gradient(circle at 15% 20%, rgba(160, 30, 50, 0.35), transparent 40%),
        radial-gradient(circle at 85% 0%, rgba(140, 25, 45, 0.25), transparent 35%);
    filter: blur(90px);
    animation: driftOne 40s ease-in-out infinite alternate;
}

.page-hero-inner {
    position: relative;
    z-index: 1;
    max-width: 760px;
    margin: 0 auto;
}

.breadcrumb {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.breadcrumb a {
    color: var(--text-secondary);
    text-decoration: none;
}

.breadcrumb a:hover {
    color: var(--text-primary);
}

.page-hero h1 {
    font-family: var(--serif);
    font-size: 40px;
    font-weight: 400;
    line-height: 1.25;
    letter-spacing: -0.4px;
    margin-bottom: 20px;
}

.page-hero .lede {
    font-size: 18px;
    color: var(--text-secondary);
}

.page-hero .tags {
    margin-top: 24px;
}

/* ---------- Sections ---------- */

.section {
    padding: 112px var(--gutter);
}

.section-alt {
    background: var(--bg-alt);
    border-top: 1px solid var(--border-subtle);
    border-bottom: 1px solid var(--border-subtle);
}

.section h2 {
    font-family: var(--serif);
    font-size: 34px;
    font-weight: 400;
    margin-bottom: 16px;
    text-align: center;
}

.section-intro {
    max-width: 680px;
    margin: 0 auto 56px;
    text-align: center;
    color: var(--text-secondary);
}

.grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 32px;
    max-width: 1200px;
    margin: 0 auto;
}

.grid-2 {
    grid-template-columns: repeat(2, 1fr);
    max-width: 1000px;
}

.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

.grid-5 {
    grid-template-columns: repeat(5, 1fr);
    gap: 20px;
    max-width: 1320px;
}

.grid-5 .card {
    padding: 24px;
}

.card {
    display: block;
    padding: 28px;
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.015);
    text-decoration: none;
    transition: border-color 0.2s, background 0.2s, transform 0.2s;
}

a.card:hover {
    border-color: rgba(192, 57, 77, 0.5);
    background: var(--accent-soft);
    transform: translateY(-2px);
}

.card .card-kicker {
    font-size: 12px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent-bright);
    margin-bottom: 12px;
}

.card h3 {
    font-size: 18px;
    font-weight: 500;
    margin-bottom: 12px;
}

.card p {
    color: var(--text-secondary);
    font-size: 15px;
}

.card .card-more {
    display: inline-block;
    margin-top: 16px;
    font-size: 13px;
    color: var(--text-primary);
}

.feature-quote {
    max-width: 860px;
    margin: 0 auto;
    text-align: center;
}

.feature-quote blockquote {
    font-family: var(--serif);
    font-size: 28px;
    line-height: 1.5;
    font-style: italic;
}

.feature-quote p {
    margin-top: 28px;
    color: var(--text-secondary);
    max-width: 680px;
    margin-left: auto;
    margin-right: auto;
}

.center-actions {
    text-align: center;
    margin-top: 48px;
}

/* ---------- Status tags ---------- */

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag {
    display: inline-block;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    white-space: nowrap;
}

.tag-question {
    border-color: rgba(192, 57, 77, 0.6);
    color: #E8A0AA;
}

.tag-hypothesis {
    border-color: rgba(214, 170, 90, 0.5);
    color: #E3C68F;
}

.tag-synthesis {
    border-color: rgba(120, 160, 220, 0.5);
    color: #A9C2E8;
}

.tag-literature {
    border-color: rgba(120, 190, 160, 0.5);
    color: #9FD3BC;
}

.tag-speculation {
    border-color: rgba(180, 140, 220, 0.5);
    color: #CDB5EA;
}

.tag-thought {
    border-color: rgba(255, 255, 255, 0.25);
    color: var(--text-primary);
}

.tag-history {
    border-color: rgba(255, 255, 255, 0.12);
    color: var(--text-muted);
}

.legend {
    max-width: 900px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px 40px;
}

.legend div {
    display: flex;
    gap: 14px;
    align-items: baseline;
}

.legend .tag {
    flex-shrink: 0;
    min-width: 132px;
    text-align: center;
}

.legend p {
    font-size: 14px;
    color: var(--text-secondary);
}

/* ---------- Prose (article pages) ---------- */

.prose {
    max-width: 760px;
    margin: 0 auto;
    padding: 72px var(--gutter) 96px;
    box-sizing: content-box;
    font-size: 17px;
    line-height: 1.75;
}

.prose > :first-child {
    margin-top: 0;
}

.prose [id] {
    scroll-margin-top: 100px;
}

.prose > * + * {
    margin-top: 1.1em;
}

.prose h2 {
    font-family: var(--serif);
    font-size: 26px;
    font-weight: 400;
    line-height: 1.35;
    margin-top: 2.4em;
    padding-top: 0.2em;
}

.prose h3 {
    font-size: 18px;
    font-weight: 600;
    margin-top: 2em;
}

.prose h2 + *,
.prose h3 + * {
    margin-top: 0.7em;
}

.prose p,
.prose li {
    color: #D4D6DB;
}

.prose a {
    color: var(--text-primary);
    text-decoration-color: var(--accent-bright);
    text-underline-offset: 3px;
}

.prose a:hover {
    color: #fff;
    text-decoration-thickness: 2px;
}

.prose strong {
    color: var(--text-primary);
    font-weight: 600;
}

.prose ul,
.prose ol {
    padding-left: 1.4em;
}

.prose li + li {
    margin-top: 0.45em;
}

.prose blockquote {
    border-left: 2px solid var(--accent-bright);
    padding: 4px 0 4px 24px;
    font-family: var(--serif);
    font-size: 20px;
    line-height: 1.6;
    font-style: italic;
    color: var(--text-primary);
}

.prose blockquote p {
    color: var(--text-primary);
}

.prose blockquote cite {
    display: block;
    margin-top: 10px;
    font-family: var(--sans);
    font-style: normal;
    font-size: 13px;
    color: var(--text-muted);
}

.prose hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 3em 0;
}

.math {
    font-family: 'Cambria Math', 'STIX Two Math', Georgia, serif;
    font-style: italic;
    white-space: nowrap;
}

.prose code {
    font-family: ui-monospace, 'SFMono-Regular', Consolas, monospace;
    font-size: 0.88em;
    background: var(--bg-raised);
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    padding: 1px 6px;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
}

.prose table {
    width: 100%;
    border-collapse: collapse;
    font-size: 15px;
    line-height: 1.55;
}

.prose th,
.prose td {
    text-align: left;
    vertical-align: top;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
}

.prose th {
    font-weight: 600;
    font-size: 13px;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    background: var(--bg-alt);
}

.prose tr:last-child td {
    border-bottom: 0;
}

.callout {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px 24px;
    background: var(--bg-alt);
}

.callout-title {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent-bright);
    margin-bottom: 8px;
}

.callout p {
    font-size: 15px;
    color: var(--text-secondary);
}

.callout p + p {
    margin-top: 0.7em;
}

.callout-caution {
    border-color: rgba(214, 170, 90, 0.35);
}

.callout-caution .callout-title {
    color: #E3C68F;
}

/* Alchemical stages (About page) */
.stages {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.stage {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 18px 20px;
    border-radius: 10px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-alt);
    font-size: 14px;
    line-height: 1.55;
}

.stage strong {
    font-family: var(--serif);
    font-weight: 400;
    font-size: 19px;
}

.stage span:last-child {
    color: var(--text-secondary);
}

.stage-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    margin-bottom: 4px;
}

.stage-nigredo .stage-dot {
    background: #050506;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.stage-albedo .stage-dot {
    background: #E8E6E1;
}

.stage-rubedo {
    border-color: rgba(192, 57, 77, 0.45);
    background: var(--accent-soft);
}

.stage-rubedo .stage-dot {
    background: var(--accent-bright);
    box-shadow: 0 0 14px rgba(192, 57, 77, 0.8);
}

@media (max-width: 700px) {
    .stages {
        grid-template-columns: 1fr;
    }
}

/* Inline flow diagrams: A → B → C */
.flow {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 6px;
    padding: 20px;
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    background: var(--bg-alt);
    font-size: 14px;
}

.flow span {
    padding: 6px 12px;
    border-radius: 6px;
    background: var(--bg-raised);
    border: 1px solid var(--border);
    color: var(--text-primary);
}

.flow span.arrow {
    padding: 0 2px;
    background: none;
    border: 0;
    color: var(--accent-bright);
}

.flow-vertical {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
}

.flow-caption {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 8px !important;
    text-align: center;
}

.on-this-page {
    border-left: 1px solid var(--border);
    padding-left: 20px;
    font-size: 14px;
}

.on-this-page p {
    font-size: 12px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted) !important;
    margin-bottom: 6px;
}

.on-this-page ol {
    padding-left: 1.2em;
}

.on-this-page li {
    color: var(--text-secondary);
}

.on-this-page li + li {
    margin-top: 2px;
}

.on-this-page a {
    color: var(--text-secondary);
    text-decoration: none;
}

.on-this-page a:hover {
    color: var(--text-primary);
}

.page-nav {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-top: 4em !important;
    padding-top: 2em;
    border-top: 1px solid var(--border);
}

.page-nav a {
    text-decoration: none;
    font-size: 15px;
    max-width: 48%;
}

.page-nav a span {
    display: block;
    font-size: 12px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.page-nav .next {
    margin-left: auto;
    text-align: right;
}

/* ---------- Index lists (questions, essays) ---------- */

.index-list {
    list-style: none;
    padding: 0 !important;
    border-top: 1px solid var(--border);
}

.index-list li {
    margin: 0 !important;
    border-bottom: 1px solid var(--border);
}

.index-list a {
    display: grid;
    grid-template-columns: 48px 1fr;
    gap: 4px 16px;
    padding: 24px 4px;
    text-decoration: none;
    transition: background 0.2s;
}

.index-list a:hover {
    background: var(--accent-soft);
}

.index-num {
    font-family: var(--serif);
    color: var(--accent-bright);
    font-size: 20px;
    grid-row: span 2;
}

.index-title {
    font-size: 18px;
    font-weight: 500;
    color: var(--text-primary);
}

.index-desc {
    font-size: 15px;
    color: var(--text-secondary);
    grid-column: 2;
}

/* ---------- Reading map ---------- */

.ref {
    padding: 22px 0;
    border-bottom: 1px solid var(--border-subtle);
}

.ref + .ref {
    margin-top: 0 !important;
}

.ref-title {
    font-size: 17px;
    font-weight: 500;
    color: var(--text-primary);
}

.ref-meta {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 2px !important;
}

.ref-meta a {
    color: var(--text-secondary);
}

.ref p {
    font-size: 15px;
    margin-top: 10px;
}

.ref .ref-limit {
    color: var(--text-secondary);
}

.ref .tags {
    margin-top: 12px;
}

.ref-group-intro {
    color: var(--text-secondary) !important;
}

/* ---------- Notebook timeline ---------- */

.timeline {
    position: relative;
    padding-left: 28px !important;
    list-style: none;
}

.timeline::before {
    content: "";
    position: absolute;
    left: 5px;
    top: 8px;
    bottom: 8px;
    width: 1px;
    background: var(--border);
}

.timeline > li {
    position: relative;
    margin-top: 0 !important;
    padding-bottom: 40px;
}

.timeline > li::before {
    content: "";
    position: absolute;
    left: -28px;
    top: 9px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: var(--bg);
    border: 2px solid var(--accent-bright);
}

.timeline-date {
    font-size: 13px;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.timeline h3 {
    margin-top: 4px !important;
    font-size: 19px;
}

.timeline p,
.timeline ul {
    margin-top: 0.7em;
}

.timeline .tags {
    margin-top: 12px;
}

/* ---------- Layers (home) ---------- */

.layers {
    max-width: 1000px;
    margin: 0 auto;
    display: grid;
    gap: 16px;
}

.layer {
    display: grid;
    grid-template-columns: 64px 1fr;
    gap: 20px;
    align-items: start;
    padding: 28px;
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.015);
}

.layer-num {
    font-family: var(--serif);
    font-size: 34px;
    color: var(--accent-bright);
    line-height: 1;
}

.layer h3 {
    font-size: 18px;
    font-weight: 500;
    margin-bottom: 6px;
}

.layer p {
    color: var(--text-secondary);
    font-size: 15px;
}

.layer .layer-q {
    margin-top: 10px;
    font-family: var(--serif);
    font-style: italic;
    color: var(--text-primary);
}

/* ---------- Footer ---------- */

.footer {
    padding: 64px var(--gutter) 40px;
    color: var(--text-secondary);
    font-size: 14px;
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-alt);
}

.footer-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 48px;
}

.footer-logo {
    font-family: var(--serif);
    font-size: 18px;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.footer p {
    max-width: 520px;
}

.footer-links {
    display: grid;
    gap: 8px;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
}

.footer-links a:hover {
    color: var(--text-primary);
}

.footer-note {
    max-width: 1200px;
    margin: 40px auto 0;
    padding-top: 24px;
    border-top: 1px solid var(--border-subtle);
    font-size: 13px;
    color: var(--text-muted);
}

/* ---------- Responsive ---------- */

@media (max-width: 1100px) {
    .grid-5,
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 900px) {
    :root {
        --gutter: 24px;
    }

    .prose [id] {
        scroll-margin-top: 130px;
    }

    .site-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        padding-top: 16px;
        padding-bottom: 12px;
    }

    .site-header nav {
        gap: 20px;
        width: 100%;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .site-header nav::-webkit-scrollbar {
        display: none;
    }

    .hero {
        padding-top: 150px;
    }

    .hero h1 {
        font-size: 34px;
    }

    .page-hero {
        padding-top: 150px;
    }

    .page-hero h1 {
        font-size: 32px;
    }

    .section {
        padding: 80px var(--gutter);
    }

    .section h2 {
        font-size: 28px;
    }

    .grid,
    .grid-2,
    .grid-4,
    .grid-5,
    .legend,
    .footer-inner {
        grid-template-columns: 1fr;
    }

    .feature-quote blockquote {
        font-size: 22px;
    }

    .layer {
        grid-template-columns: 1fr;
        gap: 10px;
    }
}

@media (max-width: 520px) {
    .prose {
        font-size: 16px;
    }

    .legend div {
        flex-direction: column;
        gap: 6px;
    }

    .legend .tag {
        min-width: 0;
    }

    .page-nav {
        flex-direction: column;
    }

    .page-nav a {
        max-width: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .hero::before,
    .hero::after,
    .page-hero::before {
        animation: none;
    }

    html {
        scroll-behavior: auto;
    }

    a.card:hover {
        transform: none;
    }
}
