/* ================================================
   GLOBAL CSS - TTPOG Astro
   ================================================
   Clean, organized global styles with CSS variable
   support for user preferences and theming.
   ================================================ */

/* ================================================
   CSS VARIABLES & THEME DEFINITIONS
   ================================================ */

:root {
  /* =========================
     TYPOGRAPHY VARIABLES
     ========================= */
  --user-font: Georgia, 'Times New Roman', serif; /* Default font - overridden by font selector */
  --ui-font: Arial, sans-serif; /* UI elements font */

  /* Font-specific variables for font selector */
  --font-merriweather: 'Merriweather', serif;
  --font-source-sans: 'Source Sans 3', sans-serif;
  --font-opendyslexic: 'OpenDyslexic', sans-serif;
  --font-crimson: 'Crimson Pro', serif;
  --font-atkinson: 'Atkinson Hyperlegible', sans-serif;
  --font-work-sans: 'Work Sans', sans-serif;

  /* =========================
     COLOR VARIABLES - DARK THEME (DEFAULT)
     ========================= */
  --color-bg: #000000;
  --color-text: #ffffff;
  --color-text-secondary: #aaaaaa;
  --color-text-muted: rgba(255, 255, 255, 0.8);
  --color-border: #444444;
  --color-button-bg: #222222;
  --color-button-text: #ffffff;
  --color-button-hover: #333333;
  --color-button-active-bg: #ffffff;
  --color-button-active-text: #000000;

  /* =========================
     LAYOUT & SIZING VARIABLES
     ========================= */
  --content-max-width: 700px;
  --content-padding: 40px 20px;
  --base-font-size: 1.1rem;
  --base-line-height: 1.7;
  --header-font-size: 1.6rem;
  --ui-font-size: 1rem;

  /* =========================
     TRANSITION VARIABLES
     ========================= */
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s ease;
  --transition-slow: 0.5s ease;
}

/* ================================================
   LIGHT THEME OVERRIDES
   ================================================ */

html.light {
  --color-bg: #ffffff;
  --color-text: #000000;
  --color-text-secondary: #333333;
  --color-text-muted: rgba(0, 0, 0, 0.8);
  --color-border: #888888;
  --color-button-bg: #ffffff;
  --color-button-text: #000000;
  --color-button-hover: #f5f5f5;
  --color-button-active-bg: #000000;
  --color-button-active-text: #ffffff;
  --color-toc-bg: #f9f9f9;
  --color-toc-text: #000000;
  --color-chapter-bg: #ffffff;
  --color-chapter-text: #000000;
}

/* ================================================
   GLOBAL RESET & BASE STYLES
   ================================================ */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--user-font) !important; /* !important to override any conflicting styles */
  height: 100%;
  scroll-behavior: auto;
  overflow-x: hidden;
  transition:
    background-color var(--transition-normal),
    color var(--transition-normal);
}

/* ================================================
   LAYOUT CONTAINERS
   ================================================ */

/* Main scroll container for page sections */
#scroll-container {
  overflow-y: auto;
  height: 100vh;
  scroll-snap-type: y proximity;
  -webkit-overflow-scrolling: touch;
}

/* Snapping enabled state */
#scroll-container.snapping {
  scroll-snap-type: y mandatory;
}

/* Base section styling */
section {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 60px 20px;
  min-height: 100vh;
}

/* Preference pane specific override */
section.preference-pane {
  padding: 20px;
  min-height: auto;
  align-items: stretch;
  justify-content: flex-start;
}

/* Apply snap to key sections when snapping enabled */
#prefs {
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

#cover {
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

#toc {
  scroll-snap-align: start;
}

.gwt-names {
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

/* Reader content should not snap */
.chapter-content {
  scroll-snap-align: none;
}

/* ================================================
   BOOK COVER STYLES
   ================================================ */

.book-cover {
  height: 100vh;
  background-color: var(--color-bg);
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.book-cover img {
  max-width: 100%;
  max-height: 100%;
  object-fit: cover;
  display: block;
}

.gwt-names {
  height: 100vh;
  background-color: var(--color-bg);
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.gwt-names img {
  max-width: 100%;
  max-height: 100%;
  object-fit: cover;
  display: block;
}

.gwt-link {
  position: absolute;
  inset: 0;
  display: block;
}

/* ================================================
   CONTENT AREAS
   ================================================ */

/* Table of Contents */
.toc-panel {
  background-color: var(--color-bg);
  max-width: var(--content-max-width);
  width: 100%;
  margin: 0 auto;
  font-size: var(--base-font-size);
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  text-align: left;
  font-family: var(--user-font);
  transition: background-color var(--transition-normal);
}

.toc-panel h1 {
  font-weight: bold;
  text-align: center;
  margin-bottom: 2rem;
  color: var(--color-text);
  font-family: var(--user-font);
}

.toc-entry {
  margin: 0.5rem 0;
}

.toc-entry a {
  color: var(--color-text);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.toc-entry a:hover {
  text-decoration: underline;
  
}

/* Chapter Content */
.chapter-content {
  background-color: var(--color-bg);
  max-width: var(--content-max-width);
  font-size: var(--base-font-size);
  line-height: var(--base-line-height);
  text-align: left;
  margin: 0 auto;
  padding: var(--content-padding);
  font-family: var(--user-font);
  transition: background-color var(--transition-normal);
}

.chapter-content h1 {
  font-size: 1.5em;
  font-weight: bold;
  text-align: center;
  margin-bottom: 2rem;
  color: var(--color-text);
}

.chapter-content p {
  margin-bottom: 1.5rem;
  color: var(--color-text);
}

/* First paragraph after h1 should not be indented */
.chapter-content h1 + p {
  text-indent: 0;
}

/* Poetry sections */
.chapter-content p.verse {
  text-align: center;
  text-indent: 0;
  line-height: 2;
  margin: 2rem auto;
  font-style: italic;
}

/* Prayer section */
.chapter-content .prayer {
  text-align: center;
  font-style: italic;
  max-width: 90%;
  margin: 0.75rem auto;
  text-indent: 0;
}

/* First prayer paragraph should have more space above */
.chapter-content .divider + .prayer {
  margin-top: 2rem;
}

/* Last prayer paragraph should have more space below */
.chapter-content .prayer:last-of-type {
  margin-bottom: 2rem;
}

/* Decorative divider */
.chapter-content .divider {
  text-align: center;
  margin: 2rem auto;
  color: var(--color-text-muted);
  font-size: 1.5rem;
}

/* Scene transition */
.chapter-content .scene-break {
  text-align: center;
  margin: 2rem auto;
  color: var(--color-text-muted);
  font-size: 0.8rem;
  letter-spacing: 0.5em;
}

/* ================================================
   CHAPTER NAVIGATION STYLES
   ================================================ */

section.chapter-content .chapter-navigation {
  background: none !important;
  color: var(--color-text-muted) !important;
  border: none !important;
  border-radius: 0 !important;
  padding: 0.5rem 0 !important;
  width: auto !important;
  max-width: 300px !important;
  font-size: 1.15rem !important;
  font-weight: 600 !important;
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  gap: 0.5rem !important;
  margin: 3rem auto 2rem !important;
  font-family: var(--user-font) !important;
}

section.chapter-content .chapter-navigation a,
section.chapter-content .chapter-navigation a:link,
section.chapter-content .chapter-navigation a:visited {
  color: var(--color-text-muted) !important;
  text-decoration: none !important;
  transition: color var(--transition-fast);
}

section.chapter-content .chapter-navigation a:hover {
  color: var(--color-text) !important;
  text-decoration: underline !important;
}

section.chapter-content .chapter-navigation .nav-separator {
  margin: 0 1rem;
  color: var(--color-text-muted);
}

/* ================================================
   NAVIGATION & CONTROLS
   ================================================ */

/* Back Link */
.back-link {
  margin-top: 2rem;
  text-align: center;
}

.back-link a {
  color: var(--color-text-muted);
  text-decoration: none;
  font-family: var(--ui-font);
  transition: color var(--transition-fast);
}

.back-link a:hover {
  color: var(--color-text);
  text-decoration: underline;
}

/* Theme Toggle Buttons */
.theme-toggle {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
  justify-content: center;
}

.theme-btn {
  padding: 0.75rem 1.5rem;
  background: var(--color-button-bg);
  color: var(--color-button-text);
  border: none;
  border-radius: 0;
  cursor: pointer;
  font-size: var(--ui-font-size);
  font-family: var(--ui-font);
  transition: all var(--transition-normal);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.theme-btn:hover:not(.active) {
  background: var(--color-button-hover);
}

.theme-btn.active {
  background: var(--color-button-active-bg);
  color: var(--color-button-active-text);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

html.light .theme-btn.active {
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
}

/* ================================================
   TEXT SIZE SYSTEM
   ================================================ */

/* Text size control buttons */
.text-size-selector {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: center;
}

.size-option {
  cursor: pointer;
  padding: 0.3rem 0.5rem;
  border-radius: 4px;
  border: 1px solid transparent;
  font-weight: 700;
  background-color: transparent;
  color: var(--color-text-muted);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--ui-font);
  transition: all var(--transition-fast);
}

.size-option:hover {
  background-color: var(--color-button-hover);
}

.size-option.active {
  background-color: var(--color-button-active-bg);
  color: var(--color-button-active-text);
}

.size-option[data-size='small'] {
  font-size: 0.8rem;
}
.size-option[data-size='medium'] {
  font-size: 1rem;
}
.size-option[data-size='large'] {
  font-size: 1.2rem;
}
.size-option[data-size='extra-large'] {
  font-size: 1.4rem;
}

/* Text size application classes */
body.text-size-small .chapter-content,
body.text-size-small .toc-panel,
body.text-size-small .reader,
body.text-size-small .reader p,
body.text-size-small #lang-select,
body.text-size-small #font-select {
  font-size: 0.85rem !important;
  line-height: 1.5;
}

body.text-size-small .toc-panel h1 {
  font-size: 1.2rem;
}

body.text-size-medium .chapter-content,
body.text-size-medium .toc-panel,
body.text-size-medium .reader,
body.text-size-medium .reader p,
body.text-size-medium #lang-select,
body.text-size-medium #font-select {
  font-size: 1.1rem !important;
  line-height: 1.5;
}

body.text-size-medium .toc-panel h1 {
  font-size: 1.6rem;
}

body.text-size-large .chapter-content,
body.text-size-large .toc-panel,
body.text-size-large .reader,
body.text-size-large .reader p,
body.text-size-large #lang-select,
body.text-size-large #font-select {
  font-size: 1.3rem !important;
  line-height: 1.4;
}

body.text-size-large .toc-panel h1 {
  font-size: 1.8rem;
}

body.text-size-extra-large .chapter-content,
body.text-size-extra-large .toc-panel,
body.text-size-extra-large .reader,
body.text-size-extra-large .reader p,
body.text-size-extra-large #lang-select,
body.text-size-extra-large #font-select {
  font-size: 1.7rem !important;
  line-height: 1.4;
}

body.text-size-extra-large .toc-panel h1 {
  font-size: 2.2rem;
}

/* ================================================
   FONT FAMILIES FOR SELECTOR OPTIONS
   ================================================ */

/* Font family classes applied by font selector */

/* ================================================
   RESPONSIVE DESIGN
   ================================================ */

@media (max-width: 768px) {
  :root {
    --content-padding: 20px 15px;
    --base-font-size: 1rem;
    --header-font-size: 1.4rem;
  }

  section {
    padding: 40px 15px;
  }

  .theme-toggle {
    flex-direction: column;
    gap: 0.5rem;
  }

  .theme-btn {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
  }

  .theme-size-row {
    gap: 1rem;
  }
}

@media (max-width: 480px) {
  :root {
    --content-padding: 15px 10px;
    --base-font-size: 0.95rem;
    --header-font-size: 1.3rem;
  }

  .text-size-selector {
    flex-wrap: wrap;
  }

  .size-option {
    width: 28px;
    height: 28px;
  }
}

/* ================================================
   UTILITY CLASSES
   ================================================ */

/* Hide elements visually but keep them accessible to screen readers */
.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;
}

/* Center content with max width */
.container {
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: 0 20px;
}

/* Smooth transitions for interactive elements */
.transition {
  transition: all var(--transition-normal);
}

/* ================================================
   PRINT STYLES
   ================================================ */

@media print {
  html,
  body {
    background-color: #fff !important;
    color: #000 !important;
    font-size: 12pt;
    line-height: 1.4;
  }

  .preference-pane,
  .book-cover,
  .toc-panel,
  .theme-toggle-btn,
  .text-size-selector,
  script {
    display: none !important;
  }

  .chapter-content,
  .chapter-content h1,
  .chapter-content p {
    margin: 0 auto !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    min-height: auto !important;
    display: block !important;
  }

  .chapter-content .opening-verse {
    font-style: italic;
    margin-bottom: 1.5em;
    text-align: center;
  }

  .chapter-content .verse-citation {
    display: block;
    text-align: right;
    font-size: 0.9em;
    margin-top: 0.5em;
  }
  .chapter-content .verse-flourish {
    display: block;
    text-align: center;
    font-size: 1.5em;
    margin: 0.5em 0;
    color: #666;
  }

  .chapter-navigation {
    display: none !important;
  }
}

/* ================================================
   PREFERENCE PANE SYSTEM
   ================================================ */

/* Preference Pane Container */
.preference-pane {
  max-width: 400px;
  margin: 0 auto;
  background: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  padding: 2rem 0 !important;
  border: none;
  text-align: center;
}

.preference-pane h2 {
  font-size: 1.4rem;
  margin-bottom: 1.5rem;
  text-transform: uppercase;
  color: var(--color-text-muted);
  font-family: var(--ui-font);
}

/* Form Block Container */
.form-block {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
}

.form-block label {
  font-size: var(--ui-font-size);
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
  font-family: var(--ui-font);
}

/* Language and Font Selectors with Clean Styling */
#lang-select,
#font-select {
  background: none !important;
  color: var(--color-text-muted) !important;
  border: none !important;
  border-radius: 0 !important;
  padding: 0.5rem 0 !important;
  cursor: pointer !important;
  width: 200px !important;
  font-size: 1.15rem !important;
  font-weight: 600 !important;
  text-align: center !important;
  text-align-last: center !important;
  -moz-text-align-last: center !important;
  -webkit-text-align-last: center !important;
  appearance: none !important;
  font-family: var(--user-font) !important;
}

#lang-select:focus,
#font-select:focus {
  outline: none !important;
}

#lang-select option,
#font-select option,
#lang-select optgroup,
#font-select optgroup {
  text-align: center !important;
  text-align-last: center !important;
}

/* Font-specific styling for dropdown options */
#font-select option[value='merriweather'] {
  font-family: var(--font-merriweather) !important;
}
#font-select option[value='source-sans'] {
  font-family: var(--font-source-sans) !important;
}
#font-select option[value='opendyslexic'] {
  font-family: var(--font-opendyslexic) !important;
}
#font-select option[value='crimson'] {
  font-family: var(--font-crimson) !important;
}
#font-select option[value='atkinson'] {
  font-family: var(--font-atkinson) !important;
}
#font-select option[value='work-sans'] {
  font-family: var(--font-work-sans) !important;
}

/* Theme and Size Controls Row */
.theme-size-row {
  display: flex;
  align-items: center;
  gap: 2rem;
  justify-content: center;
}

/* Theme Button Styling */
.theme-btn {
  background-color: var(--color-bg) !important;
  color: var(--color-text-muted) !important;
  border: 1px solid transparent !important;
  border-radius: 4px !important;
  padding: 0.5rem !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 40px !important;
  height: 40px !important;
  font-size: var(--ui-font-size) !important;
  transition: background-color var(--transition-fast) !important;
}

.theme-btn:hover {
  background-color: var(--color-button-hover) !important;
}

/* Theme Icon Display Logic */
.moon-icon {
  display: block;
}

.sun-icon {
  display: none;
}

html.light .moon-icon {
  display: none;
}

html.light .sun-icon {
  display: block;
}

/* ================================================
   END OF GLOBAL CSS
   ================================================ */ 

.chapter-separator {
  height: 2rem;
}




.reader .chapter-number {
  color: var(--color-text);
}

/* Book/Chapter Navigation Styles */
.book-name,
.chapter-num {
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

.chapter-num {
  margin-left: 0.3em !important;
}

.book-name:active,
.chapter-num:active {
  opacity: 0.7;
}

/* Selector Modal */
.selector-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  z-index: 9999;
  align-items: center;
  justify-content: center;
}

.selector-modal.show {
  display: flex !important;
}

.selector-modal-content {
  background: var(--color-bg);
  border-radius: 12px;
  padding: 2rem;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.selector-modal-content h3 {
  text-align: center;
  margin: 0 0 1.5rem 0;
  font-size: clamp(1.5rem, 3vw, 2rem);
  color: var(--color-text);
}

/* Chapter Grid */
.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
  gap: 0.75rem;
}

.chapter-grid a {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: var(--color-text);
  color: var(--color-bg);
  text-decoration: none;
  border-radius: 8px;
  font-size: clamp(1.2rem, 2.5vw, 1.5rem);
  font-weight: 600;
  transition: opacity 0.2s;
}

.chapter-grid a:hover,
.chapter-grid a:active {
  opacity: 0.8;
}

/* Book List */
.book-list {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.testament-section h4 {
  text-align: center;
  margin: 0 0 1rem 0;
  font-size: clamp(1.2rem, 2.5vw, 1.5rem);
  color: var(--color-text);
  opacity: 0.8;
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
}

.book-grid a {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1rem;
  background: var(--color-text);
  color: var(--color-bg);
  text-decoration: none;
  border-radius: 8px;
  font-size: clamp(0.95rem, 2vw, 1.1rem);
  font-weight: 600;
  transition: opacity 0.2s;
  text-align: center;
}

.book-grid a:hover,
.book-grid a:active {
  opacity: 0.8;
}
