/* Shared styles for the primary-source viewer pages
   Linked from /sources/*.html
   ------------------------------------------------------------- */
*,*::before,*::after { margin:0; padding:0; box-sizing:border-box; }
html { scroll-behavior: smooth; }
body { font-family: 'Iowan Old Style', Georgia, 'Times New Roman', serif; background:#f6f1e7; color:#2c2620; line-height:1.55; }
::selection { background:#d8b366; color:#1f1a14; }
a { color:#8a6420; text-decoration:none; border-bottom:1px dotted #d8b366; }
a:hover { color:#74420f; border-bottom-color:#8a6420; }

header.src-hero { background:linear-gradient(135deg, #162132 0%, #263855 100%); color:#f6f1e7; padding:1.6rem 1.5rem 1.4rem; border-bottom:4px double #d8b366; }
header.src-hero .crumbs { font-size:0.82rem; color:#c8b896; margin-bottom:0.4rem; }
header.src-hero .crumbs a { color:#d8b366; border-bottom:none; }
header.src-hero h1 { color:#f6f1e7; font-size:1.9rem; line-height:1.2; }
header.src-hero .sub { color:#e8dfc8; font-style:italic; margin-top:0.3rem; font-size:0.95rem; }
header.src-hero .meta-row { margin-top:0.7rem; display:flex; flex-wrap:wrap; gap:0.4rem; align-items:center; }
header.src-hero .pill { display:inline-block; font-size:0.72rem; font-weight:700; letter-spacing:0.07em; text-transform:uppercase; padding:3px 10px; border-radius:4px; background:rgba(212,160,23,0.18); color:#d8b366; }
header.src-hero .pill.primary { background:#d8b366; color:#1f1a14; }

main { max-width: 1100px; margin: 0 auto; padding: 1.6rem 1.4rem 4rem; }

.section { margin-bottom: 1.6rem; background:#fffaf0; border:1px solid #d8c8a8; border-radius:6px; padding:1rem 1.2rem; }
.section h2 { color: var(--brand-dark); border-bottom:1px solid #d8b366; padding-bottom:0.4rem; margin-bottom:0.8rem; font-size:1.25rem; font-weight:600; }
.section h3 { color:#4a3a22; font-size:1.05rem; margin:0.8rem 0 0.4rem; }
.section p { margin-bottom:0.7rem; }
.section .small { font-size:0.85rem; color:#6a5a42; }
.section ul, .section ol { padding-left:1.4rem; margin:0.4rem 0 0.8rem; }
.section li { margin-bottom:0.25rem; }

.kv { width:100%; border-collapse:collapse; }
.kv td { padding:0.45rem 0.7rem; vertical-align:top; border-bottom:1px solid #d8c8a8; font-size:0.95rem; }
.kv td:first-child { width:32%; color:#5a4a32; font-weight:600; font-size:0.78rem; text-transform:uppercase; letter-spacing:0.05em; padding-top:0.55rem; }
.kv tr:last-child td { border-bottom:none; }

/* PDF / image embed wrapper.
   Default: "wide" mode breaks out of main's max-width:1100px constraint and uses ~96vw of the
   viewport, giving the PDF plugin room to render at a readable size before the user even
   touches the zoom.

   The user-driven zoom controls below set --embed-zoom (a CSS custom property) on the wrapper.
   At >1.0 the embed itself overflows the wrapper — wrapper has overflow:auto, so horizontal
   AND vertical scroll bars appear, and the user can pan around the zoomed page. */
.embed-wrap {
  --embed-zoom: 1;
  background:#162132;
  padding:0.6rem;
  border-radius:4px;
  width:96vw;
  max-width:1800px;
  position:relative;
  left:50%;
  transform:translateX(-50%);
  margin:0.6rem auto;
  overflow:auto;
  scrollbar-color:#d8b366 #2c2620;
  scrollbar-width:thin;
}
/* Image-only viewers (single-page PDFs rendered as images, etc.) keep the in-column width. */
.embed-wrap.narrow { width:100%; max-width:none; left:auto; transform:none; }
.embed-wrap .embed-frame {
  /* Embed pixel size scales with --embed-zoom. At 1.0 it fills the wrapper exactly; at 2.0 it
     becomes twice as wide as the wrapper, triggering horizontal scroll. */
  width: calc(100% * var(--embed-zoom));
  min-width: calc(100% * var(--embed-zoom));
  height: calc(92vh * var(--embed-zoom));
  min-height: calc(760px * var(--embed-zoom));
  border:none;
  background:#fff;
  border-radius:4px;
  display:block;
}
.embed-wrap.image-frame { padding:0.4rem; }
.embed-wrap img { display:block; max-width:100%; height:auto; margin:0 auto; border-radius:3px; }
.embed-fallback { font-size:0.85rem; color:#c8b896; margin-top:0.5rem; text-align:center; padding:0.4rem; }
.embed-fallback a { color:#d8b366; }
/* Controls toolbar that sits below the embed: open-fullscreen, download, etc. */
.embed-controls { display:flex; flex-wrap:wrap; gap:0.5rem; margin:0.5rem auto 0; align-items:center; justify-content:center; max-width:1800px; }
.embed-controls a, .embed-controls button { display:inline-block; padding:0.35rem 0.8rem; background:#1f2e45; color:#d8b366; border:1px solid #d8b366; border-radius:4px; font-size:0.82rem; font-family:inherit; cursor:pointer; text-decoration:none; transition:all 0.15s; }
.embed-controls a:hover, .embed-controls button:hover { background:#d8b366; color:#1f1a14; }
.embed-controls button.active { background:#d8b366; color:#1f1a14; font-weight:700; }
.embed-controls .label { color:#5a4a32; font-size:0.78rem; font-style:italic; padding-right:0.3rem; }
.embed-controls .zoom-group { display:inline-flex; gap:0; border:1px solid #d8b366; border-radius:4px; overflow:hidden; }
.embed-controls .zoom-group button { border:none; border-radius:0; padding:0.35rem 0.65rem; }
.embed-controls .zoom-group button + button { border-left:1px solid rgba(212,160,23,0.3); }
.embed-controls .zoom-readout { display:inline-block; padding:0.35rem 0.6rem; color:#5a4a32; font-size:0.82rem; font-family:'SF Mono',Menlo,Consolas,monospace; min-width:3.4rem; text-align:center; }

.transcription { background:#fffaf0; padding:1rem 1.2rem; border-left:4px solid #33507a; border-radius:0 4px 4px 0; }
.transcription pre { font-family:'SF Mono',Menlo,Consolas,monospace; font-size:0.84rem; line-height:1.6; white-space:pre-wrap; word-wrap:break-word; color:#2c2620; background:#f6ebd2; padding:0.8rem 1rem; border-radius:4px; overflow-x:auto; }

/* Page-by-page transcription blocks (used on the pension file viewer) */
.page-toolbar { display:flex; flex-wrap:wrap; gap:0.4rem; margin:0.6rem 0 1rem; padding:0.6rem 0.8rem; background:#f6ebd2; border:1px solid #d8c8a8; border-radius:4px; font-size:0.78rem; align-items:center; }
.page-toolbar strong { color:#5a4a32; margin-right:0.3rem; }
.page-toolbar a { display:inline-block; padding:2px 7px; background:#fffaf0; border:1px solid #d8b366; border-radius:4px; color:#5a4a32; text-decoration:none; font-family:'SF Mono',Menlo,Consolas,monospace; font-weight:600; }
.page-toolbar a:hover { background:#d8b366; color:#1f1a14; border-color:#8a6420; }
.page-toolbar button { padding:2px 7px; background:#1f2e45; color:#d8b366; border:1px solid #d8b366; border-radius:4px; font-family:inherit; font-size:0.78rem; cursor:pointer; }
.page-toolbar button:hover { background:#d8b366; color:#1f1a14; }

.page-block { margin: 0.7rem 0; border:1px solid #d8c8a8; border-radius:4px; background:#fffaf0; overflow:hidden; scroll-margin-top: 70px; }
.page-block > summary { cursor:pointer; padding:0.6rem 0.9rem; background:linear-gradient(140deg, #f6ebd2, #f6ebd2); border-bottom:1px solid transparent; font-weight:600; color:#3a2f1e; list-style:none; user-select:none; }
.page-block[open] > summary { border-bottom-color:#d8c8a8; }
.page-block > summary::-webkit-details-marker { display:none; }
.page-block > summary::before { content:"▸"; color:#8a6420; font-weight:700; transition:transform 0.15s ease; display:inline-block; margin-right:0.45rem; }
.page-block[open] > summary::before { transform:rotate(90deg); }
.page-block > summary .page-num { display:inline-block; min-width:2.4rem; text-align:center; padding:1px 6px; background:#8a6420; color:#fff; border-radius:4px; font-family:'SF Mono',Menlo,Consolas,monospace; font-size:0.78rem; margin-right:0.5rem; vertical-align:middle; }
.page-block > summary .page-type { color:#5a4a32; font-weight:500; font-style:italic; font-size:0.92rem; }
.page-block .page-body { padding:0.8rem 1rem 1rem; }
.page-block .page-body dl.page-meta { display:grid; grid-template-columns: max-content 1fr; gap:0.25rem 0.8rem; margin-bottom:0.6rem; font-size:0.84rem; }
.page-block .page-body dl.page-meta dt { color:#5a4a32; font-weight:700; font-size: 0.76rem; text-transform:uppercase; letter-spacing:0.04em; padding-top:0.15rem; }
.page-block .page-body dl.page-meta dd { color:#2c2620; }
.page-block .page-body .body-text { background:#f6ebd2; border-left:4px solid #d8b366; padding:0.7rem 0.9rem; margin:0.4rem 0; font-size:0.88rem; line-height:1.6; border-radius:0 4px 4px 0; white-space:pre-wrap; font-family: 'Iowan Old Style', Georgia, 'Times New Roman', serif; }
.page-block .page-body .editor-note { font-size:0.8rem; color:#6a5a42; font-style:italic; margin-top:0.5rem; padding:0.3rem 0.5rem 0.3rem 0.7rem; border-left:2px solid #d8b366; background:rgba(212,160,23,0.06); border-radius:0 4px 4px 0; }
.page-block .page-body .editor-note::before { content:"Editor's note: "; font-weight:700; color:#8a6420; font-style:normal; }
.page-block .page-body .uncertain, .page-block .page-body em.unc { color:#8a6420; font-style:italic; }

.evidence-card { background:linear-gradient(140deg, #fffaf0, #f6ebd2); border:1px solid #d8b366; border-left:4px solid #d8b366; border-radius:4px; padding:0.9rem 1.1rem; margin:0.6rem 0; }
.evidence-card h3 { color: var(--brand-dark); margin-top:0; }

a.fsn { color:#4a3a22; text-decoration:none; border-bottom:1px dotted #d8b366; background:rgba(212,160,23,0.06); padding:0 2px; border-radius:4px; transition:all 0.15s; white-space:nowrap; }
a.fsn:hover { background:#d8b366; color:#1f1a14; border-bottom-color:#d8b366; }

footer.back-nav { margin-top:2rem; text-align:center; padding:1rem; }
footer.back-nav a { display:inline-block; padding:0.5rem 1rem; background:#1f2e45; color:#d8b366; border:1px solid #d8b366; border-radius:4px; font-weight:600; letter-spacing:0.04em; border-bottom:none; margin: 0 0.3rem; }
footer.back-nav a:hover { background:#d8b366; color:#1f1a14; }

@media (max-width: 640px) {
  header.src-hero h1 { font-size:1.4rem; }
  .embed-wrap { width:98vw; }
  .embed-wrap .embed-frame { height:75vh; min-height:480px; }
}

/* BEGIN-DARK-MODE-BODY-OVERRIDE */
/* ============================================================
   Dark-mode body override — updated 11 May 2026 (robust fallback)
   ============================================================
   The body rule earlier in this file hardcodes background:#f6f1e7
   (cream). We override with `:root:not(.theme-light)` so the page
   renders DARK whenever the user is in dark mode OR when the theme
   init script fails to run (e.g., scripts blocked on file:// URLs).
   The only way to get cream is to explicitly toggle to light, which
   adds the .theme-light class.
   ------------------------------------------------------------ */
:root:not(.theme-light) body,
:root.theme-dark body {
  background: #1c2a3f !important;
  color: #e8dfc8 !important;
}
:root:not(.theme-light) a,
:root.theme-dark a { color: #e6c47a; }
:root:not(.theme-light) a:hover,
:root.theme-dark a:hover { color: #fadea0; }
/* END-DARK-MODE-BODY-OVERRIDE */

/* ============================================================
   Research-log COMPREHENSIVE dark-mode override (17 May 2026 night)
   ============================================================
   The earlier body-only override flipped the page background, but
   all the container classes in this _shared.css file still
   hardcoded light cream backgrounds and dark sepia text — so the
   nested cards/sections/transcription blocks all rendered as
   bright islands on the walnut page. Below, every load-bearing
   class in this stylesheet gets a paired dark-mode rule that
   uses the same walnut / cream / muted-text palette the rest of
   the site uses.
   ------------------------------------------------------------ */

:root:not(.theme-light) header.src-hero,
:root.theme-dark header.src-hero {
  background: #1c2a3f !important;
  border-color: #d8b366 !important;
  color: #e8dfc8 !important;
}
:root:not(.theme-light) header.src-hero h1,
:root.theme-dark header.src-hero h1,
:root:not(.theme-light) header.src-hero .crumbs,
:root.theme-dark header.src-hero .crumbs {
  color: #f6f1e7 !important;
}
:root:not(.theme-light) header.src-hero .crumbs a,
:root.theme-dark header.src-hero .crumbs a {
  color: #d8b366 !important;
}

:root:not(.theme-light) .section,
:root.theme-dark .section {
  background: #1c2a3f !important;
  border-color: #33496b !important;
  color: #e8dfc8 !important;
}
:root:not(.theme-light) .section h2,
:root.theme-dark .section h2,
:root:not(.theme-light) .section h3,
:root.theme-dark .section h3,
:root:not(.theme-light) .section h4,
:root.theme-dark .section h4 {
  color: #f1cf85 !important;
}

:root:not(.theme-light) .transcription,
:root.theme-dark .transcription {
  background: #1c2a3f !important;
  border-left-color: #6a8acc !important;
  color: #e8dfc8 !important;
}
:root:not(.theme-light) .transcription pre,
:root.theme-dark .transcription pre {
  background: #1c2a3f !important;
  color: #e8dfc8 !important;
}

:root:not(.theme-light) .page-toolbar,
:root.theme-dark .page-toolbar {
  background: #1c2a3f !important;
  border-color: #33496b !important;
  color: #c8b896 !important;
}
:root:not(.theme-light) .page-toolbar a,
:root.theme-dark .page-toolbar a {
  background: #1c2a3f !important;
  border-color: #33496b !important;
  color: #fadea0 !important;
}
:root:not(.theme-light) .page-toolbar a:hover,
:root.theme-dark .page-toolbar a:hover {
  background: #d8b366 !important;
  color: #1f1a14 !important;
  border-color: #d8b366 !important;
}
:root:not(.theme-light) .page-toolbar button,
:root.theme-dark .page-toolbar button {
  background: #1c2a3f !important;
  color: #fadea0 !important;
  border-color: #d8b366 !important;
}
:root:not(.theme-light) .page-toolbar button:hover,
:root.theme-dark .page-toolbar button:hover {
  background: #d8b366 !important;
  color: #1f1a14 !important;
}

:root:not(.theme-light) .page-block,
:root.theme-dark .page-block {
  background: #1c2a3f !important;
  border-color: #33496b !important;
}
:root:not(.theme-light) .page-block > summary,
:root.theme-dark .page-block > summary {
  background: #1c2a3f !important;
  color: #e8dfc8 !important;
}
:root:not(.theme-light) .page-block > summary .page-num,
:root.theme-dark .page-block > summary .page-num {
  background: #d8b366 !important;
  color: #1f1a14 !important;
}
:root:not(.theme-light) .page-block .page-body .body-text,
:root.theme-dark .page-block .page-body .body-text {
  background: #1c2a3f !important;
  border-left-color: #33496b !important;
  color: #e8dfc8 !important;
}

:root:not(.theme-light) .embed-controls,
:root.theme-dark .embed-controls {
  background: #1c2a3f !important;
  color: #e8dfc8 !important;
}
:root:not(.theme-light) .embed-controls a,
:root.theme-dark .embed-controls a,
:root:not(.theme-light) .embed-controls button,
:root.theme-dark .embed-controls button {
  background: #1c2a3f !important;
  color: #fadea0 !important;
  border-color: #d8b366 !important;
}
:root:not(.theme-light) .embed-controls a:hover,
:root.theme-dark .embed-controls a:hover,
:root:not(.theme-light) .embed-controls button:hover,
:root.theme-dark .embed-controls button:hover,
:root:not(.theme-light) .embed-controls button.active,
:root.theme-dark .embed-controls button.active {
  background: #d8b366 !important;
  color: #1f1a14 !important;
}

/* Anything else with a hardcoded #fff background on these pages */
:root:not(.theme-light) .src-img,
:root.theme-dark .src-img {
  background: #2c261d !important;
}

/* Force descendant text colors to flip — catches inline <strong>,
   <em>, <span> etc. inside the research-log container surfaces. */
:root:not(.theme-light) .section *,
:root.theme-dark .section *,
:root:not(.theme-light) .transcription *,
:root.theme-dark .transcription *,
:root:not(.theme-light) .page-block *,
:root.theme-dark .page-block *,
:root:not(.theme-light) .page-toolbar *,
:root.theme-dark .page-toolbar * {
  color: inherit;
}
:root:not(.theme-light) .section h2,
:root.theme-dark .section h2,
:root:not(.theme-light) .section h3,
:root.theme-dark .section h3,
:root:not(.theme-light) .section strong,
:root.theme-dark .section strong {
  color: #f1cf85 !important;
}
