/* =========================================================
   CARTA TILA — Body Map prototype
   Mobile-first. Target: 375px–430px viewport.
   ========================================================= */

:root {
  --bg-hero: #F2EDE6;
  --bg-dark: #1A1612;
  --ink: #3A2F26;
  --ink-soft: rgba(58, 47, 38, 0.6);
  --accent-pulse: #C77B4A;
  --accent-marked: #A89060;
  --text-on-dark: #F2EDE6;

  --font-serif: 'Cormorant Garamond', Georgia, serif;
  --font-sans: 'Manrope', system-ui, -apple-system, sans-serif;

  /* viewport-safe paddings (iOS notch) */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  /* shared 6s breath cycle — drives dots pulse + photo breathing */
  --breath-cycle: 6s;
}

/* ---------- Reset ---------- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  overflow-x: hidden;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-hero);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

button {
  background: none;
  border: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

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

img {
  display: block;
  max-width: 100%;
}

/* ---------- HERO ---------- */
.hero {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: calc(24px + var(--safe-top)) 20px calc(24px + var(--safe-bottom));
  position: relative;
}

.hero__head {
  text-align: center;
  max-width: 320px;
  margin-bottom: 8px;
  padding-top: 8px; /* clearance под sound toggle */
}

.hero__title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(26px, 7.5vw, 34px);
  line-height: 1.12;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.hero__sub {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(15px, 4.2vw, 18px);
  line-height: 1.4;
  color: var(--ink-soft);
  margin-top: 10px;
}

/* ---------- Силуэт (fineline, Gemini 3 Pro) ---------- */
/*
   silhouette-wrap соответствует аспекту PNG-силуэта (301x1000 = 0.301).
   .dots-layer использует % от wrap → координаты привязаны к анатомии.
*/
.silhouette-wrap {
  position: relative;
  width: 100%;
  max-width: 160px;
  aspect-ratio: 301 / 1000;
  margin: 16px auto 8px;
}

.silhouette__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

/* ---------- Dots layer (HTML overlay) ---------- */
.dots-layer {
  position: absolute;
  inset: 0;
  pointer-events: none; /* пропускаем клики мимо точек */
}

.dots-layer .dot {
  pointer-events: auto; /* но сами точки кликаются */
}

/* ---------- Точки ---------- */
.dot {
  position: absolute;
  width: 36px;
  height: 36px;
  margin: -18px 0 0 -18px; /* центрирование по top/left */
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  z-index: 2;
  background: transparent;
}

.dot__inner {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 50%;
  background: var(--accent-pulse);
  opacity: 0.92;
  box-shadow: 0 0 0 2px rgba(242, 237, 230, 0.4);
  transition: background 0.3s ease;
  z-index: 2;
}

.dot__halo {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 50%;
  background: var(--accent-pulse);
  opacity: 0;
  transform: scale(1);
  transform-origin: center;
  pointer-events: none;
  z-index: 1;
}

/* Pulse-анимация (только не-marked) — 6s breath cycle */
.dot--pulse .dot__halo {
  animation: dotPulse var(--breath-cycle) ease-in-out infinite;
}

/* Внутренняя точка тоже мягко "дышит" в той же фазе */
.dot--pulse .dot__inner {
  animation: dotBreath var(--breath-cycle) ease-in-out infinite;
}

@keyframes dotPulse {
  0%   { opacity: 0.55; transform: scale(0.8); }
  40%  { opacity: 0;    transform: scale(3.2); }
  100% { opacity: 0;    transform: scale(3.2); }
}

@keyframes dotBreath {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50%      { transform: translate(-50%, -50%) scale(1.15); }
}

/* Перебиваем фиксированное позиционирование .dot__inner — добавляем transform-origin */
.dot--pulse .dot__inner {
  top: 50%;
  left: 50%;
  margin: 0;
  transform: translate(-50%, -50%);
  transform-origin: center;
}

/* Отмеченная точка — статичная золотая */
.dot--marked .dot__halo {
  animation: none;
  opacity: 0;
}

.dot--marked .dot__inner {
  background: var(--accent-marked);
  opacity: 1;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  box-shadow: 0 0 0 2px rgba(242, 237, 230, 0.6), 0 0 12px rgba(168, 144, 96, 0.35);
}

.dot--marked {
  pointer-events: none; /* нельзя кликнуть повторно */
}

/* Координаты точек на fineline-силуэте (301x1000) */
/* Калибровано визуально: голова 4-14%, шея 18%, лопатки 26%, грудь 34%,
   поясница 44% (выше изгиба талии), сакрум 52%, бёдра 60% (тазобедренный сустав) */
[data-point="temples"]         { top: 7%;  left: 50%; }
[data-point="neck"]            { top: 18%; left: 50%; }
[data-point="shoulder-blades"] { top: 26%; left: 50%; }
[data-point="chest"]           { top: 34%; left: 50%; }
[data-point="lower-back"]      { top: 44%; left: 50%; }
[data-point="lower-belly"]     { top: 52%; left: 50%; }
[data-point="hips"]            { top: 60%; left: 50%; }

/* Focus state */
.dot:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 4px;
}

/* Подсказка для первой точки (показывается через 2 сек) */
.hint {
  position: absolute;
  top: 8%;
  left: 50%;
  transform: translate(28px, -50%);
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--ink-soft);
  opacity: 0;
  transition: opacity 0.6s ease;
  pointer-events: none;
  white-space: nowrap;
}

.hint__arrow {
  font-size: 14px;
  line-height: 1;
}

.hint.is-visible {
  opacity: 1;
}

/* ---------- Инструкция ---------- */
.hero__instruction {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.4;
  color: var(--ink);
  margin: 14px 0 0;
  text-align: center;
  letter-spacing: 0.01em;
}

.hero__instruction strong {
  font-weight: 600;
  color: #C77B4A;
  border-bottom: 1.5px dotted #C77B4A;
  padding-bottom: 1px;
}

/* ---------- Прогресс ---------- */
.hero__progress {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.progress__pips {
  display: flex;
  gap: 10px;
}

.pip {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid #C77B4A;
  background: transparent;
  transition: background 0.4s ease, transform 0.3s ease, border-color 0.3s ease;
}

.hero__progress[data-progress="1"] .pip:nth-child(-n+1),
.hero__progress[data-progress="2"] .pip:nth-child(-n+2),
.hero__progress[data-progress="3"] .pip:nth-child(-n+3) {
  background: #A89060;
  border-color: #A89060;
  transform: scale(1.1);
}

.progress__text {
  font-variant-numeric: tabular-nums;
}

.hero__progress[data-progress="3"] .progress__text {
  color: #A89060;
  font-weight: 700;
}

/* Fallback CTA (показан если JS отвалился) */
.fallback-cta {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 13px;
  color: var(--ink-soft);
  text-decoration: underline;
  display: none;
  z-index: 1;
}

/* Если JS не загрузился — body не имеет класса .js-ready, показываем fallback */
body:not(.js-ready) .fallback-cta {
  display: block;
}

/* ---------- ZONE MODAL ---------- */
.zone-modal {
  position: fixed;
  inset: 0;
  background: var(--bg-dark);
  color: var(--text-on-dark);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(60px + var(--safe-top)) 24px calc(32px + var(--safe-bottom));
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transform: scale(1.05);
  transition:
    opacity 0.4s ease,
    transform 0.4s ease,
    visibility 0s linear 0.4s;
}

.zone-modal.is-open {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
  transition:
    opacity 0.4s ease,
    transform 0.4s ease,
    visibility 0s linear 0s;
}

.zone-modal__close {
  position: absolute;
  top: calc(20px + var(--safe-top));
  right: 20px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-on-dark);
  opacity: 0.7;
}

.zone-modal__close:hover,
.zone-modal__close:focus-visible {
  opacity: 1;
  outline: none;
}

.zone-modal__title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(28px, 8vw, 36px);
  line-height: 1.1;
  text-align: center;
  letter-spacing: -0.01em;
  margin-bottom: 24px;
  max-width: 320px;
}

.zone-modal__figure {
  width: 100%;
  max-width: 320px;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  border-radius: 6px;
  background: rgba(242, 237, 230, 0.05);
  margin-bottom: 24px;
  position: relative;
}

/* Wrapper-слой для "дыхания" — оборачивает Ken Burns слой */
.zone-modal__breath {
  position: absolute;
  inset: 0;
  animation: photoBreath var(--breath-cycle) ease-in-out infinite;
  transform-origin: center center;
  will-change: transform;
}

@keyframes photoBreath {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.015); }
}

.zone-modal__photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(0.3) contrast(1.05) brightness(0.95);
  opacity: 0;
  transition: opacity 0.6s ease;
  transform-origin: center center;
  will-change: transform, opacity;
}

.zone-modal__photo.is-loaded {
  opacity: 1;
}

/* Ken Burns — два направления, чередуются по индексу зоны */
.zone-modal__photo.is-loaded.kb-left {
  animation: kenBurnsLeft 8s cubic-bezier(0.4, 0, 0.2, 1) infinite alternate;
}

.zone-modal__photo.is-loaded.kb-right {
  animation: kenBurnsRight 8s cubic-bezier(0.4, 0, 0.2, 1) infinite alternate;
}

@keyframes kenBurnsLeft {
  0%   { transform: scale(1) translate3d(0, 0, 0); }
  100% { transform: scale(1.08) translate3d(-2%, -1%, 0); }
}

@keyframes kenBurnsRight {
  0%   { transform: scale(1) translate3d(0, 0, 0); }
  100% { transform: scale(1.08) translate3d(2%, -1%, 0); }
}

/* Cross-fade — два фото меняются местами через каждые 8s (полный цикл 16s) */
/* Альтернативное фото в начальном состоянии скрыто, основное видно */

/* Для зон с парными фото — оба фото включают cross-fade */
/* Cycle: 0s   — A=1, B=0
          6s   — A=1, B=0 (sustain)
          8s   — A=0, B=1 (transition done)
          14s  — A=0, B=1 (sustain)
          16s  — A=1, B=0 (back to start) */
.zone-modal__figure[data-crossfade="true"] .zone-modal__photo.is-loaded {
  animation:
    kenBurnsLeft 8s cubic-bezier(0.4, 0, 0.2, 1) infinite alternate,
    crossfadeA 16s ease-in-out infinite;
}

.zone-modal__figure[data-crossfade="true"] .zone-modal__photo--alt.is-loaded {
  animation:
    kenBurnsRight 8s cubic-bezier(0.4, 0, 0.2, 1) infinite alternate,
    crossfadeB 16s ease-in-out infinite;
}

@keyframes crossfadeA {
  0%,  40%  { opacity: 1; }
  50%, 90%  { opacity: 0; }
  100%      { opacity: 1; }
}

@keyframes crossfadeB {
  0%,  40%  { opacity: 0; }
  50%, 90%  { opacity: 1; }
  100%      { opacity: 0; }
}

/* ---------- Glow Follower (за пальцем на hero) ---------- */
.glow-follower {
  position: fixed;
  top: 0;
  left: 0;
  width: 240px;
  height: 240px;
  margin: -120px 0 0 -120px;
  pointer-events: none;
  background: radial-gradient(circle, rgba(199, 123, 74, 0.35) 0%, rgba(199, 123, 74, 0) 60%);
  opacity: 0;
  transition: opacity 0.9s ease-out;
  z-index: 0;
  will-change: transform, opacity;
  filter: blur(8px);
  mix-blend-mode: multiply;
}

.glow-follower.is-active {
  opacity: 1;
  transition: opacity 0.2s ease-out;
}

/* ---------- Sound Toggle ---------- */
.sound-toggle {
  position: fixed;
  top: calc(12px + var(--safe-top));
  right: 12px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(58, 47, 38, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50; /* выше hero контента, но ниже модалок (z=90/100) */
  font-size: 16px;
  line-height: 1;
  color: var(--ink-soft);
  transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.sound-toggle:hover,
.sound-toggle:focus-visible {
  background: rgba(58, 47, 38, 0.15);
  color: var(--ink);
  outline: none;
}

.sound-toggle:active {
  transform: scale(0.92);
}

.sound-toggle.is-on {
  color: var(--accent-pulse);
}

.sound-toggle__icon {
  pointer-events: none;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Версия 'icon-only' с тонкими SVG */
.sound-toggle svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.zone-modal__text {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: clamp(17px, 4.6vw, 20px);
  line-height: 1.45;
  text-align: center;
  max-width: 320px;
  margin-bottom: 28px;
  color: rgba(242, 237, 230, 0.88);
}

.zone-modal__cta {
  background: var(--accent-marked);
  color: var(--bg-dark);
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 15px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 16px 36px;
  border-radius: 999px;
  min-height: 52px;
  min-width: 200px;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.zone-modal__cta:active {
  transform: scale(0.97);
  opacity: 0.9;
}

.zone-modal__cta:focus-visible {
  outline: 2px solid var(--text-on-dark);
  outline-offset: 3px;
}

/* ---------- FINAL SCREEN ---------- */
.final-screen {
  position: fixed;
  inset: 0;
  background: var(--bg-dark);
  color: var(--text-on-dark);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(32px + var(--safe-top)) 24px calc(24px + var(--safe-bottom));
  z-index: 90;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.5s ease, visibility 0s linear 0.5s;
  overflow-y: auto;
}

.final-screen.is-open {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.5s ease, visibility 0s linear 0s;
}

.final__head {
  text-align: center;
  margin-bottom: 12px;
}

.final__eyebrow {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent-marked);
  margin-bottom: 8px;
}

.final__title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(24px, 6.6vw, 30px);
  line-height: 1.15;
  letter-spacing: -0.01em;
  max-width: 320px;
}

.final__silhouette-wrap {
  position: relative;
  width: 100%;
  max-width: 110px;
  aspect-ratio: 301 / 1000;
  margin: 12px auto;
}

.final__silhouette-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: invert(1) brightness(1.2) opacity(0.55);
  user-select: none;
  -webkit-user-drag: none;
}

.final__silhouette-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.final__card {
  text-align: center;
  width: 100%;
  max-width: 340px;
}

.final__card-line {
  font-family: var(--font-sans);
  font-size: 14px;
  color: rgba(242, 237, 230, 0.7);
  margin-bottom: 6px;
  line-height: 1.5;
}

.final__card-zones {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 17px;
  line-height: 1.4;
  color: var(--text-on-dark);
  margin-bottom: 24px;
}

.final__cta {
  display: inline-block;
  background: var(--accent-marked);
  color: var(--bg-dark);
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 15px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 18px 36px;
  border-radius: 999px;
  min-height: 56px;
  margin-bottom: 16px;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.final__cta:active {
  transform: scale(0.97);
}

.final__back {
  font-size: 13px;
  color: rgba(242, 237, 230, 0.5);
  padding: 8px;
}

.final__back:hover {
  color: rgba(242, 237, 230, 0.85);
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .dot--pulse .dot__halo,
  .dot--pulse .dot__inner,
  .zone-modal__breath,
  .zone-modal__photo,
  .zone-modal__photo.is-loaded,
  .zone-modal__photo.is-loaded.kb-left,
  .zone-modal__photo.is-loaded.kb-right,
  .zone-modal__figure[data-crossfade="true"] .zone-modal__photo.is-loaded,
  .zone-modal__figure[data-crossfade="true"] .zone-modal__photo--alt.is-loaded {
    animation: none !important;
  }
  .zone-modal__photo--alt {
    opacity: 0 !important; /* в reduced-motion показываем только основное фото */
  }
  .glow-follower {
    display: none;
  }
  .dot svg circle:first-child {
    opacity: 1;
  }
  .zone-modal,
  .final-screen {
    transition: opacity 0.15s ease, visibility 0s linear 0.15s;
  }
  .zone-modal.is-open,
  .final-screen.is-open {
    transition: opacity 0.15s ease, visibility 0s linear 0s;
  }
}

/* ---------- Дополнительная адаптация для очень узких экранов ---------- */
@media (max-width: 360px) {
  .hero {
    padding: 18px 14px;
  }
  .hero__title {
    font-size: 23px;
  }
  .silhouette-wrap {
    max-width: 135px;
  }
}

/* Большие телефоны — больше пространства */
@media (min-width: 420px) {
  .silhouette-wrap {
    max-width: 175px;
  }
}

/* Очень высокие экраны — позволяем силуэту быть больше */
@media (min-height: 800px) {
  .silhouette-wrap {
    max-width: 175px;
  }
}
