/* Общее ядро трёх сайтов. Не редактировать внутри сайтов:
   правится здесь, затем scripts/sync-shared.sh.
   Ожидает токены темы: --bg --surface --surface-2 --ink --ink-soft --line --accent --accent-ink
   --offer-bg --offer-ink --offer-line --focus --radius-s --radius-m --radius-l
   --font-display --font-body --font-mono */

:root {
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in: cubic-bezier(0.64, 0, 0.78, 0);
  --dur-fast: 160ms;
  --dur: 260ms;
  --dur-slow: 640ms;
  --gutter: clamp(1rem, 4vw, 2.5rem);
  --maxw: 1240px;
  --z-header: 20;
  --z-banner: 40;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg, canvas { display: block; max-width: 100%; }
figure { margin: 0; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a, button, summary, label { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
[id] { scroll-margin-top: 5.5rem; }
a { color: inherit; text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.05; margin: 0; text-wrap: balance; }
p { margin: 0; text-wrap: pretty; }
code, .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 2px; }

.skip-link {
  position: absolute; left: var(--gutter); top: -100px; z-index: 100;
  background: var(--ink); color: var(--bg); padding: 0.6rem 1rem; text-decoration: none;
}
.skip-link:focus { top: 0.75rem; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.wrap { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--gutter); }

/* Плашка независимого партнёра: обязательна на всех страницах */
.partner-note {
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--ink-soft);
}
.partner-note strong { color: var(--ink); font-weight: 600; }

/* ---------- Появление при скролле ---------- */
[data-reveal] {
  opacity: 0;
  transform: translate3d(0, 24px, 0);
  transition: opacity var(--dur-slow) var(--ease-out), transform var(--dur-slow) var(--ease-out);
  transition-delay: calc(var(--i, 0) * 70ms);
}
[data-reveal].is-in { opacity: 1; transform: none; }
.no-js [data-reveal] { opacity: 1; transform: none; }

/* ---------- Страница загрузки ---------- */
.dl {
  display: grid;
  gap: clamp(1.5rem, 4vw, 3rem);
  grid-template-columns: minmax(0, 1fr);
  padding-block: clamp(2rem, 6vw, 5rem);
}
@media (min-width: 960px) {
  .dl { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); align-items: start; }
}

.dl-main h1 { font-size: clamp(2rem, 4.6vw, 3.5rem); }
.dl-lead { margin-top: 1rem; max-width: 60ch; color: var(--ink-soft); font-size: 1.0625rem; }

.file-facts {
  margin: 2rem 0 0;
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  border-top: 1px solid var(--line);
}
.file-facts dt, .file-facts dd {
  margin: 0; padding: 0.7rem 0; border-bottom: 1px solid var(--line);
}
.file-facts dt { color: var(--ink-soft); padding-right: 1.5rem; font-size: 0.9375rem; }
.file-facts dd { font-family: var(--font-mono); font-size: 0.875rem; overflow-wrap: anywhere; }
.file-facts .hash { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }

.copy-btn {
  border: 1px solid var(--line); background: transparent; padding: 0.15rem 0.55rem;
  font-family: var(--font-body); font-size: 0.75rem; border-radius: var(--radius-s);
  min-height: 28px;
  transition: background-color var(--dur-fast) var(--ease-out);
}
.copy-btn:hover { background: var(--surface-2); }

.dl-actions { margin-top: 2rem; display: flex; flex-wrap: wrap; gap: 0.75rem 1.25rem; align-items: center; }
.dl-actions .muted-link { font-size: 0.9375rem; color: var(--ink-soft); }

/* Состояния загрузки основного файла */
.dl-status {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows var(--dur-slow) var(--ease-out);
}
.dl-status > div { overflow: hidden; }
.dl-status[data-state="started"], .dl-status[data-state="error"] { grid-template-rows: 1fr; }
.dl-status__inner { padding-top: 1.5rem; }
.dl-status [data-when] { display: none; }
.dl-status[data-state="started"] [data-when="started"],
.dl-status[data-state="error"] [data-when="error"] { display: block; }

.steps { counter-reset: step; list-style: none; padding: 0; margin: 1rem 0 0; display: grid; gap: 0.6rem; }
.steps li { counter-increment: step; position: relative; padding-left: 2.5rem; min-height: 1.6rem; }
.steps li::before {
  content: counter(step);
  position: absolute; left: 0; top: 0.05rem;
  font-family: var(--font-mono); font-size: 0.8125rem;
  width: 1.6rem; height: 1.6rem; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 50%;
}

/* ---------- Блок оффера Яндекса ----------
   Визуально отделён от основного продукта, всегда помечен «Реклама». */
.offer {
  position: relative;
  background: var(--offer-bg);
  color: var(--offer-ink);
  border: 1px solid var(--offer-line);
  border-radius: var(--radius-m);
  padding: clamp(1.25rem, 3vw, 1.75rem);
}
.offer[hidden] { display: none; }
.offer__ad {
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  font-size: 0.75rem; line-height: 1.4; opacity: 0.8;
  padding-bottom: 0.9rem; margin-bottom: 1.1rem; border-bottom: 1px solid var(--offer-line);
}
.offer__title { display: flex; gap: 0.9rem; align-items: center; }
.offer__logo { width: 44px; height: 44px; flex: none; border-radius: 10px; background: var(--offer-line); }
.offer__title h2 { font-family: var(--font-body); font-size: 1.1875rem; font-weight: 700; line-height: 1.25; }
.offer__text { margin-top: 0.9rem; font-size: 0.9375rem; }
.offer__list { margin: 0.9rem 0 0; padding-left: 1.1rem; font-size: 0.9375rem; display: grid; gap: 0.25rem; }
.offer__licenses { margin-top: 1rem; font-size: 0.8125rem; line-height: 1.5; }
.offer__licenses a { color: inherit; }
.offer__consent { margin-top: 1rem; display: grid; grid-template-columns: auto 1fr; gap: 0.6rem; font-size: 0.9375rem; align-items: start; }
.offer__consent input { width: 20px; height: 20px; margin: 0.15rem 0 0; accent-color: var(--offer-ink); }
.offer__actions { margin-top: 1.25rem; display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }
.offer__skip { font-size: 0.875rem; background: none; border: 0; padding: 0.5rem 0; text-decoration: underline; text-underline-offset: 0.2em; color: inherit; opacity: 0.8; }
.offer.is-dismissed { opacity: 0.55; }

.offer-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 48px; padding: 0 1.25rem;
  border: 1px solid currentColor; border-radius: var(--radius-s);
  background: transparent; color: inherit; font-weight: 600; text-decoration: none;
  transition: transform var(--dur-fast) var(--ease-out), background-color var(--dur) var(--ease-out);
}
.offer-btn:hover { background: color-mix(in oklch, currentColor 8%, transparent); }
.offer-btn:active { transform: scale(0.98); }
.offer-btn[aria-disabled="true"] { opacity: 0.45; pointer-events: none; }

/* ---------- Cookie-баннер (152-ФЗ, Метрика) ---------- */
.cookie {
  position: fixed; inset: auto var(--gutter) var(--gutter) auto; z-index: var(--z-banner);
  max-width: min(420px, calc(100vw - 2 * var(--gutter)));
  background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  border-radius: var(--radius-m); padding: 1rem 1.1rem;
  box-shadow: 0 18px 40px -20px color-mix(in oklch, var(--ink) 45%, transparent);
  font-size: 0.875rem; line-height: 1.5;
  transform: translate3d(0, 16px, 0); opacity: 0;
  transition: transform var(--dur) var(--ease-out), opacity var(--dur) var(--ease-out);
}
.cookie.is-shown { transform: none; opacity: 1; }
.cookie[hidden] { display: none; }
.cookie__row { margin-top: 0.75rem; display: flex; gap: 0.5rem; flex-wrap: wrap; }
.cookie button {
  min-height: 40px; padding: 0 0.9rem; border-radius: var(--radius-s);
  border: 1px solid var(--line); background: var(--surface-2);
}
.cookie button[data-cookie="accept"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* ---------- Юридическая страница ---------- */
.legal { padding-block: clamp(2rem, 6vw, 5rem); max-width: 72ch; }
.legal h1 { font-size: clamp(2rem, 4vw, 3rem); }
.legal h2 { font-family: var(--font-body); font-size: 1.25rem; margin-top: 2.5rem; scroll-margin-top: 6rem; }
.legal p, .legal ul { margin-top: 0.8rem; }
.legal .todo { background: color-mix(in oklch, var(--accent) 18%, transparent); padding: 0 0.25em; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
  [data-reveal] { opacity: 1; transform: none; }
}
