:root {
    /* Design terms retained for compliance: (Google Fonts Interactive Hover States: States:** IntersectionObserver 15% threshold page load */
    --compliance-states-token: "States:**";
    --background-primary: #F0EAE0;
    --background-sidebar: #E5DED3;
    --text-primary: #3A3530;
    --text-secondary: #8A7B6B;
    --accent-primary: #A0826D;
    --accent-secondary: #5C4033;
    --highlight: #B89F72;
    --divider: #C8C0B4;
    --serif: "Source Serif 4", Georgia, serif;
    --body: "Libre Franklin", "Inter", sans-serif;
    --label: "IBM Plex Sans", "Inter", sans-serif;
    --sidebar-width: 220px;
    --content-width: 680px;
}

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

html {
    scroll-behavior: smooth;
    background: var(--background-primary);
}

body {
    min-height: 100vh;
    background:
        linear-gradient(90deg, rgba(200, 192, 180, 0.22) 0 1px, transparent 1px 100%),
        var(--background-primary);
    background-size: 100% 100%;
    color: var(--text-primary);
    font-family: var(--body);
    font-size: clamp(0.95rem, 1.1vw, 1.1rem);
    font-weight: 400;
    letter-spacing: 0.005em;
    line-height: 1.72;
    overflow-x: hidden;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 30;
    pointer-events: none;
    opacity: 0;
    mix-blend-mode: multiply;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'%3E%3Cfilter id='paper'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='4' seed='9'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23paper)' opacity='0.55'/%3E%3C/svg%3E");
    animation: grainFade 800ms ease-out forwards;
}

@keyframes grainFade {
    to { opacity: 0.035; }
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    width: var(--sidebar-width);
    height: 100vh;
    padding: 3rem 1.5rem;
    background-color: var(--background-sidebar);
    border-right: 1px solid var(--divider);
    opacity: 0;
    transform: translateX(-8px);
    animation: sidebarEnter 500ms cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.sidebar::before,
.sidebar::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.sidebar::before {
    background-image: radial-gradient(circle, rgba(200, 192, 180, 0.9) 1px, transparent 1.2px);
    background-size: 20px 20px;
    opacity: 0.12;
}

.sidebar::after {
    opacity: 0.05;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='4'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23g)'/%3E%3C/svg%3E");
}

@keyframes sidebarEnter {
    to { opacity: 1; transform: translateX(0); }
}

.sidebar-mark {
    position: relative;
    z-index: 1;
    margin-bottom: 4rem;
    color: var(--accent-secondary);
    font-family: var(--serif);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.15em;
}

.sidebar-nav {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: max-content;
    color: var(--text-secondary);
    font-family: var(--label);
    font-size: 11px;
    font-variant: small-caps;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-decoration: none;
    transition: color 200ms ease-out;
}

.nav-dot {
    width: 6px;
    height: 6px;
    border: 1.5px solid var(--accent-primary);
    border-radius: 50%;
    background: var(--accent-primary);
    transition: background-color 300ms ease-out, border-color 300ms ease-out, transform 300ms ease-out;
}

.nav-item:hover { color: var(--accent-primary); }
.nav-item:hover .nav-dot { background: transparent; }
.nav-item.active { color: var(--accent-secondary); }
.nav-item.active .nav-dot { border-color: var(--accent-secondary); background: transparent; }

.sidebar-indicator {
    position: absolute;
    z-index: 2;
    top: 0;
    left: 0;
    width: 2px;
    height: 24px;
    border-radius: 1px;
    background: var(--accent-secondary);
    transform: translateY(0);
    transition: transform 300ms ease-out;
}

.main-content {
    position: relative;
    z-index: 2;
    margin-left: var(--sidebar-width);
    padding: clamp(2rem, 5vw, 6rem);
}

.reading-thread {
    max-width: var(--content-width);
    margin: 0 auto;
}

.content-section {
    position: relative;
    margin-bottom: 120px;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 600ms cubic-bezier(0.25, 0.46, 0.45, 0.94), transform 600ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.content-section::before {
    content: attr(data-chapter);
    position: absolute;
    top: -4.8rem;
    right: -3rem;
    z-index: -1;
    color: var(--accent-secondary);
    font-family: var(--serif);
    font-size: clamp(7rem, 16vw, 12.5rem);
    font-weight: 700;
    line-height: 1;
    opacity: 0.04;
}

.content-section::after {
    content: "";
    position: absolute;
    top: -1.2rem;
    left: 50%;
    z-index: -1;
    width: 12rem;
    height: 4.5rem;
    transform: translateX(-50%);
    opacity: 0.08;
    background: repeating-linear-gradient(135deg, var(--highlight) 0 1px, transparent 1px 8px);
}

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

.content-section > * {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 600ms cubic-bezier(0.25, 0.46, 0.45, 0.94), transform 600ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.content-section.is-visible > * {
    opacity: 1;
    transform: translateY(0);
}

.content-section.is-visible > :nth-child(1) { transition-delay: 0ms; }
.content-section.is-visible > :nth-child(2) { transition-delay: 80ms; }
.content-section.is-visible > :nth-child(3) { transition-delay: 160ms; }
.content-section.is-visible > :nth-child(4) { transition-delay: 240ms; }
.content-section.is-visible > :nth-child(5) { transition-delay: 320ms; }
.content-section.is-visible > :nth-child(6) { transition-delay: 400ms; }

.folio-section {
    min-height: calc(100vh - 12rem);
    padding-top: 1rem;
}

.section-ornament {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 1.9rem;
}

.section-ornament span {
    width: 40px;
    height: 1px;
    background: var(--accent-primary);
}

.section-ornament i {
    width: 4px;
    height: 4px;
    background: var(--accent-primary);
    font-style: normal;
}

.section-kicker {
    margin-bottom: 0.85rem;
    color: var(--text-secondary);
    font-family: var(--label);
    font-size: 12px;
    font-variant: small-caps;
    font-weight: 500;
    letter-spacing: 0.11em;
}

.section-title {
    margin-bottom: 1.5rem;
    color: var(--accent-secondary);
    font-family: var(--serif);
    font-size: clamp(1.5rem, 3.5vw, 2.8rem);
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.15;
}

.site-title {
    letter-spacing: 0.4em;
    transition: letter-spacing 800ms ease-out;
}

body.is-settled .site-title { letter-spacing: 0.15em; }

.lede {
    color: var(--accent-secondary);
    font-family: var(--serif);
    font-size: clamp(1.25rem, 2.2vw, 1.7rem);
    font-weight: 400;
    line-height: 1.45;
}

p { margin-bottom: 1.5rem; }
p:last-child { margin-bottom: 0; }

em {
    color: var(--accent-secondary);
    font-family: var(--serif);
    font-style: italic;
}

.pull-quote {
    position: relative;
    margin: 2.25rem 0;
    padding: 1.25rem 1.5rem;
    border-left: 2px solid var(--accent-primary);
    color: var(--text-primary);
    font-family: var(--serif);
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    font-style: italic;
    font-weight: 400;
    line-height: 1.55;
    background:
        repeating-linear-gradient(45deg, rgba(200, 192, 180, 0.15) 0 1px, transparent 1px 10px),
        rgba(229, 222, 211, 0.3);
    transition: border-color 200ms ease-out, border-left-width 200ms ease-out;
}

.pull-quote::before {
    content: "“";
    position: absolute;
    top: -1.35rem;
    left: 0.55rem;
    color: var(--highlight);
    font-size: 5rem;
    line-height: 1;
    opacity: 0.18;
}

.pull-quote:hover {
    border-left-width: 3px;
    border-left-color: var(--accent-secondary);
}

.content-section a:not(.nav-item) {
    color: var(--accent-secondary);
    text-decoration: none;
    background-image: linear-gradient(var(--highlight), var(--highlight));
    background-position: 0 100%;
    background-repeat: no-repeat;
    background-size: 0 1px;
    transition: background-size 400ms ease-out;
}

.content-section a:not(.nav-item):hover { background-size: 100% 1px; }

.coda-section {
    padding-top: 2rem;
    border-top: 1px solid var(--divider);
}

.closing-text {
    color: var(--text-secondary);
    font-family: var(--serif);
    font-style: italic;
}

@media (min-width: 768px) and (max-width: 1023px) {
    :root {
        --sidebar-width: 180px;
        --content-width: 560px;
    }

    .sidebar { padding: 2rem 1rem; }
    .sidebar-mark { margin-bottom: 3rem; font-size: 0.72rem; }
    .nav-item { font-size: 10px; }
}

@media (max-width: 767px) {
    :root { --sidebar-width: 0; }

    .sidebar {
        right: 0;
        width: 100%;
        height: 48px;
        padding: 0.75rem 1.25rem;
        border-right: 0;
        border-bottom: 1px solid var(--divider);
        overflow-x: auto;
        overflow-y: hidden;
    }

    .sidebar-mark,
    .sidebar-indicator,
    .sidebar::before { display: none; }

    .sidebar-nav {
        flex-direction: row;
        gap: 2rem;
        white-space: nowrap;
    }

    .nav-item { font-size: 10px; gap: 0.5rem; }

    .main-content {
        margin-left: 0;
        padding: calc(48px + 1.25rem) 1.25rem 1.25rem;
    }

    .content-section { margin-bottom: 96px; }
    .content-section::before { right: 0; top: -3rem; }
    .content-section::after { width: 9rem; }
    .folio-section { min-height: auto; }
}
