/* ─────────────────────────────────────────────────────────────
   Splendet — стили сайта.
   Палитра один-в-один с приложением:
   content-studio/apps/web/src/styles/tokens.css («Bento Pop»).

   Правило сцены: гравюра остаётся чернилами по бумаге.
   Цвет живёт в контенте ниже — как в bento-карточках приложения.
   ───────────────────────────────────────────────────────────── */

:root {
  /* Surfaces */
  --bg: #f3f2ee;
  --card: #ffffff;
  --line: #e7e4dc;
  --hover: #eceae3;
  --glass: rgba(243, 242, 238, 0.85);

  /* Ink */
  --ink: #191713;
  --ink-soft: #7d7768;
  --ink-inverse: #f4f1ea;

  /* Brand */
  --accent: #ff5c38;
  --accent-glow: 0 4px 14px rgba(255, 92, 56, 0.3);

  /* Bento card fills */
  --bento-dark: #191713;
  --bento-blue: #e3e9ff;
  --bento-amber: #ffefcc;
  --bento-red: #ffe5df;

  /* Semantic */
  --good: #0d7a4f;
  --good-bg: #dcf5e7;
  --bad: #c2270f;
  --bad-bg: #ffe5df;

  /* Status pills */
  --st-sched: #2547c9;   --st-sched-bg: #e3e9ff;
  --st-review: #9a6200;  --st-review-bg: #ffefcc;
  --st-pub: #0d7a4f;     --st-pub-bg: #dcf5e7;
  --st-err: #c2270f;     --st-err-bg: #ffe5df;
  --st-draft: #6d6656;   --st-draft-bg: #efede6;

  /* Shape */
  --rad: 20px;
  --rad-s: 12px;

  /* Type */
  --font-body: "DM Sans", "Segoe UI", system-ui, sans-serif;
  --font-display: "Space Grotesk", "DM Sans", system-ui, sans-serif;

  --t-fast: 150ms ease;

  /* Переменные сцены — пишутся из scene.js */
  --reveal: 0;
  --logoScale: 1;
  --worldY: 0;
  --plateP: 0;
  --coreP: 0;
  --flow: 0;
  --cardP: 0;
  --nodeP: 0;
  --liveP: 0;
  --fan: 305;
  --nodeDist: 450;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Зерно бумаги. Статичное — не анимируется никогда. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  opacity: 0.45;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='0.28'/%3E%3C/svg%3E");
}

a { color: inherit; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.12;
  margin: 0 0 0.6em;
}

.wrap { max-width: 1140px; margin: 0 auto; padding: 0 24px; }
.narrow { max-width: 760px; }

/* ── Шапка ─────────────────────────────────────────────────── */

#top {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: max(16px, env(safe-area-inset-top)) 24px 28px;
  pointer-events: none;
}
#top > * { pointer-events: auto; }
/* Фиксированная шапка иначе садится прямо на текст секций. */
#top::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(
    var(--bg) 52%,
    color-mix(in srgb, var(--bg) 65%, transparent) 78%,
    transparent
  );
  pointer-events: none;
}

.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.03em;
  text-decoration: none;
  opacity: var(--reveal);
}

.badge-soon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--bento-red);
  border: 1px solid color-mix(in srgb, var(--accent) 32%, transparent);
  border-radius: 999px;
  padding: 4px 11px;
  opacity: var(--reveal);
}
.badge-soon::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

/* ── Кино: закреплённая сцена ──────────────────────────────── */

#film { height: 720vh; position: relative; }

.film-sticky {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}

#stage { position: absolute; inset: 0; pointer-events: none; }
#stage svg { width: 100%; height: 100%; display: block; }

#world {
  transform: translateY(calc(var(--worldY) * 1px)) scale(var(--logoScale));
  transform-origin: 0 0;
}

.ink { stroke: var(--ink); fill: none; stroke-linecap: round; }
.hatch { stroke: var(--ink); stroke-width: 1.15; fill: none; }

#rim {
  stroke: var(--ink); stroke-width: 3; fill: none;
  stroke-dasharray: var(--rimLen);
  stroke-dashoffset: calc(var(--rimLen) * (1 - min(1, var(--reveal) / 0.35)));
}

#star {
  fill: var(--bg); stroke: var(--ink); stroke-width: 2.2; stroke-linejoin: round;
  stroke-dasharray: var(--starLen);
  stroke-dashoffset: calc(var(--starLen) * (1 - max(0, min(1, (var(--reveal) - 0.7) / 0.3))));
  transform: scale(calc(1 + 0.06 * var(--coreP)));
}

.ray {
  stroke: var(--ink); stroke-width: 1.6; fill: none;
  stroke-linecap: butt;
  stroke-dashoffset: var(--flow);
}

#hatchWipe {
  transform: translateY(-190px) scaleY(clamp(0.001, calc((var(--reveal) - 0.2) / 0.4), 1)) translateY(190px);
}
#rayWipe { transform: scale(clamp(0.001, calc((var(--reveal) - 0.45) / 0.35), 1)); }

/* Траектория держится выше текстовой полосы: любой кадр — законченный плакат. */
#plate {
  transform:
    translateY(calc((1 - var(--plateP)) * 330px))
    scale(calc(1 - 0.88 * var(--plateP)));
  opacity: clamp(0, min(calc(var(--plateP) * 4), calc((1 - var(--plateP)) * 2.2)), 1);
}

.card {
  transform:
    rotate(calc(var(--ang) * 1deg))
    translateY(calc(var(--fan) * var(--d) * var(--cardP) * -1px))
    rotate(calc(var(--ang) * -1deg))
    scale(var(--cardP));
  opacity: clamp(0, calc(var(--cardP) * 3), 1);
}
.card rect { fill: #fff; stroke: var(--ink); stroke-width: 2; }
.card .hatch { stroke-width: 0.9; opacity: 0.55; }

/* Публикуется прямо сейчас — единственный цвет внутри гравюры. */
#cardLive {
  transform:
    translateY(calc(var(--liveP) * -104px))
    rotate(calc(var(--ang) * 1deg))
    translateY(calc(var(--fan) * var(--d) * var(--cardP) * -1px))
    rotate(calc(var(--ang) * -1deg))
    scale(var(--cardP));
}
#cardLive rect { stroke: color-mix(in srgb, var(--accent) calc(var(--liveP) * 100%), var(--ink)); }
#cardLive .hatch { stroke: color-mix(in srgb, var(--accent) calc(var(--liveP) * 70%), var(--ink)); }

.node {
  transform:
    rotate(calc(var(--ang) * 1deg))
    translateY(calc(var(--nodeDist) * var(--nodeP) * -1px))
    rotate(calc(var(--ang) * -1deg))
    scale(var(--nodeP));
  opacity: clamp(0, calc(var(--nodeP) * 3), 1);
  pointer-events: auto;
  cursor: pointer;
}
.node circle { fill: var(--bg); stroke: var(--ink); stroke-width: 2; transition: fill var(--t-fast); }
.node text {
  font-family: var(--font-display);
  font-size: 15px; font-weight: 700;
  fill: var(--ink);
  text-anchor: middle; dominant-baseline: central;
  user-select: none;
}
/* Тап красит ноду в цвет её карточки из приложения. */
.node.sel circle { stroke-width: 3; }
.node.sel[data-net="ig"] circle { fill: var(--bento-red); stroke: var(--accent); }
.node.sel[data-net="th"] circle { fill: var(--bento-blue); stroke: var(--st-sched); }
.node.sel[data-net="fb"] circle { fill: var(--good-bg); stroke: var(--good); }

/* ── Текстовые шаги поверх сцены ───────────────────────────── */

#copy {
  position: absolute;
  left: 0; right: 0;
  bottom: max(6vh, env(safe-area-inset-bottom));
  z-index: 3;
  display: grid;
  place-items: center;
  pointer-events: none;
  padding: 0 24px;
}

.step {
  grid-area: 1 / 1;
  max-width: 34rem;
  text-align: center;
  opacity: 0;
  transform: translateY(calc(var(--slide, 0) * 14px));
}
.step h1 { font-size: clamp(2.1rem, 7.5vw, 3.6rem); margin-bottom: 0.35em; }
.step h2 { font-size: clamp(1.35rem, 5vw, 2.1rem); }
.step p { margin: 0; font-size: clamp(0.95rem, 3.2vw, 1.05rem); color: var(--ink-soft); }
.step .cta { margin-top: 22px; pointer-events: auto; }

#hint {
  position: absolute;
  left: 0; right: 0;
  bottom: max(1.6vh, env(safe-area-inset-bottom));
  z-index: 4;
  text-align: center;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  pointer-events: none;
}

/* ── Кнопки ────────────────────────────────────────────────── */

.cta { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  text-decoration: none;
  border-radius: 999px;
  padding: 13px 22px;
  border: 1.5px solid var(--ink);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast);
}
.btn:hover { background: var(--hover); }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--ink);
  color: var(--ink-inverse);
  border-color: var(--ink);
}
.btn-primary:hover { background: #000; }

.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: var(--accent-glow);
}
.btn-accent:hover { background: #ef4f2c; }

.btn small {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.7;
}

/* Заглушка вместо официального бейджа App Store.
   На релизе заменить на официальную графику Apple. */
.btn-store { flex-direction: column; align-items: flex-start; gap: 1px; padding: 11px 22px; }
.btn-store b { font-size: 1.02rem; line-height: 1.15; }
.btn-store span {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  opacity: 0.75;
}
.btn[aria-disabled="true"] { cursor: default; opacity: 0.95; }

/* ── Контент ───────────────────────────────────────────────── */

main { position: relative; z-index: 10; background: var(--bg); }

section.band { padding: clamp(64px, 11vw, 130px) 0; }

.eyebrow {
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 14px;
}

.band h2 { font-size: clamp(1.8rem, 5.2vw, 3rem); }
.lede { font-size: clamp(1.02rem, 2.6vw, 1.2rem); color: var(--ink-soft); max-width: 46rem; margin: 0 0 8px; }

/* Bento-сетка — та же логика, что в кабинете приложения */
.bento {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 16px;
  margin-top: 44px;
}
.bx {
  grid-column: span 2;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--rad);
  padding: 26px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.bx h3 { font-size: 1.22rem; margin: 0; }
.bx p { margin: 0; font-size: 0.95rem; color: var(--ink-soft); }
.bx .kpi {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2rem, 5vw, 2.9rem);
  line-height: 1;
  letter-spacing: -0.03em;
  margin-top: auto;
  padding-top: 12px;
}
.bx-wide { grid-column: span 3; }
.bx-full { grid-column: span 6; }
.bx-blue { background: var(--bento-blue); border-color: transparent; }
.bx-amber { background: var(--bento-amber); border-color: transparent; }
.bx-red { background: var(--bento-red); border-color: transparent; }
.bx-dark { background: var(--bento-dark); border-color: transparent; color: var(--ink-inverse); }
.bx-dark p { color: color-mix(in srgb, var(--ink-inverse) 70%, transparent); }
.bx-dark .kpi { color: var(--accent); }

/* Пилюли статусов — ровно те, что в БД публикаций */
.pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.pill {
  font-size: 0.78rem;
  font-weight: 500;
  border-radius: 999px;
  padding: 5px 12px;
  white-space: nowrap;
}
.p-draft { background: var(--st-draft-bg); color: var(--st-draft); }
.p-sched { background: var(--st-sched-bg); color: var(--st-sched); }
.p-review { background: var(--st-review-bg); color: var(--st-review); }
.p-pub { background: var(--st-pub-bg); color: var(--st-pub); }
.p-err { background: var(--st-err-bg); color: var(--st-err); }
.p-live { background: var(--accent); color: #fff; }

/* Стадии пайплайна */
.stages { display: grid; gap: 10px; margin-top: 36px; }
.stage {
  display: grid;
  grid-template-columns: 3.2rem 1fr auto;
  align-items: center;
  gap: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--rad-s);
  padding: 14px 18px;
}
.stage b { font-family: var(--font-display); font-size: 0.95rem; color: var(--ink-soft); }
.stage .who { font-size: 0.84rem; color: var(--ink-soft); }
.stage .bar { grid-column: 1 / -1; height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; }
.stage .bar i { display: block; height: 100%; background: var(--accent); border-radius: 2px; }

/* Таблица платформ */
.tbl { width: 100%; border-collapse: collapse; margin-top: 32px; font-size: 0.95rem; }
.tbl th, .tbl td { text-align: left; padding: 14px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { font-family: var(--font-display); font-size: 0.78rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-soft); }
.tbl tr:last-child td { border-bottom: 0; }
.scroll-x { overflow-x: auto; }

/* Полоса фактов */
.facts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-top: 40px; }
.fact { border-top: 2px solid var(--ink); padding-top: 14px; }
.fact b { display: block; font-family: var(--font-display); font-size: 1.7rem; letter-spacing: -0.02em; }
.fact span { font-size: 0.85rem; color: var(--ink-soft); }

/* ── Подвал ────────────────────────────────────────────────── */

footer {
  position: relative;
  z-index: 10;
  background: var(--bento-dark);
  color: var(--ink-inverse);
  padding: 64px 0 44px;
}
footer a { color: var(--ink-inverse); text-decoration: none; opacity: 0.78; }
footer a:hover { opacity: 1; text-decoration: underline; }
.foot-grid { display: flex; flex-wrap: wrap; gap: 40px 60px; justify-content: space-between; }
.foot-col h4 { font-size: 0.72rem; letter-spacing: 0.16em; text-transform: uppercase; opacity: 0.55; margin-bottom: 14px; }
.foot-col ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; font-size: 0.95rem; }
.foot-note { margin-top: 44px; font-size: 0.82rem; opacity: 0.5; }

/* ── Юридические страницы ──────────────────────────────────── */

.doc { padding: 120px 0 90px; }
.doc h1 { font-size: clamp(2rem, 6vw, 3rem); }
.doc h2 { font-size: 1.35rem; margin-top: 2.4em; scroll-margin-top: 96px; }
.doc h3 { font-size: 1.05rem; margin-top: 1.8em; scroll-margin-top: 96px; }
.doc p, .doc li { color: #2b2822; }
.doc ul, .doc ol { padding-left: 1.3em; }
.doc li { margin-bottom: 0.45em; }
.doc .meta { color: var(--ink-soft); font-size: 0.9rem; margin-bottom: 2.5em; }
.doc table { width: 100%; border-collapse: collapse; margin: 1.4em 0; font-size: 0.92rem; }
.doc th, .doc td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.doc th { font-family: var(--font-display); font-size: 0.76rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); }

/* Незаполненные реквизиты. Видно издалека — чтобы не уехало в прод. */
.todo {
  background: var(--st-review-bg);
  color: var(--st-review);
  border-radius: 4px;
  padding: 1px 6px;
  font-weight: 500;
  white-space: nowrap;
}

.notice {
  background: var(--bento-amber);
  border-radius: var(--rad-s);
  padding: 18px 20px;
  font-size: 0.92rem;
  margin: 0 0 2.5em;
}

.back {
  display: inline-block;
  margin-bottom: 34px;
  font-size: 0.85rem;
  color: var(--ink-soft);
  text-decoration: none;
}
.back:hover { color: var(--ink); }

/* ── Адаптив ───────────────────────────────────────────────── */

@media (max-width: 860px) {
  .bento { grid-template-columns: repeat(2, 1fr); }
  .bx, .bx-wide, .bx-full { grid-column: span 2; }
  .facts { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 520px) {
  body { font-size: 16px; }
  .stage { grid-template-columns: 2.8rem 1fr; }
  .stage .who { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  #hint { display: none; }
}
