/* Т. Субба Роу — сайт для чтения. Шрифты: Source Serif 4, Golos Text (OFL, site/fonts).
   Латиница с санскритской диакритикой (ā ī ū ṛ ṇ ṭ ḍ ṣ ḥ ṃ ś ṅ) — в *-ext.woff2.
   Палитра: пальмовый лист и охра; ночью — тёмный индиго. */
@font-face { font-family: 'SR Serif'; font-weight: 400; font-display: swap; src: url(fonts/serif-400-lat.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122, U+2190-21FF, U+2212; }
@font-face { font-family: 'SR Serif'; font-weight: 400; font-display: swap; src: url(fonts/serif-400-ext.woff2) format('woff2'); unicode-range: U+0100-0130, U+0132-0151, U+0154-02BA, U+02BD-02FF, U+0300-036F, U+1D00-1DBF, U+1E00-1EFF, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'SR Serif'; font-weight: 400; font-display: swap; src: url(fonts/serif-400-cyr.woff2) format('woff2'); unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'SR Serif'; font-weight: 400; font-style: italic; font-display: swap; src: url(fonts/serif-400i-lat.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122, U+2190-21FF, U+2212; }
@font-face { font-family: 'SR Serif'; font-weight: 400; font-style: italic; font-display: swap; src: url(fonts/serif-400i-ext.woff2) format('woff2'); unicode-range: U+0100-0130, U+0132-0151, U+0154-02BA, U+02BD-02FF, U+0300-036F, U+1D00-1DBF, U+1E00-1EFF, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'SR Serif'; font-weight: 400; font-style: italic; font-display: swap; src: url(fonts/serif-400i-cyr.woff2) format('woff2'); unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'SR Serif'; font-weight: 600; font-display: swap; src: url(fonts/serif-600-lat.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122, U+2190-21FF, U+2212; }
@font-face { font-family: 'SR Serif'; font-weight: 600; font-display: swap; src: url(fonts/serif-600-ext.woff2) format('woff2'); unicode-range: U+0100-0130, U+0132-0151, U+0154-02BA, U+02BD-02FF, U+0300-036F, U+1D00-1DBF, U+1E00-1EFF, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'SR Serif'; font-weight: 600; font-display: swap; src: url(fonts/serif-600-cyr.woff2) format('woff2'); unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'SR Sans'; font-weight: 400; font-display: swap; src: url(fonts/golos-400-lat.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122, U+2190-21FF, U+2212; }
@font-face { font-family: 'SR Sans'; font-weight: 400; font-display: swap; src: url(fonts/golos-400-ext.woff2) format('woff2'); unicode-range: U+0100-02BA, U+02BD-02FF; }
@font-face { font-family: 'SR Sans'; font-weight: 400; font-display: swap; src: url(fonts/golos-400-cyr.woff2) format('woff2'); unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'SR Sans'; font-weight: 600; font-display: swap; src: url(fonts/golos-600-lat.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122, U+2190-21FF, U+2212; }
@font-face { font-family: 'SR Sans'; font-weight: 600; font-display: swap; src: url(fonts/golos-600-ext.woff2) format('woff2'); unicode-range: U+0100-02BA, U+02BD-02FF; }
@font-face { font-family: 'SR Sans'; font-weight: 600; font-display: swap; src: url(fonts/golos-600-cyr.woff2) format('woff2'); unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }

:root {
  --bg: #F2EEE4; --paper: #FAF8F2; --ink: #26231F; --muted: #6E675D; --line: #DED7C8;
  --accent: #8A3F12; --accent-ink: #FAF8F2; --mark: #F1E2CC; --quote: #F5F0E4;
  --serif: 'SR Serif', 'Iowan Old Style', 'PT Serif', Georgia, serif;
  --sans: 'SR Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --deva: 'Noto Serif Devanagari', 'Noto Sans Devanagari', 'Kohinoor Devanagari', 'Devanagari MT', 'Mangal', serif;
  --fs: clamp(17px, 0.95rem + 0.4vw, 20px);
  --measure: 36em;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) {
    --bg: #14151C; --paper: #1B1D26; --ink: #E6E2D8; --muted: #9D998F; --line: #30323E;
    --accent: #E3A86E; --accent-ink: #14151C; --mark: #3A2C1E; --quote: #20222C;
    color-scheme: dark;
  }
}
:root[data-theme=dark] {
  --bg: #14151C; --paper: #1B1D26; --ink: #E6E2D8; --muted: #9D998F; --line: #30323E;
  --accent: #E3A86E; --accent-ink: #14151C; --mark: #3A2C1E; --quote: #20222C;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 400 var(--fs)/1.62 var(--serif); -webkit-font-smoothing: antialiased; overflow-wrap: break-word; }
a { color: var(--accent); text-underline-offset: .15em; text-decoration-thickness: 1px; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
img { max-width: 100%; height: auto; }

/* шапка */
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; display: flex; align-items: center; justify-content: space-between;
  gap: 8px 16px; flex-wrap: wrap; padding: 8px max(16px, env(safe-area-inset-right, 0px)) 8px max(16px, env(safe-area-inset-left, 0px));
  font: 400 14px/1.3 var(--sans); background: var(--paper); border-bottom: 1px solid var(--line); }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--paper); }
.top .brand { color: var(--ink); text-decoration: none; font: 600 15px/1.3 var(--serif); letter-spacing: .01em; }
.nav { display: flex; align-items: center; gap: 4px 14px; flex-wrap: wrap; }
.nav a { color: var(--muted); text-decoration: none; }
.nav a:hover { color: var(--accent); }
.langs { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.langs a { padding: 3px 9px; font: 600 12px/1.4 var(--sans); letter-spacing: .04em; color: var(--muted); }
.langs a.on { background: var(--ink); color: var(--paper); }
.theme { display: grid; place-items: center; background: none; border: 1px solid var(--line); border-radius: 999px; width: 30px; height: 30px; padding: 0; cursor: pointer; color: var(--ink); }
.theme svg { width: 16px; height: 16px; }

/* общее для страниц */
main { padding: 32px max(16px, env(safe-area-inset-right, 0px)) 80px max(16px, env(safe-area-inset-left, 0px)); }
.eyebrow { font: 400 13px/1.4 var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0; }
.eyebrow a { color: inherit; text-decoration: none; }
.eyebrow a:hover { color: var(--accent); }
.lede { color: var(--muted); max-width: 40em; }
h1, h2, h3 { text-wrap: balance; }
.cta { display: inline-block; font: 600 15px/1 var(--sans); padding: 12px 18px; border-radius: 6px; background: var(--accent); color: var(--accent-ink); text-decoration: none; border: 1px solid var(--accent); }
.cta.ghost { background: transparent; color: var(--accent); }
.ctas { display: flex; flex-wrap: wrap; gap: 10px; margin: 24px 0 0; }

/* стартовая: книга крупно */
.start { max-width: 68rem; margin: 0 auto; display: grid; gap: 56px; }
.feature { display: grid; grid-template-columns: minmax(0, 4fr) minmax(0, 7fr); gap: 48px; align-items: center; }
.cover { display: block; justify-self: center; max-width: 340px; transform: rotate(-1.2deg); transition: transform .2s ease; }
.cover:hover { transform: rotate(0deg); }
.cover img { display: block; width: 100%; border-radius: 2px 6px 6px 2px; border: 1px solid var(--line);
  box-shadow: inset 6px 0 10px -6px rgba(0,0,0,.25), 0 1px 2px rgba(0,0,0,.08), 0 14px 34px -12px rgba(60,35,10,.45); }
.feature-text h1 { font: 400 clamp(34px, 3.2vw + 16px, 60px)/1.06 var(--serif); margin: 10px 0 14px; letter-spacing: -.005em; }
.feature-text h1 a { color: var(--ink); text-decoration: none; }
.feature-text h1 a:hover { color: var(--accent); }
.feature-text .subtitle { font-style: italic; color: var(--muted); margin: 0 0 16px; }
.feature-text .lede p { margin: 0 0 .8em; }
.feature-text .edition { font: 400 13px/1.5 var(--sans); color: var(--muted); margin: 18px 0 0; }
.author-teaser { max-width: var(--measure); border-top: 1px solid var(--line); padding-top: 28px; }
.author-teaser h2, .start .books h2 { font: 600 13px/1.4 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 12px; }
.author-teaser p { margin: 0 0 .8em; }
.author-teaser .more { font: 600 15px/1.4 var(--sans); text-decoration: none; }
.nav a[aria-current=page]:not(.lang) { color: var(--ink); }
@media (max-width: 760px) {
  .feature { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .cover { max-width: 230px; }
  body:not(.pg-start):not(.pg-author) .nav .author-link { display: none; }
}

/* автор */
.author-page { max-width: var(--measure); margin: 0 auto; display: grid; gap: 40px; }
.who h1 { font: 400 clamp(36px, 3.2vw + 16px, 58px)/1.05 var(--serif); margin: 8px 0 6px; }
.who .full { margin: 0; color: var(--muted); font-style: italic; }
.books h2, .toc h2 { font: 600 13px/1.4 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 14px; }
.books ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.bookcard a { display: grid; gap: 6px; padding: 20px 22px; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; color: var(--ink); text-decoration: none; }
.bookcard a:hover { border-color: var(--accent); }
.bookcard .bt { font: 400 1.5em/1.2 var(--serif); }
.bookcard .bs { color: var(--muted); font-size: .95em; }
.bookcard .be { font: 400 13px/1.4 var(--sans); color: var(--muted); }

/* книга */
.home { max-width: var(--measure); margin: 0 auto; display: grid; gap: 48px; }
.hero h1 { font: 400 clamp(32px, 3vw + 14px, 52px)/1.1 var(--serif); margin: 10px 0 12px; }
.hero .author { font-size: 1.15em; margin: 0 0 12px; }
.hero .author a { color: var(--ink); text-decoration: none; }
.hero .subtitle { font-style: italic; color: var(--muted); margin: 0 0 16px; }
.hero .lede p { margin: 0 0 .8em; }
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc li a { display: grid; grid-template-columns: 2.2em minmax(0, 1fr) auto; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.toc li a:hover .t { color: var(--accent); }
.toc .t small { display: block; font: 400 13px/1.4 var(--sans); color: var(--muted); }
.toc .n, .toc .p { font: 400 13px/1.9 var(--sans); color: var(--muted); font-variant-numeric: tabular-nums; }

/* чтение */
.reader { max-width: calc(var(--measure) + 8rem); margin: 0 auto; }
.where { font: 400 13px/1.4 var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); max-width: var(--measure); margin: 0 auto 8px; }
.where a { color: inherit; text-decoration: none; }
.where a:hover { color: var(--accent); }
.text { max-width: var(--measure); margin: 0 auto; }
.text p { margin: 0; text-indent: 1.5em; hyphens: auto; -webkit-hyphens: auto; }
.text h1 + p, .text h2 + p, .text h3 + p, .text h4 + p, .text .pgb + p, .text blockquote + p { text-indent: 0; }
.text h1, .text h2, .text h3, .text h4 { font-weight: 400; text-align: center; margin: 1.6em 0 .6em; line-height: 1.3; }
.text h1 { font-size: 1.15em; letter-spacing: .08em; color: var(--muted); }
.text h2 { font-size: 1.35em; letter-spacing: .1em; margin-top: 1.2em; }
.text h3 { font-size: 1.05em; letter-spacing: .12em; margin: .2em 0 1.2em; }
.text em { font-style: italic; }
.text blockquote { margin: .9em 0 1em; padding: .6em 1em .6em 1.1em; background: var(--quote); border-left: 2px solid var(--accent); font-size: .94em; border-radius: 0 4px 4px 0; }
.text blockquote p { text-indent: 0; }
.text blockquote p + p { margin-top: .5em; }
.text .tbl { overflow-x: auto; margin: .8em 0 1em; }
.text table { border-collapse: collapse; font-size: .9em; margin: 0 auto; }
.text td, .text th { padding: 3px 14px 3px 0; vertical-align: top; text-align: left; border-bottom: 1px solid var(--line); }
.text.title p { text-indent: 0; text-align: center; }
.text.appreciation p:last-child { text-align: right; font-variant: small-caps; }
a.term { color: inherit; text-decoration: underline dotted var(--muted); text-decoration-thickness: 1px; text-underline-offset: .2em; }
a.term:hover { color: var(--accent); text-decoration-color: var(--accent); }
/* метка страницы оригинала: на полях на широком экране, в строке — на узком */
.pg { font: 400 11px/1 var(--sans); color: var(--muted); text-indent: 0; font-variant-numeric: tabular-nums; font-style: normal; }
.pg a { color: inherit; text-decoration: none; border: 1px solid var(--line); border-radius: 3px; padding: 1px 4px; background: var(--paper); }
.pg a:hover { color: var(--accent); border-color: var(--accent); }
.pg.static { border: 1px solid var(--line); border-radius: 3px; padding: 1px 4px; }
.text .pgb { height: 0; }
.pg, .notes li, sup.fnref, h1, h2, h3, h4, .text p, .term-row { scroll-margin-top: 72px; }
@media (min-width: 60rem) {
  .text { position: relative; }
  .text .pg { position: absolute; left: -4.5rem; width: 3.6rem; text-align: right; margin-top: .45em; }
  .text blockquote .pg { left: -4.5rem; }
}
@media (max-width: 59.99rem) {
  .text .pg { margin: 0 .3em; vertical-align: .15em; }
  .text .pgb { height: auto; text-align: right; }
}
.text p:target { background: var(--mark); }
sup.fnref { font: 600 .66em/0 var(--sans); padding: 0 .1em; }
sup.fnref a { text-decoration: none; }
.notes { max-width: var(--measure); margin: 2.5em auto 0; border-top: 1px solid var(--line); padding-top: 1em; font-size: .88em; }
.notes h2 { font: 600 13px/1.4 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 .6em; }
.notes ol { padding-left: 1.6em; margin: 0; }
.notes li { margin: 0 0 .5em; }
.notes li:target, sup.fnref:target { background: var(--mark); }
.notes .back { text-decoration: none; margin-left: .2em; }
.pager { max-width: var(--measure); margin: 3em auto 0; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.pager a { display: grid; gap: 2px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); text-decoration: none; color: var(--ink); }
.pager a:hover { border-color: var(--accent); }
.pager .next { text-align: right; grid-column: 2; }
.pager .dir { font: 400 12px/1.3 var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.pager .t { font-size: .95em; line-height: 1.35; }

/* словарь */
.glossary h1, .about h1 { font: 400 clamp(28px, 2vw + 16px, 40px)/1.15 var(--serif); margin: 6px 0 10px; }
.terms { margin: 28px 0 0; }
.term-row { padding: 14px 0 12px; border-top: 1px solid var(--line); }
.term-row:target { background: var(--mark); box-shadow: 0 0 0 8px var(--mark); }
.term-row dt { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; }
.term-row .iast { font: 600 1.12em/1.3 var(--serif); }
.term-row .deva { font: 400 1.1em/1.3 var(--deva); color: var(--muted); }
.term-row .ru { margin-left: auto; font-size: 1.02em; }
.term-row dd { margin: 4px 0 0; }
.term-row dd p { margin: 0 0 .35em; }
.term-row .forms { font: 400 14px/1.45 var(--sans); color: var(--muted); }
.term-row .forms i { font-family: var(--serif); font-size: 1.08em; color: var(--ink); }
.term-row .where { font: 400 13px/1.5 var(--sans); color: var(--muted); text-transform: none; letter-spacing: 0; margin: 0; max-width: none; }

/* об издании, текст об авторе */
.prose { max-width: var(--measure); margin: 0 auto; }
.prose h2 { font: 600 13px/1.4 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 2em 0 .4em; }
.prose li { margin-bottom: .4em; }
.prose blockquote { margin: 1.2em 0; padding: .1em 0 .1em 1.1em; border-left: 2px solid var(--line); }
.prose blockquote p { margin: 0 0 .5em; }
.prose blockquote .src { font: 400 13px/1.4 var(--sans); color: var(--muted); margin: 0; }
.prose table { border-collapse: collapse; font-size: .92em; margin: .6em 0 1em; width: 100%; }
.prose td, .prose th { text-align: left; padding: 4px 12px 4px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.prose th { font: 600 13px/1.4 var(--sans); color: var(--muted); }

/* скан страницы поверх текста */
.scanview { border: 0; padding: 0; background: transparent; max-width: min(96vw, 760px); max-height: 96vh; overflow: visible; }
.scanview::backdrop { background: rgba(10, 10, 14, .74); }
.scanview figure { margin: 0; display: grid; gap: 6px; }
.scanview img { display: block; max-height: 88vh; width: auto; margin: 0 auto; border-radius: 3px; background: #fff; }
.scanview figcaption { font: 400 13px/1.3 var(--sans); color: #e6e6e6; text-align: center; }
.scanview .close { position: absolute; top: -6px; right: -6px; width: 34px; height: 34px; border-radius: 999px; border: 0; background: var(--paper); color: var(--ink); font-size: 20px; cursor: pointer; }

@media (max-width: 560px) {
  .top { flex-wrap: nowrap; }
  .top .brand { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .nav { flex-wrap: nowrap; gap: 4px 10px; }
  .nav > .about-link { display: none; }
  .pager { grid-template-columns: minmax(0, 1fr); }
  .pager .next { grid-column: 1; }
  .term-row .ru { margin-left: 0; flex-basis: 100%; }
}
@media (max-width: 430px) { .nav > a:first-child:not(.author-link) { display: none; } }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
@media print { .top, .pager, .theme { display: none; } body { background: #fff; } }
