/* =============================================================================
   TACHYON STYLESHEET
   =============================================================================
   Table of Contents:
   1. CSS Variables (Light Theme Default)
   2. Dark Theme Variables
   3. Typography & Base Styles
   4. Content & Thematic Styles
   5. Components (TOC, Menu, Buttons)
   6. Focus Mode & Sightline
   7. Battle Stats
   8. Responsive Adjustments
   9. Utilities
   ============================================================================= */

/* -----------------------------------------------------------------------------
   1. CSS VARIABLES (Light Theme Default)
   ----------------------------------------------------------------------------- */
:root {
  /* -- Typography -- */
  --font-serif: 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
  --font-display: "Source Serif 4 Display", serif;
  --font-mono: Consolas, Menlo, Monaco, "DejaVu Sans Mono", "Lucida Console", monospace;

  /* -- Core Colors -- */
  --c-bg: #fbf9f3;
  --c-text: #2c2a2e;
  --c-text-soft: #6d6a70;
  --c-link: #3a5c8d;
  --c-link-hover: #1e3250;
  --c-border: #e0dce5;
  --c-border-strong: #bfbac9;
  --c-bg-offset: #f2f0f5;

  /* -- Thematic Colors -- */
  --c-king: #942939;
  --c-wisdom: #2b6a73;
  --c-logoscript-1: var(--c-king);
  --c-logoscript-2: var(--c-wisdom);

  /* -- UI Colors -- */
  --c-button-bg: var(--c-link);
  --c-button-text: var(--c-bg);
  --c-menu-border: var(--c-bg);
  --c-menu-outline: var(--c-text);
  --c-path-delight: var(--c-wisdom);
  --c-path-plague: var(--c-king);
  --c-path-default: var(--c-border-strong);
  --c-grid-line: rgba(0, 0, 0, 0.15);

  /* -- Code Block Colors -- */
  --c-code-bg: #121212;
  --c-code-text: #e6e6e6;
  --c-code-border: #444;
  --c-code-keyword: #ff79c6;
  --c-code-function: #50fa7b;
  --c-code-variable: #8be9fd;
  --c-code-string: #f1fa8c;
  --c-code-number: #bd93f9;
  --c-code-comment: #7a7a7a;
  --c-code-symbol: #ffb86c;
  --c-code-blue: #6aa9ff;
  --c-code-red: #ff5555;

  /* -- Battle Stats (light) -- */
  --c-stats-bg: linear-gradient(#f0f2f6, #e9ebf2);
  --c-stats-border: #1b1b1b;
  --c-stats-shadow: inset 0 0 0 2px rgba(0,0,0,.06), 0 6px 16px rgba(0,0,0,.12);
  --c-stats-text: #111;
  --c-stats-divider: rgba(0,0,0,.12);

  /* -- Sightline -- */
  --c-sightline: rgba(0,0,0,.06);
}

/* -----------------------------------------------------------------------------
   2. DARK THEME VARIABLES
   ----------------------------------------------------------------------------- */

/* Shared dark theme values - applied via system preference OR explicit toggle */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --c-bg: #191c23;
    --c-text: #d1d1d6;
    --c-text-soft: #888ca0;
    --c-link: #82aaff;
    --c-link-hover: #b3c5ff;
    --c-border: #333644;
    --c-border-strong: #4d5163;
    --c-bg-offset: #222630;
    --c-king: #ff7b8c;
    --c-wisdom: #63d9e8;
    --c-logoscript-1: var(--c-king);
    --c-logoscript-2: var(--c-wisdom);
    --c-button-bg: var(--c-bg-offset);
    --c-button-text: var(--c-text);
    --c-menu-border: #fbf9f3;
    --c-code-bg: #181818;
    --c-code-text: #d6d6d6;
    --c-code-string: #f7d58b;
    --c-code-comment: #888888;
    --c-code-symbol: #ffa07a;
    --c-path-delight: #58a6ff;
    --c-path-plague: #ff6666;
    --c-grid-line: rgba(255, 255, 255, 0.15);
    --c-stats-bg: linear-gradient(#0c0f18, #0b0e16);
    --c-stats-border: #fbf9f3;
    --c-stats-shadow: inset 0 0 0 2px rgba(255,255,255,.08), 0 6px 18px rgba(0,0,0,.3);
    --c-stats-text: #eaeaf0;
    --c-stats-divider: rgba(255,255,255,.12);
    --c-sightline: rgba(255,255,255,.14);
  }
}

/* Explicit dark mode toggle (same values, no duplication via CSS custom properties) */
:root[data-theme="dark"] {
  --c-bg: #191c23;
  --c-text: #d1d1d6;
  --c-text-soft: #888ca0;
  --c-link: #82aaff;
  --c-link-hover: #b3c5ff;
  --c-border: #333644;
  --c-border-strong: #4d5163;
  --c-bg-offset: #222630;
  --c-king: #ff7b8c;
  --c-wisdom: #63d9e8;
  --c-logoscript-1: var(--c-king);
  --c-logoscript-2: var(--c-wisdom);
  --c-button-bg: var(--c-bg-offset);
  --c-button-text: var(--c-text);
  --c-menu-border: #fbf9f3;
  --c-code-bg: #181818;
  --c-code-text: #d6d6d6;
  --c-code-string: #f7d58b;
  --c-code-comment: #888888;
  --c-code-symbol: #ffa07a;
  --c-path-delight: #58a6ff;
  --c-path-plague: #ff6666;
  --c-grid-line: rgba(255,255,255,.15);
  --c-stats-bg: linear-gradient(#0c0f18, #0b0e16);
  --c-stats-border: #fbf9f3;
  --c-stats-shadow: inset 0 0 0 2px rgba(255,255,255,.08), 0 6px 18px rgba(0,0,0,.3);
  --c-stats-text: #eaeaf0;
  --c-stats-divider: rgba(255,255,255,.12);
  --c-sightline: rgba(255,255,255,.14);
}

/* -----------------------------------------------------------------------------
   3. TYPOGRAPHY & BASE STYLES
   ----------------------------------------------------------------------------- */
@font-face {
  font-family: "Source Serif 4 Display";
  src: url("SourceSerif4Display-Light.woff2") format("woff2");
  font-weight: 300;
  font-style: normal;
}

body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-family: var(--font-serif);
  font-size: 11pt;
  line-height: 1.4;
  color: var(--c-text);
  background: var(--c-bg);
  margin: 0;
}

.container {
  max-width: 700px;
  width: 90%;
  margin: 0 auto;
  padding: 1rem 0;
}

p {
  text-align: justify;
  margin: 0 0 8.5pt 0;
}

h2, h3, h4 {
  font-size: 11pt;
  font-weight: bold;
  margin: 12pt 0 8.5pt 0;
}

h2 {
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 18pt;
  text-align: center;
}

h3 {
  font-style: italic;
  text-align: center;
}

h1 {
  font-family: var(--font-display);
  font-size: min(10vw, 5.2rem);
  font-weight: 300;
  text-transform: uppercase;
  letter-spacing: -0.02em;
  text-align: center;
  text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.25);
  margin: 0 auto;
  max-width: 90vw;
  display: block;
  overflow-wrap: break-word;
  white-space: normal;
}

a {
  color: var(--c-link);
  text-decoration: none;
  border-bottom: 1px dotted var(--c-link-hover);
}

a:hover, a:focus {
  color: var(--c-link-hover);
  border-bottom-style: solid;
}

blockquote {
  margin: 1em 0.5in;
  padding-left: 0.5em;
  border-left: 2px solid var(--c-border);
  font-style: italic;
  color: var(--c-text-soft);
}

/* Wide-margin blockquote for invective prayer - responsive */
blockquote.invective-prayer {
  margin: 1em 15em;
}

@media (max-width: 1200px) {
  blockquote.invective-prayer { margin: 1em 8em; }
}

@media (max-width: 900px) {
  blockquote.invective-prayer { margin: 1em 4em; }
}

@media (max-width: 600px) {
  blockquote.invective-prayer { margin: 1em 1em; }
}

ul {
  margin: 0 0 8.5pt 0.75in;
  padding: 0;
  list-style-position: outside;
}

ul li {
  padding-left: 0.25in;
  text-indent: -0.25in;
}

/* -----------------------------------------------------------------------------
   4. CONTENT & THEMATIC STYLES
   ----------------------------------------------------------------------------- */
.author { text-align: center; margin-bottom: 1em; }
.divine { font-variant: small-caps; font-weight: bold; }
.king { color: var(--c-king); }
.wisdom { color: var(--c-wisdom); }
.sibyl { font-size: 1.5rem; font-variant: small-caps; font-weight: normal; }

@keyframes shimmer-red-blue {
  0%, 100% { color: var(--c-logoscript-1); }
  50% { color: var(--c-logoscript-2); }
}

.logoscript {
  font-weight: bold;
  font-variant: small-caps;
  animation: shimmer-red-blue 6s infinite ease-in-out;
}

.subtitle {
  font-size: min(0.55rem, 2vw);
  font-weight: normal;
  text-transform: uppercase;
  text-align: center;
  white-space: normal;
  word-wrap: break-word;
  display: block;
  margin-top: 0.25em;
}

.scripture-subtitle {
  font-size: min(1.25rem, 4vw);
  font-weight: normal;
  line-height: 22pt;
  text-align: center;
  margin: 0.2em 0;
}

.ancient {
  font-size: min(10vw, 4.5rem);
  font-weight: bold;
  text-align: center;
  max-width: 85vw;
  line-height: 1.2;
  word-break: keep-all;
  white-space: normal;
  display: block;
  margin: 1em auto;
  text-transform: uppercase;
  letter-spacing: -0.02em;
}

/* Verse styling */
.verse { position: relative; }
.verse-num-primary { font-weight: bold; color: var(--c-text); margin-right: 6px; }
.verse-num-ref { font-style: italic; font-size: 0.85em; vertical-align: super; color: var(--c-text-soft); margin: 0 6px 0 2px; }
.verse-ref { font-variant: small-caps; font-weight: bold; color: var(--c-text-soft); margin: 0 2px 0 4px; }

/* Chapter/Subchapter */
.chapter, .subchapter { position: relative; }

/* Figures & Images */
figure { margin: 1.5em auto; text-align: center; }
picture { display: block; margin: auto; width: 50%; }
img { max-width: 100%; height: auto; }

figure figcaption {
  font-size: 8.5pt;
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  margin: 4px auto;
  max-width: 90%;
}

figure figcaption strong { font-weight: bold; font-style: italic; }

/* Tables */
.table-container { overflow-x: auto; margin: 1em auto; }

table {
  border-collapse: collapse;
  margin: 0 auto;
  width: 100%;
  max-width: 5.5in;
  border-bottom: 1px solid var(--c-border-strong);
}

table caption { font-size: 8.5pt; line-height: 14pt; margin-bottom: 4pt; text-align: center; }
table caption strong { font-weight: bold; font-style: italic; }
th, td { font-size: 8.5pt; padding: 4px; }
th { border-bottom: 1px solid var(--c-border-strong); }
table tbody tr:last-child td { border-bottom: 1px solid var(--c-border-strong); }

/* Footer */
footer { text-align: center; padding: 1.25rem 0; }
footer p { text-align: center; padding: 1.25rem 0; }
footer nav a { margin: 0 0.25rem; text-decoration: none; }
footer picture { display: block; margin: 0.75rem auto 0; }

/* Text alignment utilities for content */
.text-center,
.text-center h2,
.text-center h3,
.text-center p,
.text-center blockquote { text-align: center; }

/* -----------------------------------------------------------------------------
   5. COMPONENTS (TOC, Menu, Buttons)
   ----------------------------------------------------------------------------- */

/* Table of Contents */
#table-of-contents {
  max-width: 650px;
  margin: 2rem auto;
  padding: 1rem;
  border: 1px solid var(--c-border);
  background: var(--c-bg-offset);
  border-radius: 8px;
}

#table-of-contents ul { list-style: none; padding: 0; margin: 0; }
#table-of-contents > ul > li { font-size: 12pt; font-weight: bold; margin-bottom: 0.75rem; }
#table-of-contents ul ul { margin-top: 0.25rem; padding-left: 1.25rem; }
#table-of-contents ul ul li { font-size: 11pt; font-weight: normal; margin-bottom: 0.5rem; }
#table-of-contents a { color: var(--c-link); border-bottom-color: var(--c-link-hover); }
#table-of-contents a:hover { color: var(--c-link-hover); border-bottom-style: solid; }

/* Floating Menu & Toggle */
#floating-menu,
#menu-toggle {
  background: var(--c-button-bg);
  color: var(--c-button-text);
  border: 2px solid var(--c-menu-border);
  font-family: inherit;
  font-size: 12pt;
}

#floating-menu {
  position: fixed;
  bottom: 70px;
  right: 15px;
  width: 200px;
  border-radius: 6px;
  box-shadow: 0 0 0 2px var(--c-menu-outline), 2px 2px 8px rgba(0, 0, 0, 0.3);
  z-index: 999;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s ease-out, transform 0.2s ease-out;
  pointer-events: none;
}

#floating-menu:not(.hidden) {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

#floating-menu ul { list-style: none; margin: 0; padding: 0.5rem; }
#floating-menu li { margin: 0.25rem 0; }

#floating-menu button,
#floating-menu a {
  display: block;
  width: 100%;
  padding: 6px 12px;
  color: inherit;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  text-decoration: none;
}

#floating-menu button:hover,
#floating-menu a:hover { background-color: rgba(255, 255, 255, 0.2); }

#menu-toggle {
  position: fixed;
  bottom: 15px;
  right: 15px;
  padding: 10px 15px;
  border-radius: 5px;
  box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
  pointer-events: none;
}

/* TTS Button */
.verse-tts-button {
  background: none;
  border: 1px solid var(--c-text-soft);
  border-radius: 3px;
  padding: 2px 6px;
  margin-right: 0.5em;
  font-size: 0.85em;
  font-variant: small-caps;
  color: var(--c-wisdom);
  cursor: pointer;
}

/* -----------------------------------------------------------------------------
   6. FOCUS MODE & SIGHTLINE
   ----------------------------------------------------------------------------- */
#sightline {
  position: fixed;
  left: 0;
  right: 0;
  height: 4vh;
  top: 40vh;
  pointer-events: none;
  background: linear-gradient(to bottom, transparent, var(--c-sightline), transparent);
  opacity: 0;
  transition: opacity .15s ease;
  z-index: 9999;
}

/* Highlight for the verse currently crossing the band */
.verse.current {
  outline: 2px solid currentColor;
  outline-offset: 6px;
}

/* When focus mode is on, slightly dim surroundings */
.focus-mode .verse { transition: opacity .15s ease; }
.focus-mode .verse:not(.current) { opacity: .88; }

/* When refs are OFF, hide visual refs for sighted users */
.refs-off .verse-ref,
.refs-off .verse-num-ref { display: none !important; }

/* -----------------------------------------------------------------------------
   7. BATTLE STATS
   ----------------------------------------------------------------------------- */
#floating-menu #battle-stats.bm {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .5rem;
  margin: .5rem .5rem .6rem;
  padding: .5rem .6rem;
  border: 2px solid var(--c-stats-border);
  background: var(--c-stats-bg);
  box-shadow: var(--c-stats-shadow);
  color: var(--c-stats-text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

#battle-stats .bm-col {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
}

#battle-stats .bm-label {
  font-size: .68rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  opacity: .75;
  margin-bottom: .15rem;
}

#battle-stats .bm-value {
  font-size: 1.05rem;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#battle-stats .bm-split { opacity: .5; padding: 0 .25ch; }

/* Subtle divider between the two columns */
#battle-stats .bm-col:first-child { position: relative; }
#battle-stats .bm-col:first-child::after {
  content: "";
  position: absolute;
  right: -.25rem;
  top: .1rem;
  bottom: .1rem;
  width: 1px;
  background: var(--c-stats-divider);
}

/* -----------------------------------------------------------------------------
   8. RESPONSIVE ADJUSTMENTS
   ----------------------------------------------------------------------------- */
@media (max-width: 700px) {
  #sightline { top: 35vh; }
}

@media (max-width: 600px) {
  body { font-size: 12pt; }
  .container { width: 95%; }
  ul, ol { margin-left: 0.5in; }

  /* Make tables more compact on small screens */
  th, td {
    font-size: 7.5pt;
    padding: 3px;
  }
  table caption { font-size: 8pt; }
}

/* -----------------------------------------------------------------------------
   9. UTILITIES
   ----------------------------------------------------------------------------- */
.readingTime { text-align: center; }

.downloads {
  justify-content: center;
  margin: 1rem 0 2rem;
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
}

.downloads .btn {
  padding: .5rem .8rem;
  border: 1px solid currentColor;
  border-radius: .5rem;
  text-decoration: none;
}

/* Source list (verse counts) */
.source-list {
  list-style: none;
  margin: 0 auto 1em;
  padding: 0;
  text-align: center;
}

.source-list li {
  text-indent: 0;
  padding-left: 0;
}

/* PWA Install Banner */
.pwa-banner {
  display: flex;
  gap: .6rem;
  align-items: center;
  justify-content: space-between;
  padding: .6rem .8rem;
  border: 1px solid currentColor;
  border-radius: .6rem;
  margin: 1rem 0;
  font-size: .95rem;
  flex-wrap: wrap;
}

.pwa-banner .btn {
  padding: .4rem .7rem;
  border: 1px solid currentColor;
  border-radius: .4rem;
  background: none;
}

.pwa-banner .pwa-close {
  border: 0;
  background: transparent;
  font: inherit;
  line-height: 1;
  opacity: .7;
  cursor: pointer;
}

.pwa-banner .pwa-close:hover {
  opacity: 1;
}

/* Language nav in footer - add to style.css */
.lang-nav {
  margin: 0.75rem 0;
  font-size: 0.9em;
  text-align: center;
}

.lang-nav a {
  border-bottom: none;
}

.lang-nav a:hover {
  border-bottom: 1px solid currentColor;
}
