/* amanat.online — песочная бумага, коричневые чернила, зелёный акцент.
   Шрифты системные: сайт должен открываться и из DHT без внешних запросов. */

:root {
  --bg: #f5eee2;
  --bg-alt: #ede3d3;
  --surface: #fbf7f0;
  --ink: #2a2018;
  --muted: #6e5e4c;
  --brown: #87583a;
  --accent: #2f6b55;
  --accent-ink: #f8f3ea;
  --gold: #b0843d;
  --line: #ddcdb5;
  --shadow: 0 1px 2px rgb(60 40 20 / .06), 0 8px 24px rgb(60 40 20 / .06);

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Noto Serif", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Ubuntu, sans-serif;
  --arabic: "Amiri", "Scheherazade New", "Noto Naskh Arabic", "Traditional Arabic", "Geeza Pro", serif;

  --radius: 14px;
  --wrap: 1120px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #18130e;
    --bg-alt: #1f1912;
    --surface: #251d15;
    --ink: #f0e6d7;
    --muted: #b3a28c;
    --brown: #d39b6e;
    --accent: #6db495;
    --accent-ink: #12241c;
    --gold: #d6ad67;
    --line: #3b2f23;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #18130e;
  --bg-alt: #1f1912;
  --surface: #251d15;
  --ink: #f0e6d7;
  --muted: #b3a28c;
  --brown: #d39b6e;
  --accent: #6db495;
  --accent-ink: #12241c;
  --gold: #d6ad67;
  --line: #3b2f23;
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .25);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0 0 .5em; text-wrap: balance; }
h1 { font-size: clamp(2.1rem, 5vw, 3.4rem); letter-spacing: -.01em; }
h2 { font-size: clamp(1.6rem, 3.2vw, 2.2rem); }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; }
a { color: var(--accent); }
.muted { color: var(--muted); }

.wrap { max-width: var(--wrap); margin: 0 auto; padding-inline: 20px; }

/* ───────── шапка ───────── */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s, box-shadow .2s;
}
.site-header.scrolled { border-bottom-color: var(--line); box-shadow: 0 4px 16px rgb(0 0 0 / .05); }
.header-row { display: flex; align-items: center; gap: 24px; min-height: 64px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-family: var(--serif); font-size: 1.3rem; font-weight: 600; }
.brand .logo { width: 30px; height: 30px; color: var(--accent); }
.brand.small { font-size: 1.1rem; }
.brand.small .logo { width: 24px; height: 24px; }

.site-nav { display: flex; gap: 4px; margin-inline-start: auto; flex-wrap: wrap; }
.site-nav a {
  color: var(--muted); text-decoration: none; font-size: .95rem;
  padding: 6px 10px; border-radius: 8px; white-space: nowrap;
}
.site-nav a:hover { color: var(--ink); background: var(--bg-alt); }
.site-nav a[aria-current="page"] { color: var(--ink); background: var(--bg-alt); }

.header-actions { display: flex; align-items: center; gap: 6px; }
.lang-switch {
  color: var(--ink); text-decoration: none; font-weight: 600; font-size: .85rem; letter-spacing: .05em;
  border: 1px solid var(--line); border-radius: 8px; padding: 5px 9px;
}
.lang-switch:hover { border-color: var(--brown); }
.icon-btn {
  width: 38px; height: 38px; display: grid; place-items: center;
  background: none; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); cursor: pointer;
}
.icon-btn:hover { border-color: var(--brown); }
.icon-btn svg { width: 20px; height: 20px; }
/* без wasm кнопки ничего не делают — прячем их */
html:not(.wasm) .icon-btn { display: none; }
.menu-btn { display: none; }

@media (max-width: 900px) {
  .menu-btn { display: grid; }
  .site-nav {
    display: none; position: absolute; inset-inline: 0; top: 100%;
    flex-direction: column; gap: 0; padding: 8px 12px 16px;
    background: var(--bg); border-bottom: 1px solid var(--line); box-shadow: var(--shadow);
  }
  .site-nav.open { display: flex; }
  .site-nav a { padding: 12px; font-size: 1.05rem; }
  .header-actions { margin-inline-start: auto; }
  /* без wasm меню нельзя открыть — показываем ссылки строкой */
  html:not(.wasm) .site-nav { display: flex; position: static; flex-direction: row; flex-wrap: wrap; box-shadow: none; border: 0; padding: 0 0 10px; background: none; }
  html:not(.wasm) .header-row { flex-wrap: wrap; }
}

/* ───────── первый экран ───────── */
.hero { position: relative; overflow: hidden; padding: clamp(56px, 10vw, 120px) 0 clamp(48px, 8vw, 96px); border-bottom: 1px solid var(--line); }
.hero::before {
  content: ""; position: absolute; inset: 0;
  background: var(--gold); opacity: .13;
  -webkit-mask: url(pattern.svg) 0 0 / 96px 96px repeat;
  mask: url(pattern.svg) 0 0 / 96px 96px repeat;
  pointer-events: none;
}
/* узор плавно растворяется книзу */
.hero::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to bottom, transparent 30%, var(--bg) 95%);
}
.hero-inner { z-index: 1; }
.hero-inner { position: relative; max-width: 820px; }
.hero.small { padding: 40px 0 44px; }
.kicker {
  display: inline-block; font-size: .8rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
  color: var(--brown); border: 1px solid var(--line); background: var(--surface);
  padding: 4px 12px; border-radius: 999px; margin-bottom: 18px;
}
.arabic-word {
  font-family: var(--arabic); font-size: clamp(4rem, 12vw, 7.5rem); line-height: 1.1;
  color: var(--brown); margin: 0 0 .1em;
}
.lead { font-size: clamp(1.08rem, 2vw, 1.25rem); color: var(--muted); max-width: 680px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 28px; }
.btn {
  display: inline-flex; align-items: center; min-height: 46px; padding: 0 22px; border-radius: 10px;
  font-weight: 600; text-decoration: none; color: var(--ink);
  border: 1px solid var(--line); background: var(--surface);
  transition: transform .15s, border-color .15s;
}
.btn:hover { transform: translateY(-1px); border-color: var(--brown); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* ───────── секции ───────── */
.section { padding: clamp(56px, 8vw, 96px) 0; }
.section.alt { background: var(--bg-alt); border-block: 1px solid var(--line); }
.section-lead { color: var(--muted); font-size: 1.1rem; margin-top: -.2em; }

.meaning-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: clamp(32px, 6vw, 72px); align-items: center; }
.ayah { margin: 0; padding: 32px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); position: relative; }
.ayah::before { content: ""; position: absolute; inset: 8px; border: 1px solid var(--line); border-radius: 9px; pointer-events: none; }
.ayah blockquote { margin: 0; }
.ayah-ar { font-family: var(--arabic); font-size: clamp(1.6rem, 3vw, 2.05rem); line-height: 1.9; color: var(--brown); text-align: center; margin-bottom: .6em; }
.ayah-tr { font-family: var(--serif); font-style: italic; font-size: 1.15rem; text-align: center; }
.ayah figcaption { text-align: center; color: var(--muted); font-size: .9rem; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin-top: 28px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.card p { color: var(--muted); margin: 0; }
.num { display: block; font-family: var(--serif); color: var(--gold); font-size: 1.1rem; font-weight: 600; margin-bottom: 10px; letter-spacing: .05em; }

/* продукты */
.product-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; margin-top: 28px; }
.product-card {
  position: relative; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px; text-decoration: none; color: var(--ink);
  transition: transform .2s, border-color .2s, box-shadow .2s;
}
.product-card:hover { transform: translateY(-3px); border-color: var(--brown); box-shadow: var(--shadow); }
.product-card h3 { font-size: 1.5rem; margin-top: 14px; }
.product-card p { color: var(--muted); flex: 1; }
.product-card .status { position: absolute; top: 28px; inset-inline-end: 28px; }
.product-icon {
  display: inline-grid; place-items: center; width: 52px; height: 52px; border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); flex: none;
}
.product-icon svg { width: 30px; height: 30px; }
.product-icon.large { width: 76px; height: 76px; border-radius: 18px; }
.product-icon.large svg { width: 44px; height: 44px; }
.status {
  display: inline-block; font-size: .78rem; font-weight: 600; letter-spacing: .03em;
  color: var(--brown); background: color-mix(in srgb, var(--gold) 16%, transparent);
  padding: 3px 10px; border-radius: 999px;
}
.more { font-weight: 600; color: var(--accent); }
.arrow { display: inline-block; transition: transform .2s; }
.product-card:hover .arrow { transform: translateX(4px); }
[dir="rtl"] .arrow { transform: scaleX(-1); }

/* как связано */
.flow { list-style: none; padding: 0; margin: 28px 0 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; counter-reset: f; }
.flow li { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.flow li span:last-child { color: var(--muted); font-size: .95rem; }
.flow strong { font-family: var(--serif); font-size: 1.1rem; }
.flow-icon { color: var(--accent); }
.flow-icon svg { width: 30px; height: 30px; }
.flow li:not(:last-child)::after {
  content: "→"; position: absolute; top: 50%; inset-inline-end: -14px; transform: translateY(-50%);
  width: 22px; height: 22px; display: grid; place-items: center; font-size: .8rem;
  background: var(--bg-alt); color: var(--brown); border: 1px solid var(--line); border-radius: 50%; z-index: 1;
}

/* заметка */
.note { border-inline-start: 4px solid var(--gold); background: var(--surface); border-radius: var(--radius); padding: 26px 30px; box-shadow: var(--shadow); max-width: 860px; }
.note h2 { font-size: 1.4rem; }
.note p { margin: 0; color: var(--muted); }
.note.big h2 { font-size: clamp(1.6rem, 3vw, 2rem); }
.note.big p { font-size: 1.1rem; }

/* страница продукта */
.back { display: inline-flex; gap: 6px; color: var(--muted); text-decoration: none; margin-bottom: 24px; font-size: .95rem; }
.back:hover { color: var(--ink); }
[dir="rtl"] .back-arrow { transform: scaleX(-1); }
.product-head { display: flex; gap: 24px; align-items: flex-start; }
.product-head h1 { margin-top: 10px; }
.product-head .lead { margin: 0; }
.intro { max-width: 760px; font-size: 1.12rem; }
.intro p:first-child { font-family: var(--serif); font-size: 1.3rem; line-height: 1.55; }

.steps { list-style: none; padding: 0; margin: 28px 0 0; counter-reset: s; display: grid; gap: 14px; max-width: 860px; }
.steps li { counter-increment: s; position: relative; padding: 22px 24px 22px 76px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
[dir="rtl"] .steps li { padding: 22px 76px 22px 24px; }
.steps li::before {
  content: counter(s); position: absolute; inset-inline-start: 22px; top: 20px;
  width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); font-weight: 700;
}
.steps h3 { font-family: var(--sans); font-size: 1.05rem; margin-bottom: .3em; }
.steps p { margin: 0; color: var(--muted); }

.mini-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 24px; }
.mini-card { display: flex; gap: 14px; align-items: center; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); text-decoration: none; transition: border-color .2s; }
.mini-card:hover { border-color: var(--brown); }
.mini-card small { display: block; color: var(--muted); font-size: .88rem; line-height: 1.4; }

/* подвал */
.site-footer { border-top: 1px solid var(--line); padding: 36px 0 calc(36px + env(safe-area-inset-bottom)); }
.footer-row { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; justify-content: space-between; }
.footer-row p { margin: 0; color: var(--muted); font-size: .92rem; }
.footer-row .brand .logo { color: var(--brown); }

/* ───────── появление (только при работающем wasm) ───────── */
html.wasm .reveal { opacity: 0; transform: translateY(14px); transition: opacity .6s ease, transform .6s ease; }
html.wasm .reveal.shown { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  html.wasm .reveal { opacity: 1; transform: none; transition: none; }
}

/* ───────── адаптив ───────── */
@media (max-width: 900px) {
  .meaning-grid { grid-template-columns: 1fr; }
  .flow { grid-template-columns: 1fr 1fr; }
  .flow li:nth-child(2)::after { display: none; }
  .mini-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  body { font-size: 16px; }
  .wrap { padding-inline: 16px; }
  .product-grid { grid-template-columns: 1fr; }
  .flow { grid-template-columns: 1fr; }
  .flow li::after { display: none !important; }
  .product-head { flex-direction: column; gap: 16px; }
  .product-card, .card { padding: 20px; }
  .product-card .status { position: static; align-self: flex-start; margin-top: 14px; order: 1; }
  .product-card h3 { order: 2; }
  .product-card p { order: 3; }
  .product-card .more { order: 4; }
  .ayah { padding: 24px 18px; }
  .note { padding: 20px; }
  .steps li { padding: 66px 18px 18px; }
  [dir="rtl"] .steps li { padding: 66px 18px 18px; }
  .steps li::before { inset-inline-start: 18px; top: 18px; }
}

/* арабское слово выравниваем по началу строки страницы, а не по своему RTL */
[dir="ltr"] .arabic-word { text-align: left; }
[dir="rtl"] .arabic-word { text-align: right; }
