/* ============================================================
   Vasudev Mahatmya — shared lesson stylesheet
   Used by every lesson + reference doc in this workspace.
   Design: Tufte-ish. Wide left margin for sidenotes, generous
   line height, serif body, Gujarati/Devanagari kept legible and
   slightly larger than Latin (they need it).
   ============================================================ */

:root {
  --ink:        #1a1a18;
  --ink-soft:   #55534d;
  --ink-faint:  #8a877e;
  --paper:      #fffef9;
  --rule:       #ddd9cc;
  --saffron:    #b3541e;   /* accent — headings, marks */
  --saffron-lt: #f6ece1;
  --indigo:     #2c3e6b;   /* second accent — sanskrit, links */
  --green:      #2f6b46;   /* correct */
  --red:        #9b2c22;   /* incorrect */
  --measure:    38rem;
}

*, *::before, *::after { box-sizing: border-box; }

html { font-size: 17px; -webkit-text-size-adjust: 100%; }

body {
  margin: 0 auto;
  padding: 4rem 2rem 8rem;
  max-width: 62rem;
  background: var(--paper);
  color: var(--ink);
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  line-height: 1.62;
  counter-reset: qnum;
}

/* ---------- typography ---------- */

h1, h2, h3, h4 { font-weight: 600; line-height: 1.2; color: var(--ink); }
h1 { font-size: 2.2rem; margin: 0 0 .3rem; letter-spacing: -.01em; }
h2 {
  font-size: 1.45rem; margin: 3.2rem 0 .8rem;
  padding-bottom: .3rem; border-bottom: 1px solid var(--rule);
  max-width: var(--measure);
}
h3 { font-size: 1.12rem; margin: 2rem 0 .4rem; }
p, ul, ol, blockquote { max-width: var(--measure); }
p { margin: 0 0 1.1rem; }
li { margin-bottom: .35rem; }
a { color: var(--indigo); text-decoration: none; border-bottom: 1px solid #c3cbdd; }
a:hover { border-bottom-color: var(--indigo); }
strong { font-weight: 600; }
em { font-style: italic; }
code, .mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .88em; }

.subtitle {
  font-size: 1.12rem; color: var(--ink-soft); font-style: italic;
  margin: 0 0 .2rem; max-width: var(--measure);
}
.meta {
  font-size: .82rem; color: var(--ink-faint); letter-spacing: .04em;
  text-transform: uppercase; margin: 0 0 2.6rem;
}
.lede { font-size: 1.1rem; }
.lede::first-letter { font-size: 3rem; float: left; line-height: .82; padding: .06em .08em 0 0; color: var(--saffron); }

/* ---------- Indic scripts ---------- */

.gu, .sa {
  font-family: "Noto Sans Gujarati", "Gujarati Sangam MN", "Nirmala UI", "Shruti", sans-serif;
  font-size: 1.06em; line-height: 1.85;
}
.sa {
  font-family: "Noto Sans Devanagari", "Devanagari Sangam MN", "Nirmala UI", "Kohinoor Devanagari", serif;
  color: var(--indigo);
}
.translit { font-style: italic; color: var(--ink-soft); }

/* ---------- verse block: sanskrit → gujarati → my english ---------- */

.verse {
  margin: 1.6rem 0 2rem; padding: 1.1rem 1.3rem;
  background: #fcfaf3; border-left: 3px solid var(--saffron);
  max-width: 44rem; border-radius: 2px;
}
.verse .num {
  font-size: .74rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--saffron); display: block; margin-bottom: .5rem;
}
.verse .sa { margin: 0 0 .7rem; }
.verse .gu { margin: 0 0 .7rem; font-size: 1rem; color: #3d3b35; }
.verse .en { margin: 0; font-size: 1rem; }
.verse .en::before {
  content: "→ "; color: var(--saffron); font-weight: 600;
}
.verse .note {
  margin: .8rem 0 0; padding-top: .7rem; border-top: 1px dotted var(--rule);
  font-size: .9rem; color: var(--ink-soft);
}
.mine {
  font-size: .72rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-faint); border: 1px solid var(--rule);
  padding: .08em .4em; border-radius: 2px; margin-left: .4rem; vertical-align: .12em;
}

/* ---------- callouts ---------- */

.callout {
  margin: 1.8rem 0; padding: 1rem 1.2rem; max-width: 44rem;
  background: var(--saffron-lt); border-radius: 3px;
  border: 1px solid #ecdcc9;
}
.callout h3 { margin: 0 0 .4rem; font-size: .95rem; letter-spacing: .04em; text-transform: uppercase; color: var(--saffron); }
.callout p:last-child { margin-bottom: 0; }
.callout.plain { background: #f7f6f0; border-color: var(--rule); }
.callout.plain h3 { color: var(--ink-soft); }

/* ---------- cast cards ---------- */

.cast {
  display: grid; gap: 1rem; margin: 1.6rem 0 2.4rem;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  max-width: 62rem;
}
.card {
  border: 1px solid var(--rule); border-radius: 4px; padding: .95rem 1.05rem;
  background: #fffdf6;
}
.card .role {
  font-size: .7rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--saffron); display: block; margin-bottom: .25rem;
}
.card h4 { margin: 0 0 .1rem; font-size: 1.05rem; }
.card .native { font-size: .95rem; color: var(--ink-soft); margin: 0 0 .5rem; }
.card p { font-size: .9rem; margin: 0 0 .5rem; max-width: none; }
.card ul { font-size: .86rem; margin: .3rem 0 0; padding-left: 1.1rem; max-width: none; }
.card .aka { font-size: .82rem; color: var(--ink-faint); }

/* ---------- diagram ---------- */

figure { margin: 2.2rem 0; max-width: 62rem; }
figure svg { width: 100%; height: auto; display: block; }
figcaption {
  font-size: .86rem; color: var(--ink-soft); margin-top: .6rem;
  max-width: var(--measure); line-height: 1.5;
}

/* ---------- tables ---------- */

table { border-collapse: collapse; font-size: .92rem; margin: 1.6rem 0; width: 100%; max-width: 56rem; }
th, td { text-align: left; padding: .5rem .7rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { font-size: .76rem; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-faint); font-weight: 600; }
tbody tr:hover { background: #fbf9f1; }

/* ---------- quiz widget (assets/quiz.js) ---------- */

.quiz { margin: 2rem 0; max-width: 46rem; }
.quiz-q {
  counter-increment: qnum; margin: 0 0 1.5rem;
  padding: 1rem 1.2rem; border: 1px solid var(--rule);
  border-radius: 4px; background: #fffdf6;
}
.quiz-q > .q {
  font-weight: 600; margin: 0 0 .8rem; max-width: none;
}
.quiz-q > .q::before {
  content: counter(qnum) ". "; color: var(--saffron);
}
.quiz-opts { list-style: none; margin: 0; padding: 0; max-width: none; }
.quiz-opts li { margin: 0 0 .45rem; }
.quiz-opts button {
  width: 100%; text-align: left; cursor: pointer;
  font-family: inherit; font-size: .95rem; line-height: 1.4;
  padding: .55rem .8rem; border: 1px solid var(--rule);
  background: var(--paper); border-radius: 3px; color: var(--ink);
  transition: background .12s, border-color .12s;
}
.quiz-opts button:hover:not(:disabled) { background: #f4f1e6; border-color: #c9c4b2; }
.quiz-opts button:disabled { cursor: default; }
.quiz-opts button.correct { background: #eaf3ed; border-color: var(--green); color: var(--green); font-weight: 600; }
.quiz-opts button.wrong   { background: #f8ecea; border-color: var(--red);   color: var(--red); text-decoration: line-through; }
.quiz-fb {
  margin: .8rem 0 0; font-size: .92rem; padding: .6rem .8rem;
  border-radius: 3px; background: #f7f6f0; display: none;
}
.quiz-fb.show { display: block; }
.quiz-score {
  font-size: .95rem; padding: .8rem 1rem; border-radius: 4px;
  background: var(--saffron-lt); border: 1px solid #ecdcc9; display: none;
}
.quiz-score.show { display: block; }

/* ---------- recall / self-test prompt ---------- */

.recall {
  margin: 2rem 0; padding: 1.1rem 1.3rem; max-width: 46rem;
  border: 2px dashed #d9d3bf; border-radius: 4px; background: #fffdf4;
}
.recall h3 { margin: 0 0 .5rem; font-size: .95rem; text-transform: uppercase; letter-spacing: .05em; color: var(--saffron); }
.reveal { margin-top: .7rem; }
.reveal summary { cursor: pointer; font-size: .9rem; color: var(--indigo); }
.reveal[open] summary { margin-bottom: .5rem; }

/* ---------- nav / footer ---------- */

.crumbs { font-size: .82rem; color: var(--ink-faint); margin: 0 0 2rem; }
.crumbs a { border: none; }
.next {
  margin: 3.5rem 0 0; padding: 1.2rem 1.4rem; max-width: 46rem;
  border-top: 3px solid var(--saffron); background: #fbf9f1;
}
.next h3 { margin: 0 0 .5rem; font-size: 1rem; }
footer {
  margin-top: 4rem; padding-top: 1.2rem; border-top: 1px solid var(--rule);
  font-size: .82rem; color: var(--ink-faint); max-width: 46rem;
}
footer a { color: var(--ink-soft); }

/* ---------- print ---------- */

@media print {
  html { font-size: 11.5pt; }
  body { padding: 0; max-width: none; background: #fff; }
  .quiz-opts button { border-color: #bbb; }
  .quiz-fb, .quiz-score { display: block !important; }
  .reveal { display: block; }
  .reveal[open] summary, .reveal summary { list-style: none; }
  details > * { display: block !important; }
  a { color: #000; border: none; }
  h2 { page-break-after: avoid; }
  .verse, .card, .quiz-q, figure { page-break-inside: avoid; }
}

@media (max-width: 40rem) {
  body { padding: 2rem 1.1rem 5rem; }
  h1 { font-size: 1.7rem; }
}

/* ============================================================
   READER COMPONENTS — used by reference reading pages.
   A sticky shlok rail, speaker-coloured verse cards, and a
   toolbar that toggles script visibility. Reusable per adhyaay.
   ============================================================ */

:root {
  --sp-shaunak: #2c3e6b;   /* asks, present day  */
  --sp-sauti:   #5d5a4f;   /* narrator           */
  --sp-savarni: #1f6b63;   /* asks, long ago     */
  --sp-kartik:  #b3541e;   /* answers, long ago  */
}

.reader { display: grid; grid-template-columns: 5.5rem minmax(0, 1fr); gap: 2rem; align-items: start; }

/* --- toolbar --- */
.toolbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; flex-wrap: wrap; gap: .4rem; align-items: center;
  padding: .7rem 0 .7rem; margin: 0 0 1.6rem;
  background: linear-gradient(var(--paper) 72%, rgba(255,254,249,0));
}
.toolbar button {
  font-family: inherit; font-size: .82rem; cursor: pointer;
  padding: .32rem .7rem; border-radius: 999px;
  border: 1px solid var(--rule); background: var(--paper); color: var(--ink-soft);
}
.toolbar button[aria-pressed="true"] {
  background: var(--saffron); border-color: var(--saffron); color: #fff;
}
.toolbar .spacer { flex: 1 1 2rem; }
.toolbar .count { font-size: .8rem; color: var(--ink-faint); letter-spacing: .05em; }

/* --- shlok rail --- */
.rail { position: sticky; top: 4.2rem; }
.rail ol { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: .3rem; }
.rail a {
  display: block; text-align: center; border: 1px solid var(--rule); border-radius: 3px;
  font-size: .78rem; padding: .22rem 0; color: var(--ink-soft); background: #fffdf6;
}
.rail a:hover { background: #f2efe3; }
.rail a.on { color: #fff; }
.rail a.sp-shaunak.on { background: var(--sp-shaunak); border-color: var(--sp-shaunak); }
.rail a.sp-sauti.on   { background: var(--sp-sauti);   border-color: var(--sp-sauti); }
.rail a.sp-savarni.on { background: var(--sp-savarni); border-color: var(--sp-savarni); }
.rail a.sp-kartik.on  { background: var(--sp-kartik);  border-color: var(--sp-kartik); }
.rail a.here { outline: 2px solid var(--saffron); outline-offset: 1px; }
.rail .legend { margin-top: .9rem; font-size: .68rem; line-height: 1.5; color: var(--ink-faint); }
.rail .legend i { display: inline-block; width: .55rem; height: .55rem; border-radius: 2px; margin-right: .25rem; }

/* --- verse cards --- */
.vcard {
  scroll-margin-top: 5rem;
  border: 1px solid var(--rule); border-left-width: 4px; border-radius: 5px;
  background: #fffdf6; padding: 1rem 1.2rem; margin: 0 0 1.1rem; max-width: 48rem;
}
.vcard.sp-shaunak { border-left-color: var(--sp-shaunak); }
.vcard.sp-sauti   { border-left-color: var(--sp-sauti); }
.vcard.sp-savarni { border-left-color: var(--sp-savarni); }
.vcard.sp-kartik  { border-left-color: var(--sp-kartik); }

.vcard header { display: flex; align-items: baseline; gap: .6rem; margin-bottom: .6rem; }
.vcard .badge {
  font-size: .72rem; letter-spacing: .06em; color: var(--ink-faint);
  border: 1px solid var(--rule); border-radius: 999px; padding: .1rem .5rem; white-space: nowrap;
}
.vcard .chip { font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; font-weight: 600; }
.vcard.sp-shaunak .chip { color: var(--sp-shaunak); }
.vcard.sp-sauti   .chip { color: var(--sp-sauti); }
.vcard.sp-savarni .chip { color: var(--sp-savarni); }
.vcard.sp-kartik  .chip { color: var(--sp-kartik); }
.vcard .said { font-size: .78rem; color: var(--ink-faint); }

.vcard .sa, .vcard .gu { margin: 0 0 .7rem; max-width: none; }
.vcard .gu { font-size: 1rem; color: #3a3833; }
.vcard .gist {
  margin: .7rem 0 0; padding-top: .65rem; border-top: 1px dotted var(--rule);
  font-size: .93rem; color: var(--ink-soft); max-width: none;
}
.vcard .gist strong { color: var(--ink); }
body.hide-sa .vcard .sa { display: none; }
body.hide-gu .vcard .gu { display: none; }
body.hide-gist .vcard .gist { display: none; }

.iti-line {
  margin: 2rem 0 0; padding: 1rem 1.2rem; max-width: 48rem;
  background: var(--saffron-lt); border: 1px solid #ecdcc9; border-radius: 5px;
}
.iti-line p { margin: 0 0 .4rem; max-width: none; }
.iti-line p:last-child { margin: 0; }

@media (max-width: 52rem) {
  .reader { grid-template-columns: 1fr; }
  .rail { position: static; }
  .rail ol { grid-template-columns: repeat(7, 1fr); }
}
@media print {
  .reader { display: block; }
  .rail, .toolbar { display: none; }
  body.hide-sa .vcard .sa, body.hide-gu .vcard .gu, body.hide-gist .vcard .gist { display: block; }
}
