/* ownify · экраны 5.1 «Морда» и 5.2 «Театр сборки»
   Реализация 01-morda-teatr.dc.html. Брейкпоинты 390 / 768 / 1120. */

/* ============================================================
   1. База
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: 16px;
  line-height: 26px;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

a { color: var(--ink); }
a:hover { color: var(--ink-60); }

button { font: inherit; color: inherit; }

[hidden] { display: none !important; }

/* Счётчики — всегда табличными цифрами */
.num { font-variant-numeric: tabular-nums; }

.vh {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

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

/* prefers-reduced-motion: без анимаций, сетка целыми блоками,
   перекраска в --brand мгновенная. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    transition-delay: 0ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================================
   2. Общее: вордмарк, кнопки, плейсхолдеры
   ============================================================ */

/* Вордмарк ownify — строчными, 14px, --ink-60. Единственная константа обоих экранов. */
.wordmark {
  position: fixed;
  left: 40px;
  top: 36px;
  z-index: 3;
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  color: var(--ink-60);
  text-decoration: none;
  transition: opacity var(--t-recolor) var(--ease);
}
.wordmark:hover { color: var(--ink-60); }

/* Кнопки ownify — всегда чернила */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 56px;
  padding: 0 28px;
  border: 0;
  border-radius: var(--r-btn);
  background: var(--ink);
  color: var(--paper);
  font-size: 16px;
  line-height: 1;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t-base) var(--ease), opacity var(--t-base) var(--ease);
}
.btn:hover { background: var(--ink-hover); }
.btn:disabled { opacity: .35; cursor: default; }
.btn:disabled:hover { background: var(--ink); }
.btn.is-waiting { color: rgba(255, 255, 255, .7); cursor: default; }

/* Кнопка --brand существует только внутри витрины и превью (сцена театра) */
.btn--brand {
  height: 44px;
  padding: 0 22px;
  background: var(--brand);
  color: var(--brand-on);
  font-size: 14px;
  transition: background var(--t-recolor) var(--ease);
}
.btn--brand:hover { background: var(--brand); }

/* Плейсхолдер: полосатый паттерн + моно-подпись. Ничего не рисуем от руки. */
.ph {
  display: flex;
  align-items: center;
  justify-content: center;
  background: repeating-linear-gradient(45deg, var(--paper-dim) 0 12px, var(--line-soft) 12px 24px);
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 14px;
  color: var(--ink-60);
}

/* ============================================================
   3. Экран 5.1 — Морда
   Один экран всегда. ≤ 35 слов, ≥ 60% пустоты.
   ============================================================ */

.morda {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 96px 40px 84px;
  text-align: center;
  transition: opacity var(--t-base) var(--ease);
}

.morda__h1 {
  margin: 0;
  max-width: 680px;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 40px;
  line-height: 48px;
  letter-spacing: -0.01em;
}

.morda__sub {
  margin: 16px 0 0;
  max-width: 560px;
  font-size: 16px;
  line-height: 26px;
  color: var(--ink-60);
}

.morda__form {
  position: relative;
  width: var(--w-form);
  max-width: 100%;
  margin: 48px 0 0;
}

/* Поле: фон --paper-dim, граница --line, радиус 12, высота 56. Фокус — граница --ink. */
.field { position: relative; }

.field__input {
  display: block;
  width: 100%;
  height: 56px;
  margin: 0;
  padding: 0 170px 0 20px; /* справа — место под вложенную кнопку */
  background: var(--paper-dim);
  border: 1px solid var(--line);
  border-radius: var(--r-field);
  color: var(--ink);
  font-family: inherit;
  font-size: 16px;
  line-height: 26px;
  text-align: left;
  appearance: none;
  transition: border-color var(--t-base) var(--ease);
}
.field__input::placeholder { color: var(--ink-60); opacity: 1; }
.field__input:focus { border-color: var(--ink); outline: none; }
.field.is-error .field__input { border-color: var(--err); }

/* Кнопка внутри поля: вложенный радиус 8 (поле 12 с инсетом 6) */
.btn--inset {
  position: absolute;
  right: 6px;
  top: 6px;
  height: 44px;
  padding: 0 20px;
  border-radius: var(--r-btn-inset);
  font-size: 15px;
}

/* Ошибка не извиняется: что случилось и что делать */
.field__error {
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 20px;
  color: var(--err);
  text-align: left;
}
.field__error a { color: var(--err); }

.morda__quiet {
  margin: 20px 0 0;
  font-size: 13px;
  line-height: 20px;
  color: var(--ink-60);
}
.morda__quiet a {
  color: var(--ink-60);
  text-underline-offset: 3px;
}

.morda__foot {
  position: absolute;
  left: 0; right: 0;
  bottom: 32px;
  margin: 0;
  padding: 0 40px;
  font-size: 13px;
  line-height: 20px;
  color: var(--ink-60);
}

.morda__noscript {
  margin: 20px 0 0;
  font-size: 13px;
  line-height: 20px;
  color: var(--err);
}

/* Морда · mobile: блок ввода в средней трети, достаётся большим пальцем */
@media (max-width: 767px) {
  .wordmark { left: 20px; top: 24px; }

  .morda { padding: 80px 16px 72px; }
  .morda__h1 { font-size: 30px; line-height: 38px; }
  .morda__sub { margin-top: 12px; }

  .morda__form { width: 100%; margin-top: 32px; }
  .field { display: flex; flex-direction: column; gap: 12px; }
  .field__input { padding: 0 20px; }

  /* При отдельном использовании кнопка всегда 10 */
  .btn--inset {
    position: static;
    width: 100%;
    height: 56px;
    padding: 0 24px;
    border-radius: var(--r-btn);
    font-size: 16px;
  }

  .morda__quiet { margin-top: 16px; }
  .morda__foot { bottom: 24px; padding: 0 16px; }
}

/* ============================================================
   4. Экран 5.2 — Театр сборки
   Лог 360 слева, сцена с тенью справа. 40–70 сек, не быстрее 25.
   ============================================================ */

.theater {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  gap: 48px;
  padding: 120px 64px 64px;
  transition: padding var(--t-recolor) var(--ease),
              gap var(--t-recolor) var(--ease),
              opacity var(--t-base) var(--ease);
}

/* --- 4.1 Лог --- */

.theater__log {
  width: 360px;
  flex: none;
  padding-top: 8px;
  overflow: hidden;
  transition: width var(--t-recolor) var(--ease),
              opacity var(--t-recolor) var(--ease);
}

/* Лог длиннее колонки: старые строки уходят под мягкую кромку, свежая видна.
   Кромка появляется только когда есть что прятать — иначе она съедала бы
   первую строку. Класс ставит theater.js. */
.theater__log.is-scrolled {
  mask-image: linear-gradient(to bottom, transparent 0, #000 32px);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 32px);
}

.log {
  margin: 0;
  padding: 0;
  list-style: none;
}

.log__row {
  padding: 8px 0;
  animation: log-in var(--t-line) var(--ease) both;
}

.log__line {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

@keyframes log-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.log__mark {
  width: 20px;
  height: 26px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-60);
}
.log__mark svg { width: 18px; height: 18px; }

/* Текущая строка — точка чернилами; завершённая — чек --ink-60 */
.log__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink);
}

.log__text {
  font-size: 16px;
  line-height: 26px;
  font-variant-numeric: tabular-nums;
}
/* Числа внутри строк лога — вес 600 */
.log__text b { font-weight: 600; }

.log__row[data-state="active"] .log__text { font-weight: 500; color: var(--ink); }
.log__row[data-state="done"]   .log__text { color: var(--ink-60); }

/* Зелёный --ok — только у финального «Готово» */
.log__row[data-final] .log__mark { color: var(--ok); }
.log__row[data-final] .log__text { font-weight: 500; color: var(--ink); }

/* Шаг упал: строка не извиняется, экран ошибки рисует вызывающий код */
.log__row[data-state="failed"] .log__mark { color: var(--err); }
.log__row[data-state="failed"] .log__text { font-weight: 500; color: var(--err); }

/* Чипы палитры — плоские плашки цветопробы, без свечения */
.log__chips {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 6px 0 0 32px;
}
.chip {
  width: 24px;
  height: 24px;
  border-radius: var(--r-chip);
  border: 1px solid rgba(0, 0, 0, .06);
}

/* --- 4.2 Сцена --- */

.theater__scene {
  flex: 1;
  min-width: 0;
  display: flex;
  transition: padding var(--t-recolor) var(--ease);
}

.stage {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-scene);
  box-shadow: var(--shadow-scene);
  overflow: hidden;
  transition: box-shadow var(--t-recolor) var(--ease),
              border-radius var(--t-recolor) var(--ease),
              border-color var(--t-recolor) var(--ease);
}

/* Обойма браузера: адрес источника, затем адрес будущего сайта */
.stage__chrome {
  height: 44px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--line);
  transition: height var(--t-recolor) var(--ease),
              opacity var(--t-recolor) var(--ease);
}
.stage__url {
  height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  max-width: 70%;
  background: var(--paper-dim);
  border-radius: 999px;
  font-size: 13px;
  line-height: 20px;
  color: var(--ink-60);
  white-space: nowrap;
  overflow: hidden;
}
.caret {
  display: inline-block;
  width: 1px;
  height: 14px;
  flex: none;
  margin-left: 1px;
  background: var(--ink);
  animation: caret 1s step-end infinite;
}
@keyframes caret { 50% { opacity: 0; } }

/* Шапка сайта селлера */
.site__head {
  height: 60px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  transition: height var(--t-recolor) var(--ease), padding var(--t-recolor) var(--ease);
}
.site__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
}
/* Монограмма — акцент витрины, красится в --brand за 600ms */
.site__mono {
  width: 28px;
  height: 28px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--brand);
  color: var(--brand-on);
  font-size: 14px;
  line-height: 1;
  font-weight: 600;
  transition: background var(--t-recolor) var(--ease),
              width var(--t-recolor) var(--ease),
              height var(--t-recolor) var(--ease);
}
.site__name {
  font-size: 15px;
  line-height: 20px;
  font-weight: 600;
  transition: font-size var(--t-recolor) var(--ease);
}
.site__nav {
  display: flex;
  align-items: center;
  gap: 24px;
  margin-left: auto;
  min-width: 0;
}
.site__cat {
  font-size: 13px;
  line-height: 20px;
  color: var(--ink-60);
  white-space: nowrap;
  transition: color var(--t-recolor) var(--ease),
              border-color var(--t-recolor) var(--ease);
}
/* Активная категория — второй акцент --brand */
.site__cat.is-active {
  font-weight: 500;
  color: var(--brand);
  border-bottom: 2px solid var(--brand);
  padding-bottom: 2px;
}
.site__more {
  display: none;
  font-size: 12px;
  line-height: 20px;
  color: var(--ink-60);
}

/* Страница «О бренде» — второе из 2–3 мест Spectral */
.site__hero {
  flex: none;
  padding: 36px 32px;
  border-bottom: 1px solid var(--line);
  animation: block-in var(--t-line) var(--ease) both;
}
.site__about {
  margin: 0;
  max-width: 620px;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 26px;
  line-height: 34px;
}
/* Текст «О бренде» печатается из payload шага copy_write */
.site__about .caret { height: 26px; vertical-align: -4px; }
.site__hero .btn--brand { margin-top: 20px; }

@keyframes block-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

.site__body {
  flex: 1;
  min-height: 0;
  padding: 24px 28px;
  overflow: hidden;
  transition: padding var(--t-recolor) var(--ease);
}

.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.card {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--t-line) var(--ease), transform var(--t-line) var(--ease);
  transition-delay: calc(var(--i, 0) * var(--t-stagger));
}
.card.is-in { opacity: 1; transform: none; }

.card__photo {
  aspect-ratio: 3 / 4;
  border-radius: var(--r-card-mini);
}

/* Фото 3:4 — герой, UI молчит. Реальная картинка кроется по кадру. */
img.card__photo {
  display: block;
  width: 100%;
  height: auto;
  object-fit: cover;
  background: var(--paper-dim);
}
.card__name {
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 16px;
}
.card__price {
  margin: 2px 0 0;
  font-size: 13px;
  line-height: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* --- 4.3 Свёрнутый лог для mobile --- */

.theater__digest {
  display: none;
  flex: none;
  max-height: 240px;
  overflow: hidden;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--line);
  transition: opacity var(--t-recolor) var(--ease),
              max-height var(--t-recolor) var(--ease),
              padding var(--t-recolor) var(--ease),
              border-color var(--t-recolor) var(--ease);
}
.digest__done {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  line-height: 20px;
  color: var(--ink-60);
  font-variant-numeric: tabular-nums;
}
.digest__done svg { width: 14px; height: 14px; flex: none; }
.digest__now {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}
.digest__now .log__dot { flex: none; }
.digest__text {
  font-size: 15px;
  line-height: 22px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.digest__text b { font-weight: 600; }
.digest__chips { display: inline-flex; gap: 5px; flex: none; }
.digest__chips .chip { width: 18px; height: 18px; border-radius: 5px; }

/* --- 4.4 Кадр 3: «передача ключей» --- */

/* Лог и рамка растворяются, сцена становится сайтом */
.theater[data-phase="handoff"],
.theater[data-phase="release"] {
  padding: 120px 40px 40px 64px;
  gap: 40px;
}

body[data-phase="handoff"] .wordmark,
body[data-phase="release"] .wordmark { opacity: .4; }

.theater[data-phase="handoff"] .theater__log {
  width: 280px;
  opacity: .35;
}
.theater[data-phase="handoff"] .log__row { padding: 6px 0; }
.theater[data-phase="handoff"] .log__mark { height: 24px; }
.theater[data-phase="handoff"] .log__mark svg { width: 16px; height: 16px; }
.theater[data-phase="handoff"] .log__text { font-size: 14px; line-height: 24px; }

.theater[data-phase="handoff"] .stage,
.theater[data-phase="release"] .stage {
  box-shadow: 0 8px 40px rgba(0, 0, 0, .04);
}
.theater[data-phase="handoff"] .site__head,
.theater[data-phase="release"] .site__head {
  height: 64px;
  padding: 0 32px;
}
.theater[data-phase="handoff"] .site__mono,
.theater[data-phase="release"] .site__mono { width: 30px; height: 30px; }
.theater[data-phase="handoff"] .site__name,
.theater[data-phase="release"] .site__name { font-size: 16px; }
.theater[data-phase="handoff"] .site__body,
.theater[data-phase="release"] .site__body { padding: 24px 32px; }

/* На готовом сайте активной категории нет — акцент снимается */
.theater[data-phase="handoff"] .site__cat,
.theater[data-phase="release"] .site__cat {
  color: var(--ink);
  font-weight: 400;
  border-bottom-color: transparent;
}

/* Растворение: рамка и лог уходят, сайт остаётся во весь экран */
.theater[data-phase="release"] { padding: 0; gap: 0; }
.theater[data-phase="release"] .theater__log {
  width: 0;
  opacity: 0;
}
.theater[data-phase="release"] .theater__digest {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
  border-bottom-color: transparent;
}
.theater[data-phase="release"] .stage {
  border-radius: 0;
  border-color: transparent;
  box-shadow: none;
}

/* Обойма браузера растворяется вместе с рамкой */
.theater[data-chrome="none"] .stage__chrome {
  height: 0;
  opacity: 0;
  overflow: hidden;
  border-bottom-color: transparent;
}

/* Скрытые до своего шага части сцены */
.theater[data-site="off"] .site__head,
.theater[data-site="off"] .site__body,
.theater[data-hero="off"] .site__hero { display: none; }

/* Театр · mobile: завершённые строки сворачиваются в одну строку с чеком,
   текущая закреплена над сценой. */
@media (max-width: 767px) {
  .theater {
    flex-direction: column;
    gap: 0;
    padding: 56px 0 0;
  }
  .theater[data-phase="handoff"],
  .theater[data-phase="release"] { padding: 56px 0 0; gap: 0; }
  .theater[data-phase="release"] { padding: 0; }

  .theater__log { display: none; }
  .theater__digest { display: block; }

  .theater__scene {
    flex: 1;
    min-height: 0;
    padding: 16px;
    display: flex;
  }
  .theater[data-phase="release"] .theater__scene { padding: 0; }

  .stage { width: 100%; }
  .stage__chrome { display: none; }

  .site__head { height: 52px; padding: 0 16px; gap: 8px; }
  .theater[data-phase="handoff"] .site__head,
  .theater[data-phase="release"] .site__head { height: 52px; padding: 0 16px; }
  .site__mono { width: 26px; height: 26px; font-size: 13px; }
  .theater[data-phase="handoff"] .site__mono,
  .theater[data-phase="release"] .site__mono { width: 26px; height: 26px; }
  .site__name { font-size: 14px; }
  .theater[data-phase="handoff"] .site__name,
  .theater[data-phase="release"] .site__name { font-size: 14px; }

  .site__nav { gap: 12px; }
  .site__cat { font-size: 12px; }
  .site__cat:not(.is-active) { display: none; }
  .site__more { display: inline; }
  .theater[data-phase="handoff"] .site__cat:not(.is-active),
  .theater[data-phase="release"] .site__cat:not(.is-active) { display: inline; }
  .theater[data-phase="handoff"] .site__more,
  .theater[data-phase="release"] .site__more { display: none; }

  .site__hero { padding: 20px 16px; }
  .site__about { font-size: 20px; line-height: 28px; }

  .site__body { padding: 14px; }
  .theater[data-phase="handoff"] .site__body,
  .theater[data-phase="release"] .site__body { padding: 14px; }
  .grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .card__name { margin-top: 6px; }
}

/* Планшет: сцена не должна ужиматься до нечитаемой сетки */
@media (min-width: 768px) and (max-width: 1119px) {
  .theater { padding: 96px 32px 32px; gap: 32px; }
  .theater[data-phase="handoff"] { padding: 96px 24px 32px 32px; gap: 28px; }
  .theater__log { width: 300px; }
  .theater[data-phase="handoff"] .theater__log { width: 240px; }
  .grid { grid-template-columns: repeat(3, 1fr); }
}

/* ============================================================
   5. Переключение экранов
   ============================================================ */

body[data-view="morda"]   .theater { display: none; }
body[data-view="theater"] .morda   { display: none; }
