/* Squirrel Papers - design tokens and base styles.
 *
 * Colours are taken from the logo (assets/img/sqp-logo.png) and the old
 * WordPress site (PRIMER A1, Befund 11):
 *   plum     #892a69   logo body, "SQUIRREL"
 *   magenta  #c94fa0   logo tail, "PAPERS"
 *   berry    #b03686   anti-aliasing tone between the two
 *   grey     #767676   page header of the old site
 *   night    #2b1a29   dark purple of the network background
 *
 * No web fonts are loaded: the build runs offline and the site makes no
 * third-party request that the privacy notice would have to explain. The
 * stacks below fall back to what the reader's system has.
 */

:root {
  --sqp-plum: #892a69;
  --sqp-magenta: #c94fa0;
  --sqp-berry: #b03686;
  --sqp-grey: #767676;
  --sqp-night: #2b1a29;
  --sqp-night-2: #3d2639;

  --bg: #ffffff;
  --bg-soft: #f6f1f5;
  --text: #1d141b;
  --text-muted: #5c4f59;
  --link: var(--sqp-plum);
  --link-hover: var(--sqp-berry);
  --accent: var(--sqp-magenta);      /* large text and decoration only: 4.1:1 on white */
  --accent-text: var(--sqp-berry);   /* accent at body size: 5.6:1 on white */
  --rule: #e4d9e1;
  --header-bg: var(--sqp-grey);
  --header-text: #ffffff;
  --hero-bg: var(--sqp-night);
  --hero-text: #ffffff;

  --font-heading: "Inter", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-body: "Inter", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Code", Consolas, monospace;

  --measure: 42rem;
  --wide: 72rem;
  --radius: 4px;
  --gutter: 16px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1018;
    --bg-soft: #251822;
    --text: #f2e9ef;
    --text-muted: #c4b3bf;
    --link: #e283c1;
    --link-hover: #f2a9d8;
    --rule: #3d2639;
    --header-bg: #2a2a2a;
    --accent-text: var(--sqp-magenta);
  }
}

:root[data-theme="dark"] {
  --bg: #1a1018;
  --bg-soft: #251822;
  --text: #f2e9ef;
  --text-muted: #c4b3bf;
  --link: #e283c1;
  --link-hover: #f2a9d8;
  --rule: #3d2639;
  --header-bg: #2a2a2a;
  --accent-text: var(--sqp-magenta);
}

/* Form controls and scrollbars follow the theme too. */
:root { color-scheme: light dark; }
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

*, *::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-body);
  font-size: 1.0625rem;
  line-height: 1.6;
  overflow-x: hidden;
}

h1, h2, h3, h4 {
  font-family: var(--font-heading);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

a { color: var(--link); text-underline-offset: 0.15em; }
a:hover, a:focus-visible { color: var(--link-hover); }

code, pre, kbd { font-family: var(--font-mono); font-size: 0.92em; }

.wrap { max-width: var(--wide); margin: 0 auto; padding: 0 var(--gutter); }
.measure { max-width: var(--measure); }

/* Site header: grey bar, title left, navigation right - as on the old site. */
.site-header { background: var(--header-bg); color: var(--header-text); }
.site-header .wrap {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.5rem 1.5rem;
  padding-top: 1rem; padding-bottom: 1rem;
}
.site-header a { color: inherit; text-decoration: none; }
.site-title { font-family: var(--font-heading); font-weight: 800; font-size: 1.1rem; }
.site-tagline { font-size: 0.85rem; opacity: 0.85; }
.site-nav { margin-left: auto; display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; }
.site-nav a { font-size: 0.9rem; font-weight: 600; }
.site-nav a[aria-current="page"] { text-decoration: underline; }

/* Dark purple band for hero, journal facts and footer. */
.band { background: var(--hero-bg); color: var(--hero-text); }
.band a { color: #f2a9d8; }

/* Drop cap in magenta, as on the old landing text. */
.dropcap::first-letter {
  float: left; font-family: var(--font-heading); font-weight: 900;
  font-size: 3.4em; line-height: 0.85; margin: 0.05em 0.1em 0 0; color: var(--accent);
}

/* Entry type labels, replacing the old [`Presentation`] backtick badges. */
.badge {
  display: inline-block; padding: 0.05em 0.5em; border-radius: var(--radius);
  background: var(--bg-soft); border: 1px solid var(--rule);
  font-size: 0.78em; font-weight: 600; color: var(--text-muted); vertical-align: 0.1em;
}
.sigil { font-weight: 800; color: var(--accent-text); }

.site-footer { border-top: 1px solid var(--rule); color: var(--text-muted); font-size: 0.9rem; }
.site-footer .wrap { padding-top: 1.5rem; padding-bottom: 2rem; }

/* ------------------------------------------------------------------------
 * Pages (S5)
 * --------------------------------------------------------------------- */

.skip { position: absolute; left: -999px; }
.skip:focus { left: var(--gutter); top: 8px; background: var(--bg); padding: 4px 8px; z-index: 10; }

main { display: block; padding-bottom: 3rem; }
main .wrap > h1:first-child, .breadcrumb + h1 { margin-top: 0.4rem; }
.muted { color: var(--text-muted); }
.small { font-size: 0.85rem; }
.lead { font-size: 1.2rem; color: var(--text-muted); margin-top: -0.5rem; }

.breadcrumb { font-size: 0.85rem; color: var(--text-muted); margin: 1.5rem 0 0.5rem; }
.breadcrumb a { color: inherit; }

/* Hero: dark band with the network pattern, as on the old landing page. */
.band {
  background-color: var(--hero-bg);
  background-image:
    linear-gradient(90deg, rgba(43,26,41,0.92), rgba(61,38,57,0.75) 50%, rgba(43,26,41,0.92)),
    url("../img/network.svg");
  background-size: auto, 1200px 600px;
}
.hero-inner { text-align: center; padding-top: 2.5rem; padding-bottom: 2.5rem; }
.hero-logo { width: min(384px, 80%); height: auto; background: #fff; padding: 1rem 1.5rem; border-radius: var(--radius); }
.hero h1 { font-size: clamp(1.6rem, 4vw, 2.6rem); max-width: 36rem; margin: 1.5rem auto 0.75rem; }
.hero-facts { font-size: 1.05rem; opacity: 0.9; }

.intro { margin: 2.5rem 0 1.5rem; }

.volume-grid { list-style: none; padding: 0; display: grid; gap: 0.75rem;
  grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr)); }
.volume-card a { display: flex; flex-direction: column; gap: 0.15rem; padding: 0.9rem 1rem;
  border: 1px solid var(--rule); border-radius: var(--radius); text-decoration: none;
  color: var(--text); background: var(--bg-soft); height: 100%; }
.volume-card a:hover { border-color: var(--accent); }
.volume-number { font-family: var(--font-heading); font-weight: 800; font-size: 1.15rem; color: var(--link); }
.volume-year { font-weight: 600; }
.volume-count { font-size: 0.85rem; color: var(--text-muted); }

.issue-list { padding-left: 1.2rem; }
.volume-block { border-top: 1px solid var(--rule); padding-top: 0.5rem; }
.issue-block { margin-top: 2rem; }

.entry-list { list-style: none; padding: 0; margin: 0.5rem 0 1rem; }
.entry-item { display: grid; grid-template-columns: 3.2rem 1fr; gap: 0.5rem;
  padding: 0.65rem 0; border-bottom: 1px solid var(--rule); }
.entry-item .sigil { font-family: var(--font-heading); text-align: right; padding-top: 0.05rem; }
.entry-item-title { font-weight: 600; text-decoration: none; }
.entry-item-title:hover { text-decoration: underline; }
.entry-item-meta { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.15rem;
  display: flex; flex-wrap: wrap; gap: 0.15rem 0.4rem; align-items: baseline; }

/* Entry page */
.entry-kicker { margin: 0.25rem 0 0; display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: baseline; }
.entry-title { font-size: clamp(1.5rem, 3.2vw, 2.3rem); margin: 0.4rem 0 0.6rem; }
.entry-authors { font-size: 1.05rem; margin-top: 0; }
.person { white-space: nowrap; }
.orcid { display: inline-block; width: 0.8em; height: 0.8em; margin-left: 0.2em; border-radius: 50%;
  background: #a6ce39; vertical-align: 0.05em; }
.entry-grid { display: grid; gap: 2rem; grid-template-columns: minmax(0, 1fr); margin-top: 1rem; }
@media (min-width: 900px) { .entry-grid { grid-template-columns: minmax(0, 1fr) 20rem; } }
.entry-main h2, .entry-facts h2 { font-size: 1.2rem; margin-bottom: 0.4rem; }
.abstract { overflow-wrap: anywhere; }
.entry-facts { font-size: 0.92rem; border-left: 3px solid var(--accent); padding-left: 1rem; }
.entry-facts dl { margin: 0; }
.entry-facts dt { font-weight: 700; margin-top: 0.7rem; font-size: 0.78rem; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--text-muted); }
.entry-facts dd { margin: 0.1rem 0 0; overflow-wrap: anywhere; }
.iri { font-family: var(--font-mono); font-size: 0.85em; }

.button { font: inherit; font-weight: 600; cursor: pointer; border: 0; border-radius: var(--radius);
  background: var(--sqp-plum); color: #fff; padding: 0.55rem 1rem; }
.button:hover, .button:focus-visible { background: var(--sqp-berry); }
.button-small { padding: 0.25rem 0.6rem; font-size: 0.85rem; }
.preview-box { margin-top: 0.75rem; max-height: 80vh; overflow-y: auto; border: 1px solid var(--rule);
  border-radius: var(--radius); background: var(--bg-soft); padding: 0.5rem; }
.preview-box canvas { display: block; margin: 0 auto 0.5rem; box-shadow: 0 1px 3px rgba(0,0,0,0.25); background: #fff; }
.preview-fallback { margin: 0.25rem; }
.cite-box { background: var(--bg-soft); border: 1px solid var(--rule); border-radius: var(--radius);
  padding: 0.75rem 1rem; display: flex; gap: 1rem; align-items: flex-start; }
.cite-box p { margin: 0; flex: 1; overflow-wrap: anywhere; }
.downloads { font-size: 0.9rem; }

.prose h2 { font-size: 1.25rem; margin-top: 1.8rem; }

/* Footer: dark band with two columns, as on the old site. */
.site-footer.band { color: #f2e9ef; border-top: 0; margin-top: 2rem; }
.site-footer h2 { font-size: 1.2rem; }
.footer-grid { display: grid; gap: 1.5rem; grid-template-columns: minmax(0, 1fr); padding-top: 1.5rem; }
@media (min-width: 760px) { .footer-grid { grid-template-columns: 1fr 1fr; } }
.footer-small { font-size: 0.82rem; opacity: 0.85; padding-bottom: 1.5rem; }
.site-footer .wrap { padding-bottom: 0.5rem; }
.lang-switch { border: 1px solid rgba(255,255,255,0.6); border-radius: var(--radius); padding: 0 0.4rem; }

/* Citation (S6) */
.cite-style { margin: 0 0 0.5rem; display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.cite-style select { font: inherit; padding: 0.25rem 0.4rem; border: 1px solid var(--rule);
  border-radius: var(--radius); background: var(--bg); color: var(--text); }
.cite-text { flex: 1; overflow-wrap: anywhere; }
.cite-text .csl-entry { margin: 0; }
.cite-text .csl-left-margin { display: inline; margin-right: 0.4em; }
.cite-text .csl-right-inline { display: inline; }

/* Search and SPARQL (S9) */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; }
.notice { background: var(--bg-soft); border: 1px solid var(--rule); border-radius: var(--radius);
  padding: 0.6rem 0.8rem; }
.button-quiet { background: transparent; color: var(--link); border: 1px solid var(--rule); }
.button-quiet:hover, .button-quiet:focus-visible { background: var(--bg-soft); color: var(--link-hover); }
.button:disabled { opacity: 0.55; cursor: default; }
.search-bar { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 1rem 0; }
.search-bar input { flex: 1; min-width: 12rem; font: inherit; padding: 0.5rem 0.7rem;
  border: 1px solid var(--rule); border-radius: var(--radius); background: var(--bg); color: var(--text); }
.search-bar input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.search-grid { display: grid; gap: 1.5rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 860px) { .search-grid { grid-template-columns: 16rem minmax(0, 1fr); } }
.facet { border: 0; border-top: 1px solid var(--rule); margin: 0 0 0.8rem; padding: 0.5rem 0 0; min-width: 0; }
.facet legend { font-weight: 700; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-muted); padding: 0 0.3rem 0 0; }
.facet-value { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 0.4rem;
  align-items: baseline; font-size: 0.9rem; padding: 0.1rem 0; cursor: pointer; }
.facet-label { overflow-wrap: anywhere; }
.facet-count { color: var(--text-muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.facet-more { font: inherit; font-size: 0.82rem; background: none; border: 0; padding: 0.2rem 0;
  color: var(--link); cursor: pointer; text-decoration: underline; }
.search-count { font-weight: 700; margin: 0 0 0.5rem; }
.result-list { list-style: none; padding: 0; margin: 0; }
.result { display: grid; grid-template-columns: 6.2rem minmax(0, 1fr); gap: 0.6rem;
  padding: 0.55rem 0; border-bottom: 1px solid var(--rule); }
.result-label { font-family: var(--font-heading); font-weight: 800; color: var(--accent-text);
  font-size: 0.9rem; white-space: nowrap; }
@media (max-width: 520px) { .result { grid-template-columns: minmax(0, 1fr); gap: 0.1rem; } }
.engine { display: flex; flex-wrap: wrap; gap: 0.8rem; align-items: center; margin: 1.2rem 0;
  padding: 0.8rem 1rem; background: var(--bg-soft); border: 1px solid var(--rule); border-radius: var(--radius); }
.engine-status { font-size: 0.9rem; color: var(--text-muted); }
.engine-status[data-state="ok"] { color: var(--text); font-weight: 600; }
.engine-status[data-state="err"] { color: #b42318; font-weight: 600; }
.query-toc { columns: 2 18rem; padding-left: 1.4rem; }
.query { border-top: 1px solid var(--rule); padding-top: 0.6rem; margin-top: 2rem; }
.query h2 { font-size: 1.2rem; margin: 0.4rem 0; }
.sparql-src { width: 100%; font-family: var(--font-mono); font-size: 0.82rem; line-height: 1.45;
  padding: 0.6rem 0.7rem; border: 1px solid var(--rule); border-radius: var(--radius);
  background: var(--bg-soft); color: var(--text); resize: vertical; tab-size: 2; }
.query-bar { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin-top: 0.5rem; }
.query-meta { margin-left: auto; }
.query-result { margin-top: 0.8rem; }
.table-scroll { overflow-x: auto; }
.result-table { border-collapse: collapse; width: 100%; font-size: 0.82rem; }
.result-table th, .result-table td { text-align: left; vertical-align: top; padding: 0.3rem 0.5rem;
  border-bottom: 1px solid var(--rule); }
.result-table th { font-family: var(--font-mono); font-weight: 600; color: var(--text-muted); white-space: nowrap; }
.result-table td a { overflow-wrap: anywhere; }
.result-table td.nil { color: var(--text-muted); }
.query-error { background: var(--bg-soft); border-left: 3px solid #b42318; padding: 0.6rem 0.8rem;
  white-space: pre-wrap; font-size: 0.8rem; overflow-x: auto; }
.facet-panel > summary { cursor: pointer; font-weight: 700; padding: 0.4rem 0; }
@media (min-width: 860px) { .facet-panel > summary { display: none; } }

/* Map (S10). The background is drawn from Natural Earth on this site. */
:root { --map-land: #f6f1f5; --map-border: #b9a9b5; --map-sea: #dde7ee; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --map-land: #2c1f2a; --map-border: #5a4656; --map-sea: #141019; }
}
:root[data-theme="dark"] { --map-land: #2c1f2a; --map-border: #5a4656; --map-sea: #141019; }
.map { height: min(70vh, 560px); border: 1px solid var(--rule); border-radius: var(--radius); margin: 0.5rem 0; }
.map-tools { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin: 1rem 0 0.4rem; }
.map-tools select { font: inherit; padding: 0.25rem 0.4rem; border: 1px solid var(--rule);
  border-radius: var(--radius); background: var(--bg); color: var(--text); }
.map-tools .button-quiet { margin-left: auto; }
.map-popup { font-size: 0.85rem; max-height: 18rem; overflow-y: auto; }
.leaflet-popup-content .map-popup p { margin: 0.15rem 0; }
.map-popup-place { font-weight: 700; font-size: 0.95rem; }
.leaflet-popup-content .map-popup .map-popup-event { font-weight: 600; margin-top: 0.6rem; }
.map-popup-date { color: #5c4f59; }
.map-popup .sigil { margin-right: 0.2em; }
.leaflet-container { font-family: var(--font-body); }
.leaflet-container a { color: var(--sqp-plum); }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li + li { margin-top: 0.25rem; }
.nowrap { white-space: nowrap; }
.event-table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
.event-table th, .event-table td { text-align: left; vertical-align: top; padding: 0.45rem 0.5rem;
  border-bottom: 1px solid var(--rule); }
.event-table th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
.event-table a { text-decoration-thickness: 1px; }

/* Data model (S16). Swatches use the diagram colours (Flo's scheme). */
.model-head { display: grid; gap: 1.5rem; grid-template-columns: minmax(0, 1fr); margin: 1.5rem 0; }
@media (min-width: 760px) { .model-head { grid-template-columns: 1fr 1fr; } }
.small-heading { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-muted); margin: 0 0 0.4rem; }
.model-toc ol { margin: 0; padding-left: 1.3rem; }
.legend { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.3rem;
  grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); font-size: 0.9rem; }
.legend li { display: flex; align-items: center; gap: 0.5rem; }
.swatch { width: 1.4rem; height: 0.9rem; border: 1px solid #000; border-radius: 3px; flex: none; }
.swatch-inst { background: #e2e8f0; border-radius: 999px; }
.swatch-real { background: #166534; }
.swatch-cls { background: #9a3412; }
.swatch-term { background: #4c1d95; }
.swatch-ext { background: #ffffff; }
.swatch-prop { background: #fbbf24; }
.model-section { border-top: 1px solid var(--rule); margin-top: 2.2rem; padding-top: 0.6rem; }
.model-section h2 { font-size: 1.35rem; }
.diagram { margin: 1rem 0; padding: 0.8rem; border: 1px solid var(--rule); border-radius: var(--radius);
  background: var(--bg); overflow-x: auto; }
.diagram figcaption { font-weight: 700; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.4rem; }
pre.mermaid { margin: 0; font-size: 0.75rem; white-space: pre; color: var(--text-muted); background: none; }
pre.mermaid[data-processed] { text-align: center; }
pre.mermaid svg { max-width: 100%; height: auto; }
.diagram-pair { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); }
.model-table { border-collapse: collapse; width: 100%; font-size: 0.88rem; margin: 1rem 0; }
.model-table th, .model-table td { text-align: left; vertical-align: top; padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--rule); }
.model-table th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
.model-table code { font-size: 0.82rem; overflow-wrap: anywhere; }
/* On a phone a scaled-down diagram is unreadable: keep its size and scroll. */
@media (max-width: 760px) {
  pre.mermaid svg { min-width: 680px; max-width: none !important; }
}

/* Light / dark switch in the header */
.theme-switch { font: inherit; font-size: 0.9rem; font-weight: 600; cursor: pointer; color: inherit;
  background: transparent; border: 1px solid rgba(255,255,255,0.6); border-radius: var(--radius);
  padding: 0 0.45rem; line-height: 1.5; display: inline-flex; align-items: center; gap: 0.3rem; }
.theme-switch:hover, .theme-switch:focus-visible { background: rgba(255,255,255,0.15); }
.theme-switch svg { width: 1em; height: 1em; }
