/* ============================================================
   doc-page.css — текстовые страницы (about.html, terms.html).
   Только семантические токены из variables.css: цвета берутся из
   палитры, выбранной в ЛК (theme-boot.js ставит переменные на <html>),
   светлые и тёмные темы работают без отдельных night-правил.
   ============================================================ */

* { box-sizing: border-box; }

/* Язык: виден только блок языка, выбранного на сайте (см. js/doc-lang.js) */
[data-lang] { display: none; }
html[lang="ru"] [data-lang="ru"],
html[lang="en"] [data-lang="en"],
html[lang="ar"] [data-lang="ar"],
html[lang="tr"] [data-lang="tr"],
html[lang="ur"] [data-lang="ur"],
html[lang="de"] [data-lang="de"],
html[lang="bs"] [data-lang="bs"],
html[lang="bn"] [data-lang="bn"] { display: revert; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    color: var(--text-1);
    font-family: var(--font-primary);
    font-size: 15px;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
}
html[dir="rtl"] body {
    font-family: var(--font-arabic-display);
    font-size: 17px;
    line-height: 1.85;
}

/* ── Шапка — как у модулей (эталон Ифта: css/ifta/ifta-header.css) ── */
.doc-header {
    padding: 13px 20px;
    background: var(--surface-1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    position: relative;
    z-index: 100;
}
.doc-header-inner {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 0 16px;
}
.doc-header-left { display: flex; align-items: center; }
.doc-title {
    font-family: var(--font-arabic-display);
    font-size: 28px;
    font-weight: 700;
    color: var(--accent);
    direction: rtl;
    text-decoration: none;
    white-space: nowrap;
    transition: color var(--transition-fast);
}
.doc-title:hover { color: var(--emerald-dark); }
.doc-header-center { display: flex; justify-content: center; align-items: center; }
.doc-header-right { display: flex; justify-content: flex-end; }
.doc-back {
    color: var(--text-2);
    text-decoration: none;
    font-size: 0.88rem;
    white-space: nowrap;
    transition: color var(--transition-fast);
}
.doc-back:hover { color: var(--accent); }

/* ── Текст ─────────────────────────────────────────────── */
.wrap { flex: 1 0 auto; padding: 28px 40px 64px; }

header.doc {
    border-bottom: 2px solid var(--border-subtle);
    padding-bottom: 18px;
    margin-bottom: 8px;
}
h1 { font-size: var(--text-xl); line-height: 1.25; margin: 0 0 6px; color: var(--text-1); }
h2 { font-size: 1.1rem; margin: 30px 0 8px; color: var(--accent); }
.sub { color: var(--text-2); font-size: 0.95rem; }
.ar { font-family: var(--font-arabic-display); font-size: 1.1em; }
p, li { color: var(--text-1); }
ul { padding-inline-start: 22px; }
li { margin: 6px 0; }
a { color: var(--accent); }
code {
    background: var(--surface-2);
    padding: 1px 6px;
    border-radius: calc(5px * var(--radius-scale, 1));
    font-size: 0.9em;
}

.lead {
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-inline-start: 4px solid var(--accent);
    border-radius: var(--radius-md);
    padding: 16px 18px;
    margin: 18px 0;
    box-shadow: var(--shadow-sm);
}

/* Орнамент плашки (js/doc-ornament.js): слева фактурная панель с дугой и жёлтым кольцом, цветок-мандала на дуге;
   в RTL — зеркально справа */
.lead.has-orn {
    position: relative;
    overflow: hidden;
    border-inline-start: 1px solid var(--border-subtle);
    padding-inline-start: 70px;
    min-height: 96px;
}
.lead-orn {
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 56px;   /* срез панели: левая часть обрезана по краю плашки, цветок наполовину за краем */
    pointer-events: none;
}
.lead-orn-panel { position: absolute; inset: 0; width: 100%; height: 100%; display: block; max-width: none; }
/* цветок: центр на самой дальней точке дуги (40px от края панели), диаметр под высоту плашки */
.lead-orn-flower {
    position: absolute;
    left: 12px; top: 50%;
    height: clamp(72px, calc(100% - 8px), 108px);
    aspect-ratio: 1;
    transform: translate(-50%, -50%);
    max-width: none;
    overflow: visible;
}
.lead:dir(rtl).has-orn { padding-inline-start: 18px; padding-inline-end: 70px; }
.lead:dir(rtl) .lead-orn { left: auto; right: 0; transform: scaleX(-1); }
/* ── Подвал — как у модулей (css/global.css .module-footer) ── */
.module-footer {
    background: #1f2937;
    padding: 32px 24px;
    color: rgba(255, 255, 255, 0.65);
    font-size: 14px;
}
.night-mode .module-footer { background: #0f172a; }
.module-footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
    padding: 0 16px;
}
.module-footer-links { display: flex; gap: 20px; flex-wrap: wrap; justify-content: center; }
.module-footer-link {
    font-size: 13px;
    color: var(--emerald-light, #6ee7b7);
    text-decoration: none;
    transition: color 0.15s;
}
.module-footer-link:hover { color: var(--gold-light, #fde68a); }

/* ── Гармошки разделов (about) ─────────────────────────── */
details {
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    margin: 8px 0;
    padding: 0 16px;
    transition: border-color var(--transition-fast);
}
details:hover, details[open] { border-color: var(--border-strong); }
details[open] { padding-bottom: 12px; }
summary {
    cursor: pointer;
    padding: 12px 0;
    font-weight: 600;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; color: var(--accent); font-size: 1.3rem; line-height: 1; }
details[open] summary::after { content: "−"; }
summary:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: calc(4px * var(--radius-scale, 1)); }
details p { margin: 4px 0 10px; }
.howto { color: var(--text-2); font-size: 0.95em; }
.go { font-size: 0.95em; }

/* ── Контакты (about) ──────────────────────────────────── */
table.contacts { width: 100%; border-collapse: collapse; margin: 12px 0; }
table.contacts td {
    padding: 10px 8px;
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: top;
}
table.contacts td:first-child { white-space: nowrap; width: 1%; }
table.contacts a { unicode-bidi: isolate; direction: ltr; }

.cta {
    display: inline-block;
    margin-top: 6px;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    background: var(--accent);
    color: var(--on-accent);
    text-decoration: none;
    font-weight: 600;
    box-shadow: var(--accent-glow);
    transition: background var(--transition-fast);
}
.cta:hover { background: var(--emerald-dark); }
.cta:focus-visible { outline: none; box-shadow: var(--focus-ring); }

@media (max-width: 700px) {
    .doc-header { padding: 10px 12px; }
    .doc-header-inner { padding: 0 4px; }
    .doc-title { font-size: 22px; }
    .wrap { padding: 22px 16px 56px; }
    .module-footer { padding: 24px 16px; }
    .module-footer-inner { flex-direction: column; text-align: center; gap: 16px; }
    .module-footer-links { gap: 12px 16px; }
    table.contacts, table.contacts tbody, table.contacts tr, table.contacts td { display: block; width: auto; }
    table.contacts tr { border-bottom: 1px solid var(--border-subtle); padding: 8px 0; }
    table.contacts td { border: 0; padding: 2px 0; }
}

/* ── Тарифы (/pricing): сетка карточек; сама карточка — css/plan-cards.css (.kpc) ── */
.pricing .plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 18px; margin: 26px 0 14px; }

/* Текст — по ширине (ровный правый край), с переносами по слогам; карточки тарифов и заголовки не трогаем */
.wrap :is(p, li, .lead):not(.kpc *) { text-align: justify; text-justify: inter-word; hyphens: auto; -webkit-hyphens: auto; overflow-wrap: break-word; }

/* Планшеты и узкие ноутбуки: боковые поля 40px (+16px в шапке) съедали место — делаем их уже,
   контент и шапка идут почти от края до края */
@media (max-width: 1100px) {
    .doc-header { padding-left: 16px; padding-right: 16px; }
    .doc-header-inner { padding: 0; }
    .wrap { padding: 24px 18px 56px; }
}

/* Телефоны: у страницы были боковые поля 40px — контент сжимался; делаем поля уже, карточки тарифов
   шире и с большим зазором друг от друга */
@media (max-width: 640px) {
    /* шапка: заголовок у левого края, «Главная» у правого — как поля текста */
    .doc-header { padding: 11px 12px; }
    .doc-header-inner { padding: 0; }
    /* арабский заголовок страницы (напр. «شروط الاستخدام والبيع») не должен заезжать под логотип */
    .doc-header-left { min-width: 0; }
    .doc-title { font-size: clamp(16px, 4.8vw, 22px); }
    .wrap { padding: 20px 12px 48px; }
    .pricing .plans { grid-template-columns: 1fr; gap: 28px; margin-top: 30px; }
}
@media (max-width: 560px) {
    .lead.has-orn { padding-inline-start: 62px; }
    .lead:dir(rtl).has-orn { padding-inline-start: 18px; padding-inline-end: 62px; }
    .lead-orn { width: 50px; }
    .lead-orn-flower { left: 10px; height: clamp(60px, calc(100% - 8px), 84px); }
}

/* ── Урду: насталик (Noto Nastaliq Urdu подключён в fonts.css), высокий межстрочный интервал; латиница/цифры — Inter ── */
html[lang="ur"] body {
    font-family: 'Islamic Honorifics', 'Inter', 'Noto Nastaliq Urdu', serif;
    font-size: 17px;
    line-height: 2.1;
}
html[lang="ur"] :is(h1, h2, h3, h4, p, li, td, th, a, span, label, summary, blockquote) {
    font-family: inherit;
}
/* адреса, ссылки, числа и латинские фрагменты внутри урду-текста остаются слева направо */
html[lang="ur"] a[href^="mailto:"], html[lang="ur"] a[href^="http"], html[lang="ur"] code { unicode-bidi: plaintext; }

/* ── Бенгальский: шрифт не вшиваем — Bangla есть в системе (Nirmala UI / Noto Sans Bengali / Bangla Sangam MN) ── */
html[lang="bn"] body {
    font-family: 'Islamic Honorifics', 'Inter', 'Noto Sans Bengali', 'Nirmala UI', 'Bangla Sangam MN', 'Kalpurush', sans-serif;
    line-height: 1.8;
}
