/* Анфилада LADOVA. Палитра и шрифты те же, что на основном сайте. */

:root {
  color-scheme: only light;
  --svh: 100vh;
  --cream: #f6f1ea;
  --paper: #fbf8f3;
  --sand: #ede3d6;
  --blush: #ebd5d0;
  --rose: #a9776e;
  --olive-deep: #5c6148;
  --ink: #35332f;
  --muted: #6f685f;
  --line: rgba(53, 51, 47, 0.14);

  --serif: 'Cormorant', 'Cormorant Garamond', Georgia, serif;
  --sans: 'Montserrat', 'Segoe UI', sans-serif;
  --script: 'Great Vibes', cursive;

  --gutter: clamp(18px, 4vw, 56px);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

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

/* высота экрана без прячущейся адресной строки; у переменных запасное значение второй строкой не работает */
@supports (height: 100svh) {
  :root {
    --svh: 100svh;
  }
}

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

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

p,
h1,
h2 {
  margin: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

#gl,
.scrim,
.grain {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#gl {
  z-index: 0;
}

/* Затемнение только там, где стоит подпись комнаты (левый нижний угол), и лёгкая тень под шапку:
   сам рендер остаётся открытым. */
.scrim {
  z-index: 1;
  background:
    radial-gradient(115% 95% at 0% 100%, rgba(30, 26, 22, 0.6), rgba(30, 26, 22, 0.28) 38%, rgba(30, 26, 22, 0) 68%),
    linear-gradient(to bottom, rgba(30, 26, 22, 0.22), rgba(30, 26, 22, 0) 15%);
  opacity: 0;
  transition: opacity 0.9s var(--ease);
}

.is-cap .scrim {
  opacity: 1;
}

/* Бумажное зерно. Без режима наложения: он заставляет браузер пересобирать весь экран на каждом кадре.
   Над рендерами зерно гаснет: на картинке оно читается как грязь. */
.grain {
  z-index: 2;
  opacity: 0.5;
  transition: opacity 0.6s var(--ease);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .55 0 0 0 0 .5 0 0 0 0 .44 0 0 0 .1 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.is-inside .grain {
  opacity: 0;
}

/* рамка арочного окна: нужна только на вертикальном экране */
.frame {
  display: none;
}

/* Мерка высоты экрана без прячущейся адресной строки: по ней считается длина прокрутки. */
#vh {
  position: fixed;
  left: 0;
  top: 0;
  width: 0;
  height: 100vh;
  height: 100svh;
  visibility: hidden;
  pointer-events: none;
}

.track {
  position: relative;
  width: 1px;
  height: 1200vh;
}

/* ---------- Типографика ---------- */

.script {
  font-family: var(--script);
  line-height: 1;
  color: var(--rose);
}

.eyebrow {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}

.lead {
  font-size: clamp(15px, 1.25vw, 18px);
  font-weight: 300;
  line-height: 1.7;
  max-width: 30em;
}

.link-arrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 5px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  background: linear-gradient(currentColor, currentColor) 0 100% / 100% 1px no-repeat;
  transition: gap 0.35s var(--ease);
}

.link-arrow::after {
  content: '→';
  font-size: 14px;
  letter-spacing: 0;
}

@media (hover: hover) {
  .link-arrow:hover {
    gap: 16px;
  }
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 50px;
  padding: 0 30px;
  border-radius: 999px;
  background: var(--olive-deep);
  color: var(--paper);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  white-space: nowrap;
  transition: background 0.35s var(--ease), transform 0.35s var(--ease);
}

@media (hover: hover) {
  .btn:hover {
    background: var(--ink);
  }
}

.btn:active {
  transform: scale(0.98);
}

/* ---------- Шапка ---------- */

.top {
  position: fixed;
  inset: 0 0 auto;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 72px;
  padding-inline: var(--gutter);
  transition: color 0.6s var(--ease);
}

.top__logo img {
  display: block;
  width: 150px;
  height: auto;
  transition: filter 0.6s var(--ease);
}

/* над рендерами шапка светлая, с мягкой тенью: на светлой стене без неё логотип теряется */
.is-inside .top {
  color: var(--paper);
  text-shadow: 0 1px 12px rgba(30, 26, 22, 0.55);
}

.is-inside .top__logo img {
  filter: invert(1) brightness(1.7) drop-shadow(0 1px 10px rgba(30, 26, 22, 0.5));
}

/* ---------- Загрузка ---------- */

.loader {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 6px;
  background: var(--cream);
}

.loader .script {
  font-size: clamp(54px, 8vw, 110px);
}

.loader__pct {
  font-family: var(--serif);
  font-size: 18px;
  letter-spacing: 0.3em;
  color: var(--muted);
}

.loader__pct b {
  font-weight: 400;
}

/* Плавно только уходит: при повороте экрана загрузка должна закрыть сцену сразу. */
.is-ready .loader {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.9s var(--ease) 0.15s, visibility 0s 1.1s;
}

/* ---------- Титул ---------- */

.intro {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  padding: 72px var(--gutter) 40px;
  pointer-events: none;
  will-change: opacity, transform;
}

.intro__copy {
  width: min(46vw, 730px);
}

.intro__title {
  margin: 18px 0 26px;
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(40px, 5.3vw, 84px);
  line-height: 0.98;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.intro__title > span {
  display: block;
}

.intro__title .script {
  margin: 0 0 -0.1em 0.04em;
  font-size: clamp(60px, 8vw, 122px);
  letter-spacing: 0;
  text-transform: none;
}

.hint {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: clamp(28px, 4vw, 52px);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}

.hint i {
  position: relative;
  width: 1px;
  height: 46px;
  background: var(--line);
  overflow: hidden;
}

.hint i::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--ink);
  animation: drip 2.2s var(--ease) infinite;
}

@keyframes drip {
  from {
    transform: translateY(-100%);
  }

  to {
    transform: translateY(100%);
  }
}

.intro__copy > * {
  opacity: 0;
  transform: translateY(18px);
}

.is-ready .intro__copy > * {
  opacity: 1;
  transform: none;
  transition: opacity 1.1s var(--ease), transform 1.1s var(--ease);
}

.is-ready .intro__copy > :nth-child(1) { transition-delay: 0.35s; }
.is-ready .intro__copy > :nth-child(2) { transition-delay: 0.47s; }
.is-ready .intro__copy > :nth-child(3) { transition-delay: 0.6s; }
.is-ready .intro__copy > :nth-child(4) { transition-delay: 0.75s; }

/* ---------- Подписи комнат ---------- */

.hud {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  color: var(--paper);
}

.cap {
  position: absolute;
  left: var(--gutter);
  right: var(--gutter);
  bottom: clamp(26px, 5vw, 60px);
  visibility: hidden;
  transition: visibility 0s 0.7s;
}

.cap.is-on {
  visibility: visible;
  transition-delay: 0s;
}

.mask {
  display: block;
  overflow: hidden;
  padding: 0.14em 0.1em 0.08em;
  margin: -0.14em -0.1em -0.08em;
}

.mask > span {
  display: block;
  transform: translateY(112%);
  transition: transform 0.7s var(--ease);
}

.cap.is-on .mask > span {
  transform: none;
  transition-duration: 1.15s;
}

.cap__idx,
.cap__lead,
.cap__foot {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.5s var(--ease), transform 0.5s var(--ease);
}

.cap.is-on .cap__idx,
.cap.is-on .cap__lead,
.cap.is-on .cap__foot {
  opacity: 1;
  transform: none;
  transition-duration: 1s;
}

.cap.is-on .cap__idx { transition-delay: 0.05s; }
.cap.is-on .cap__title .mask > span { transition-delay: 0.1s; }
.cap.is-on .cap__room .mask > span { transition-delay: 0.28s; }
.cap.is-on .cap__lead { transition-delay: 0.36s; }
.cap.is-on .cap__foot { transition-delay: 0.46s; }

.cap__idx {
  font-family: var(--serif);
  font-style: italic;
  font-size: 18px;
  letter-spacing: 0.06em;
  opacity: 0;
}

.cap__idx span {
  font-size: 26px;
}

/* площадь квартиры рядом с номером комнаты */
.cap__area {
  margin-left: 16px;
  padding-left: 16px;
  border-left: 1px solid currentColor;
  font-style: normal;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.16em;
}

.cap__area:empty {
  display: none;
}

.cap__title {
  margin-top: 4px;
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(46px, 8.6vw, 136px);
  line-height: 0.96;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  text-shadow: 0 2px 30px rgba(30, 26, 22, 0.25);
}

.cap--long .cap__title {
  font-size: clamp(34px, 6.2vw, 100px);
}

.cap__room {
  margin: -0.5em 0 0 0.2em;
  font-family: var(--script);
  font-size: clamp(40px, 5.4vw, 84px);
  line-height: 1.1;
  color: var(--blush);
  text-shadow: 0 2px 24px rgba(30, 26, 22, 0.35);
}

.cap__room .mask {
  padding: 0.3em 0.2em 0.3em;
  margin: -0.3em -0.2em -0.3em;
}

.cap__lead {
  margin-top: 8px;
  max-width: 30em;
  font-size: 15px;
  font-weight: 300;
}

.cap__foot {
  display: flex;
  align-items: center;
  gap: 22px;
  margin-top: 18px;
  pointer-events: auto;
}

.swatches {
  display: inline-flex;
}

.swatches i {
  width: 20px;
  height: 20px;
  margin-left: -6px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(251, 248, 243, 0.85);
}

.swatches i:first-child {
  margin-left: 0;
}

/* ---------- Точки комнат справа ---------- */

.rail {
  position: fixed;
  right: calc(var(--gutter) - 8px);
  top: 50%;
  z-index: 20;
  display: grid;
  gap: 4px;
  transform: translateY(-50%);
  opacity: 0;
  transition: opacity 0.6s var(--ease);
  pointer-events: none;
}

.is-inside .rail {
  opacity: 1;
  pointer-events: auto;
}

.rail button {
  position: relative;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

.rail button::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 5px;
  height: 5px;
  margin: -2.5px;
  border-radius: 50%;
  background: var(--paper);
  opacity: 0.55;
  transition: transform 0.5s var(--ease), opacity 0.5s var(--ease);
}

.rail button.is-on::before {
  opacity: 1;
  transform: scale(2.2);
}

/* ---------- Финал ---------- */

.outro {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 4px;
  padding: 72px var(--gutter) 40px;
  text-align: center;
  visibility: hidden;
  pointer-events: none;
}

.outro > * {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s var(--ease), transform 0.5s var(--ease);
}

.is-out .outro {
  visibility: visible;
  pointer-events: auto;
}

.is-out .outro > * {
  opacity: 1;
  transform: none;
  transition-duration: 1.1s;
}

.is-out .outro > :nth-child(2) { transition-delay: 0.1s; }
.is-out .outro > :nth-child(3) { transition-delay: 0.2s; }
.is-out .outro > :nth-child(4) { transition-delay: 0.3s; }

.outro .script {
  font-size: clamp(48px, 6vw, 88px);
}

.outro__title {
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(34px, 5.4vw, 78px);
  line-height: 1.02;
  letter-spacing: 0.035em;
  text-transform: uppercase;
  text-wrap: balance;
}

.outro .lead {
  margin-top: 22px;
}

.outro__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 18px 30px;
  margin-top: 30px;
}

.nogl,
.nojs {
  display: none;
  position: fixed;
  inset: auto var(--gutter) 40px;
  z-index: 50;
  text-align: center;
}

.nogl a,
.nojs a {
  text-decoration: underline;
}

.no-gl .nogl,
.nojs {
  display: block;
}

.no-gl #gl,
.no-gl .frame {
  display: none;
}

.no-gl .loader {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.9s var(--ease) 0.15s, visibility 0s 1.1s;
}

/* ---------- Почти квадратный экран ---------- */

@media (max-aspect-ratio: 21/20) {
  .intro {
    align-items: flex-end;
    padding-bottom: clamp(24px, 6vh, 56px);
  }

  .intro__copy {
    width: 100%;
  }

  .intro__title {
    margin: 10px 0 14px;
  }

  .hint {
    margin-top: 18px;
  }

  .hint i {
    height: 30px;
  }

  .top__link {
    display: none;
  }

  .rail {
    right: 2px;
  }
}

/* ---------- Телефон вертикально ---------- */
/* На вертикальном экране сцена стоит не во весь экран, а в арочном окне на бумаге, и в нём идут вертикальные
   рендеры: они помещаются почти целиком. Подпись комнаты под окном, на бумаге, и картинку не закрывает.
   Порог тот же, что в app.js. Размеры окна считает app.js и кладёт в --win-w и --win-h целыми числами,
   чтобы холст лёг точка в точку; значения ниже работают до его запуска. Всё привязано к верху экрана
   и к его высоте при видимой адресной строке, поэтому при прокрутке ничего не прыгает. */

@media (max-aspect-ratio: 5/6) {
  :root {
    --bar: 52px;
    --copy: 208px;   /* 12 зазор + до 184 подпись + 12 поле снизу */
    --win-w: min(calc(100vw - 32px), 560px);
    --win-h: max(260px, min(calc(var(--svh) - var(--bar) - var(--copy)), calc(var(--win-w) * 1.25)));
    --win-x: calc((100vw - var(--win-w)) / 2);
    --arc: min(calc(var(--win-w) / 2), calc(var(--win-h) * 0.4));
    --win-r: calc(var(--win-w) / 2) calc(var(--win-w) / 2) 3px 3px / var(--arc) var(--arc) 3px 3px;
    --below: calc(var(--bar) + var(--win-h) + 12px);
  }

  :root.is-short {
    --copy: 168px;
  }

  #gl,
  .frame {
    inset: auto;
    left: var(--win-x);
    top: var(--bar);
    width: var(--win-w);
    height: var(--win-h);
    border-radius: var(--win-r);
  }

  .frame {
    display: block;
    position: fixed;
    z-index: 3;   /* над сценой и зерном */
    pointer-events: none;
    box-shadow: inset 0 0 0 1px var(--line), 0 34px 60px -44px rgba(53, 51, 47, 0.55);
    transition: background-color 0.9s var(--ease);
  }

  /* последняя арка выходит на бумагу: окно становится светлой нишей для финала */
  .is-out .frame {
    background-color: var(--paper);
  }

  .scrim {
    display: none;
  }

  /* бумаге вокруг окна зерно нужно всегда, а окно лежит выше него */
  .is-inside .grain {
    opacity: 0.5;
  }

  #gl {
    z-index: 3;
  }

  .top {
    height: var(--bar);
    padding-inline: var(--win-x);
  }

  .is-inside .top {
    color: var(--ink);
    text-shadow: none;
  }

  .is-inside .top__logo img {
    filter: none;
  }

  .top__logo img {
    width: 124px;
  }

  .top__link {
    display: inline-flex;
  }

  .intro {
    inset: var(--below) var(--win-x) auto;
    align-items: flex-start;
    padding: 0;
  }

  .intro .eyebrow {
    font-size: 10px;
    letter-spacing: 0.16em;
    white-space: nowrap;
  }

  .intro__title {
    margin: 4px 0 8px;
    font-size: clamp(26px, 7.4vw, 34px);
  }

  .is-short .intro__title {
    margin: 2px 0 4px;
  }

  .intro__title .script {
    font-size: clamp(40px, 11.5vw, 52px);
  }

  .intro .lead {
    font-size: 14px;
    line-height: 1.5;
  }

  .hint {
    margin-top: 8px;
  }

  .hint i {
    height: 16px;
  }

  .is-short .hint {
    display: none;
  }

  .hud {
    color: var(--ink);
  }

  .cap {
    left: var(--win-x);
    right: var(--win-x);
    top: var(--below);
    bottom: auto;
  }

  .cap__idx {
    font-size: 14px;
    line-height: 32px;
    color: var(--rose);
  }

  .cap__idx span {
    font-size: 20px;
  }

  .cap__title,
  .cap--long .cap__title {
    margin-top: 0;
    font-size: clamp(32px, 10vw, 44px);
    text-shadow: none;
  }

  .cap--long .cap__title {
    font-size: clamp(26px, 7.8vw, 34px);
  }

  .cap__room {
    margin: -0.3em 0 0 0.1em;
    font-size: clamp(32px, 9.4vw, 42px);
    color: var(--rose);
    text-shadow: none;
  }

  .cap__lead {
    margin-top: 2px;
    min-height: 42px;
    font-size: 14px;
    line-height: 1.5;
  }

  .is-short .cap__lead {
    display: none;
  }

  .cap__foot {
    justify-content: space-between;
    margin-top: 10px;
  }

  /* область нажатия ссылки 47 px, раскладка при этом не меняется */
  .cap__foot .link-arrow {
    margin-block: -12px;
    padding-block: 12px 17px;
    background-position: 0 calc(100% - 12px);
  }

  .swatches i {
    box-shadow: 0 0 0 2px var(--cream), inset 0 0 0 1px rgba(53, 51, 47, 0.1);
  }

  /* точки комнат стоят в первой строке подписи справа, на бумаге */
  .rail {
    left: auto;
    right: calc(var(--win-x) - 12px);
    top: var(--below);
    display: flex;
    gap: 0;
    transform: none;
  }

  .rail button {
    width: 30px;
    height: 32px;
  }

  .rail button::before {
    background: var(--ink);
    opacity: 0.3;
  }

  .rail button.is-on::before {
    background: var(--rose);
    opacity: 1;
  }

  /* финал: заголовок в нише окна, текст и кнопки на месте подписи */
  .outro {
    display: block;
    padding: 0;
  }

  .outro > * {
    position: absolute;
    left: var(--win-x);
    right: var(--win-x);
    margin: 0;
  }

  .outro .script,
  .outro__title {
    left: calc(var(--win-x) + 20px);
    right: calc(var(--win-x) + 20px);
  }

  .outro .script {
    top: calc(var(--bar) + var(--win-h) * 0.5 - 10px);
    font-size: clamp(38px, 11vw, 48px);
  }

  .outro__title {
    top: calc(var(--bar) + var(--win-h) * 0.5 + 40px);
    font-size: clamp(24px, 7.4vw, 30px);
  }

  .outro .lead {
    top: var(--below);
    margin: 0;
    max-width: none;
    font-size: 14px;
    line-height: 1.5;
  }

  .outro__actions {
    top: calc(var(--below) + 70px);
    margin: 0;
    gap: 10px 20px;
  }

  .outro .btn {
    height: 46px;
    padding: 0 24px;
  }
}

/* ---------- Телефон горизонтально ---------- */
/* Сцена во весь экран занимает высоту при спрятанной адресной строке, чтобы картинка не пересчитывалась,
   когда строка прячется и возвращается. */

@media (pointer: coarse) and (min-aspect-ratio: 5/6) {
  #gl,
  .scrim {
    inset: 0 auto auto 0;
    height: 100vh;
    height: 100lvh;
  }
}

/* низкий широкий экран: тексты титула и подписи ужимаются по высоте, чтобы не наезжать на шапку */
@media (max-height: 480px) and (min-aspect-ratio: 5/6) {
  .intro {
    align-items: flex-end;
    padding-bottom: 14px;
  }

  .intro__title {
    margin: 6px 0 10px;
    font-size: clamp(26px, 9vh, 40px);
  }

  .intro__title .script {
    font-size: clamp(38px, 13vh, 60px);
  }

  .intro .lead {
    font-size: 14px;
    line-height: 1.5;
  }

  .hint {
    margin-top: 10px;
  }

  .hint i {
    height: 18px;
  }

  .cap {
    bottom: 14px;
  }

  .cap__title {
    font-size: clamp(34px, 15vh, 136px);
  }

  .cap--long .cap__title {
    font-size: clamp(30px, 11vh, 100px);
  }

  .cap__room {
    font-size: clamp(30px, 10vh, 84px);
  }

  .cap__lead {
    margin-top: 4px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0ms !important;
  }
}
