/* GlassPortal mobile layer, 2026-10-08.
 * Loaded last by the customer, staff and sign in layouts (layouts/partials/mobile-head).
 * Every rule sits inside a max-width media query, so the desktop layout does not change.
 * Molten Obsidian tokens only. Phones 360 to 430 px, tablets up to 1024 px. */

/* ---------- Tablet and below: customer top nav collapses into the Menu button ---------- */
@media (max-width: 1024px) {
  .gb-header .header-inner {
    flex-wrap: wrap; height: auto; min-height: var(--nav-h, 64px); gap: 0.25rem 0.75rem;
    padding: max(0.35rem, env(safe-area-inset-top)) 1rem 0.35rem;
  }
  .gb-header .nav-toggle-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
    margin-left: auto; min-height: 44px; min-width: 44px; padding: 0 0.9rem;
    border-radius: var(--radius-xs, 8px); border: 1px solid var(--glass-stroke-molten, rgba(255,106,26,.35));
    background: var(--glass-fill, rgba(11,17,24,.6)); color: var(--text-primary, #F8FAFC);
    font-size: var(--fs-sm, .875rem); font-weight: 600; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .gb-header .nav-toggle-btn::before {
    content: ""; width: 16px; height: 12px; flex-shrink: 0;
    background:
      linear-gradient(currentColor, currentColor) 0 0 / 100% 2px no-repeat,
      linear-gradient(currentColor, currentColor) 0 50% / 100% 2px no-repeat,
      linear-gradient(currentColor, currentColor) 0 100% / 100% 2px no-repeat;
  }
  .gb-header .nav-toggle:focus-visible + .nav-toggle-btn { outline: 2px solid var(--molten-orange, #FF6A1A); outline-offset: 2px; }
  .gb-header .nav-toggle:checked + .nav-toggle-btn { background: rgba(255,106,26,.14); }
  .gb-header .header-user, .gb-header nav.top-nav { display: none; width: 100%; margin-left: 0; flex: none; }
  .gb-header .nav-toggle:checked ~ nav.top-nav { display: grid; }
  .gb-header .nav-toggle:checked ~ .header-user { display: flex; }
  .gb-header nav.top-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.25rem;
    padding: 0.35rem 0 0.5rem; border-top: 1px solid var(--glass-stroke-soft, rgba(248,250,252,.08));
    max-height: calc(100vh - 9rem); max-height: calc(100dvh - 9rem); overflow-y: auto; overscroll-behavior: contain;
  }
  .gb-header nav.top-nav a {
    min-height: 44px; display: flex; align-items: center; padding: 0.6rem 0.75rem;
    font-size: 0.95rem; overflow-wrap: anywhere;
  }
  .gb-header .header-user {
    flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.25rem 0.75rem;
    padding: 0.35rem 0.25rem 0.75rem; border-top: 1px solid var(--glass-stroke-soft, rgba(248,250,252,.08));
  }
  .gb-header .header-user a, .gb-header .header-user form button {
    min-height: 44px; display: inline-flex; align-items: center; padding: 0 0.35rem;
  }
  .gb-header .header-user span { overflow-wrap: anywhere; }
  .gp-brand { min-height: 44px; }
}
@media (min-width: 641px) and (max-width: 1024px) {
  .gb-header nav.top-nav { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ---------- Tablet and below: shared fixes for customer and staff pages ---------- */
@media (max-width: 1024px) {
  .page-wrap, .page-content { overflow-wrap: break-word; }
  .page-wrap img, .page-content img, .page-wrap video, .page-content video, .page-wrap iframe, .page-content iframe { max-width: 100%; height: auto; }
  .page-wrap pre, .page-content pre { overflow-x: auto; max-width: 100%; }
  /* Grid children may shrink, so one wide table can never push the page sideways. */
  .grid > *, .tk-grid > *, [class*="-grid"] > *, .gb-deploy-panel > * { min-width: 0; }
  body .tk-grid { grid-template-columns: minmax(0, 1fr); }
  .gb-card:has(thead), .card:has(thead), .tk-card:has(thead) { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* ---------- Phones and small tablets ---------- */
@media (max-width: 760px) {
  body.gp-staff { overflow-x: clip; }

  /* Text sizes: nothing important under 12 px. */
  .badge, .tk-tag, .gb-chip, th, .card-title, .gb-stat-label,
  body .page-content th, body .page-wrap th, body .rm-pill, body .rm-how, body .tk-filters label, .gb-kicker, .gb-honest-note, .gb-cover-chip, .gb-cover-label, .gb-from-price,
  .sidebar-badge, nav.sidebar-nav .nav-section, .sidebar-user .user-role { font-size: 0.75rem; }
  .text-sm { font-size: 0.8125rem; }
  .page-wrap [style*="font-size:.6"], .page-wrap [style*="font-size:0.6"], .page-wrap [style*="font-size:.7"], .page-wrap [style*="font-size:0.7"],
  .page-content [style*="font-size:.6"], .page-content [style*="font-size:0.6"], .page-content [style*="font-size:.7"], .page-content [style*="font-size:0.7"] { font-size: 0.75rem !important; }

  /* Modals and dialogs fit the screen. */
  dialog, .modal, [role="dialog"] { max-width: calc(100vw - 1.5rem); max-height: calc(100dvh - 1.5rem); overflow: auto; }
}


/* ---------- Phones, plus touch tablets up to 1024 px: 44 px tap targets ---------- */
@media (max-width: 760px), (max-width: 1024px) and (pointer: coarse) {
  /* Form fields: 44 px tall, 16 px text so iOS does not zoom in. */
  .page-wrap input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]):not([type="range"]):not([type="color"]),
  .page-content input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]):not([type="range"]):not([type="color"]),
  .page-wrap select, .page-content select, .gp-public main input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]), .gp-public main select {
    min-height: 44px; font-size: 16px !important; max-width: 100%;
  }
  .page-wrap textarea, .page-content textarea, .gp-public main textarea { font-size: 16px !important; max-width: 100%; }
  .page-wrap input[type="file"], .page-content input[type="file"] { min-height: 44px; max-width: 100%; font-size: 0.875rem; }
  .page-wrap button, .page-content button, .page-wrap .btn, .page-content .btn,
  .page-wrap input[type="submit"], .page-content input[type="submit"], .gp-public main button, .gp-public main .btn { min-height: 44px; }

  /* Checkboxes and radios: bigger box and a full height tap row. */
  .page-wrap input[type="checkbox"], .page-content input[type="checkbox"], .page-wrap input[type="radio"], .page-content input[type="radio"],
  .gp-public main input[type="checkbox"], .gp-public main input[type="radio"] {
    width: 22px; height: 22px; flex-shrink: 0; accent-color: var(--molten-orange, #FF6A1A);
  }
  .page-wrap label:has(> input[type="checkbox"]), .page-content label:has(> input[type="checkbox"]),
  .page-wrap label:has(> input[type="radio"]), .page-content label:has(> input[type="radio"]),
  .gp-public main label:has(> input[type="checkbox"]) {
    min-height: 44px; padding-top: 0.3rem; padding-bottom: 0.3rem; align-items: flex-start;
  }
  .page-wrap label:has(> input[type="radio"]), .page-content label:has(> input[type="radio"]) { display: inline-flex; gap: 0.4rem; align-items: center; margin-right: 0.75rem; }

  /* Filter rows built with inline flex: fields get a usable width instead of collapsing. */
  form[style*="display:flex"] > [style*="flex:"] { flex: 1 1 9rem !important; }
  form[style*="display:flex"] > [style*="flex:2"], form[style*="display:flex"] > [style*="flex:3"] { flex-basis: 100% !important; }
  .tk-filters { gap: 0.5rem; }
  .tk-filters label { flex: 1 1 9rem; min-width: 0; }
  .tk-filters select, .tk-filters input { width: 100%; }
  .tk-filters button, .tk-filters .btn { flex: 1 1 100%; }
  .page-content select[style*="width:auto"], .page-wrap select[style*="width:auto"] { width: 100% !important; margin-left: 0 !important; display: block !important; margin-top: 0.35rem; }

  /* Tabs and section links: 44 px tap height. */
  .gb-local-nav a, .subnav a, .gb-meta-strip a, a.gb-chip, a.badge, a.section-link,
  .page-wrap a.text-sm, .page-content a.text-sm,
  .page-wrap a[style*="padding"]:not([style*="display:block"]):not([style*="display:flex"]):not([style*="display:grid"]),
  .page-content a[style*="padding"]:not([style*="display:block"]):not([style*="display:flex"]):not([style*="display:grid"]) {
    min-height: 44px; display: inline-flex; align-items: center;
  }
  .gb-local-nav, .subnav { flex-wrap: wrap; row-gap: 0.25rem; }
  a.tk-row-link { display: block; padding: 0.35rem 0; min-height: 44px; }
  .gp-public main a[href*="forgot-password"] { display: inline-flex; min-height: 44px; align-items: center; }

  /* Staff sidebar footer links. */
  .sidebar-user a { min-height: 44px; display: flex !important; align-items: center; }

  .gp-tabs a, .gb-breadcrumb a, a.alt-link { min-height: 44px; display: inline-flex; align-items: center; }
  a.alt-link { display: flex; justify-content: center; }
  .page-wrap [style*="display:flex"] > a:not([style*="display:block"]):not([style*="display:inline-block"]),
  .page-content [style*="display:flex"] > a:not([style*="display:block"]):not([style*="display:inline-block"]),
  .page-content .alert > a, .page-content form > a { min-height: 44px; display: inline-flex; align-items: center; }
}

/* ---------- Phones: tables become stacked cards (labels added by portal-mobile.js) ---------- */
@media (max-width: 640px) {
  .page-content [style*="display:flex"] > .card[style*="flex:1"] { flex: 1 1 calc(50% - 0.5rem) !important; }
  table.gp-stack, table.gp-stack tbody, table.gp-stack tr, table.gp-stack td { display: block; width: 100% !important; }
  table.gp-stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  table.gp-stack tr { padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--border, rgba(248,250,252,.08)); }
  table.gp-stack tr:last-child { border-bottom: 0; }
  table.gp-stack tr:hover td { background: transparent; }
  table.gp-stack td {
    padding: 0.3rem 0 0.3rem 7.6rem !important;
    border: 0 !important; white-space: normal !important; text-align: left !important;
    overflow-wrap: anywhere; min-width: 0;
  }
  table.gp-stack td::before {
    content: attr(data-label); float: left; width: 7rem; margin-left: -7.6rem;
    color: var(--text-dim, var(--text-muted, #94A3B8));
    font-size: 0.72rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; line-height: 1.5;
    padding-top: 0.1rem; overflow-wrap: anywhere;
  }
  table.gp-stack td::after { content: ""; display: table; clear: both; }
  table.gp-stack td:first-child, table.gp-stack td[data-label=""], table.gp-stack td:not([data-label]) { padding-left: 0 !important; }
  table.gp-stack td:first-child { padding-bottom: 0.4rem !important; font-size: 0.95rem; }
  table.gp-stack td:first-child::before, table.gp-stack td[data-label=""]::before, table.gp-stack td:not([data-label])::before { content: none; display: none; }
  table.gp-stack td:empty { display: none; }
  table.gp-stack td > form, table.gp-stack td .btn, table.gp-stack td button { max-width: 100%; }
  .card:has(table.gp-stack), .gb-card:has(table.gp-stack), .tk-card:has(table.gp-stack) { overflow-x: visible; }
  .card:has(table.gp-stack) td, .gb-card:has(table.gp-stack) td { white-space: normal !important; }
}

@media (max-width: 640px) and (prefers-reduced-motion: no-preference) {
  .gb-header nav.top-nav { animation: gp-menu-in 0.14s ease-out; }
  @keyframes gp-menu-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
}
