/* Движение: переходы, появления, нажатие кнопок */

:root {
  --ease: cubic-bezier(.22, .8, .3, 1);
  --page-time: .55s;
}

/* Переход между сайтом и личным кабинетом */
@view-transition { navigation: auto; }

/* ---------- Смена страницы ---------- */
.top { view-transition-name: site-header; }
::view-transition { pointer-events: none; }
::view-transition-group(site-header) { z-index: 5; }
::view-transition-old(root) { animation: page-out var(--page-time) var(--ease) both; }
::view-transition-new(root) { animation: page-in var(--page-time) var(--ease) both; }
::view-transition-old(site-header),
::view-transition-new(site-header) { animation-duration: .4s; }

/* Изменение внутри страницы: только растворение, без сдвига */
html[data-motion="soft"]::view-transition-old(root) { animation: fade-out .36s ease both; }
html[data-motion="soft"]::view-transition-new(root) { animation: fade-in .36s ease both; }

/* Половина первого экрана превращается в обложку раздела */
::view-transition-group(stage) { overflow: hidden; animation-duration: .7s; animation-timing-function: var(--ease); }
::view-transition-old(stage),
::view-transition-new(stage) { height: 100%; object-fit: cover; animation-duration: .7s; }

/* Форма поиска лежит на обложке — и во время превращения остаётся поверх неё */
html[data-morph] .search-block { view-transition-name: stage-over; }
::view-transition-group(stage-over) { z-index: 2; }
::view-transition-new(stage-over) { animation: page-in .7s var(--ease) both; }

@keyframes page-out { to { opacity: 0; transform: translateY(-14px); } }
@keyframes page-in { from { opacity: 0; transform: translateY(22px); } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

/* ---------- Окна ---------- */
dialog[open] { animation: window-in .38s var(--ease) both; }
dialog[open]::backdrop { animation: fade-in .38s ease both; }
dialog[open].closing { animation: window-out .22s ease-in both; pointer-events: none; }
dialog[open].closing::backdrop { animation: fade-out .22s ease-in both; }
dialog > :not(.x) { animation: fade-in .35s ease both; }
@keyframes window-in { from { opacity: 0; transform: translateY(24px) scale(.95); } }
@keyframes window-out { to { opacity: 0; transform: translateY(16px) scale(.96); } }

/* ---------- Появления ---------- */
details.opening > :not(summary) { animation: rise .36s var(--ease) both; }
.gallery:not([hidden]) { animation: fade-in .45s ease both; }
.packet > * { animation: fade-in .4s ease both; }
.results > .filters,
.results > .empty { animation: rise .45s var(--ease) both; }
.ages > .field { animation: rise .3s var(--ease) both; }
.doors,
.editor { animation: rise .42s var(--ease) both; }

/* ---------- Кнопки ---------- */
button, a, summary, .pick label { -webkit-tap-highlight-color: transparent; }

.btn, .cabinet, .langs button, .top nav a, .tabs a, .kinds button, .chips a, .x, .wa, .cab-nav button, .pick label, .side-text i {
  transition: scale .22s var(--ease), translate .22s var(--ease), background-color .22s ease, color .22s ease, box-shadow .22s ease, border-color .22s ease;
}
/* Нулевая специфичность: не перебивает fixed у WhatsApp и absolute у крестика */
:where(.btn, .cabinet, .langs button, .top nav a, .tabs a, .kinds button, .chips a, .x, .wa, .cab-nav button, .pick label) { position: relative; }
summary, .service, .hotel h3 a { transition: color .22s ease, background-color .22s ease, box-shadow .22s ease; }
.card { transition: scale .22s var(--ease), box-shadow .3s ease; }

/* Мышь навели — кнопка вдавливается */
@media (hover: hover) and (pointer: fine) {
  .btn:not(:disabled):hover,
  .cabinet:hover, .langs button:hover, .kinds button:hover, .chips a:hover, .x:hover, .wa:hover, .pick label:hover,
  .side:hover .side-text i {
    scale: .94;
    translate: 0 2px;
    box-shadow: inset 0 3px 7px #0000003d;
  }

  /* Невидимое поле вокруг вдавленной кнопки: иначе на самом её краю она дрожит */
  .btn:not(:disabled):hover::before,
  .cabinet:hover::before, .langs button:hover::before, .kinds button:hover::before, .chips a:hover::before, .x:hover::before, .wa:hover::before, .pick label:hover::before {
    content: '';
    position: absolute;
    inset: -18% -6%;
  }

  /* В прокручиваемых меню вдавливаем слабее, чтобы не появлялась полоса прокрутки */
  .top nav a:hover, .tabs a:hover, .cab-nav button:hover {
    scale: .95;
    box-shadow: inset 0 3px 7px #00000033;
  }
  .top nav a:hover::before, .tabs a:hover::before, .cab-nav button:hover::before {
    content: '';
    position: absolute;
    inset: 0 -3%;
  }

  .x:hover { background: var(--paper); }
  summary:hover, .hotel h3 a:hover { color: var(--deep); }
  .service:hover { box-shadow: inset 0 2px 7px #073f4324; }
  .card:hover { box-shadow: 0 10px 26px #073f4340; }
}

/* Нажали — вдавливается сильнее. Работает и пальцем на телефоне */
.btn:not(:disabled):active,
.cabinet:active, .langs button:active, .kinds button:active, .chips a:active, .x:active, .wa:active, .pick label:active,
.top nav a:active, .tabs a:active, .cab-nav button:active,
.side:active .side-text i {
  scale: .88;
  translate: 0 3px;
  box-shadow: inset 0 4px 10px #00000059;
  transition-duration: .08s;
}
.card:active { scale: .97; transition-duration: .08s; }

/* ---------- В системе отключена анимация: оставляем только короткое растворение ---------- */
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*) { animation-duration: .01s !important; }
  ::view-transition-old(root) { animation: fade-out .2s both !important; }
  ::view-transition-new(root) { animation: fade-in .2s both !important; }
  dialog[open], details.opening > :not(summary), .results > *, .ages > .field, .doors, .editor { animation: fade-in .2s both !important; }
  dialog[open].closing { animation: fade-out .2s both !important; }
  .btn, .cabinet, .langs button, .top nav a, .tabs a, .kinds button, .chips a, .x, .wa, .cab-nav button, .pick label, .side-text i, .card { scale: none !important; translate: none !important; }
}
