/* ── Flavor DNA Mobile Fixes (3 bugs — 2026-06-22) ── */

/* Bug 2 fix: preview card text clipping on 375px mobile.
   Clamp max-width to viewport + add overflow guard so text wraps safely. */
@media (max-width: 480px) {
  .dna-preview-outer {
    max-width: min(680px, calc(100vw - 1.5rem)) !important;
    padding: 1rem !important;
    margin: 1.5rem auto !important;
    overflow: hidden !important;
    box-sizing: border-box;
  }
  .dna-preview-card {
    padding: 1.5rem 1rem !important;
    overflow: hidden !important;
    width: 100%;
    box-sizing: border-box;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    /* CRITICAL: flex children must be min-width:0 to shrink below min-content */
    min-width: 0 !important;
  }
  .dna-preview-card > div {
    /* Every flex child must allow shrinking */
    min-width: 0 !important;
    max-width: 100% !important;
    overflow-wrap: break-word !important;
    word-break: break-word !important;
  }
  .dna-preview-card > div:first-child {
    overflow: hidden;
    min-width: 0;
    flex-shrink: 1;
  }
  .dna-preview-card > div:first-child svg {
    max-width: 100% !important;
    height: auto !important;
  }
  .dna-preview-card > div:nth-child(2) {
    /* Title text — clamp size, allow wrapping */
    font-size: clamp(1.1rem, 4vw, 1.5rem) !important;
    line-height: 1.25 !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    max-width: 100% !important;
    min-width: 0 !important;
    text-align: center !important;
  }
  .dna-preview-card > div:nth-child(3) {
    /* Subtitle — key fix for truncation */
    font-size: clamp(0.75rem, 2.8vw, 0.88rem) !important;
    line-height: 1.5 !important;
    max-width: 100% !important;
    min-width: 0 !important;
    overflow-wrap: break-word !important;
    word-break: break-word !important;
    text-align: center !important;
    padding: 0 0.25rem !important;
  }
  .dna-preview-card > div:nth-child(4) {
    /* Axis labels — clamp and wrap */
    font-size: clamp(0.68rem, 2.5vw, 0.78rem) !important;
    line-height: 1.4 !important;
    max-width: 100% !important;
    min-width: 0 !important;
    overflow-wrap: break-word !important;
    flex-wrap: wrap !important;
  }
  .dna-preview-card > div:nth-child(5) {
    /* CTA button row */
    overflow: hidden !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
    min-width: 0 !important;
  }
}

/* Bug 3 fix: prevent any floating elements (HTML5 video native controls ···
   and 🔇) from overflowing the flavor DNA page.
   Contain all containers with overflow:hidden + position:relative. */
#fdna-container {
  overflow: hidden !important;
  max-width: 100vw !important;
  position: relative;
}

.fdna-root {
  overflow: hidden;
  max-width: 100vw;
  position: relative;
}

/* Guard share modal canvas wrapper */
.canvas-preview-wrap {
  overflow: hidden;
  max-width: 100%;
  position: relative;
  z-index: 1;
}

/* Guard share modal itself */
.share-modal-overlay {
  overflow: hidden;
  position: relative;
  z-index: 1000;
}

/* Hide any stray video elements that may be injected by JS
   inside the Flavor DNA page (e.g. from canvas/card generation). */
#fdna-container video,
.fdna-root video,
.dna-preview-outer video {
  position: absolute !important;
  top: -9999px !important;
  left: -9999px !important;
  width: 1px !important;
  height: 1px !important;
  pointer-events: none !important;
  opacity: 0 !important;
}

/* Also contain video elements site-wide within flavor DNA section */
#fdna-container video,
.fdna-root video {
  contain: strict;
}
/* These styles enhance flavor-dna.css for mobile-first layout */

/* Ensure bottom nav spacing */
body.fdna-body {
  padding-bottom: calc(80px + env(safe-area-inset-bottom));
}

/* Mobile radar: constrain to viewport width */
@media (max-width: 500px) {
  .fdna-radar-section {
    padding: 0;
  }

  .fdna-radar-wrap {
    max-width: min(420px, 92vw);
  }

  #fdna-radar-svg {
    max-width: min(380px, 88vw);
  }

  .fdna-radar-legend {
    grid-template-columns: repeat(2, 1fr);
    gap: 4px 8px;
    max-width: 100%;
    padding: 0 0.5rem;
  }

  .fdna-legend-item {
    font-size: 10px;
    gap: 4px;
  }

  .fdna-legend-dot { width: 6px; height: 6px; }
  .fdna-legend-score { min-width: 18px; }

  .fdna-root {
    padding: 16px 12px 80px;
    gap: 36px;
  }

  .fdna-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .fdna-header-label { font-size: 1.6rem; }

  .fdna-arch-content {
    flex-direction: column;
    gap: 14px;
  }

  .fdna-arch-icon { width: 48px; height: 48px; }
  .fdna-arch-name { font-size: 1.4rem; }

  .fdna-arch-secondaries {
    flex-wrap: wrap;
    gap: 8px;
  }

  .fdna-arch-secondary {
    padding: 6px 10px;
    font-size: 11px;
  }

  .fdna-affinity-row {
    grid-template-columns: 90px 1fr 32px;
    gap: 8px;
  }

  .fdna-affinity-label { font-size: 11px; }

  .fdna-evolution-chart {
    padding: 16px 12px 10px;
  }

  .fdna-evolution-labels {
    font-size: 9px;
  }

  .fdna-community-card {
    padding: 12px;
  }

  .fdna-community-card-label { font-size: 11px; }

  .fdna-community-bar-row span:first-child {
    font-size: 10px;
    min-width: 36px;
  }

  .fdna-empty {
    padding: 3rem 2rem;
  }

  .fdna-empty h2 { font-size: 1.4rem; }
  .fdna-empty p { font-size: 0.85rem; }
}

/* Loading spinner */
.fdna-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 40vh;
}

.fdna-spinner {
  width: 36px;
  height: 36px;
  border: 2px solid rgba(201,169,110,0.2);
  border-top-color: #c9a96e;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.fdna-error {
  text-align: center;
  padding: 3rem 1.5rem;
  color: rgba(201,169,110,0.6);
  font-size: 0.9rem;
}

.fdna-empty-section {
  text-align: center;
  color: rgba(242,234,216,0.35);
  font-size: 0.82rem;
  padding: 1rem;
}

/* Archetype glow animation */
.fdna-arch-glow {
  animation: archPulse 4s ease-in-out infinite;
}
@keyframes archPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Mobile-specific flavor DNA bottom sticky bar */
@media (max-width: 500px) {
  .fdna-root .fdna-radar-wrap::after {
    content: '';
    display: block;
    height: env(safe-area-inset-bottom);
  }
}