/* ХЭНГРИ UX — прод-патч: OTP, корзина-коробка, тонкие бордеры на моб */

:root {
  --hx-pink: #ff2d6a;
  --hx-pink-glow: rgba(255, 45, 106, 0.45);
  --hx-cell: 56px;
}

/* ========== Mobile thinner borders ========== */
@media (max-width: 720px) {
  .menu-grid .product-card,
  .product-card {
    border-width: 1px !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
    box-shadow: none !important;
  }

  .btn-cart,
  .price,
  .pick-btn,
  .btn-ghost,
  .nav-toggle,
  .cat-btn,
  .cart-line,
  .field input,
  .modal-card,
  .product-modal-card {
    border-width: 1px !important;
  }

  .price {
    border-color: rgba(255, 29, 142, 0.28) !important;
  }

  .pick-btn {
    border-color: rgba(255, 29, 142, 0.35) !important;
  }

  .menu-grid .product-image__media,
  .product-card .product-image__media {
    box-shadow:
      0 0 0 1px rgba(255, 255, 255, 0.14),
      0 6px 16px rgba(255, 29, 142, 0.22) !important;
  }
}

/* ========== Constructor: compact stack, no UI over image ========== */
#product-modal .product-modal-card {
  max-height: min(86dvh, 680px) !important;
  overflow: hidden !important;
}

#product-modal .product-modal-grid {
  display: grid !important;
  grid-template-columns: 148px 1fr !important;
  min-height: 0 !important;
  overflow: hidden !important;
  align-items: stretch !important;
  isolation: isolate !important;
}

#product-modal .product-modal-image {
  grid-column: 1 !important;
  grid-row: 1 !important;
  min-height: 0 !important;
  max-height: none !important;
  height: auto !important;
  overflow: hidden !important;
  padding: 10px 6px 8px !important;
  justify-content: center !important;
  align-items: center !important;
  position: relative !important;
  z-index: 1 !important;
}

#product-modal .product-modal-info {
  grid-column: 2 !important;
  grid-row: 1 !important;
  position: relative !important;
  z-index: 2 !important;
  min-height: 0 !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  background: #fff !important;
  /* Keep sticky CTA inside the right column only */
  contain: layout paint !important;
}

/* Sticky CTA must never paint over the burger column */
#product-modal .product-modal-info .btn-primary,
#product-modal #pm-add {
  position: sticky !important;
  bottom: 0 !important;
  left: auto !important;
  right: auto !important;
  width: 100% !important;
  max-width: 100% !important;
  margin-top: auto !important;
  z-index: 3 !important;
  background: linear-gradient(90deg, #ff1d8e, #ff4da6) !important;
  box-shadow: 0 -8px 16px #fff !important;
}

#product-modal .pm-burger-stack {
  width: min(128px, 100%) !important;
  min-height: 0 !important;
  max-height: 100% !important;
  overflow: hidden !important;
  transform-origin: center center !important;
  justify-content: flex-start !important;
  gap: 0 !important;
}

/* Compact stack — toppings readable, no explode */
#product-modal .pm-burger-stack .pm-layer {
  margin-bottom: 0 !important;
  flex-shrink: 0 !important;
}

#product-modal .pm-burger-stack .pm-layer:not(:first-child) {
  margin-top: -58% !important;
}

#product-modal .pm-burger-stack .pm-layer--cheddar {
  width: 68% !important;
  transform: scaleY(0.78) !important;
}

#product-modal .pm-burger-stack .pm-layer--cheddar:not(:first-child) {
  margin-top: -48% !important;
}

#product-modal .pm-burger-stack .pm-layer[data-id="sesame"]:not(:first-child),
#product-modal .pm-burger-stack .pm-layer[data-id="mayo-top"]:not(:first-child),
#product-modal .pm-burger-stack .pm-layer[data-id="mayo-bottom"]:not(:first-child),
#product-modal .pm-burger-stack .pm-layer[data-id="teriyaki"]:not(:first-child),
#product-modal .pm-burger-stack .pm-layer[data-id="truffle"]:not(:first-child) {
  margin-top: -54% !important;
}

#product-modal .pm-burger-stack .pm-layer[data-id="onion"]:not(:first-child),
#product-modal .pm-burger-stack .pm-layer[data-id="jalapeno"]:not(:first-child),
#product-modal .pm-burger-stack .pm-layer[data-id="pickles"]:not(:first-child),
#product-modal .pm-burger-stack .pm-layer[data-id="cherry"]:not(:first-child),
#product-modal .pm-burger-stack .pm-layer[data-id="iceberg"]:not(:first-child),
#product-modal .pm-burger-stack .pm-layer[data-id="bacon"]:not(:first-child) {
  margin-top: -56% !important;
}

#product-modal .pm-image-hint {
  display: none !important;
}

@media (max-width: 980px) {
  #product-modal.modal {
    align-items: flex-end !important;
  }

  #product-modal .product-modal-card {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 92dvh !important;
    border-radius: 16px 16px 0 0 !important;
  }

  #product-modal .product-modal-grid {
    grid-template-columns: 1fr !important;
    grid-template-rows: minmax(200px, 38vh) minmax(0, 1fr) !important;
  }

  #product-modal .product-modal-image {
    grid-column: 1 !important;
    grid-row: 1 !important;
    min-height: 200px !important;
    max-height: 38vh !important;
    height: auto !important;
    overflow: hidden !important;
    flex-direction: column !important;
    justify-content: center !important;
  }

  #product-modal .product-modal-info {
    grid-column: 1 !important;
    grid-row: 2 !important;
  }

  #product-modal .pm-burger-stack {
    width: min(210px, 72vw) !important;
    overflow: hidden !important;
  }

  #product-modal .pm-burger-stack .pm-layer:not(:first-child) {
    margin-top: -52% !important;
  }

  #product-modal .pm-burger-stack .pm-layer--cheddar:not(:first-child) {
    margin-top: -44% !important;
  }

  #product-modal .pm-burger-stack .pm-layer[data-id="sesame"]:not(:first-child),
  #product-modal .pm-burger-stack .pm-layer[data-id="mayo-top"]:not(:first-child),
  #product-modal .pm-burger-stack .pm-layer[data-id="mayo-bottom"]:not(:first-child),
  #product-modal .pm-burger-stack .pm-layer[data-id="teriyaki"]:not(:first-child),
  #product-modal .pm-burger-stack .pm-layer[data-id="truffle"]:not(:first-child) {
    margin-top: -48% !important;
  }

  #product-modal .product-modal-info {
    padding-bottom: calc(12px + env(safe-area-inset-bottom)) !important;
  }
}

/* ========== Floating cart → box ========== */
#floating-cart.hx-box-cart {
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 112px;
  right: 10px;
  bottom: 10px;
}

#floating-cart.hx-box-cart:hover {
  transform: none;
}

#floating-cart.hx-box-cart .fc-icon {
  display: none;
}

#floating-cart.hx-box-cart .fc-meta {
  align-items: center;
  order: 2;
}

#floating-cart.hx-box-cart .fc-meta strong {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 3;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--hx-pink);
  color: #fff;
  font-size: 12px;
  display: grid;
  place-items: center;
  box-shadow: 0 0 0 2px #05060a;
}

#floating-cart.hx-box-cart .fc-meta small {
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  opacity: 1;
  margin-top: 0;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.8);
}

.hx-box-scene {
  position: relative;
  width: 108px;
  height: 100px;
  order: 1;
}

.hx-box-scene img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  filter: saturate(1.05) contrast(1.02) brightness(1.02);
  transition: opacity 0.18s ease, transform 0.25s ease;
}

.hx-box-scene .hx-box-open {
  opacity: 0;
}

#floating-cart[data-hx-state="open"] .hx-box-closed,
#floating-cart[data-hx-state="catch"] .hx-box-closed {
  opacity: 0;
}

#floating-cart[data-hx-state="open"] .hx-box-open,
#floating-cart[data-hx-state="catch"] .hx-box-open {
  opacity: 1;
}

#floating-cart[data-hx-state="open"] .hx-box-open {
  animation: hxLidKick 0.35s cubic-bezier(0.2, 1.4, 0.3, 1);
}

#floating-cart[data-hx-state="catch"] .hx-box-open {
  animation: hxBoxCatch 0.4s ease-in-out;
}

#floating-cart[data-hx-state="slam"] .hx-box-closed {
  animation: hxLidSlam 0.35s cubic-bezier(0.2, 1.5, 0.3, 1);
}

.hx-box-catch {
  position: absolute;
  left: 50%;
  top: 42%;
  width: 8px;
  height: 8px;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.hx-flyer {
  position: fixed;
  z-index: 200;
  width: 48px;
  height: 48px;
  margin: -24px 0 0 -24px;
  border-radius: 12px;
  object-fit: cover;
  pointer-events: none;
  opacity: 0;
  transition: left 0.7s cubic-bezier(0.2, 0.8, 0.2, 1), top 0.7s cubic-bezier(0.2, 0.8, 0.2, 1),
    transform 0.3s ease, opacity 0.2s ease;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}

.hx-flyer.is-fly {
  opacity: 1;
  transform: scale(0.85) rotate(-8deg);
}

.hx-flyer.is-suck {
  transform: scale(0.2);
  opacity: 0;
}

@keyframes hxLidKick {
  0% { transform: rotate(-5deg) scale(0.96); }
  60% { transform: rotate(3deg) scale(1.04); }
  100% { transform: rotate(0) scale(1); }
}

@keyframes hxBoxCatch {
  0%, 100% { transform: translateY(0) rotate(0); }
  30% { transform: translateY(3px) rotate(-2deg); }
  60% { transform: translateY(-2px) rotate(2deg); }
}

@keyframes hxLidSlam {
  0% { transform: scale(1.08) rotate(3deg); filter: brightness(1.2) saturate(1.05); }
  60% { transform: scale(0.96) rotate(-2deg); }
  100% { transform: scale(1) rotate(0); filter: saturate(1.05) contrast(1.02) brightness(1.02); }
}

@media (max-width: 720px) {
  #floating-cart.hx-box-cart {
    width: 96px;
    right: 8px;
    bottom: 8px;
  }
  .hx-box-scene {
    width: 92px;
    height: 86px;
  }
}

/* ========== Auth OTP (horizontal L→R) ========== */
#auth-step-code.hx-otp-ready .field:has(#auth-code),
#auth-step-code.hx-otp-ready label.field {
  /* hide single input field; keep input in DOM for app.js */
}

#auth-step-code.hx-otp-ready #auth-code {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  pointer-events: none !important;
  left: -9999px;
}

#auth-step-code.hx-otp-ready label.field span {
  display: none;
}

.hx-otp-row {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin: 18px 0 16px;
  direction: ltr;
}

.hx-otp-cell {
  flex: 0 0 var(--hx-cell);
  width: var(--hx-cell);
  height: var(--hx-cell);
  border-radius: 14px;
  border: 1.5px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  font-family: "Oswald", "Montserrat", sans-serif;
  font-size: 1.45rem;
  font-weight: 700;
  text-align: center;
  outline: none;
  caret-color: var(--hx-pink);
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s, background 0.2s;
}

.hx-otp-cell:focus {
  border-color: var(--hx-pink);
  box-shadow: 0 0 0 3px rgba(255, 45, 106, 0.25), 0 0 18px var(--hx-pink-glow);
  background: rgba(255, 45, 106, 0.08);
  transform: scale(1.05);
}

.hx-otp-cell.filled {
  border-color: rgba(255, 45, 106, 0.7);
  background: rgba(255, 45, 106, 0.1);
}

.hx-otp-cell.error {
  border-color: #ff4d4d;
  animation: hxShake 0.4s ease;
}

.hx-otp-row.is-verifying .hx-otp-cell {
  border-color: var(--hx-pink);
  box-shadow: 0 0 0 3px rgba(255, 45, 106, 0.2);
  animation: hxCellPulse 0.7s ease-in-out infinite;
}

@keyframes hxShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

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

/* Mount success overlay after OTP */
.hx-mount-overlay {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: grid;
  place-items: center;
  background: rgba(5, 6, 10, 0.82);
  backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.hx-mount-overlay.is-on {
  opacity: 1;
  pointer-events: auto;
}

.hx-mount-stage {
  text-align: center;
  padding: 20px;
}

.hx-mount-glow {
  position: absolute;
  width: 240px;
  height: 240px;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 45, 106, 0.45), transparent 70%);
  filter: blur(8px);
  pointer-events: none;
}

.hx-mount-wrap {
  position: relative;
  width: min(220px, 56vw);
  height: min(220px, 56vw);
  margin: 0 auto 12px;
  display: grid;
  place-items: center;
}

.hx-mount-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 18px 30px rgba(0, 0, 0, 0.5));
  transform-origin: center;
}

.hx-mount-overlay.is-spinning .hx-mount-wrap img {
  animation: hxMountSpin 0.85s cubic-bezier(0.22, 1, 0.36, 1) 1;
}

.hx-mount-title {
  margin: 8px 0 0;
  font-size: 1.5rem;
  font-weight: 900;
  color: #fff;
  opacity: 0;
  transform: translateY(8px);
}

.hx-mount-overlay.is-done .hx-mount-title {
  animation: hxFadeUp 0.4s ease forwards;
}

@keyframes hxMountSpin {
  0% { transform: rotate(0) scale(1); }
  40% { transform: rotate(220deg) scale(1.12); }
  70% { transform: rotate(340deg) scale(1.04); }
  100% { transform: rotate(360deg) scale(1); }
}

@keyframes hxFadeUp {
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 380px) {
  :root { --hx-cell: 48px; }
  .hx-otp-cell { font-size: 1.25rem; border-radius: 12px; }
}
