/* ==========================================================================
   Matthew MacLellan — Book Indexer
   Stylesheet
   ========================================================================== */

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

/* CSS Variables — the design system */
:root {
    --color-ground: #F5F2EA;
    --color-ink: #1A1A17;
    --color-muted: #555450;
    --color-rule: #C9C6BD;
    --color-accent: #CA6342;

    --font-serif: 'Newsreader', Georgia, 'Times New Roman', serif;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;

    --measure: 70ch;
    --page-max: 1180px;
    --page-pad-x: clamp(1.5rem, 4vw, 4rem);
    --page-pad-y: clamp(2.5rem, 5vw, 4rem);
}

/* Base */
html { font-size: 16px; scroll-behavior: smooth; }

body {
    background: var(--color-ground);
    color: var(--color-ink);
    font-family: var(--font-serif);
    font-size: 16px;
    line-height: 1.6;
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Layout container */
.page {
    max-width: var(--page-max);
    margin: 0 auto;
    padding: var(--page-pad-y) var(--page-pad-x);
}

/* The 12-column grid — the backbone of the site */
.grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 16px;
}

/* ==========================================================================
   Masthead (header/nav)
   ========================================================================== */
.masthead {
    align-items: baseline;
    padding-bottom: 2rem;
    border-bottom: 0.5px solid var(--color-ink);
}

.masthead__identity {
    grid-column: 1 / span 6;
}

.masthead__nav {
    grid-column: 7 / span 6;
    text-align: right;
    font-family: var(--font-sans);
    font-size: 13px;
    letter-spacing: 0.04em;
}

.masthead__home {
    text-decoration: none;
    color: inherit;
    display: block;
}

.masthead__home:hover .masthead__name {
    border-bottom: 0.5px solid var(--color-ink);
    padding-bottom: 1px;
}

.masthead__name {
    font-family: var(--font-sans);
    font-size: 13px;
    letter-spacing: 0.04em;
    font-weight: 500;
    display: inline-block;
}

.masthead__role {
    font-family: var(--font-sans);
    font-size: 13px;
    letter-spacing: 0.04em;
    color: var(--color-muted);
    margin-top: 2px;
}

.masthead__nav a {
    color: var(--color-ink);
    text-decoration: none;
    margin-left: 1.5rem;
    padding-bottom: 2px;
}

.masthead__nav a:hover,
.masthead__nav a[aria-current="page"] {
    border-bottom: 0.5px solid var(--color-ink);
}

/* ==========================================================================
   Sections
   ========================================================================== */
.section {
    margin-top: 5rem;
    margin-bottom: 5rem;
    padding-top: 2rem;
    border-top: 0.5px solid var(--color-rule);
}

.section--first {
    border-top: none;
    padding-top: 0;
}

.section--major-rule {
    border-top: 0.5px solid var(--color-ink);
}

.section__label {
    grid-column: 1 / span 2;
}

.section__label--wide {
    grid-column: 1 / span 3;
}

.section__body {
    grid-column: 4 / span 8;
}

.section__body--wide {
    grid-column: 4 / span 9;
    scroll-margin-top: 80px;
}

.label {
    font-family: var(--font-sans);
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-muted);
    font-weight: 400;
    scroll-margin-top: 80px;
}

.label__descriptor {
    font-family: var(--font-sans);
    font-size: 13px;
    letter-spacing: 0.04em;
    color: var(--color-muted);
    margin-top: 6px;
    line-height: 1.5;
    text-transform: none;
}

/* ==========================================================================
   Typography — display & body
   ========================================================================== */
.lede {
    font-family: var(--font-serif);
    font-size: clamp(28px, 3.4vw, 40px);
    line-height: 1.3;
    font-weight: 400;
    font-optical-sizing: auto;
}

.page-title {
    font-family: var(--font-serif);
    font-size: clamp(34px, 4vw, 48px);
    line-height: 1.1;
    font-weight: 400;
    margin-top: 12px;
}

.body-copy {
    font-family: var(--font-serif);
    font-size: 17px;
    line-height: 1.7;
    max-width: var(--measure);
    color: var(--color-ink);
}

.body-copy p + p {
    margin-top: 1rem;
}

.body-copy em, .body-copy i { font-style: italic; }

.prose-intro {
    font-family: var(--font-serif);
    font-size: 17px;
    line-height: 1.7;
    color: #3A3A35;
}

.prose-meta {
    font-family: var(--font-sans);
    font-size: 11px;
    letter-spacing: 0.08em;
    color: var(--color-muted);
    margin-top: 16px;
}

/* Italic for book titles is handled inline via <em> or <cite> */
cite { font-style: italic; font-weight: 400; }

/* ==========================================================================
   Selected work (home page)
   ========================================================================== */
.selected-work {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 48px 32px;
}

.selected-work__category {
    font-family: var(--font-sans);
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-muted);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 0.5px solid var(--color-rule);
}

.selected-work__item {
    font-size: 16px;
    line-height: 1.55;
    margin-bottom: 14px;
}

.selected-work__item:last-child { margin-bottom: 0; }

.selected-work__item cite { font-style: italic; }

.selected-work__meta { color: var(--color-muted); }

.selected-work__more {
    font-family: var(--font-sans);
    font-size: 12px;
    letter-spacing: 0.04em;
    margin-top: 32px;
}

.selected-work__more a {
    color: var(--color-ink);
    text-decoration: none;
    border-bottom: 0.5px solid var(--color-ink);
    padding-bottom: 2px;
}

/* ==========================================================================
   Bibliography (work page)
   ========================================================================== */
.biblio {
    columns: 2;
    column-gap: 40px;
    column-rule: 0.5px solid var(--color-rule);
}

.biblio__entry {
    font-size: 15px;
    line-height: 1.55;
    margin-bottom: 16px;
    break-inside: avoid;
}

.biblio__entry:last-child { margin-bottom: 0; }

.biblio__entry cite { font-style: italic; }

.biblio__entry a,
.biblio__entry a:visited,
.interlude__attribution a,
.interlude__attribution a:visited,
.notice__attribution a,
.notice__attribution a:visited {
    color: var(--color-ink);
    text-decoration: none;
    background-image: linear-gradient(var(--color-rule), var(--color-rule));
    background-size: 100% 0.5px;
    background-repeat: no-repeat;
    background-position: 0 100%;
    padding-bottom: 2px;
    transition: background-size 0.18s ease, background-image 0.18s ease;
}

.biblio__entry a:hover,
.interlude__attribution a:hover,
.notice__attribution a:hover {
    background-image: linear-gradient(var(--color-accent), var(--color-accent));
    background-size: 100% 3px;
}

.biblio__entry-meta { color: var(--color-muted); }

.biblio__note {
    font-size: 15px;
    line-height: 1.55;
    color: var(--color-muted);
    font-style: italic;
    break-inside: avoid;
}

/* Cluster heading within a top-level section */
.biblio-cluster {
    margin-top: 48px;
    scroll-margin-top: 80px;
}

.biblio-cluster:first-child {
    margin-top: 0;
}

.biblio-cluster__heading {
    font-family: var(--font-serif);
    font-weight: 500;
    font-size: 19px;
    letter-spacing: 0.01em;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 0.5px solid var(--color-rule);
}

.biblio-cluster__descriptor {
    font-family: var(--font-sans);
    font-size: 13px;
    line-height: 1.6;
    color: var(--color-muted);
    margin-top: -10px;
    margin-bottom: 24px;
}

.biblio__tag {
    color: var(--color-muted);
    font-style: italic;
    font-size: 13.5px;
}

.biblio-cluster__seealso {
    font-size: 14px;
    line-height: 1.55;
    color: var(--color-muted);
    font-style: italic;
    margin-top: 20px;
    padding-top: 12px;
    border-top: 0.5px solid var(--color-rule);
}

.biblio-cluster__top {
    font-size: 13px;
    color: var(--color-muted);
    font-style: italic;
    margin-top: 20px;
    padding-top: 12px;
    border-top: 0.5px solid var(--color-rule);
    text-align: right;
}

.biblio-cluster__top a {
    color: var(--color-muted);
    text-decoration: none;
    border-bottom: 0.5px solid var(--color-rule);
}

.biblio-cluster__top a:hover {
    color: var(--color-ink);
    border-bottom-color: var(--color-ink);
}

/* Jump-to anchor navigation */
.jump-to {
    font-size: 14px;
    line-height: 1.7;
    color: var(--color-muted);
    margin-bottom: 36px;
    padding-bottom: 24px;
    border-bottom: 0.5px solid var(--color-rule);
}

.jump-to__label {
    font-style: italic;
    margin-right: 6px;
}

.jump-to a {
    color: var(--color-ink);
    text-decoration: none;
    border-bottom: 0.5px solid var(--color-rule);
    white-space: nowrap;
}

.jump-to a:hover { border-bottom-color: var(--color-ink); }

.jump-to__sep {
    margin: 0 6px;
    color: var(--color-muted);
}

/* ==========================================================================
   Scrollspy sidebar — floating section index with active-state highlighting
   ========================================================================== */
.section[id], .label[id] {
    scroll-margin-top: 40px;
}

.scrollspy {
    position: fixed;
    top: 50%;
    left: 32px;
    transform: translateY(-50%);
    z-index: 10;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.scrollspy--visible {
    opacity: 1;
    pointer-events: auto;
}

.scrollspy__item {
    font-family: var(--font-sans);
    font-size: 12px;
    letter-spacing: 0.04em;
    line-height: 1.5;
    margin: 0 0 14px;
    padding-left: 14px;
    border-left: 1px solid transparent;
    transition: border-color 0.2s ease, color 0.2s ease;
}

.scrollspy__item a {
    color: var(--color-muted);
    text-decoration: none;
    display: block;
    transition: color 0.2s ease;
}

.scrollspy__item:hover a {
    color: var(--color-ink);
}

.scrollspy__item--active {
    border-left-color: var(--color-ink);
}

.scrollspy__item--active a {
    color: var(--color-ink);
    font-weight: 500;
}

.scrollspy__number {
    display: inline-block;
    width: 22px;
    color: inherit;
    opacity: 0.7;
}

/* Hide scrollspy on narrower screens — there's no room for it */
@media (max-width: 1200px) {
    .scrollspy {
        display: none;
    }
}

/* ==========================================================================
   Pull quote / Notice
   ========================================================================== */
.notice__quote {
    font-family: var(--font-serif);
    font-size: clamp(20px, 2.2vw, 24px);
    line-height: 1.5;
    font-style: italic;
    margin-bottom: 24px;
    max-width: var(--measure);
}

.notice__attribution {
    font-family: var(--font-sans);
    font-size: 12px;
    letter-spacing: 0.04em;
    color: var(--color-muted);
    line-height: 1.5;
}

.notice__attribution cite { font-style: italic; }

/* ==========================================================================
   Interlude — a pull quote between bibliography sections
   ========================================================================== */
.interlude {
    margin-top: 5rem;
    margin-bottom: 5rem;
    padding-top: 2rem;
    padding-bottom: 2rem;
    border-top: 0.5px solid var(--color-rule);
    border-bottom: 0.5px solid var(--color-rule);
}

.interlude__inner {
    max-width: 820px;
    margin: 0 auto;
    text-align: left;
}

.interlude__quote {
    font-family: var(--font-serif);
    font-size: clamp(20px, 2.2vw, 26px);
    line-height: 1.45;
    font-style: italic;
    margin-bottom: 20px;
}

.interlude__attribution {
    font-family: var(--font-sans);
    font-size: 12px;
    letter-spacing: 0.04em;
    color: var(--color-muted);
    line-height: 1.5;
}

.interlude__attribution cite { font-style: italic; }

/* ==========================================================================
   About page — facts list
   ========================================================================== */
.facts-list {
    font-family: var(--font-serif);
    font-size: 17px;
    line-height: 1.7;
}

.facts-list li {
    list-style: none;
    padding-left: 0;
    margin-bottom: 6px;
}

/* ==========================================================================
   Colophon (footer)
   ========================================================================== */
.colophon {
    margin-top: 5rem;
    padding-top: 2rem;
    border-top: 0.5px solid var(--color-ink);
}

.colophon__block { grid-column: span 6; }
.colophon__block--right { text-align: right; }

.colophon__label {
    font-family: var(--font-sans);
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-muted);
}

.colophon__value {
    font-size: 14px;
    margin-top: 6px;
}

.colophon__value a {
    color: var(--color-ink);
    text-decoration: none;
    border-bottom: 0.5px solid var(--color-ink);
    padding-bottom: 1px;
}

/* ==========================================================================
   Inline links in prose
   ========================================================================== */
.body-copy a,
.prose-intro a {
    color: var(--color-ink);
    text-decoration: none;
    border-bottom: 0.5px solid var(--color-ink);
    padding-bottom: 1px;
}

.body-copy a:hover,
.prose-intro a:hover { border-bottom-style: dotted; }

/* ==========================================================================
   Responsive — collapse grid on narrow screens
   ========================================================================== */
@media (max-width: 768px) {
    .masthead__identity,
    .masthead__nav { grid-column: 1 / -1; text-align: left; }

    .masthead__nav { margin-top: 1rem; }

    .masthead__nav a {
        margin-left: 0;
        margin-right: 1.5rem;
    }

    .section__label,
    .section__label--wide,
    .section__body,
    .section__body--wide { grid-column: 1 / -1; }

    .section__body,
    .section__body--wide { margin-top: 1.25rem; }

    .selected-work { grid-template-columns: 1fr; gap: 32px; }

    .biblio { columns: 1; column-rule: none; }

    .colophon__block,
    .colophon__block--right {
        grid-column: 1 / -1;
        text-align: left;
    }

    .colophon__block--right { margin-top: 1.5rem; }

    .section { margin-top: 3rem; margin-bottom: 3rem; }
}

/* ==========================================================================
   Accessibility
   ========================================================================== */
:focus-visible {
    outline: 2px solid var(--color-ink);
    outline-offset: 2px;
}

.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0);
    white-space: nowrap; border: 0;
}
