/* =============================================================================
   POLPEXA — breakpoints.

   The base stylesheet is written for 320px. Everything here widens the layout
   as space allows; nothing here is required for the app to be usable.

   Targeted widths: 320 · 360 · 375 · 390 · 414 · 430 · 480 · tablet · desktop.
   ========================================================================== */

/* ---------------------------------------------------- 320px — the floor */

@media (max-width: 359px) {
  .screens { padding-left: 10px; padding-right: 10px; }

  .panel { padding: 13px; }

  /* Three tiles at 320px would be ~95px each; two rows read better. */
  .tile-row { grid-template-columns: repeat(2, 1fr); }
  .tile-row > :last-child { grid-column: 1 / -1; }

  .plan-rate { font-size: 34px; }
  .plan-specs { grid-template-columns: 1fr; gap: 8px; }

  .tab-label { font-size: 9.5px; }
  .tab-icon { font-size: 15px; }

  .quick-grid { grid-template-columns: 1fr 1fr; }
  .quick-grid > :last-child { grid-column: 1 / -1; }

  .figure-xl { font-size: 27px; }
  .rank-name-lg { font-size: 18px; }

  /* Stacked rather than side-by-side, so nothing is clipped. */
  .tier { flex-wrap: wrap; }
  .tier-right { width: 100%; justify-items: start; text-align: left; }

  /* At 320px the emblem, title and wallet must all still fit on one row. */
  .appbar-logo { width: 40px; height: 40px; flex-basis: 40px; }
  .appbar-wallet { max-width: 36vw; padding: 0 9px; }
  .appbar-title { font-size: 11px; letter-spacing: .08em; }
}

/* ------------------------------------------- 360–413px — common Android */

@media (min-width: 360px) and (max-width: 413px) {
  .plan-rate { font-size: 38px; }
}

/* ---------------------------------------- 414px+ — larger phones (414/430) */

@media (min-width: 414px) {
  .screens { padding-left: 16px; padding-right: 16px; }
  .panel { padding: 17px; }
  .plan-rate { font-size: 44px; }
  .tile .figure-md { font-size: 16px; }
}

/* -------------------------------------------------- 480px+ — phablet */

@media (min-width: 480px) {
  .screens { max-width: 560px; margin: 0 auto; }
  .tabbar { padding-left: 12px; padding-right: 12px; }
  .quick-grid { grid-template-columns: repeat(3, 1fr); }
  .figure-xl { font-size: 42px; }
}

/* ---------------------------------------------------- 700px+ — tablet */

@media (min-width: 700px) {
  .screens { max-width: 720px; }

  /* Three plan cards side by side once there is room for them. */
  .plan-cards { grid-template-columns: repeat(3, 1fr); align-items: start; }
  .plan-specs { grid-template-columns: 1fr; }
  .plan-rate { font-size: 38px; }

  .stack { grid-template-columns: repeat(2, 1fr); }
  .stack-sm { grid-template-columns: repeat(3, 1fr); }
}

/* --------------------------------------------------- 1024px+ — desktop */

@media (min-width: 1024px) {
  :root { --appbar-h: 76px; }

  /* More room on desktop — let the emblem read properly. */
  .appbar-logo { width: 58px; height: 58px; flex-basis: 58px; }
  .appbar-title { font-size: 14px; }

  .screens {
    max-width: 1080px;
    /* The bar becomes a floating pill below, so the reserve must still clear
       it: pill height (~65px) + its 18px offset + breathing room. */
    padding-bottom: 116px;
  }

  .appbar { padding-left: 24px; padding-right: 24px; }
  .appbar-title { text-align: left; margin-left: 6px; }

  /* On a desktop pointer the bottom bar becomes a centred pill. */
  .tabbar {
    left: 50%;
    right: auto;
    bottom: 18px;
    transform: translateX(-50%);
    width: auto;
    grid-template-columns: repeat(5, minmax(88px, 1fr));
    gap: 4px;
    padding: 7px;
    border: 1px solid var(--edge);
    border-radius: 999px;
    box-shadow: var(--shadow-lg);
  }

  .tab { min-height: 46px; }
  .tab-label { font-size: 11px; }

  .toast-wrap { bottom: 96px; }

  .plan-rate { font-size: 46px; }
  .plan-specs { grid-template-columns: 1fr 1fr; }

  .tile-row { gap: 12px; }
  .stack { grid-template-columns: repeat(2, 1fr); }

  .sheet-backdrop { align-items: center; }
  .sheet { margin: 0; border-radius: var(--radius-lg); max-height: 82dvh; }
}

/* ------------------------------------------------- coarse pointers */

@media (pointer: coarse) {
  /* Hover lifts are meaningless on touch and cause sticky states. */
  .btn:hover:not(:disabled),
  .plan-card:hover { transform: none; }

  /* Touch floors, not ceilings — never below 44px on a coarse pointer.
     Chips and calculator tabs are deliberately compact for a mouse, but a
     thumb needs the full target, so they are raised here too. */
  .btn { min-height: 46px; }
  .btn-lg { min-height: 52px; }
  .btn-chip { min-height: 44px; }
  .icon-btn { min-width: 44px; min-height: 44px; }
  .link-btn { min-height: 44px; }
  .tab-btn { min-height: 44px; }
  .appbar-wallet { min-height: 44px; }
  .wallet-option { min-height: 58px; }
}

/* ------------------------------------------------------- short screens */

@media (max-height: 640px) {
  .sheet { max-height: 92dvh; }
  .rank-medal-lg { width: 48px; height: 48px; flex-basis: 48px; font-size: 24px; }
}

/* ------------------------------------------------------------ printing */

@media print {
  .appbar, .tabbar, .scene, .toast-wrap, .sheet-backdrop { display: none !important; }
  .screens { padding: 0; max-width: none; }
  .screen { display: block !important; }
  body { background: #fff; color: #000; }
}
