/* ============================================================================
   Qvorium public reader — bespoke, bundler-free, CDN-free (GDPR/EU clean).
   Design language: scientific-publishing. Display = STIX Two Text; UI = IBM
   Plex Sans; identifiers = IBM Plex Mono. Signature element = the citation
   strip. Fonts are self-hosted in /fonts (SIL OFL). Bump ?v=N in the layout
   link when this file changes.
   ========================================================================= */

/* ---- fonts --------------------------------------------------------------- */
@font-face { font-family: "STIX Two Text"; font-style: normal; font-weight: 500;
  font-display: swap; src: url("/fonts/stix-two-text-500.woff2") format("woff2"); }
@font-face { font-family: "STIX Two Text"; font-style: normal; font-weight: 600;
  font-display: swap; src: url("/fonts/stix-two-text-600.woff2") format("woff2"); }
@font-face { font-family: "STIX Two Text"; font-style: italic; font-weight: 500;
  font-display: swap; src: url("/fonts/stix-two-text-500-italic.woff2") format("woff2"); }
@font-face { font-family: "Plex Sans"; font-style: normal; font-weight: 400;
  font-display: swap; src: url("/fonts/ibm-plex-sans-400.woff2") format("woff2"); }
@font-face { font-family: "Plex Sans"; font-style: normal; font-weight: 500;
  font-display: swap; src: url("/fonts/ibm-plex-sans-500.woff2") format("woff2"); }
@font-face { font-family: "Plex Sans"; font-style: normal; font-weight: 600;
  font-display: swap; src: url("/fonts/ibm-plex-sans-600.woff2") format("woff2"); }
@font-face { font-family: "Plex Mono"; font-style: normal; font-weight: 400;
  font-display: swap; src: url("/fonts/ibm-plex-mono-400.woff2") format("woff2"); }
@font-face { font-family: "Plex Mono"; font-style: normal; font-weight: 500;
  font-display: swap; src: url("/fonts/ibm-plex-mono-500.woff2") format("woff2"); }

/* ---- tokens -------------------------------------------------------------- */
:root {
  --paper:   #FAFBFA;
  --surface: #FFFFFF;
  --ink:     #1A2E35;
  --survey:  #1F3A5F;
  --survey-hover: #16304C;
  --slate:   #5A6B6E;
  --contour: #D8DEDC;
  --contour-soft: #E9EDEB;
  --signal:  #B65C1F;
  --signal-tint: #FBF1E9;
  /* chart series (validated: CVD ΔE 45+, lightness band, AA contrast on white) */
  --chart-views: #1C8078;
  --chart-reads: #33629C;
  --chart-downloads: #C15E1D;

  --serif: "STIX Two Text", Georgia, "Times New Roman", serif;
  --sans:  "Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono:  "Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --wrap: 1180px;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(26, 46, 53, .04), 0 6px 24px rgba(26, 46, 53, .05);
}

/* ---- reset --------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; height: auto; }
a { color: var(--survey); text-decoration: none; }
a:hover { color: var(--survey-hover); text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.2; }
p { margin: 0 0 1rem; }
:focus-visible { outline: 2px solid var(--survey); outline-offset: 2px; border-radius: 3px; }

/* ---- masthead ------------------------------------------------------------ */
.reader-masthead {
  background: var(--surface);
  border-bottom: 1px solid var(--contour);
}
.reader-masthead__in {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: .85rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  justify-content: space-between;
}
.reader-brand-group { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.reader-logo { display: inline-flex; flex: none; }
.reader-logo img { display: block; height: 48px; width: auto; }
.reader-brand {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.2rem;
  color: var(--ink);
  letter-spacing: -.01em;
}
.reader-brand:hover { color: var(--ink); text-decoration: none; }
.reader-brand span { color: var(--survey); }
.reader-search { display: flex; align-items: stretch; gap: 0; }
.reader-search input {
  font-family: var(--sans);
  font-size: .9rem;
  border: 1px solid var(--contour);
  border-right: 0;
  border-radius: 8px 0 0 8px;
  padding: .4rem .7rem;
  min-width: 12rem;
  background: var(--paper);
  color: var(--ink);
}
.reader-search input:focus { outline: none; border-color: var(--survey); }
.reader-search button {
  font-family: var(--sans);
  font-size: .85rem;
  border: 1px solid var(--survey);
  background: var(--survey);
  color: #fff;
  border-radius: 0 8px 8px 0;
  padding: .4rem .8rem;
  cursor: pointer;
}
.reader-search button:hover { background: var(--survey-hover); border-color: var(--survey-hover); }
/* De-branded masthead (logo + series title hidden): the search form is the only
   child, so space-between would park it left — keep it on the right. */
.reader-masthead__in > .reader-search:only-child { margin-left: auto; }

/* ---- client chrome + sub-bar + banner ------------------------------------ */
/* .client-chrome wraps the instance's deploy-authored theme header (see
   app/views/client_themes/); everything theme-specific lives in the theme's
   own theme.css, scoped under this class. */
body.is-pdf-reader .client-chrome { display: none; }

/* Slim series bar shown instead of the masthead when READER_SHOW_MASTHEAD is
   off (white-label mode): keeps series wayfinding + quick search reachable. */
.reader-subbar { background: var(--surface); border-bottom: 1px solid var(--contour); }
.reader-subbar__in {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: .6rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  justify-content: space-between;
}

/* Per-series banner (uploaded in admin): text-free background art with the
   series title overlaid — neutral baseline; client themes override the look. */
.reader-banner {
  min-height: 190px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem 0;
  text-align: center;
  background-color: var(--survey);
  background-size: cover;
  background-position: top center;
  background-repeat: no-repeat;
}
/* The title wraps at exactly the content width of the page below
   (.reader-main: --wrap + 1.25rem side padding). */
.reader-banner .headline-title {
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 1.25rem;
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(1.4rem, 3vw, 2.2rem);
  color: #fff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, .55);
  line-height: 1.25;
}

/* Fixed client chrome (READER_FIXED_CHROME): pin the theme header; the content
   offset comes from --chrome-h, measured by the layout's inline script. The
   PDF reader page needs no carve-out — its client chrome is display:none, so
   the measured height (and thus the offset) is zero there. */
@media (min-width: 992px) {
  body.fixed-chrome .client-chrome { position: fixed; top: 0; left: 0; right: 0; z-index: 500; }
  body.fixed-chrome { padding-top: var(--chrome-h, 0px); }
}

/* Search-scope extras: series label on platform-wide hits, the in-volume
   search box on volume pages, and the landing's platform search. */
.toc__series { font-size: .8rem; color: var(--slate); }
.reader-search--volume { margin-top: .75rem; }
.landing-search { margin: 1rem 0 .25rem; }

/* ---- search scope (vector toggle) ---------------------------------------- */
.search-scope {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem;
  margin-top: .75rem;
}
.search-scope__label {
  font-family: var(--mono);
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--slate);
  margin-right: .25rem;
}
.search-scope__pill {
  display: inline-flex;
  align-items: center;
  font-family: var(--sans);
  font-size: .82rem;
  color: var(--survey);
  border: 1px solid var(--contour);
  border-radius: 999px;
  padding: .28rem .8rem;
  cursor: pointer;
  user-select: none;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.search-scope__pill:hover { border-color: var(--survey); }
.search-scope__pill input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.search-scope__pill.is-active,
.search-scope__pill:has(input:checked) {
  background: var(--survey);
  border-color: var(--survey);
  color: #fff;
}
.search-scope__pill:focus-within { outline: 2px solid var(--survey); outline-offset: 2px; }

/* ---- shell --------------------------------------------------------------- */
.reader-main { max-width: var(--wrap); margin: 0 auto; padding: 2rem 1.25rem 3rem; }
.reader-footer {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
  border-top: 1px solid var(--contour);
  color: var(--slate);
  font-size: .82rem;
}
.reader-footer a { color: var(--slate); text-decoration: underline; }

/* ---- breadcrumb ---------------------------------------------------------- */
.reader-crumbs {
  font-family: var(--mono);
  font-size: .72rem;
  letter-spacing: .02em;
  color: var(--slate);
  margin-bottom: 1.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
}
.reader-crumbs a { color: var(--slate); }
.reader-crumbs a:hover { color: var(--survey); }
.reader-crumbs span[aria-hidden] { color: var(--contour); }

/* ---- eyebrow + titles ---------------------------------------------------- */
.reader-eyebrow {
  font-family: var(--mono);
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--survey);
  margin-bottom: .6rem;
}
.reader-title {
  font-family: var(--serif);
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -.012em;
  font-size: clamp(1.55rem, 1rem + 2.4vw, 2.35rem);
  line-height: 1.16;
}
.reader-title--sm { font-size: clamp(1.35rem, 1rem + 1.6vw, 1.85rem); }
.reader-subtitle {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  color: var(--slate);
  font-size: 1.05rem;
  margin-top: -.1rem;
}

/* ---- volume header topographic motif ------------------------------------- */
.reader-volhead {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--contour);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 1.6rem 1.5rem;
  margin-bottom: 1.75rem;
}
.reader-volhead__topo {
  position: absolute;
  inset: 0;
  z-index: 0;
  opacity: .5;
  pointer-events: none;
  color: var(--contour);
}
.reader-volhead > *:not(.reader-volhead__topo) { position: relative; z-index: 1; }
.reader-metaline { color: var(--slate); font-size: .95rem; margin: .1rem 0; }
.reader-metaline strong { color: var(--ink); font-weight: 600; }

/* ---- citation strip (SIGNATURE) ------------------------------------------ */
.citation-strip {
  border-top: 1px solid var(--contour);
  border-bottom: 1px solid var(--contour);
  padding: .8rem 0;
  margin: 1.1rem 0 1.4rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.4rem;
}
.citation-strip__item { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.citation-strip__label {
  font-family: var(--mono);
  font-size: .64rem;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--slate);
}
.citation-strip__value {
  font-family: var(--mono);
  font-size: .82rem;
  color: var(--ink);
  word-break: break-word;
}
.citation-strip__value a { color: var(--ink); text-decoration: none; }
.citation-strip__value a:hover { color: var(--survey); text-decoration: underline; }
.citation-strip__spacer { flex: 1 1 auto; }
.copy-btn {
  font-family: var(--mono);
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--survey);
  background: transparent;
  border: 1px solid var(--contour);
  border-radius: 7px;
  padding: .3rem .6rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.copy-btn:hover { background: var(--survey); border-color: var(--survey); color: #fff; }
.copy-btn.is-done { background: var(--signal-tint); border-color: var(--signal); color: var(--signal); }

/* ---- byline + affiliations ----------------------------------------------- */
.byline {
  font-family: var(--sans);
  font-size: 1.06rem;
  color: var(--ink);
  margin: .4rem 0 .5rem;
  line-height: 1.6;
}
.byline__author { white-space: nowrap; }
.byline sup { font-size: .62em; font-weight: 500; color: var(--survey); padding-left: .05em; }
.byline .orcid { display: inline-block; vertical-align: text-top; margin-left: .15rem; line-height: 1; }
.affil-list { list-style: none; margin: 0 0 1rem; padding: 0; color: var(--slate); font-size: .85rem; }
.affil-list li { margin: .1rem 0; }
.affil-list sup { color: var(--survey); font-weight: 500; margin-right: .3rem; }
.affil-single { color: var(--slate); font-size: .85rem; margin: 0 0 1rem; }

/* ---- tabs ---------------------------------------------------------------- */
.reader-tabs {
  display: flex;
  gap: 1.5rem;
  border-bottom: 1px solid var(--contour);
  margin: 1.5rem 0 1.75rem;
}
.reader-tabs a {
  font-family: var(--sans);
  font-size: .9rem;
  font-weight: 500;
  color: var(--slate);
  padding: .55rem .1rem;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  text-decoration: none;
}
.reader-tabs a:hover { color: var(--ink); }
.reader-tabs a[aria-current="page"] { color: var(--survey); border-bottom-color: var(--survey); }

/* ---- article two-column grid --------------------------------------------- */
.article-grid { display: grid; grid-template-columns: 1fr; gap: 2rem; }
@media (min-width: 992px) {
  .article-grid { grid-template-columns: minmax(0, 1fr) 20rem; align-items: start; }
}
.article-body h2 {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--ink);
  margin-top: 1.6rem;
}
.article-body p { color: var(--ink); }
.abstract { font-size: 1.02rem; line-height: 1.72; }
.keywords { font-size: .9rem; color: var(--slate); }
.keywords strong { color: var(--ink); font-weight: 600; }

/* ---- rail panels --------------------------------------------------------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--contour);
  border-radius: var(--radius);
  padding: 1.15rem 1.15rem 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}
.panel__title {
  font-family: var(--mono);
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--slate);
  margin-bottom: .85rem;
}
.panel dl { margin: 0; }
.panel dt {
  font-family: var(--mono);
  font-size: .64rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--slate);
  margin-top: .7rem;
}
.panel dt:first-child { margin-top: 0; }
.panel dd { margin: .1rem 0 0; font-size: .88rem; color: var(--ink); word-break: break-word; }
.panel dd.mono { font-family: var(--mono); font-size: .8rem; }

/* ---- buttons ------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-family: var(--sans);
  font-size: .86rem;
  font-weight: 500;
  border-radius: 8px;
  padding: .5rem .85rem;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.btn:hover { text-decoration: none; }
.btn--primary { background: var(--survey); color: #fff; border-color: var(--survey); width: 100%; justify-content: center; }
.btn--primary:hover { background: var(--survey-hover); border-color: var(--survey-hover); color: #fff; }
.btn--block { width: 100%; justify-content: center; }
.btn__size { font-family: var(--mono); font-size: .72rem; opacity: .85; }
.export-row { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .75rem; }
.export-link {
  font-family: var(--mono);
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--survey);
  border: 1px solid var(--contour);
  border-radius: 7px;
  padding: .35rem .55rem;
  text-decoration: none;
}
.export-link:hover { background: var(--survey); border-color: var(--survey); color: #fff; text-decoration: none; }
.share-row { display: flex; flex-wrap: wrap; gap: .5rem 1rem; margin-top: .9rem; font-size: .8rem; }
.share-row a { color: var(--slate); text-decoration: none; }
.share-row a:hover { color: var(--survey); text-decoration: underline; }

/* ---- badges + how-to-cite + notes ---------------------------------------- */
.badge-oa {
  display: inline-block;
  font-family: var(--mono);
  font-size: .66rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--signal);
  border: 1px solid var(--signal);
  border-radius: 6px;
  padding: .12rem .4rem;
  background: var(--signal-tint);
}
.how-to-cite {
  background: var(--paper);
  border: 1px solid var(--contour);
  border-left: 3px solid var(--survey);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  margin: 1.75rem 0;
}
.how-to-cite__head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .5rem; }
.how-to-cite__label {
  font-family: var(--mono); font-size: .68rem; text-transform: uppercase;
  letter-spacing: .08em; color: var(--slate);
}
.how-to-cite p { font-size: .9rem; line-height: 1.65; margin: 0; color: var(--ink); }
.reader-note {
  border-top: 1px solid var(--contour);
  margin-top: 1.75rem;
  padding-top: 1rem;
  color: var(--slate);
  font-size: .84rem;
}
.reader-note p { margin: 0 0 .4rem; }

/* ---- table of contents --------------------------------------------------- */
.section-head {
  font-family: var(--mono);
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--slate);
  margin: 2rem 0 .3rem;
  padding-bottom: .35rem;
  border-bottom: 1px solid var(--contour);
}
.toc { list-style: none; margin: 0; padding: 0; }
.toc__row { padding: 1rem 0; border-bottom: 1px solid var(--contour-soft); }
.toc__date { font-family: var(--mono); font-size: .72rem; color: var(--slate); }
.toc__title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.1rem;
  line-height: 1.3;
  color: var(--ink);
  margin: .15rem 0;
}
.toc__title a { color: var(--ink); }
.toc__title a:hover { color: var(--survey); }
.toc__authors { font-size: .88rem; color: var(--slate); }
.toc__cite { font-family: var(--mono); font-size: .74rem; color: var(--slate); margin-top: .25rem; }
.toc__cite a { color: var(--survey); }

/* ---- root landing: hero + series index ----------------------------------- */
.landing-hero { margin: 1rem 0 2.25rem; max-width: 46rem; }
.series-index {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.series-card {
  background: var(--surface);
  border: 1px solid var(--contour);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.15rem 1.25rem 1.25rem;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.series-card:hover { border-color: var(--survey); }
.series-card__eyebrow {
  font-family: var(--mono);
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--slate);
  margin-bottom: .35rem;
}
.series-card__title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.2rem;
  line-height: 1.25;
  color: var(--ink);
  margin: 0 0 .35rem;
}
.series-card__title a { color: var(--ink); }
.series-card__title a:hover { color: var(--survey); }
.series-card__count {
  font-family: var(--mono);
  font-size: .74rem;
  color: var(--slate);
  margin: .5rem 0 .15rem;
}
.series-card__latest { font-size: .85rem; color: var(--slate); margin: 0; }
.series-card__latest a { color: var(--survey); }
.landing-admin { margin-top: 2.5rem; }

/* ---- index (author / keyword) -------------------------------------------- */
.az-bar {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem;
  font-family: var(--mono);
  font-size: .8rem;
  margin: 1.25rem 0 1.75rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--contour);
}
.az-bar a {
  display: inline-flex;
  min-width: 1.7rem;
  height: 1.7rem;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--contour);
  border-radius: 6px;
  color: var(--survey);
  text-decoration: none;
}
.az-bar a:hover { background: var(--survey); color: #fff; }
.index-group { margin-bottom: 1.75rem; }
.index-group__letter {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.3rem;
  color: var(--survey);
  border-bottom: 1px solid var(--contour);
  padding-bottom: .25rem;
  margin-bottom: .6rem;
}
.index-entry { margin-bottom: .8rem; }
.index-entry__name { font-weight: 600; color: var(--ink); }
.index-entry__name--kw { font-weight: 600; color: var(--ink); }
.index-entry ul { list-style: none; margin: .2rem 0 0; padding: 0; }
.index-entry li { font-size: .9rem; margin: .1rem 0; }

/* ---- metrics ------------------------------------------------------------- */
.metric-figures {
  display: flex;
  flex-wrap: wrap;
  gap: 2.5rem;
  margin: 1rem 0 2rem;
}
.metric { display: flex; flex-direction: column; gap: .2rem; }
.metric__value { font-family: var(--mono); font-weight: 500; font-size: 2.1rem; color: var(--ink); line-height: 1; }
.metric__label {
  font-family: var(--mono); font-size: .7rem; text-transform: uppercase;
  letter-spacing: .07em; color: var(--slate);
}
.metric__sub { font-size: .74rem; color: var(--slate); }
.chart-wrap { border: 1px solid var(--contour); border-radius: var(--radius); background: var(--surface); padding: 1.25rem; overflow-x: auto; }
.chart-legend { display: flex; gap: 1.25rem; font-size: .78rem; color: var(--slate); margin-bottom: .75rem; }
.chart-legend span { display: inline-flex; align-items: center; gap: .35rem; }
.chart-legend i { width: .8rem; height: .8rem; border-radius: 2px; display: inline-block; }
.chart-svg text { font-family: var(--mono); fill: var(--slate); }

/* ---- lists / empty ------------------------------------------------------- */
.reader-empty { color: var(--slate); font-style: italic; }
.reader-links { font-size: .85rem; margin: 1rem 0 0; }
.reader-links a { margin-right: 1rem; }

/* ---- motion + print ------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
@media print {
  .reader-masthead, .reader-search, .reader-tabs, .export-row, .share-row,
  .copy-btn, .reader-footer, .btn--primary { display: none !important; }
  body { background: #fff; color: #000; }
  .article-grid { grid-template-columns: 1fr; }
  .panel { border: none; box-shadow: none; padding: 0; }
  a { color: #000; text-decoration: underline; }
}

/* ---- pdf reader (in-browser reading of the camera-ready galley) ---------- */
.btn--secondary { background: transparent; color: var(--survey); border-color: var(--contour); width: 100%; justify-content: center; }
.btn--secondary:hover { border-color: var(--survey); background: rgba(31, 58, 95, .06); color: var(--survey); }

body.is-pdf-reader { display: flex; flex-direction: column; height: 100dvh; }
body.is-pdf-reader .reader-main { flex: 1 1 auto; min-height: 0; max-width: none; width: 100%; padding: 0; margin: 0; display: flex; }
body.is-pdf-reader .reader-footer { display: none; }

.pdf-reader { flex: 1; display: flex; flex-direction: column; min-height: 0; width: 100%; }
.pdf-reader:fullscreen { background: var(--paper); }

.pdf-toolbar {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .5rem .9rem;
  background: var(--surface);
  border-bottom: 1px solid var(--contour);
  font-size: .85rem;
}
.pdf-toolbar__back { white-space: nowrap; }
.pdf-toolbar__title {
  font-family: var(--serif);
  color: var(--ink);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pdf-toolbar__pages { font-family: var(--mono); font-size: .78rem; color: var(--slate); white-space: nowrap; }
.pdf-toolbar__zoom { display: flex; gap: .25rem; }
.pdf-toolbar__zoom button, .pdf-toolbar [data-pdf="fullscreen"] {
  font: inherit;
  font-size: .78rem;
  color: var(--survey);
  background: var(--surface);
  border: 1px solid var(--contour);
  border-radius: 7px;
  padding: .25rem .55rem;
  min-width: 2rem;
  cursor: pointer;
}
.pdf-toolbar__zoom button:hover, .pdf-toolbar [data-pdf="fullscreen"]:hover { border-color: var(--survey); }
.pdf-toolbar__download { white-space: nowrap; font-weight: 500; }

.pdf-pages {
  position: relative;
  flex: 1;
  overflow: auto;
  padding: 1.5rem .75rem;
  background: var(--contour-soft);
  --scale-factor: 1;
}
.pdf-reader[data-state="loading"] .pdf-pages::before {
  content: "Loading PDF…";
  display: block;
  text-align: center;
  font-family: var(--mono);
  font-size: .8rem;
  color: var(--slate);
  padding: 2rem 0;
}
.pdf-reader[data-state="error"] .pdf-pages { display: none; }

.pdf-page {
  position: relative;
  margin: 0 auto 1.25rem;
  background: #fff;
  box-shadow: var(--shadow);
  /* pdf.js layer contract (pdfjs-dist 5.7.284 web/pdf_viewer.css): the text layer
     sizes itself from these variables; --scale-factor is set by pdf-reader.js. */
  --user-unit: 1;
  --total-scale-factor: calc(var(--scale-factor) * var(--user-unit));
  --scale-round-x: 1px;
  --scale-round-y: 1px;
}
.pdf-page canvas { display: block; width: 100%; height: 100%; }

.pdf-fallback { padding: 3rem 1.25rem; text-align: center; color: var(--slate); }
.pdf-fallback .btn { display: inline-flex; width: auto; }

/* Text layer — extracted subset of pdfjs-dist 5.7.284 web/pdf_viewer.css
   (invisible selectable text positioned over the canvas). */
.textLayer {
  position: absolute;
  text-align: initial;
  inset: 0;
  overflow: clip;
  opacity: 1;
  line-height: 1;
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
  forced-color-adjust: none;
  transform-origin: 0 0;
  caret-color: CanvasText;
  z-index: 0;
  --min-font-size: 1;
  --text-scale-factor: calc(var(--total-scale-factor) * var(--min-font-size));
  --min-font-size-inv: calc(1 / var(--min-font-size));
}
.textLayer :is(span, br) {
  color: transparent;
  position: absolute;
  white-space: pre;
  cursor: text;
  transform-origin: 0% 0%;
}
.textLayer > :not(.markedContent), .textLayer .markedContent span:not(.markedContent) {
  z-index: 1;
  --font-height: 0;
  font-size: calc(var(--text-scale-factor) * var(--font-height));
  --scale-x: 1;
  --rotate: 0deg;
  transform: rotate(var(--rotate)) scaleX(var(--scale-x)) scale(var(--min-font-size-inv));
}
.textLayer .markedContent { display: contents; }
.textLayer span[role="img"] { user-select: none; cursor: default; }
.textLayer ::selection { background: color-mix(in srgb, var(--survey), transparent 70%); }
.textLayer br::selection { background: transparent; }
.textLayer .endOfContent {
  display: block;
  position: absolute;
  inset: 100% 0 0;
  z-index: 0;
  cursor: default;
  user-select: none;
}

@media (max-width: 640px) {
  .pdf-toolbar { gap: .5rem; }
  .pdf-toolbar__title { display: none; }
  .pdf-pages { padding: .75rem .25rem; }
  /* On small screens the reading area wins: compact the masthead, drop the search. */
  body.is-pdf-reader .reader-masthead__in { padding: .6rem 1rem; }
  body.is-pdf-reader .reader-search { display: none; }
  body.is-pdf-reader .reader-brand {
    font-size: 1rem;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}
@media print {
  .pdf-toolbar { display: none !important; }
  body.is-pdf-reader { height: auto; }
}
