/* Wellness Studio — улучшенные анимации, микровзаимодействия и исправления сцен (19.11.2026). */

/* 1. Исправление верхнего зазора фонового фото в #workouts и на мобильных сценах */
.scene--workouts .scene-photo img {
  transform-origin: 73% 50%;
}

/* 2. Сброс задержки появления после первого каскада и защита выносных элементов кириллицы (д, р, у, й, ё) в h2.split */
.js-intro [data-stagger].is-stagger-done > * {
  transition-delay: 0ms !important;
}

h2.split .w {
  padding-top: .08em;
  margin-top: -.08em;
  padding-bottom: .22em;
  margin-bottom: -.22em;
}

@media (prefers-reduced-motion: no-preference) {
  h2.split .w > span {
    transition: transform .72s var(--spring);
    transition-delay: calc(var(--wi, 0) * 42ms + 40ms);
  }
}

/* 3. Раскрывающиеся блоки в #health и #nutrition — единый редакторский стиль с круглой кнопкой «+» */
#health .limits-search summary,
#health .health-extras summary,
#nutrition .calc__method summary {
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px 10px 0;
  border-radius: 12px;
  user-select: none;
  -webkit-user-select: none;
  transition: color .2s ease, opacity .2s ease;
}

#health .limits-search summary::-webkit-details-marker,
#health .health-extras summary::-webkit-details-marker,
#nutrition .calc__method summary::-webkit-details-marker {
  display: none;
}

.summary-icon {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(244, 240, 229, .3);
  background: rgba(255, 252, 245, .06);
  color: #f4f0e5;
  font-size: 1.08rem;
  font-weight: 400;
  line-height: 1;
  transition: transform .28s var(--spring), background-color .22s ease, border-color .22s ease, color .22s ease;
}

#health details > summary:hover .summary-icon,
#nutrition .calc__method > summary:hover .summary-icon {
  background: rgba(255, 252, 245, .15);
  border-color: rgba(244, 240, 229, .55);
}

#health details[open]:not(.is-closing) > summary .summary-icon,
#nutrition .calc__method[open]:not(.is-closing) > summary .summary-icon {
  transform: rotate(45deg);
  background: #e2c29f;
  border-color: #e2c29f;
  color: #261d15;
}

#avatar .avatar-feature.is-closing summary span {
  transform: rotate(0deg);
}

/* 4. Раздел #health: цветовые индикаторы примеров, динамическое свечение вердикта и плашка классов движений */
#health #limitChips button {
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.chip-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(244, 240, 229, .45);
  transition: transform .26s var(--spring), box-shadow .24s ease, background-color .24s ease;
}

#health #limitChips button[data-tier="shape"] .chip-dot { background: #9fd4ae; }
#health #limitChips button[data-tier="specialist"] .chip-dot { background: #ecc082; }
#health #limitChips button[data-tier="noGym"] .chip-dot { background: #ee9e90; }

#health #limitChips button[aria-pressed="true"] .chip-dot {
  transform: scale(1.22);
  box-shadow: 0 0 0 2.5px rgba(38, 29, 21, .28);
}

#health #limitChips button[data-tier="shape"][aria-pressed="true"] .chip-dot { background: #2f6b47; }
#health #limitChips button[data-tier="specialist"][aria-pressed="true"] .chip-dot { background: #8f5719; }
#health #limitChips button[data-tier="noGym"][aria-pressed="true"] .chip-dot { background: #8e3224; }

#health #comboVerdict,
#health #limitVerdict {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  transition: border-color .42s ease, box-shadow .42s ease, background-color .42s ease;
}

#health #comboVerdict::before,
#health #limitVerdict::before {
  content: "";
  position: absolute;
  inset: -25% -15% auto auto;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  z-index: -1;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(closest-side, var(--verdict-aura, rgba(203, 217, 164, .22)), transparent 74%);
  transition: opacity .45s ease, transform .55s var(--spring);
  transform: scale(.82);
}

#health #comboVerdict[data-verdict-tier]::before,
#health #limitVerdict[data-verdict-tier]::before {
  opacity: 1;
  transform: scale(1);
}

#health #comboVerdict[data-verdict-tier="shape"],
#health #limitVerdict[data-verdict-tier="shape"] {
  --verdict-aura: rgba(159, 212, 174, .26);
  border-color: rgba(179, 209, 188, .54);
  box-shadow: 0 18px 44px rgba(10, 18, 12, .28), inset 0 1px 0 rgba(196, 232, 206, .18);
}

#health #comboVerdict[data-verdict-tier="specialist"],
#health #limitVerdict[data-verdict-tier="specialist"] {
  --verdict-aura: rgba(236, 192, 130, .28);
  border-color: rgba(224, 180, 122, .58);
  box-shadow: 0 18px 44px rgba(20, 15, 8, .28), inset 0 1px 0 rgba(242, 210, 162, .18);
}

#health #comboVerdict[data-verdict-tier="noGym"],
#health #limitVerdict[data-verdict-tier="noGym"] {
  --verdict-aura: rgba(238, 158, 144, .28);
  border-color: rgba(229, 154, 140, .6);
  box-shadow: 0 18px 44px rgba(22, 11, 10, .3), inset 0 1px 0 rgba(244, 184, 173, .18);
}

#health #comboClasses:not([hidden]) {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
  padding: 7px 13px;
  border: 1px solid rgba(179, 209, 188, .34);
  border-radius: 999px;
  background: rgba(159, 212, 174, .12);
  color: #dcecdf;
  font-weight: 500;
}

/* Плавающий переключатель дней Пн / Ср / Сб в Apple Health */
#daySeg {
  position: relative;
  isolation: isolate;
}

.seg-pill {
  position: absolute;
  top: 0;
  left: 0;
  z-index: -1;
  pointer-events: none;
  border-radius: 13px;
  background: #e2c29f;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .2);
  width: var(--seg-w, 0px);
  height: var(--seg-h, 44px);
  opacity: var(--seg-o, 0);
  transform: translate3d(var(--seg-x, 0px), var(--seg-y, 0px), 0);
  transition: transform .34s var(--spring), width .28s var(--spring), opacity .2s ease;
}

#daySeg.has-seg-pill button[aria-pressed="true"],
#daySeg.has-seg-pill button.is-active {
  background: transparent;
  box-shadow: none;
}

/* 5. Шапка: плавающая капсула текущего раздела на широких экранах */
@media (min-width: 1200px) {
  #siteNav {
    position: relative;
    isolation: isolate;
  }

  .nav__pill {
    position: absolute;
    top: 0;
    left: 0;
    z-index: -1;
    pointer-events: none;
    border-radius: 999px;
    background: var(--accent-soft);
    width: var(--pill-w, 0px);
    height: var(--pill-h, 36px);
    opacity: var(--pill-o, 0);
    transform: translate3d(var(--pill-x, 0px), var(--pill-y, 0px), 0);
    transition: transform .38s var(--spring), width .32s var(--spring), height .24s ease, opacity .22s ease, background-color .25s ease;
  }

  .nav:not(.is-solid) .nav__pill {
    background: rgba(255, 250, 242, .16);
    box-shadow: inset 0 0 0 1px rgba(255, 250, 242, .16);
  }

  #siteNav.has-nav-pill a.is-current:not(:hover) {
    background: transparent;
  }
}

@media (max-width: 1199px) {
  .nav__pill {
    display: none;
  }
}

/* 6. Личный план (#return-plan): мягкое свечение под iPhone и живой отклик строк */
.personal-plan__device {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.personal-plan__device::before {
  content: "";
  position: absolute;
  inset: -18% -12% auto;
  aspect-ratio: 1;
  border-radius: 50%;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 22%, transparent), transparent 72%);
  opacity: .85;
}

.personal-plan__feature {
  border-radius: 14px;
  padding-inline: 10px;
  margin-inline: -10px;
  transition: background-color .22s ease, transform .24s var(--spring);
}

.personal-plan__feature:is(:hover, :focus-visible) {
  background: color-mix(in srgb, var(--accent-soft) 58%, transparent);
}

.personal-plan__arrow {
  transition: background-color .22s ease, border-color .22s ease, color .22s ease, transform .28s var(--spring);
}

.personal-plan__feature:is(:hover, :focus-visible) .personal-plan__arrow {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  transform: translate(3px, -3px) scale(1.05);
}

/* 7. Бегущая строка возможностей (.ticker) */
.ticker__group {
  display: flex;
  align-items: center;
  gap: 24px;
  flex: none;
}

/* 8. Помощник (#assistant) и Врачи (#clinic) */
.assistant-demo__question {
  transform-origin: 100% 100%;
}

.assistant-demo__answer {
  transform-origin: 0% 100%;
}

.assistant-demo__header .monogram {
  transition: transform .32s var(--spring), box-shadow .32s ease;
}

.assistant-demo.is-responding .assistant-demo__header .monogram {
  transform: scale(1.08);
  box-shadow: 0 0 0 5px rgba(119, 86, 62, .16);
}

#clinic .clinic-preview label span {
  transition: transform .22s var(--spring), background-color .18s ease, color .18s ease, border-color .18s ease, box-shadow .22s ease;
}

#clinic .clinic-preview label:active span {
  transform: scale(.96);
}

#clinic .clinic-preview input:checked + span {
  box-shadow: 0 6px 16px rgba(115, 81, 58, .24);
}

#clinic .clinic-preview__mark {
  transition: transform .36s var(--spring), box-shadow .36s ease, background-color .25s ease;
}

#clinic .clinic-preview__mark.is-pulsing {
  transform: scale(1.08) rotate(90deg);
  box-shadow: 0 0 0 6px rgba(82, 99, 74, .16);
}

/* 9. Скролл-история (#story): вертикальный акцент активного экрана на широком окне */
@media (min-width: 760px) {
  #story:not(.is-compact) .story__step {
    position: relative;
    padding-left: 22px;
    transition: translate .42s var(--spring), opacity .35s ease;
  }

  #story:not(.is-compact) .story__step h2 {
    transition: color .32s ease;
  }

  #story:not(.is-compact) .story__step::before {
    content: "";
    position: absolute;
    left: 0;
    top: 26px;
    bottom: 26px;
    width: 3px;
    border-radius: 3px;
    background: var(--accent);
    opacity: .2;
    transform: scaleY(.28);
    transform-origin: 50% 50%;
    transition: transform .48s var(--spring), opacity .35s ease, background-color .35s ease;
  }

  #story:not(.is-compact) .story__step.is-active {
    translate: 4px 0;
  }

  #story:not(.is-compact) .story__step.is-active::before {
    opacity: 1;
    transform: scaleY(1);
  }
}

/* 10. Улучшенная композиция кнопок, колец и модальных окон при разрешённом движении */
@media (prefers-reduced-motion: no-preference) {
  .btn {
    transition: transform .28s var(--spring), translate .22s var(--spring), scale .18s var(--spring), box-shadow .24s ease, background .2s ease, border-color .2s ease;
  }

  .btn:hover {
    translate: 0 -2px;
  }

  .btn:active {
    scale: .97;
  }

  /* Исправление краёв фоновых фото при параллаксе на десктопе и мобильных */
  .scenes-motion .scene-photo img {
    transform: translate3d(0, var(--scene-drift, 0px), 0) scale(calc(1.18 - .07 * var(--scene-progress, 0)));
  }

  @media (max-width: 759px) {
    .scenes-motion .scene-photo img {
      transform: translate3d(0, calc(var(--scene-drift, 0px) * .42), 0) scale(calc(1.18 - .06 * var(--scene-progress, 0)));
    }
  }

  /* Входная хореография первого экрана (Hero) */
  .has-hero-entrance .hero__content > * {
    animation: heroItemIn .82s var(--spring) backwards;
  }
  .has-hero-entrance .hero__content > :nth-child(1) { animation-delay: 20ms; }
  .has-hero-entrance .hero__content > :nth-child(2) { animation-delay: 85ms; }
  .has-hero-entrance .hero__content > :nth-child(3) { animation-delay: 155ms; }
  .has-hero-entrance .hero__content > :nth-child(4) { animation-delay: 225ms; }
  .has-hero-entrance .hero__content > :nth-child(5) { animation-delay: 290ms; }

  @keyframes heroItemIn {
    from {
      opacity: 0;
      translate: 0 22px;
    }
    to {
      opacity: 1;
      translate: 0 0;
    }
  }

  .scene-scroll {
    transition: background-color .22s ease, border-color .22s ease, transform .28s var(--spring), box-shadow .28s ease;
  }

  .scene-scroll:hover {
    transform: translateY(-2px) scale(1.06);
    border-color: #fffaf2;
    box-shadow: 0 8px 22px rgba(0, 0, 0, .28);
  }

  .hero:not(.is-offscreen) .scene-scroll span {
    display: inline-block;
    animation: scrollCueBob 2.2s ease-in-out infinite;
  }

  @keyframes scrollCueBob {
    0%, 100% { transform: translateY(-2px); }
    50% { transform: translateY(3px); }
  }

  /* 3D-парение макета iPhone в #return-plan */
  .personal-plan .phone--personal {
    transform: perspective(1200px) translate3d(0, var(--plan-y, 0px), 0) rotateX(var(--plan-rx, 0deg)) rotateY(var(--plan-ry, 0deg));
    transition: transform .36s cubic-bezier(.16, 1, .3, 1);
    will-change: transform;
  }

  .personal-plan__device::before {
    animation: planAuraFloat 9s ease-in-out infinite alternate;
  }

  @keyframes planAuraFloat {
    to { transform: translate(6%, 8%) scale(1.08); }
  }

  /* Плавная бегущая строка возможностей */
  .ticker.is-marquee {
    overflow: hidden;
    mask-image: linear-gradient(90deg, transparent, #000 5%, #000 95%, transparent);
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 5%, #000 95%, transparent);
  }

  .ticker.is-marquee .ticker__track {
    overflow: visible;
    width: max-content;
    padding-inline: 0;
    gap: 24px;
    animation: tickerSlide 44s linear infinite;
    will-change: transform;
  }

  .ticker.is-marquee:is(:hover, :focus-within) .ticker__track {
    animation-play-state: paused;
  }

  @keyframes tickerSlide {
    to { transform: translate3d(calc(-50% - 12px), 0, 0); }
  }

  /* Каскад преимуществ клиники */
  .scenes-motion #clinic .clinic-benefits > :nth-child(2) { transition-delay: 120ms; }
  .scenes-motion #clinic .clinic-benefits > :nth-child(3) { transition-delay: 220ms; }

  /* Кольца Apple Health: каскад при первом открытии и мягкий отклик при наведении */
  #rings .ring {
    transition: transform .28s var(--spring);
  }

  #rings .ring:hover {
    transform: translateY(-3px) scale(1.025);
  }

  #rings.is-revealing .ring:nth-child(2) .ring__bar { transition-delay: 95ms; }
  #rings.is-revealing .ring:nth-child(3) .ring__bar { transition-delay: 190ms; }

  /* Каскад строк поиска в #health и #nutrition */
  #limitResults li,
  #foodResults li {
    animation: searchRowIn .28s var(--spring) backwards;
    animation-delay: calc(var(--row-i, 0) * 38ms);
  }

  @keyframes searchRowIn {
    from {
      opacity: 0;
      translate: 0 8px;
    }
    to {
      opacity: 1;
      translate: 0 0;
    }
  }

  /* Каскад шагов в разделе #together */
  #communitySteps li {
    animation: communityStepIn .34s var(--spring) backwards;
    animation-delay: calc(var(--step-i, 0) * 65ms);
  }

  @keyframes communityStepIn {
    from {
      opacity: 0;
      translate: -10px 0;
    }
    to {
      opacity: 1;
      translate: 0 0;
    }
  }

  /* Выпадающее меню на мобильных экранах */
  @media (max-width: 1199px) {
    .nav.is-menu-open .nav__links {
      animation: navSheetIn .24s var(--spring) both;
      transform-origin: 50% 0%;
    }

    .nav.is-menu-open .nav__links a {
      animation: navLinkIn .28s var(--spring) backwards;
      animation-delay: calc(var(--nav-i, 0) * 18ms);
    }
  }

  @keyframes navSheetIn {
    from {
      opacity: 0;
      transform: translateY(-8px);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }

  @keyframes navLinkIn {
    from {
      opacity: 0;
      translate: 0 -6px;
    }
    to {
      opacity: 1;
      translate: 0 0;
    }
  }

  /* Сканер питания: световой отклик при успешном считывании штрихкода */
  .scanner__window {
    transition: box-shadow .35s ease, border-color .35s ease;
    border: 1px solid rgba(255, 250, 242, .08);
  }

  .scanner.is-found .scanner__window {
    border-color: color-mix(in srgb, var(--ok) 65%, transparent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent), inset 0 0 24px color-mix(in srgb, var(--ok) 18%, transparent);
  }

  /* Чекбокс упражнения и кольцо прогресса в окне тренировки (#planDialog) */
  .ex.is-done .ex__check {
    animation: checkPop .34s var(--spring);
  }

  @keyframes checkPop {
    0% { transform: scale(.82); }
    55% { transform: scale(1.16); }
    100% { transform: scale(1); }
  }

  #planProgress.is-complete {
    animation: ringCelebrate .55s var(--spring);
  }

  @keyframes ringCelebrate {
    0% { transform: scale(1); }
    45% { transform: scale(1.09); }
    100% { transform: scale(1); }
  }

  /* Плавное открытие и закрытие <dialog.modal> без задержки снятия [open] */
  @supports (transition-behavior: allow-discrete) {
    dialog.modal {
      opacity: 0;
      transition: opacity .22s ease, overlay .22s allow-discrete, display .22s allow-discrete;
    }

    dialog.modal[open] {
      opacity: 1;
    }

    @starting-style {
      dialog.modal[open] {
        opacity: 0;
      }
    }

    dialog.modal .modal__box {
      animation: none;
      transform: translateY(14px) scale(.975);
      transition: transform .28s var(--spring), opacity .22s ease;
    }

    dialog.modal[open] .modal__box {
      transform: none;
    }

    @starting-style {
      dialog.modal[open] .modal__box {
        transform: translateY(18px) scale(.97);
      }
    }

    dialog.modal::backdrop {
      opacity: 0;
      transition: opacity .24s ease, overlay .24s allow-discrete, display .24s allow-discrete;
    }

    dialog.modal[open]::backdrop {
      opacity: 1;
    }

    @starting-style {
      dialog.modal[open]::backdrop {
        opacity: 0;
      }
    }
  }
}

/* 11. Полное соблюдение prefers-reduced-motion и режима высокой контрастности */
@media (prefers-reduced-motion: reduce) {
  .summary-icon,
  .chip-dot,
  .seg-pill,
  .nav__pill,
  .personal-plan .phone--personal,
  .personal-plan__feature,
  .personal-plan__arrow,
  #health #comboVerdict,
  #health #limitVerdict,
  #health #comboVerdict::before,
  #health #limitVerdict::before {
    transition: none !important;
    animation: none !important;
  }

  .personal-plan .phone--personal {
    transform: none !important;
  }
}

@media (forced-colors: active) {
  .nav__pill,
  .seg-pill,
  #health #comboVerdict::before,
  #health #limitVerdict::before,
  .personal-plan__device::before {
    display: none;
  }
}
