/* fsb-v1.css : Fillmore Street Books, first upgrade version.
   One stylesheet. Plain CSS. Tokens first, then components, then page templates.
   Spec: docs/DESIGN-SPEC-v1.md. Fonts: Literata and Work Sans (SIL OFL 1.1), self-hosted in fonts/.

   Two kinds of body markup are styled:
   - EmDash (the real target): Portable Text rendered by EmDash components. Classes: figure.emdash-image
     (+ .emdash-image--align-left/right/center/wide/full), figure.emdash-embed, .emdash-break-dots/-line,
     .has-text-align-center/right/justify, plain p, h2..h4, ul, ol, blockquote, a, strong, em.
   - LEGACY ONLY: the old WordPress HTML while legacy_pages are served as raw HTML (figure.wp-caption, alignleft/right,
     div.wp-caption wrappers, .mceTemp, .wp-video, inline width and text-align). Those rules are marked LEGACY below
     and can be deleted when no page is served as raw HTML any more. */

/* ---------- 1. Fonts (self-hosted, nothing fetched from third parties) ---------- */
@font-face {
  font-family: "Literata";
  src: url("fonts/literata-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Literata";
  src: url("fonts/literata-latin-wght-italic.woff2") format("woff2");
  font-weight: 200 900;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Work Sans";
  src: url("fonts/work-sans-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* ---------- 2. Tokens ---------- */
:root {
  /* colour */
  --paper: #fffefa;        /* page background */
  --ink: #2b2825;          /* body text */
  --ink-soft: #5a544c;     /* bylines, captions, small print */
  --brick: #86280f;        /* links, wordmark, buttons (the site's existing red-brown, nudged darker for 7:1 on the yellow) */
  --brick-deep: #6a1f0c;   /* hover for brick things */
  --butter: #ffe895;       /* masthead band (the site's existing yellow) */
  --butter-edge: #d9c46a;  /* thin line under the band (decoration only) */
  --teal-deep: #1c516a;    /* footer (the site's existing teal, darkened for contrast) */
  --on-teal: #ffffff;      /* text on the footer */
  --rule: #ddd6c8;         /* hairlines (decoration only) */
  --tint: #f5f0e2;        /* table heads, quote background */
  --visited: #5b3a63;      /* visited links in lists */
  --focus: #0f4c6b;        /* keyboard focus ring */
  --field-edge: #6b6355;   /* border of form fields (3:1 against the band and paper) */

  /* EmDash component hooks: its own scoped CSS reads these, with a #666 fallback (5.69:1, below our 7:1 target) */
  --emdash-caption-color: var(--ink-soft);
  --emdash-break-dots-color: var(--ink-soft);
  --emdash-break-color: var(--rule);

  /* type */
  --serif: "Literata", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: "Work Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --step--1: 0.875rem;   /* 14px: captions, bylines, buttons, small print */
  --step-0: 1.125rem;    /* 18px: body */
  --step-1: 1.25rem;     /* 20px: h3, result titles */
  --step-2: 1.5rem;      /* 24px: h2 */
  --step-3: 1.875rem;    /* 30px: h1 on small screens */
  --step-4: 2.25rem;     /* 36px: h1 on large screens */
  --step-5: 2.75rem;     /* 44px: site name on large screens */

  /* space (4px steps) */
  --s-1: 0.25rem;
  --s-2: 0.5rem;
  --s-3: 0.75rem;
  --s-4: 1rem;
  --s-5: 1.5rem;
  --s-6: 2rem;
  --s-7: 3rem;
  --s-8: 4rem;

  /* layout */
  --measure: 35rem;       /* text column: 560px, 54 to 72 characters per line (average about 64) at 18px */
  --col-title: 46rem;     /* title block of a text page, so a long title wraps to 2 lines */
  --col-mid: 58rem;       /* film list, search results, cartoons */
  --col-max: 70rem;       /* header, footer, home grid, indexes */
  --gutter: 1rem;
}
@media (min-width: 37.5em) { :root { --gutter: 1.5rem; } }

/* ---------- 3. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: var(--step-0);
  line-height: 1.65;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;   /* a long word never makes the page scroll sideways (seen at 200% text on a 320px screen) */
}
img, video, iframe { max-width: 100%; height: auto; }
img { display: block; }
a { color: var(--brick); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { color: var(--brick-deep); text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 2px; }
::selection { background: var(--butter); color: var(--ink); }

.skip-link {
  position: absolute; left: var(--s-4); top: -4rem; z-index: 10;
  background: var(--ink); color: #fff; font-family: var(--sans); font-weight: 600;
  padding: var(--s-3) var(--s-4); border-radius: 3px;
}
.skip-link:focus { top: var(--s-3); }
.skip-link:focus-visible { outline-color: #fff; outline-offset: -5px; }
.screen-reader-text {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* ---------- 4. Header: masthead, menu, search ---------- */
.site-header { background: var(--butter); border-bottom: 1px solid var(--butter-edge); }
.wrap { max-width: var(--col-max); margin-inline: auto; padding-inline: var(--gutter); }

/* logo and name are ONE link to home: one Tab stop. The image has empty alt because the name sits right beside it. */
.brand { margin: 0; padding-block: var(--s-4) var(--s-3); display: flex; justify-content: center; }
.brand a { display: inline-flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: var(--s-3); text-decoration: none; color: var(--brick); }
.brand img { width: min(4.5rem, 18vw); height: auto; flex: none; }
.brand-name { font-family: var(--serif); font-weight: 700; font-size: var(--step-2); line-height: 1.12; text-align: center; min-width: 0; }
.brand a:hover .brand-name { color: var(--brick-deep); text-decoration: underline; text-decoration-thickness: 2px; }
@media (min-width: 37.5em) {
  .brand { padding-block: var(--s-5) var(--s-4); }
  .brand a { gap: var(--s-5); }
  .brand img { width: 7.5rem; }
  .brand-name { font-size: var(--step-5); }
}

.nav-row {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: var(--s-2) var(--s-5);
  border-top: 1px solid var(--butter-edge);
  padding-block: var(--s-1) var(--s-3);
}
.site-nav ul { display: flex; flex-wrap: wrap; gap: 0 var(--s-1); margin: 0; padding: 0; list-style: none; }
.site-nav a {
  display: block; padding: var(--s-3) var(--s-3) calc(var(--s-3) - 3px);
  font-family: var(--sans); font-weight: 600; font-size: 1rem; letter-spacing: 0.005em;
  color: var(--ink); text-decoration: none; border-bottom: 3px solid transparent;
}
.site-nav a:hover { border-bottom-color: var(--ink); }
/* aria-current="page" = this exact page; aria-current="true" = a page inside this section */
.site-nav a[aria-current] { color: var(--brick); border-bottom-color: var(--brick); }

.search-form { display: flex; flex-wrap: wrap; gap: var(--s-2); width: 100%; max-width: 100%; }
@media (min-width: 37.5em) { .search-form { width: auto; } }
.search-form label { flex: 1 1 auto; min-width: 0; }
.search-field, .search-submit { font-family: var(--sans); font-size: 1rem; line-height: 1.2; min-height: 2.75rem; border-radius: 3px; }
.search-field {
  width: 100%; min-width: 0; padding: 0 var(--s-3);
  background: #fff; color: var(--ink); border: 1px solid var(--field-edge);
}
@media (min-width: 37.5em) { .search-field { width: 14rem; } }
.search-field::placeholder { color: var(--ink-soft); opacity: 1; }
.search-submit, .button, .filmlink {
  display: inline-block; cursor: pointer; border: 0;
  background: var(--brick); color: #fff;
  font-family: var(--sans); font-weight: 600; font-size: var(--step--1);
  padding: 0.7rem 1.1rem; border-radius: 3px; text-decoration: none; text-align: center;
}
.search-submit { padding-inline: var(--s-4); }
.search-submit:hover, .button:hover, .filmlink:hover { background: var(--brick-deep); color: #fff; }

/* ---------- 5. Page frame and title block ---------- */
main { display: block; padding-block: var(--s-6) var(--s-8); }
.page { max-width: var(--col-title); margin-inline: auto; padding-inline: var(--gutter); }
.page--mid { max-width: var(--col-mid); }
.page--wide { max-width: var(--col-max); }
/* on a text page the title block is wider than the text, so the title wraps to two lines at most */
.page--text > :not(.entry-header) { max-width: var(--measure); margin-inline: auto; }

.entry-header { margin-bottom: var(--s-6); text-align: center; }
.entry-title {
  margin: 0; font-family: var(--serif); font-weight: 600; font-size: var(--step-3);
  line-height: 1.2; letter-spacing: -0.005em; text-wrap: balance;
}
@media (min-width: 37.5em) { .entry-title { font-size: var(--step-4); } }
.story-byline {
  margin: var(--s-3) 0 0; font-family: var(--sans); font-weight: 500;
  font-size: var(--step--1); color: var(--ink-soft);
}

/* ---------- 6. Article body: plain text, no per-page styling ---------- */
.entry-content > :first-child { margin-top: 0; }
.entry-content p, .entry-content ul, .entry-content ol, .entry-content blockquote,
.entry-content figure, .entry-content table { margin: 0 0 1.1em; }
.entry-content h2, .entry-content h3, .entry-content h4 { clear: both; text-wrap: balance; }
.entry-content h2 { margin: 2.2em 0 0.6em; font-family: var(--serif); font-weight: 700; font-size: var(--step-2); line-height: 1.25; }
.entry-content h3 { margin: 1.8em 0 0.5em; font-family: var(--serif); font-weight: 700; font-size: var(--step-1); line-height: 1.3; }
.entry-content h4 { margin: 1.6em 0 0.4em; font-family: var(--sans); font-weight: 600; font-size: 1rem; line-height: 1.4; }
.entry-content strong, .entry-content b { font-weight: 700; }
.entry-content ul, .entry-content ol { padding-left: 1.5em; }
.entry-content li { margin-bottom: 0.35em; padding-left: 0.2em; }
.entry-content li::marker { color: var(--brick); }
.entry-content blockquote {
  margin-inline: 0; padding: var(--s-1) var(--s-5); border-left: 3px solid var(--brick);
  background: var(--tint); font-style: italic;
}
.entry-content blockquote p:last-child { margin-bottom: 0; }
.entry-content hr, .entry-content .emdash-break-line { border: 0; border-top: 1px solid var(--rule); margin: 2em 0; }
.entry-content .emdash-break-dots { margin: 1.5em 0; font-size: 1rem; }  /* scene break "• • •"; colour from --emdash-break-dots-color */
.entry-content del { color: var(--ink-soft); }
.entry-content sub, .entry-content sup { line-height: 0; }

/* Text alignment from the editor: EmDash writes a class. LEGACY pages carry inline text-align instead; both are respected. */
.entry-content .has-text-align-center { text-align: center; }
.entry-content .has-text-align-right { text-align: right; }

/* a few old pages carry a second title block inside the body (War Letters). LEGACY ONLY: show it as a section heading */
.entry-content .entry-header { margin: 2.4em 0 0.8em; text-align: center; }
.entry-content .entry-header .entry-title { font-size: var(--step-2); line-height: 1.25; }

/* Images with captions.
   EmDash: figure.emdash-image [+ --align-left/right/center/wide/full], plain figcaption (EmDash's own CSS centres it in #666 and
   floats up to 50 percent; the selectors below carry one extra element name so they win without !important).
   LEGACY ONLY: figure.wp-caption.alignleft/alignright/alignnone with an inline width="300px". Same rules, so both look alike. */
.entry-content img { height: auto; }
.entry-content figure.emdash-image, .entry-content figure.wp-caption {
  width: fit-content; max-width: 100%; margin: 1.5rem auto;
}
.page .entry-content figure.emdash-image figcaption, .entry-content figure.wp-caption figcaption, .wp-caption-text,
.entry-content figure.emdash-embed figcaption {
  margin-top: var(--s-2); font-family: var(--sans); font-size: var(--step--1); line-height: 1.45;
  color: var(--ink-soft); text-align: left;
}
.entry-content figure.emdash-image--align-wide, .entry-content figure.emdash-image--align-full { width: 100%; }
@media (min-width: 37.5em) {
  .entry-content figure.emdash-image--align-left, .entry-content figure.emdash-image--align-right,
  .entry-content figure.alignleft, .entry-content figure.alignright {
    max-width: min(18.75rem, 44%); margin-top: 0.3em; margin-bottom: 1em;
  }
  .entry-content figure.emdash-image--align-right, .entry-content figure.alignright { float: right; margin-left: var(--s-5); margin-right: 0; }
  .entry-content figure.emdash-image--align-left, .entry-content figure.alignleft { float: left; margin-right: var(--s-5); margin-left: 0; }
  .entry-content img.alignright { float: right; margin: 0.3em 0 1em var(--s-5); }   /* LEGACY: bare img without figure */
  .entry-content img.alignleft { float: left; margin: 0.3em var(--s-5) 1em 0; }     /* LEGACY */
}
.entry-content p:has(> img:only-child), .entry-content p:has(> a:only-child > img:only-child) { text-align: center; }
.entry-content div.wp-caption { display: contents; }                     /* LEGACY: old wrapper div around the figure */
.entry-content div.wp-caption:not(:has(img)) { display: none; }         /* LEGACY: empty wrapper left by the old editor */
.entry-content .mceTemp:empty { display: none; }                         /* LEGACY */

/* gallery: a plain wrapping row of thumbnails (none in the content today) */
.entry-content .gallery { display: flex; flex-wrap: wrap; gap: var(--s-3); margin-bottom: 1.1em; }
.entry-content .gallery-item { margin: 0; flex: 0 1 calc(33.333% - var(--s-3)); }

/* tables: scroll sideways inside the column rather than break the page (none in the content today) */
.entry-content table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; font-size: 1rem; }
.entry-content th, .entry-content td { padding: var(--s-2) var(--s-3); border: 1px solid var(--rule); text-align: left; vertical-align: top; }
.entry-content th { background: var(--tint); font-family: var(--sans); font-weight: 600; font-size: var(--step--1); }

/* video and flipbook. EmDash: figure.emdash-embed (16:9 box, native controls). LEGACY: .wp-video wrapper with inline width */
.entry-content figure.emdash-embed { margin: 1.5rem 0; }
.entry-content .wp-video { max-width: 100%; margin: 0 auto 1.1em; }          /* LEGACY */
.entry-content .wp-video video { display: block; width: 100%; height: auto; background: #000; }
.flipbook { max-width: 100%; margin: 0 auto 1.5rem; }
.flipbook iframe, .flipbook > div { max-width: 100%; }

/* ---------- 7. Previous / next, store line (generated by the layout, not typed in the body) ---------- */
/* a grid, so a lone "Next" stays on the right and a lone "Previous" on the left */
.subnav {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: var(--s-2) var(--s-4); align-items: center;
  margin-top: var(--s-7); padding-top: var(--s-4); border-top: 1px solid var(--rule);
  font-family: var(--sans); font-weight: 600; font-size: var(--step--1);
}
.subnav a { display: inline-block; padding: var(--s-3) var(--s-1); text-decoration: none; }
.subnav a:hover { text-decoration: underline; text-decoration-thickness: 2px; }
.subnav .left { grid-column: 1; justify-self: start; }
.subnav .stories-home { grid-column: 2; justify-self: center; }
.subnav .right { grid-column: 3; justify-self: end; }
@media (max-width: 37.49em) {
  .subnav .stories-home { grid-column: 1 / -1; grid-row: 2; }
}
.go-to-store { margin: var(--s-5) auto 0; text-align: center; font-size: 1rem; color: var(--ink-soft); }
.go-to-store p { margin: 0; }
.go-to-store a { font-weight: 600; }

/* ---------- 8. Page templates ---------- */
/* Home: eight covers in a grid; the old body markup (p > a > img) is used as it is */
.page--home .entry-header { margin: 0; }
.page--home .entry-content { display: grid; gap: var(--s-4); grid-template-columns: 1fr; }
@media (min-width: 35em) { .page--home .entry-content { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 56.25em) { .page--home .entry-content { grid-template-columns: repeat(4, 1fr); gap: var(--s-5); } }
.page--home .entry-content p { margin: 0; }
.page--home .entry-content a { display: block; line-height: 0; }
.page--home .entry-content img {
  float: none; margin: 0; width: 100%; aspect-ratio: 1 / 1; object-fit: cover;
}
/* EmDash form: each tile is a linked image block (figure.emdash-image), stored left-aligned; the grid places it */
.page--home .entry-content figure.emdash-image { float: none; width: auto; max-width: none; margin: 0; }
.page--home .entry-content a:hover img { outline: 3px solid var(--brick); outline-offset: -3px; }
.page--home .entry-content a:focus-visible { outline-offset: 4px; }

/* Index pages. Stories: always-open sections, each an h2 and a list of title links, in columns.
   Essays: a numbered list of links. Both are generated by the layout from the pages' category and order. */
.story-category { margin-bottom: var(--s-6); padding-top: var(--s-4); border-top: 1px solid var(--rule); }
.story-category h2 { margin: 0 0 var(--s-3); font-family: var(--serif); font-weight: 700; font-size: var(--step-2); line-height: 1.25; }
.entry-content .index-list { margin: 0; padding: 0; list-style: none; }
.entry-content .index-list li { margin: 0; padding: 0; }
.index-list a { display: block; padding-block: 0.4rem; text-decoration: none; }
.index-list a:hover { text-decoration: underline; text-decoration-thickness: 2px; }
.index-list a:visited { color: var(--visited); }
.index-list--cols { column-width: 16rem; column-gap: var(--s-6); }
.index-list--cols li { break-inside: avoid; font-size: 1rem; line-height: 1.4; }
.index-list--lines li { border-bottom: 1px solid var(--rule); }
.index-list--lines a { padding-block: 0.6rem; }
.entry-content ol.index-list { padding-left: 2.2rem; list-style: decimal; }
.entry-content ol.index-list li::marker { color: var(--ink-soft); font-family: var(--sans); font-size: var(--step--1); }

/* Films index: one block per film, video beside the text on wide screens */
.entry-section { margin-bottom: var(--s-7); padding-top: var(--s-5); border-top: 1px solid var(--rule); display: flow-root; }
.entry-section:first-child { border-top: 0; padding-top: 0; }
.entry-section h2 { margin: 0 0 var(--s-2); font-size: var(--step-2); }
.entry-section > p:not(:last-of-type) { margin-bottom: 0.4em; }
.entry-section .filmlink { margin-top: var(--s-3); }
.entry-section a:has(.filmlink) { text-decoration: none; display: inline-block; }
@media (min-width: 48em) {
  .entry-section .wp-video, .entry-section .emdash-embed { float: left; width: 48%; margin: 0 var(--s-6) var(--s-4) 0; }
}

/* Search results and 404 */
.search-results .entry-header { margin-bottom: var(--s-5); }
.result { padding-block: var(--s-5); border-top: 1px solid var(--rule); }
.result h2 { margin: 0 0 var(--s-2); font-size: var(--step-1); line-height: 1.3; }
.result h2 a { text-decoration: none; }
.result h2 a:hover { text-decoration: underline; text-decoration-thickness: 2px; }
.result p { margin: 0 0 var(--s-2); }
.result .read-more { font-family: var(--sans); font-weight: 600; font-size: var(--step--1); }
.error-404 .entry-header { margin-bottom: var(--s-5); }
.error-404 .search-form { max-width: 24rem; margin-inline: auto; }
.error-404 .search-field { width: 100%; }
.error-404 p { text-align: center; }

/* ---------- 9. Footer ---------- */
.site-footer { background: var(--teal-deep); color: var(--on-teal); font-family: var(--sans); font-size: 1rem; line-height: 1.55; }
.site-footer :focus-visible { outline-color: var(--butter); }
.site-footer a { color: var(--on-teal); text-decoration-thickness: 1px; }
.site-footer a:hover { color: var(--butter); text-decoration-thickness: 2px; }
.footer-widgets { display: grid; gap: var(--s-6); padding-block: var(--s-7) var(--s-6); }
.footer-widgets > section { min-width: 0; overflow-wrap: anywhere; }
@media (min-width: 48em) { .footer-widgets { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.3fr); gap: var(--s-7); } }
.site-footer h2 { margin: 0 0 var(--s-3); font-family: var(--serif); font-weight: 700; font-size: var(--step-1); line-height: 1.3; color: var(--on-teal); }
.site-footer p { margin: 0 0 var(--s-3); }
.site-footer .widget-links { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-5); margin: 0; padding: 0; list-style: none; }
.site-footer .widget-links a { display: inline-block; padding-block: 0.7rem; font-weight: 600; }
.site-footer p a { display: inline-block; padding-block: 0.3rem; }
.site-footer .site-credit { margin: 0; padding-block: var(--s-4) var(--s-6); border-top: 1px solid rgba(255, 255, 255, 0.35); font-size: var(--step--1); }

/* ---------- 10. Motion ---------- */
@media (prefers-reduced-motion: no-preference) {
  .search-submit, .button, .filmlink, .site-nav a { transition: background-color 0.12s, border-color 0.12s; }
}

/* ---------- 11. Picture overlay (scripts/emdash-site/v1/lightbox.js) ---------- */
.lightbox-open { overflow: hidden; }
.lightbox { border: 0; padding: var(--s-4); background: var(--paper); color: var(--ink); border-radius: 3px; max-width: min(96vw, 60rem); max-height: 94vh; width: auto; overflow: auto; }
.lightbox::backdrop { background: rgba(20, 17, 14, 0.82); }
.lightbox img { display: block; max-width: 100%; max-height: 78vh; width: auto; height: auto; margin: var(--s-3) auto 0; }
.lightbox-caption { margin: var(--s-3) 0 0; font-family: var(--sans); font-size: var(--step--1); line-height: 1.45; color: var(--ink-soft); }
.lightbox-close { display: block; margin-left: auto; font-family: var(--sans); font-size: 1rem; font-weight: 600; min-height: 2.75rem; padding: 0 var(--s-4); background: var(--brick); color: #fff; border: 0; border-radius: 3px; cursor: pointer; }
.lightbox-close:hover { background: var(--brick-deep); }
