/* ============================================================
   BLUE WATERS — страница «Апартаменты» и вьюер интерактивного тура.
   Подключается только на apartments.html поверх styles.css.
   Токены, типографика и кнопки — общие из styles.css.
   ============================================================ */

/* ============================================================
   Первый экран страницы
   ============================================================ */
.apt-hero {
  position: relative; isolation: isolate; overflow: hidden;
  background: var(--ink); color: #fff;
  padding-top: calc(var(--header-h) + clamp(3rem, 8vw, 6.5rem));
  padding-bottom: clamp(2.6rem, 6vw, 5rem);
}
.apt-hero__media { position: absolute; inset: 0; z-index: -1; }
.apt-hero__media img { width: 100%; height: 100%; object-fit: cover; object-position: center 42%; }
/* по горизонтали — чтобы читался светлый текст слева, по вертикали —
   чтобы низ ушёл в фон и стык со следующей секцией исчез */
.apt-hero__media::after {
  content: ""; position: absolute; inset: 0;
  background:
    linear-gradient(96deg, rgba(11,30,42,.88) 0%, rgba(11,30,42,.6) 42%, rgba(11,30,42,.12) 78%, rgba(11,30,42,.24) 100%),
    linear-gradient(180deg, rgba(11,30,42,.5) 0%, rgba(11,30,42,0) 30%, rgba(11,30,42,.3) 70%, rgba(11,30,42,.9) 100%);
}
.apt-hero .eyebrow { color: rgba(255,255,255,.82); }
.apt-hero__title {
  font-family: var(--font-b); font-weight: 200; color: #fff;
  font-size: clamp(2.4rem, 6.4vw, 5.8rem); line-height: .98; letter-spacing: -.01em;
}
.apt-hero__title .line { display: block; overflow: hidden; }
.apt-hero__title .line > span { display: block; }
.apt-hero__title em { font-style: normal; color: var(--gold); }
.apt-hero__lead {
  font-family: var(--font-b); font-weight: 300;
  font-size: clamp(.95rem, 1.2vw, 1.3rem); line-height: 1.7;
  color: rgba(255,255,255,.9); margin-top: clamp(1.2rem, 2.4vw, 2rem); max-width: 56ch;
}
/* ============================================================
   Превью тура — затемнение как на генплане
   ============================================================ */
.apt-tour { background: var(--ink); padding: 0; }
.tour-preview {
  position: relative; overflow: hidden;
  width: 100%; aspect-ratio: 16 / 9; min-height: 340px; max-height: 78vh;
  background: var(--ink-2);
  display: grid; place-items: center; text-align: center;
  isolation: isolate;
}
.tour-preview__img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  transform: scale(1.04); transition: transform 1.6s var(--ease);
}
.tour-preview:hover .tour-preview__img { transform: scale(1.08); }
/* тот же приём, что в .mp__veil: тёмная шапка сверху и глубокий низ,
   чтобы кнопка и подписи читались поверх светлого рендера */
.tour-preview__veil {
  position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(180deg, rgba(11,30,42,.52) 0%, rgba(11,30,42,.12) 26%, rgba(11,30,42,.3) 58%, rgba(11,30,42,.88) 100%),
    radial-gradient(78% 62% at 50% 46%, rgba(11,30,42,.06) 0%, rgba(11,30,42,.62) 100%);
}
.tour-preview__body {
  position: relative; z-index: 2; padding: clamp(1.6rem, 5vw, 3rem);
  display: grid; justify-items: center; gap: clamp(.9rem, 2vw, 1.5rem);
}
.tour-preview__badge {
  display: inline-flex; align-items: center; gap: .6rem;
  font-size: .68rem; letter-spacing: .22em; text-transform: uppercase;
  color: rgba(255,255,255,.9);
  border: 1px solid rgba(255,255,255,.3); border-radius: 100px;
  padding: .5em 1.2em; backdrop-filter: blur(6px);
}
.tour-preview__title {
  font-family: var(--font-d); font-weight: 400; color: #fff;
  font-size: clamp(1.9rem, 4.6vw, 3.6rem); line-height: 1.08; max-width: 18ch;
}
.tour-preview__note {
  color: rgba(233,241,245,.78); font-size: clamp(.85rem, 1.1vw, 1rem);
  max-width: 46ch; line-height: 1.7;
}
.tour-start {
  margin-top: .4rem; display: inline-flex; align-items: center; gap: .85rem;
  padding: 1.05em 2.1em; border-radius: 100px;
  background: var(--gold); color: var(--ink);
  font-size: clamp(.85rem, 1vw, .98rem); font-weight: 600;
  letter-spacing: .04em;
  box-shadow: 0 18px 40px -18px rgba(192,160,98,.9);
  transition: transform .4s var(--ease), box-shadow .4s var(--ease), background .3s var(--ease);
}
.tour-start svg { width: 18px; height: 18px; fill: currentColor; }
.tour-start:hover { transform: translateY(-2px); background: #d4b479; box-shadow: 0 24px 50px -20px rgba(192,160,98,1); }
.tour-start:active { transform: translateY(0); }
.tour-preview__corner {
  position: absolute; width: 34px; height: 34px; z-index: 2; pointer-events: none;
  border: 1px solid rgba(255,255,255,.4);
}
.tour-preview__corner--tl { top: 22px; left: 22px; border-right: 0; border-bottom: 0; }
.tour-preview__corner--tr { top: 22px; right: 22px; border-left: 0; border-bottom: 0; }
.tour-preview__corner--bl { bottom: 22px; left: 22px; border-right: 0; border-top: 0; }
.tour-preview__corner--br { bottom: 22px; right: 22px; border-left: 0; border-top: 0; }

/* ============================================================
   Список комнат под превью
   ============================================================ */
.apt-rooms { background: var(--paper); }
.apt-rooms__grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: clamp(.7rem, 1.4vw, 1.1rem);
}
.apt-room {
  position: relative; overflow: hidden; border-radius: 8px;
  border: 1px solid var(--line); background: var(--foam);
  text-align: left; width: 100%; padding: 0; display: block;
  transition: transform .45s var(--ease), box-shadow .45s var(--ease), border-color .45s var(--ease);
}
.apt-room:hover { transform: translateY(-4px); border-color: var(--mist); box-shadow: 0 26px 44px -32px rgba(11,30,42,.45); }
/* span внутри кнопки — по умолчанию строчный, а строчный бокс
   игнорирует aspect-ratio: без display:block карточка схлопывается */
.apt-room__media { display: block; position: relative; aspect-ratio: 3 / 2; overflow: hidden; background: var(--paper-2); }
.apt-room__media img { width: 100%; height: 100%; object-fit: cover; transition: transform .8s var(--ease); }
.apt-room:hover .apt-room__media img { transform: scale(1.05); }
.apt-room__media::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(11,30,42,0) 45%, rgba(11,30,42,.55) 100%);
}
.apt-room__zone {
  position: absolute; left: 12px; top: 12px; z-index: 2;
  font-size: .6rem; letter-spacing: .18em; text-transform: uppercase;
  color: #fff; background: rgba(11,30,42,.5); backdrop-filter: blur(4px);
  border-radius: 100px; padding: .45em 1em;
}
.apt-room__foot {
  display: flex; align-items: center; justify-content: space-between; gap: .8rem;
  padding: clamp(.9rem, 1.6vw, 1.2rem) clamp(1rem, 1.8vw, 1.4rem);
}
.apt-room__name { font-family: var(--font-d); font-size: 1.2rem; line-height: 1.2; color: var(--ink); }
.apt-room__go {
  flex: none; width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid var(--line); display: grid; place-content: center;
  color: var(--tide); transition: background .35s var(--ease), color .35s var(--ease), border-color .35s var(--ease);
}
.apt-room__go svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.apt-room:hover .apt-room__go { background: var(--tide); border-color: var(--tide); color: #fff; }
.apt-rooms__foot { margin-top: clamp(1.8rem, 3vw, 2.6rem); text-align: center; color: var(--text-mut); }

/* ============================================================
   Вьюер тура
   ============================================================ */
body.tour-open { overflow: hidden; }

.tourx {
  position: fixed; inset: 0; z-index: 1200;
  background: #060f16;
  opacity: 0; visibility: hidden;
  transition: opacity .38s var(--ease), visibility .38s;
  --chrome-top: clamp(56px, 8vh, 88px);
  --chrome-bottom: clamp(84px, 13vh, 116px);
}
.tourx[hidden] { display: none; }
.tourx.is-open { opacity: 1; visibility: visible; }
.tourx:focus { outline: none; }

.tourx__stage {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  padding: var(--chrome-top) clamp(10px, 2.4vw, 34px) var(--chrome-bottom);
}

/* кадр обхватывает картинку вплотную: слой точек лежит ровно на ней,
   поэтому проценты из tour.js всегда попадают в нужное место */
.tourx__frame {
  position: relative; max-width: 100%;
  line-height: 0; border-radius: 6px; overflow: hidden;
  box-shadow: 0 40px 90px -40px rgba(0,0,0,.9);
}
/* высоту ограничиваем от вьюпорта, а не в процентах: у обхватывающего
   кадр блока высота auto, а процентный max-height от auto-высоты
   браузер игнорирует — картинка вылезала за экран */
.tourx__img {
  display: block; width: auto; height: auto;
  max-width: 100%;
  max-height: calc(100vh - var(--chrome-top) - var(--chrome-bottom));
  object-fit: contain;
  -webkit-user-drag: none; user-select: none;
}
@supports (height: 100dvh) {
  .tourx__img { max-height: calc(100dvh - var(--chrome-top) - var(--chrome-bottom)); }
}
.tourx__img--ghost {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; opacity: 0; pointer-events: none;
  transition: opacity .55s var(--ease);
}
.tourx__img--ghost.is-on { opacity: 1; transition: none; }
.tourx__frame.is-in .tourx__img--ghost.is-on { opacity: 0; transition: opacity .55s var(--ease); }
/* «шаг в комнату»: новый кадр слегка наезжает */
.tourx__frame.is-in { animation: tourx-in .75s var(--ease-out) both; }
@keyframes tourx-in {
  from { transform: scale(1.045); }
  to   { transform: scale(1); }
}

.tourx__spots { position: absolute; inset: 0; z-index: 3; }

.tourx__loader {
  position: absolute; z-index: 4; width: 42px; height: 42px;
  opacity: 0; transition: opacity .25s var(--ease); pointer-events: none;
}
.tourx.is-loading .tourx__loader { opacity: 1; }
.tourx__loader span {
  display: block; width: 100%; height: 100%; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.18); border-top-color: var(--gold);
  animation: tourx-spin .8s linear infinite;
}
@keyframes tourx-spin { to { transform: rotate(360deg); } }

/* ---------- горячие точки ----------
   Точка — одна капсула «иконка + подпись», а не кружок с оторванной
   таблеткой рядом: на светлых рендерах кружок и подпись с зазором
   читались как две разные кнопки, а под наведением — как два белых
   пятна. Якорь капсулы — центр иконки (--anchor), а не её середина:
   иконка должна стоять ровно на двери, подпись уходит от неё вправо.
   --shift / --shift-y задаёт tour.js, когда капсула упирается в край
   кадра или наезжает на соседнюю. */
.tspot {
  --dot: clamp(30px, 2.4vw, 36px);
  --pad: 6px;
  --anchor: calc(-1 * (var(--pad) + var(--dot) / 2));
  position: absolute; left: var(--x); top: var(--y); z-index: 2;
  display: flex; align-items: center; gap: 10px;
  padding: var(--pad) calc(var(--pad) + 10px) var(--pad) var(--pad);
  border-radius: 999px; color: #fff;
  background: rgba(9,20,29,.62);
  border: 1px solid rgba(255,255,255,.32);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 14px 34px -14px rgba(0,0,0,.95), inset 0 1px 0 rgba(255,255,255,.14);
  touch-action: manipulation;
  transform: translate(calc(var(--anchor) + var(--shift, 0px)),
                       calc(-50% + var(--shift-y, 0px)))
             scale(var(--s, 1));
  transition: background .3s var(--ease), border-color .3s var(--ease),
              color .3s var(--ease), box-shadow .3s var(--ease),
              transform .35s var(--ease);
  animation: tspot-in .45s var(--ease-out) both;
  animation-delay: calc(var(--i) * 90ms + 260ms);
}
@keyframes tspot-in { from { opacity: 0; } to { opacity: 1; } }

/* пульс — отдельный слой поверх капсулы: её собственный transform занят
   позиционированием, анимировать его нельзя */
.tspot::after {
  content: ""; position: absolute; inset: -1px; border-radius: inherit;
  border: 1px solid rgba(255,255,255,.5); pointer-events: none;
  animation: tspot-ring 2.8s var(--ease-out) infinite;
}
@keyframes tspot-ring {
  0%   { transform: scale(1);    opacity: .75; }
  65%  { transform: scale(1.14); opacity: 0; }
  100% { transform: scale(1.14); opacity: 0; }
}

.tspot__dot {
  width: var(--dot); height: var(--dot); flex: none;
  border-radius: 50%; display: grid; place-content: center;
  background: rgba(255,255,255,.14);
  transition: background .3s var(--ease), color .3s var(--ease);
}
/* размер иконки — от размера кружка: проценты внутри grid-ячейки
   с авто-треком не разрешаются и схлопывают svg */
.tspot__dot svg {
  width: calc(var(--dot) * .46); height: calc(var(--dot) * .46);
  fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
/* подпись видна сразу — так понятно, куда ведёт точка, без наведения */
.tspot__label {
  font-size: clamp(.76rem, .95vw, .86rem); font-weight: 600; letter-spacing: .01em;
  white-space: nowrap;
}

/* hover — только для мыши: на тач-экране он «залипает» после нажатия,
   и капсула остаётся белой уже после перехода */
@media (hover: hover) and (pointer: fine) {
  .tspot:hover {
    --s: 1.04;
    background: #fff; border-color: #fff; color: var(--ink);
    box-shadow: 0 20px 44px -16px rgba(0,0,0,.8);
  }
  .tspot:hover .tspot__dot { background: rgba(11,30,42,.1); }
  .tspot--enter:hover { background: #d4b479; border-color: #fff; }
  .tspot--enter:hover .tspot__dot { background: rgba(11,30,42,.18); }
}
.tspot:active { --s: .97; }
.tspot:focus-visible { outline: 2px solid rgba(255,255,255,.85); outline-offset: 3px; }

/* ключевой переход и «назад» — своя окраска */
.tspot--enter {
  background: var(--gold); border-color: rgba(255,255,255,.7); color: var(--ink);
  box-shadow: 0 16px 38px -14px rgba(192,160,98,.9), inset 0 1px 0 rgba(255,255,255,.35);
}
.tspot--enter .tspot__dot { background: rgba(11,30,42,.16); }
.tspot--enter::after { border-color: rgba(255,255,255,.75); }

/* «назад» всегда стоит по центру внизу кадра — её ровняем по центру
   капсулы, иначе она выглядела бы сдвинутой вбок */
.tspot--back {
  --dot: clamp(24px, 2vw, 30px);
  --pad: 5px;
  --anchor: -50%;
  background: rgba(9,20,29,.52); border-color: rgba(255,255,255,.22);
  box-shadow: 0 12px 28px -14px rgba(0,0,0,.9);
}
.tspot--back .tspot__label { font-size: clamp(.72rem, .85vw, .8rem); font-weight: 500; opacity: .9; }
.tspot--back::after { animation: none; }

/* ---------- верхняя панель ---------- */
.tourx__top {
  position: absolute; top: 0; left: 0; right: 0; z-index: 5;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem;
  padding: clamp(14px, 2.2vw, 26px) clamp(14px, 2.6vw, 34px);
  background: linear-gradient(180deg, rgba(6,15,22,.86) 0%, rgba(6,15,22,0) 100%);
  pointer-events: none;
}
.tourx__top > * { pointer-events: auto; }
.tourx__crumb { color: #fff; min-width: 0; }
.tourx__zone {
  display: block; font-size: .64rem; letter-spacing: .24em; text-transform: uppercase;
  color: var(--gold);
}
.tourx__title {
  display: block; font-family: var(--font-d); font-weight: 400;
  font-size: clamp(1.25rem, 2.4vw, 2rem); line-height: 1.15; margin-top: .25rem;
}
.tourx__tools { display: flex; align-items: center; gap: .5rem; flex: none; }
.tourx__btn {
  display: inline-flex; align-items: center; gap: .5rem;
  height: 42px; padding: 0 1.05rem; border-radius: 100px;
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.18);
  color: #fff; font-size: .82rem; font-weight: 500;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: background .3s var(--ease), border-color .3s var(--ease), opacity .3s var(--ease);
}
.tourx__btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tourx__btn:hover { background: rgba(255,255,255,.22); border-color: rgba(255,255,255,.35); }
.tourx__btn:disabled { opacity: .35; pointer-events: none; }
.tourx__btn--icon { width: 42px; padding: 0; justify-content: center; }
.tourx__btn--close:hover { background: #fff; color: var(--ink); }

/* ---------- нижняя панель ---------- */
.tourx__bottom {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 5;
  padding: clamp(10px, 2vw, 18px) clamp(14px, 2.6vw, 34px) clamp(14px, 2.4vw, 26px);
  background: linear-gradient(0deg, rgba(6,15,22,.9) 0%, rgba(6,15,22,0) 100%);
  display: grid; gap: .7rem; justify-items: center;
}
.tourx__hint {
  font-size: .72rem; letter-spacing: .06em; color: rgba(233,241,245,.6);
  text-align: center;
}
.tourx__rooms {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: .5rem 1.1rem; max-width: 100%;
}
.tourx__group { display: inline-flex; align-items: center; gap: .4rem; flex-wrap: wrap; justify-content: center; }
.tourx__group-name {
  font-size: .6rem; letter-spacing: .2em; text-transform: uppercase;
  color: rgba(157,190,205,.7); margin-right: .2rem;
}
.tourx__room {
  padding: .5em 1em; border-radius: 100px;
  border: 1px solid rgba(255,255,255,.16); background: rgba(255,255,255,.06);
  color: rgba(255,255,255,.82); font-size: .76rem; white-space: nowrap;
  transition: background .3s var(--ease), color .3s var(--ease), border-color .3s var(--ease);
}
.tourx__room:hover { background: rgba(255,255,255,.18); color: #fff; }
.tourx__room.is-current { background: var(--gold); border-color: var(--gold); color: var(--ink); font-weight: 600; }

/* ---------- адаптив ---------- */
@media (max-width: 1100px) {
  .apt-rooms__grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  /* микроподписи на телефоне: 9.6px читаются плохо */
  .apt-room__zone { font-size: .66rem; letter-spacing: .12em; }
  .tour-preview__badge { font-size: .72rem; letter-spacing: .16em; }
  .apt-rooms__foot { font-size: .9rem; }
}
@media (max-width: 860px) {
  .tourx { --chrome-top: 74px; --chrome-bottom: 128px; }
  .tourx__btn span { display: none; }
  .tourx__btn { width: 40px; height: 40px; padding: 0; justify-content: center; }
  .tourx__hint { display: none; }
  .tourx__rooms { gap: .4rem .7rem; }
  .tourx__group-name { display: none; }

  /* на телефоне капсула крупнее относительно кадра: 44px под палец */
  .tspot { --dot: 32px; gap: 9px; }
  .tspot__label { font-size: .78rem; }
  .tspot--back { --dot: 26px; }
}
@media (max-width: 640px) {
  .apt-rooms__grid { grid-template-columns: 1fr; }
  .tour-preview { aspect-ratio: 4 / 5; max-height: 82vh; }
  .tour-preview__corner { width: 22px; height: 22px; }
  .tour-preview__corner--tl, .tour-preview__corner--tr { top: 14px; }
  .tour-preview__corner--bl, .tour-preview__corner--br { bottom: 14px; }
  .tour-preview__corner--tl, .tour-preview__corner--bl { left: 14px; }
  .tour-preview__corner--tr, .tour-preview__corner--br { right: 14px; }
  .tourx__rooms {
    flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; padding-bottom: 4px;
    scrollbar-width: none; -ms-overflow-style: none;
  }
  .tourx__rooms::-webkit-scrollbar { display: none; }
  .tourx__group { flex-wrap: nowrap; }
  .tspot { --dot: 30px; --pad: 5px; gap: 8px; }
  .tspot__label { font-size: .74rem; }
  .tspot--back { --dot: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  .tourx__frame.is-in { animation: none; }
  .tspot { animation: none; transition: none; }
  .tspot::after { animation: none; }
  .tour-preview__img, .tour-preview:hover .tour-preview__img { transform: none; transition: none; }
}
