/* ══════════════════════════════════════════════════════════
   HTDB Modern Stylesheet
   Added to all content pages by setup.sh
   Theme switching is handled by htdb-theme.js via postMessage
   from the parent shell (index.html).
══════════════════════════════════════════════════════════ */

/* ── Layout & Typography ── */
html {
  background-color: #fdfaf4 !important;
}
body, html body {
  font-family: Georgia, 'Times New Roman', serif !important;
  line-height: 1.8 !important;
  margin: 0 auto !important;
  padding: 1.5rem 2.25rem 4rem !important;
  max-width: 960px !important;
  background:  rgba(253,250,244,0.88) !important;
  color:       #1a1a1a !important;
}

/* ── Links ── */
a, a:link { color: #1a4f8b !important; text-decoration: none; }
a:visited  { color: #5b3080 !important; }
a:hover    { text-decoration: underline !important; }
a:active   { color: #1a4f8b !important; }

/* ── Emphasis ── */
b, strong  { color: #0d0d0d !important; }
i, em      { color: inherit !important; }

/* ── Dividers ── */
hr {
  border: none !important;
  border-top: 1px solid rgba(0,0,0,0.15) !important;
  margin: 0.75em 0 !important;
}

/* ── Old <font size> tags ── */
font[size="5"], font[size="4"] {
  display:     block !important;
  font-size:   1.5em !important;
  font-weight: 700 !important;
  color:       #1a3a5c !important;
  font-family: Georgia, serif !important;
  margin:      0.6em 0 0.3em !important;
  line-height: 1.3 !important;
}
font[size="3"] {
  display:     block !important;
  font-size:   1.1em !important;
  font-weight: 600 !important;
  color:       #1a3a5c !important;
  margin:      0.8em 0 0.25em !important;
}
font[size="2"] { font-size: 0.93em !important; }
font[size="1"] { font-size: 0.82em !important; }

/* ── Paragraph spacing ── */
p { margin-bottom: 0.75em !important; }
a[name] { scroll-margin-top: 1rem; }

/* ── Hide old layout-spacer images ── */
img[src="blnk.gif"],
img[src*="blnk"],
img[src="img0.gif"],
img[width="1"],
img[height="1"] { display: none !important; }

img { max-width: 100% !important; height: auto !important; }

/* ── Flatten old zero-padding table spacer layout ──
   Index pages (indexot.htm etc.) use a table with spacer GIFs
   to position content. Setting display:block collapses the
   fixed pixel rows/columns back to normal document flow. */
table[cellpadding="0"][cellspacing="0"] {
  display: block !important;
  width:   100%  !important;
  border:  0     !important;
}
table[cellpadding="0"][cellspacing="0"] tr {
  display: block  !important;
  height:  auto   !important;
}
table[cellpadding="0"][cellspacing="0"] td {
  display:        block !important;
  width:          auto  !important;
  height:         auto  !important;
  padding:        0     !important;
  vertical-align: top   !important;
}

/* Content tables (e.g. comparison tables in Studies) stay as tables */
table:not([cellpadding="0"]):not([cellspacing="0"]) {
  max-width:       100% !important;
  border-collapse: collapse !important;
}

/* ══════════════════════════════════════════════════════════
   DARK MODE
   Applied via [data-theme="dark"] on <html> by htdb-theme.js
══════════════════════════════════════════════════════════ */
html[data-theme="dark"] {
  background-color: #0f1826 !important;
}
[data-theme="dark"] body,
[data-theme="dark"] html body {
  background: rgba(15,24,38,0.88) !important;
  color:      #c8d8ec !important;
}
[data-theme="dark"] a,
[data-theme="dark"] a:link { color: #6eaff5 !important; }
[data-theme="dark"] a:visited  { color: #c084fc !important; }
[data-theme="dark"] a:hover    { color: #6eaff5 !important; }
[data-theme="dark"] b,
[data-theme="dark"] strong     { color: #e8f0ff !important; }
[data-theme="dark"] hr         { border-top-color: rgba(255,255,255,0.1) !important; }

[data-theme="dark"] font[size="5"],
[data-theme="dark"] font[size="4"] { color: #90c8f8 !important; }
[data-theme="dark"] font[size="3"] { color: #a8cfff !important; }

[data-theme="dark"] table:not([cellpadding="0"]):not([cellspacing="0"]) td,
[data-theme="dark"] table:not([cellpadding="0"]):not([cellspacing="0"]) th {
  color:        #c8d8ec !important;
  background:   transparent !important;
  border-color: rgba(255,255,255,0.1) !important;
}

/* ══════════════════════════════════════════════════════════
   PRINT STYLES
══════════════════════════════════════════════════════════ */
@media print {
  @page {
    size: letter portrait;
    margin: 2cm 2.2cm 2cm;

    /* Centered "Page X of X" footer — replaces browser default on
       supporting browsers (Chrome 85+, Firefox 132+).
       Turn off "Headers and footers" in your browser's print dialog
       to show only this footer. */
    @bottom-center {
      content: "Page " counter(page) " of " counter(pages);
      font-family: Georgia, 'Times New Roman', serif;
      font-size:   9pt;
      color:       #555;
      border-top:  1px solid #ddd;
      padding-top: 4pt;
    }

    /* Clear other margin boxes so the browser defaults don't double up */
    @bottom-left  { content: none; }
    @bottom-right { content: none; }
    @top-left     { content: none; }
    @top-center   { content: none; }
    @top-right    { content: none; }
  }

  html,
  html[data-theme="dark"] {
    background: #fff !important;
    background-image: none !important;
    color: #000 !important;
  }
  body,
  [data-theme="dark"] body,
  [data-theme="dark"] html body {
    background: #fff !important;
    color:      #000 !important;
    padding:    0    !important;
    max-width:  none !important;
    font-size:  11pt !important;
    line-height: 1.6 !important;
  }
  a,
  [data-theme="dark"] a          { color: #000 !important; text-decoration: underline !important; }
  a:visited,
  [data-theme="dark"] a:visited  { color: #333 !important; }
  b, strong,
  [data-theme="dark"] b,
  [data-theme="dark"] strong     { color: #000 !important; }
  hr                             { border-top: 1px solid #ccc !important; }

  font[size="5"], font[size="4"] {
    font-size: 16pt !important;
    color:     #1a3a5c !important;
    page-break-after: avoid;
  }
  font[size="3"] {
    font-size: 12pt !important;
    color:     #1a3a5c !important;
    page-break-after: avoid;
  }
  font[size="2"] { font-size: 9.5pt !important; }
  font[size="1"] { font-size: 8.5pt !important; }

  img[src="blnk.gif"],
  img[src*="blnk"],
  img[src="img0.gif"] { display: none !important; }

  table[cellpadding="0"][cellspacing="0"]    { display: block !important; }
  table[cellpadding="0"][cellspacing="0"] tr { display: block !important; height: auto !important; }
  table[cellpadding="0"][cellspacing="0"] td { display: block !important; height: auto !important; }

  h1, h2, h3  { page-break-after: avoid; }
  p           { orphans: 3; widows: 3; }
}
