/* ============================================================
   HYVE ALPHA — Universal Responsive Overrides
   Breakpoints:
     Phone    ≤ 640px
     Tablet   641px – 1024px
     Laptop   1025px – 1536px (default site design)
     TV/big   ≥ 1537px
   Loaded last so it overrides per-page styles. Never put
   layout here that breaks desktop — only mobile/tablet deltas.
   ============================================================ */

/* ── Universal: prevent horizontal scroll, use safe-area insets ── */
html, body {
  max-width: 100%;
  overflow-x: hidden !important;
}
body {
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}
*, *::before, *::after { box-sizing: border-box; }
img, video, canvas, iframe, audio { max-width: 100%; height: auto; }
iframe, video { aspect-ratio: auto; }
pre, code { overflow-x: auto; word-break: break-word; white-space: pre-wrap; }
table { max-width: 100%; }

/* ───────────────────────────────────────
   PHONE (≤ 640px) — single column, everything bigger and tappable
   ─────────────────────────────────────── */
@media (max-width: 640px) {

  /* ── Research banner + nav ── */
  .research-banner {
    font-size: 9px !important;
    padding: 6px 10px !important;
    line-height: 1.5 !important;
    white-space: normal !important;
  }
  nav {
    top: 30px !important;
    padding: 8px 12px !important;
    gap: 6px !important;
    flex-wrap: wrap !important;
  }
  nav .brand { font-size: 11px !important; }
  nav .sep, nav span[style*="font-size:9px"] { display: none !important; }
  nav .links {
    gap: 10px !important;
    flex-wrap: wrap !important;
    justify-content: flex-end !important;
  }
  nav .links a {
    font-size: 10px !important;
    padding: 6px 8px !important;
    white-space: nowrap !important;
  }

  /* ── Hero ── */
  .hero {
    padding: 96px 16px 32px !important;
    min-height: auto !important;
  }
  .hero-logo {
    width: 160px !important;
    height: 160px !important;
    margin-bottom: 18px !important;
  }
  .hero-label { font-size: 7px !important; letter-spacing: 3px !important; }
  .hero h1 { font-size: 28px !important; letter-spacing: -0.3px !important; }
  .hero .desc { font-size: 12px !important; line-height: 1.7 !important; padding: 0 4px; }
  .hero-btns {
    flex-direction: column !important;
    width: 100% !important;
    gap: 10px !important;
  }
  .hero-btns .btn, .hero-btns a {
    width: 100% !important;
    text-align: center !important;
    padding: 14px 20px !important;
    font-size: 13px !important;
  }
  .chat-alpha-hero-btn {
    font-size: 13px !important;
    padding: 16px 24px !important;
    width: calc(100% - 8px) !important;
    letter-spacing: 1px !important;
    margin-bottom: 20px !important;
  }

  /* ── Generic buttons & forms ── */
  button, .btn, a.btn, input[type="submit"] {
    min-height: 44px !important; /* iOS tap target minimum */
  }
  input, textarea, select {
    font-size: 16px !important; /* prevents iOS zoom on focus */
    min-height: 44px !important;
    padding: 12px 14px !important;
  }
  textarea { min-height: 60px !important; }

  /* ── Cards and grids collapse to single column ── */
  .cards, .arch, .tiers, .grid, .grid-2, .grid-3, .grid-4,
  [style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
  [style*="flex-direction:row"] { flex-direction: column !important; }
  .layers { flex-wrap: wrap !important; gap: 8px !important; }
  .stats-bar { flex-wrap: wrap !important; gap: 14px !important; }

  /* ── Chat surface (most important) ── */
  .chat-surface {
    height: calc(100vh - 180px) !important;
    min-height: 520px !important;
    max-height: none !important;
    border-radius: 12px !important;
    margin-bottom: 24px !important;
  }
  .chat-topbar {
    padding: 10px 12px !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
  }
  .chat-topbar .avatar { width: 34px !important; height: 34px !important; }
  .chat-topbar .name { font-size: 11px !important; }
  .chat-topbar .status { font-size: 7px !important; }
  .chat-topbar .counter { font-size: 8px !important; }
  #live-counter {
    padding: 4px 9px !important;
    margin-right: 6px !important;
  }
  #live-counter span[style*="font-size:9px"] { font-size: 8px !important; }

  .chat-messages {
    padding: 14px 12px !important;
    gap: 12px !important;
  }
  .chat-msg {
    max-width: 90% !important;
    padding: 10px 13px !important;
    font-size: 13px !important;
  }
  .chat-input-row {
    padding: 10px !important;
    gap: 6px !important;
    flex-wrap: nowrap !important;
  }
  .chat-input-row textarea {
    font-size: 15px !important;
    padding: 12px !important;
  }
  #chat-mic {
    min-width: 44px !important;
    padding: 0 10px !important;
    font-size: 18px !important;
  }
  #chat-send {
    min-width: 64px !important;
    padding: 12px 14px !important;
    font-size: 12px !important;
  }

  /* ── Booking / donation / tiles ── */
  .booking-module, .why-section, .legend {
    padding: 24px 14px !important;
  }
  .tier-card { padding: 16px !important; }
  .why-title h2 { font-size: 22px !important; }
  .why-title p.sub { font-size: 12px !important; }

  /* ── Limits / footer text ── */
  .limits {
    font-size: 9px !important;
    gap: 6px !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
    padding: 0 12px !important;
  }
  .limits .dot { display: none !important; }

  /* ── Tables: horizontal scroll container ── */
  table {
    font-size: 11px !important;
  }
  /* Wrap tables in scroll container when they're direct page children */
  .card table, .drawer-inner table {
    display: block !important;
    overflow-x: auto !important;
    white-space: nowrap !important;
  }

  /* ── Admin sidebar: collapsible drawer on phone ── */
  .sidebar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    transform: translateX(-100%) !important;
    transition: transform 0.3s !important;
    z-index: 200 !important;
    width: 260px !important;
    box-shadow: 8px 0 40px rgba(0,0,0,0.8) !important;
  }
  .sidebar.open { transform: translateX(0) !important; }
  .topbar .menu-btn { display: inline-flex !important; }
  .main .topbar { padding: 10px 14px !important; }
  .main .content { padding: 14px !important; }

  /* ── Fit test gate ── */
  #chat-gate #fit-wrap { padding: 24px 18px !important; }
  #chat-gate h2 { font-size: 20px !important; }
  #fit-slider { height: 8px !important; }

  /* ── Booking cards + session tiers grid collapses ── */
  .sheading { font-size: 22px !important; }

  /* ── Investors / articles / donation forms stack ── */
  form[onsubmit] {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
  }
  form[onsubmit] input,
  form[onsubmit] select,
  form[onsubmit] button,
  form[onsubmit] textarea {
    width: 100% !important;
    min-width: 0 !important;
  }
}

/* ───────────────────────────────────────
   TABLET (641–1024px) — 2 columns, medium sizing
   ─────────────────────────────────────── */
@media (min-width: 641px) and (max-width: 1024px) {

  nav { padding: 10px 18px !important; }
  nav .links { gap: 12px !important; }
  nav .links a { font-size: 10px !important; }

  .hero { padding: 100px 24px 40px !important; }
  .hero-logo { width: 220px !important; height: 220px !important; }
  .hero h1 { font-size: 36px !important; }
  .hero .desc { font-size: 13px !important; max-width: 620px !important; }
  .chat-alpha-hero-btn { font-size: 15px !important; padding: 18px 40px !important; }

  .cards, .arch, .tiers, .grid, .grid-3, .grid-4,
  [style*="grid-template-columns"] {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 14px !important;
  }
  .grid-2 { grid-template-columns: repeat(2, 1fr) !important; }

  .chat-surface {
    height: 680px !important;
    max-width: 100% !important;
  }
  .chat-msg { max-width: 84% !important; }

  /* Admin content padding */
  .main .content { padding: 18px !important; }

  /* Forms can go 2 column */
  .booking-module .tier-card { padding: 20px !important; }
}

/* ───────────────────────────────────────
   TV / LARGE MONITOR (≥ 1537px) — scale up gracefully
   ─────────────────────────────────────── */
@media (min-width: 1537px) {
  .hero-logo { width: 320px !important; height: 320px !important; }
  .hero h1 { font-size: 52px !important; }
  .hero .desc { font-size: 15px !important; max-width: 680px !important; }
  .page, .booking-module, .why-section {
    max-width: 1280px !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }
  .chat-surface { max-width: 1080px !important; margin-left: auto !important; margin-right: auto !important; }
}

/* ───────────────────────────────────────
   VERY WIDE (≥ 1920px) — TV landscape
   ─────────────────────────────────────── */
@media (min-width: 1920px) {
  body { font-size: 16px; }
  .hero h1 { font-size: 64px !important; }
  .hero-logo { width: 360px !important; height: 360px !important; }
  .chat-surface { max-width: 1200px !important; }
}

/* ───────────────────────────────────────
   LANDSCAPE PHONE — compact height
   ─────────────────────────────────────── */
@media (max-width: 932px) and (orientation: landscape) and (max-height: 500px) {
  .hero { padding: 70px 20px 24px !important; min-height: auto !important; }
  .hero-logo { width: 110px !important; height: 110px !important; margin-bottom: 10px !important; }
  .hero h1 { font-size: 22px !important; }
  .hero .desc { font-size: 11px !important; margin-bottom: 14px !important; }
  .chat-surface { height: calc(100vh - 140px) !important; min-height: 380px !important; }
}

/* ───────────────────────────────────────
   Dark-mode touch: disable hover lifts on touch devices
   ─────────────────────────────────────── */
@media (hover: none) {
  .btn:hover, button:hover, a:hover { transform: none !important; }
}
