html {
  font-size: 20px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  margin: 0;
  padding: 15px;
  display: flex;
  justify-content: center;
}

.accent {
  color: var(--accent-color);
}

/* Hide print utilities on digital displays */
.print-url-footer {
  display: none;
}

/* Common Container */
.container-index, .container-kisah {
  max-width: 600px;
  width: 100%;
}
h2 {
  font-size: 1.3rem;
}
h2.index-h2 {
  text-align: center;
  opacity: .7;
  font-family: monospace;
  font-weight: 400;
}

h1 {
  text-align: center;
  color: var(--text-color); /* Matches text color for pure black/white feel */
  margin-bottom: 5px;
  font-size: 1.6rem;
}

.subtitle-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.subtitle-wrapper .index-h2 {
  margin: 0;
}

.wa-share-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background-color: #e0e0e0;
  color: #333333;
  padding: 6px 12px;
  border-radius: 20px;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.85rem;
  line-height: 1;
  margin-left: 5px;
}

.wa-share-btn:hover {
  background-color: #d0d0d0;
}

.wa-share-btn svg {
  display: block;
}

#story-subtitle {
  text-align: center;
  margin-bottom: 25px;
  font-size: 1.0rem;
}

/* STORY IMAGE -->  */
.story-image-container {
  width: 100%;
  margin: 20px 0;
  /*border-radius: 12px;*/
  overflow: hidden;
  /* This forces the 4:3 ratio even before the image loads */
  aspect-ratio: 4 / 3; 
  background-color: rgba(128, 128, 128, 0.1);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

#story-image {
  width: 100%;
  height: 100%;
  object-fit: cover; /* Ensures the image fills the 4:3 area perfectly */
  display: block;
}
/* <-- STORY IMAGE */

/* Index Page Styles */
.story-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.story-title-list {
  font-weight: bold;
  margin-bottom: 3px;
}

.story-card {
  background: var(--card-bg);
  padding: 15px 18px;
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  transition: transform 0.1s ease;
  border: 1px solid rgba(128, 128, 128, 0.2); /* Subtle border adds definition */
}

.story-card:active {
  transform: scale(0.98);
}

#story-title {
  font-weight: bold;
}

.story-ref {
  font-size: 0.85rem;
  opacity: 0.7;
}

/* Kisah (Story) Page Styles */
.container-kisah {
  background: var(--card-bg);
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  border: 1px solid rgba(128, 128, 128, 0.2);
}

.controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(128, 128, 128, 0.3);
  padding-bottom: 10px;
  margin-bottom: 20px;
  gap: 10px;
}

/* Button Upgrades */
.btn {
  background: var(--btn-bg);
  color: var(--btn-text);
  border: 1px solid rgba(128, 128, 128, 0.4);
  padding: 10px 15px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
  touch-action: manipulation;
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
}

.btn:active {
  opacity: 0.8;
}

/* WhatsApp Branding with High Contrast */
.btn-wa {
  background-color: #25D366 !important; 
  color: #000000 !important; /* Black text often provides better contrast on bright green */
  border: 1px solid rgba(0,0,0,0.2) !important;
  font-weight: 800 !important; /* Extra bold for readability */
}
@media (prefers-color-scheme: dark) {
  .btn-wa {
    background-color: #20b858 !important;
    color: #000000 !important;
  }
}

.btn-wa:active {
  background-color: #1ebd5c !important;
}

/* Action Grid for Share, Download, Copy */
.action-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin: 20px 0;
}

@media (min-width: 400px) {
  .action-grid {
    grid-template-columns: 1fr 1fr;
  }
  .full-width {
    grid-column: span 2;
  }
}

#audio-player {
  width: 100%;
  margin: 15px 0;
  height: 54px;
  border-radius: 8px;
}

/* Story Verses - Base state for smooth transition */
#story-content p {
  border-left: 3px solid transparent;
  padding-left: 8px;
  margin-left: -11px; /* Offsets border & padding so text remains aligned */
  border-radius: 0 6px 6px 0;
  transition: border-color 0.1s ease, background-color 0.1s ease;

  /* so the background won't be at the edge of the text */
  padding-right: 4px;
  margin-right: -4px;
}
#story-content p[data-start] {
  cursor: pointer;
  &:active {
    opacity: 0.7;
  }
}

/* Active Verse Highlight */
#story-content p.active-verse {
  border-left-color: var(--accent-color);
  background-color: rgba(164, 67, 7, 0.04); /* Soft amber tint */
}

@media (prefers-color-scheme: dark) {
  #story-content p.active-verse {
    background-color: rgba(255, 225, 134, 0.04); /* Warm dark mode glow */
  }
}

.verse-number {
  font-size: 0.8rem;
  color: var(--accent-color);
  font-weight: bold;
  vertical-align: text-top;
  margin-right: 2px;
}

p {
  line-height: 1.6;
  margin: 14px auto;
}

hr.skip {
  margin: -5px 5px;
  margin-right: 50%;
  padding: 0;
  border: none;
  border-bottom: dotted 2px;
  opacity: 0.25;
}

/* DBS Questions Styles */
.dbs-questions {
  margin: 30px 0;
  padding: 0 20px 10px 30px;
  background: var(--card-bg);
  border-radius: 12px;
  border: 1px solid rgba(128, 128, 128, 0.2);
}
.dbs-questions h2 {
  /*font-size: 1.3rem;*/
  color: var(--text-color);
  margin-bottom: 15px;
  text-align: left; /* Aligned left rather than center like h1 */
}
.dbs-questions ol {
  margin: 0;
  padding-left: 20px; /* Space for numbers */
  color: var(--text-color);
}
.dbs-questions ol li {
  /*font-size: 1rem;*/
  line-height: 1.2;
  padding-bottom: 10px;
  padding-left: 5px;
}
/* Make the numbers themselves the accent color */
.dbs-questions ol li::marker {
  color: var(--accent-color);
  font-weight: bold;
}

/* Question Audio Interactivity */
.dbs-questions ol li {
  cursor: pointer;
  transition: opacity 0.15s ease;
}
.dbs-questions ol li:active {
  opacity: 0.7;
}

.dbs-questions ol li.speaking-question::after {
  content: "🔊";
  font-size: 0.85em;
  margin-left: 8px;
  position: absolute;
}


.dialogue {
  color: var(--dialogue-color);
  /*font-weight: 500;*/
}

/* TURN ON IF READY FOR CBB */
#translation-toggle {
  display: none;
}

/* ==========================================================================
   QR CODE STYLES
   ========================================================================== */
.qr-container {
  text-align: center;
  margin: 20px 0;
}

.qr-code {
  width: 120px;
  height: 120px;
  border: 2px solid white;
}

/* ==========================================================================
   A4 SINGLE-PAGE PRINT SHEETS (Continuous 2-Column Flow + 1-Column Footer)
   ========================================================================== */
@media print {
  @page {
    size: A4;
    margin: 8mm 8mm 8mm 8mm; /* Consistent margins around the page edge */
  }
  
  body {
    background: #ffffff !important;
    color: #000000 !important;
    padding: 0 !important;
    margin: 0 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* 1. HIDE INTERACTIVE WEB UI COMPONENTS */
  .controls, 
  #audio-player, 
  .action-grid, 
  hr {
    display: none !important;
  }

  /* 2. MAIN FLOW CONTAINER (Controls the 2-Column Balance for the Top Section) */
  .container-kisah {
    /* Forces the entire printed document to use ultra-legible print geometry */
    font-family: Georgia, "Times New Roman", serif !important;

    display: block !important; 
    column-count: 2 !important;
    column-gap: 10mm !important;
    column-fill: balance !important; 
    
    /* Crucial Change: Height must be auto so column-span breakout renders cleanly */
    height: auto !important;
    
    width: 100% !important;
    max-width: 100% !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    box-sizing: border-box !important;
  }

  /* 3. ELEMENT SEQUENCE FLOW (Flows sequentially across columns 1 & 2) */
  h1 {
    display: block !important;
    text-align: left !important;
    margin: 0 0 1mm 0 !important;
    font-size: 18pt !important;
    line-height: 1.1 !important;
    break-inside: avoid !important; 
  }

  #story-subtitle {
    display: block !important;
    text-align: left !important;
    margin: 0 0 2mm 0 !important;
    font-size: 12pt !important;
    font-weight: bold !important;
    break-inside: avoid !important;
  }
  
  #story-subtitle a {
    color: #000000 !important;
    text-decoration: none !important;
  }

  .story-image-container {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 4 / 3 !important;
    margin: 0 0 4mm 0 !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    border: 1px solid #cccccc !important;
    break-inside: avoid !important;
  }

  #story-image {
    width: 100% !important;
    height: auto !important;
    object-fit: contain !important;
    display: block !important;
  }

  /* 4. SCRIPTURE ENGINE RUNTIME TEXT */
  #story-content {
    display: block !important;
    column-count: auto !important; 
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
  }

  #story-content p {
    font-size: 12pt !important; /* Optimized for single-page multi-column canvas matching */
    line-height: 1.4 !important;
    margin: 0 0 6pt 0 !important;
    text-align: left !important;
    break-inside: avoid !important; 
  }

  .verse-number {
    font-size: 10pt !important;
    color: #000000 !important;
  }

  hr.skip {
    display: block !important;
    margin: 5pt 0pt !important;
    margin-right: 50% !important;
    border: none !important;
    border-bottom: 1px dotted #aaa !important;
  }

  /* 5. DISCUSSION QUESTIONS (Spans across the entire bottom landscape width) */
  .dbs-questions {
    display: block !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 4mm 0 0 0 !important;
    border-top: 1.5px solid #000000 !important; /* Solid divider line above discussion block */
    border-radius: 0 !important;
    padding-top: 2mm !important;
    break-inside: avoid !important; /* Keeps all 5 questions structurally together */
  }

  .dbs-questions h2 {
    font-size: 12pt !important;
    margin: 0 0 1mm 0 !important;
    padding-bottom: 1mm !important;
  }

  .dbs-questions ol {
    padding-left: 14pt !important;
    margin: 0 !important;
  }

  .dbs-questions ol li {
    font-size: 12pt !important;
    line-height: 1.35 !important;
    padding-bottom: 4pt !important;
  }

  /* Print-only footer for shortlink mapping */
  .print-url-footer {
    display: block !important;
    text-align: right !important;
    font-family: monospace;
    font-size: 14pt !important;
    font-weight: bold !important;
    color: #000000 !important;
    margin-top: 4mm !important;
    /*letter-spacing: 0.5px !important;*/
  }

  /* 6. GRAPHICS RECOVERY INVERSION */
  .dialogue, .accent, .dbs-questions ol li::marker {
    color: #000000 !important;
  }
  .dialogue {
    font-style: italic !important;
    font-weight: normal !important; 
  }
  .dialogue.quotation-mark {
    font-style: normal !important;
  }
  .accent {
    font-weight: bold;
  }
  
  .dbs-questions, h1, #story-subtitle, .verse-number {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important;
  }
}
