/* =============================================================
   v31 Mobile Plan Sheet — Option C styles
   Pinned-bottom sheet on mobile (≤767px). Two snap points: peek (40vh
   from bottom) and full (close to top). Horizontal carousel inside.
   Hidden on desktop+tablet.
   ============================================================= */

/* Base — desktop+tablet do nothing. */
.mps-sheet { display: none; }

@media (max-width: 767px) {

  .mps-sheet {
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 47; /* under .nx-tabs (49) so bottom tab nav stays tappable */
    background: var(--cream, #FFFAEA);
    border-top: 1px solid var(--rule, #E1E6EC);
    border-top-left-radius: 22px;
    border-top-right-radius: 22px;
    box-shadow: 0 -8px 24px rgba(14, 42, 58, 0.10);
    padding: 8px 0 0;
    /* Default: closed. Translate fully out of view. */
    transform: translateY(100%);
    transition: transform 280ms cubic-bezier(.22,.61,.36,1);
    /* Account for the bottom-fixed .nx-tabs (~52px + safe-area) */
    padding-bottom: calc(64px + env(safe-area-inset-bottom));
    max-height: calc(100vh - 60px);
    max-height: calc(100svh - 60px);
  }

  /* Snap points */
  .mps-sheet.is-peek {
    transform: translateY(0);
    height: 56vh;
  }
  .mps-sheet.is-full {
    transform: translateY(0);
    height: calc(100vh - 60px);
    height: calc(100svh - 60px);
  }
  .mps-sheet.is-closed {
    transform: translateY(100%);
  }

  /* Drag handle */
  .mps-handle {
    width: 40px;
    height: 5px;
    background: var(--rule, #E1E6EC);
    border-radius: 3px;
    margin: 6px auto 4px;
    cursor: pointer;
    flex-shrink: 0;
  }

  /* Header: chevrons + dots + pager label */
  .mps-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 14px 8px;
    gap: 10px;
    flex-shrink: 0;
  }
  .mps-chev {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 50%;
    background: white;
    border: 1px solid var(--rule, #E1E6EC);
    color: var(--mute, #4A6678);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
  }
  .mps-chev:hover,
  .mps-chev:focus-visible {
    background: var(--lemon, #FFD84D);
    border-color: var(--ink, #0E2A3A);
    color: var(--ink, #0E2A3A);
    outline: none;
  }
  .mps-chev:disabled {
    opacity: 0.35;
    cursor: not-allowed;
  }
  .mps-chev:active {
    transform: scale(0.94);
    transition: transform 80ms;
  }
  .mps-dots {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1 1 auto;
    justify-content: center;
  }
  .mps-dot {
    width: 8px;
    height: 8px;
    background: var(--rule, #E1E6EC);
    border: 0;
    border-radius: 50%;
    padding: 0;
    cursor: pointer;
    transition: width 200ms cubic-bezier(.22,.61,.36,1), background 200ms;
    -webkit-tap-highlight-color: transparent;
  }
  .mps-dot.is-active {
    background: var(--ink, #0E2A3A);
    width: 24px;
    border-radius: 4px;
  }
  .mps-pager-label {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 11px;
    letter-spacing: .04em;
    color: var(--mute, #4A6678);
    font-weight: 700;
    min-width: 40px;
    text-align: right;
  }

  /* Carousel track — horizontal scroll-snap */
  .mps-track {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding: 0 14px 8px;
    flex: 1 1 auto;
    min-height: 0;
    scrollbar-width: none;
  }
  .mps-track::-webkit-scrollbar { display: none; }
  .mps-card {
    flex: 0 0 calc(100% - 12px);
    scroll-snap-align: start;
    background: white;
    border: 1.5px solid var(--ink, #0E2A3A);
    border-radius: 14px;
    box-shadow: 3px 3px 0 var(--ink, #0E2A3A);
    padding: 14px 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .mps-card--recommended {
    background: linear-gradient(180deg, rgba(255, 216, 77, 0.18) 0%, white 60%);
  }
  .mps-card-tier {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 10px;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--mute, #4A6678);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
  }
  .mps-card--recommended .mps-card-tier {
    color: var(--ink, #0E2A3A);
  }
  .mps-badge-fi {
    display: inline-block;
    background: var(--lemon, #FFD84D);
    color: var(--ink, #0E2A3A);
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 8px;
    letter-spacing: .08em;
    padding: 2px 6px;
    border-radius: 3px;
    text-transform: uppercase;
    font-weight: 700;
  }
  .mps-card-price {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.05;
    color: var(--ink, #0E2A3A);
  }
  .mps-card-price small {
    font-size: 12px;
    font-weight: 500;
    color: var(--mute, #4A6678);
  }
  .mps-card-carrier {
    font-size: 13px;
    font-weight: 600;
    color: var(--ink, #0E2A3A);
  }
  .mps-card-name {
    font-size: 12px;
    color: var(--mute, #4A6678);
    line-height: 1.3;
    margin-bottom: 4px;
  }
  .mps-card-facts {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
    margin-top: 6px;
    padding-top: 8px;
    border-top: 1px dashed var(--rule, #E1E6EC);
  }
  .mps-fact {
    display: flex;
    flex-direction: column;
    gap: 1px;
    text-align: center;
  }
  .mps-fact-label {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 8.5px;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--mute, #4A6678);
    font-weight: 700;
  }
  .mps-fact-value {
    font-size: 13px;
    font-weight: 700;
    color: var(--ink, #0E2A3A);
  }
  .mps-fact--mute .mps-fact-value {
    color: var(--mute, #4A6678);
  }
  .mps-card-cta {
    margin-top: 12px;
    background: var(--ink, #0E2A3A);
    color: var(--cream, #FFFAEA);
    border: 0;
    border-radius: 10px;
    padding: 12px 14px;
    font-family: 'Inter', system-ui, sans-serif;
    font-weight: 700;
    font-size: 14px;
    min-height: 44px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .mps-card--recommended .mps-card-cta {
    background: var(--lemon, #FFD84D);
    color: var(--ink, #0E2A3A);
    box-shadow: 2px 2px 0 var(--ink, #0E2A3A);
  }
  .mps-card-cta:active {
    transform: scale(0.98);
    transition: transform 80ms;
  }

  .mps-swipe-hint {
    text-align: center;
    font-size: 10px;
    color: var(--mute, #4A6678);
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    letter-spacing: .05em;
    text-transform: uppercase;
    padding: 6px 0 8px;
    opacity: 0.7;
    flex-shrink: 0;
  }

  /* DAV-97 — Compare CTA inside the sheet. Sits just above the bottom-tab
   safe-area so it's always reachable without horizontal swipe. Subtler
   than a primary button but still tappable (≥44px). */
  .mps-compare-cta {
    align-self: center;
    margin: 4px 16px 12px;
    padding: 12px 18px;
    min-height: 44px;
    background: var(--cream, #FFFAEA);
    color: var(--ink, #0E2A3A);
    border: 1.5px solid var(--ink, #0E2A3A);
    border-radius: 999px;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: -.005em;
    cursor: pointer;
    flex-shrink: 0;
  }
  .mps-compare-cta:hover { background: var(--lemon, #FFC857); }
  .mps-compare-cta:focus-visible {
    outline: 3px solid var(--lemon, #FFC857);
    outline-offset: 2px;
  }
  .mps-empty {
    text-align: center;
    color: var(--mute, #4A6678);
    padding: 24px;
    font-size: 13px;
  }

  /* When sheet is mounted, hide the dash zone tab — the sheet is the
     dashboard now. Chat + Report tabs remain. */
  body.has-mobile-sheet .nx-tab[data-tab="dash"] {
    display: none;
  }
  body.has-mobile-sheet .nx-tabs {
    /* Recompute the grid so the 2 remaining tabs fill the width evenly. */
    gap: 6px;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .mps-sheet { transition: none; }
  .mps-card-cta:active,
  .mps-chev:active,
  .mps-dot { transition: none; }
}
