@import url("../perform-athlete-survey/survey.css");

/* Fat-loss funnel refinements. The shared survey stylesheet keeps the proven
   layout and the animated projection graph in sync with the athlete funnel. */

:root {
  --fat-loss-bevel: 18px;
  --survey-vh: 100dvh;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
  overscroll-behavior-x: none;
}

body {
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

.survey-app,
.screen {
  min-height: var(--survey-vh, 100dvh);
}

button,
a,
input {
  touch-action: manipulation;
}

.choice,
.info-visual,
.profile-card,
.benefit-card,
.text-field input {
  border-radius: 0;
  clip-path: polygon(
    0 0,
    calc(100% - var(--fat-loss-bevel)) 0,
    100% var(--fat-loss-bevel),
    100% 100%,
    0 100%
  );
}

.gender-toggle,
.unit-toggle,
.target-toggle {
  border-radius: 0;
  clip-path: polygon(
    0 0,
    calc(100% - 14px) 0,
    100% 14px,
    100% 100%,
    14px 100%,
    0 calc(100% - 14px)
  );
}

.gender-toggle:not(:has(.gender-option.is-selected))::before {
  opacity: 0;
}

.contact-panel {
  align-content: start;
}

.contact-fields {
  display: grid;
  gap: 18px;
  width: min(100%, 580px);
}

.contact-helper {
  margin-top: -18px;
}

.summary-grid {
  margin-top: 26px;
}

/* ============================================================
   FLUTTER EQUIPMENT CATALOG GRID
   ============================================================ */

.content.is-equipment {
  width: min(100%, 920px);
}

/* Flutter WebViews are more reliable when the long equipment screen owns its
   scroll container instead of delegating scrolling to the document viewport. */
body.equipment-step-active {
  height: var(--survey-vh, 100dvh);
  overflow-y: hidden;
}

body.equipment-step-active .survey-app,
body.equipment-step-active .screen {
  height: var(--survey-vh, 100dvh);
  min-height: 0;
}

body.equipment-step-active .screen {
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  scroll-padding-bottom: calc(112px + env(safe-area-inset-bottom));
  touch-action: pan-y;
}

body.equipment-step-active .content.is-equipment {
  padding-bottom: calc(112px + env(safe-area-inset-bottom));
}

.equipment-block {
  gap: 20px;
}

.equipment-heading .subtitle {
  margin-top: 10px;
}

.equipment-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.equipment-choice {
  position: relative;
  display: grid;
  grid-template-rows: minmax(74px, 1fr) auto;
  align-items: center;
  justify-items: center;
  min-width: 0;
  min-height: 140px;
  padding: 12px 10px 14px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: linear-gradient(180deg, rgba(21, 57, 110, 0.82), rgba(8, 24, 47, 0.94));
  color: var(--text);
  cursor: pointer;
  clip-path: polygon(
    0 0,
    calc(100% - var(--fat-loss-bevel)) 0,
    100% var(--fat-loss-bevel),
    100% 100%,
    0 100%
  );
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.28));
  transition:
    transform 180ms var(--perform-ease),
    border-color 180ms var(--perform-ease),
    background 180ms var(--perform-ease);
}

.equipment-choice::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(135deg, rgba(31, 124, 232, 0.24), transparent 52%);
  opacity: 0;
  transition: opacity 180ms var(--perform-ease);
}

.equipment-choice.is-selected {
  border-color: var(--perform-blue-300);
  background: linear-gradient(180deg, rgba(31, 124, 232, 0.28), rgba(8, 24, 47, 0.96));
}

.equipment-choice.is-selected::before {
  opacity: 1;
}

@media (hover: hover) {
  .equipment-choice:hover {
    transform: translateY(-2px);
    border-color: rgba(94, 163, 242, 0.72);
  }
}

.equipment-choice:focus-visible {
  outline: 3px solid var(--gold-glow);
  outline-offset: 3px;
}

.equipment-choice__visual {
  display: grid;
  place-items: center;
  width: 100%;
  height: 82px;
}

.equipment-choice__visual img {
  display: block;
  width: min(100%, 84px);
  height: 76px;
  object-fit: contain;
  filter: drop-shadow(0 8px 8px rgba(0, 0, 0, 0.28));
  user-select: none;
  -webkit-user-drag: none;
}

.equipment-choice__none {
  position: relative;
  width: 58px;
  height: 58px;
  border: 2px solid var(--perform-mist);
  border-radius: 50%;
  opacity: 0.82;
}

.equipment-choice__none::after {
  content: "";
  position: absolute;
  left: 7px;
  right: 7px;
  top: 50%;
  height: 3px;
  background: var(--perform-blue-300);
  transform: rotate(-35deg);
  transform-origin: center;
}

.equipment-choice__label {
  align-self: end;
  max-width: 100%;
  color: var(--text);
  font-size: 0.75rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

html[dir="rtl"] .equipment-choice__label {
  letter-spacing: 0;
}

.equipment-choice__check {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 2px solid rgba(255, 255, 255, 0.24);
  background: rgba(7, 22, 46, 0.84);
  transform: skewX(var(--perform-skew));
}

html[dir="rtl"] .equipment-choice__check {
  right: auto;
  left: 8px;
}

.equipment-choice.is-selected .equipment-choice__check {
  border-color: var(--perform-blue-300);
  background: var(--perform-blue);
}

.equipment-choice.is-selected .equipment-choice__check::after {
  content: "";
  width: 7px;
  height: 4px;
  border-left: 2px solid #ffffff;
  border-bottom: 2px solid #ffffff;
  transform: skewX(22deg) rotate(-45deg) translateY(-1px);
}

.plan-note {
  max-width: 620px;
  margin: 22px auto 0;
  padding: 16px 18px;
  border-inline-start: 4px solid var(--perform-blue);
  background: rgba(31, 124, 232, 0.08);
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

.sticky-footer {
  transition: transform 180ms var(--perform-ease), opacity 180ms var(--perform-ease);
}

body.keyboard-open .sticky-footer {
  opacity: 0;
  pointer-events: none;
  transform: translateY(120%);
}

body.embedded-mobile .topbar {
  padding-top: calc(6px + env(safe-area-inset-top));
}

body.embedded-mobile .content {
  padding-bottom: calc(82px + env(safe-area-inset-bottom));
}

@media (max-width: 620px) {
  .topbar {
    min-height: calc(56px + env(safe-area-inset-top));
    padding-top: calc(6px + env(safe-area-inset-top));
  }

  .content {
    padding-inline: 14px;
    padding-bottom: calc(80px + env(safe-area-inset-bottom));
  }

  .choice {
    min-height: 50px;
  }

  .gender-toggle {
    min-height: 60px;
  }

  .unit-button,
  .target-toggle {
    min-height: 44px;
  }

  .text-field input {
    min-height: 52px;
    font-size: 16px;
  }

  .equipment-block {
    gap: 10px;
  }

  .equipment-heading .title {
    font-size: clamp(1.2rem, 5vw, 1.5rem);
  }

  .equipment-heading .subtitle {
    margin-top: 5px;
    font-size: 0.78rem;
  }

  .equipment-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .equipment-choice {
    grid-template-rows: 54px auto;
    min-height: 96px;
    padding: 7px 5px 9px;
  }

  .equipment-choice__visual {
    height: 54px;
  }

  .equipment-choice__visual img {
    width: min(100%, 58px);
    height: 52px;
  }

  .equipment-choice__none {
    width: 42px;
    height: 42px;
  }

  .equipment-choice__label {
    font-size: 0.61rem;
    line-height: 1.15;
    letter-spacing: 0.04em;
  }

  .equipment-choice__check {
    top: 5px;
    right: 5px;
    width: 17px;
    height: 17px;
    border-width: 1.5px;
  }

  html[dir="rtl"] .equipment-choice__check {
    right: auto;
    left: 5px;
  }

  .contact-fields {
    gap: 12px;
  }

  .contact-helper {
    margin-top: -6px;
  }

  .summary-grid {
    margin-top: 14px;
  }
}

@media (max-width: 340px) {
  .equipment-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  .content.is-equipment {
    padding-top: 8px;
  }

  .equipment-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .equipment-choice {
    grid-template-rows: 46px auto;
    min-height: 82px;
  }

  .equipment-choice__visual,
  .equipment-choice__visual img {
    height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .equipment-choice,
  .sticky-footer {
    transition: none;
  }
}
