/* ──────────────────────────────────────────────────────────────────────────
 * cabinet-responsive.css — mobile/tablet adaptation layer.
 *
 * Loaded LAST (after kit.css, auth.css, pages.css, overrides.css) so its
 * media-query rules win.  Touches the skeleton class names plus the
 * inline-styled blocks used by newer client components (sessions panel,
 * devices QR-modal, trial-device QR layout, onboarding plan picker, etc.)
 * ────────────────────────────────────────────────────────────────────────── */


/* ════════════════ Global safety: prevent horizontal overflow ════════════════ */
html, body { max-width: 100vw; overflow-x: hidden; }
img, svg, video, iframe { max-width: 100%; height: auto; }
.main, .cabinet, .au-page, .rl-main, .ts-main, .ct-main, .tro-main { max-width: 100vw; overflow-x: hidden; }


/* ════════════════ Tablet ≤ 1024px ════════════════ */
@media (max-width: 1024px) {
  /* Hero typography softens */
  .card-obsidian-active h1,
  .card-obsidian h1,
  .hero-short h1 { font-size: clamp(28px, 5vw, 40px); line-height: 1.08; }
  .card-obsidian-active p,
  .card-obsidian p { font-size: 14px; }

  /* Top action rows wrap */
  .h-actions { flex-wrap: wrap; gap: 10px; }
  .h-actions .btn { flex: 1 1 auto; justify-content: center; min-width: 200px; }

  /* Trial-device 2-column QR layout — collapse to single col */
  .au-page,
  .cabinet { /* no-op anchor */ }
}


/* ════════════════ Sidebar drawer ≤ 960px ════════════════ */
@media (max-width: 960px) {
  .cabinet { grid-template-columns: 1fr; }

  /* Skeleton hides sidebar by default — bring it back as a slide-in drawer
     when CabinetShell adds the `is-open` class via the burger. */
  .sidebar {
    display: flex !important;
    position: fixed !important;
    top: 0; left: 0; bottom: 0;
    width: min(280px, 86vw);
    height: 100vh;
    z-index: 100;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: 0 12px 80px rgba(0,0,0,0.55);
  }
  .sidebar.is-open { transform: translateX(0); }

  /* Topbar adjustments */
  .topbar {
    flex-wrap: wrap;
    gap: 10px;
    padding-bottom: 16px;
    margin-bottom: 18px;
  }
  .topbar .crumbs { font-size: 10px; flex: 1; min-width: 0; }
  .topbar .pill { font-size: 10px; padding: 4px 8px; }
}


/* ════════════════ Phone ≤ 720px ════════════════ */
@media (max-width: 720px) {
  .main { padding: 16px 14px 64px; }

  /* The decorative glowing hero-mark orb overlaps heading text on narrow
     screens — hide the purely-decorative ornaments (hero-wrap, trial-
     onboarding welcome). Keeps meaningful UI like brand mark, check
     indicator on trial/success, etc. */
  .hero-wrap > .hero-mark,
  .tro-mark { display: none !important; }
  .hero-wrap { padding-left: 0 !important; }

  /* Hero card softens further */
  .hero-wrap { margin-bottom: 16px; }
  .card-obsidian-active,
  .hero-short { padding: 22px 20px !important; border-radius: 18px; }
  .card-obsidian-active h1,
  .hero-short h1 { font-size: clamp(24px, 6vw, 32px); }
  .h-meta { gap: 8px; flex-wrap: wrap; }
  .h-meta .pill,
  .h-meta .eyebrow { font-size: 10px; padding: 3px 8px; }

  /* Common 2-col → 1-col */
  .grid-2,
  .stat-strip,
  .bento,
  .co-grid,
  .gc-grid,
  .rf-top,
  .rn-grid,
  .tdp-grid,
  .tp-grid { grid-template-columns: 1fr !important; }

  /* Devices grid */
  .dv-grid { grid-template-columns: 1fr !important; gap: 12px; }
  .dv-bar { flex-direction: column; gap: 10px; }
  .dv-bar .dv-search-wrap { width: 100%; }
  .dv-filters { flex-wrap: wrap; gap: 6px; }
  .dv-card { padding: 16px; }
  .dv-card-head { flex-wrap: wrap; gap: 10px; }
  .dv-card-actions { flex-direction: column; align-items: stretch; gap: 8px; }
  .dv-card-actions .dv-action-btn { width: 100%; justify-content: center; }
  .dv-card-actions .dv-action-icon-btn { width: 100%; height: 36px; }

  /* Renew panel */
  .rn-status { flex-direction: column; align-items: flex-start; gap: 14px; padding: 18px 20px; }
  .rn-status-dial { width: 64px; height: 64px; flex-shrink: 0; }
  .rn-plans { grid-template-columns: 1fr !important; gap: 10px; }
  .rn-plan { padding: 14px 16px; }
  .rn-periods { grid-template-columns: 1fr !important; gap: 10px; }
  .rn-sum { padding: 18px; }

  /* Checkout */
  .co-step { padding: 16px; }
  .co-methods { grid-template-columns: 1fr; gap: 8px; }
  .co-summary { padding: 18px; }

  /* Trial onboarding */
  .tro-card { padding: 26px 22px; }
  .tro-h1 { font-size: clamp(26px, 6vw, 32px); }
  .tro-highlights { grid-template-columns: 1fr 1fr; gap: 8px; }
  .tro-cta { padding: 16px 18px !important; font-size: 14px; }
  .tro-meta { flex-direction: column; align-items: flex-start; gap: 6px; }

  /* Trial device picker (the platform tiles) */
  .td-grid { grid-template-columns: 1fr 1fr !important; }
  .td-platform { padding: 16px; }

  /* Trial success */
  .ts-card { padding: 26px 22px; }
  .ts-h1 { font-size: clamp(24px, 6vw, 32px); }
  .ts-info { grid-template-columns: 1fr 1fr; }
  .ts-actions { flex-direction: column; gap: 10px; }
  .ts-actions .ts-btn { width: 100%; text-align: center; }

  /* Members + Referral + Help cards */
  .mem-list .row, .mem-row { flex-wrap: wrap; gap: 10px; }
  .hp-qcards { grid-template-columns: 1fr !important; }

  /* Settings */
  .st-grid { grid-template-columns: 1fr !important; gap: 16px; }
  .st-side {
    position: static !important;
    display: flex !important;
    flex-direction: row !important;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
  }
  .st-side a { white-space: nowrap; padding: 8px 12px; font-size: 12px; }
  .st-panel { padding: 20px 18px; }
  .st-row { flex-wrap: wrap; gap: 10px; padding: 12px 0; }
  .st-row .ctrl { width: 100%; justify-content: flex-start; }
  .st-row > .text { width: 100%; }

  /* Auth / public pages */
  .au-form-wrap { padding: 24px 18px !important; }
  .au-title { font-size: clamp(28px, 7vw, 38px) !important; line-height: 1.05 !important; }
  .au-otp { gap: 6px; }
  .au-otp input { width: 40px !important; height: 48px !important; font-size: 20px !important; }
  .au-btn { padding: 14px 18px; font-size: 14px; }

  /* Ref/invite/gift recipient landings */
  .rl-main { padding: 20px 14px 40px; }
  .rl-card { padding: 24px 20px; border-radius: 18px; }
  .rl-h1 { font-size: clamp(24px, 6vw, 32px) !important; }
  .rl-bonus-box { grid-template-columns: 1fr !important; gap: 8px; padding: 12px 14px; }
  .rl-meta { flex-direction: column; gap: 4px; align-items: flex-start; }

  /* Connect Telegram page */
  .ct-card { padding: 26px 22px; }
  .ct-h1 { font-size: clamp(24px, 6vw, 32px); }
  .ct-code-box { padding: 14px 16px; }
  .ct-code-box .code { font-size: 18px !important; word-break: break-all; }

  /* Billing table */
  .bl-table { font-size: 12px; }
  .bl-table th, .bl-table td { padding: 8px 6px; }
  .bl-summary-grid { grid-template-columns: 1fr 1fr !important; gap: 8px; }

  /* Gift catalogue */
  .gf-tiers { grid-template-columns: 1fr !important; gap: 10px; }
  .gf-tier { padding: 18px; }

  /* Upgrade family compare + calculator */
  .up-comp { grid-template-columns: 1fr !important; gap: 12px; }
  .up-arrow { display: none !important; }
  .up-card { padding: 18px; }
  .up-calc {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px;
    padding: 18px !important;
  }
  .up-calc-num {
    flex-wrap: wrap !important;
    gap: 10px !important;
    justify-content: flex-start !important;
  }
  .up-calc-num .cell {
    flex: 1 1 45% !important;
    min-width: 140px !important;
    margin-left: 0 !important;
  }
  .up-calc-num .arrow { display: none !important; }
  .up-calc-num .v { font-size: 28px !important; white-space: nowrap; }
  .up-calc-num .u { font-size: 11px !important; }
  .up-actions { flex-direction: column; gap: 10px; }
  .up-actions .up-btn { width: 100%; text-align: center; }
  .up-trans { grid-template-columns: 1fr !important; gap: 12px; }

  /* QR / generic modal */
  .qr-modal { padding: 16px !important; }
  .qr-modal__inner { padding: 22px 18px !important; }
}


/* ════════════════ Small phone ≤ 480px ════════════════ */
@media (max-width: 480px) {
  /* Tighten more */
  .main { padding: 12px 12px 56px; }

  .hero-wrap { margin-bottom: 12px; }
  .card-obsidian-active,
  .hero-short { padding: 18px 16px !important; }
  .card-obsidian-active h1,
  .hero-short h1 { font-size: 22px; }
  .card-obsidian-active p,
  .hero-short p { font-size: 13px; }

  /* Trial device tiles single column on tiny phones */
  .td-grid { grid-template-columns: 1fr !important; }

  /* Trial-success info strip */
  .ts-info { grid-template-columns: 1fr; }

  /* Onboarding plan picker — single column at smallest size */
  .tro-highlights { grid-template-columns: 1fr; }

  /* Topbar email pill hidden — saves space */
  .topbar .pill { display: none; }
}


/* ════════════════ Inline-style overrides for newer client components ══════
 * These components use inline CSS-in-JS and can't be touched via class media.
 * Use selector-based attribute targeting where possible.
 * ══════════════════════════════════════════════════════════════════════════ */

/* Trial-device page: the inline two-column grid (320px QR + content) */
@media (max-width: 900px) {
  /* The grid is rendered via inline `gridTemplateColumns: "minmax(0,320px) 1fr"`
     — override by targeting any direct grid that contains both .qr (we use
     a known data attribute via parent class). Use a generic safe selector. */
  [data-trial-device-content] { grid-template-columns: 1fr !important; }
  [data-trial-device-content] > aside { max-width: 100% !important; }
}

/* Sessions panel rows in /settings (inline-styled) */
@media (max-width: 720px) {
  .st-row .text h4 { font-size: 14px; gap: 6px !important; flex-wrap: wrap; }
  .st-row .text p { font-size: 11px !important; }
}


/* ════════════════ Touch-friendly tweaks ════════════════ */
@media (hover: none) and (pointer: coarse) {
  .btn,
  .au-btn,
  .ts-btn,
  .tro-cta,
  .rl-cta,
  .st-btn,
  .dv-action-btn,
  .dv-action-icon-btn { min-height: 44px; }
}
