/* Almanack CSS - main stylesheet */

/* ==========================================================================
   CSS Custom Properties
   ========================================================================== */
:root {
    /* Colors */
    --color-text: #1a1a1a;
    --color-bg: #f9f7f4;
    --color-bg-center: #fefefe;
    --color-bg-edge: #e5d9c3;
    --color-muted: #666;
    --color-subtle: #999;
    --color-dim: #444;
    --color-faint: #777;
    --color-dark: #333;
    --color-light: #ccc;
    --color-border: #aaa;
    --color-rule: #e0e0e0;
    --color-code-bg: #f5f5f5;

    /* Fonts */
    --font-display: "Fell English", "Big Caslon Adjusted", "Big Caslon", "Hoefler Text", Garamond, serif;
    --font-body: "Cormorant Garamond", "Baskerville Adjusted", Baskerville, "Palatino Linotype", Palatino, serif;
    --font-mono: Iosevka, Menlo, Monaco, Consolas, 'Lucida Console', monospace;

    /* Breakpoints (for reference - can't use in media queries) */
    --breakpoint-tablet: 768px;
    --breakpoint-mobile: 640px;
}

html {
    color: var(--color-text);
    background-color: var(--color-bg);
    /* Paper texture: SVG noise + radial vignette */
    background-image:
        url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.4' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.1'/%3E%3C/svg%3E"),
        radial-gradient(ellipse at center, var(--color-bg-center) 0%, var(--color-bg-center) 45%, var(--color-bg-edge) 95%);
    background-attachment: fixed, fixed;
}

/* Adjusted fallback fonts - match metrics to reduce layout shift during font load */
@font-face {
    font-family: "Baskerville Adjusted";
    src: local("Baskerville");
    size-adjust: 96.5%;        /* Match Cormorant x-height: 38.6/40.0 */
    ascent-override: 92.4%;
    descent-override: 28.7%;
}

@font-face {
    font-family: "Big Caslon Adjusted";
    src: local("Big Caslon Medium");
    size-adjust: 92.1%;        /* Match Fell English x-height: 44.0/47.8 */
    ascent-override: 90.5%;
    descent-override: 36.3%;
}

/* Font faces - paths relative to /static/css/, WOFF2 with TTF fallback */
@font-face {
    font-family: "Fell English";
    src: url("../fonts/IMFellEnglishSC-Regular.woff2") format("woff2"),
         url("../fonts/IMFellEnglishSC-Regular.ttf") format("truetype");
    font-display: block;  /* Hide title until font loads (up to 3s) */
}

@font-face {
    font-family: "Cormorant Garamond";
    font-style: normal;
    font-weight: 400;
    src: url("../fonts/CormorantGaramond-Regular.woff2") format("woff2"),
         url("../fonts/CormorantGaramond-Regular.ttf") format("truetype");
    font-display: swap;
}

@font-face {
    font-family: "Cormorant Garamond";
    font-style: italic;
    font-weight: 400;
    src: url("../fonts/CormorantGaramond-Italic.woff2") format("woff2"),
         url("../fonts/CormorantGaramond-Italic.ttf") format("truetype");
    font-display: swap;
}

@font-face {
    font-family: "Cormorant Garamond";
    font-style: normal;
    font-weight: 300;
    src: url("../fonts/CormorantGaramond-Light.woff2") format("woff2"),
         url("../fonts/CormorantGaramond-Light.ttf") format("truetype");
    font-display: swap;
}

@font-face {
    font-family: "Cormorant Garamond";
    font-style: italic;
    font-weight: 300;
    src: url("../fonts/CormorantGaramond-LightItalic.woff2") format("woff2"),
         url("../fonts/CormorantGaramond-LightItalic.ttf") format("truetype");
    font-display: swap;
}

@font-face {
    font-family: "Cormorant Garamond";
    font-style: normal;
    font-weight: 500;
    src: url("../fonts/CormorantGaramond-Medium.woff2") format("woff2"),
         url("../fonts/CormorantGaramond-Medium.ttf") format("truetype");
    font-display: swap;
}

@font-face {
    font-family: "Cormorant Garamond";
    font-style: italic;
    font-weight: 500;
    src: url("../fonts/CormorantGaramond-MediumItalic.woff2") format("woff2"),
         url("../fonts/CormorantGaramond-MediumItalic.ttf") format("truetype");
    font-display: swap;
}

@font-face {
    font-family: "Cormorant Garamond";
    font-style: normal;
    font-weight: 600;
    src: url("../fonts/CormorantGaramond-SemiBold.woff2") format("woff2"),
         url("../fonts/CormorantGaramond-SemiBold.ttf") format("truetype");
    font-display: swap;
}

@font-face {
    font-family: "Cormorant Garamond";
    font-style: italic;
    font-weight: 600;
    src: url("../fonts/CormorantGaramond-SemiBoldItalic.woff2") format("woff2"),
         url("../fonts/CormorantGaramond-SemiBoldItalic.ttf") format("truetype");
    font-display: swap;
}

@font-face {
    font-family: "Cormorant Garamond";
    font-style: normal;
    font-weight: 700;
    src: url("../fonts/CormorantGaramond-Bold.woff2") format("woff2"),
         url("../fonts/CormorantGaramond-Bold.ttf") format("truetype");
    font-display: swap;
}

@font-face {
    font-family: "Cormorant Garamond";
    font-style: italic;
    font-weight: 700;
    src: url("../fonts/CormorantGaramond-BoldItalic.woff2") format("woff2"),
         url("../fonts/CormorantGaramond-BoldItalic.ttf") format("truetype");
    font-display: swap;
}

/* Masthead container - Gazette style with flanking meta */
.masthead {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 3px double var(--color-text);
    padding: 0.5em 2.5%;
    margin-bottom: 1em;
}

.frontispiece {
    flex-grow: 2;
    font-size: 5em;
    font-family: var(--font-display);
    text-align: center;
    margin: 0;
    line-height: 1;
}

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

/* Meta info on the wings */
.meta-left, .meta-right {
    flex-grow: 1;
    font-family: var(--font-display);
    font-size: 1rem;
    width: 15%;
}

.meta-right {
    text-align: right;
}

/* Body layout */
body {
    margin: 0 auto;
    max-width: 43em;
    padding: 50px;
    hyphens: auto;
    overflow-wrap: break-word;
    text-rendering: optimizeLegibility;
    font-kerning: normal;
    font-size: 1.3rem;
    font-family: var(--font-body);
    line-height: 1.5;
}

/* Main content narrower to align with masthead center */
main {
    padding-left: 15%;
    padding-right: 15%;
}

/* Three-column margins layout */
/* Override body and main constraints when using margins layout */
body:has(.margins-layout) {
    max-width: none;
    padding-left: 3rem;
    padding-right: 3rem;
}

main:has(.margins-layout) {
    padding-left: 0;
    padding-right: 0;
}

.margins-layout {
    display: grid;
    grid-template-columns:
        minmax(14rem, 1fr)
        minmax(20rem, 37rem)
        minmax(14rem, 1fr);
    gap: 0.5rem;
    width: 100%;
    padding: 0 1rem;
    box-sizing: border-box;
}

.margin {
    position: relative;
    font-size: 0.85rem;
    line-height: 1.4;
    font-family: var(--font-body);
}

.margin-left {
    grid-column: 1;
}

.body-text {
    grid-column: 2;
}

.margin-right {
    grid-column: 3;
}

/* Collapse to single column on narrow screens */
@media (max-width: 768px) {
    .margins-layout {
        display: block;
        max-width: 43em;
        padding: 0;
    }
    .margin {
        display: none;
    }
}

/* Publication name in title font (use *Almnck.*{.pub} in markdown) */
em.pub {
    font-family: var(--font-display);
    font-style: normal;
    font-weight: 800;
    text-shadow: 0.25px 0 0 currentColor;
}

/* Sidenote elements */
.sidenote {
    position: absolute;
    width: 100%;
    padding: 0.5em 0;
    display: flex;
    gap: 0.4em;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.4s ease-out, transform 0.4s ease-out;
}

/* Sidenotes materialize: fade in and float upward */
.sidenotes-ready .sidenote {
    opacity: 1;
    transform: translateY(0);
}

/* Disable transitions during programmatic repositioning to prevent jumping */
.repositioning .sidenote,
.repositioning .margin-box {
    transition: none !important;
}

/* Hide number, show manicule instead */
.sidenote-number {
    font-size: 1.1em;
    line-height: 1.3;
}

/* Hide number, manicule alone suffices */
.sidenote-numtext {
    display: none;
}

/* Left margin: content first, manicule on right pointing toward body */
.sidenote.margin-left {
    flex-direction: row;
}

.sidenote.margin-left .sidenote-number {
    order: 2;
    margin-left: auto;
}

.sidenote.margin-left .sidenote-number::after {
    content: "☞";
}

.sidenote.margin-left .sidenote-content {
    order: 1;
}

/* Right margin: manicule on left pointing toward body, then content */
.sidenote.margin-right {
    flex-direction: row;
}

.sidenote.margin-right .sidenote-number {
    order: 1;
}

.sidenote.margin-right .sidenote-number::before {
    content: "☜";
}

.sidenote.margin-right .sidenote-content {
    order: 2;
}

.sidenote-content {
    flex: 1;
}

.sidenote-content p {
    margin: 0 0 0.5em 0;
}

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

/* Collapsed state - keep flex layout, just hide content */
.sidenote.collapsed .sidenote-content {
    display: none;
}

.sidenote.collapsed .sidenote-number {
    margin-left: auto; /* Push to right for left margin */
}

.sidenote.collapsed.margin-right .sidenote-number {
    margin-left: 0; /* Reset for right margin */
}

/* Offset sidenotes: anchor marker stays at correct line, content floats down */
.sidenote-anchor-marker {
    position: absolute;
    display: none; /* Shown by JS when needed */
}

.sidenote.margin-left .sidenote-anchor-marker {
    right: 0;
}

.sidenote.margin-right .sidenote-anchor-marker {
    left: 0;
}

/* Hide the regular manicule when offset - the marker shows it instead */
.sidenote.sidenote-offset > .sidenote-number {
    visibility: hidden;
}

/* Dotted connector line from marker to content - emerges from manicule's wrist */
.sidenote-connector {
    position: absolute;
    opacity: 0;
    border-left: 1px dotted var(--color-subtle);
    width: 0;
    transition: opacity 0.6s ease;
}

/* Position connector on body-text side (near manicule finger) */
.sidenote.margin-left .sidenote-connector {
    right: 1.2rem;
}

.sidenote.margin-right .sidenote-connector {
    left: 1.2rem;
}

/* Show connector only on hover */
.sidenote.sidenote-offset:hover .sidenote-connector,
.sidenote.sidenote-offset.highlighted .sidenote-connector {
    opacity: 1;
}

/* Hide original footnotes when sidenotes are active */
.sidenotes-enabled .footnote {
    display: none;
}

/* Sidenote content - invisible border to prevent layout shift */
.sidenote .sidenote-content {
    border: 1px solid transparent;
    padding: 3px;
    transition: border-color 0.6s ease;
}

/* Bidirectional highlight - all four borders */
.sidenote.highlighted .sidenote-content {
    border: 1px dotted var(--color-subtle);
}

.footnote-ref.highlighted {
    outline: 1px dotted var(--color-subtle);
    outline-offset: 1px;
}

/* Hide footnotes section when sidenotes enabled */
.sidenotes-enabled .footnotes {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* Show footnotes on narrow screens */
@media (max-width: 768px) {
    .sidenotes-enabled .footnotes {
        position: static;
        width: auto;
        height: auto;
        padding: 0;
        margin: 0;
        overflow: visible;
        clip: auto;
    }
    .sidenotes-enabled .footnote {
        display: revert;
    }
}

/* Margin boxes - inline fallback for no-JS/mobile */
.margin-box {
    margin: 1.5em auto;
    max-width: 70%;
    padding: 1em;
    border-top: 1px solid var(--color-text);
    border-bottom: 1px solid var(--color-text);
    font-size: 0.9rem;
}

/* Hide margin-boxes in margins-layout until JS positions them */
.margins-layout .margin-box {
    opacity: 0;
}

/* JS enabled: boxes get absolutely positioned in margins */
.sidenotes-enabled .margin-box {
    position: absolute;
    width: 100%;
    margin: 0;
    max-width: none;
    border: none;
    padding: 0.5em 0;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.4s ease-out, transform 0.4s ease-out;
}

/* Margin boxes materialize with sidenotes */
.sidenotes-ready .margin-box {
    opacity: 1;
    transform: translateY(0);
}

/* Margin box type variants */
.margin-box[data-type="quote"] {
    font-style: italic;
    border-left: 2px solid var(--color-text);
    padding-left: 0.5em;
    border-top: none;
    border-bottom: none;
}

.margin-box[data-type="quote"] cite {
    display: block;
    margin-top: 0.5em;
    font-style: normal;
    font-size: 0.9em;
}

.margin-box[data-type="ad"] {
    border: 1px solid var(--color-text);
    padding: 0.5em;
    text-align: center;
}

.margin-box[data-type="aphorism"] {
    font-family: var(--font-display);
    text-align: center;
    font-size: 1rem;
}

.margin-box[data-type="poem"] {
    font-family: var(--font-body);
    font-size: 0.85rem;
    line-height: 1.4;
    border-top: none;
    border-bottom: none;
    padding: 0.25em 0;
}

.margin-box[data-type="poem"] em:first-child {
    display: block;
    font-style: italic;
    font-weight: 600;
    margin-bottom: 0.75em;
    text-align: left;
}

/* Match sidenote spacing from body text */
/* Left margin: content flush left like sidenotes */
.margin-box[data-type="poem"].margin-left {
    padding-left: 0;
    padding-right: 2em;
}

/* Right margin: indent to match manicule + gap */
.margin-box[data-type="poem"].margin-right {
    padding-left: 2em;
    padding-right: 0;
}

/* Top ornament */
.margin-box[data-type="poem"]::before {
    content: "❦";
    display: block;
    text-align: center;
    margin-bottom: 0.5em;
    font-size: 0.9em;
    color: var(--color-muted);
}

/* Bottom ornament */
.margin-box[data-type="poem"]::after {
    content: "❧";
    display: block;
    text-align: center;
    margin-top: 0.5em;
    font-size: 0.9em;
    color: var(--color-muted);
}

/* Sidenote preference toggle */
.sidenote-toggle {
    font-family: var(--font-display);
    font-size: 0.9rem;
}

.sidenote-toggle button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.2em 0.4em;
    color: var(--color-muted);
    font-family: inherit;
    font-size: inherit;
}

.sidenote-toggle button:hover {
    color: var(--color-text);
}

.sidenote-toggle button.active {
    color: var(--color-text);
    text-decoration: underline;
}

/* Hide toggle on narrow screens (sidenotes not shown) */
@media (max-width: 768px) {
    .sidenote-toggle {
        display: none;
    }
}

/* Full-bleed elements span all columns */
.full-bleed {
    grid-column: 1 / -1;
    width: 100%;
    margin: 2rem 0;
}

@media (max-width: 640px) {
    body {
        font-size: 1.2rem;
        padding: 20px;
    }
    /* Stack masthead vertically on mobile */
    .masthead {
        flex-direction: column;
        padding: 0.5em 0;
    }
    .frontispiece {
        font-size: 3rem;
        order: 1;
    }
    .meta-left, .meta-right {
        width: auto;
        text-align: center;
        font-size: 0.9rem;
    }
    .meta-left {
        order: 2;
    }
    .meta-right {
        order: 3;
    }
    /* Remove side padding on mobile */
    main {
        padding-left: 0;
        padding-right: 0;
    }
    /* Smaller title on mobile */
    header .title {
        font-size: 2rem;
    }
    /* Smaller drop cap on mobile */
    .initial {
        height: 4.5rem;
        margin-left: 0;
        margin-right: 0.3em;
    }
}

@media print {
    html {
        background-color: white;
    }
    body {
        background-color: transparent;
        color: black;
        font-size: 12pt;
    }
    p, h2, h3 {
        orphans: 3;
        widows: 3;
    }
    h2, h3, h4 {
        page-break-after: avoid;
    }
}

/* Typography */
p {
    margin: 1em 0;
}

a {
    color: var(--color-text);
}

a:visited {
    color: var(--color-text);
}

img {
    max-width: 100%;
    height: auto;
}

h1, h2, h3, h4, h5, h6 {
    margin-top: 1.4em;
}

h5, h6 {
    font-size: 1em;
    font-style: italic;
}

h6 {
    font-weight: normal;
}

ol, ul {
    padding-left: 1.7em;
    margin-top: 1em;
}

li > ol, li > ul {
    margin-top: 0;
}

blockquote {
    margin: 1em 0;
    padding: 0.5em 1em;
    border-left: 1px solid var(--color-subtle);
    border-right: 1px solid var(--color-subtle);
    font-style: italic;
    color: inherit;
}

/* Reverse italic: emphasis within italic blockquotes becomes roman */
blockquote em,
blockquote i {
    font-style: normal;
}

code {
    font-family: var(--font-mono);
    font-size: 85%;
    margin: 0;
    hyphens: manual;
}

pre {
    margin: 1em 0;
    overflow: auto;
}

pre code {
    padding: 0;
    overflow: visible;
    overflow-wrap: normal;
}

hr {
    background-color: var(--color-text);
    border: none;
    height: 1px;
    margin: 1em 0;
}

/* Article header - Gazette style */
header {
    margin-bottom: 2em;
    text-align: center;
}

header .title {
    text-align: center;
    font-family: var(--font-display);
    font-size: 3rem;
    font-variant: small-caps;
    letter-spacing: 0.05em;
    margin-top: 1em;
    margin-bottom: 0.1em;
}

header .title a {
    text-decoration: none;
    color: inherit;
}

header .date {
    display: none;
}

header .authorship {
    font-family: var(--font-display);
    font-size: 1rem;
    color: var(--color-dim);
    margin-top: 0;
    margin-bottom: 0;
}

header .byline {
    font-family: var(--font-display);
    font-size: 1rem;
    color: var(--color-dim);
    margin-top: 0;
    margin-bottom: 1.5em;
}

header .byline a,
header .authorship a {
    text-decoration: none;
    color: inherit;
}


/* Drop cap initial - sized to 4 lines with symmetric overhang */
.initial {
    float: left;
    margin-top: 0.3em;
    margin-left: 0.2em;
    margin-right: 0.2em;
    height: calc(9rem + 0.2em);
    width: auto;
}

/* Main article text */
.maintext {
    text-align: justify;
}

.maintext::first-line {
    font-size: 2rem;
    font-variant: small-caps;
    text-transform: lowercase;
    text-justify: inter-character;
}

.maintext > p:first-of-type {
    font-size: 1.5rem;
    font-weight: 600;
    text-align: justify;
}

/* Sign-off */
.signoff {
    margin-top: 3em;
    text-align: right;
    font-style: italic;
}

.signoff a {
    text-decoration: none;
}

/* Footnotes */
.footnotes,
.footnotes * {
    /* Reset first-line styling that leaks from .maintext::first-line on mobile */
    font-size: revert;
    font-variant: normal;
    text-transform: none;
}

.footnote {
    font-size: 0.85em;
    margin-top: 3em;
    margin-right: 1.7em;  /* match left indent from ol numbering */
}

.footnote hr {
    margin-right: -1.7em;  /* extend hr to full width */
}

.footnote-ref {
    text-decoration: none;
}

/* Force text rendering for backref arrow (prevents iOS emoji) */
.footnote-backref {
    font-family: var(--font-body);
}
.footnote-backref::after {
    content: "\FE0E";
}

sup {
    font-size: 0.8em;
}

/* Hide figure captions (used for decorative images) */
figcaption {
    display: none;
}

/* Margin figures - plate style presentation */
.figure {
    display: block;
    border: 1px solid var(--color-text);
    padding: 0.5em;
    margin: 0.5em 0.4em;
    background: var(--color-bg);
}

.figure img {
    display: block;
    width: 100%;
    height: auto;
}

/* Show and style captions for .figure elements */
.figure figcaption {
    display: block;
    position: relative;
    font-size: 0.8em;
    font-weight: 600;
    text-align: center;
    margin-top: 0.5em;
    padding-top: 0.5em;
    color: var(--color-dark);
}

.figure figcaption::before {
    content: "";
    position: absolute;
    top: 0;
    left: 10%;
    width: 80%;
    border-top: 1px solid var(--color-light);
}

@media (max-width: 768px) {
    .figure {
        margin: 1em auto;
        max-width: 80%;
    }
}

/* Interactive figures - ensure caption at bottom */
.figure[data-interactive] {
    display: flex;
    flex-direction: column;
}

.figure[data-interactive] figcaption {
    order: 999; /* Always last */
    margin-top: auto;
}

/* Lightbox dialog for enlarged figures */
#lightbox {
    border: none;
    background: transparent;
    max-width: 90vw;
    max-height: 90vh;
    padding: 1em;
}

#lightbox[open] {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#lightbox::backdrop {
    background: rgba(0, 0, 0, 0.85);
}

#lightbox img {
    max-width: 90vw;
    max-height: 80vh;
    object-fit: contain;
    cursor: zoom-out;
}

.lightbox-caption {
    position: relative;
    color: #fff;
    text-align: center;
    margin: 1em 0 0;
    padding-top: 0.8em;
    font-family: var(--font-body);
    font-size: 1.1rem;
    font-weight: 600;
    max-width: 60ch;
}

.lightbox-caption::before {
    content: "";
    position: absolute;
    top: 0;
    left: 10%;
    width: 80%;
    border-top: 1px solid rgba(255, 255, 255, 0.4);
}

.figure img {
    cursor: zoom-in;
}

/* Tables */
table {
    margin: 1em 0;
    border-collapse: collapse;
    width: 100%;
    overflow-x: auto;
    display: block;
    font-variant-numeric: lining-nums tabular-nums;
}

table caption {
    margin-bottom: 0.75em;
}

tbody {
    margin-top: 0.5em;
    border-top: 1px solid var(--color-text);
    border-bottom: 1px solid var(--color-text);
}

th {
    border-top: 1px solid var(--color-text);
    padding: 0.25em 0.5em;
}

td {
    padding: 0.125em 0.5em 0.25em 0.5em;
}

/* Index page */
.article-list {
    list-style: none;
    padding: 0;
}

.article-list li {
    margin: 1em 0;
    font-size: 1.2em;
}

.article-list .day {
    color: var(--color-muted);
    font-size: 0.9em;
}

/* Manual layout - override body/main constraints */
body:has(.manual-layout) {
    max-width: none;
    padding-left: 0;
    padding-right: 0;
}

main:has(.manual-layout) {
    padding-left: 0;
    padding-right: 0;
}

.manual-layout {
    display: grid;
    grid-template-columns: minmax(12rem, 14rem) minmax(20rem, 50rem) 1fr;
    gap: 2rem;
    width: 100%;
    padding: 2rem 3rem;
    box-sizing: border-box;
}

.manual-nav {
    grid-column: 1;
    position: sticky;
    top: 2rem;
    align-self: start;
    font-family: var(--font-body);
    padding-right: 1rem;
    border-right: 1px solid var(--color-rule);
}

.manual-nav h3 {
    font-family: var(--font-display);
    font-size: 1.2rem;
    margin-bottom: 0.5em;
    border-bottom: 1px solid var(--color-text);
    padding-bottom: 0.3em;
}

.manual-nav h3 a {
    text-decoration: none;
    color: inherit;
}

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

.manual-nav li {
    margin: 0.3em 0;
}

.manual-nav a {
    text-decoration: none;
    color: var(--color-text);
}

.manual-nav a:hover {
    text-decoration: underline;
}

.manual-nav li.active > a {
    font-weight: 600;
}

.manual-nav ul ul {
    padding-left: 1em;
    font-size: 0.9em;
}

.manual-content {
    grid-column: 2;
    min-width: 0;
}

.manual-content h1 {
    font-family: var(--font-display);
    font-size: 2rem;
    margin-top: 0;
}

.manual-content h2 {
    font-family: var(--font-display);
    font-size: 1.4rem;
    margin-top: 1.5em;
}

.manual-content pre {
    background: var(--color-code-bg);
    padding: 1em;
    overflow-x: auto;
    font-size: 0.9em;
}

.manual-content code {
    font-family: var(--font-mono);
}

.manual-content p code {
    background: var(--color-code-bg);
    padding: 0.1em 0.3em;
}

.nav-children {
    list-style: none;
    padding: 0;
    margin: 1em 0;
}

.nav-children li {
    margin: 0.5em 0;
}

@media (max-width: 768px) {
    .manual-layout {
        display: block;
        padding: 1rem;
    }

    .manual-nav {
        position: static;
        border-right: none;
        border-bottom: 1px solid var(--color-text);
        padding-right: 0;
        padding-bottom: 1em;
        margin-bottom: 1.5em;
    }
}

/* Back-of-book index styling */
.idx {
    margin: 0.5em 0;
}

/* All lists in index: no bullets */
.idx ul {
    list-style: none;
    margin: 0;
    padding-left: 0;
}

/* Nested lists (sub-entries): indent */
.idx li > ul {
    padding-left: 1.5em;
}

.idx li {
    margin: 0.15em 0;
    line-height: 1.4;
}

/* Tighten spacing for sub-entries */
.idx li > ul > li {
    margin: 0.1em 0;
}

/* Index links: no underline, dotted on hover */
.idx a {
    text-decoration: none;
    color: inherit;
}

.idx a:hover {
    text-decoration: underline dotted;
    text-underline-offset: 2px;
}


/* Index search plinth - ornate memorial tablet style */
#idx-search {
    display: none;
    margin: 0 auto 1em;
    max-width: 22em;
    text-align: center;
}

#idx-search.js-enabled {
    display: block;
}

/* The motto */
#idx-search .motto {
    font-variant: small-caps;
    letter-spacing: 0.15em;
    font-size: 0.85em;
    margin-bottom: 0.5em;
    color: var(--color-dim);
}

/* Outer ornamental frame */
#idx-search .plinth {
    border: 2px solid var(--color-muted);
    padding: 0.6em;
    position: relative;
    background: linear-gradient(to bottom, #fafafa 0%, #f5f5f0 100%);
    box-shadow:
        inset 0 0 0 1px #fff,
        inset 0 0 0 4px #e8e8e0,
        inset 0 0 0 5px #999,
        0 2px 4px rgba(0,0,0,0.1);
}

/* Corner flourishes using pseudo-elements */
#idx-search .plinth::before,
#idx-search .plinth::after {
    content: "❧";
    position: absolute;
    font-size: 1.2em;
    color: var(--color-faint);
    line-height: 1;
}

#idx-search .plinth::before {
    top: -0.6em;
    left: 0.5em;
}

#idx-search .plinth::after {
    top: -0.6em;
    right: 0.5em;
    transform: scaleX(-1);
}

/* Bottom flourishes */
#idx-search .plinth-bottom {
    position: absolute;
    bottom: -0.6em;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    padding: 0 0.5em;
}

#idx-search .plinth-bottom span {
    font-size: 1.2em;
    color: var(--color-faint);
    line-height: 1;
}

#idx-search .plinth-bottom span:first-child {
    transform: scaleY(-1);
}

#idx-search .plinth-bottom span:last-child {
    transform: scale(-1, -1);
}

/* Inner input container */
#idx-search .input-frame {
    border: 1px solid var(--color-border);
    background: #fff;
    display: flex;
    align-items: center;
    padding: 0.3em 0.5em;
}

#idx-search input {
    font-family: inherit;
    font-size: 1em;
    padding: 0.2em;
    flex: 1;
    border: none;
    background: transparent;
    text-align: center;
}

#idx-search input:focus {
    outline: none;
}

#idx-search input::placeholder {
    font-style: italic;
    color: var(--color-subtle);
}

/* Clear button */
#idx-search .clear-btn {
    background: none;
    border: none;
    font-size: 1.1em;
    color: var(--color-subtle);
    cursor: pointer;
    padding: 0 0.2em;
    line-height: 1;
    visibility: hidden;
}

#idx-search .clear-btn:hover {
    color: var(--color-dark);
}

#idx-search.has-text .clear-btn {
    visibility: visible;
}

/* Results count */
#idx-search .results-count {
    font-size: 0.75em;
    color: var(--color-muted);
    margin-top: 0.4em;
    font-variant: small-caps;
    letter-spacing: 0.1em;
    min-height: 1.2em;
}

/* Index letter navigation - justified across full width, auto-scaled by JS */
.idx-nav {
    margin: 0.5em 0 1em;
    overflow: hidden;
}

.idx-nav p {
    display: flex;
    justify-content: space-between;
    white-space: nowrap;
    margin: 0;
    font-size: 1.1em;
}

.idx-nav a {
    text-decoration: underline;
}

.idx-nav a:hover {
    text-decoration: underline dotted;
}

/* Hide search box when printing */
@media print {
    #idx-search {
        display: none !important;
    }
}

/* Frontpage Navigation */
.frontpage-nav {
    display: flex;
    justify-content: space-between;
    margin: 1rem 0;
    padding: 0.5rem 0;
    border-top: 1px solid var(--rule-color, #ccc);
    border-bottom: 1px solid var(--rule-color, #ccc);
}

.frontpage-nav a {
    text-decoration: none;
}

.frontpage-nav a:hover {
    text-decoration: underline;
}

.frontpage-nav-fallback {
    margin: 1rem 0;
    font-style: italic;
}

/* Chronology archive */
.chronology-entry {
    margin: 0.5rem 0;
    padding: 0.25rem 0;
}

.chronology-entry time {
    display: inline-block;
    width: 12em;
    color: var(--muted-color, #666);
}

.chronology-entry:target {
    background-color: var(--highlight-color, #ffffcc);
}

/* ==========================================================================
   NTK Style
   72-character monospace plain-text newsletter, circa 1997-2006
   ========================================================================== */

/* Expand body/main to allow NTK width on desktop */
body:has(.ntk) {
    max-width: none;
}

main:has(.ntk) {
    padding-left: 0;
    padding-right: 0;
}

.ntk {
    /* Container for horizontal scrolling on narrow screens */
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.ntk pre {
    /* Fixed 72-character width in monospace */
    font-family: var(--font-mono);
    font-size: 0.9rem;
    line-height: 1.35;

    /* Exact width for 72 characters + small padding */
    width: 74ch;
    max-width: none;

    /* Center the content */
    margin: 0 auto;
    padding: 1em 1ch;

    /* Preserve whitespace exactly */
    white-space: pre;
    overflow-wrap: normal;
    word-wrap: normal;

    /* Subtle styling */
    background: transparent;
    color: var(--color-text);
}

/* Override .maintext first-line styling that leaks into pre */
.ntk pre::first-line {
    font-size: inherit;
    font-variant: normal;
    text-transform: none;
}

/* Links within NTK should be subtle */
.ntk a {
    color: var(--color-text);
    text-decoration: underline;
    text-decoration-style: dotted;
}

.ntk a:hover {
    text-decoration-style: solid;
}

/* Mobile: shrink font to fit, with horizontal scroll as fallback */
@media (max-width: 768px) {
    body:has(.ntk) {
        max-width: none;
        padding: 10px;
    }

    .ntk pre {
        /* Scale font to fit 72ch in viewport */
        font-size: calc((100vw - 40px) / 74);
        padding: 0.5em 0;
    }
}
