/*
 * GRANTHA — reader-only stylesheet.
 * Loads only when Grantha's router served this request (see grantha.php).
 * Consumes the theme's :root tokens via var() with literal fallbacks, so a
 * reader page still renders sensibly if this plugin is ever active without
 * vedic-people-v3 (see the theme's Phase 2 notes on this coupling).
 *
 * The .content-page/.content-main/.side-stack/.side-card/.toc-body layout
 * and the .crumb breadcrumb component are NOT redefined here — they come
 * from the theme's content.css/base.css, which load on reader pages too.
 * This file only adds reader-specific pieces on top of them.
 *
 * IMPORTANT: the block marked "PRESERVED — DO NOT RENAME" near the bottom
 * styles content baked into potentially hundreds of already-published
 * chapter files by Talapatra (chapter-summary panels). Those files use the
 * OLD .grantha-toc/.grantha-toc-toggle/.grantha-toc-body class names
 * directly — renaming or removing these rules breaks every existing
 * chapter summary on the site. The book-level Contents widget above no
 * longer uses these classes (it's .side-card/.toc-body now), so this
 * block only ever matches summary panels going forward.
 */

.grantha-wrap{width:100%; margin:0 auto;}

/* Book header, above the chapter content */
.read-book-header{margin:6px 0 10px;}
.read-book-title{font:600 var(--h2-en, 1.7rem) var(--font-serif, Georgia, serif); color:var(--ink, #1a1008); margin:0;}

/* Top/bottom toolbar */
.read-toolbar{display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:10px; padding:12px 28px; background:var(--paper, #FBF6EC); border-bottom:1px solid var(--line, #E3D8C2);}
.read-toolbar--bottom{border-bottom:none; border-top:1px solid var(--line, #E3D8C2); margin-top:8px;}
.close-book{display:flex; align-items:center; gap:6px; font:400 1.2rem var(--font-ui, sans-serif); color:var(--green-deep, #0B4A2C); padding:8px 14px; background:var(--green-soft, #E1EEE4); border-radius:999px; text-decoration:none;}
.close-book:hover{background:var(--green, #10673D); color:#fff;}
.close-book svg{width:15px; height:15px;}
.chapter-nav-btns{display:flex; gap:8px; flex-wrap:wrap;}
.chapter-nav-btns a{display:inline-flex; align-items:center; gap:4px; font:400 1.2rem var(--font-ui, sans-serif); padding:8px 14px; border-radius:999px; background:var(--green-soft, #E1EEE4); color:var(--green-deep, #0B4A2C); text-decoration:none;}
.chapter-nav-btns a:hover{background:var(--green, #10673D); color:#fff;}
.chapter-nav-btns svg{width:14px; height:14px;}

/* Breadcrumb: bottom-position spacing + edition-crumb / current-chapter
   language font hints (book_format_value-driven — see reader.php). */
.crumb--bottom{margin:20px 0 8px 0;}
.grantha-bc-tel{font-family:var(--font-te, 'Mallanna', sans-serif);}
.grantha-bc-hin{font-family:var(--font-hi, 'Martel', serif);}
.grantha-lang-tel .crumb .crumb-current{font-family:var(--font-te, 'Mallanna', sans-serif);}
.grantha-lang-hin .crumb .crumb-current{font-family:var(--font-hi, 'Martel', serif);}

/* Chapter Contents widget — extends the shared .side-card/.toc-body with
   reader-specific behavior: a scroll cap (book TOCs can run to hundreds of
   chapters) and ellipsis truncation (chapter titles can run to ~512
   characters — only safe because this is plain <details>/<a>, not a
   native <select>). */
.chapter-toc-body{max-height:420px; overflow-y:auto;}
.chapter-toc-body a{white-space:normal;}

/* ── Chapter content ────────────────────────────────────────────────────────── */
.read-body{font-family:var(--font-serif, Georgia, serif); font-size:20px; line-height:1.85; color:var(--ink, #1a1008);}
.read-body p{margin-bottom:1.2em; text-align:justify; hyphens:auto;}
.read-body h1, .read-body h2, .read-body h3, .read-body h4, .read-body h5, .read-body h6{font-family:var(--font-serif, Georgia, serif); color:var(--ink, #1a1008); line-height:1.3; font-weight:700;}
.read-body h1{font-size:2.2rem; line-height:1.8; margin-top:0; margin-bottom:0.8em;}
.read-body h2{font-size:22px; margin-top:2em; margin-bottom:0.6em; border-bottom:1px solid var(--line, #E3D8C2); padding-bottom:0.3em;}
.read-body h3{font-size:19px; margin-top:1.5em; margin-bottom:0.5em;}
.read-body h4{font-size:17px; margin-top:1.25em; margin-bottom:0.4em;}

.read-body blockquote{border-left:6px solid var(--gold, #ECC843); padding-left:16px; color:var(--ink-soft, #6B6152); margin:1.5em 0; font-style:italic;}

/* Content-authored, generated by Talapatra — never rename these classes. */
.read-body blockquote.sloka-block{background-color:var(--surface, #F6F4EE); border-left-color:var(--gold, #ECC843); padding:20px; color:var(--ink, #1a1008); font-style:normal;}
.read-body blockquote.sloka-block p.Sloka,
.read-body blockquote.sloka-block p.MsoSloka{margin-top:0; margin-bottom:0; font-style:normal;}
.read-body p.MsoNormal{margin:0 0 1.2em;}

.read-body ul, .read-body ol{padding-left:1.5em; margin-bottom:1em;}
.read-body li{margin-bottom:0.4em;}

.read-body a{color:var(--green, #10673D); text-decoration:underline;}
.read-body a:hover{color:var(--vermilion, #D73C21);}

.read-body img{max-width:100%; height:auto; display:block; margin:1em auto;}

.read-body table{width:100%; border-collapse:collapse; margin:1.5em 0; font-size:0.9em;}
.read-body th, .read-body td{border:1px solid var(--line, #E3D8C2); padding:8px 12px; text-align:left;}
.read-body th{background:var(--paper-deep, #F4EAD3); font-weight:700;}

.read-body hr{border:none; border-top:1px solid var(--line, #E3D8C2); margin:2em 0;}

/* ── Language: Telugu / Hindi ──────────────────────────────────────────────── */
.grantha-lang-tel .read-book-title{font-family:var(--font-te, 'Mallanna', sans-serif);}
.grantha-lang-tel .read-body{font-family:var(--font-te, 'Mallanna', sans-serif); font-size:125%;}
.grantha-lang-tel .read-body h1, .grantha-lang-tel .read-body h2, .grantha-lang-tel .read-body h3,
.grantha-lang-tel .read-body h4, .grantha-lang-tel .read-body h5, .grantha-lang-tel .read-body h6{font-family:var(--font-te, 'Mallanna', sans-serif);}
.grantha-lang-tel .chapter-toc-body{font-family:var(--font-te, 'Mallanna', sans-serif); font-size:115%;}

.grantha-lang-hin .read-book-title{font-family:var(--font-hi, 'Martel', serif);}
.grantha-lang-hin .read-body{font-family:var(--font-hi, 'Martel', serif); font-size:125%;}
.grantha-lang-hin .read-body h1, .grantha-lang-hin .read-body h2, .grantha-lang-hin .read-body h3,
.grantha-lang-hin .read-body h4, .grantha-lang-hin .read-body h5, .grantha-lang-hin .read-body h6{font-family:var(--font-hi, 'Martel', serif);}
.grantha-lang-hin .chapter-toc-body{font-family:var(--font-hi, 'Martel', serif); font-size:115%;}

/* ── Error state ────────────────────────────────────────────────────────────── */
.grantha-error{padding:60px 40px; text-align:center; font-family:var(--font-serif, Georgia, serif); font-size:20px; color:var(--ink-soft, #6B6152); max-width:600px; margin:0 auto;}
.grantha-error p{margin-bottom:1.2em;}
.grantha-error small{font-size:14px; font-family:monospace; color:var(--ink-faint, #9C9282); opacity:0.7;}

/* ══════════════════════════════════════════════════════════════════════════
   PRESERVED — DO NOT RENAME. Chapter-summary panels (Talapatra's
   build_summary_panel(), baked into existing chapter HTML files). Copied
   unchanged from the previous grantha.css. See file header note above.
   ══════════════════════════════════════════════════════════════════════════ */
.grantha-chapter-summary {
    width:  100%;
    margin: 2.5em 0 1.5em;
    clear:  both;
}

.grantha-toc {
    border:        1px solid var(--vp-border, rgba(0,0,0,0.12));
    border-radius: var(--vp-radius, 6px);
    overflow:      hidden;
    background:    #F8F9FA;
    box-shadow:    0 1px 3px rgba(0, 0, 0, 0.07);
}

.grantha-toc-toggle {
    width:           100%;
    display:         flex;
    align-items:     center;
    justify-content: space-between;
    padding:         8px 14px;
    font-family:     var(--vp-font-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif);
    font-size:       15px;
    font-weight:     700;
    color:           #1a1008 !important;
    background:      #F3F4F6 !important;
    border:          none !important;
    border-bottom:   1px solid rgba(0, 0, 0, 0.12) !important;
    border-radius:   0 !important;
    cursor:          pointer;
    text-align:      left;
}
.grantha-toc-toggle:hover {
    background: #E8EAED !important;
}
.grantha-toc-toggle:focus-visible {
    outline:        2px solid #999;
    outline-offset: -2px;
}

.grantha-chevron {
    transition:  transform 0.2s ease;
    display:     inline-block;
    line-height: 1;
    color:       #777 !important;
}
.grantha-toc-toggle[aria-expanded="false"] .grantha-chevron {
    transform: rotate(-90deg);
}

.grantha-toc-body {
    padding:         8px 0;
    max-height:      70vh;
    overflow-y:      auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.12) transparent;
}
.grantha-toc-body.is-collapsed {
    display: none;
}

.grantha-summary-body {
    max-height: none;
    overflow-y: visible;
}

.grantha-summary-body .grantha-summary-content {
    padding: 16px;
}

.grantha-summary-body .grantha-summary-content p {
    font-family:   'Lora', serif;
    font-size:     16pt;
    line-height:   1.25;
    margin-bottom: 1em;
    text-align:    left;
    font-style:    normal;
}

.grantha-lang-tel .grantha-summary-chname { font-family: 'Mallanna', sans-serif; }
.grantha-lang-hin .grantha-summary-chname { font-family: 'Martel', serif; }
/* ══════════════════════════════════════════════════════════════════════════
   END PRESERVED BLOCK
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Mobile ─────────────────────────────────────────────────────────────────────
   Matches content.css's 960px breakpoint (where .content-page--reader's
   side-stack reorder also kicks in) — a single shared breakpoint for the
   whole reader layout instead of two slightly-offset ones. */
@media (max-width: 960px){
    .read-body{font-size:18px; line-height:1.75;}
    .read-toolbar{flex-wrap:wrap; justify-content:center;}
}

/* ── Print ──────────────────────────────────────────────────────────────────── */
@media print {
    .read-toolbar, .side-stack, .crumb { display: none !important; }
    .read-body { font-size: 12pt; line-height: 1.6; color: #000; }
    .grantha-wrap { width: 100%; padding: 0; }
}
