/* UATH — Coming soon. Один экран: слева бренд и контакты, справа сетка с видео и направлениями */

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

html, body {
  margin: 0;
  height: 100%;
  overflow: clip;
}

html {
  color-scheme: light;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  background: var(--color-paper);
  color: var(--color-ink);
  font-family: var(--font-text);
  font-size: var(--text-small);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
a:hover {
  text-decoration: underline;
  text-decoration-thickness: var(--line);
  text-underline-offset: .25em;
}

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

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

/* ---------- Раскладка ---------- */

.page {
  height: 100vh;
  height: 100svh;
  height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  grid-template-areas:
    "brand    stage"
    "soon     stage"
    "contacts stage"
    "lang     stage";
}

/* ---------- Логотип ---------- */

.brand {
  grid-area: brand;
  margin: 0;
  padding: var(--pad-y) var(--pad-x) 0;
  line-height: 0;
}

.brand__logo {
  display: block;
  width: min(86%, 380px, 34vh);
  height: auto;
}

/* ---------- Coming soon ---------- */

.soon {
  grid-area: soon;
  margin: 0;
  padding: 0 var(--pad-x);
  min-height: 0;
  overflow: clip;
  display: flex;
  flex-direction: column;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(44px, 6vw, 120px); /* точный размер подгоняет main.js */
  line-height: .88;
  letter-spacing: -.015em;
  overflow-wrap: break-word;
  min-width: 0;
  transition: opacity .28s var(--ease-in-out);
}

.soon.is-swapping { opacity: 0; }

.soon__line {
  display: block;
  overflow: clip;
  /* маска шире строки, чтобы при плотном интерлиньяже не резать верх и хвосты букв */
  padding: .14em 0 .2em;
  margin: -.14em 0 -.2em;
}

.soon__text {
  display: inline-block;
  white-space: nowrap;
}

.soon__dots span {
  display: inline-block;
  animation: dot 2.8s var(--ease-in-out) infinite;
}
.soon__dots span:nth-child(2) { animation-delay: .25s; }
.soon__dots span:nth-child(3) { animation-delay: .5s; }

@keyframes dot {
  0%, 60%, 100% { opacity: 1; }
  30% { opacity: .18; }
}

/* ---------- Контакты и языки ---------- */

.contacts {
  grid-area: contacts;
  padding: 0 var(--pad-x);
  font-style: normal;
  color: var(--color-ink-soft);
  display: grid;
  grid-template-columns: auto auto;
  justify-content: start;
  column-gap: clamp(24px, 3vw, 56px);
  row-gap: .85em;
  /* Одна высота строки для адреса и телефонов: строки стоят вровень,
     а у каждого телефона зона нажатия не меньше 24 px */
  line-height: max(24px, 1.55em);
}

.contacts a { white-space: nowrap; }
.contacts__address { grid-column: 1; grid-row: 1; }
.contacts__phones { grid-column: 2; grid-row: 1; display: flex; flex-direction: column; }
.contacts__email { grid-column: 1 / -1; grid-row: 2; justify-self: start; }

.contacts a:hover { color: var(--color-ink); }
.contacts a:active { color: var(--color-ink-faint); }

.lang {
  grid-area: lang;
  padding: 1.6em var(--pad-x) var(--pad-y);
  display: flex;
  gap: .2em;
  margin-left: -.55em;
}

.lang button {
  font: inherit;
  font-weight: 500;
  line-height: 1;
  color: var(--color-ink-faint);
  background: none;
  border: 0;
  padding: .55em .55em;
  cursor: pointer;
  text-decoration-line: underline;
  text-decoration-color: transparent;
  text-decoration-thickness: var(--line);
  text-underline-offset: .45em;
  transition: color .2s linear, text-decoration-color .2s linear;
}

.lang button:hover { color: var(--color-ink); }
.lang button:active { transform: translateY(1px); }

.lang button[aria-pressed="true"] {
  color: var(--color-ink);
  text-decoration-color: currentColor;
}

/* ---------- Сетка справа ---------- */

.stage {
  --cols: 4;
  --rows: 3;
  grid-area: stage;
  position: relative;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  grid-template-rows: repeat(var(--rows), minmax(0, 1fr));
  container-type: size;
  --text-label: clamp(26px, 4cqi, 58px);
  --cell-pad: clamp(14px, 1.8cqi, 30px);
}

.lattice {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.ln {
  position: absolute;
  display: none;
  background: var(--color-line);
}

.ln--v {
  top: 0;
  bottom: 0;
  width: var(--line);
  left: calc(var(--at) * 100%);
  transform-origin: 50% 0;
}

.ln--h {
  left: 0;
  right: 0;
  height: var(--line);
  top: min(calc(var(--at) * 100%), calc(100% - var(--line)));
  transform-origin: 0 50%;
}

.ln--wide,
.ln--half,
.ln--h:not(.ln--stacked) { display: block; }

/* ---------- Плитки ---------- */

.tile {
  position: relative;
  z-index: 1;
  min-width: 0;
  min-height: 0;
  margin: var(--line) 0 0 var(--line);
  overflow: clip;
  background: var(--color-media);
}

.tile__media,
.tile__poster,
.tile video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.tile__poster,
.tile video {
  display: block;
  object-fit: cover;
  object-position: var(--focus, 50%) 50%;
}

.tile video {
  opacity: 0;
  transition: opacity .35s linear;
}
.tile video.is-playing { opacity: 1; }

.tile--label {
  background: var(--color-paper);
  padding: var(--cell-pad);
  display: flex;
  flex-direction: column;
}

.tile__index {
  font-family: var(--font-text);
  font-size: var(--text-small);
  line-height: 1;
  color: var(--color-ink-faint);
  font-variant-numeric: tabular-nums;
}

.tile__text {
  margin: auto 0 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: var(--text-label);
  line-height: 1.06;
  letter-spacing: -.012em;
  overflow-wrap: break-word;
  min-width: 0;
}

.tile__text .w {
  display: inline-block;
  overflow: clip;
  vertical-align: top;
  padding-bottom: .14em;
  margin-bottom: -.14em;
}
.tile__text .w > span { display: inline-block; }

.tile__text .arrow {
  display: inline-block;
  width: 1.1em;
  height: .48em;
  vertical-align: .1em;
  overflow: visible;
}
.tile__text .arrow path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tile--measure {
  position: absolute;
  top: 0;
  left: 0;
  visibility: hidden;
  pointer-events: none;
  background: none;
}
.tile--measure .tile__text { width: max-content; }

/* Статичная композиция (без JS) */
.tile--s1 { grid-column: 1 / span 2; grid-row: 1; }
.tile--s2 { grid-column: 3 / span 2; grid-row: 2; }
.tile--s3 { grid-column: 4; grid-row: 3; }
.js .tile--static { display: none; }

/* ---------- Появление ---------- */

.js [data-intro] {
  opacity: 0;
  transform: translateY(12px);
}
.is-in [data-intro] {
  opacity: 1;
  transform: none;
  transition:
    opacity .9s var(--ease-out) calc(var(--d, 0) * 1ms),
    transform 1.2s var(--ease-out) calc(var(--d, 0) * 1ms);
}

.js .soon__text { transform: translateY(108%); }
.is-in .soon__text {
  transform: none;
  transition: transform 1.3s var(--ease-out) .25s;
}
.is-in .soon__line + .soon__line .soon__text { transition-delay: .38s; }

.js .ln--v { transform: scaleY(0); }
.js .ln--h { transform: scaleX(0); }
.is-in .ln {
  transform: none;
  transition: transform 1.6s var(--ease-out);
}
.is-in .ln:nth-child(1) { transition-delay: .1s; }
.is-in .ln:nth-child(2) { transition-delay: .22s; }
.is-in .ln:nth-child(3) { transition-delay: .34s; }
.is-in .ln:nth-child(4) { transition-delay: .46s; }
.is-in .ln:nth-child(5) { transition-delay: .22s; }
.is-in .ln:nth-child(6) { transition-delay: .34s; }
.is-in .ln:nth-child(7) { transition-delay: .3s; }
.is-in .ln:nth-child(8) { transition-delay: .42s; }
.is-in .ln:nth-child(9) { transition-delay: .54s; }
.is-in .ln:nth-child(10) { transition-delay: .66s; }

/* ---------- Телефон и планшет в портрете: всё в столбик, тоже без скролла ---------- */

@media (orientation: portrait), (max-width: 599px) {
  .page {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    grid-template-areas:
      "brand    lang"
      "soon     soon"
      "stage    stage"
      "contacts contacts";
  }

  .brand { padding: var(--pad-y) var(--pad-x) 0; }
  .brand__logo { width: min(100%, 300px, 44vw, 22vh); }

  .lang {
    align-self: start;
    padding: calc(var(--pad-y) - .55em) var(--pad-x) 0 0;
    margin-left: 0;
  }

  /* В портрете — одной строкой; размер по ширине подгоняет main.js */
  .soon {
    padding: clamp(14px, 3.2vh, 44px) var(--pad-x);
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: baseline;
    column-gap: .24em;
    font-size: clamp(24px, 6.4vw, 64px);
  }

  .stage {
    --cols: 2;
    --text-label: clamp(22px, 6.4cqi, 44px);
    --cell-pad: clamp(12px, 3.6cqi, 24px);
    /* полоса под нижнюю линию сетки: плитки нижнего ряда её не перекрывают */
    padding-bottom: var(--line);
  }

  .ln--wide { display: none; }
  .ln--stacked { display: block; }

  /* Контакты прижаты к низу — сетке достаётся больше высоты */
  .contacts {
    padding: clamp(10px, 1.8vh, 24px) var(--pad-x) max(14px, env(safe-area-inset-bottom));
    column-gap: clamp(16px, 6vw, 48px);
    row-gap: .35em;
  }

  .tile--s1 { grid-column: 1 / span 2; grid-row: 1; }
  .tile--s2 { grid-column: 2; grid-row: 2; }
  .tile--s3 { grid-column: 1; grid-row: 3; }
}

/* Телефон: переключатель языка, логотип и «Coming soon» по центру */
@media (orientation: portrait) and (max-width: 699px), (max-width: 599px) {
  .page {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto minmax(0, 1fr) auto;
    grid-template-areas:
      "lang"
      "brand"
      "soon"
      "stage"
      "contacts";
  }

  .lang {
    justify-self: center;
    padding: calc(var(--pad-y) - .55em) var(--pad-x) 0;
  }

  .brand {
    justify-self: stretch;
    padding: clamp(6px, 1.6vh, 16px) var(--pad-x) 0;
  }
  .brand__logo { margin-inline: auto; }

  .soon { justify-content: center; }
}

@media (orientation: portrait) and (min-width: 700px) {
  .stage {
    --cols: 3;
    --text-label: clamp(26px, 4.6cqi, 52px);
  }
  .ln--half { display: none; }
  .ln--third { display: block; }

  .tile--s2 { grid-column: 3; grid-row: 2; }
  .tile--s3 { grid-column: 2; grid-row: 3; }
}

/* ---------- Телефон в ландшафте: узкая левая колонка, контакты в столбик ---------- */

@media (orientation: landscape) and (max-height: 500px) {
  .brand__logo { width: min(100%, 36vh); }
  .contacts {
    grid-template-columns: auto;
    row-gap: .5em;
  }
  .contacts__phones { grid-column: 1; grid-row: 2; }
  .contacts__email { grid-row: 3; }
  .lang { padding-top: .8em; }
}

/* ---------- Меньше движения ---------- */

@media (prefers-reduced-motion: reduce) {
  .js [data-intro],
  .js .soon__text,
  .js .ln--v,
  .js .ln--h { transform: none; }

  .is-in [data-intro],
  .is-in .soon__text,
  .is-in .ln { transition: opacity .6s linear; }

  .soon__dots span { animation: none; }
}

/* Без JS переключатель языка не работает — не показываем */
html:not(.js) .lang { visibility: hidden; }
