/* ============================================
   Колесо фортуны: плавающая кнопка + попап
   Блоки: .wheel-fortune, .wheel-modal
   ============================================ */

/* --- Плавающая кнопка (launcher) --- */

.wheel-fortune {
  position: fixed;
  display: flex;
  left: var(--space-4);
  /* на одном уровне с .quiz-mini (quiz.css), пока баннер квиза скрыт */
  bottom: 0.9rem;
  z-index: 260;
}

.wheel-fortune__launcher {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100vw - var(--space-8));
  padding: 0;
  border: none;
  border-radius: var(--radius-full);
  background: transparent;
  cursor: pointer;
}

.wheel-fortune__launcher:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 4px;
}

/* Колесо: объёмный обод + вращающийся диск */

.wheel-fortune__launcher-wheel {
  position: relative;
  flex-shrink: 0;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background:
    conic-gradient(
      from 0deg,
      rgba(255, 255, 255, 0.14),
      rgba(255, 255, 255, 0) 25%,
      rgba(255, 255, 255, 0.14) 50%,
      rgba(255, 255, 255, 0) 75%,
      rgba(255, 255, 255, 0.14)
    ),
    radial-gradient(circle at 50% 32%, #3a3a3a 0%, #0d0d0d 62%, #050505 100%);
  box-shadow:
    0 2px 3px rgba(255, 255, 255, 0.22) inset,
    0 -4px 8px rgba(0, 0, 0, 0.6) inset,
    0 8px 16px rgba(0, 0, 0, 0.28);
}

/* Стрелка сверху */
.wheel-fortune__launcher-wheel::before {
  content: '';
  position: absolute;
  top: -7px;
  left: 50%;
  z-index: 3;
  width: 14px;
  height: 13px;
  background: var(--primary);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform: translateX(-50%);
}

/* Пульс — кольцом от колеса, не от всей плашки */
.wheel-fortune__launcher-wheel::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  animation: wheel-fortune-pulse 2.2s ease-out infinite;
}

.wheel-fortune__launcher-bulbs {
  position: absolute;
  inset: 0;
  z-index: 2;
}

.wheel-fortune__launcher-bulb {
  position: absolute;
  top: 1.5%;
  left: 46.5%;
  width: 7%;
  height: 7%;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--warning-light) 0%, var(--star) 45%, var(--warning) 100%);
  box-shadow: 0 0 4px var(--star);
  transform-origin: 50% 693%;
  animation: wheel-fortune-blink 1.2s ease-in-out infinite alternate;
}

.wheel-fortune__launcher-bulb:nth-child(2) {
  transform: rotate(36deg);
}

.wheel-fortune__launcher-bulb:nth-child(3) {
  transform: rotate(72deg);
}

.wheel-fortune__launcher-bulb:nth-child(4) {
  transform: rotate(108deg);
}

.wheel-fortune__launcher-bulb:nth-child(5) {
  transform: rotate(144deg);
}

.wheel-fortune__launcher-bulb:nth-child(6) {
  transform: rotate(180deg);
}

.wheel-fortune__launcher-bulb:nth-child(7) {
  transform: rotate(216deg);
}

.wheel-fortune__launcher-bulb:nth-child(8) {
  transform: rotate(252deg);
}

.wheel-fortune__launcher-bulb:nth-child(9) {
  transform: rotate(288deg);
}

.wheel-fortune__launcher-bulb:nth-child(10) {
  transform: rotate(324deg);
}

.wheel-fortune__launcher-bulb:nth-child(even) {
  animation-delay: -0.6s;
}

.wheel-fortune__launcher-disc {
  position: absolute;
  top: 11%;
  left: 11%;
  z-index: 1;
  width: 78%;
  height: 78%;
  border-radius: 50%;
  background: conic-gradient(
    from 180deg,
    var(--primary) 0deg 45deg,
    var(--primary-hover) 45deg 90deg,
    var(--primary) 90deg 135deg,
    var(--primary-hover) 135deg 180deg,
    var(--primary) 180deg 225deg,
    var(--primary-hover) 225deg 270deg,
    var(--primary) 270deg 315deg,
    var(--primary-hover) 315deg 360deg
  );
  animation: wheel-fortune-spin 14s linear infinite;
}

.wheel-fortune__launcher-disc::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(
    circle at 50% 28%,
    rgba(255, 255, 255, 0.75) 0%,
    rgba(255, 255, 255, 0.15) 55%,
    rgba(0, 0, 0, 0.35) 100%
  );
}

.wheel-fortune__launcher:hover .wheel-fortune__launcher-disc {
  animation-duration: 2.4s;
}

.wheel-fortune__launcher-hub {
  position: absolute;
  top: 33%;
  left: 33%;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34%;
  height: 34%;
  border-radius: 50%;
  color: var(--primary);
  background: radial-gradient(circle at 50% 30%, var(--warning-light) 0%, var(--star) 55%, var(--warning) 100%);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.35), 0 1px 2px rgba(255, 255, 255, 0.45) inset;
}

.wheel-fortune__launcher-hub svg {
  width: 50%;
  height: 50%;
  fill: currentColor;
}

/* Подпись — отдельная синяя плашка */
.wheel-fortune__launcher-text {
  max-width: 150px;
  padding: 8px 12px;
  border-radius: var(--radius-full);
  background: var(--gradient-primary);
  color: var(--text-white);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: var(--weight-bold);
  line-height: 1.25;
  text-align: center;
  overflow-wrap: break-word;
  box-shadow: var(--shadow-glow-md), 0 1px 0 rgba(255, 255, 255, 0.35) inset;
}

@media (min-width: 768px) {
  .wheel-fortune__launcher-wheel {
    width: 68px;
    height: 68px;
  }

  .wheel-fortune__launcher-text {
    max-width: none;
    padding: 9px 14px;
    font-size: 14px;
  }
}

.wheel-fortune__noscript {
  max-width: min(280px, calc(100vw - var(--space-8)));
  margin: 0;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-inner);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  font-size: var(--font-size-13);
  color: var(--text-secondary);
}

@keyframes wheel-fortune-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes wheel-fortune-blink {
  from {
    opacity: 0.45;
  }
  to {
    opacity: 1;
  }
}

@keyframes wheel-fortune-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(var(--primary-rgb), 0.55);
  }
  100% {
    box-shadow: 0 0 0 14px rgba(var(--primary-rgb), 0);
  }
}

/* Баннер квиза виден — поднимаем launcher над ним */
body:has(.quiz-banner:not([hidden])) .wheel-fortune {
  bottom: calc(var(--space-4) + 98px);
}

@media (min-width: 480px) {
  body:has(.quiz-banner:not([hidden])) .wheel-fortune {
    bottom: calc(var(--space-4) + 103px);
  }
}

@media (min-width: 1366px) {
  body:has(.quiz-banner:not([hidden])) .wheel-fortune {
    bottom: calc(var(--space-4) + 126px);
  }
}


/* --- Попап --- */

.wheel-modal {
  padding: 0;
}

.wheel-modal__content {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  padding: 0;
  border-radius: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(255, 255, 255, 0.16) 0%, rgba(255, 255, 255, 0) 70%),
    linear-gradient(160deg, var(--text) 0%, var(--primary-hover) 100%);
  color: var(--text-white);
  overflow-y: auto;
}

.wheel-modal__grid {
  display: flex;
  flex-direction: column;
}

.wheel-fortune__stage {
  display: flex;
  justify-content: center;
  /* вращающийся квадрат диска увеличивает AABB и даёт transient scrollHeight модалке */
  overflow: hidden;
  padding: 28px 24px 0;
}

.wheel-fortune__panel {
  padding: 20px 24px 24px;
}

/* --- Колесо --- */

.wheel-fortune__wheel {
  --wheel-size: min(300px, 80vw);
  position: relative;
  flex-shrink: 0;
  width: var(--wheel-size);
  height: var(--wheel-size);
  border-radius: 50%;
  background: radial-gradient(circle at 50% 30%, #3c4257 0%, #242838 55%, #12141f 100%);
  box-shadow:
    0 2px 3px rgba(255, 255, 255, 0.2) inset,
    0 -8px 18px rgba(0, 0, 0, 0.6) inset,
    0 20px 40px rgba(0, 0, 0, 0.45);
}

.wheel-fortune__dial {
  position: absolute;
  inset: 7%;
  overflow: hidden;
  border-radius: 50%;
  background: var(--primary-hover);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.4) inset, 0 8px 24px rgba(0, 0, 0, 0.4) inset;
  transform: rotate(0deg);
  will-change: transform;
}

.wheel-fortune__labels {
  position: absolute;
  inset: 0;
}

.wheel-fortune__label {
  position: absolute;
  inset: 0;
}

.wheel-fortune__label-inner {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.35em;
  /* 28% держит внешний угол подписи внутри рабочего радиуса диска */
  width: 28%;
  margin: 10% auto 0;
  /* Касательная ориентация как wf1-wheel-row */
  transform: rotate(-90deg);
  transform-origin: center;
}

/* На 320px колесо меньше — отступ 15% уводит иконку под hub */
@media (min-width: 360px) {
  .wheel-fortune__label-inner {
    margin-top: 15%;
  }
}

.wheel-fortune__label-icon {
  width: 42%;
  max-width: 16px;
  height: auto;
  aspect-ratio: 1;
  /* Material Symbols приходят чёрными — на синем секторе нужны белые */
  filter: brightness(0) invert(1);
}

.wheel-fortune__label-text {
  min-width: 0;
  font-family: var(--font-display);
  font-size: clamp(8px, 2vw, 10px);
  font-weight: var(--weight-bold);
  line-height: var(--line-height-110);
  text-align: center;
  color: var(--text-white);
  overflow-wrap: break-word;
  hyphens: auto;
}

/* Главный приз — золотая плашка (только стиль, выбор приза не меняется) */
.wheel-fortune__label--main .wheel-fortune__label-inner {
  padding: 3px 4px 4px;
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, var(--warning-light) 0%, var(--star) 100%);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.wheel-fortune__label--main .wheel-fortune__label-text {
  color: var(--text);
}

.wheel-fortune__label--main .wheel-fortune__label-icon {
  /* как main/pic у WF1: на золотой плашке иконка не выводится */
  display: none;
}

/* 16 лампочек по ободу: угол приходит из inline-переменной */
.wheel-fortune__bulbs {
  position: absolute;
  inset: 0;
  z-index: 2;
}

.wheel-fortune__bulb {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 2.6%;
  height: 2.6%;
  margin: -1.3% 0 0 -1.3%;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--warning-light) 0%, var(--star) 45%, var(--warning) 100%);
  box-shadow: 0 0 6px var(--star);
  transform: rotate(var(--wheel-bulb-angle, 0deg)) translateY(calc(var(--wheel-size) * -0.465));
  animation: wheel-fortune-blink 1.2s ease-in-out infinite alternate;
}

.wheel-fortune__bulb:nth-child(even) {
  animation-delay: -0.6s;
}

/* Указатель справа (90deg по часовой стрелке от верха) */
.wheel-fortune__pointer {
  position: absolute;
  top: 50%;
  right: -1.5%;
  z-index: 4;
  width: 13.8%;
  height: 10.8%;
  background: linear-gradient(180deg, #5b6178 0%, #2c3145 45%, #15171f 100%);
  clip-path: polygon(100% 0, 100% 100%, 0 50%);
  transform: translateY(-50%);
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.55));
}

.wheel-fortune__hub {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24%;
  height: 24%;
  border: 4px solid #0d0d0d;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 28%, var(--surface) 0%, var(--surface-2) 62%, var(--primary-light) 100%);
  color: var(--primary);
  transform: translate(-50%, -50%);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.45), 0 1px 0 rgba(255, 255, 255, 0.9) inset;
}

.wheel-fortune__hub svg {
  width: 46%;
  height: 46%;
  fill: currentColor;
}

/* --- Текст панели --- */

.wheel-modal__title {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: clamp(28px, 4.4vw, 40px);
  font-weight: var(--weight-extrabold);
  line-height: 1;
  color: var(--text-white);
}

.wheel-modal__desc {
  margin: 0 0 18px;
  font-size: clamp(15px, 1.6vw, 18px);
  line-height: var(--line-height-150);
  color: var(--white-70);
}

.wheel-modal__info {
  margin: 0 0 20px;
  padding: 14px 16px;
  border-radius: var(--radius-inner);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}

.wheel-modal__info-title {
  margin: 0 0 4px;
  font-size: var(--font-size-12);
  font-weight: var(--weight-semibold);
  color: var(--text-muted);
}

.wheel-modal__info-text {
  margin: 0;
  font-size: var(--font-size-15);
  font-weight: var(--weight-semibold);
  color: var(--text);
}

/* --- Результат --- */

.wheel-modal__result {
  margin: 0 0 6px;
}

.wheel-modal__result-title {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: clamp(26px, 4vw, 40px);
  font-weight: var(--weight-extrabold);
  line-height: 1;
  color: var(--text-white);
}

.wheel-modal__result-label {
  margin: 0 0 4px;
  font-size: var(--font-size-15);
  color: var(--white-70);
}

.wheel-modal__result-prize {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: clamp(18px, 2.2vw, 22px);
  font-weight: var(--weight-bold);
  line-height: var(--line-height-125);
  color: var(--star);
}

/* Intro скрывается в состоянии результата */
.wheel-modal--has-result .wheel-modal__intro {
  display: none;
}

/* В result spin скрыт — пустой actions не должен добавлять margin-top */
.wheel-modal--has-result .wheel-modal__actions {
  display: none;
}

/* Mobile result: колесо сохраняет 300px-раскладку и масштабируется целиком,
   чтобы подписи не перекомпоновывались; на ≥768 масштаб снимается. */
.wheel-modal--has-result .wheel-fortune__wheel {
  transform: scale(0.7);
  transform-origin: center top;
}

.wheel-modal--has-result .wheel-fortune__stage {
  height: calc(28px + min(210px, 56vw));
}

/* --- Действия --- */

.wheel-modal__actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}

.wheel-fortune__spin {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 20px;
  border: none;
  border-radius: var(--radius-full);
  font-family: var(--font-display);
  font-size: var(--font-size-15);
  font-weight: var(--weight-bold);
  line-height: var(--line-height-120);
  color: var(--text);
  background: var(--star);
  cursor: pointer;
}

.wheel-fortune__spin:hover {
  color: var(--text);
  background: var(--warning-light);
}

.wheel-fortune__spin:disabled {
  opacity: 0.75;
  cursor: default;
}

/* Крестик: базовый .modal__close даёт position absolute/top/right/размер */
.wheel-modal__close {
  z-index: 5;
  color: var(--text-white);
  border-radius: var(--radius-full);
  background: transparent;
}

.wheel-modal__close:hover {
  color: var(--text-white);
  background: var(--white-10);
}

.wheel-fortune__spin:focus-visible,
.wheel-modal__close:focus-visible {
  outline: 2px solid var(--primary-light);
  outline-offset: 2px;
}

/* .btn задаёт display, поэтому [hidden] нужно вернуть явно */
.wheel-fortune__spin[hidden],
.wheel-modal__result[hidden],
.wheel-fortune__form[hidden] {
  display: none;
}

/* --- Форма и юридический текст --- */

.wheel-fortune__form {
  margin-top: 14px;
}

/* Форма — белая карточка lead-capture: тёмные подписи и согласие */
.wheel-fortune__form .cf7-field > span:first-child {
  color: var(--text-secondary);
}

.wheel-fortune__form .wpcf7-acceptance {
  color: var(--text-muted);
}

.wheel-fortune__form .wpcf7-list-item-label a {
  color: var(--primary);
}

.wheel-fortune__form .wpcf7-submit:disabled {
  opacity: 0.85;
  cursor: not-allowed;
}

.wheel-fortune__legal {
  margin: 16px 0 0;
  font-size: var(--font-size-12);
  line-height: var(--line-height-150);
  color: var(--white-50);
}

/* --- Планшет / десктоп --- */

@media (min-width: 768px) {
  .wheel-modal {
    padding: var(--space-4);
  }

  .wheel-modal__content {
    max-width: 1000px;
    height: auto;
    max-height: calc(100vh - var(--space-8));
    border-radius: var(--radius-card);
  }

  .wheel-modal__grid {
    display: grid;
    grid-template-columns: 45% 55%;
    align-items: center;
  }

  .wheel-fortune__stage {
    padding: clamp(16px, 3vw, 30px);
  }

  .wheel-fortune__panel {
    padding: clamp(22px, 4vw, 40px) clamp(24px, 7vw, 70px) clamp(22px, 4vw, 40px) clamp(24px, 5vw, 50px);
  }

  .wheel-fortune__wheel {
    --wheel-size: min(300px, 34vw);
  }

  /* Desktop result: без уменьшения, stage снова по содержимому */
  .wheel-modal--has-result .wheel-fortune__wheel {
    transform: none;
  }

  .wheel-modal--has-result .wheel-fortune__stage {
    height: auto;
  }

  .wheel-modal__actions {
    flex-direction: row;
  }

  .wheel-fortune__spin {
    flex: 1;
    min-height: 44px;
  }
}

@media (min-width: 1024px) {
  .wheel-fortune__wheel {
    --wheel-size: min(390px, 36vw);
  }
}

/* --- Reduced motion --- */

@media (prefers-reduced-motion: reduce) {
  .wheel-fortune__launcher-wheel::after,
  .wheel-fortune__launcher-disc,
  .wheel-fortune__launcher-bulb,
  .wheel-fortune__bulb {
    animation: none;
  }

  .wheel-fortune__dial {
    transition: none;
  }
}
