/* ============================================================
   Sanatana Grantha — Ramayana page.
   Left nav (7 kandas) + right content pane (kanda overview or a
   sarga's verses). Layers on top of ../site.css. Single clean theme,
   no toggle. Shares almost all its verse-card/chapter-header/pagination
   rules verbatim with bhagavad-gita/style.css (same class names on
   purpose) — only the layout wrapper classes are renamed per page
   (.gita-* -> .ramayana-*) so both pages' left-nav/content containers
   can coexist without clashing if ever loaded together.
   ============================================================ */

.ramayana-layout {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  box-sizing: border-box;
  padding: 32px 24px 90px;
  display: flex;
  align-items: flex-start;
  gap: 32px;
}

/* ---------- Left nav ---------- */

.ramayana-nav {
  width: 240px;
  flex-shrink: 0;
  position: sticky;
  top: 84px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}

.ramayana-nav-label {
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 12px;
}

.ramayana-nav-content a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  color: var(--ink);
  font-size: 14px;
  text-decoration: none;
  margin-bottom: 2px;
  transition: background 120ms ease, color 120ms ease;
}

.ramayana-nav-content a:hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.ramayana-nav-content a.active {
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}

.chapter-num {
  font-size: 12px;
  width: 20px;
  flex-shrink: 0;
  color: var(--ink-soft);
}

.ramayana-nav-content a.active .chapter-num { color: var(--on-accent-dim); }

.chapter-name {
  flex: 1;
  line-height: 1.3;
}

.chapter-soon {
  font-size: 10px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--ink-soft);
  border: 1px dashed var(--border);
  border-radius: 50px;
  padding: 1px 7px;
  flex-shrink: 0;
}

.ramayana-nav-content a.active .chapter-soon { border-color: var(--on-accent-border); color: var(--on-accent-dim); }

/* ---------- Content pane ---------- */

.ramayana-content {
  flex: 1;
  min-width: 0;
}

.ramayana-content:focus { outline: none; }

.gita-breadcrumb {
  font-size: 12px;
  color: var(--ink-soft);
  margin: 0 0 18px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.gita-breadcrumb a { color: var(--ink-soft); text-decoration: none; }
.gita-breadcrumb a:hover { color: var(--accent); text-decoration: underline; }
.gita-breadcrumb span[aria-current] { color: var(--ink); }

.chapter-header {
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.chapter-cover {
  position: relative;
  margin: 0 0 24px;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 10px 32px rgba(var(--card-shadow-rgb), 0.16);
  aspect-ratio: 2.6 / 1;
}

.chapter-cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 40%;
  filter: saturate(1.1) contrast(1.05);
  transition: transform 500ms ease;
  transform: scale(1.001);
}

@media (prefers-color-scheme: dark) {
  .chapter-cover img {
    filter: saturate(1.05) contrast(1.12) brightness(0.82);
  }
}

@media (hover: hover) {
  .chapter-cover:hover img {
    transform: scale(1.035);
  }
}

.chapter-cover::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0) 58%, rgba(0, 0, 0, 0.42) 100%);
  pointer-events: none;
  z-index: 1;
}

.chapter-cover figcaption {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 2;
  font-size: 11px;
  line-height: 1.3;
  background: rgba(20, 14, 8, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-radius: 999px;
  padding: 5px 12px;
}

.chapter-cover figcaption a {
  color: rgba(255, 255, 255, 0.92);
  text-decoration: none;
}

.chapter-cover figcaption a:hover {
  color: #fff;
  text-decoration: underline;
}

/* ---------- Kanda overview: sliding image carousel ---------- */
/* Used instead of the single static cover above when a kanda has more
   than one verified image (see engine.js's kandaImageHTML) — same
   .chapter-cover sizing/frame, just with a horizontally sliding track
   of full-size slides inside it. */

.kanda-carousel-track {
  display: flex;
  height: 100%;
  transition: transform 600ms ease;
}

.kanda-carousel-slide {
  position: relative;
  flex-shrink: 0;
  height: 100%;
}

.kanda-carousel-slide img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 40%;
  filter: saturate(1.1) contrast(1.05);
  transition: transform 500ms ease;
  transform: scale(1.001);
}

@media (prefers-color-scheme: dark) {
  .kanda-carousel-slide img {
    filter: saturate(1.05) contrast(1.12) brightness(0.82);
  }
}

/* Every slide's figcaption is still positioned relative to the outer
   .chapter-cover figure (all slides sit in one shared bottom-right
   anchor), so only the active slide's caption may be shown — otherwise
   every slide's caption would render stacked on top of the others. */
.kanda-carousel-slide figcaption {
  opacity: 0;
  transition: opacity 300ms ease;
  pointer-events: none;
}

.kanda-carousel-slide.active figcaption {
  opacity: 1;
  pointer-events: auto;
}

.kanda-carousel-dots {
  /* Anchored top-left, not bottom — the bottom-right corner is the
     figcaption's territory, and on narrow screens its credit text
     wraps to two lines, which would otherwise collide with the dots. */
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 2;
  display: flex;
  gap: 7px;
  padding: 7px 9px;
  border-radius: 999px;
  background: rgba(20, 14, 8, 0.4);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.kanda-carousel-dot {
  width: 8px;
  height: 8px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
  cursor: pointer;
  transition: background 150ms ease, transform 150ms ease;
}

.kanda-carousel-dot:hover {
  background: rgba(255, 255, 255, 0.7);
}

.kanda-carousel-dot.active {
  background: #fff;
  transform: scale(1.2);
}

.chapter-eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 8px;
}

.chapter-header h1 {
  font-size: 30px;
  color: var(--ink);
  margin: 0 0 6px;
  font-weight: 700;
}

.chapter-title-en {
  font-size: 15px;
  color: var(--ink-soft);
  margin: 0 0 16px;
}

.chapter-summary {
  font-size: 15px;
  line-height: 1.7;
  color: var(--ink-soft);
  margin: 0 0 8px;
}

/* Standalone badge (unlike site.css's .placeholder-hero .badge, this one
   isn't nested inside that specific placeholder block — kanda overviews
   use it directly inside .chapter-header for "more sargas coming soon"). */
.badge {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 50px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin: 8px 0 0;
}

/* ---------- Kanda overview: sarga list ---------- */

.sarga-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.sarga-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 20px;
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  background: var(--verse-bg);
  color: var(--ink);
  text-decoration: none;
  transition: border-color 120ms ease, background 120ms ease;
}

.sarga-card:hover {
  border-color: var(--accent);
}

.sarga-card-num {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--accent);
}

.sarga-card-title {
  font-size: 15px;
  font-weight: 600;
}

.sarga-more-note {
  margin-top: 16px;
  font-size: 13px;
  color: var(--ink-soft);
}

/* ---------- Verses ---------- */

.verse-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chapter-pagination {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 32px;
}

.chapter-pagination-link {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 20px;
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  background: var(--verse-bg);
  color: var(--ink);
  text-decoration: none;
  transition: border-color 120ms ease, background 120ms ease;
}

.chapter-pagination-link:hover {
  border-color: var(--accent);
  color: var(--ink);
}

.chapter-pagination-link.next {
  text-align: right;
  align-items: flex-end;
}

.chapter-pagination-link.disabled {
  visibility: hidden;
}

.chapter-pagination-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--accent);
}

.chapter-pagination-title {
  font-size: 15px;
  font-weight: 600;
}

.verse {
  background: var(--verse-bg);
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  padding: 24px 28px;
  box-shadow: 0 2px 12px rgba(var(--card-shadow-rgb), 0.05);
  scroll-margin-top: 90px;
}

.verse-number-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.verse-number {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-strong);
  background: var(--accent-soft);
  padding: 2px 10px;
  border-radius: 50px;
}

.verse-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.verse-copy-link {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

.verse-copy-link:hover,
.verse-copy-link:focus-visible {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.verse-copy-link svg {
  width: 15px;
  height: 15px;
}

.verse-action-feedback {
  position: absolute;
  top: -28px;
  right: 0;
  padding: 3px 9px;
  border-radius: 6px;
  background: var(--accent-strong);
  color: var(--on-accent);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 140ms ease, transform 140ms ease;
  pointer-events: none;
}

.verse-copy-link.done {
  color: var(--accent-strong);
}

.verse-copy-link.done .verse-action-feedback {
  opacity: 1;
  transform: translateY(0);
}

.verse-scripts {
  margin-bottom: 18px;
}

.verse-sanskrit {
  font-size: 19px;
  line-height: 1.9;
  color: var(--ink);
  margin: 0 0 8px;
}

.verse-transliteration {
  font-size: 14px;
  font-style: italic;
  line-height: 1.7;
  color: var(--ink-soft);
  margin: 0;
}

.verse-telugu,
.verse-hindi,
.verse-english {
  font-size: 15px;
  line-height: 1.65;
  color: var(--ink);
  margin: 0 0 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.verse-telugu:first-of-type,
.verse-hindi:first-of-type,
.verse-english:first-of-type {
  padding-top: 0;
  border-top: none;
}

.verse-lang-label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}

/* ప్రతిపదార్థం hover/focus tooltip on each glossed Sanskrit word. */

.gloss-word {
  position: relative;
  cursor: pointer;
  border-bottom: 1px dotted var(--accent);
}

.gloss-word:focus {
  outline: none;
}

.gloss-tooltip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 9px);
  transform: translateX(-50%) translateY(4px);
  width: max-content;
  min-width: 140px;
  max-width: min(240px, 88vw);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(var(--card-shadow-rgb), 0.2);
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.12s ease, transform 0.12s ease;
  z-index: 20;
}

.gloss-word:hover .gloss-tooltip,
.gloss-word:focus .gloss-tooltip,
.gloss-word:focus-visible .gloss-tooltip {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.gloss-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--surface);
}

.gloss-tooltip-teluguscript {
  display: block;
  font-size: 14px;
  color: var(--ink);
  margin-bottom: 2px;
}

.gloss-tooltip-translit {
  display: block;
  font-size: 11px;
  font-style: italic;
  color: var(--ink-soft);
  margin-bottom: 6px;
}

.gloss-tooltip-part {
  display: block;
  color: var(--ink);
}

.gloss-tooltip-part + .gloss-tooltip-part {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px dashed var(--border);
}

/* ---------- Responsive ---------- */

@media (min-width: 720px) {
  .verse-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 32px;
  }

  .verse-scripts {
    margin-bottom: 0;
  }

  .verse-meanings {
    border-left: 1px solid var(--border);
    padding-left: 32px;
  }
}

@media (max-width: 860px) {
  .ramayana-layout {
    flex-direction: column;
    padding: 24px 16px 60px;
    gap: 20px;
  }

  .ramayana-nav {
    width: 100%;
    position: static;
    max-height: none;
  }

  .ramayana-content {
    width: 100%;
  }

  .verse { padding: 18px 18px; }

  .chapter-pagination { grid-template-columns: 1fr; }
  .chapter-pagination-link.next { text-align: left; align-items: flex-start; }
  .sarga-list { grid-template-columns: 1fr; }
}

@media print {
  .ramayana-nav, .gita-breadcrumb, .chapter-pagination, .verse-actions {
    display: none;
  }

  .ramayana-layout {
    display: block;
    padding: 0;
  }

  .verse-meanings .verse-english {
    border-left: none;
    padding-left: 0;
    border-top: 1px solid #ccc;
    padding-top: 10px;
  }
}
