/* Reader theme. Mobile-first, no JavaScript, system fonts only. */

:root {
    --accent: #1f5f8b;
    --bg: #fbfaf7;
    --surface: #ffffff;
    --text: #1d1b19;
    --muted: #6b665f;
    --line: #e6e1d8;
    --measure: 40rem;
    --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-read: Georgia, "Iowan Old Style", "Palatino Linotype", "Times New Roman", serif;
    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #16161a;
        --surface: #1e1e24;
        --text: #ebe8e2;
        --muted: #a39e95;
        --line: #32323a;
    }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 1rem;
    line-height: 1.6;
}

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

a { color: var(--accent); text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }
a:focus-visible, .button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.wrap { width: 100%; max-width: 62rem; margin: 0 auto; padding: 0 1rem; }

.skip-link { position: absolute; left: -999px; top: 0; background: var(--surface); padding: 0.5rem 1rem; z-index: 10; }
.skip-link:focus { left: 0.5rem; top: 0.5rem; }

.preview-notice { margin: 0; padding: 0.5rem 1rem; background: #b45309; color: #fff; font-size: 0.9rem; font-weight: 600; text-align: center; }

/* Header and footer */

.site-header { border-bottom: 1px solid var(--line); background: var(--surface); }
.site-header__inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 3.5rem; }
.site-brand { font-family: var(--font-read); font-size: 1.3rem; font-weight: 700; color: var(--text); text-decoration: none; }
.site-nav { display: flex; gap: 1rem; font-size: 0.95rem; }
.site-nav a { color: var(--muted); text-decoration: none; white-space: nowrap; }
.site-nav a:hover { color: var(--text); }

main.wrap { padding-top: 1.5rem; padding-bottom: 3rem; min-height: 60vh; }

.site-footer { border-top: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 0.9rem; }
.site-footer__inner { padding-top: 1.5rem; padding-bottom: 2rem; }
.site-footer__name { margin: 0 0 0.5rem; font-family: var(--font-read); font-weight: 700; color: var(--text); }
.site-footer__nav { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; margin-bottom: 0.75rem; }
.site-footer__nav a { color: var(--muted); }
.site-footer__copy { margin: 0; }

/* Shared pieces */

.page-head { margin: 1rem 0 2rem; }
.page-head__title { margin: 0 0 0.5rem; font-family: var(--font-read); font-size: clamp(1.7rem, 5vw, 2.4rem); line-height: 1.2; }
.page-head__lede { margin: 0 0 1rem; max-width: var(--measure); color: var(--muted); font-size: 1.05rem; }

.meta { margin: 0; color: var(--muted); font-size: 0.9rem; }
.empty { color: var(--muted); }

.button {
    display: inline-block;
    padding: 0.7rem 1.2rem;
    border: 1px solid var(--accent);
    border-radius: 0.5rem;
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    text-decoration: none;
    line-height: 1.2;
}
.button:hover { filter: brightness(1.08); }
.button--ghost { background: transparent; color: var(--accent); }

/* Home */

.story-grid { display: grid; gap: 1.25rem; grid-template-columns: 1fr; }
@media (min-width: 40rem) { .story-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 60rem) { .story-grid { grid-template-columns: repeat(3, 1fr); } }

.story-card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 0.75rem; overflow: hidden; }
.story-card__cover img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.story-card__body { padding: 1rem 1.1rem 1.2rem; display: flex; flex-direction: column; gap: 0.5rem; }
.story-card__title { margin: 0; font-family: var(--font-read); font-size: 1.2rem; line-height: 1.3; }
.story-card__title a { color: var(--text); text-decoration: none; }
.story-card__title a:hover { color: var(--accent); }
.story-card__excerpt { margin: 0; color: var(--muted); font-size: 0.95rem; }

.pager { display: flex; justify-content: space-between; margin-top: 2rem; }

/* Story overview */

.story { max-width: var(--measure); margin: 0 auto; }
.story__head { margin: 1rem 0 1.25rem; }
.story__title { margin: 0 0 0.5rem; font-family: var(--font-read); font-size: clamp(1.8rem, 6vw, 2.6rem); line-height: 1.15; }
.story__cover { width: 100%; aspect-ratio: 1200 / 630; object-fit: cover; border-radius: 0.75rem; margin-bottom: 1.25rem; }

.toc { margin-top: 2rem; }
.toc__heading { font-size: 1rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0 0 0.5rem; }
.toc__list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.toc__list a { display: flex; gap: 0.9rem; align-items: baseline; padding: 0.85rem 0.25rem; border-bottom: 1px solid var(--line); color: var(--text); text-decoration: none; }
.toc__list a:hover .toc__title { color: var(--accent); }
.toc__no { flex: 0 0 1.75rem; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }

/* Chapter */

.chapter { max-width: var(--measure); margin: 0 auto; }
.chapter__head { margin: 1rem 0 1.5rem; }
.chapter__crumb { margin: 0 0 0.5rem; color: var(--muted); font-size: 0.9rem; }
.chapter__crumb a { color: var(--muted); }
.chapter__title { margin: 0; font-family: var(--font-read); font-size: clamp(1.6rem, 5.5vw, 2.2rem); line-height: 1.2; }

.prose { font-family: var(--font-read); font-size: 1.125rem; line-height: 1.75; overflow-wrap: break-word; }
.prose--reading { font-size: 1.1875rem; line-height: 1.8; }
.prose > :first-child { margin-top: 0; }
.prose p { margin: 0 0 1.25em; }
.prose h2, .prose h3 { font-size: 1.3em; line-height: 1.3; margin: 1.8em 0 0.6em; }
.prose h3 { font-size: 1.12em; }
.prose blockquote { margin: 1.5em 0; padding-left: 1em; border-left: 3px solid var(--line); color: var(--muted); }
.prose img { border-radius: 0.5rem; margin: 1.5em auto; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
.prose table { width: 100%; border-collapse: collapse; font-family: var(--font-ui); font-size: 0.95rem; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--line); padding: 0.5rem 0.75rem; text-align: left; }

.chapter-nav { display: flex; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }
@media (max-width: 30rem) {
    .chapter-nav .button { flex: 1 1 100%; text-align: center; }
}

/* Story extras */

.story__tags { margin: 0 0 1rem; }

.related { margin-top: 2.5rem; }
.related__list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.related__list li { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; padding: 0.8rem 0.25rem; border-bottom: 1px solid var(--line); }
.related__list a { color: var(--text); text-decoration: none; font-family: var(--font-read); font-size: 1.05rem; }
.related__list a:hover { color: var(--accent); }

/*
  Advertising. Positions are fixed by the theme. Space is reserved so the page does not shift when an ad loads,
  every unit is labelled, and the end-of-chapter unit keeps a clear distance from the navigation buttons.
*/

.ad-slot { clear: both; margin: 2.5rem 0; padding: 0; text-align: center; min-height: calc(var(--ad-min-height, 280px) + 1.6rem); overflow: hidden; }
.ad-slot__label { margin: 0 0 0.4rem; font-family: var(--font-ui); font-size: 0.7rem; line-height: 1.2rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.ad-slot__placeholder { display: flex; align-items: center; justify-content: center; min-height: var(--ad-min-height, 280px); padding: 1rem; border: 1px dashed var(--line); border-radius: 0.5rem; color: var(--muted); font-family: var(--font-ui); font-size: 0.85rem; }
.prose + .chapter-nav, .ad-slot + .chapter-nav { margin-top: 3rem; }
.prose > .ad-slot:last-child { margin-bottom: 5rem; }
.story-grid > .ad-slot { grid-column: 1 / -1; margin: 0.5rem 0; }

/* Share links */

.share { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; margin: 2rem 0 0; font-family: var(--font-ui); font-size: 0.95rem; }
.share__label { color: var(--muted); }
.share a { padding: 0.35rem 0.8rem; border: 1px solid var(--line); border-radius: 999px; color: var(--text); text-decoration: none; }
.share a:hover { border-color: var(--accent); color: var(--accent); }

/* Cookie consent. Until the reader accepts, no ad is requested, so the reserved ad space is removed. */

.consent-pending .ad-slot { display: none; }
.consent { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.12); font-family: var(--font-ui); font-size: 0.95rem; }
.consent[hidden] { display: none; }
.consent__inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem 1.5rem; padding-top: 0.9rem; padding-bottom: 0.9rem; }
.consent__text { margin: 0; flex: 1 1 20rem; }
.consent__actions { display: flex; gap: 0.6rem; }
.consent__actions .button { min-width: 6.5rem; text-align: center; cursor: pointer; font: inherit; font-weight: 600; }
.site-footer__copy a { margin-left: 0.75rem; color: var(--muted); }
