/* Лендинг Метчера: цвета и шрифты приложения (web/src/styles/base.css) и видео (videos/metcher-puzzle) */

@font-face {
  font-family: "Metcher Sans";
  src: url("/landing/fonts/montserrat.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Metcher Mono";
  src: url("/landing/fonts/jetbrains-mono.woff2") format("woff2");
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --border: #e3e8f0;
  --border-strong: #d5dced;
  --text: #172033;
  --text-soft: #3b4660;
  --muted: #64708a;
  --accent: #2457d6;
  --accent-dark: #1b45b0;
  --accent-soft: #e8efff;
  --success: #12804a;
  --success-soft: #e3f6ec;
  --error: #c02e3b;
  --error-soft: #fde8ea;
  --sans: "Metcher Sans", "Segoe UI", system-ui, sans-serif;
  --mono: "Metcher Mono", ui-monospace, monospace;
  --wrap: 1180px;
  --gutter: 24px;
}

* {
  box-sizing: border-box;
}
html {
  scroll-behavior: smooth;
  scroll-padding-top: 88px;
}
/* Детали до анимации стоят за краем экрана: обрезаем по горизонтали. clip, а не hidden — hidden
   сделал бы body контейнером прокрутки и сломал липкую шапку */
html,
body {
  overflow-x: clip;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 18px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
img,
video {
  display: block;
  max-width: 100%;
}
a {
  color: inherit;
}
h1,
h2,
h3,
p {
  margin: 0;
}

.wrap {
  width: 100%;
  max-width: calc(var(--wrap) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.eyebrow {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}
h1 {
  font-weight: 900;
  font-size: clamp(42px, 6vw, 76px);
  line-height: 1;
  letter-spacing: -0.04em;
}
h2 {
  font-weight: 900;
  font-size: clamp(32px, 4.2vw, 52px);
  line-height: 1.05;
  letter-spacing: -0.035em;
}
.lead {
  font-size: clamp(18px, 1.6vw, 21px);
  line-height: 1.5;
  color: var(--text-soft);
}

/* ---------------------------------------------------------------- кнопки */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  border-radius: 12px;
  border: 2px solid transparent;
  font-family: var(--sans);
  font-weight: 800;
  font-size: 17px;
  text-decoration: none;
  white-space: nowrap;
  transition:
    background 0.15s ease,
    transform 0.15s ease,
    box-shadow 0.15s ease;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 10px 24px rgba(36, 87, 214, 0.28);
}
.btn-primary:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
}
.btn-ghost {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}
.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.btn-sm {
  padding: 10px 18px;
  font-size: 15px;
  border-radius: 10px;
}
.btn:focus-visible,
.nav a:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

/* ---------------------------------------------------------------- шапка */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(245, 247, 251, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar .wrap {
  display: flex;
  align-items: center;
  gap: 28px;
  height: 72px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 900;
  font-size: 22px;
  letter-spacing: -0.03em;
  color: var(--accent);
  text-decoration: none;
}
.brand img {
  width: 36px;
  height: 36px;
}
.nav {
  display: flex;
  gap: 24px;
  margin-right: auto;
}
.nav a {
  font-weight: 600;
  font-size: 15px;
  color: var(--text-soft);
  text-decoration: none;
}
.nav a:hover {
  color: var(--accent);
}
.topbar-actions {
  display: flex;
  gap: 10px;
}

/* ---------------------------------------------------------------- секции */

section {
  position: relative;
  padding: 96px 0;
}
.section-head {
  display: grid;
  gap: 16px;
  max-width: 720px;
  margin-bottom: 48px;
}
.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 64px;
  align-items: center;
}
.split-text {
  display: grid;
  gap: 20px;
}
.ticks {
  display: grid;
  gap: 10px;
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
}
.ticks li {
  position: relative;
  padding-left: 34px;
  color: var(--text-soft);
}
.ticks li::before {
  content: "✓";
  position: absolute;
  left: 0;
  top: 1px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 900;
  font-size: 14px;
  line-height: 24px;
  text-align: center;
}
.note {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--muted);
}
.note a {
  color: var(--accent);
}

/* ---------------------------------------------------------------- первый экран */

.hero {
  padding: 72px 0 96px;
  overflow: hidden;
}
#hero-ghosts {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
#hero-ghosts path {
  fill: none;
  stroke: var(--accent);
  stroke-opacity: 0.13;
  stroke-width: 3;
}
.hero .split {
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
}
.hero-text {
  display: grid;
  gap: 24px;
  position: relative;
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.hero-formats {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--muted);
}
.hero-visual {
  position: relative;
}
.hero-visual::before {
  content: "";
  position: absolute;
  inset: -12% -10%;
  background: radial-gradient(circle, rgba(36, 87, 214, 0.16), rgba(36, 87, 214, 0) 65%);
  pointer-events: none;
}

/* Фрагмент ролика вместо живого пазла — только на телефоне и планшете */
.hero-clip {
  display: none;
  position: relative;
}
.hero-clip video {
  width: 100%;
  aspect-ratio: 9 / 16;
  border-radius: 28px;
  border: 1px solid var(--border);
  background: var(--bg);
  box-shadow: 0 24px 56px rgba(23, 32, 51, 0.16);
  object-fit: cover;
}
.hero-clip-link {
  display: block;
  margin-top: 14px;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 14px;
  text-align: center;
  color: var(--accent);
  text-decoration: none;
}

/* ---------------------------------------------------------------- сцены и детали */

.stage-wrap {
  position: relative;
  width: 100%;
}
.stage {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
}
.piece {
  position: absolute;
  display: block;
}
.piece-shape {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 14px 30px rgba(23, 32, 51, 0.12));
}
.piece-shape path {
  fill: var(--surface);
  stroke: var(--border-strong);
  stroke-width: 3;
  stroke-linejoin: round;
  transition:
    stroke 0.2s ease,
    fill 0.2s ease;
}
.piece-body {
  position: absolute;
  inset: var(--pad);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  padding: 0 40px;
}
.piece.is-match .piece-shape path {
  stroke: var(--accent);
  stroke-width: 5;
}
.piece.is-miss .piece-shape path {
  stroke: var(--error);
  stroke-width: 4;
  fill: #fffafa;
}
.piece.is-blue .piece-shape path {
  fill: var(--accent);
  stroke: var(--accent);
}

/* Стык совпавших деталей: щелчок → граница мигает зелёным и исчезает, детали становятся одной
   карточкой в синей рамке. Тела деталей примыкают, выступ внутри — объединение это прямоугольник. */
.joint-frame {
  position: absolute;
  border: 5px solid var(--accent);
  box-shadow: 0 14px 30px rgba(23, 32, 51, 0.12);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.joint-seam {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}
.joint-seam path {
  fill: none;
  stroke: var(--success);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
}
.is-joined .joint-frame {
  opacity: 1;
}
.is-joined .joint-seam path {
  animation: seam-flash 1.2s ease-out forwards;
}
.is-joined .piece.joined .piece-shape {
  filter: none;
}
.is-joined .piece.joined .piece-shape path {
  stroke: transparent;
}
@keyframes seam-flash {
  0% {
    opacity: 0;
  }
  12% {
    opacity: 1;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

/* Типографика внутри сцен — в пикселях сцены, масштабируется вместе с ней */
.p-k {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 30px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}
.p-name {
  font-weight: 900;
  font-size: 52px;
  line-height: 1.03;
  letter-spacing: -0.03em;
}
.p-spec {
  font-family: var(--mono);
  font-size: 32px;
  color: var(--text-soft);
}
.p-price {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 46px;
}
.p-why {
  font-family: var(--mono);
  font-size: 30px;
}
.p-row {
  display: flex;
  align-items: center;
  gap: 18px;
}
.p-badge {
  display: block;
  padding: 8px 22px;
  border-radius: 999px;
  background: var(--success-soft);
  color: var(--success);
  font-weight: 800;
  font-size: 32px;
}
.p-why.ok {
  color: var(--success);
}
.p-why.miss {
  color: var(--error);
}
.p-desc {
  font-size: 28px;
  line-height: 1.35;
  color: var(--text-soft);
}
.p-num {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 34px;
  color: var(--accent);
}
.p-title {
  font-weight: 900;
  font-size: 44px;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

/* Первый экран: подписи появляются только у «лучшего» и только у отвергнутых */
#hero-best .p-badge,
#hero-best .p-why {
  opacity: 0;
  transform: scale(0.8);
  transform-origin: 0 50%;
  transition:
    opacity 0.3s ease,
    transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}
#hero-best.is-best .p-badge,
#hero-best.is-best .p-why {
  opacity: 1;
  transform: none;
}
.hero-miss .p-why {
  opacity: 0;
  transition: opacity 0.25s ease;
}
.hero-miss.is-miss .p-why {
  opacity: 1;
}
#hero-status {
  position: absolute;
  left: 70px;
  right: 70px;
  top: 650px;
  padding: 22px 30px;
  border-radius: 20px;
  background: var(--surface);
  border: 3px solid var(--border);
  font-family: var(--mono);
  font-weight: 700;
  font-size: 34px;
  color: var(--muted);
  text-align: center;
  transition:
    color 0.2s ease,
    border-color 0.2s ease;
}
#hero-status[data-tone="miss"] {
  color: var(--error);
  border-color: var(--error-soft);
}
#hero-status[data-tone="ok"] {
  color: var(--success);
  border-color: var(--success-soft);
}

/* Появление деталей при прокрутке: из --fx/--fy/--fr в своё место */
.reveal .fly {
  transform: translate(var(--fx, 0), var(--fy, 0)) rotate(var(--fr, 0deg));
  opacity: 0;
  transition:
    transform 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) var(--d, 0ms),
    opacity 0.4s ease var(--d, 0ms);
}
.reveal.is-in .fly {
  transform: none;
  opacity: 1;
}
/* Отвергнутые в примере подбора: в покое — повёрнуты и с красным контуром */
.reveal.is-in .fly.tilt-l {
  transform: rotate(-5deg);
}
.reveal.is-in .fly.tilt-r {
  transform: rotate(4deg);
}
.reveal .late {
  opacity: 0;
  transition: opacity 0.4s ease var(--d, 0ms);
}
.reveal.is-in .late {
  opacity: 1;
}

/* ---------------------------------------------------------------- шаги */

.steps-mobile {
  display: none;
}

/* ---------------------------------------------------------------- пример подбора */

.match-card {
  padding: 32px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--border);
}

/* ---------------------------------------------------------------- результат */

.result-frame {
  padding: 18px;
  border-radius: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 30px 70px rgba(23, 32, 51, 0.14);
}
#result-tiles .tile {
  position: absolute;
  display: block;
  background-image: url("/landing/app-result.webp");
  background-size: 936px auto;
  background-repeat: no-repeat;
  background-color: var(--bg);
}
#result-tiles .seams {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  transition: opacity 0.8s ease 1.6s;
}
#result-tiles .seams path {
  fill: none;
  stroke: var(--accent);
  stroke-opacity: 0.45;
  stroke-width: 3;
}
.reveal.is-in #result-tiles .seams {
  opacity: 0;
}
.reveal #result-tiles .tile {
  transform: translate(var(--fx), var(--fy)) rotate(var(--fr));
  opacity: 0;
  transition:
    transform 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) var(--d),
    opacity 0.4s ease var(--d);
}
.reveal.is-in #result-tiles .tile {
  transform: none;
  opacity: 1;
}

/* ---------------------------------------------------------------- видео */

.video-section {
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.phone {
  width: min(340px, 100%);
  margin: 0 auto;
  padding: 12px;
  border-radius: 44px;
  background: var(--text);
  box-shadow: 0 30px 70px rgba(23, 32, 51, 0.28);
}
.phone video {
  width: 100%;
  aspect-ratio: 9 / 16;
  border-radius: 34px;
  background: var(--bg);
  object-fit: cover;
}

/* ---------------------------------------------------------------- финал */

.final .split {
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.9fr);
}
.lid-wrap {
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
}
#lid-tiles .lid-tile {
  position: absolute;
  display: block;
  transform: translate(var(--fx), var(--fy)) rotate(var(--fr));
  opacity: 0;
  transition:
    transform 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) var(--d),
    opacity 0.3s ease var(--d);
}
#lid-tiles .lid-tile svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}
#lid-tiles .lid-tile path {
  fill: var(--accent);
  stroke: #fff;
  stroke-opacity: 0.3;
  stroke-width: 3;
}
.reveal.is-in #lid-tiles .lid-tile {
  transform: none;
  opacity: 1;
}
#lid {
  position: absolute;
  inset: 0;
  border-radius: 36px;
  background: var(--accent);
  box-shadow:
    0 26px 0 var(--accent-dark),
    0 60px 90px rgba(23, 32, 51, 0.28);
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.4s ease 1.7s;
}
.reveal.is-in #lid {
  opacity: 1;
}
.reveal.is-in #lid-tiles {
  opacity: 0;
  transition: opacity 0.4s ease 1.9s;
}
#lid-ghosts {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
#lid-ghosts path {
  fill: none;
  stroke: #fff;
  stroke-opacity: 0.16;
  stroke-width: 3;
}
.lid-inner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 30px;
  text-align: center;
}
.lid-inner img {
  width: 300px;
  height: 300px;
  border-radius: 64px;
  box-shadow: 0 0 0 10px rgba(255, 255, 255, 0.9);
}
.lid-name {
  font-weight: 900;
  font-size: 168px;
  line-height: 1;
  letter-spacing: -0.045em;
  color: #fff;
}
.lid-line {
  font-weight: 700;
  font-size: 56px;
  color: var(--accent-soft);
}

/* ---------------------------------------------------------------- подвал */

.footer {
  padding: 40px 0 48px;
  border-top: 1px solid var(--border);
  font-size: 15px;
  color: var(--muted);
}
.footer .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px 32px;
}
.footer .brand {
  font-size: 18px;
}
.footer .brand img {
  width: 28px;
  height: 28px;
}
.footer a {
  color: var(--text-soft);
}
.footer a:hover {
  color: var(--accent);
}
.footer-copy {
  margin-left: auto;
}

.sticky-cta {
  display: none;
}

/* ---------------------------------------------------------------- телефон и планшет */

@media (max-width: 960px) {
  section {
    padding: 72px 0;
  }
  .split,
  .hero .split,
  .final .split {
    grid-template-columns: minmax(0, 1fr);
    gap: 40px;
  }
  .nav {
    display: none;
  }
  .topbar .wrap {
    justify-content: space-between;
  }
  .hero {
    padding: 40px 0 72px;
  }
  .hero-visual {
    max-width: 360px;
    width: 100%;
    margin: 0 auto;
  }
  .hero-visual .stage-wrap {
    display: none;
  }
  .hero-clip {
    display: block;
  }
  .steps-desktop {
    display: none;
  }
  .steps-mobile {
    display: block;
    max-width: 520px;
    margin: 0 auto;
  }
  .match-card {
    padding: 20px;
  }
  .result-frame {
    padding: 10px;
    border-radius: 20px;
  }
}

@media (max-width: 640px) {
  :root {
    --gutter: 18px;
  }
  body {
    font-size: 17px;
    padding-bottom: 84px;
  }
  .topbar .wrap {
    height: 64px;
  }
  .topbar-actions .btn-primary {
    display: none;
  }
  .hero-actions .btn {
    flex: 1 1 100%;
  }
  .section-head {
    margin-bottom: 32px;
  }
  .footer-copy {
    margin-left: 0;
  }
  .sticky-cta {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    padding: 12px var(--gutter) calc(12px + env(safe-area-inset-bottom));
    background: rgba(245, 247, 251, 0.94);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
  }
  .sticky-cta .btn {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}
