/* ── Reset & Base ────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sky-dawn:    linear-gradient(to bottom, #1a0533 0%, #6b2d6b 40%, #e8956d 70%, #f4c97e 100%);
  --sky-morning: linear-gradient(to bottom, #1a3a5c 0%, #2e6da4 40%, #7eb8d4 70%, #c9e8f5 100%);
  --sky-day:     linear-gradient(to bottom, #1565c0 0%, #1976d2 40%, #42a5f5 80%, #bbdefb 100%);
  --sky-golden:  linear-gradient(to bottom, #0d1b2a 0%, #b5451b 30%, #e8803a 55%, #f5c842 100%);
  --sky-dusk:    linear-gradient(to bottom, #0d1b2a 0%, #4a1942 40%, #8b3060 65%, #c97070 100%);
  --sky-night:   linear-gradient(to bottom, #020814 0%, #0d1b2a 50%, #0a1520 100%);

  --gold:        #c9a84c;
  --gold-light:  #e8cf8a;
  --parchment:   #f5f0e8;
  --text-main:   #f0e8d8;
  --text-dim:    rgba(240,232,216,0.65);
  --glass:       rgba(10,20,35,0.4);
  --glass-light: rgba(255,255,255,0.06);
  --border:      rgba(201,168,76,0.25);
  --radius:      14px;
  --shadow:      0 8px 32px rgba(0,0,0,0.45);

  --font-display: 'Cinzel', Georgia, serif;
  --font-body:    'Lora', Georgia, serif;
  --font-ui:      system-ui, -apple-system, sans-serif;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font-body);
  color: var(--text-main);
  background: #020814;
}

/* ── Sky Background ──────────────────────────────────────────────────── */
#sky {
  position: fixed;
  inset: 0;
  background: var(--sky-night);
  transition: background 2s ease;
  z-index: 0;
}

#sky-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  opacity: 0.45;
  transition: opacity 1.5s ease;
}

#sky-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.3);
}

/* ── App Shell ───────────────────────────────────────────────────────── */
#app {
  position: relative;
  z-index: 1;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Header ──────────────────────────────────────────────────────────── */
#header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 10px;
  background: rgba(5,12,22,0.65);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

#header h1 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  letter-spacing: 0.06em;
  color: var(--gold-light);
  font-weight: 600;
}

#header-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

#translation-select {
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-main);
  font-family: var(--font-ui);
  font-size: 0.78rem;
  padding: 5px 8px;
  cursor: pointer;
  outline: none;
}

#translation-select option { background: #0d1b2a; }

/* ── Main Content ────────────────────────────────────────────────────── */
#main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

/* ── Screens ─────────────────────────────────────────────────────────── */
.screen { display: none; padding: 16px; }
.screen.active { display: block; }

/* ── Verse of the Day ────────────────────────────────────────────────── */
#home-screen { padding: 0; }

#votd-wrapper {
  position: relative;
  min-height: 52vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

#votd-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  z-index: 0;
}

#votd-bg-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(0,0,0,0.15) 0%, rgba(0,0,0,0.55) 100%);
  z-index: 1;
}

#votd-card {
  position: relative;
  z-index: 2;
  background: var(--glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 20px 18px;
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow), 0 0 0 1px rgba(201,168,76,0.1);
}

#votd-label {
  font-family: var(--font-display);
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 12px;
  opacity: 0.9;
}

#votd-text {
  font-family: var(--font-body);
  font-size: 1.05rem;
  line-height: 1.65;
  color: var(--text-main);
  font-style: italic;
  margin-bottom: 14px;
}

#votd-reference {
  font-family: var(--font-display);
  font-size: 0.8rem;
  color: var(--gold-light);
  letter-spacing: 0.05em;
}

#votd-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.votd-btn {
  flex: 1;
  background: var(--glass-light);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-main);
  font-family: var(--font-ui);
  font-size: 0.78rem;
  padding: 8px 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.2s;
}
.votd-btn:hover, .votd-btn:active { background: rgba(201,168,76,0.15); }
.votd-btn svg { width: 15px; height: 15px; flex-shrink: 0; }

/* ── Home lower section ──────────────────────────────────────────────── */
#home-lower {
  padding: 16px;
}

.home-section-title {
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 12px;
  opacity: 0.8;
}

/* Quick nav tiles */
#quick-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 22px;
}

.nav-tile {
  background: var(--glass);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 14px;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
}
.nav-tile:hover, .nav-tile:active {
  border-color: var(--gold);
  background: rgba(201,168,76,0.1);
}
.nav-tile .tile-icon { font-size: 1.5rem; margin-bottom: 6px; }
.nav-tile .tile-label {
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  color: var(--gold-light);
}

/* ── Bible Library ───────────────────────────────────────────────────── */
#library-search {
  width: 100%;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 11px 14px;
  margin-bottom: 14px;
  outline: none;
}
#library-search::placeholder { color: var(--text-dim); }

.testament-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.tab-btn {
  flex: 1;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-dim);
  font-family: var(--font-display);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  padding: 9px;
  cursor: pointer;
  transition: all 0.2s;
}
.tab-btn.active {
  background: rgba(201,168,76,0.18);
  border-color: var(--gold);
  color: var(--gold-light);
}

#book-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.book-btn {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 0.8rem;
  padding: 10px 6px;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
  line-height: 1.3;
}
.book-btn:hover, .book-btn:active {
  border-color: var(--gold);
  background: rgba(201,168,76,0.12);
  color: var(--gold-light);
}

/* ── Chapter Reader ───────────────────────────────────────────────────── */
#reader-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

#reader-title {
  font-family: var(--font-display);
  font-size: 1rem;
  color: var(--gold-light);
  letter-spacing: 0.04em;
  flex: 1;
}

.reader-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-main);
  padding: 7px 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-ui);
  font-size: 0.78rem;
  transition: all 0.2s;
  white-space: nowrap;
}
.icon-btn:hover, .icon-btn:active {
  border-color: var(--gold);
  background: rgba(201,168,76,0.15);
}
.icon-btn svg { width: 15px; height: 15px; }
.icon-btn.speaking {
  border-color: var(--gold);
  background: rgba(201,168,76,0.2);
  color: var(--gold-light);
}

#chapter-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 10px;
}

.ch-nav-btn {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-main);
  font-family: var(--font-ui);
  font-size: 0.82rem;
  padding: 8px 14px;
  cursor: pointer;
  transition: all 0.2s;
}
.ch-nav-btn:hover, .ch-nav-btn:active {
  border-color: var(--gold);
  background: rgba(201,168,76,0.15);
}
.ch-nav-btn:disabled { opacity: 0.3; cursor: default; }

#chapter-select-wrap {
  flex: 1;
  text-align: center;
}

#chapter-select {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-main);
  font-family: var(--font-ui);
  font-size: 0.82rem;
  padding: 7px 10px;
  outline: none;
  cursor: pointer;
  max-width: 130px;
}
#chapter-select option { background: #0d1b2a; }

#verses-container {
  padding-bottom: 40px;
}

.verse-row {
  display: flex;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(201,168,76,0.06);
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s;
}
.verse-row:hover, .verse-row:active { background: rgba(201,168,76,0.06); }
.verse-row.highlighted { background: rgba(201,168,76,0.13); }

.verse-num {
  font-family: var(--font-display);
  font-size: 0.7rem;
  color: var(--gold);
  min-width: 22px;
  padding-top: 3px;
  text-align: right;
  flex-shrink: 0;
}

.verse-text {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text-main);
}

#reader-loading {
  text-align: center;
  color: var(--text-dim);
  padding: 40px 0;
  font-style: italic;
}

/* ── Analysis Overlay ─────────────────────────────────────────────────── */
#analysis-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(2,8,20,0.82);
  backdrop-filter: blur(6px);
  display: none;
  flex-direction: column;
}
#analysis-overlay.open { display: flex; }

#analysis-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(5,12,22,0.9);
  flex-shrink: 0;
}

#analysis-ref {
  font-family: var(--font-display);
  font-size: 0.9rem;
  color: var(--gold-light);
}

#analysis-header-actions {
  display: flex;
  gap: 8px;
}

#analysis-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  -webkit-overflow-scrolling: touch;
}

#analysis-content {
  font-family: var(--font-body);
  font-size: 0.97rem;
  line-height: 1.75;
  color: var(--text-main);
  white-space: pre-wrap;
}

.analysis-loading {
  text-align: center;
  padding: 40px 0;
  color: var(--text-dim);
  font-style: italic;
}

/* ── Theology Explorer ───────────────────────────────────────────────── */
#explorer-form {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}

#explorer-input {
  flex: 1;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 11px 14px;
  outline: none;
}
#explorer-input::placeholder { color: var(--text-dim); }

#explorer-submit {
  background: rgba(201,168,76,0.2);
  border: 1px solid var(--gold);
  border-radius: 10px;
  color: var(--gold-light);
  font-family: var(--font-display);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  padding: 0 16px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}
#explorer-submit:hover, #explorer-submit:active {
  background: rgba(201,168,76,0.35);
}
#explorer-submit:disabled { opacity: 0.5; cursor: default; }

#explorer-result {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: none;
}
#explorer-result.visible { display: block; }

#explorer-result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

#explorer-result-title {
  font-family: var(--font-display);
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
}

#explorer-text {
  font-family: var(--font-body);
  font-size: 0.97rem;
  line-height: 1.75;
  color: var(--text-main);
  white-space: pre-wrap;
}

#explorer-loading {
  text-align: center;
  padding: 30px 0;
  color: var(--text-dim);
  font-style: italic;
  display: none;
}
#explorer-loading.visible { display: block; }

.suggested-topics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.topic-chip {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-dim);
  font-family: var(--font-ui);
  font-size: 0.78rem;
  padding: 6px 12px;
  cursor: pointer;
  transition: all 0.2s;
}
.topic-chip:hover, .topic-chip:active {
  border-color: var(--gold);
  color: var(--gold-light);
  background: rgba(201,168,76,0.1);
}

/* ── Bottom Nav ──────────────────────────────────────────────────────── */
#bottom-nav {
  flex-shrink: 0;
  display: flex;
  background: rgba(5,12,22,0.75);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.nav-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: var(--font-ui);
  font-size: 0.65rem;
  letter-spacing: 0.04em;
  padding: 10px 4px 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: color 0.2s;
}
.nav-btn svg { width: 20px; height: 20px; }
.nav-btn.active { color: var(--gold-light); }

/* ── Utilities ───────────────────────────────────────────────────────── */
.back-btn {
  background: none;
  border: none;
  color: var(--gold);
  font-family: var(--font-display);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  cursor: pointer;
  padding: 4px 0;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.close-btn {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-dim);
  width: 32px;
  height: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: all 0.2s;
}
.close-btn:hover { color: var(--text-main); border-color: var(--gold); }

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(201,168,76,0.3); border-radius: 2px; }

/* Loading spinner */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 24px; height: 24px;
  border: 2px solid rgba(201,168,76,0.2);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
  vertical-align: middle;
  margin-right: 8px;
}

/* ── Accordion ───────────────────────────────────────────────────────── */
.accord-section {
  background: rgba(10,20,35,0.45);
  border: 1px solid rgba(201,168,76,0.25);
  border-radius: 14px;
  margin-bottom: 10px;
  overflow: hidden;
}
.accord-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
}
.accord-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Cinzel', Georgia, serif;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #c9a84c;
}
.accord-arrow {
  color: #c9a84c;
  font-size: 0.8rem;
  transition: transform 0.25s;
  flex-shrink: 0;
}
.accord-section.open .accord-arrow { transform: rotate(180deg); }
.accord-body {
  display: none;
  padding: 0 16px 16px;
  font-family: 'Lora', Georgia, serif;
  font-size: 0.97rem;
  line-height: 1.75;
  color: #f0e8d8;
  white-space: pre-wrap;
}
.accord-section.open .accord-body { display: block; }
.plain-summary {
  background: rgba(10,20,35,0.45);
  border: 1px solid rgba(201,168,76,0.25);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 12px;
  font-family: 'Lora', Georgia, serif;
  font-size: 1rem;
  line-height: 1.7;
  color: #f0e8d8;
}

.verse-card {
  background: linear-gradient(135deg, #c9a84c, #8b6914);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 14px;
  font-family: 'Lora', Georgia, serif;
  font-size: 1.05rem;
  line-height: 1.65;
  color: #fff;
  font-style: italic;
}
.verse-card-ref {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.85);
  margin-top: 10px;
  font-style: normal;
}

/* ── New layout - full bg, content at bottom ─────────────────────────── */
#home-screen { padding: 0; display: flex; flex-direction: column; height: 100%; }

#votd-wrapper {
  flex: 1;
  min-height: unset;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 16px 16px 10px;
  position: relative;
}

#votd-bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  opacity: 1;
  z-index: -1;
}

#sky-img {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  opacity: 1;
}

#sky-overlay { background: rgba(0,0,0,0.5); }

#votd-bg-overlay { display: none; }

#votd-card { max-width: 100%; }

#home-lower {
  padding: 0 16px 12px;
  background: transparent;
}

/* ── Solid dark background for non-home screens ──────────────────────── */
#library-screen,
#reader-screen,
#explorer-screen {
  background: #0a0f1a;
  min-height: 100%;
}

/* ── Chapter picker grid ─────────────────────────────────────────────── */
#chapter-picker-screen {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  background: #0a0f1a;
  display: none;
}
#chapter-picker-screen.active { display: block; }

#chapter-picker-title {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 1rem;
  color: #e8cf8a;
  letter-spacing: 0.04em;
  margin-bottom: 16px;
}

#chapter-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  padding-bottom: 40px;
}

.chapter-btn {
  background: rgba(10,20,35,0.45);
  border: 1px solid rgba(201,168,76,0.25);
  border-radius: 10px;
  color: #f0e8d8;
  font-family: 'Cinzel', Georgia, serif;
  font-size: 0.85rem;
  padding: 14px 6px;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
}
.chapter-btn:hover, .chapter-btn:active {
  border-color: #c9a84c;
  background: rgba(201,168,76,0.15);
  color: #e8cf8a;
}
