/* ══════════════════════════════════════════════════════════════════
   Ganapati Sambhavam — reading site stylesheet
   ══════════════════════════════════════════════════════════════════ */

@font-face { font-family: 'Gidugu';      src: url('../fonts/Gidugu.ttf') format('truetype'); font-weight: normal; }
@font-face { font-family: 'Ponnala';     src: url('../fonts/Ponnala.ttf') format('truetype'); font-weight: normal; }
@font-face { font-family: 'Tiro Telugu'; src: url('../fonts/TiroTelugu.ttf') format('truetype'); font-weight: normal; }
@font-face { font-family: 'Noto Serif Devanagari'; src: url('../fonts/NotoSerifDevanagari-Regular.ttf') format('truetype'); font-weight: normal; }
@font-face { font-family: 'Noto Serif Devanagari'; src: url('../fonts/NotoSerifDevanagari-Bold.ttf') format('truetype'); font-weight: bold; }
@font-face { font-family: 'Noto Serif';  src: url('../fonts/NotoSerif-Regular.ttf') format('truetype'); font-weight: normal; font-style: normal; }
@font-face { font-family: 'Noto Serif';  src: url('../fonts/NotoSerif-Bold.ttf') format('truetype');    font-weight: bold;   font-style: normal; }
@font-face { font-family: 'Noto Serif';  src: url('../fonts/NotoSerif-Italic.ttf') format('truetype');  font-weight: normal; font-style: italic; }

:root {
  --bg:        #faf7f0;
  --bg-panel:  #ffffff;
  --bg-raised: #f1ece0;
  --border:    #e4dcc8;
  --text:      #241f14;
  --text-dim:  #6b6252;
  --accent:    #a8541e;
  --accent-soft: #f4e3d3;
  --link:      #8a4315;
  --shadow:    0 2px 14px rgba(60, 45, 20, 0.10);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg:        #1a1712;
  --bg-panel:  #221e17;
  --bg-raised: #2a2419;
  --border:    #3a3226;
  --text:      #ece4d3;
  --text-dim:  #a89b83;
  --accent:    #e2925a;
  --accent-soft: #3a2a1a;
  --link:      #f0a86e;
  --shadow:    0 2px 14px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Noto Serif', Georgia, serif;
  line-height: 1.6;
  min-height: 100vh;
}
a { color: var(--link); }
button { font: inherit; }

/* ── Topbar ─────────────────────────────────────────────────────── */

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 1rem;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.icon-btn {
  background: none; border: none; color: var(--text);
  font-size: 1.25rem; line-height: 1; cursor: pointer;
  padding: 0.35rem 0.5rem; border-radius: 6px;
}
.icon-btn:hover { background: var(--bg-raised); }

.brand { display: flex; align-items: baseline; gap: 0.4rem; flex: 1; min-width: 0; overflow: hidden; }
.brand-te  { font-family: 'Ponnala', serif; font-size: 1.15rem; color: var(--accent); white-space: nowrap; }
.brand-sep { color: var(--text-dim); }
.brand-en  { font-size: 0.9rem; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.topbar-actions { display: flex; align-items: center; gap: 0.6rem; }

.lang-toggle { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.lang-btn {
  background: var(--bg-panel); border: none; color: var(--text-dim);
  padding: 0.35rem 0.7rem; cursor: pointer; font-size: 0.85rem;
}
.lang-btn + .lang-btn { border-left: 1px solid var(--border); }
.lang-btn.active { background: var(--accent); color: #fff; }

/* ── Layout ─────────────────────────────────────────────────────── */

.layout { display: flex; align-items: flex-start; max-width: 1200px; margin: 0 auto; }

.sidebar {
  width: 300px; flex: 0 0 300px;
  position: sticky; top: 53px;
  height: calc(100vh - 53px);
  overflow-y: auto;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  z-index: 20;
}
.sidebar-inner { padding: 0.75rem 0.5rem 3rem; }
.sidebar-loading { color: var(--text-dim); padding: 1rem; font-size: 0.9rem; }

.nav-group { margin-bottom: 0.2rem; }
.nav-group-btn {
  width: 100%; display: flex; align-items: center; gap: 0.5rem;
  background: none; border: none; text-align: left; cursor: pointer;
  padding: 0.55rem 0.6rem; border-radius: 8px; color: var(--text);
  font-size: 0.95rem;
}
.nav-group-btn:hover { background: var(--bg-raised); }
.nav-group-btn.open { background: var(--bg-raised); font-weight: bold; }
.nav-group-btn .chev { transition: transform 0.15s; color: var(--text-dim); font-size: 0.75rem; }
.nav-group-btn.open .chev { transform: rotate(90deg); }
.nav-group-num { color: var(--accent); font-variant-numeric: tabular-nums; min-width: 1.4em; }

.nav-topics { list-style: none; margin: 0; padding: 0 0 0.4rem 0; display: none; }
.nav-topics.open { display: block; }
.nav-topics li a {
  display: block; text-decoration: none; color: var(--text-dim);
  padding: 0.4rem 0.6rem 0.4rem 2.1rem; border-radius: 8px; font-size: 0.88rem;
  border-left: 2px solid transparent;
}
.nav-topics li a:hover { background: var(--bg-raised); color: var(--text); }
.nav-topics li a.active {
  background: var(--accent-soft); color: var(--accent); border-left-color: var(--accent); font-weight: bold;
}
.nav-topics .range { color: var(--text-dim); font-size: 0.78rem; margin-left: 0.3em; }

/* ── Content ────────────────────────────────────────────────────── */

.content { flex: 1; min-width: 0; padding: 1.5rem 1.75rem 4rem; max-width: 820px; margin: 0 auto; }
.loading, .error { color: var(--text-dim); padding: 2rem 0; }
.error { color: #b3462c; }

.breadcrumb {
  font-size: 0.82rem; color: var(--text-dim); margin-bottom: 1.1rem;
  display: flex; flex-wrap: wrap; gap: 0.3rem; align-items: center;
}
.breadcrumb .sep { opacity: 0.5; }

.pending-banner {
  background: var(--accent-soft); border: 1px solid var(--border);
  border-radius: 10px; padding: 0.8rem 1rem; margin-bottom: 1.2rem;
  font-size: 0.9rem; color: var(--text-dim);
}

/* Language-aware body/sidebar defaults. Gidugu/Tiro Telugu happen to carry
   Latin glyphs too (unlike Ponnala), so section-header text needs an
   explicit English-mode override rather than relying on font fallback. */
[data-active-lang="te"] .content, [data-active-lang="te"] .sidebar { font-family: 'Gidugu', sans-serif; }
[data-active-lang="en"] .sec-hdr:not(.sec-hdr-deva) { font-family: 'Noto Serif', Georgia, serif; }

.topic-title, .s0-title {
  font-family: 'Ponnala', serif; text-align: center;
  color: var(--text); line-height: 1.35;
}
.topic-title { font-size: 1.5rem; margin: 0.6rem 0 0.4rem; }
.s0-title    { font-size: 1.7rem; margin: 0 0 1.2rem; }

.s0-h2 { font-family: 'Ponnala', serif; font-size: 1.2rem; margin: 1.4rem 0 0.5rem; color: var(--text); }
.s0-h3 { font-family: 'Ponnala', serif; font-size: 1.05rem; margin: 1.1rem 0 0.4rem; color: var(--text); }

.topic-desc {
  font-style: italic; color: var(--text-dim); text-align: center;
  font-size: 0.92rem; margin: 0 0 1.1rem;
}

.trans-label {
  font-family: 'Ponnala', serif; color: var(--text-dim); font-style: italic;
  text-align: center; font-size: 0.88rem; margin: 1rem 0 0.3rem;
}

/* Verse blocks */
.verse-block {
  position: relative;
  margin: 0.9rem 0 1.1rem;
  padding: 0.85rem 1.1rem;
  background: var(--bg-panel);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
}
.verse-block[data-audio] { padding-right: 3.2rem; }

.play-btn {
  position: absolute; top: 0.6rem; right: 0.7rem;
  width: 2.1rem; height: 2.1rem; border-radius: 50%;
  border: none; background: var(--accent); color: #fff;
  font-size: 0.85rem; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow);
}
.play-btn:hover { filter: brightness(1.08); }
.play-btn.playing { background: var(--link); }
.verse {
  font-family: 'Tiro Telugu', 'Noto Serif Devanagari', serif;
  font-weight: bold; font-size: 1.08rem; line-height: 1.55;
  color: var(--text);
}
.verse-deva { font-family: 'Noto Serif Devanagari', serif; font-weight: bold; font-size: 1.08rem; line-height: 1.6; color: var(--text); }
.verse-iast { font-family: 'Noto Serif', serif; font-style: italic; color: var(--text-dim); font-size: 0.94rem; line-height: 1.55; margin-top: 0.5rem; }

/* Section headers: పదచ్ఛేదము / అన్వయము / ప్రతిపదార్థము / భావము */
.sec-hdr {
  font-family: 'Gidugu', sans-serif; font-weight: bold; color: var(--accent);
  font-size: 1.05rem; margin: 1.1rem 0 0.35rem; letter-spacing: 0.01em;
}
.sec-hdr-deva { font-family: 'Noto Serif Devanagari', serif; }
.s0-sec-hdr { font-weight: bold; color: var(--accent); margin: 1rem 0 0.3rem; }

.body-text { margin: 0.15rem 0; }
.s0-body   { text-align: justify; margin: 0.4rem 0; }
.s0-bold   { font-weight: bold; margin: 0.5rem 0; }
.s0-bullet { margin: 0.2rem 0 0.2rem 1.3rem; }
.s0-attribution { text-align: right; font-style: italic; color: var(--text-dim); margin: 0.3rem 0 0.8rem; }
.s0-hr { border: none; border-top: 1px solid var(--border); margin: 1.3rem 0; }

.pratipa-item { margin: 0.15rem 0 0.15rem 1.1rem; line-height: 1.5; }
.pratipa-item strong { color: var(--text); }

.bhava-spacer { height: 0.6rem; }

/* Images */
.img-pg, .s0-img { text-align: center; margin: 1.1rem 0; }
.img-pg img, .s0-img img {
  max-width: 100%; max-height: 60vh; height: auto; border-radius: 8px;
  box-shadow: var(--shadow);
}
.img-caption { font-size: 0.82rem; font-style: italic; color: var(--text-dim); margin-top: 0.5rem; }
.s0-caption  { font-size: 0.85rem; font-style: italic; color: var(--text-dim); text-align: center; margin: 0.3rem 0 0.8rem; }

.s0-gallery { text-align: center; }
.s0-photo-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 1.2rem; }
.s0-photo-grid > *:first-child { flex: 0 0 100%; }
.family-cell { flex: 0 0 44%; min-width: 220px; }

/* Sanskrit verse block inside English front matter (Devanagari + IAST) */
.s0-verse-block { margin: 0.7rem 0; padding: 0.7rem 1rem; background: var(--bg-panel); border-left: 3px solid var(--accent); border-radius: 4px; }
.s0-verse       { font-family: 'Noto Serif Devanagari', serif; font-weight: bold; font-size: 1.05rem; line-height: 1.6; color: var(--text); }
.s0-verse-iast  { font-family: 'Noto Serif', serif; font-style: italic; color: var(--text-dim); font-size: 0.92rem; }

/* ── Prev / next footer nav ────────────────────────────────────── */

.page-nav {
  display: flex; justify-content: space-between; gap: 1rem;
  margin-top: 2.5rem; padding-top: 1.2rem; border-top: 1px solid var(--border);
}
.page-nav a {
  flex: 1; text-decoration: none; color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 0.7rem 0.9rem; font-size: 0.85rem; background: var(--bg-panel);
}
.page-nav a:hover { border-color: var(--accent); }
.page-nav .dir   { display: block; color: var(--text-dim); font-size: 0.75rem; margin-bottom: 0.2rem; }
.page-nav .next  { text-align: right; }
.page-nav .spacer{ flex: 1; }

/* ── Mobile ─────────────────────────────────────────────────────── */

.scrim { display: none; }

@media (max-width: 860px) {
  .brand-en { display: none; }
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh;
    transform: translateX(-100%); transition: transform 0.2s ease;
    box-shadow: var(--shadow); padding-top: 53px;
  }
  .sidebar.open { transform: translateX(0); }
  .scrim.show {
    display: block; position: fixed; inset: 0; z-index: 15;
    background: rgba(0,0,0,0.35);
  }
  .content { padding: 1.2rem 1.1rem 3rem; }
  .layout { display: block; }
}
