/* 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;
  /* Fixed viewport-sized box so the horizontal scrollbar lands at the visible bottom edge,
     not somewhere ~184vh below the fold when the user zooms in. */
  height:92vh;
  max-height:92vh;
  min-height:680px;
  position:relative;
  left:50%;
  transform:translateX(-50%);
  margin:0.6rem auto;
  overflow:auto;
  scrollbar-color:#d8b366 #2c2620;
  scrollbar-width:thin;
}
/* Always-visible scrollbars on WebKit / Blink (Chrome / Safari / Edge) — by default these
   browsers auto-hide the scrollbar on macOS, so the user couldn't see the horizontal scrollbar
   they need to use after zooming in. Force the scrollbar to render permanently. */
.embed-wrap::-webkit-scrollbar { width:14px; height:14px; background:#2c2620; }
.embed-wrap::-webkit-scrollbar-track { background:#2c2620; border-radius:7px; }
.embed-wrap::-webkit-scrollbar-thumb { background:#d8b366; border-radius:7px; border:2px solid #2c2620; min-width:30px; min-height:30px; }
.embed-wrap::-webkit-scrollbar-thumb:hover { background:#f1cf85; }
.embed-wrap::-webkit-scrollbar-corner { background:#2c2620; }
/* 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 and tall as the wrapper, triggering horizontal AND vertical scroll
     INSIDE the fixed-viewport-height wrapper above. */
  width: calc(100% * var(--embed-zoom));
  min-width: calc(100% * var(--embed-zoom));
  height: calc(100% * var(--embed-zoom));
  min-height: calc(100% * 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; height:80vh; max-height:80vh; min-height:480px; }
  .embed-wrap .embed-frame { height:calc(100% * var(--embed-zoom)); min-height:calc(100% * var(--embed-zoom)); }
}

/* ============================================================
   DARK-MODE OVERRIDES — added 10 May 2026
   The defaults above hardcode the cream/brown light palette.
   These rules invert the page surfaces (body, .section panels,
   .page-block details, .transcription, .page-toolbar) using the
   same theme-token values as ../assets/dark-mode.css. The dark
   .src-hero header and dark .embed-wrap PDF frame already work
   in both modes and need no override here.
   ============================================================ */

/* -- Explicit theme-dark toggle -------------------------------- */
:root.theme-dark body {
  background: #1c2a3f;
  color: #e8dfc8;
}
:root.theme-dark a { color: #fadea0; border-bottom-color: #d8b366; }
:root.theme-dark a:hover { color: #f1cf85; border-bottom-color: #f1cf85; }
:root.theme-dark ::selection { background: #d8b366; color: #1a1612; }

:root.theme-dark .section {
  background: #1c2a3f;
  border-color: #33496b;
  color: #e8dfc8;
}
:root.theme-dark .section h3 { color: #f1cf85; }
:root.theme-dark .section .small { color: #c8b896; }
:root.theme-dark .section strong { color: #fadea0; }
:root.theme-dark .section em { color: #c8b896; }

:root.theme-dark .kv td { color: #e8dfc8; }
:root.theme-dark .kv td:first-child { color: #c8b896; }

:root.theme-dark .transcription {
  background: #1c2a3f;
  border-left-color: #6a8acc;
  color: #e8dfc8;
}
:root.theme-dark .transcription pre {
  background: #1c2a3f;
  color: #e8dfc8;
  border: 1px solid #33496b;
}

:root.theme-dark .page-toolbar {
  background: #1c2a3f;
  border-color: #33496b;
  color: #e8dfc8;
}
:root.theme-dark .page-toolbar strong { color: #fadea0; }
:root.theme-dark .page-toolbar a {
  background: #1c2a3f;
  border-color: #33496b;
  color: #fadea0;
}
:root.theme-dark .page-toolbar a:hover {
  background: #d8b366;
  color: #1a1612;
  border-color: #fadea0;
}

:root.theme-dark .page-block {
  background: #1c2a3f;
  border-color: #33496b;
}
:root.theme-dark .page-block > summary {
  background: linear-gradient(140deg, #1c2a3f, #1c2a3f);
  color: #f1cf85;
}

:root.theme-dark body dl.page-meta dt { color: #c8b896; }
:root.theme-dark body dl.page-meta dd { color: #e8dfc8; }
:root.theme-dark body .body-text {
  background: #1c2a3f;
  border-left-color: #d8b366;
  color: #e8dfc8;
}
:root.theme-dark body .editor-note {
  color: #c8b896;
  background: rgba(216, 179, 102, 0.10);
  border-left-color: #d8b366;
}
:root.theme-dark body .editor-note::before { color: #fadea0; }
:root.theme-dark body .uncertain { color: #fadea0; }

/* -- prefers-color-scheme: dark (system preference) ----------- */
@media (prefers-color-scheme: dark) {
  html:not(.theme-light) body {
    background: #1a1612;
    color: #e8dfc8;
  }
  html:not(.theme-light) a { color: #fadea0; border-bottom-color: #d8b366; }
  html:not(.theme-light) a:hover { color: #f1cf85; border-bottom-color: #d8b366; }

  html:not(.theme-light) .section {
    background: #24201a;
    border-color: #8a6420;
    color: #e8dfc8;
  }
  html:not(.theme-light) .section h3 { color: #f1cf85; }
  html:not(.theme-light) .section .small { color: #c8b896; }
  html:not(.theme-light) .section strong { color: #fadea0; }

  html:not(.theme-light) .kv td { color: #e8dfc8; }
  html:not(.theme-light) .kv td:first-child { color: #c8b896; }

  html:not(.theme-light) .transcription {
    background: #24201a;
    border-left-color: #33507a;
    color: #e8dfc8;
  }
  html:not(.theme-light) .transcription pre {
    background: #1a1612;
    color: #e8dfc8;
    border: 1px solid #1c2a3f;
  }

  html:not(.theme-light) .page-toolbar {
    background: #2a2519;
    border-color: #8a6420;
    color: #e8dfc8;
  }
  html:not(.theme-light) .page-toolbar strong { color: #fadea0; }
  html:not(.theme-light) .page-toolbar a {
    background: #1a1612;
    border-color: #8a6420;
    color: #fadea0;
  }
  html:not(.theme-light) .page-toolbar a:hover {
    background: #d8b366;
    color: #1a1612;
  }

  html:not(.theme-light) .page-block {
    background: #24201a;
    border-color: #8a6420;
  }
  html:not(.theme-light) .page-block > summary {
    background: linear-gradient(140deg, #2a2519, #24201a);
    color: #f1cf85;
  }
}

/* ============================================================
   Inline-style override — added 10 May 2026
   Three source viewer pages (entry-195-baptism, fold3-service,
   project-attachment-3) have <div class="evidence-card"> and
   <p class="small"> elements with hardcoded background hex
   colors in their style attributes. Inline styles win over
   normal CSS, so the only way to invert them is !important
   plus an attribute selector that matches the inline-style
   shape. We force them onto the walnut palette while
   preserving any decorative left-border accent.
   ============================================================ */
:root.theme-dark .evidence-card[style*="background"] {
  background: #1c2a3f !important;
  color: #e8dfc8 !important;
}
:root.theme-dark .evidence-card[style*="background"] strong { color: #fadea0 !important; }
:root.theme-dark .evidence-card[style*="background"] em { color: #c8b896 !important; }
:root.theme-dark .evidence-card[style*="background"] a { color: #fadea0 !important; }

:root.theme-dark p[style*="background:#f6ebd2"],
:root.theme-dark p[style*="background: #f6ebd2"],
:root.theme-dark .small[style*="background:#f6ebd2"],
:root.theme-dark .small[style*="background: #f6ebd2"] {
  background: #1c2a3f !important;
  color: #e8dfc8 !important;
}
:root.theme-dark p[style*="background:#f6ebd2"] a,
:root.theme-dark .small[style*="background:#f6ebd2"] a {
  color: #fadea0 !important;
}

@media (prefers-color-scheme: dark) {
  html:not(.theme-light) .evidence-card[style*="background"] {
    background: #1c2a3f !important;
    color: #e8dfc8 !important;
  }
  html:not(.theme-light) .evidence-card[style*="background"] strong { color: #fadea0 !important; }
  html:not(.theme-light) .evidence-card[style*="background"] em { color: #c8b896 !important; }
  html:not(.theme-light) .evidence-card[style*="background"] a { color: #fadea0 !important; }

  html:not(.theme-light) p[style*="background:#f6ebd2"],
  html:not(.theme-light) p[style*="background: #f6ebd2"],
  html:not(.theme-light) .small[style*="background:#f6ebd2"],
  html:not(.theme-light) .small[style*="background: #f6ebd2"] {
    background: #1c2a3f !important;
    color: #e8dfc8 !important;
  }
}

/* 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 */
