/* ==========================================================================
   Bhajan Kosh — Design System v2
   Old-scripture feel: warm beige/parchment with subtle grain, generous
   whitespace, large readable type, lyrics as continuous flowing text
   (not boxed per verse). Built for an audience that skews 40+.
   ========================================================================== */

:root {
  /* Palette — parchment (always-on default, not theme-conditional).
     Text/border colors are tuned to meet WCAG AA (4.5:1 text, 3:1 UI)
     against both --bg and --bg-raised; see contrast notes inline. */
  --bg: #F6EFDE;
  --bg-raised: #FCF8EC;
  --bg-muted: #EFE5CC;
  --text: #2B2013;
  --text-muted: #5E5138;
  --text-faint: #6E6046;   /* was #8A7C60 (3.6:1, failed AA) — now ~5.3:1 */
  --border: #907E42;       /* was #DCCEA4 (1.4:1) — now ~3.5:1 for visible UI boundaries */
  --accent-1: #96590D;     /* was #B5721A — white-on-accent-1 was 3.9:1, now ~5.6:1 */
  --accent-2: #A1441F;     /* terracotta */
  --accent-soft: #EDDDB6;
  --accent-gradient: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  --link: #8C3A18;
  --focus-ring: #A1441F;
  --shadow-sm: 0 1px 2px rgba(43, 32, 19, 0.08);
  --shadow-md: 0 4px 16px rgba(43, 32, 19, 0.10);
  --shadow-lg: 0 12px 32px rgba(43, 32, 19, 0.14);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;

  --font-latin: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-deva: 'Noto Sans Devanagari', var(--font-latin);
  --font-deva-display: 'Rozha One', 'Noto Serif Devanagari', serif;

  --body-size: 22px;
  --content-max: 740px;
  --page-max: 1120px;

  /* Subtle paper grain: layered turbulence noise, very low opacity */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0.30  0 0 0 0 0.22  0 0 0 0 0.10  0 0 0 0.05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background-color: var(--bg);
  background-image: var(--grain);
  color: var(--text);
  font-family: var(--font-latin);
  font-size: var(--body-size);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

body[lang="hi"], .lang-hi {
  font-family: var(--font-deva);
}

img { max-width: 100%; display: block; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

/* Skip link — WCAG 2.4.1 bypass blocks */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent-2);
  color: #fff;
  padding: 12px 20px;
  z-index: 100;
  border-radius: 0 0 var(--radius-sm) 0;
  font-family: var(--font-latin);
}
.skip-link:focus {
  left: 0;
}

h1, h2, h3, h4 {
  font-family: var(--font-deva-display);
  font-weight: 400;
  line-height: 1.3;
  margin: 0 0 0.5em;
  color: var(--text);
}
h1 { font-size: clamp(2.1rem, 4.5vw, 3rem); }
h2 { font-size: clamp(1.6rem, 3.2vw, 2.1rem); }
h3 { font-size: 1.35rem; }
p { margin: 0 0 1em; }

.container {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 20px;
}
.content-width {
  max-width: var(--content-max);
  margin: 0 auto;
}

/* ---------- Header ---------- */
.site-header {
  border-bottom: 1px solid var(--border);
  background-color: var(--bg);
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(1.2) blur(6px);
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  height: 72px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-deva-display);
  font-size: 1.5rem;
  color: var(--text);
}
.brand .mark {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--accent-gradient);
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.15rem; font-family: var(--font-deva);
}
.brand:hover { text-decoration: none; }

/* Hamburger toggle — mobile only (see media query below) */
.nav-toggle {
  display: none;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  background: var(--bg-raised);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.nav-toggle-bars { display: flex; flex-direction: column; gap: 4px; width: 20px; }
.nav-toggle-bars span { display: block; height: 2.5px; background: var(--text); border-radius: 2px; }

nav.main-nav { display: flex; align-items: center; gap: 4px; }
nav.main-nav a {
  color: var(--text-muted);
  font-size: 1.05rem;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
nav.main-nav a:hover, nav.main-nav a:focus-visible { color: var(--text); background: var(--bg-muted); text-decoration: none; }

/* ---------- Hero ---------- */
.hero {
  padding: 48px 0 40px;
  text-align: center;
}
.hero .motif {
  width: 72px;
  height: 72px;
  margin: 0 auto 18px;
  color: var(--accent-2);
}
.hero .eyebrow {
  display: inline-block;
  font-family: var(--font-latin);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-2);
  background: var(--accent-soft);
  padding: 7px 16px;
  border-radius: 999px;
  margin-bottom: 18px;
}
.hero h1 { margin-bottom: 0.3em; }
.hero .sub {
  color: var(--text-muted);
  font-size: 1.2rem;
  max-width: 640px;
  margin: 0 auto;
  line-height: 1.6;
}

/* ---------- Category groups (hub) ---------- */
.category-group { margin: 48px 0; }
.category-group h2 {
  display: flex;
  align-items: baseline;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
  margin-bottom: 20px;
}
.category-group h2 .count {
  font-family: var(--font-latin);
  font-size: 1rem;
  color: var(--text-faint);
  font-weight: 500;
}

.bhajan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 18px;
}
.bhajan-card {
  background: var(--bg-raised);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 22px;
  transition: box-shadow 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
  display: block;
  min-height: 44px;
}
.bhajan-card:hover, .bhajan-card:focus-visible {
  box-shadow: var(--shadow-md);
  border-color: var(--accent-1);
  transform: translateY(-2px);
  text-decoration: none;
}
.bhajan-card .num {
  font-family: var(--font-latin);
  font-size: 0.88rem;
  color: var(--text-faint);
  font-weight: 600;
}
.bhajan-card .title-hi {
  font-family: var(--font-deva);
  font-size: 1.4rem;
  line-height: 1.4;
  color: var(--text);
  margin: 6px 0 4px;
}
.bhajan-card .title-en {
  font-size: 0.98rem;
  color: var(--text-muted);
}
.bhajan-card .preview {
  margin-top: 12px;
  font-family: var(--font-deva);
  font-size: 1.02rem;
  color: var(--text-muted);
  border-left: 3px solid var(--accent-soft);
  padding-left: 12px;
}

/* ---------- Reader controls ---------- */
.reader-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-muted);
  border-radius: var(--radius-md);
  margin: 24px 0;
}
.reader-controls .group {
  display: flex;
  align-items: center;
  gap: 8px;
  border-right: 1px solid var(--border);
  padding-right: 14px;
  margin-right: 4px;
}
.reader-controls .group:last-child { border-right: none; }
.reader-controls button {
  font-family: var(--font-latin);
  font-size: 1rem;
  font-weight: 500;
  background: var(--bg-raised);
  border: 1.5px solid var(--border);
  color: var(--text);
  padding: 11px 16px;
  min-height: 44px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.reader-controls button:hover { border-color: var(--accent-1); }
.reader-controls button.active {
  background: var(--accent-gradient);
  color: #fff;
  border-color: transparent;
}
.reader-controls label {
  font-size: 0.95rem;
  color: var(--text-muted);
}

/* ---------- Lyrics flow (continuous text, not boxed per verse) ---------- */
.lyrics-flow {
  margin: 32px 0;
  padding: 32px clamp(20px, 5vw, 48px);
  background: var(--bg-raised);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.lyrics-flow .verse-line {
  font-family: var(--font-deva);
  font-size: 1.55em;
  line-height: 1.5;
  color: var(--text);
  margin: 0;
  white-space: pre-line;
}
/* Line-to-line rhythm follows the lyric's own punctuation, since the
   source text has no blank-line stanza markers: a trailing comma means
   the line is sung in the same breath as the next one (tight), a danda
   (।) closes a line with a small pause, and a doubled danda (।।) closes
   a stanza/refrain — a real paragraph break. */
.lyrics-flow .verse-line.line-tight { margin-bottom: 0.15em; }
.lyrics-flow .verse-line.line-pause { margin-bottom: 0.65em; }
.lyrics-flow .verse-line.line-stanza-end { margin-bottom: 1.6em; }
.lyrics-flow .verse-line:last-child { margin-bottom: 0; }
.lyrics-flow .verse-line .vnum {
  font-family: var(--font-latin);
  font-size: 0.5em;
  vertical-align: super;
  color: var(--accent-2);
  margin-inline-start: 6px;
}

.section-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 48px 0 20px;
}
.section-heading h2 { margin: 0; }
.section-heading::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.flow-section {
  padding: 8px 4px;
}
.flow-section .entry {
  padding: 16px 0;
  border-bottom: 1px dashed var(--border);
}
.flow-section .entry:last-child { border-bottom: none; }
.flow-section .vnum-label {
  font-family: var(--font-latin);
  font-size: 0.88rem;
  color: var(--accent-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
  display: block;
  font-weight: 600;
}
.flow-section.roman .text {
  font-family: var(--font-latin);
  font-style: italic;
  color: var(--text-muted);
  font-size: 1.02em;
  white-space: pre-line;
  line-height: 1.8;
}
.flow-section.meaning .text {
  font-family: var(--font-deva);
  color: var(--text);
  font-size: 1.05em;
  line-height: 1.85;
}

body.hide-roman #transliteration-section { display: none; }
body.hide-meaning #meaning-section { display: none; }

/* ---------- Share buttons ---------- */
.share-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 0 0 22px;
  padding: 12px 16px;
  background: var(--bg-muted);
  border-radius: var(--radius-md);
  position: sticky;
  top: 73px;
  z-index: 20;
  box-shadow: var(--shadow-sm);
}
.share-row .share-label {
  font-family: var(--font-latin);
  font-size: 0.98rem;
  color: var(--text-muted);
  margin-inline-end: 4px;
}
.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  min-height: 44px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--bg-raised);
  color: var(--text);
  font-family: var(--font-latin);
  font-size: 0.98rem;
  cursor: pointer;
}
.share-btn:hover { border-color: var(--accent-1); text-decoration: none; }
.share-btn svg { width: 19px; height: 19px; flex-shrink: 0; }
.share-btn.whatsapp:hover { border-color: #25D366; color: #128C3E; }
.share-btn.facebook:hover { border-color: #1877F2; color: #1456B0; }

/* ---------- Video embed ---------- */
.video-embed {
  margin: 28px 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.video-embed .ratio {
  position: relative;
  width: 100%;
  padding-top: 56.25%; /* 16:9 */
  background: var(--bg-muted);
}
.video-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
/* Click-to-load facade: shows the thumbnail only, so the page doesn't pull
   YouTube's player/data on every visit — matters on limited mobile data.
   JS swaps this for the real iframe on click. */
.video-embed .yt-facade {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  padding: 0;
  cursor: pointer;
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
}
.video-embed .yt-facade .play-circle {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: rgba(20, 14, 6, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, transform 0.15s ease;
}
.video-embed .yt-facade:hover .play-circle,
.video-embed .yt-facade:focus-visible .play-circle {
  background: var(--accent-2);
  transform: scale(1.06);
}
.video-embed .yt-facade .play-circle svg { width: 30px; height: 30px; fill: #fff; margin-left: 4px; }
.video-embed .yt-facade .yt-label {
  position: absolute;
  bottom: 14px;
  left: 14px;
  background: rgba(20, 14, 6, 0.72);
  color: #fff;
  font-family: var(--font-latin);
  font-size: 0.95rem;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
}

/* ---------- Info panel (origin / when sung) ---------- */
.info-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin: 24px 0 36px;
}
.info-panel .card {
  background: var(--accent-soft);
  border-radius: var(--radius-md);
  padding: 18px 20px;
}
.info-panel .card h3 {
  font-family: var(--font-latin);
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-2);
  margin-bottom: 8px;
}
.info-panel .card p {
  font-family: var(--font-deva);
  color: var(--text);
  margin: 0;
  font-size: 1.08rem;
  line-height: 1.6;
}

/* ---------- FAQ ---------- */
.faq { margin: 40px 0; }
.faq-item {
  border-bottom: 1px solid var(--border);
}
.faq-item summary {
  cursor: pointer;
  padding: 18px 4px;
  min-height: 44px;
  font-family: var(--font-deva);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: "+";
  font-family: var(--font-latin);
  font-size: 1.5rem;
  color: var(--accent-2);
  margin-left: 12px;
}
.faq-item[open] summary::after { content: "\2212"; }
.faq-item p {
  padding: 0 4px 18px;
  color: var(--text-muted);
  font-family: var(--font-deva);
  font-size: 1.05rem;
  line-height: 1.65;
}

/* ---------- Related / breadcrumb ---------- */
.breadcrumb {
  font-size: 1rem;
  color: var(--text-faint);
  margin: 18px 0;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb .sep { margin: 0 6px; }

.related {
  margin: 48px 0;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 13px 22px;
  min-height: 44px;
  border-radius: var(--radius-sm);
  font-size: 1.02rem;
  font-family: var(--font-latin);
  border: 1.5px solid var(--border);
  background: var(--bg-raised);
  color: var(--text);
  cursor: pointer;
}
.btn-primary {
  background: var(--accent-gradient);
  color: #fff;
  border-color: transparent;
  font-weight: 600;
}
.btn:hover { border-color: var(--accent-1); text-decoration: none; }

/* ---------- Pagination (hub/bhajan-listing page) ---------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 40px 0;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}
.pagination-status {
  font-family: var(--font-latin);
  color: var(--text-muted);
  font-size: 1.02rem;
  font-weight: 500;
  white-space: nowrap;
}
span.pagination-btn {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 80px;
  padding: 40px 0;
  color: var(--text-faint);
  font-size: 1rem;
  line-height: 1.6;
}
.site-footer a {
  color: var(--text-muted);
  padding: 6px 2px;
  display: inline-block;
}
.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin-bottom: 16px;
}

/* ---------- Print ---------- */
@media print {
  .site-header, .reader-controls, .share-row, .site-footer, .related, .faq, nav, .skip-link { display: none !important; }
  body { background: #fff; color: #000; background-image: none; }
  .lyrics-flow { border: none; box-shadow: none; padding: 8px 0; }
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  :root { --body-size: 21px; }

  /* Hamburger nav: collapses the 3 links into a dropdown instead of
     stacking them full-height in the header on every page. */
  .nav-toggle { display: flex; }
  nav.main-nav {
    display: none;
    position: absolute;
    top: calc(100% + 1px);
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 2px;
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: 8px;
  }
  nav.main-nav.open { display: flex; }
  nav.main-nav a { width: 100%; padding: 13px 14px; }

  .hero { padding: 32px 0 28px; }
  .category-group { margin: 32px 0; }
  .site-footer { margin-top: 56px; padding: 32px 0; }

  /* Share buttons: a steady 2-column grid (WhatsApp + Facebook). */
  .share-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .share-row .share-label { grid-column: 1 / -1; margin-bottom: -2px; }
  .share-btn { justify-content: center; width: 100%; }

  .lyrics-flow { padding: 22px 18px; margin: 24px 0; }
  .lyrics-flow .verse-line { font-size: 1.35em; }
  .btn { width: 100%; justify-content: center; }
  .reader-controls .group { width: 100%; justify-content: space-between; border-right: none; padding-right: 0; }

  .pagination { flex-direction: column; align-items: stretch; gap: 12px; }
  .pagination-status { text-align: center; order: -1; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
