/*
 * Первый экран главной «Список Вместе — органайзер для всей семьи»
 * (index.html, .hero-organizer). Анимация — scripts/hero-organizer-live.js.
 *
 * Сцена собрана из вёрстки приложения, уже повторённой на сайте:
 *  - карточки товаров — .jl-card из styles/journey-live.css (ShoppingItemCard);
 *  - карточки дел — .tk-card, правила перенесены из styles/tasks.css;
 *  - обсуждение — экран чата, правила перенесены из styles/family-chat.css
 *    (размеры приведены к масштабу сцены).
 * Никаких emoji — только картинки приложения.
 *
 * Базовые стили = итоговый кадр (без JS и при prefers-reduced-motion).
 * Скрипт ставит .hh-anim и по шагам добавляет классы s-*; состояния самих
 * карточек (is-checked, is-flash, is-done) переключает тоже скрипт.
 */

/* ---------- Текст ---------- */
.hero-organizer .hero-copy {
  min-width: 0;
  align-self: start;
}

.hero-organizer .hh-title {
  color: #3c3c43;
  font-family: "Inter", system-ui, sans-serif;
  font-size: clamp(1.375rem, 2.8vw, 2.75rem);
  font-weight: 500;
  line-height: 1.27;
  letter-spacing: -0.024em;
}

.hh-title strong {
  color: var(--blue-600);
  font-size: 1.3em;
  font-weight: 700;
  letter-spacing: 0.012em;
}

.hh-title b {
  color: rgb(244, 170, 43);
  font-weight: 800;
}

.hero-organizer .hh-title-description {
  display: block;
  margin-top: 0.35em;
  color: inherit;
}

.hero-organizer .hh-title-description::after {
  content: none;
}

.hero-organizer .hh-sub {
  max-width: 600px;
  margin: 0 0 14px;
  color: var(--ink);
  font-size: clamp(19px, 1.75vw, 24px);
  font-weight: 650;
  line-height: 1.3;
  letter-spacing: -0.02em;
}

/* ---------- Сцена ---------- */
.hh-demo {
  z-index: 2;
  min-width: 0;
}

.hh-scene {
  /* переменные вёрстки приложения (journey-live.css, tasks.css, family-chat.css) */
  --jl-blue: #007aff;
  --jl-label: #000000;
  --jl-muted: #66707c;
  --jl-border: rgba(216, 218, 222, 0.82);
  --ios-blue: #007aff;
  --fc-blue: #007aff;
  --fc-ink: #111827;
  --fc-muted: #8a8f98;
  --fc-bubble-in: #ffffff;
  --hh-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --hh-cloud-width: 356px;
  --hh-thought-offset: clamp(24px, 5vw, 54px);
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-areas:
    "lena   lena"
    "ha     hb"
    "shop   toys"
    "shop   chat"
    "parcel chat";
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-rows: auto auto auto auto 1fr;
  align-content: start;
  gap: 10px 14px;
  min-width: 0;
  height: 610px;
  margin: 0;
  padding: 22px 22px 18px;
  overflow: hidden;
  border: 1px solid rgba(47, 107, 255, 0.1);
  border-radius: 34px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.32), rgba(255, 255, 255, 0)),
    #e3eaff;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.75),
    0 26px 55px rgba(47, 107, 255, 0.12);
  isolation: isolate;
  color: #111827;
  font-family: Inter, -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
}

.hh-scene .stage-orb {
  z-index: -1;
}

.hh-scene figcaption {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Участники (как .jl-chip) ---------- */
.hh-person {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  height: 46px;
  padding: 6px 12px 6px 6px;
  border: 1px solid rgba(255, 255, 255, 0.86);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 10px 24px rgba(31, 62, 127, 0.12);
}

.hh-person-lena {
  position: relative;
  left: 0;
  grid-area: lena;
  justify-self: start;
  transition: left 550ms var(--hh-ease), transform 550ms var(--hh-ease),
    background-color 350ms ease, border-color 350ms ease, box-shadow 350ms ease;
}

.hh-person-lena .hh-avatar {
  transform-origin: left center;
  transition: transform 550ms var(--hh-ease), box-shadow 350ms ease;
}

.hh-person-lena .hh-person-text { transition: transform 550ms var(--hh-ease); }
.hh-person-anton { grid-area: ha; }
.hh-person-anya { grid-area: hb; }
.hh-person-anton, .hh-person-anya { transition: opacity 350ms ease; }

.hh-avatar {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
}

.hh-person-text {
  display: grid;
  min-width: 0;
  line-height: 1.2;
}

.hh-person-text b {
  font-size: 13px;
  font-weight: 700;
}

.hh-person-text small {
  overflow: hidden;
  color: rgba(60, 60, 67, 0.62);
  font-size: 11.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hh-badge {
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--ios-blue);
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  transition: opacity 300ms ease, transform 400ms var(--hh-ease);
}

.hh-lena-state { display: grid; }
.hh-lena-state > span { grid-area: 1 / 1; transition: opacity 300ms ease; }
.hh-lena-now { opacity: 0; }
.hh-lena-done { color: #34c759; font-weight: 600; }

/* ---------- Мысли Лены ---------- */
.hh-cloud {
  position: absolute;
  z-index: 6;
  grid-area: lena;
  top: calc(100% + var(--hh-thought-offset) + 10px);
  right: 0;
  left: 0;
  display: grid;
  gap: 9px;
  width: min(100%, var(--hh-cloud-width));
  margin-inline: auto;
  padding-block: clamp(58px, 7vw, 74px) clamp(34px, 4vw, 44px);
  font-size: clamp(16px, 2vw, 18px);
  font-weight: 550;
  line-height: 1.4;
  letter-spacing: -0.02em;
  transform: translateY(-16px) scale(0.88);
  transform-origin: 10% 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 320ms ease, transform 520ms var(--hh-ease);
}

.hh-cloud-shape {
  position: absolute;
  z-index: -1;
  inset: 0;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 5px 9px rgba(42, 62, 115, 0.13));
}

.hh-cloud span {
  margin-inline: 22% 5%;
  transition: opacity 300ms ease, transform 400ms var(--hh-ease);
}

/* ---------- Покупки: .jl-card из приложения ---------- */
.hh-shop {
  grid-area: shop;
  display: grid;
  align-content: start;
  gap: 8px;
  min-width: 0;
  transition: opacity 450ms ease, transform 800ms var(--hh-ease);
}

.hh-shop-head > div {
  padding: 0 6px 0 10px;
}

.hh-count {
  font-variant-numeric: tabular-nums;
}

.hh-scene .jl-card {
  min-height: 100px;
  box-shadow: 0 6px 18px rgba(28, 39, 70, 0.07);
}

.hh-scene .jl-card.is-flash {
  box-shadow: 0 4px 26px 1px rgba(0, 122, 255, 0.24);
}

.hh-scene .jl-name {
  font-size: 16px;
}

.hh-scene .jl-art {
  width: 92px;
  height: 92px;
}

/* «Сметана» появляется в списке (как .jl-collapse) */
.hh-collapse {
  display: grid;
  grid-template-rows: 1fr;
  opacity: 1;
  transition: grid-template-rows 0.42s ease, opacity 0.32s ease;
}

.hh-collapse > div {
  min-height: 0;
  overflow: hidden;
}

/* ---------- Дела: .tk-card (из styles/tasks.css) ---------- */
.hh-tk {
  min-width: 0;
  transition: opacity 450ms ease, transform 800ms var(--hh-ease);
}

.hh-scene .tk-card {
  position: relative;
  overflow: hidden;
  margin: 0;
  padding: 13px 7px 12px 8px;
  border: 0.9px solid rgba(255, 165, 58, 0.28);
  border-radius: 22px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(241, 242, 244, 0.94));
  box-shadow: 0 5px 16px rgba(0, 0, 0, 0.055), 0 1px 4px rgba(0, 0, 0, 0.02);
}

.hh-tk[data-hh-task="toys"] { grid-area: toys; align-self: start; }
.hh-tk[data-hh-task="parcel"] { grid-area: parcel; align-self: start; }

.hh-scene .tk-art {
  position: absolute;
  top: 1px;
  right: 36px;
  width: 92px;
  height: 92px;
  object-fit: contain;
  opacity: 0.74;
}

.hh-scene .tk-row {
  position: relative;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 30px;
  gap: 4px;
  align-items: start;
}

/* Чекбокс — общий блок .app-check (styles/app-check.css), здесь только состояние. */
.hh-scene .tk-check img {
  transition: opacity 0.18s ease;
}

.hh-scene .tk-check-on { opacity: 0; }
.hh-tk.is-done .tk-check-on { opacity: 1; }
.hh-tk.is-done .tk-check-off { opacity: 0; }

.hh-scene .tk-main { min-width: 0; }

.hh-scene .tk-title {
  position: relative;
  display: inline-block;
  max-width: 100%;
  padding-top: 9px;
  color: #111827;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.25;
  transition: color 0.3s ease;
}

.hh-scene .tk-title::after {
  position: absolute;
  top: calc(50% + 4.5px);
  left: 0;
  width: 0;
  height: 1.5px;
  background: #8e8e93;
  content: "";
  transition: width 0.4s ease;
}

.hh-tk.is-done .tk-title { color: #8e8e93; }
.hh-tk.is-done .tk-title::after { width: 100%; }

.hh-scene .tk-people {
  display: flex;
  margin-top: 7px;
}

.hh-scene .tk-pill {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 5px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
}

.hh-scene .tk-pill.is-blue {
  background: #eef5fe;
  color: var(--ios-blue);
}

.hh-scene .tk-pill img {
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: 50%;
  object-fit: cover;
}

.hh-scene .tk-pill small,
.hh-scene .tk-pill b {
  display: block;
  overflow: hidden;
  font-size: 10.5px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hh-scene .tk-pill b {
  font-size: 12px;
  font-weight: 600;
}

.hh-scene .tk-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 7px;
}

.hh-scene .tk-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  transition: opacity 300ms ease, transform 400ms var(--hh-ease);
}

.hh-scene .tk-chip.is-muted { background: #f2f3f4; color: var(--muted); }
.hh-scene .tk-chip.is-green { background: #eaf8ee; color: #34c759; }

.hh-scene .tk-side {
  display: grid;
  justify-items: center;
  gap: 14px;
  padding-top: 2px;
  color: var(--ios-blue);
}

.hh-scene .tk-side svg:not(:first-child) { color: var(--muted); }

/* ---------- Обсуждение: экран чата (из styles/family-chat.css) ---------- */
.hh-chat {
  grid-area: chat;
  align-self: start;
  display: flex;
  flex-direction: column;
  padding: 10px 12px 8px;
  border: 1px solid rgba(255, 255, 255, 0.86);
  border-radius: 22px;
  background: #f6f7f9;
  box-shadow: 0 12px 28px rgba(28, 39, 70, 0.12);
  color: var(--fc-ink);
  transition: opacity 450ms ease, transform 600ms var(--hh-ease);
}

.hh-chat-head {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 0 2px 8px;
  border-bottom: 1px solid #e3e5e9;
  color: var(--fc-blue);
}

.hh-chat-head span {
  display: grid;
  min-width: 0;
  color: var(--fc-ink);
  line-height: 1.2;
}

.hh-chat-head b { font-size: 13px; }

.hh-chat-head small {
  overflow: hidden;
  color: var(--fc-muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hh-chat-head i {
  font-size: 12px;
  font-style: normal;
  font-weight: 600;
}

.hh-chat-card {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 2px;
  padding: 6px 9px;
  border: 1px solid rgba(0, 122, 255, 0.18);
  border-radius: 12px;
  background: rgba(0, 122, 255, 0.06);
}

.hh-chat-card img { width: 28px; height: 28px; object-fit: contain; }
.hh-chat-card span { display: grid; line-height: 1.25; }
.hh-chat-card b { font-size: 12px; }
.hh-chat-card small { color: var(--fc-muted); font-size: 10.5px; }

.hh-msgs {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 0 6px;
}

.hh-msg {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  max-width: 88%;
  font-size: 12.5px;
  line-height: 1.35;
  transition: opacity 300ms ease, transform 400ms var(--hh-ease);
}

.hh-msg img {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
}

.hh-msg span {
  padding: 6px 10px;
  border-radius: 14px;
}

.hh-msg small {
  display: block;
  margin-bottom: 1px;
  color: #d9822b;
  font-size: 10px;
  font-weight: 700;
}

.hh-in span {
  background: var(--fc-bubble-in);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.hh-out {
  align-self: flex-end;
}

.hh-out span {
  background: var(--fc-blue);
  color: #ffffff;
}

.hh-typing {
  display: none;
  align-self: flex-end;
  gap: 4px;
  padding: 9px 11px;
  border-radius: 14px;
  background: rgba(0, 122, 255, 0.14);
}

.hh-typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--fc-blue);
  animation: hh-dot 1s ease-in-out infinite;
}

.hh-typing i:nth-child(2) { animation-delay: calc(0.15s * var(--hh-delay-scale, 1)); }
.hh-typing i:nth-child(3) { animation-delay: calc(0.3s * var(--hh-delay-scale, 1)); }

@keyframes hh-dot {
  0%, 100% { opacity: 0.3; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-3px); }
}

.hh-input {
  display: flex;
  align-items: center;
  gap: 7px;
  padding-top: 2px;
}

.hh-input span {
  flex: 1;
  padding: 6px 11px;
  border: 1px solid #dfe2e7;
  border-radius: 16px;
  background: #ffffff;
  color: #9aa0a9;
  font-size: 11.5px;
}

.hh-input i {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--fc-blue);
}

/* ---------- Итог ---------- */
.hh-toast {
  position: absolute;
  z-index: 7;
  bottom: 22px;
  left: 50%;
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--navy);
  color: #ffffff;
  font-size: 14px;
  font-weight: 650;
  white-space: nowrap;
  box-shadow: var(--shadow-small);
  transform: translate(-50%, 0);
  opacity: 0;
  transition: opacity 400ms ease, transform 500ms var(--hh-ease);
}

/* ============ Режим анимации (.hh-anim) ============ */
.hh-anim:not(.s-release) .hh-person-lena {
  left: max(0px, calc((100% - var(--hh-cloud-width)) / 2));
  transform: translateY(var(--hh-thought-offset));
  border-color: transparent;
  background-color: transparent;
  box-shadow: none;
}

.hh-anim:not(.s-release) .hh-person-lena .hh-avatar {
  transform: scale(1.65);
  box-shadow: 0 0 0 2px white;
}

.hh-anim:not(.s-release) .hh-person-lena .hh-person-text { transform: translateX(24px); }
.hh-anim:not(.s-release) .hh-person-anton,
.hh-anim:not(.s-release) .hh-person-anya { opacity: 0; }

.hh-anim.s-t1 .hh-cloud {
  opacity: 1;
  transform: none;
}

.hh-anim:not(.s-t1) .hh-cloud span:nth-of-type(1),
.hh-anim:not(.s-t2) .hh-cloud span:nth-of-type(2),
.hh-anim:not(.s-t3) .hh-cloud span:nth-of-type(3) {
  opacity: 0;
  transform: translateY(-5px);
}

.hh-anim.s-release .hh-cloud {
  opacity: 0;
  transform: translateY(20px);
}

.hh-anim:not(.s-release) .hh-lena-now { opacity: 1; }
.hh-anim:not(.s-release) .hh-lena-done { opacity: 0; }

/* Карточки «вылетают» из облака */
.hh-anim:not(.s-release) .hh-shop,
.hh-anim:not(.s-release) .hh-tk {
  opacity: 0;
  transform: translate(var(--hh-fx, 0), var(--hh-fy, -60px)) scale(0.55);
}

.hh-shop { --hh-fx: 70px; --hh-fy: -30px; }
.hh-tk[data-hh-task="parcel"] { --hh-fx: 70px; --hh-fy: -200px; }
.hh-tk[data-hh-task="toys"] { --hh-fx: -90px; --hh-fy: -20px; }

.hh-anim.s-release .hh-tk[data-hh-task="toys"] { transition-delay: calc(120ms * var(--hh-delay-scale, 1)); }
.hh-anim.s-release .hh-tk[data-hh-task="parcel"] { transition-delay: calc(240ms * var(--hh-delay-scale, 1)); }

.hh-anim:not(.s-release) .hh-badge {
  opacity: 0;
  transform: scale(0.4);
}

.hh-anim:not(.s-accept) .hh-accepted {
  opacity: 0;
  transform: translateY(4px);
}

/* Обсуждение */
.hh-anim:not(.s-chat) .hh-chat,
.hh-anim.s-collapse .hh-chat {
  opacity: 0;
  transform: translateY(14px) scale(0.97);
}

.hh-anim:not(.s-chat) [data-hh-msg="1"],
.hh-anim:not(.s-m2) [data-hh-msg="2"],
.hh-anim:not(.s-m3) [data-hh-msg="3"],
.hh-anim:not(.s-m4) [data-hh-msg="4"] {
  opacity: 0;
  transform: translateY(8px);
}

.hh-anim.s-typing:not(.s-m2) .hh-typing { display: flex; }

/* Ответ «5%» становится меткой товара, как в приложении */
.hh-anim:not(.s-m2) .hh-label-fat { display: none; }

/* «Сметана» появляется в списке */
.hh-anim:not(.s-add) .hh-collapse {
  grid-template-rows: 0fr;
  opacity: 0;
}

.hh-anim.s-done .hh-toast {
  opacity: 1;
  transform: translate(-50%, -4px);
}

.hh-anim.s-fade .hh-shop,
.hh-anim.s-fade .hh-tk,
.hh-anim.s-fade .hh-toast,
.hh-anim.s-fade .hh-badge {
  opacity: 0;
  transition-delay: 0ms;
}

/* ---------- Адаптив ---------- */
@media (min-width: 1181px) {
  .hero-organizer .hh-title {
    margin-top: 0;
  }

  .hh-scene {
    min-height: 100%;
  }
}

@media (max-width: 1180px) {
  .hero-organizer {
    grid-template-columns: minmax(0, 1fr);
  }

  .hero-organizer .hh-title {
    font-size: clamp(1.375rem, 7.2vw, 2.75rem);
  }

  .hh-scene {
    width: min(820px, 100%);
    margin: 0 auto;
  }
}

@media (max-width: 820px) {
  .hero-organizer .hh-sub {
    margin-right: auto;
    margin-left: auto;
  }
}

@media (max-width: 580px) {
  .hero-organizer .hero-actions {
    display: flex;
  }

  .hh-scene {
    grid-template-areas:
      "lena"
      "ha"
      "shop"
      "parcel"
      "hb"
      "toys";
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    height: auto;
    padding: 16px 12px 76px;
    border-radius: 26px;
  }

  .hh-chat {
    grid-area: auto;
  }

  /* Во время анимации обсуждение открывается поверх карточек, как в приложении. */
  .hh-anim .hh-chat {
    position: absolute;
    z-index: 6;
    right: 10px;
    bottom: 10px;
    left: 10px;
    box-shadow: 0 -10px 40px rgba(28, 39, 70, 0.18);
  }

  .hh-shop { --hh-fx: 0px; --hh-fy: -40px; }
  .hh-tk[data-hh-task="parcel"] { --hh-fx: 0px; --hh-fy: -260px; }
  .hh-tk[data-hh-task="toys"] { --hh-fx: 0px; --hh-fy: -420px; }

  .hh-toast {
    bottom: 18px;
    font-size: 13px;
  }

  /* Место под «Сметану» зарезервировано: страница ниже не прыгает. */
  .hh-anim:not(.s-add) .hh-collapse {
    grid-template-rows: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hh-scene *,
  .hh-scene *::before,
  .hh-scene *::after {
    transition: none !important;
    animation: none !important;
  }
}
