/* /historic-floods — the written-account collections (historic-floods.php, includes/historic-floods.php,
   public/historic-floods.js). Phone first. Reads the v4 chrome's theme tokens where that chrome is on (dark by default,
   light under :root[data-theme=light], as /recorded-floods does); the classic chrome has no tokens, so each falls back to
   the v4 light value. Two voices: the interface in the site's sans, the record itself (the figures, the dates, the quoted
   words) in a book serif already on the reader's device (no font is fetched). Purple is the BHS chronology (the history
   map's documented-flood colour), teal the JBA Trust's. */

body.hfp-page { background: var(--v4-bg, #f3f6fb); margin: 0; }
:root[data-theme="dark"] body.hfp-page { color-scheme: dark; }
:root[data-theme="light"] body.hfp-page { color-scheme: light; }

.hfp {
  --hfp-bg: var(--v4-bg, #f3f6fb); --hfp-panel: var(--v4-panel, #fff); --hfp-border: var(--v4-border, #d0d9e6);
  --hfp-ink: var(--v4-text, #123051); --hfp-muted: var(--v4-muted, #536581); --hfp-accent: var(--v4-accent, #087fda);
  --hfp-doc: #6c3fc4; --hfp-jba: #0f8f7e; --hfp-tint: color-mix(in srgb, var(--hfp-doc) 7%, var(--hfp-panel));
  --hfp-serif: Charter, 'Bitstream Charter', 'Iowan Old Style', 'Sitka Text', Cambria, Georgia, serif;
  --dfr-accent: var(--hfp-doc);
  color: var(--hfp-ink); background: var(--hfp-bg); line-height: 1.55; font-size: 16px;
  font-family: var(--v4-font, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
  padding-bottom: 2.5rem;
}
:root:not([data-theme=light]) .hfp { --hfp-doc: #c39bff; --hfp-jba: #2dd4bf; }
/* The classic chrome sets no data-theme and no tokens: keep it light. */
:root:not([data-theme]) .hfp { --hfp-doc: #6c3fc4; --hfp-jba: #0f8f7e; }

.hfp *, .hfp *::before, .hfp *::after { box-sizing: border-box; }
.hfp [hidden] { display: none !important; }
.hfp-wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.hfp h1, .hfp h2, .hfp h3 { color: var(--hfp-ink); letter-spacing: -.02em; line-height: 1.15; margin: 0; }
.hfp a { color: var(--hfp-accent); }
.hfp :focus-visible { outline: 2px solid var(--hfp-accent); outline-offset: 2px; border-radius: 4px; }

/* ── the opening ── */
.hfp-hero { padding: 2rem 0 1.4rem; }
.hfp-kicker { margin: 0 0 .4rem; font-size: .9rem; font-weight: 700; color: var(--hfp-doc); }
.hfp h1 { font-size: clamp(2.1rem, 7vw, 3.4rem); font-weight: 800; letter-spacing: -.035em; }
.hfp-lede { margin: .8rem 0 0; color: var(--hfp-muted); max-width: 60ch; font-size: 1.04rem; }
.hfp-stats { display: grid; grid-template-columns: 1fr 1fr; margin: 1.6rem 0 0; border-top: 1px solid var(--hfp-border); }
.hfp-stat { display: flex; flex-direction: column-reverse; justify-content: flex-end; padding: .9rem .9rem .2rem 0; border-bottom: 1px solid var(--hfp-border); min-width: 0; }
.hfp-stat:nth-child(2n) { padding-left: .9rem; border-left: 1px solid var(--hfp-border); }
.hfp-stat dt { font-size: .82rem; color: var(--hfp-muted); margin-top: .1rem; }
.hfp-stat dd { margin: 0; font-family: var(--hfp-serif); font-size: clamp(1.9rem, 7vw, 2.9rem); font-weight: 600; line-height: 1.05;
  font-variant-numeric: lining-nums tabular-nums; letter-spacing: -.01em; color: var(--hfp-ink); }
.hfp-stat dd a { color: inherit; text-decoration: none; border-bottom: 2px solid color-mix(in srgb, var(--hfp-doc) 55%, transparent); }
.hfp-stat dd a:hover { border-bottom-color: var(--hfp-doc); }

/* ── the tools: collection chips and the place filter, held at the top while reading ── */
.hfp-tools { background: var(--hfp-bg); border-bottom: 1px solid var(--hfp-border); }
.hfp-tools-in { display: flex; flex-wrap: wrap; align-items: center; gap: .55rem 1rem; padding-top: .6rem; padding-bottom: .6rem; }
.hfp-chips { display: flex; gap: .35rem; flex: 1 1 100%; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
.hfp-chips::-webkit-scrollbar { display: none; }
.hfp-chip { display: inline-flex; flex: none; align-items: center; gap: .45rem; min-height: 40px; padding: .35rem .85rem; white-space: nowrap; border-radius: 999px;
  border: 1px solid var(--hfp-border); background: var(--hfp-panel); color: var(--hfp-ink) !important; font-size: .88rem; font-weight: 700; text-decoration: none; }
.hfp-chip-bhs::before, .hfp-chip-jba::before { content: ""; width: .7em; height: .7em; border-radius: 50%; background: var(--hfp-doc); }
.hfp-chip-jba::before { background: var(--hfp-jba); }
.hfp-chip:hover { border-color: var(--hfp-doc); }
.hfp-chip[aria-current="true"] { background: var(--hfp-ink); border-color: var(--hfp-ink); color: var(--hfp-bg) !important; }
.hfp-filter { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .7rem; min-width: 0; max-width: 560px; margin: 0 0 1rem; }
.hfp-filter label { font-size: .9rem; font-weight: 800; }
.hfp-filter input { flex: 1 1 160px; min-width: 0; min-height: 40px; padding: .45rem .8rem; border-radius: 10px; border: 1px solid var(--hfp-border);
  background: var(--v4-input, #fff); color: var(--hfp-ink); font: inherit; font-size: 1rem; }
.hfp-filter input:focus { border-color: var(--hfp-doc); outline: 2px solid color-mix(in srgb, var(--hfp-doc) 35%, transparent); outline-offset: 0; }
.hfp-filter-status { flex-basis: 100%; margin: 0; font-size: .82rem; color: var(--hfp-muted); }
.hfp-filter-status:empty { display: none; }
.hfp.is-swapping { opacity: .55; transition: opacity .15s; }
/* the search box: a plain form, beside the chips on a wide screen, under them on a phone */
.hfp-search { flex: 1 1 100%; display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .7rem; min-width: 0; margin: 0; }
.hfp-search label { flex: 1 1 100%; font-size: .9rem; font-weight: 800; white-space: nowrap; }
.hfp-search-row { display: flex; flex: 1 1 100%; gap: .4rem; min-width: 0; }
.hfp-search input { flex: 1 1 auto; width: 100%; min-width: 0; min-height: 40px; padding: .45rem .8rem; border-radius: 10px; border: 1px solid var(--hfp-border);
  background: var(--v4-input, #fff); color: var(--hfp-ink); font: inherit; font-size: 1rem; }
.hfp-search input:focus { border-color: var(--hfp-doc); outline: 2px solid color-mix(in srgb, var(--hfp-doc) 35%, transparent); outline-offset: 0; }
.hfp-search button { flex: none; min-height: 40px; padding: .4rem 1rem; border-radius: 10px; border: 0; background: var(--hfp-ink); color: var(--hfp-bg);
  font: inherit; font-size: .92rem; font-weight: 800; cursor: pointer; }
.hfp-search button:hover, .hfp-search button:focus-visible { filter: brightness(1.15); }
.hfp-found { scroll-margin-top: 1rem; }
.hfp-found h2 { overflow-wrap: anywhere; }
.hfp-search-msg { font-weight: 700; color: var(--hfp-ink); }
.hfp-list mark { background: color-mix(in srgb, var(--hfp-doc) 24%, transparent); color: inherit; border-radius: 3px; padding: 0 .08em; }

/* ── sections ── */
.hfp-sec { padding: 1.8rem 0 .6rem; }
.hfp h2 { font-size: clamp(1.4rem, 4.6vw, 1.85rem); font-weight: 800; margin-bottom: .5rem; }
.hfp h3 { font-size: 1.1rem; font-weight: 800; }
.hfp-intro { margin: 0 0 1rem; color: var(--hfp-muted); max-width: 68ch; }
.hfp-fail { margin: 0 0 .8rem; padding: .7rem .9rem; border: 1px dashed var(--hfp-border); border-radius: 10px; color: var(--hfp-muted); }
.hfp-note { margin: 1rem 0 0; padding: .8rem 1rem; border-left: 3px solid var(--hfp-doc); background: var(--hfp-panel); border-radius: 0 10px 10px 0;
  font-size: .9rem; color: var(--hfp-muted); max-width: 78ch; }

/* ── famous floods ── */
.hfp-famous-grid { display: grid; gap: 14px; grid-template-columns: 1fr; align-items: start; }
.hfp-famous { background: var(--hfp-panel); border: 1px solid var(--hfp-border); border-radius: 16px; padding: 1.1rem 1.15rem 1rem; display: flex; flex-direction: column; min-width: 0; }
.hfp-date { margin: 0 0 .25rem; font-family: var(--hfp-serif); font-size: .98rem; color: var(--hfp-doc); }
.hfp-famous h3 { font-size: 1.3rem; }
.hfp-place { margin: .2rem 0 0; font-size: .86rem; color: var(--hfp-muted); }
.hfp-quote { margin: .9rem 0 0; padding: 0 0 0 .9rem; border-left: 3px solid var(--hfp-doc); }
.hfp-quote p { margin: 0; font-family: var(--hfp-serif); font-style: italic; font-size: 1.05rem; line-height: 1.5; }
.hfp-quote p.hfp-quote-by { font-family: inherit; font-style: normal; margin-top: .45rem; font-size: .8rem; line-height: 1.45; color: var(--hfp-muted); overflow-wrap: anywhere; }
.hfp-quote cite { font-style: normal; display: block; }
.hfp-via { display: block; }
.hfp-meta { margin: .8rem 0 0; font-size: .85rem; color: var(--hfp-muted); }
.hfp-srcs-h { margin: .7rem 0 0; font-size: .8rem; font-weight: 700; color: var(--hfp-muted); }
.hfp-srcs { margin: .2rem 0 0; padding-left: 1.1rem; font-size: .84rem; overflow-wrap: anywhere; }
.hfp-famous-acc { margin-top: .9rem; border-top: 1px solid var(--hfp-border); }
.hfp-famous-acc > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  min-height: 44px; padding: .55rem 0 .2rem; font-weight: 800; color: var(--hfp-doc); }
.hfp-famous-acc > summary::-webkit-details-marker { display: none; }
.hfp-famous-acc > summary::after, .hfp-period > summary::after, .hfp-place > summary::after {
  content: ""; width: .55rem; height: .55rem; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-2px); flex: none; opacity: .75; transition: transform .15s; }
.hfp-famous-acc[open] > summary::after, .hfp-period[open] > summary::after, .hfp-place[open] > summary::after { transform: rotate(225deg) translateY(-1px); }
.hfp-links { margin: .6rem 0 0; display: flex; flex-wrap: wrap; gap: .35rem 1rem; font-size: .9rem; font-weight: 700; }
.hfp-links a { text-decoration: none; }
.hfp-links a:hover, .hfp-links a:focus-visible { text-decoration: underline; }

/* ── by decade: one row per decade (a century before 1800); a row opens its accounts in place ── */
.hfp-key { display: flex; flex-wrap: wrap; gap: .3rem 1rem; margin: 0 0 .6rem; font-size: .84rem; color: var(--hfp-muted); }
.hfp-key span::before { content: ""; display: inline-block; width: .8em; height: .8em; border-radius: 3px; margin-right: .35em; vertical-align: -.05em; }
.hfp-key-bhs::before { background: var(--hfp-doc); }
.hfp-key-jba::before { background: var(--hfp-jba); }
.hfp-periods, .hfp-places { list-style: none; margin: 0; padding: 0; }
.hfp-periods { border-top: 1px solid var(--hfp-border); }
.hfp-prow { border-bottom: 1px solid var(--hfp-border); }
.hfp-period > summary, .hfp-period-none, .hfp-place > summary {
  list-style: none; display: grid; grid-template-columns: 5.4rem minmax(0, 1fr) 4.6rem 1rem; align-items: center; gap: .6rem;
  padding: .45rem .35rem; min-height: 46px; cursor: pointer; color: var(--hfp-ink); border-radius: 8px; }
.hfp-period > summary::-webkit-details-marker, .hfp-place > summary::-webkit-details-marker { display: none; }
.hfp-period-none { cursor: default; grid-template-columns: 5.4rem minmax(0, 1fr) 4.6rem 1rem; opacity: .55; }
.hfp-period > summary:hover, .hfp-place > summary:hover { background: var(--hfp-panel); }
.hfp-period[open], .hfp-place[open] { background: var(--hfp-tint); border-radius: 12px; box-shadow: inset 3px 0 0 var(--hfp-doc); margin: .35rem 0; }
.hfp-period[open] > summary, .hfp-place[open] > summary { background: transparent; }
.hfp-period[open] .hfp-period-label, .hfp-place[open] .hfp-place-name { color: var(--hfp-doc); }
.hfp-period-label { font-family: var(--hfp-serif); font-weight: 600; font-size: 1.02rem; font-variant-numeric: lining-nums tabular-nums; }
.hfp-bar { display: flex; height: 12px; background: color-mix(in srgb, var(--hfp-border) 45%, transparent); border-radius: 6px; overflow: hidden; min-width: 0; }
.hfp-bar-bhs { background: var(--hfp-doc); }
.hfp-bar-jba { background: var(--hfp-jba); }
.hfp-period-n { text-align: right; font-variant-numeric: tabular-nums; font-weight: 800; font-size: .95rem; line-height: 1.2; }
.hfp-split { display: flex; justify-content: flex-end; gap: .45rem; font-weight: 600; font-size: .72rem; color: var(--hfp-muted); }
.hfp-k::before { content: ""; display: inline-block; width: .55em; height: .55em; border-radius: 50%; margin-right: .2em; background: var(--hfp-doc); vertical-align: .05em; }
.hfp-k-jba::before { background: var(--hfp-jba); }
.dfr-vh { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* an opened list */
.hfp-acc-body { padding: .2rem .9rem 1rem 1rem; }
.hfp-load { margin: .3rem 0 .2rem; font-weight: 700; }
.hfp-loading { margin: .5rem 0; color: var(--hfp-muted); font-style: italic; }
.hfp-list { min-width: 0; max-width: 820px; }
.hfp-list-head { margin: .2rem 0 .3rem; font-size: .86rem; color: var(--hfp-muted); }
.hfp-list .dfr-list { list-style: none; margin: 0; padding: 0; }
.hfp-list .dfr-item { padding: .7rem 0; border-bottom: 1px solid color-mix(in srgb, var(--hfp-border) 75%, transparent); }
.hfp-list .dfr-date { font-family: var(--hfp-serif); font-weight: 600; font-size: 1rem; }
.hfp-list .dfr-where { font-weight: 800; }
.hfp-list .dfr-where::before { content: "at "; font-weight: 400; color: var(--hfp-muted); }
.hfp-list .dfr-lede { flex-basis: 100%; margin: .3rem 0 0; font-family: var(--hfp-serif); font-size: 1.02rem; line-height: 1.55; }
.hfp-list .dfr-lede-src { flex-basis: 100%; margin: .2rem 0 0; font-size: .8rem; color: var(--hfp-muted); overflow-wrap: anywhere; }
.hfp-town { flex-basis: 100%; margin: .35rem 0 0; font-size: .84rem; }
.hfp-town a { display: inline-flex; align-items: center; min-height: 32px; padding: .15rem .7rem; border-radius: 999px; border: 1px solid var(--hfp-border);
  background: var(--hfp-panel); color: var(--hfp-ink); font-weight: 700; text-decoration: none; }
.hfp-town a:hover { border-color: var(--hfp-doc); }
.hfp-more { margin: .9rem 0 .2rem; }
.hfp-pager { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin: .9rem 0 .2rem; font-size: .9rem; }
.hfp-pager span { color: var(--hfp-muted); }
.hfp-pager a { font-weight: 700; }
.hfp-empty { margin: .4rem 0; color: var(--hfp-muted); }
.hfp-list .dfr-note, .hfp-list .dfr-attr { font-size: .8rem; color: var(--hfp-muted); }

/* ── places: two columns of rows on a wide screen; an opened place takes the whole width ── */
.hfp-places { display: grid; grid-template-columns: 1fr; column-gap: 1.6rem; border-top: 1px solid var(--hfp-border); }
.hfp-plrow { border-bottom: 1px solid var(--hfp-border); min-width: 0; }
.hfp-place > summary { grid-template-columns: minmax(6rem, 9rem) minmax(0, 1fr) 3.4rem 1rem; }
.hfp-place-name { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hfp-plrow[data-hfp-extra] .hfp-place-name::after { content: ""; }

/* ── the collections ── */
.hfp-cards { display: grid; gap: 14px; grid-template-columns: 1fr; }
.hfp-col { background: var(--hfp-panel); border: 1px solid var(--hfp-border); border-radius: 16px; padding: 1.1rem 1.15rem; border-top: 4px solid var(--hfp-doc); }
.hfp-col-jba { border-top-color: var(--hfp-jba); }
.hfp-col p { margin: .45rem 0 0; font-size: .93rem; }
.hfp-by { color: var(--hfp-muted); font-size: .85rem !important; margin-top: .2rem !important; }
.hfp-count { font-size: .95rem !important; }
.hfp-count strong { font-family: var(--hfp-serif); font-size: 1.9rem; font-weight: 600; color: var(--hfp-ink); margin-right: .3rem; font-variant-numeric: lining-nums tabular-nums; }
.hfp-count.hfp-fail { font-size: .9rem !important; }
.hfp-col-act { margin-top: .9rem !important; }
.hfp-out { font-size: .8rem !important; color: var(--hfp-muted); }
.hfp-out a { color: var(--hfp-muted); }
.hfp-btn { display: inline-flex; align-items: center; min-height: 44px; padding: .55rem 1.1rem; border-radius: 999px; background: var(--hfp-ink);
  color: var(--hfp-bg) !important; font-weight: 800; text-decoration: none; font-size: .92rem; }
.hfp-btn:hover, .hfp-btn:focus-visible { filter: brightness(1.12); }
.hfp-col-jba .hfp-btn { background: var(--hfp-jba); color: #04211d !important; }
.hfp-col-bhs .hfp-btn { background: var(--hfp-doc); color: #fff !important; }
:root[data-theme]:not([data-theme=light]) .hfp-col-bhs .hfp-btn { color: #1c0b3d !important; }

/* ── where the accounts come from ── */
.hfp-sources { margin: 0; padding-left: 1.4rem; max-width: 80ch; }
.hfp-sources li { padding: .35rem 0; border-bottom: 1px solid var(--hfp-border); overflow-wrap: anywhere; font-size: .92rem; }
.hfp-cite { font-family: var(--hfp-serif); font-size: .98rem; }
.hfp-n { color: var(--hfp-muted); font-size: .8rem; white-space: nowrap; }

/* ── the credits ── */
.hfp-credits h2 { font-size: 1rem; }
.hfp-credits .dfr-attr { color: var(--hfp-muted); opacity: 1; max-width: 80ch; font-size: .86rem; }

@media (min-width: 640px) {
  .hfp-hero { padding: 3rem 0 1.8rem; }
  .hfp-tools { position: sticky; top: 0; z-index: 6; background: color-mix(in srgb, var(--hfp-bg) 94%, transparent); backdrop-filter: blur(6px); }
  .hfp-chips { flex: 0 1 auto; margin: 0; padding: 0; overflow: visible; }
  .hfp-search { flex: 1 1 340px; flex-wrap: nowrap; }
  .hfp-search label { flex: none; }
  .hfp-search-row { flex: 1 1 200px; }
  .hfp-found { scroll-margin-top: 7.5rem; }
  .hfp-stats { grid-template-columns: repeat(4, 1fr); }
  .hfp-stat { padding: 1rem 1.1rem .3rem; border-left: 1px solid var(--hfp-border); }
  .hfp-stat:first-child { padding-left: 0; border-left: 0; }
  .hfp-cards { grid-template-columns: 1fr 1fr; }
  .hfp-famous-grid { grid-template-columns: 1fr 1fr; }
  .hfp-period > summary, .hfp-period-none { grid-template-columns: 8rem minmax(0, 1fr) 7rem 1rem; }
}
@media (min-width: 900px) {
  .hfp-famous-grid { grid-template-columns: repeat(3, 1fr); }
  .hfp-places { grid-template-columns: 1fr 1fr; }
  .hfp-plrow:has(details[open]) { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) {
  .hfp *, .hfp *::after { transition: none !important; }
}
