/* guide/guide.css — Chanting Rules guide. Self-contained page, own theme
   (warm manuscript palette, matching daily/daily.css's spirit), light/dark
   via prefers-color-scheme + a manual toggle. */

:root {
  --bg: #17100a;
  --panel: #1f160d;
  --panel2: #241a0e;
  --ink: #f3e6cb;
  --ink2: #d8c7a0;
  --muted: #b79a63;
  --accent: #c8a84b;
  --accent2: #e0b85a;
  --line: rgba(200, 168, 75, 0.22);
  --shadow: 0 18px 46px rgba(0, 0, 0, 0.45);
  --warn: #e0763a;
  --font-body: "Noto Sans Telugu", "Noto Serif Devanagari", "Georgia", serif;
  --font-ui: -apple-system, "Segoe UI", Roboto, sans-serif;
}
:root[data-theme="light"] {
  --bg: #f4ecd8; --panel: #fbf5e6; --panel2: #f4ecd8; --ink: #3a2a12; --ink2: #5a4322;
  --muted: #8a6d34; --accent: #a87f24; --accent2: #8b6a1c;
  --line: rgba(120, 90, 20, 0.22); --shadow: 0 14px 36px rgba(90, 60, 10, 0.18);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f4ecd8; --panel: #fbf5e6; --panel2: #f4ecd8; --ink: #3a2a12; --ink2: #5a4322;
    --muted: #8a6d34; --accent: #a87f24; --accent2: #8b6a1c;
    --line: rgba(120, 90, 20, 0.22); --shadow: 0 14px 36px rgba(90, 60, 10, 0.18);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { background: var(--bg); color: var(--ink); }
body {
  font-family: var(--font-body);
  min-height: 100vh;
  padding-bottom: 3rem;
}

.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: .8rem 1rem;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.top-left { display: flex; align-items: center; gap: .6rem; font-family: var(--font-ui); }
.back { color: var(--ink2); text-decoration: none; font-size: 1.1rem; }
.brand { color: var(--muted); font-size: .85rem; text-decoration: none; }
.top-right { display: flex; align-items: center; gap: .5rem; }

.script-toggle, .theme-toggle { display: flex; gap: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 2px; }
.script-toggle button, .theme-toggle button {
  font-family: var(--font-ui); font-size: .72rem; padding: 4px 9px; border-radius: 16px;
  border: none; background: none; color: var(--muted); cursor: pointer;
}
.script-toggle button.active, .theme-toggle button.active { background: var(--accent); color: #1a1208; font-weight: 600; }

.hero { max-width: 680px; margin: 0 auto; padding: 1.5rem 1rem 1rem; text-align: center; }
.hero h1 { font-size: 1.4rem; color: var(--accent2); margin-bottom: .4rem; }
.hero p { font-size: .85rem; color: var(--muted); line-height: 1.5; font-family: var(--font-ui); }

.search-wrap { max-width: 680px; margin: 0 auto 1rem; padding: 0 1rem; }
.search-input {
  width: 100%; padding: .6rem .9rem; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink); font-size: .9rem; font-family: var(--font-ui);
}
.search-input::placeholder { color: var(--muted); }

.toc { max-width: 680px; margin: 0 auto 1.5rem; padding: 0 1rem; display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.toc a {
  font-family: var(--font-ui); font-size: .75rem; color: var(--muted); text-decoration: none;
  border: 1px solid var(--line); border-radius: 20px; padding: 4px 10px;
}
.toc a:hover { color: var(--accent2); border-color: var(--accent); }

main { max-width: 680px; margin: 0 auto; padding: 0 1rem; display: flex; flex-direction: column; gap: 1.2rem; }

.section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.2rem 1.1rem;
  box-shadow: var(--shadow);
  scroll-margin-top: 4.5rem;
}
.section.draft { border-style: dashed; }
.section-head {
  display: flex; align-items: baseline; gap: .5rem; margin-bottom: .7rem;
  cursor: pointer; list-style: none; position: relative; padding-right: 1.6rem;
}
.section-head::-webkit-details-marker { display: none; }
.section-head::after {
  content: '▾'; position: absolute; right: 0; top: 0; color: var(--muted);
  transition: transform .15s;
}
details:not([open]) .section-head { margin-bottom: 0; }
details:not([open]) .section-head::after { transform: rotate(-90deg); }
.section-icon { font-size: 1.2rem; }
.section-title { font-size: 1.1rem; color: var(--accent2); font-weight: 600; }
.section-title-sa { font-size: .8rem; color: var(--muted); margin-left: .3rem; }
.draft-badge {
  font-family: var(--font-ui); font-size: .65rem; color: var(--warn); border: 1px solid var(--warn);
  border-radius: 10px; padding: 1px 8px; margin-left: auto;
}

.expand-controls { max-width: 680px; margin: 0 auto .6rem; padding: 0 1rem; display: flex; gap: 8px; justify-content: flex-end; }
.expand-controls button {
  font-family: var(--font-ui); font-size: .72rem; color: var(--muted); background: var(--panel);
  border: 1px solid var(--line); border-radius: 20px; padding: 4px 10px; cursor: pointer;
}
.expand-controls button:hover { color: var(--accent2); border-color: var(--accent); }

#back-to-top {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 20;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--accent); color: #1a1208; border: none;
  font-size: 1.1rem; cursor: pointer; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transform: translateY(8px);
  transition: opacity .2s, transform .2s;
}
#back-to-top.visible { opacity: 1; pointer-events: auto; transform: translateY(0); }

.body-para { font-family: var(--font-ui); font-size: .88rem; line-height: 1.65; color: var(--ink2); margin-bottom: .6rem; }
.body-para .te { display: block; font-size: .82rem; color: var(--muted); margin-top: 2px; font-family: var(--font-body); }

.verse-card { background: var(--panel2); border-left: 3px solid var(--accent); border-radius: 8px; padding: .8rem .9rem; margin-bottom: .8rem; }
.verse-sa { font-size: 1rem; line-height: 1.7; margin-bottom: 4px; }
.verse-ro { font-size: .82rem; font-style: italic; color: var(--muted); font-family: var(--font-ui); margin-bottom: 6px; }
.verse-source { font-size: .72rem; color: var(--accent); font-family: var(--font-ui); }
.verse-translation { font-size: .82rem; color: var(--ink2); font-family: var(--font-ui); margin-top: 4px; line-height: 1.55; }

.rule-list { display: flex; flex-direction: column; gap: .55rem; }
.rule-item { border-bottom: 1px solid var(--line); padding-bottom: .55rem; }
.rule-item:last-child { border-bottom: none; padding-bottom: 0; }
.rule-item.tentative { border-left: 2px solid #6a9fd8; padding-left: 10px; margin-left: -12px; }
.tentative-tag {
  display: inline-block; font-family: var(--font-ui); font-size: .62rem; color: #6a9fd8;
  border: 1px solid #6a9fd8; border-radius: 8px; padding: 0 6px; margin-left: 6px; vertical-align: middle;
}
.rule-term { font-size: .95rem; color: var(--accent2); font-weight: 600; }
.rule-sub { font-size: .74rem; color: var(--muted); font-family: var(--font-ui); margin-left: 6px; }
.rule-sutra { font-size: .85rem; color: var(--ink); margin-top: 2px; }
.rule-letters { font-size: .8rem; color: var(--ink2); font-family: var(--font-ui); margin-top: 2px; }
.rule-en { font-size: .84rem; color: var(--ink2); font-family: var(--font-ui); margin-top: 2px; line-height: 1.5; }
.rule-warn { font-size: .78rem; color: var(--warn); font-family: var(--font-ui); margin-top: 4px; }

.example-row { display: flex; flex-wrap: wrap; gap: 8px; margin: .6rem 0; }
.example-chip { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; font-size: .82rem; }
.example-chip .ro { display: block; font-size: .72rem; color: var(--muted); font-family: var(--font-ui); }
.example-note { font-size: .74rem; color: var(--muted); font-family: var(--font-ui); }

.verse-example { background: var(--panel2); border-radius: 10px; padding: .7rem .9rem; margin-top: .6rem; }
.verse-example .ref { font-size: .72rem; color: var(--accent); font-family: var(--font-ui); }
.verse-example .text { font-size: .95rem; margin: 4px 0; }
.verse-example .note { font-size: .8rem; color: var(--ink2); font-family: var(--font-ui); line-height: 1.5; }

/* Diagrams */
.diagram-wrap { display: flex; justify-content: center; margin: .8rem 0 1rem; }
.diagram-wrap svg { max-width: 100%; height: auto; }
.diagram-label { font-family: var(--font-ui); font-size: 10px; fill: var(--ink2); }
.diagram-label-strong { font-family: var(--font-ui); font-size: 11px; font-weight: 600; fill: var(--accent2); }

.ref-list { display: flex; flex-direction: column; gap: 0; margin-top: .6rem; }
.ref-row { padding: 10px 0; border-bottom: 1px solid var(--line); }
.ref-row:last-child { border-bottom: none; }
.ref-source { font-family: var(--font-ui); font-size: .72rem; color: var(--muted); margin-bottom: 3px; }
.ref-sa { font-size: .92rem; line-height: 1.65; }

@media (max-width: 480px) {
  .hero h1 { font-size: 1.15rem; }
}

[data-hidden="true"] { display: none !important; }
