/* Общие стили сайта: токены темы, база и компоненты, которые нужны на нескольких страницах
   (шапка, подвал, cookie-баннер, окно покупки, карточки товаров, текст разбора, лоадер).
   На index.html и about.html файл подключается ДО встроенных стилей, поэтому их правила главнее. */
:root {
  --bg: #f7f4fc;
  --surface: #fefdff;
  --sunk: #eeebf6;
  --fg: #231d35;
  --muted: #595567;
  --line: #d3cedd;
  --gold: #a37734;
  --gold-ink: #784e14;
  --accent: #543282;
  --on-accent: #f9f7fe;
  --danger: #b02a2d;
  --digit: #c92f33;
  --male: #4160a7;
  --female: #bc4757;
  --money: #2a904b;
  --sky-star: 84, 50, 130;
  --sky-line: 120, 90, 175;
  --sky-glow: 150, 110, 205;
  --sky-strength: 1.8;
  --sky-shoot: 0;
  --nebula-a: rgba(140, 100, 210, 0.14);
  --nebula-b: rgba(225, 183, 103, 0.12);
  --shadow: rgba(24, 16, 42, 0.07);
  --ring: rgba(84, 50, 130, 0.22);
  --chart-line: #aaa3bd;
  --chart-stroke: #3b3352;
  --c7: #d0b8ee;
  --c6: #a8bdf2;
  --c5: #97d5eb;
  --c4: #a4dfaf;
  --c3: #f5de87;
  --c2: #fbbb87;
  --c1x: #f7b196;
  --c1: #f4a19a;
  --point-ink: #1c172b;

  --font-display: "Forum", "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --font-body: "Golos Text", "Segoe UI", system-ui, -apple-system, sans-serif;

  --step--1: 0.8125rem;
  --step-0: 1rem;
  --step-1: 1.25rem;
  --step-2: 1.75rem;
  --step-3: clamp(2.25rem, 1.6rem + 2.6vw, 3.5rem);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f0c1d;
    --surface: #19162b;
    --sunk: #0a0816;
    --fg: #ece7dd;
    --line: #353249;
    --gold: #dab060;
    --gold-ink: #e8c17a;
    --accent: #e1b767;
    --on-accent: #161227;
    --danger: #fe8b83;
    --digit: #f97770;
    --male: #83a3ea;
    --female: #f18790;
    --money: #6fd087;
    --sky-star: 255, 246, 225;
    --sky-line: 190, 175, 235;
    --sky-glow: 255, 226, 170;
    --sky-strength: 1.3;
    --sky-shoot: 1;
    --nebula-a: rgba(110, 70, 190, 0.30);
    --nebula-b: rgba(225, 183, 103, 0.10);
    --shadow: rgba(0, 0, 0, 0.25);
    --ring: rgba(225, 183, 103, 0.3);
    --chart-line: #6a6487;
    --chart-stroke: #cfc9de;
    --muted: #bdbacb;
    --c7: #c5a9e6;
    --c6: #9cb3ee;
    --c5: #82cae3;
    --c4: #8ed09c;
    --c3: #ead070;
    --c2: #f2ad73;
    --c1x: #eea285;
    --c1: #ec928b;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f0c1d;
  --surface: #19162b;
  --sunk: #0a0816;
  --fg: #ece7dd;
  --line: #353249;
  --gold: #dab060;
  --gold-ink: #e8c17a;
  --accent: #e1b767;
  --on-accent: #161227;
  --danger: #fe8b83;
  --digit: #f97770;
  --male: #83a3ea;
  --female: #f18790;
  --money: #6fd087;
  --sky-star: 255, 246, 225;
  --sky-line: 190, 175, 235;
  --sky-glow: 255, 226, 170;
  --sky-strength: 1.3;
  --nebula-a: rgba(110, 70, 190, 0.30);
  --nebula-b: rgba(225, 183, 103, 0.10);
  --shadow: rgba(0, 0, 0, 0.25);
  --ring: rgba(225, 183, 103, 0.3);
  --chart-line: #6a6487;
  --chart-stroke: #cfc9de;
  --muted: #bdbacb;
  --c7: #c5a9e6;
  --c6: #9cb3ee;
  --c5: #82cae3;
  --c4: #8ed09c;
  --c3: #ead070;
  --c2: #f2ad73;
  --c1x: #eea285;
  --c1: #ec928b;
  color-scheme: dark;
}

/* ---------- База ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; }
[hidden] { display: none !important; }
html { scrollbar-gutter: stable; }
body {
  background-color: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-inline: 16px;
  padding-block: 0 32px;
}
#sky { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; display: block; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 400; line-height: 1.1; text-wrap: balance; margin: 0; }
h1 { font-size: var(--step-3); letter-spacing: -0.01em; }
h2 { font-size: var(--step-2); }
h3 { font-size: var(--step-1); }
p { margin: 0; text-wrap: pretty; }
.muted { color: var(--muted); }
.eyebrow { font-family: var(--font-body); font-size: var(--step--1); letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold-ink); font-weight: 500; margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
a { color: var(--gold-ink); text-decoration-color: var(--gold); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }

.btn {
  font: inherit; font-size: 1.125rem; font-weight: 600; min-height: 60px; padding: 0 28px; border: 0; border-radius: 12px;
  background: var(--accent); color: var(--on-accent); cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; text-align: center;
  transition-property: scale, opacity; transition-duration: 150ms; transition-timing-function: ease-out;
}
.btn:active { scale: 0.96; }
.btn[aria-busy="true"] { opacity: 0.75; cursor: progress; }
.btn-ghost {
  font: inherit; font-weight: 500; min-height: 48px; padding: 0 20px; border-radius: 12px; cursor: pointer;
  background: transparent; color: var(--fg); border: 1px solid var(--line); text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-align: center;
  transition-property: background-color, border-color; transition-duration: 150ms;
}
.btn-ghost:hover { background: var(--sunk); border-color: var(--gold); }
.btn-ghost svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- Шапка внутренних страниц ---------- */
.site-top { position: relative; padding-block: 20px 0; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; min-height: 44px; }
.site-top::before {
  content: ""; position: absolute; inset-inline: 0; top: -20px; height: 300px; z-index: -1; pointer-events: none;
  background:
    radial-gradient(ellipse 45% 55% at 50% 30%, var(--nebula-a), transparent 70%),
    radial-gradient(ellipse 30% 35% at 62% 20%, var(--nebula-b), transparent 70%);
}
.brand { font-family: var(--font-display); font-size: 1.625rem; line-height: 1.1; color: var(--fg); text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; }
.brand:hover { color: var(--gold-ink); }

.theme-switch { display: inline-flex; padding: 3px; gap: 2px; border-radius: 999px; background: var(--sunk); border: 0; margin: 0; min-inline-size: 0; }
.theme-switch legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.theme-switch label { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; min-width: 44px; padding: 0 14px; border-radius: 999px; cursor: pointer; font-size: var(--step--1); font-weight: 500; color: var(--muted); transition-property: background-color, color; transition-duration: 150ms; }
.theme-switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.theme-switch label.on { background: var(--surface); color: var(--fg); box-shadow: 0 1px 3px var(--shadow); }
.theme-switch label.focus { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-switch svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
@media (max-width: 40rem) {
  .theme-switch label { padding: 0 10px; }
  .theme-switch .t { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}

/* ---------- Подвал ---------- */
.site-foot {
  position: relative; z-index: 1; width: 100%; max-width: 70rem; margin: 72px auto 0; padding-top: 24px;
  border-top: 1px solid var(--line); display: grid; gap: 12px; font-size: var(--step--1); color: var(--muted); line-height: 1.5;
}
.site-foot ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 20px; }
.site-foot li { display: block; }
.site-foot a, .site-foot .linkish { color: var(--muted); text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 4px; min-height: 32px; display: inline-flex; align-items: center; }
.site-foot a:hover, .site-foot .linkish:hover { color: var(--fg); text-decoration-color: var(--gold); }
.site-foot .linkish { font: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
.site-foot p { max-width: 70ch; }

/* ---------- Чекбокс с подписью ---------- */
.check { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 10px; align-items: start; font-size: 0.9375rem; line-height: 1.45; text-align: start; }
.check input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--accent); cursor: pointer; }
.check input[aria-invalid="true"] { outline: 2px solid var(--danger); outline-offset: 2px; }
.check label { cursor: pointer; }
.check .opt { color: var(--muted); }

/* ---------- Карточки товаров ---------- */
.offers { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 16px; align-items: stretch; }
.offer {
  position: relative; display: grid; grid-template-rows: auto auto 1fr auto; gap: 14px; padding: 24px;
  background: var(--surface); border-radius: var(--radius); border: 1px solid transparent;
  box-shadow: 0 1px 2px var(--shadow), 0 8px 28px var(--shadow);
}
.offer.best { border-color: var(--gold); box-shadow: 0 1px 2px var(--shadow), 0 12px 36px var(--shadow), 0 0 0 3px var(--ring); }
.offer-badge {
  position: absolute; top: -13px; inset-inline-start: 20px; font-size: var(--step--1); font-weight: 600; letter-spacing: 0.04em;
  background: var(--gold-ink); color: var(--on-accent); padding: 3px 12px; border-radius: 999px;
}
.offer h3 { font-size: 1.5rem; }
.offer-price { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; font-variant-numeric: tabular-nums; }
.offer-price s { color: var(--muted); font-size: 1rem; text-decoration-thickness: 1.5px; }
.offer-price .now { font-family: var(--font-display); font-size: 2rem; line-height: 1; color: var(--fg); }
.offer-price .save { flex-basis: 100%; font-size: var(--step--1); color: var(--money); font-weight: 500; }
.offer ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; align-content: start; font-size: 0.9375rem; }
.offer li { display: grid; grid-template-columns: 14px minmax(0, 1fr); gap: 8px; }
.offer li::before { content: ""; width: 7px; height: 7px; margin-top: 0.55em; border-radius: 50%; background: var(--gold); }
.offer .btn { width: 100%; min-height: 52px; font-size: 1.0625rem; }
.offer:not(.best) .btn { background: transparent; color: var(--fg); border: 1.5px solid var(--accent); }
.offer:not(.best) .btn:hover { background: var(--sunk); }

/* ---------- Окно покупки ---------- */
html.dlg-open { overflow: hidden; }
dialog.buy {
  width: min(34rem, calc(100% - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 0; border-radius: calc(var(--radius) + 6px);
  background: var(--surface); color: var(--fg); box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35); overflow: auto; overscroll-behavior: contain;
}
dialog.buy::backdrop { background: rgba(10, 8, 22, 0.6); backdrop-filter: blur(3px); }
@media (prefers-reduced-motion: no-preference) {
  dialog.buy[open] { animation: dlg-in 200ms ease-out; }
}
@keyframes dlg-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.buy form { display: grid; gap: 18px; padding: 24px 28px 28px; }
.buy-head { display: flex; justify-content: space-between; align-items: start; gap: 16px; }
.buy-head > div { display: grid; gap: 6px; min-width: 0; }
.buy-head h2 { font-size: var(--step-2); }
.buy-close {
  flex: none; width: 44px; height: 44px; margin: -6px -10px 0 0; border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer;
  display: grid; place-items: center;
}
.buy-close:hover { background: var(--sunk); color: var(--fg); }
.buy-close svg { width: 20px; height: 20px; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; fill: none; }
.buy-sum { display: grid; gap: 8px; padding: 14px 16px; background: var(--sunk); border-radius: 12px; }
.buy-sum ul { margin: 0; padding-inline-start: 1.2em; display: grid; gap: 2px; font-size: 0.9375rem; color: var(--muted); }
.buy-field { display: grid; gap: 6px; }
.buy-field label { font-weight: 600; }
.buy-field input {
  font: inherit; font-size: 1.125rem; width: 100%; min-height: 52px; padding: 8px 14px;
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--fg);
  transition-property: border-color, box-shadow; transition-duration: 150ms;
}
.buy-field input.date { font-variant-numeric: tabular-nums; letter-spacing: 0.04em; border-color: var(--gold); }
.buy-field input::placeholder { color: var(--muted); opacity: 0.7; }
.buy-field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--ring); }
.buy-field input[aria-invalid="true"] { border-color: var(--danger); }
.buy-hint { font-size: var(--step--1); color: var(--muted); }
.buy-err { color: var(--danger); font-size: var(--step--1); font-weight: 500; }
.buy-err:empty { display: none; }
.buy-checks { display: grid; gap: 14px; }
.buy-checks .buy-err { margin: -8px 0 0 32px; }
.buy .btn { width: 100%; }
.buy-note { font-size: var(--step--1); color: var(--muted); text-align: center; }
.buy-note svg { width: 14px; height: 14px; vertical-align: -2px; fill: none; stroke: currentColor; stroke-width: 1.6; }
@media (max-width: 40rem) { .buy form { padding: 20px 18px 22px; gap: 16px; } }

/* ---------- Cookie-баннер: текст слева, кнопка справа ---------- */
.cookie {
  position: fixed; z-index: 50; inset-inline: 12px; bottom: 12px; margin-inline: auto; max-width: 44rem;
  background: var(--surface); color: var(--fg); border-radius: var(--radius); border: 1px solid var(--line);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.25); padding: 16px 20px;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px 20px;
  font-size: 0.9375rem; line-height: 1.5;
}
.cookie p { margin: 0; }
.cookie-acts { display: flex; justify-content: flex-end; }
.ck-btn {
  font: inherit; font-weight: 600; min-height: 44px; padding: 0 24px; border-radius: 10px; cursor: pointer;
  border: 1.5px solid var(--accent); background: var(--accent); color: var(--on-accent); white-space: nowrap;
}
html.has-cookie body { padding-bottom: 120px; }
@media (max-width: 40rem) {
  .cookie { padding: 14px 16px; inset-inline: 8px; bottom: 8px; font-size: 0.875rem; gap: 12px 14px; }
  html.has-cookie body { padding-bottom: 150px; }
}

/* ---------- Текст разбора (markdown) ---------- */
.md { max-width: 65ch; font-size: 1.0625rem; line-height: 1.6; }
.md > * + * { margin-top: 1em; }
.md h2 { font-size: var(--step-2); margin-top: 2em; padding-top: 0.2em; color: var(--fg); }
.md h2:first-child { margin-top: 0; }
.md h3 { font-size: 1.375rem; margin-top: 1.6em; }
.md h2 + *, .md h3 + * { margin-top: 0.6em; }
.md ul, .md ol { margin-block: 0; padding-inline-start: 1.4em; display: grid; gap: 0.4em; }
.md li::marker { color: var(--gold-ink); }
.md strong { font-weight: 600; }
.md blockquote { margin-inline: 0; padding: 12px 18px; border-inline-start: 3px solid var(--gold); background: var(--sunk); border-radius: 0 10px 10px 0; }
.md hr { border: 0; height: 1px; background: var(--line); margin-block: 2em; }
@media (max-width: 40rem) { .md { font-size: 1rem; } }

/* ---------- Лоадер: медленно вращающаяся октаграмма ---------- */
.octa-loader { width: 168px; height: 168px; display: block; color: var(--gold); }
.octa-loader .spin { transform-origin: 0 0; }
.octa-loader .sq { fill: none; stroke: currentColor; stroke-width: 1.2; opacity: 0.7; }
.octa-loader .rg { fill: none; stroke: var(--chart-line); stroke-width: 1; }
.octa-loader .pt { fill: var(--accent); }
.octa-loader .core { fill: var(--c3); stroke: var(--gold); stroke-width: 1; }
@media (prefers-reduced-motion: no-preference) {
  .octa-loader .spin { animation: octa-spin 60s linear infinite; }
  .octa-loader .pt { animation: octa-tw 3.2s ease-in-out infinite; animation-delay: var(--d, 0s); }
  .octa-loader .core { animation: octa-pulse 4s ease-in-out infinite; transform-origin: 0 0; }
}
@keyframes octa-spin { to { transform: rotate(360deg); } }
@keyframes octa-tw { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }
@keyframes octa-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }

/* ---------- Подвал всегда внизу: страница не короче экрана ---------- */
body > .page { display: flex; flex-direction: column; min-height: 100dvh; }
body > .page > * { min-width: 0; }
body > .page > :nth-last-child(2) { margin-bottom: 40px; }
body > .page > .site-foot { margin-top: auto; padding-bottom: 24px; }
html body { padding-bottom: 0; }

/* переключатель темы показываем только на локальном стенде (класс ставит site.js) */
html:not(.local-stand) .theme-switch { display: none !important; }

/* страница оферты: оферта и отдельный документ — согласие на обработку ПДн */
.doc-parts { padding: 12px 16px; border-radius: 10px; background: var(--sunk); color: var(--muted); font-size: var(--step--1); }
.doc-split { margin: 56px 0 24px; border: 0; border-top: 2px solid var(--line); }
.doc-part-title { font-family: var(--font-display); font-weight: 400; font-size: var(--step-2); line-height: 1.15; scroll-margin-top: 24px; }
