/* ==========================================================================
   Первый экран инструмента на телефоне (уже 640px), композиция «Mood Dial»:
   большая карточка с фото и «пузырём», под ней H1; три статичные плашки
   «что проверим», кнопка во всю ширину и ряд готовых примеров, которые
   сразу заполняют форму (assets/js/tool-hero-m.js). Цвет — переменные
   --th* на .th-root, их задаёт страница.
   Разметка — includes/tool-hero-m.php, образец — pages/tools/name-compatibility.php.
   ========================================================================== */
.th-card,
.th-bubble,
.th-where,
.th-dial,
.th-cta,
.th-more,
.th-trust {
  display: none;
}

/* на широких экранах обёртка вокруг H1 не влияет на вёрстку */
.th-text {
  display: contents;
}

@media (max-width: 639px) {
  .th-root .th-hero {
    padding: var(--header-space) 0 8px !important;
    border-bottom: 0 !important;
    background:
      radial-gradient(90% 46% at 100% 0, var(--th-soft), transparent 70%),
      radial-gradient(70% 40% at 0 62%, var(--th-soft), transparent 70%),
      #fbf7f0 !important;
    transition: background 0.35s;
  }

  .th-hero .th-hide {
    display: none !important;
  }

  /* minmax(0, 1fr): иначе ряд примеров с прокруткой растягивает колонку шире экрана */
  .th-hero .th-inner {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    max-width: none;
    text-align: left;
  }

  /* карточка с фото; H1 с «пузырём» лежат поверх неё в той же ячейке сетки */
  .th-card {
    position: relative;
    display: block;
    grid-area: 1 / 1;
    height: clamp(300px, 53svh, 400px);
    overflow: hidden;
    border-radius: 32px;
    background: #e9dccf;
    box-shadow: 0 28px 50px -26px var(--th-glow), 0 0 0 4px #fff, 0 0 0 6px var(--th-soft);
    transition: box-shadow 0.35s;
  }

  .th-photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: 50% 14%;
  }

  .th-card::after {
    content: "";
    position: absolute;
    inset: 40% 0 0;
    background: linear-gradient(180deg, transparent, rgba(30, 20, 10, 0.35) 40%, rgba(30, 20, 10, 0.82));
  }

  .th-tag,
  .th-live {
    position: absolute;
    top: 14px;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 12px 0 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.82);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    color: var(--main-bg-color);
    font-size: 13px;
    font-weight: 600;
  }

  .th-tag {
    left: 14px;
  }

  .th-tag svg {
    width: 18px;
    height: 18px;
    color: var(--th);
    transition: color 0.3s;
  }

  .th-live {
    right: 14px;
    padding-left: 10px;
  }

  .th-live i {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--gold-color);
    box-shadow: 0 0 0 3px rgba(189, 160, 0, 0.22);
  }

  .th-text {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    grid-area: 1 / 1;
    align-self: end;
    padding: 0 16px 16px;
    color: #fff;
  }

  .th-bubble {
    display: block;
    width: fit-content;
    max-width: 88%;
    margin-bottom: 14px;
    padding: 12px 16px;
    border-radius: 22px 22px 22px 6px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 10px 26px rgba(20, 10, 0, 0.28);
    color: var(--main-bg-color);
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
    text-wrap: balance;
  }

  .th-hero .th-title {
    margin: 0 !important;
    font-size: 26px !important;
    line-height: 1.1 !important;
    color: #fff;
  }

  .th-hero .th-title span {
    display: inline;
    font-style: normal;
    color: var(--th-soft);
    transition: color 0.3s;
  }

  .th-hero .th-title span::after {
    display: none;
  }

  .th-where {
    display: block;
    margin-top: 6px;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.86);
  }

  /* переключатель режимов */
  .th-dial {
    display: block;
    padding-top: 16px;
  }

  .th-dial-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 22px;
    margin-bottom: 10px;
  }

  .th-dial-title {
    font-family: "Montserrat", sans-serif;
    font-size: 17px;
    font-weight: 700;
    color: var(--main-bg-color);
  }

  .th-pills {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
  }

  /* статичные плашки: иконка над словом, иначе длинное слово не помещается */
  .th-pill {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 76px;
    margin: 0;
    padding: 0 6px;
    border-radius: 22px;
    background: #fff;
    box-shadow: inset 0 0 0 1.5px var(--c-soft), 0 4px 12px rgba(0, 0, 0, 0.05);
    color: var(--main-bg-color);
    font-family: "Montserrat", sans-serif;
    font-size: 14px !important;
    font-weight: 700;
    line-height: 1.1;
    text-align: center;
  }

  .th-pill-ic {
    display: grid;
    flex: none;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--c-soft);
    color: var(--c);
  }

  .th-pill-ic svg {
    width: 18px;
    height: 18px;
  }

  /* главная кнопка */
  .th-cta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 58px;
    margin-top: 16px;
    padding: 0 7px 0 24px;
    border-radius: 999px;
    background-color: var(--th);
    background-image: linear-gradient(120deg, var(--th-hi), var(--th) 45%, var(--th-deep));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 16px 30px -12px var(--th-glow);
    color: #fff;
    font-family: "Montserrat", sans-serif;
    font-size: 17px;
    font-weight: 700;
    text-decoration: none;
    transition: background-color 0.3s, box-shadow 0.3s;
  }

  .th-cta-arrow {
    display: grid;
    flex: none;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #fff;
    color: var(--th);
    transition: color 0.3s;
  }

  /* под первым экраном: готовые примеры, срезанные краем экрана */
  .th-more {
    display: block;
    padding-top: 28px;
  }

  .th-more-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    color: var(--main-bg-color);
    text-decoration: none;
  }

  .th-more-title {
    font-family: "Montserrat", sans-serif;
    font-size: 19px;
    font-weight: 700;
  }

  .th-more-title em {
    font-style: normal;
    color: var(--th);
    transition: color 0.3s;
  }

  .th-more-all {
    font-size: 14px;
    font-weight: 600;
    color: var(--dark-text-color);
  }

  .th-avs {
    display: flex;
    gap: 10px;
    margin: 0 -20px;
    padding: 4px 20px 10px;
    overflow-x: auto;
    scroll-padding: 0 20px;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }

  .th-avs::-webkit-scrollbar {
    display: none;
  }

  /* пример: карточка с полным именем, нажатие заполняет форму */
  .th-av {
    position: relative;
    display: flex;
    flex: 0 0 150px;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 14px 40px 14px 14px;
    border: 0;
    border-radius: 18px;
    background: #fff;
    box-shadow: inset 0 0 0 1.5px var(--th-soft), 0 8px 18px -12px var(--th-glow);
    color: var(--main-bg-color);
    font: inherit;
    text-align: left;
    cursor: pointer;
    scroll-snap-align: start;
    transition: transform 0.2s;
  }

  .th-av:active {
    transform: scale(0.97);
  }

  .th-av b {
    font-family: "Montserrat", sans-serif;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.2;
  }

  .th-av small {
    color: var(--dark-text-color);
    font-size: 12.5px;
    line-height: 1.3;
  }

  .th-av-go {
    position: absolute;
    top: 50%;
    right: 10px;
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    margin-top: -13px;
    border-radius: 50%;
    background: var(--th-soft);
    color: var(--th);
  }

  .th-trust {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 20px;
    padding: 12px 16px;
    border-radius: 18px;
    background: #fffaf5;
    box-shadow: inset 0 0 0 1px rgba(17, 17, 17, 0.08);
  }

  .th-trust-ic {
    display: grid;
    flex: none;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--th-soft);
    color: var(--th);
  }

  .th-trust div b {
    display: block;
    color: var(--main-bg-color);
    font-size: 15px;
  }

  .th-trust div span {
    display: block;
    color: var(--dark-text-color);
    font-size: 13px;
  }
}

@media (max-width: 639px) and (prefers-reduced-motion: reduce) {
  .th-root .th-hero,
  .th-card,
  .th-cta,
  .th-av {
    transition: none;
  }
}

/* На телефоне форма, результат и пояснения идут во всю ширину, без белой
   карточки: класс th-flat в разметке или те же правила в CSS инструмента
   (для блоков, которые рисует JS). Внутренние плашки и пункты не трогаем. */
@media (max-width: 639px) {
  /* .th-root поднимает вес: CSS инструмента подключается позже и местами ставит padding с !important */
  .th-root .th-flat {
    padding: 0 !important;
    background: none !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
  }
}
