/*
 * π PI IN THE BIBLE — STYLESHEET (mobile-first)
 * ==============================================
 * Vanilla CSS. No frameworks. Base rules target phones; @media (min-width)
 * blocks progressively enhance tablets and desktops.
 *
 * TABLE OF CONTENTS
 *  §1  Design tokens (:root)          §9   Callouts (semantic colours)
 *  §2  Themes (4)                     §10  Stats, steps, compare cards, summary
 *  §3  Base / reset                   §11  Tables, formulas, Hebrew/Greek
 *  §4  Accessibility                  §12  Tools (calculators) & forms
 *  §5  Layout: header, banner         §13  Page components: progress, top, toast
 *  §6  Typography                     §14  Lightbox
 *  §7  Control bar & dropdown         §15  Splash overlay
 *  §8  Main content, figures, images  §16  Bible refs · §17 Responsive · §18 Print
 *
 * Colour semantics (universal, not themed):
 *   green  = go / success / correct     yellow = alert / warning
 *   red    = stop / error               (see --color-go / --color-alert / --color-stop)
 */


/* ═══════════════════════════════════════════════════════════════════
   §1  DESIGN TOKENS
   ═══════════════════════════════════════════════════════════════════ */
:root {
    --font-base:   17px;
    --font-scale:  1;
    --font-title:  'Gabriela', Georgia, 'Times New Roman', serif;
    --font-body:   'Lato', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    --font-mono:   ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
    --font-hebrew: 'SBL Hebrew', 'Ezra SIL', 'Times New Roman', 'Arial Hebrew', serif;
    --font-greek:  'SBL Greek', 'Gentium Plus', 'Palatino Linotype', 'Times New Roman', serif;

    --max-width:   920px;

    --radius:      16px;
    --radius-sm:   10px;
    --radius-xs:   6px;
    --radius-pill: 9999px;

    --ease:        cubic-bezier(0.25, 0.1, 0.25, 1);   /* Apple-style ease */
    --t-fast:      0.18s;
    --t-med:       0.32s;

    --space-1: 0.25rem;  --space-2: 0.5rem;  --space-3: 1rem;
    --space-4: 1.5rem;   --space-5: 2rem;    --space-6: 3rem;

    --shadow-xs: 0 1px 2px var(--shadow);
    --shadow-sm: 0 2px 8px var(--shadow);
    --shadow-md: 0 6px 20px var(--shadow);
    --shadow-lg: 0 12px 40px var(--shadow);
    --text-shadow: 1px 2px 4px var(--shadow-ink);

    /* Semantic colours — universal meaning, never themed */
    --color-go:       #22c55e;
    --color-go-bg:    rgba(34, 197, 94, 0.12);
    --color-alert:    #f5b400;
    --color-alert-bg: rgba(245, 180, 0, 0.14);
    --color-stop:     #ef4444;
    --color-stop-bg:  rgba(239, 68, 68, 0.12);
    --color-info:     #38bdf8;
    --color-info-bg:  rgba(56, 189, 248, 0.12);

    --tap: 44px;   /* minimum touch target (Apple HIG) */
}


/* ═══════════════════════════════════════════════════════════════════
   §2  THEMES — elegant, high-contrast, dark shadows
       --bg / --secondary (cards) / --text / --primary (titles, gold)
       --accent (bronze) / --link / --shadow / --shadow-ink
   ═══════════════════════════════════════════════════════════════════ */

/* 1. Temple Midnight (default) — midnight blue + burnished gold.
      Also applied to bare <body> so the page is styled even without a theme class. */
body,
body.theme-dark-temple {
    --bg:         #0b1020;
    --secondary:  #141b33;
    --tertiary:   #1c2542;
    --text:       #eef1fa;
    --muted:      #b6bdd4;
    --primary:    #e2b857;
    --accent:     #d98d3a;
    --link:       #8fd0ff;
    --shadow:     rgba(0, 0, 0, 0.55);
    --shadow-ink: rgba(0, 0, 0, 0.85);
    --on-primary: #14110a;
    --line:       rgba(226,184,87,0.55);
    --line-soft:  rgba(226,184,87,0.28);
    --hover:      rgba(226,184,87,0.08);
    --focus-ring: rgba(217,141,58,0.35);
    --bg-glass:   rgba(11,16,32,0.82);
}

/* 2. Bronze Sea — cast bronze & amber */
body.theme-dark-bronze {
    --bg:         #18100a;
    --secondary:  #271a10;
    --tertiary:   #34241a;
    --text:       #f8eddc;
    --muted:      #d8c3a5;
    --primary:    #e9a94a;
    --accent:     #ffd27f;
    --link:       #ffc98a;
    --shadow:     rgba(0, 0, 0, 0.6);
    --shadow-ink: rgba(0, 0, 0, 0.9);
    --on-primary: #1a1006;
    --line:       rgba(233,169,74,0.55);
    --line-soft:  rgba(233,169,74,0.28);
    --hover:      rgba(233,169,74,0.08);
    --focus-ring: rgba(255,210,127,0.35);
    --bg-glass:   rgba(24,16,10,0.82);
}

/* 3. Parchment — warm scroll paper */
body.theme-light-parchment {
    --bg:         #f5efe1;
    --secondary:  #fffaf0;
    --tertiary:   #f1e7d2;
    --text:       #2b2418;
    --muted:      #6b5d47;
    --primary:    #8a5a19;
    --accent:     #b8862b;
    --link:       #1b4f9c;
    --shadow:     rgba(60, 40, 10, 0.18);
    --shadow-ink: rgba(60, 40, 10, 0.35);
    --on-primary: #fff9ec;
    --line:       rgba(138,90,25,0.5);
    --line-soft:  rgba(138,90,25,0.25);
    --hover:      rgba(138,90,25,0.07);
    --focus-ring: rgba(184,134,43,0.35);
    --bg-glass:   rgba(245,239,225,0.85);
}

/* Light themes: darker semantic colours so green / yellow / red text stays readable on pale backgrounds */
body[class*="theme-light"] {
    --color-go:    #15803d;
    --color-alert: #b45309;
    --color-stop:  #b91c1c;
    --color-info:  #0369a1;
}

/* 4. Ink & Paper — clean white */
body.theme-light-ink {
    --bg:         #ffffff;
    --secondary:  #f4f5f8;
    --tertiary:   #e9ebf1;
    --text:       #111827;
    --muted:      #4b5563;
    --primary:    #1f2937;
    --accent:     #b45309;
    --link:       #1d4ed8;
    --shadow:     rgba(0, 0, 0, 0.12);
    --shadow-ink: rgba(0, 0, 0, 0.25);
    --on-primary: #ffffff;
    --line:       rgba(31,41,55,0.45);
    --line-soft:  rgba(31,41,55,0.2);
    --hover:      rgba(31,41,55,0.06);
    --focus-ring: rgba(180,83,9,0.3);
    --bg-glass:   rgba(255,255,255,0.85);
}


/* ═══════════════════════════════════════════════════════════════════
   §3  BASE / RESET
   ═══════════════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; }

html {
    font-size:          calc(var(--font-base) * var(--font-scale));
    scroll-behavior:    smooth;
    scroll-padding-top: 1rem;
    -webkit-text-size-adjust: 100%;
}

body {
    margin:           0;
    background-color: var(--bg);
    color:            var(--text);
    font-family:      var(--font-body);
    line-height:      1.7;
    overflow-wrap:    break-word;
    transition:       background-color var(--t-med) var(--ease), color var(--t-med) var(--ease);
    scrollbar-width:  thin;
    scrollbar-color:  var(--primary) var(--secondary);
}
body::-webkit-scrollbar             { width: 8px; }
body::-webkit-scrollbar-track       { background: var(--secondary); }
body::-webkit-scrollbar-thumb       { background: var(--primary); border-radius: 4px; }

img, svg { max-width: 100%; height: auto; display: block; }
[hidden]  { display: none !important; }
img       { border-radius: var(--radius-sm); }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}


/* ═══════════════════════════════════════════════════════════════════
   §4  ACCESSIBILITY
   ═══════════════════════════════════════════════════════════════════ */
.skip-link {
    position: absolute; top: -200px; left: 1rem; z-index: 99999;
    background: var(--primary); color: var(--on-primary);
    padding: 0.6rem 1.2rem; border-radius: var(--radius-sm); font-weight: 700; text-decoration: none;
    transition: top var(--t-fast) var(--ease);
}
.skip-link:focus { top: 0.5rem; outline: 3px solid var(--accent); }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: var(--radius-xs); }
:focus:not(:focus-visible) { outline: none; }

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}


/* ═══════════════════════════════════════════════════════════════════
   §5  LAYOUT — page container, header, banner (edge-to-edge on phones)
   ═══════════════════════════════════════════════════════════════════ */
.page-container {
    width: 100%; min-height: 100vh;
    display: flex; flex-direction: column; align-items: center;
}

.page-header { width: 100%; max-width: 1600px; margin: 0 auto; padding: 0; }

.banner-image {
    width: 100%; aspect-ratio: 1600 / 400; object-fit: cover;
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: var(--shadow-md);
    transition: transform var(--t-fast) var(--ease), filter var(--t-fast) var(--ease);
}
.banner-nav-trigger { cursor: pointer; }
.banner-nav-trigger:hover { filter: brightness(1.06); }
.banner-nav-trigger:focus-visible { outline: 3px solid var(--primary); outline-offset: -4px; }
.banner-link { display: block; }

.text-title {
    font-family: var(--font-title); color: var(--primary); text-align: center;
    font-size: 2.2rem; margin: 1.5rem 1rem; text-shadow: var(--text-shadow);
}

#page-description {
    max-width: var(--max-width); width: 100%;
    margin: 1rem auto 0.75rem; padding: 0 1rem;
    text-align: center; font-style: italic; color: var(--muted); font-size: 1rem;
}


/* ═══════════════════════════════════════════════════════════════════
   §6  TYPOGRAPHY
   ═══════════════════════════════════════════════════════════════════ */
h1, h2, h3, h4 {
    font-family:   var(--font-title);
    color:         var(--primary);
    text-shadow:   var(--text-shadow);
    line-height:   1.25;
    margin:        1.6em 0 0.6em;
    text-wrap:     balance;
    font-weight:   400;
}
h1 { font-size: 2rem; }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }

p, li, dd { font-size: 1rem; text-wrap: pretty; }
p  { margin: 0 0 1em; text-align: left; hyphens: auto; }
.lead { font-size: 1.12rem; }

a { color: var(--link); text-decoration: none; font-weight: 600; transition: color var(--t-fast) var(--ease); }
a:hover { text-decoration: underline; }
main a[target="_blank"]:not(.bible-ref)::after { content: " ↗"; font-size: 0.75em; opacity: 0.7; }

strong { font-weight: 700; }
em     { font-style: italic; }
.go    { color: var(--color-go); font-weight: 700; }
.stop  { color: var(--color-stop); font-weight: 700; }
.alert { color: var(--color-alert); font-weight: 700; }
.mono  { font-family: var(--font-mono); font-size: 0.85em; word-break: break-all; }

hr { border: 0; border-top: 2px solid var(--primary); opacity: 0.4; margin: 2em 0; }


/* ═══════════════════════════════════════════════════════════════════
   §7  CONTROL BAR & DROPDOWN
   ═══════════════════════════════════════════════════════════════════ */
.control-bar {
    position: sticky; top: 0; z-index: 300;
    width: 100%; max-width: var(--max-width);
    display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-glass);
    -webkit-backdrop-filter: saturate(160%) blur(14px);
    backdrop-filter: saturate(160%) blur(14px);
    border-radius: 0 0 var(--radius) var(--radius);
}

.control-btn {
    min-height: var(--tap); min-width: var(--tap); padding: 0 1rem;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--secondary); color: var(--text);
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    font: 700 1rem var(--font-body);
    cursor: pointer; user-select: none;
    box-shadow: var(--shadow-sm);
    transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease),
                transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.control-btn:hover  { background: var(--primary); color: var(--on-primary); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.control-btn:active { transform: translateY(1px); box-shadow: var(--shadow-xs); }

.dropdown { position: relative; }
.dropdown-content {
    display: none; position: absolute; left: 0; right: auto; top: calc(100% + 6px); z-index: 400;
    min-width: 260px; max-width: min(92vw, 380px);
    background: var(--secondary); color: var(--text);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); overflow: hidden;
    animation: dropdownOpen var(--t-fast) var(--ease);
}
.dropdown-content.open { display: block; }
@keyframes dropdownOpen { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.dropdown-content a {
    display: block; padding: 0.75rem 1rem; min-height: var(--tap);
    color: var(--text); font-weight: 500; text-decoration: none;
    transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.dropdown-content a:hover, .dropdown-content a:focus-visible { background: var(--primary); color: var(--on-primary); outline: none; }
.dropdown-content hr { margin: 0; opacity: 0.25; }


/* ═══════════════════════════════════════════════════════════════════
   §8  MAIN CONTENT, FIGURES, IMAGES
   ═══════════════════════════════════════════════════════════════════ */
main.content-body {
    width: 100%; max-width: var(--max-width);
    background: var(--secondary);
    padding: 1.25rem 1rem 2rem;
    margin: 0.75rem 0 2.5rem;
    border-radius: var(--radius) var(--radius) 0 0;   /* edge-to-edge on phones */
    box-shadow: var(--shadow-md);
}
main h2 {
    border-bottom: 2px solid var(--line);
    padding-bottom: 0.4rem; scroll-margin-top: 4.5rem;
}
main h2:first-of-type { margin-top: 1rem; }

figure { margin: 1.5rem 0; text-align: center; }
figure img { margin: 0 auto; border-radius: var(--radius-sm); box-shadow: var(--shadow-sm); background: #fff; }
figure img.img-inline { box-shadow: none; }
figcaption { margin-top: 0.5rem; font-size: 0.9rem; font-style: italic; color: var(--muted); text-align: center; }

.img-row, .diagram-row { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.diagram svg { width: 100%; max-width: 300px; margin: 0 auto; color: var(--text); }

.lightbox-trigger { display: block; cursor: zoom-in; border-radius: var(--radius-sm); }
.lightbox-trigger img { transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease); }
.lightbox-trigger:hover img { transform: scale(1.015); box-shadow: var(--shadow-md); }


/* ═══════════════════════════════════════════════════════════════════
   §9  CALLOUTS — colour-coded by meaning
   ═══════════════════════════════════════════════════════════════════ */
.callout {
    margin: 1.5rem 0; padding: 1rem 1.1rem;
    border-radius: var(--radius-sm);
    border-left: 5px solid var(--primary);
    background: var(--tertiary);
    box-shadow: var(--shadow-xs);
}
.callout > strong:first-child { display: block; margin-bottom: 0.35rem; font-family: var(--font-title); font-size: 1.05rem; }
.callout-info      { border-color: var(--color-info);  background: var(--color-info-bg); }
.callout-warning   { border-color: var(--color-alert); background: var(--color-alert-bg); }
.callout-danger    { border-color: var(--color-stop);  background: var(--color-stop-bg); }
.callout-success   { border-color: var(--color-go);    background: var(--color-go-bg); }
.callout-important { border-color: var(--accent); border-width: 1px 1px 1px 5px; border-style: solid; }
.callout-note      { border-color: var(--muted); font-style: italic; }
.callout-info    > strong:first-child { color: var(--color-info); }
.callout-warning > strong:first-child { color: var(--color-alert); }
.callout-danger  > strong:first-child { color: var(--color-stop); }
.callout-success > strong:first-child { color: var(--color-go); }

blockquote.scripture {
    margin: 1.5rem 0; padding: 1rem 1.25rem;
    border-left: 5px solid var(--primary);
    background: linear-gradient(135deg, var(--tertiary), transparent);
    border-radius: var(--radius-sm);
    font-family: var(--font-title); font-size: 1.05rem;
}
blockquote.scripture p { margin: 0 0 0.5rem; text-align: left; hyphens: none; }
blockquote.scripture footer { text-align: right; font-family: var(--font-body); font-weight: 700; color: var(--primary); }


/* ═══════════════════════════════════════════════════════════════════
   §10  STATS, STEPS, COMPARE CARDS, SUMMARY
   ═══════════════════════════════════════════════════════════════════ */
.stat-grid { display: grid; grid-template-columns: 1fr; gap: 0.75rem; margin: 1.25rem 0; }
.stat {
    background: var(--tertiary); border-radius: var(--radius-sm); padding: 1rem;
    text-align: center; border-top: 4px solid var(--primary); box-shadow: var(--shadow-xs);
}
.stat-number { display: block; font-family: var(--font-title); font-size: 2rem; line-height: 1.1; color: var(--primary); text-shadow: var(--text-shadow); }
.stat-label  { display: block; font-size: 0.85rem; color: var(--muted); margin-top: 0.3rem; letter-spacing: 0.02em; }
.stat-go   { border-top-color: var(--color-go); }    .stat-go   .stat-number { color: var(--color-go); }
.stat-warn { border-top-color: var(--color-alert); } .stat-warn .stat-number { color: var(--color-alert); }
.stat-stop { border-top-color: var(--color-stop); }  .stat-stop .stat-number { color: var(--color-stop); }

ol.steps { list-style: none; padding: 0; margin: 1.25rem 0; counter-reset: step; display: grid; gap: 0.5rem; }
ol.steps li {
    counter-increment: step; display: grid; grid-template-columns: 2.2rem 1fr; gap: 0.5rem 0.75rem; align-items: center;
    background: var(--tertiary); border-radius: var(--radius-sm); padding: 0.75rem 1rem; margin: 0; box-shadow: var(--shadow-xs);
}
ol.steps li::before {
    content: counter(step); grid-row: 1 / span 2;
    width: 2.2rem; height: 2.2rem; border-radius: 50%;
    background: var(--primary); color: var(--on-primary);
    display: inline-flex; align-items: center; justify-content: center; font-weight: 700;
}
ol.steps li span   { color: var(--muted); font-size: 0.9rem; }
ol.steps li strong { font-family: var(--font-title); font-size: 1.15rem; }

.compare-grid { display: grid; grid-template-columns: 1fr; gap: 0.75rem; margin: 1.25rem 0; }
.compare-card { background: var(--tertiary); border-radius: var(--radius-sm); padding: 1rem; border: 2px solid transparent; box-shadow: var(--shadow-xs); }
.compare-card h3 { margin: 0 0 0.5rem; font-size: 1.05rem; }
.compare-card-go { border-color: var(--color-go); }
.compare-card-go h3 { color: var(--color-go); }
.big-math { font-size: 1.4rem; margin: 0; text-align: center; font-family: var(--font-title); }

.summary-grid { display: grid; grid-template-columns: 1fr; gap: 0.75rem; margin: 1.25rem 0; }
.summary-card {
    background: var(--tertiary); border-radius: var(--radius); padding: 1.25rem 1rem; text-align: center;
    box-shadow: var(--shadow-sm); border-top: 4px solid var(--accent);
    transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.summary-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.summary-card h3 { margin: 0.5rem 0; }
.summary-card p  { margin: 0; font-size: 0.95rem; text-align: center; }
.summary-icon { font-size: 2rem; line-height: 1; display: block; }

.list-links { padding-left: 1.25rem; }
.list-links li { margin-bottom: 0.5rem; }


/* ═══════════════════════════════════════════════════════════════════
   §11  TABLES, FORMULAS, HEBREW / GREEK
   ═══════════════════════════════════════════════════════════════════ */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 1.25rem 0; border-radius: var(--radius-sm); }
table.table-clean { width: 100%; border-collapse: collapse; background: var(--tertiary); border-radius: var(--radius-sm); overflow: hidden; }
.table-clean th, .table-clean td { padding: 0.65rem 0.8rem; text-align: left; border-bottom: 1px solid var(--line-soft); }
.table-clean th { font-family: var(--font-title); color: var(--primary); font-weight: 400; }
.table-clean tbody tr:last-child td { border-bottom: 0; }
.table-clean tr:hover td { background: var(--hover); }
.table-compact th, .table-compact td { padding: 0.4rem 0.6rem; font-size: 0.92rem; }
tr.row-go   td:first-child { border-left: 5px solid var(--color-go); }
tr.row-warn td:first-child { border-left: 5px solid var(--color-alert); }
tr.row-stop td:first-child { border-left: 5px solid var(--color-stop); }

.formula {
    margin: 1.25rem 0; padding: 1rem; text-align: center;
    background: var(--tertiary); border-radius: var(--radius-sm);
    font-family: var(--font-title); font-size: 1.1rem; box-shadow: var(--shadow-xs);
}
.formula-tall { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }
.frac { display: inline-flex; flex-direction: column; align-items: center; }
.frac .num { padding: 0 0.5rem 0.2rem; border-bottom: 2px solid var(--primary); }
.frac .den { padding: 0.2rem 0.5rem 0; }
.formula .equals { font-size: 1.3rem; color: var(--primary); }

.hebrew        { font-family: var(--font-hebrew); font-size: 1.35em; direction: rtl; unicode-bidi: isolate; }
.hebrew-verse  { font-size: 1.5rem; text-align: right; line-height: 2; }
.greek-verse   { font-family: var(--font-greek); font-size: 1.15rem; font-style: normal; }
td.hebrew      { font-size: 1.5rem; text-align: center; }


/* ═══════════════════════════════════════════════════════════════════
   §12  TOOLS (calculators) & FORMS
   ═══════════════════════════════════════════════════════════════════ */
.tool {
    background: var(--tertiary); border-radius: var(--radius); padding: 1rem;
    margin: 1.25rem 0; box-shadow: var(--shadow-sm);
    border: 1px solid var(--line-soft);
}
.tool label { display: block; font-weight: 700; margin: 0.5rem 0 0.3rem; }
.tool .inline-label { display: inline; margin: 0; }
.tool-row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.tool-row-wrap .spacer { flex: 1 1 100%; height: 0; }
.hint { font-size: 0.9rem; color: var(--muted); margin: 0.5rem 0; }

input[type="number"], input[type="text"], select, textarea {
    font: 1rem var(--font-body); color: var(--text); background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm); padding: 0.6rem 0.8rem; min-height: var(--tap);
    width: 100%; max-width: 100%; transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
input[type="number"] { max-width: 180px; }
select { max-width: 100%; width: auto; flex: 1 1 200px; }
textarea { min-height: 96px; resize: vertical; font-size: 1.2rem; line-height: 1.8; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); }
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--color-stop); }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.4em;
    min-height: var(--tap); padding: 0 1.25rem;
    font: 700 1rem var(--font-body); border-radius: var(--radius-pill);
    border: 2px solid transparent; cursor: pointer; user-select: none; text-decoration: none;
    transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.btn:hover  { transform: translateY(-1px); box-shadow: var(--shadow-md); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.btn-outline { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: var(--on-primary); }
.btn-go   { background: var(--color-go);   color: #fff; border-color: var(--color-go); }
.btn-stop { background: var(--color-stop); color: #fff; border-color: var(--color-stop); }

.chart-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 0.4rem; margin: 0.75rem 0;
}
.chart-cell {
    background: var(--bg); border-radius: var(--radius-xs); padding: 0.4rem 0.2rem; text-align: center;
    border: 1px solid var(--line-soft);
}
.chart-cell .ch { display: block; font-size: 1.4rem; line-height: 1.2; }
.chart-cell .ch.hebrew { font-family: var(--font-hebrew); }
.chart-cell .ch.greek  { font-family: var(--font-greek); }
.chart-cell .val { display: block; font-size: 0.8rem; color: var(--primary); font-weight: 700; }
.chart-title { grid-column: 1 / -1; font-family: var(--font-title); color: var(--primary); margin: 0.5rem 0 0; }

.stat-grid-4 .stat-number { font-size: 1.5rem; }
#gem-result { font-size: 1.35rem; white-space: nowrap; }
.pair { display: inline-block; direction: ltr; unicode-bidi: isolate; margin-right: 0.5em; }
.pair .hebrew, .pair .greek-verse { font-size: 1.1em; }
.kv { display: grid; grid-template-columns: 1fr; gap: 0.25rem 1rem; margin: 0.5rem 0; }
.kv dt { font-weight: 700; color: var(--primary); }
.kv dd { margin: 0 0 0.5rem; }

details { margin: 1rem 0; padding: 0.6rem 1rem; background: var(--bg); border-radius: var(--radius-sm); border: 1px solid var(--line-soft); }
summary { cursor: pointer; font-weight: 700; color: var(--primary); min-height: var(--tap); display: flex; align-items: center; }


/* ═══════════════════════════════════════════════════════════════════
   §13  PAGE COMPONENTS — progress bar, back-to-top, toast
   ═══════════════════════════════════════════════════════════════════ */
#scroll-progress {
    position: fixed; top: 0; left: 0; z-index: 99998; height: 3px; width: 0%;
    background: var(--primary); box-shadow: 0 0 8px var(--primary);
    border-radius: 0 2px 2px 0; pointer-events: none; transition: width 0.1s linear;
}

#btn-back-to-top {
    position: fixed; right: 1rem; bottom: 1rem; z-index: 500;
    width: var(--tap); height: var(--tap); border-radius: 50%; border: 0;
    background: var(--primary); color: var(--on-primary); font: 700 1.3rem var(--font-body);
    box-shadow: var(--shadow-md); cursor: pointer;
    opacity: 0; visibility: hidden; transform: translateY(16px);
    transition: opacity var(--t-med) var(--ease), transform var(--t-med) var(--ease), visibility var(--t-med);
}
#btn-back-to-top.visible { opacity: 1; visibility: visible; transform: none; }
#btn-back-to-top:hover { background: var(--accent); }

#theme-toast {
    position: fixed; top: 1.25rem; left: 50%; z-index: 10000;
    transform: translateX(-50%) translateY(-16px);
    background: var(--secondary); color: var(--text);
    border: 1px solid var(--primary); border-radius: var(--radius-pill);
    padding: 0.6rem 1.4rem; font-weight: 700; box-shadow: var(--shadow-lg);
    opacity: 0; visibility: hidden; pointer-events: none; white-space: nowrap;
    transition: opacity var(--t-med) var(--ease), transform var(--t-med) var(--ease), visibility var(--t-med);
}
#theme-toast.show { opacity: 1; visibility: visible; transform: translateX(-50%); }


/* ═══════════════════════════════════════════════════════════════════
   §14  LIGHTBOX — full image, dark (not blurred) backdrop, caption,
        no arrows, no filenames. Close: ×, Esc, outside click.
   ═══════════════════════════════════════════════════════════════════ */
#lightbox-overlay {
    position: fixed; inset: 0; z-index: 20000;
    background: rgba(4, 6, 14, 0.92);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 1rem; cursor: zoom-out;
    opacity: 0; visibility: hidden;
    transition: opacity var(--t-med) var(--ease), visibility var(--t-med);
}
#lightbox-overlay.open { opacity: 1; visibility: visible; }
#lightbox-overlay img {
    max-width: 96vw; max-height: 78vh; width: auto; height: auto; object-fit: contain;
    border-radius: var(--radius); box-shadow: 0 20px 80px rgba(0, 0, 0, 0.8);
    cursor: default; background: #fff;
    transform: scale(0.96); transition: transform var(--t-med) var(--ease);
}
#lightbox-overlay.open img { transform: none; }
#lightbox-caption {
    margin-top: 0.9rem; max-width: 90vw; text-align: center; cursor: default;
    color: #f4f4f4; font: 1rem var(--font-body); line-height: 1.5;
    text-shadow: 0 1px 3px rgba(0,0,0,0.9);
    background: rgba(255,255,255,0.08); padding: 0.5rem 1rem; border-radius: var(--radius-sm);
}
#lightbox-caption:empty { display: none; }
#lightbox-close {
    position: fixed; top: 0.6rem; right: 0.6rem; z-index: 20001;
    width: var(--tap); height: var(--tap); border-radius: 50%; border: 1px solid rgba(255,255,255,0.3);
    background: rgba(0,0,0,0.5); color: #fff; font: 300 1.8rem/1 var(--font-body); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
#lightbox-close:hover { background: var(--color-stop); transform: scale(1.08); }


/* ═══════════════════════════════════════════════════════════════════
   §15  SPLASH OVERLAY — 2 s title card, click / Esc dismisses
   ═══════════════════════════════════════════════════════════════════ */
#flash-overlay {
    position: fixed; inset: 0; z-index: 30000; background: #000;
    display: flex; align-items: center; justify-content: center; cursor: pointer;
    opacity: 0; visibility: hidden;
    animation: flashFade var(--flash-duration, 2s) var(--ease) forwards;
}
#flash-overlay img {
    max-width: 92%; max-height: 90%; object-fit: contain; border-radius: var(--radius);
    box-shadow: 0 0 40px rgba(226, 184, 87, 0.35), 0 20px 80px rgba(0,0,0,0.8);
    animation: splashGlow 1.6s ease-in-out infinite alternate;
}
@keyframes flashFade { 0% { opacity: 0; visibility: visible; } 12% { opacity: 1; } 80% { opacity: 1; } 100% { opacity: 0; visibility: hidden; } }
@keyframes splashGlow { from { box-shadow: 0 0 30px rgba(226,184,87,0.25); } to { box-shadow: 0 0 70px rgba(226,184,87,0.6), 0 0 120px rgba(217,141,58,0.4); } }


/* ═══════════════════════════════════════════════════════════════════
   §16  BIBLE REFERENCES (markup from Universal_Bible_Popup.py)
        The popup itself is always a white card with dark ink —
        a deliberate contrast against these dark themes.
   ═══════════════════════════════════════════════════════════════════ */
a.bible-ref {
    color: var(--link); font-weight: 700; text-decoration: none; cursor: pointer;
    border-bottom: 2px dotted var(--accent); padding-bottom: 1px;
    transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
a.bible-ref:hover { color: var(--accent); border-bottom-style: solid; text-decoration: none; }
blockquote.scripture footer a.bible-ref { color: var(--primary); }


/* ═══════════════════════════════════════════════════════════════════
   §17  RESPONSIVE — progressive enhancement from phones upward
   ═══════════════════════════════════════════════════════════════════ */
@media (min-width: 600px) {
    :root { --font-base: 18px; }
    .page-header { padding: 0.75rem 1rem 0; }
    .banner-image { border-radius: var(--radius); }
    main.content-body { padding: 2rem 2rem 2.5rem; margin: 1rem 1rem 3rem; border-radius: var(--radius); width: calc(100% - 2rem); }
    p { text-align: justify; }
    .control-bar { margin-top: 0.5rem; border-radius: var(--radius-pill); width: auto; padding: 0.5rem 0.75rem; }
    .stat-grid { grid-template-columns: repeat(3, 1fr); }
    .stat-grid-4 { grid-template-columns: repeat(2, 1fr); }
    .compare-grid, .img-row, .diagram-row { grid-template-columns: 1fr 1fr; }
    .summary-grid { grid-template-columns: repeat(3, 1fr); }
    .kv { grid-template-columns: max-content 1fr; }
    h1 { font-size: 2.4rem; } h2 { font-size: 1.85rem; } h3 { font-size: 1.35rem; }
    ol.steps li { grid-template-columns: 2.2rem 1fr auto; }
    ol.steps li::before { grid-row: auto; }
    ol.steps li strong { text-align: right; }
    #btn-back-to-top { right: 1.5rem; bottom: 1.5rem; width: 52px; height: 52px; }
    .tool-row-wrap .spacer { flex: 0 0 1rem; }
}

@media (min-width: 900px) {
    .stat-grid-4 { grid-template-columns: repeat(4, 1fr); }
    main.content-body { padding: 2.5rem 3rem 3rem; }
    #page-description { font-size: 1.1rem; }
}

@media (hover: none) {
    .summary-card:hover, .control-btn:hover { transform: none; }
}


/* ═══════════════════════════════════════════════════════════════════
   §18  PRINT
   ═══════════════════════════════════════════════════════════════════ */
@media print {
    #scroll-progress, #flash-overlay, #theme-toast, #btn-back-to-top, .skip-link,
    .control-bar, #lightbox-overlay, .tool, audio { display: none !important; }
    body { background: #fff; color: #000; }
    main.content-body { box-shadow: none; background: transparent; margin: 0; padding: 0; max-width: 100%; }
    h1, h2, h3 { text-shadow: none; color: #000; }
    a { color: inherit; text-decoration: underline; }
    main a[target="_blank"]::after { content: ""; }
    h2, h3 { page-break-after: avoid; }
    figure, blockquote, .callout, table { page-break-inside: avoid; }
}
