:root {
    color-scheme: dark light;
    --bg: #000000;
    --fg: #f5f1e8;
    --muted: rgba(245, 241, 232, 0.7);
    --line: rgba(245, 241, 232, 0.12);
    --panel: rgba(245, 241, 232, 0.04);
    --panel-strong: rgba(245, 241, 232, 0.08);
    --shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
    --accent: #d4b483;
    --accent-soft: rgba(212, 180, 131, 0.16);
    --hero-image: url('hero-dark.png');
}

:root[data-theme="light"] {
    --bg: #f6f0e7;
    --fg: #111111;
    --muted: rgba(17, 17, 17, 0.74);
    --line: rgba(17, 17, 17, 0.14);
    --panel: rgba(255, 255, 255, 0.5);
    --panel-strong: rgba(255, 255, 255, 0.72);
    --shadow: 0 24px 80px rgba(35, 24, 14, 0.1);
    --accent: #6e4422;
    --accent-soft: rgba(110, 68, 34, 0.12);
    --hero-image: url('hero-light.png');
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

html,
body {
    scroll-padding-top: 6.5rem;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Avenir Next", Avenir, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--fg);
    line-height: 1.6;
    transition: background-color 180ms ease, color 180ms ease;
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    display: block;
    max-width: 100%;
}

.page-shell {
    position: relative;
    overflow-x: clip;
}

.page-shell::before {
    content: "";
    position: fixed;
    inset: -12rem auto auto -12rem;
    width: 28rem;
    height: 28rem;
    border-radius: 999px;
    background: radial-gradient(circle, var(--accent-soft), transparent 68%);
    pointer-events: none;
    filter: blur(10px);
}

.page-shell::after {
    content: "";
    position: fixed;
    inset: auto -10rem 10rem auto;
    width: 26rem;
    height: 26rem;
    border-radius: 999px;
    background: radial-gradient(circle, var(--panel-strong), transparent 70%);
    pointer-events: none;
    filter: blur(10px);
}

.container {
    width: min(1120px, calc(100vw - 2rem));
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

.topbar {
    position: sticky;
    top: 1rem;
    z-index: 20;
    padding: 1rem 0 0;
}

.topbar-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.8rem 1rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: color-mix(in srgb, var(--bg) 78%, transparent);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(18px) saturate(140%);
    -webkit-backdrop-filter: blur(18px) saturate(140%);
}

:root:not([data-theme="light"]) .topbar-inner {
    box-shadow: 0 0 0 1px rgba(245, 241, 232, 0.1), 0 0 56px rgba(245, 241, 232, 0.16), 0 0 140px rgba(212, 180, 131, 0.14), 0 24px 60px rgba(0, 0, 0, 0.34);
}

.wordmark {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.82rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--muted);
}

.wordmark img {
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 0.45rem;
}

.section-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    flex: 1;
    min-width: 0;
}

.section-nav-link {
    padding: 0.55rem 0.85rem;
    border-radius: 999px;
    color: var(--muted);
    font-size: 0.92rem;
    transition: background-color 140ms ease, color 140ms ease, transform 140ms ease;
}

.section-nav-link:hover,
.section-nav-link:focus-visible {
    background: var(--panel-strong);
    color: var(--fg);
    transform: translateY(-1px);
}

.theme-toggle {
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--fg);
    border-radius: 999px;
    padding: 0.65rem 0.9rem;
    font: inherit;
    cursor: pointer;
    transition: transform 140ms ease, background-color 140ms ease, border-color 140ms ease;
}

.theme-toggle:hover {
    transform: translateY(-1px);
    background: var(--panel-strong);
}

section {
    padding: 4.5rem 0;
}

.hero {
    padding-top: 2rem;
}

.eyebrow {
    margin: 0 0 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 0.75rem;
    color: var(--muted);
}

h1, h2, h3 {
    margin: 0;
    font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
    font-weight: 600;
    letter-spacing: -0.02em;
}

h1 {
    font-size: clamp(3.3rem, 8vw, 6.8rem);
    line-height: 0.96;
    max-width: 11ch;
}

.hero-copy {
    margin-top: 1.5rem;
    text-align: center;
}

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

.hero-copy > :last-child {
    margin-bottom: 0;
}

.hero-copy p,
.hero-copy ul,
.hero-copy ol {
    margin: 0 0 0.9rem;
    font-size: clamp(1.15rem, 2vw, 1.4rem);
    color: var(--muted);
}

.hero-copy ul,
.hero-copy ol {
    display: inline-block;
    text-align: left;
    padding-left: 1.25rem;
}

.hero-copy a {
    color: var(--accent);
}

.hero-visual {
    position: relative;
    min-height: clamp(20rem, 52vw, 42rem);
    border-radius: 2rem;
    background: linear-gradient(145deg, var(--panel), transparent 70%);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    overflow: hidden;
    isolation: isolate;
}

.hero-visual::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: var(--hero-image);
    background-size: cover;
    background-position: center;
    opacity: 0.92;
    transition: opacity 180ms ease;
}

.hero-visual::after {
    content: "";
    position: absolute;
    inset: auto 0 0;
    height: 20%;
    background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.06) 100%);
    mix-blend-mode: multiply;
}

.section-heading {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 1.5rem;
    align-items: end;
    margin-bottom: 2rem;
}

.section-heading p {
    margin: 0.8rem 0 0;
    max-width: 40rem;
    color: var(--muted);
}

.manifesto-section {
    width: 100%;
}

.manifesto-shell {
    max-width: 900px;
    margin: 0 auto;
}

.manifesto-content {
    font-size: 1.18rem;
    line-height: 1.7;
    color: var(--muted);
    background: var(--panel);
    border-radius: 1.5rem;
    padding: 2.2rem 2.5rem 2.1rem;
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.book-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.2rem;
}

.book-card {
    display: grid;
    grid-template-columns: 360px minmax(0, 1fr);
    gap: 1.4rem;
    padding: 1.25rem;
    border-radius: 1.5rem;
    border: 1px solid var(--line);
    background: linear-gradient(180deg, var(--panel), transparent 140%);
    box-shadow: var(--shadow);
}

.cover-shell {
    align-self: start;
    border-radius: 1rem;
    overflow: hidden;
    background: var(--panel-strong);
    transform: translateY(0);
    transition: transform 180ms ease, box-shadow 180ms ease;
}

.cover-shell img {
    width: 100%;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    transform: scale(1);
    transition: transform 280ms ease;
}

@media (hover: hover) {
    .book-card:hover .cover-shell,
    .book-card:focus-within .cover-shell {
        transform: translateY(-4px);
        box-shadow: 0 18px 34px rgba(0, 0, 0, 0.18);
    }

    .book-card:hover .cover-shell img,
    .book-card:focus-within .cover-shell img {
        transform: scale(1.025);
    }
}

.book-meta {
    display: flex;
    flex-direction: column;
}

.book-meta-top {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: start;
}

.section-kicker {
    margin: 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.book-card h3 {
    margin-top: 0.25rem;
    font-size: 1.45rem;
}

.book-description {
    margin: 0.65rem 0 1rem;
    color: var(--muted);
    flex: 1;
}

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

.book-description > :last-child {
    margin-bottom: 0;
}

.book-description p {
    margin: 0 0 0.85rem;
}

.book-description ul,
.book-description ol {
    margin: 0 0 0.85rem;
    padding-left: 1.2rem;
}

.book-description li + li {
    margin-top: 0.35rem;
}

.book-description a {
    color: var(--accent);
}

.book-link {
    align-self: start;
    padding: 0.7rem 0.9rem;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--fg);
    border: 1px solid transparent;
}

.book-link.muted {
    background: var(--panel);
    border-color: var(--line);
    color: var(--muted);
}

.profile-panel {
    display: grid;
    grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
    gap: 2rem;
    padding: 1.5rem;
    border-radius: 2rem;
    border: 1px solid var(--line);
    background: linear-gradient(180deg, var(--panel), transparent 150%);
    box-shadow: var(--shadow);
}

.profile-aside {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.portrait-frame {
    border-radius: 1.5rem;
    overflow: hidden;
    border: 1px solid var(--line);
    background: var(--panel-strong);
}

.portrait-frame img {
    width: 100%;
    aspect-ratio: 4 / 5;
    object-fit: cover;
}

.profile-note {
    padding: 1rem 1.1rem;
    border-radius: 1.25rem;
    background: var(--panel);
    border: 1px solid var(--line);
    color: var(--muted);
}

.profile-content {
    min-width: 0;
}

.profile-content h1,
.profile-content h2,
.profile-content h3,
.profile-content h4 {
    font-size: clamp(1.15rem, 2vw, 1.8rem);
    margin: 2rem 0 0.8rem;
    line-height: 1.2;
}

.profile-content h1:first-child,
.profile-content h2:first-child,
.profile-content h3:first-child {
    margin-top: 0;
}

.profile-content p {
    margin: 0 0 1rem;
}

.profile-content ul {
    margin: 0 0 1.15rem;
    padding-left: 1.2rem;
}

.profile-content li {
    margin-bottom: 0.45rem;
}

.profile-content strong {
    color: var(--fg);
}

.profile-content a {
    color: var(--accent);
}

.link-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.link-card {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 1.2rem;
    border-radius: 1.35rem;
    border: 1px solid var(--line);
    background: linear-gradient(180deg, var(--panel), transparent 140%);
    min-height: 8.5rem;
}

.link-card-title {
    font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
    font-size: 1.35rem;
}

.link-card-description {
    color: var(--muted);
}

.footer {
    padding: 1rem 0 3rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.reveal {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 500ms ease, transform 500ms ease;
}

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

@media (max-width: 960px) {
    .topbar-inner {
        border-radius: 1.75rem;
        padding: 0.9rem;
        flex-wrap: wrap;
    }

    .section-nav {
        order: 3;
        width: 100%;
        justify-content: flex-start;
        overflow-x: auto;
        padding-bottom: 0.1rem;
        scrollbar-width: none;
    }

    .section-nav::-webkit-scrollbar {
        display: none;
    }

    .profile-panel {
        grid-template-columns: 1fr;
    }

    .book-grid {
        grid-template-columns: 1fr;
    }

    .hero {
        min-height: auto;
        padding-top: 2rem;
    }
}

@media (max-width: 720px) {
    html,
    body {
        scroll-padding-top: 11rem;
    }

    section {
        padding: 3.5rem 0;
    }

    .topbar {
        top: 0.5rem;
        padding-top: 0.75rem;
    }

    .topbar-inner {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        gap: 0.75rem;
        padding: 0.85rem;
        border-radius: 1.35rem;
    }

    .wordmark {
        min-width: 0;
        font-size: 0.68rem;
        letter-spacing: 0.12em;
        gap: 0.55rem;
    }

    .wordmark span {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .wordmark img {
        width: 1.35rem;
        height: 1.35rem;
    }

    .theme-toggle {
        justify-self: end;
        padding: 0.55rem 0.8rem;
        font-size: 0.9rem;
    }

    .section-nav {
        grid-column: 1 / -1;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.5rem;
        width: 100%;
        overflow: visible;
        padding-bottom: 0;
    }

    .section-nav-link {
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 0.88rem;
        padding: 0.62rem 0.8rem;
        text-align: center;
        background: var(--panel);
        border: 1px solid var(--line);
    }

    .section-heading {
        grid-template-columns: 1fr;
    }

    .book-card {
        grid-template-columns: 1fr;
    }

    .cover-shell {
        max-width: 420px;
        width: 100%;
        margin: 0 auto;
    }

    .hero-visual {
        min-height: 22rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }

    *, *::before, *::after {
        transition: none !important;
        animation: none !important;
    }

    .reveal {
        opacity: 1;
        transform: none;
    }
}