/* nasiha — минималистичная типографика для длинного чтения.
   Моноширинный шрифт только в интерфейсе и заголовках; тело текста — антиква,
   потому что читать длинные абзацы моноширинным тяжело. */

/* Шрифты свои, не с CDN: ноль внешних запросов из браузера и никакого
   мигания текста. Файлы — подмножества Google Fonts, у которых сужены оси
   переменных шрифтов до тех весов, что реально используются (400/500 у моно,
   400/600 у антиквы). Подмножества разделены по unicode-range, поэтому
   русская страница не тянет латиницу целиком, а арабский Amiri грузится
   только там, где есть текст дуа. */

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400 500;
  font-display: swap;
  src: url("/static/fonts/jetbrains-mono-latin.3b487a8ff313.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400 500;
  font-display: swap;
  src: url("/static/fonts/jetbrains-mono-latin-ext.ec3fc83ba1f7.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400 500;
  font-display: swap;
  src: url("/static/fonts/jetbrains-mono-cyrillic.77a92fb6760d.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400 500;
  font-display: swap;
  src: url("/static/fonts/jetbrains-mono-cyrillic-ext.deb453ce31e4.woff2") format("woff2");
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}

@font-face {
  font-family: "Source Serif 4";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("/static/fonts/source-serif-latin.17fb4582b136.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Source Serif 4";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("/static/fonts/source-serif-latin-ext.8578249f59d8.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Source Serif 4";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("/static/fonts/source-serif-cyrillic.efcbfb01c891.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: "Source Serif 4";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("/static/fonts/source-serif-cyrillic-ext.989126754ee0.woff2") format("woff2");
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}

@font-face {
  font-family: "Amiri";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/amiri-arabic.9abf8a10b4a2.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC, U+102E0-102FB, U+10E60-10E7E, U+10EC2-10EC4, U+10EFC-10EFF, U+1EE00-1EE03, U+1EE05-1EE1F, U+1EE21-1EE22, U+1EE24, U+1EE27, U+1EE29-1EE32, U+1EE34-1EE37, U+1EE39, U+1EE3B, U+1EE42, U+1EE47, U+1EE49, U+1EE4B, U+1EE4D-1EE4F, U+1EE51-1EE52, U+1EE54, U+1EE57, U+1EE59, U+1EE5B, U+1EE5D, U+1EE5F, U+1EE61-1EE62, U+1EE64, U+1EE67-1EE6A, U+1EE6C-1EE72, U+1EE74-1EE77, U+1EE79-1EE7C, U+1EE7E, U+1EE80-1EE89, U+1EE8B-1EE9B, U+1EEA1-1EEA3, U+1EEA5-1EEA9, U+1EEAB-1EEBB, U+1EEF0-1EEF1;
}

:root {
  --bg:       #faf9f7;
  --surface:  #f2f0eb;
  --text:     #1a1a18;
  --muted:    #76736c;
  --line:     #e4e0d8;
  --accent:   #6f6448;
  --shadow:   0 1px 2px rgba(20, 18, 14, .04);

  --mono:  "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --serif: "Source Serif 4", Charter, Georgia, "Noto Serif", serif;
  --arabic: "Amiri", "Scheherazade New", "Noto Naskh Arabic", "Geeza Pro", serif;

  --measure: 34rem;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:      #0d0d0e;
    --surface: #151518;
    --text:    #e9e7e2;
    --muted:   #8d8a82;
    --line:    #24242a;
    --accent:  #bcab7d;
    --shadow:  none;
  }
}

[data-theme="dark"] {
  --bg:      #0d0d0e;
  --surface: #151518;
  --text:    #e9e7e2;
  --muted:   #8d8a82;
  --line:    #24242a;
  --accent:  #bcab7d;
  --shadow:  none;
}

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

/* Шапка липкая, а браузер довозит якорь до самого верха окна — и заголовок
   раздела уезжал под неё. scroll-padding-top сдвигает цель вниз на высоту
   шапки (~67px: паддинг 1.1rem сверху и снизу, строка управления, линия)
   плюс воздух, чтобы заголовок не прилипал к её кромке. Одно объявление
   закрывает все якоря сразу — разделы, наставления, дуа — и переход по
   ссылке извне тоже, не только клик по оглавлению. */
html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 5.5rem;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.75;
  transition: background-color .25s ease, color .25s ease;
}

::selection { background: var(--accent); color: var(--bg); }

a { color: inherit; }

/* Тонкая полоса прогресса чтения — единственная «живая» деталь на странице. */
.progress {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  width: 0;
  background: var(--accent);
  z-index: 50;
  transition: width .1s linear;
}

/* Та же полоса в роли лоадера при переходе на другой язык: за чтением она
   бежит мгновенно, а тут должна ехать заметно — иначе её не увидеть. */
.progress.is-loading { transition: width .5s cubic-bezier(.2, .7, .3, 1); }

/* ---------- шапка ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.1rem clamp(1.25rem, 4vw, 3rem);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: .45rem;
  text-decoration: none;
}
/* Знак — это буква N, и слово «nasiha» начинается с той же буквы: без
   разделителя глаз склеивает их в «Nnasiha». Тонкая линия разводит их на
   два объекта — марка и слово, — а не увеличивает пустоту между ними.
   align-self ломает baseline только для знака: имя и подзаголовок
   по-прежнему выровнены по базовой линии. */
.brand-logo {
  width: 1.5rem;
  height: 1.5rem;
  align-self: center;
  flex: none;
  padding-right: .5rem;
  border-right: 1px solid var(--line);
}

.brand-name {
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: -.02em;
}

.brand-tag {
  font-family: var(--mono);
  font-size: .68rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-left: .3rem;
}

@media (max-width: 560px) { .brand-tag { display: none; } }

.controls { display: flex; align-items: center; gap: 1.25rem; }

.langs { display: flex; gap: .1rem; }

/* Активный язык раньше держался пилюлей со скруглением — единственным
   на сайте, кроме блока дуа. Теперь его держит линия акцентом: та же
   роль, но на языке остальной страницы. */
.lang {
  position: relative;
  font-family: var(--mono);
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  text-decoration: none;
  padding: .3rem .42rem .36rem;
  transition: color .18s ease;
}

/* Линия есть всегда и только проявляется. Двигать её вслед за выбором
   нельзя — на сайте ничего не переезжает, — а проявить можно. */
.lang::after {
  content: "";
  position: absolute;
  left: .42rem;
  right: .42rem;
  bottom: 0;
  height: 1px;
  background: var(--accent);
  opacity: 0;
  transition: opacity .18s ease;
}

.lang:hover { color: var(--text); }
.lang:hover::after { opacity: .4; }
.lang.is-active { color: var(--text); }
.lang.is-active::after { opacity: 1; }

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  border: 1px solid var(--line);
  border-radius: 50%;
  text-decoration: none;
  transition: border-color .18s ease;
}

.theme-toggle:hover { border-color: var(--muted); }

/* Луна и солнце — один круг: вырез съезжает и круг становится полным.
   Форма меняется на месте, кнопка не прыгает и не крутится.
   Единственное место на сайте, где что-то двигается: тема переключается
   без перезагрузки, и переход показывает, что произошло. */
.theme-dot {
  position: relative;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--text);
  overflow: hidden;
  transition: opacity .18s ease;
}

.theme-dot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--bg);
  transform: translateX(36%);
  transition: transform .34s cubic-bezier(.4, 0, .2, 1);
}

.theme-toggle:hover .theme-dot { opacity: .75; }

[data-theme="dark"] .theme-dot::after { transform: translateX(105%); }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-dot::after { transform: translateX(105%); }
}

/* ---------- сетка ---------- */

.layout {
  display: grid;
  grid-template-columns: 1fr;
  max-width: 62rem;
  margin: 0 auto;
  padding: 0 clamp(1.25rem, 4vw, 3rem) 6rem;
}

@media (min-width: 62rem) {
  .layout {
    grid-template-columns: 13rem minmax(0, var(--measure));
    gap: 5rem;
    justify-content: center;
  }
}

/* ---------- оглавление ---------- */

.toc { display: none; }

@media (min-width: 62rem) {
  .toc {
    display: block;
    position: sticky;
    top: 7rem;
    align-self: start;
    padding-top: 5rem;
  }
}

.toc-title,
.toc-compact summary {
  font-family: var(--mono);
  font-size: .66rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 1rem;
}

/* Оглавление для телефона: свёрнуто по умолчанию. Открытый список отнимал бы
   экран прокрутки перед текстом — ровно то, из-за чего колонку слева на узких
   экранах и убрали. Свёрнутая строка не отнимает ничего, но даёт способ
   перескочить, а разделов будет семь. Нативный <details>: ни JS, ни иконок. */
.toc-compact {
  display: block;
  border-bottom: 1px solid var(--line);
  margin-bottom: 3.5rem;
}

/* Крупнее, чем подпись колонки на десктопе: там она служебная надпись над
   списком, который и так виден, а здесь — единственный элемент навигации на
   телефоне, и в него надо попасть пальцем. Вместе с паддингами зона нажатия
   выходит около 45px. Разрядка при этом чуть теснее: подпись стала крупнее. */
.toc-compact summary {
  margin: 0;
  padding: .5rem 0 1rem;
  font-size: .78rem;
  letter-spacing: .08em;
  cursor: pointer;
}

.toc-compact summary:hover { color: var(--text); }

.toc-compact .toc-list { padding-bottom: 1.25rem; }

@media (min-width: 62rem) { .toc-compact { display: none; } }

.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: toc;
}

.toc-list li { counter-increment: toc; margin-bottom: .55rem; }

.toc-list a {
  display: block;
  font-family: var(--mono);
  font-size: .78rem;
  line-height: 1.5;
  color: var(--muted);
  text-decoration: none;
  padding-left: 1.6rem;
  position: relative;
  transition: color .15s ease;
}

.toc-list a::before {
  content: counter(toc, decimal-leading-zero);
  position: absolute;
  left: 0;
  font-size: .68rem;
  opacity: .5;
}

.toc-list a:hover { color: var(--text); }

.toc-list a.is-current {
  color: var(--text);
}

.toc-list a.is-current::before { opacity: 1; color: var(--accent); }

/* ---------- контент ---------- */

/* Воздух над началом контента. На узких экранах его меньше: там первым идёт
   свёрнутое оглавление, и пять рем над ним — это дыра под шапкой, а не воздух.
   Отбив перед заголовком раздела всё равно приходит ниже, от самого
   оглавления. От 62rem пять рем возвращаются: там колонка и первый заголовок
   должны начинаться на одной высоте. */
.content { padding-top: 2rem; min-width: 0; }

@media (min-width: 62rem) { .content { padding-top: 5rem; } }

.section { margin-bottom: 7rem; }

.section-title {
  font-family: var(--mono);
  font-weight: 500;
  font-size: clamp(2rem, 6vw, 2.9rem);
  line-height: 1.1;
  letter-spacing: -.04em;
  margin: 0 0 1.25rem;
}

.section-intro {
  font-size: 1.05rem;
  color: var(--muted);
  margin: 0 0 3.5rem;
  max-width: 30rem;
}

.reminder {
  display: grid;
  grid-template-columns: 1fr;
  padding: 2.5rem 0;
  border-top: 1px solid var(--line);
}

@media (min-width: 40rem) {
  .reminder { grid-template-columns: 3rem minmax(0, 1fr); }
}

.reminder-num {
  font-family: var(--mono);
  font-size: .7rem;
  color: var(--muted);
  padding-top: .55rem;
  letter-spacing: .05em;
}

@media (max-width: 40rem) {
  .reminder-num { margin-bottom: .5rem; }
}

.reminder-body { min-width: 0; }

.reminder-title {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 1.12rem;
  line-height: 1.4;
  letter-spacing: -.02em;
  margin: 0 0 1.1rem;
  text-wrap: balance;
}

.reminder-body p {
  margin: 0 0 1.15rem;
  hyphens: auto;
}

.reminder-body p:last-child { margin-bottom: 0; }

.pending {
  display: inline-block;
  font-family: var(--mono);
  font-size: .62rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .15rem .6rem;
  margin-top: 1rem;
}

.empty { color: var(--muted); }

/* ---------- зикры ---------- */

.dhikr-block { margin-top: 4rem; }

.dhikr-heading {
  font-family: var(--mono);
  font-weight: 500;
  font-size: .7rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 1.5rem;
}

.dhikr {
  margin: 0 0 1rem;
  padding: 1.75rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.dhikr-purpose {
  font-family: var(--mono);
  font-size: .68rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 1.1rem;
}

.dhikr-arabic {
  font-family: var(--arabic);
  font-size: 1.85rem;
  line-height: 2;
  margin: 0 0 1rem;
  text-align: right;
}

.dhikr-translit {
  font-family: var(--mono);
  font-size: .84rem;
  line-height: 1.6;
  margin: 0 0 .6rem;
}

.dhikr-meaning {
  color: var(--muted);
  font-size: .95rem;
  line-height: 1.6;
}

/* ---------- подвал ---------- */

.footer {
  margin-top: 5rem;
  padding-top: 2.5rem;
  border-top: 1px solid var(--line);
}

.footer-note {
  font-size: .9rem;
  color: var(--muted);
  margin: 0 0 2rem;
  max-width: 30rem;
}

.footer-meta {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: .68rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}

/* Дата слева, «наверх» справа. Через auto-отступ, а не space-between:
   если даты нет (база не ответила), ссылка остаётся у правого края. */
.footer-updated { margin-right: auto; }

.to-top {
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color .15s ease, color .15s ease;
}

.to-top:hover { color: var(--text); border-bottom-color: var(--muted); }

/* ---------- фокус ---------- */

a:focus-visible,
[role="button"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}

/* Ссылка «перейти к содержанию»: спрятана над верхним краем окна и выезжает
   только под фокусом. Не `display: none` — скрытое так до фокуса и не дойдёт.
   z-index выше липкой шапки, иначе она появится под ней. Перехода нет
   намеренно: на сайте не двигается ничего, кроме выреза в кружке темы. */
.skip-link {
  position: absolute;
  top: -4rem;
  left: 1rem;
  z-index: 60;
  padding: .6rem .9rem;
  background: var(--bg);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: .72rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text);
  text-decoration: none;
}

.skip-link:focus { top: .75rem; }

/* ---------- страница ошибки ---------- */

/* Отдельная простая страница: та же типографика, но без оглавления и без
   колонок — читать здесь нечего, надо только понять, что произошло. */
.error {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 9rem 1.5rem 6rem;
}

.error-code {
  font-family: var(--mono);
  font-size: .7rem;
  letter-spacing: .12em;
  color: var(--muted);
  margin: 0 0 1.5rem;
}

.error-title {
  font-family: var(--mono);
  font-weight: 500;
  font-size: clamp(1.6rem, 5vw, 2.2rem);
  line-height: 1.15;
  letter-spacing: -.03em;
  margin: 0 0 1.25rem;
}

.error-text {
  color: var(--muted);
  margin: 0 0 2.5rem;
}

.error-home {
  font-family: var(--mono);
  font-size: .75rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent);
}

/* ---------- печать ---------- */

/* Раздел должны нормально печататься: человек распечатывает и кладёт на стол,
   и на бумаге ему не нужны ни переключатель языков, ни оглавление, ни полоса
   прокрутки. Тему тоже не печатаем — тёмный фон съел бы картридж, а светлый
   и без того белый. */
@media print {
  .topbar,
  .toc,
  .toc-compact,
  .progress,
  .skip-link,
  .to-top { display: none; }

  body {
    background: #fff;
    color: #000;
    font-size: 11.5pt;
  }

  .layout { max-width: none; padding: 0; }
  .content { padding-top: 0; }

  /* Наставление не должно разрываться между страницами: две строки, уехавшие
     на следующий лист, читаются как обрывок. Заголовок раздела в одиночестве
     внизу листа — то же самое. */
  .reminder,
  .dhikr { break-inside: avoid; }
  .section-title { break-after: avoid; }
  .section { margin-bottom: 2.5rem; }

  /* Единственный элемент с заливкой. На бумаге заливка становится серым
     пятном, поэтому от блока дуа остаётся только рамка. */
  .dhikr {
    background: none;
    border: 1px solid #999;
    box-shadow: none;
  }

  a { color: #000; text-decoration: none; }
}
