/* ═══════════════════════════════════════════════════════════════════
   pollitix-responsive.css
   Shared responsive overrides — loaded after per-page <style> blocks.
   Covers every page at three breakpoints: 900px, 768px, 480px.
   ═══════════════════════════════════════════════════════════════════ */

/* ── GLOBAL: prevent horizontal overflow / white-space bleed ─────────
   Stops users from scrolling sideways and seeing blank white space.
   Everything compresses to fit the screen width and scrolls vertically.
   ─────────────────────────────────────────────────────────────────── */
html {
  overflow-x: hidden;
  max-width: 100%;
}
body {
  overflow-x: hidden;
  max-width: 100%;
  /* Prevent rubber-band horizontal scroll on iOS */
  -webkit-overflow-scrolling: touch;
}
/* Ensure all direct children can't punch wider than the screen */
*,
*::before,
*::after {
  box-sizing: border-box;
  max-width: 100%;
  min-width: 0;
}

/* ── NAV SCROLL ARROWS (laptop / desktop) ────────────────────────────
   Injected by pollitix-nav-scroll.js. Visible only when nav overflows
   and only on screens wider than the mobile hamburger breakpoint.
   ─────────────────────────────────────────────────────────────────── */
.nav-links-wrap {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

/* The nav-links itself keeps its existing scroll behaviour */
.nav-links-wrap .nav-links {
  flex: 1;
}

.nav-scroll-btn {
  display: none;          /* hidden until JS detects overflow */
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 26px;
  height: 34px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 7px;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  font-weight: 300;
  cursor: pointer;
  padding: 0;
  transition: opacity .18s, background .15s;
  user-select: none;
  -webkit-user-select: none;
}
.nav-scroll-btn:hover { background: rgba(255,255,255,0.25); }

/* Only show arrows when the wrapper has overflow AND we're on laptop */
@media (min-width: 769px) {
  .nav-links-wrap.nav-overflows .nav-scroll-btn {
    display: flex;
  }
}

/* ── COLLAPSIBLE SEARCH TOGGLE ──────────────────────────────────────────
   Replaces the always-visible search bar with a 🔍 icon button.
   Clicking opens the input inline; clicking away or pressing Escape closes.
   Applied globally (all screen sizes) via JS class injection.
   ─────────────────────────────────────────────────────────────────────── */

/* The toggle button itself */
.nav-search-toggle {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 8px;
  color: #fff;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
  cursor: pointer;
  transition: background 0.15s;
}
.nav-search-toggle:hover {
  background: rgba(255,255,255,0.25);
}

/* Collapsed state: outer container tightened, input/wrap hidden */
.nav-search-outer.search-collapsible {
  padding: 0 !important;
  border-right: none !important;
  margin-right: 10px !important;
  gap: 0 !important;
  display: flex !important;
  align-items: center !important;
}
.nav-search-outer.search-collapsible .nav-search-wrap,
.nav-search-outer.search-collapsible > input.nav-search {
  max-width: 0 !important;
  width: 0 !important;
  opacity: 0 !important;
  overflow: hidden !important;
  pointer-events: none !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  margin: 0 !important;
  border-width: 0 !important;
  transition: max-width 0.25s ease, opacity 0.2s ease !important;
}

/* Expanded state: input slides open */
.nav-search-outer.search-collapsible.search-open {
  margin-right: 14px !important;
  gap: 8px !important;
}
.nav-search-outer.search-collapsible.search-open .nav-search-wrap,
.nav-search-outer.search-collapsible.search-open > input.nav-search {
  max-width: 260px !important;
  width: 220px !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  padding-left: 14px !important;
  padding-right: 14px !important;
  border-width: 1px !important;
}

/* ── MEDIUM LAPTOP NAV FIT ──────────────────────────────────────────────
   On medium screens (up to 1380px) hide the text labels and show emoji
   icons only — 12 items with labels won't fit; icons alone do.
   ─────────────────────────────────────────────────────────────────────── */
@media (min-width: 769px) and (max-width: 1380px) {
  /* Hide text labels — show emoji icons only */
  .nav-label { display: none !important; }
  /* Icon-only links: tighter padding, bigger emoji */
  .nav-links { gap: 0 !important; }
  .nav-link  { padding: 6px 9px !important; font-size: 18px !important; white-space: nowrap !important; }
  .nav-right { gap: 8px !important; }
  .nav-btn { padding: 6px 14px !important; font-size: 12px !important; }
  /* Never show scroll arrows — icons always fit */
  .nav-scroll-btn { display: none !important; }
  .nav-links-wrap { overflow: hidden !important; }
}

/* On mobile the hamburger takes over — force arrows off */
@media (max-width: 768px) {
  .nav-links-wrap { display: none !important; }
  .nav-scroll-btn { display: none !important; }
}

/* ── 0. HAMBURGER + MOBILE NAV BASE STYLES ───────────────────────────
   Defines the styles for pages that receive the hamburger via Python
   injection (profile, communities, polly, onboarding).
   Pages that already have these styles inline are unaffected.
   ───────────────────────────────────────────────────────────────── */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  padding: 8px;
  border: none;
  background: transparent;
  margin-left: auto;
  flex-shrink: 0;
}
.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: all .25s;
}
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.mobile-nav {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
}
.mobile-nav-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
}
.mobile-nav-drawer {
  position: absolute;
  top: 0; left: 0;
  width: 300px;
  height: 100%;
  background: #1a3c8f;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 24px rgba(0,0,0,0.3);
}
.mobile-nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.15);
}
.mobile-nav-close {
  background: rgba(255,255,255,0.1);
  border: none;
  color: #fff;
  width: 34px; height: 34px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mobile-nav-links { padding: 12px 0; flex: 1; }
.mobile-nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 20px;
  font-size: 14px;
  font-weight: 600;
  color: rgba(255,255,255,0.85);
  cursor: pointer;
  transition: background .15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: 'Inter', sans-serif;
}
.mobile-nav-link:hover,
.mobile-nav-link.active { background: rgba(255,255,255,0.12); color: #fff; }
.mobile-nav-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.15);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.mob-search {
  background: rgba(255,255,255,0.1);
  border: 1.5px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  padding: 10px 14px;
  color: #fff;
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  outline: none;
  width: 100%;
  box-sizing: border-box;
}
.mob-search::placeholder { color: rgba(255,255,255,0.5); }
.mob-auth-row { display: flex; gap: 8px; }
.mob-btn {
  flex: 1;
  padding: 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  text-align: center;
  border: none;
}
.mob-btn-outline { background: transparent; color: #fff; border: 1.5px solid rgba(255,255,255,0.4) !important; }
.mob-btn-primary { background: #fff; color: #1a3c8f; }
.mob-user-row { display: none; align-items: center; gap: 10px; padding: 10px 0; }
.mob-user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg,#dc2626,#9333ea);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800; color: #fff; flex-shrink: 0;
}
.mob-user-name {
  font-size: 13px; font-weight: 700; color: #fff;
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mob-logout-btn {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff; border-radius: 8px;
  padding: 6px 12px; font-size: 12px; font-weight: 700;
  cursor: pointer; font-family: 'Inter', sans-serif;
}

/* Mobile settings section selector — shown only on mobile */
.px-mobile-section-select {
  display: none;
  width: 100%;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  background: #fff;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  margin-bottom: 16px;
  color: #1e293b;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%232952c4' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
}


/* ═══════════════════════════════════════════════════════════════════
   0.5. WIDE DESKTOP — cap page width so content doesn't stretch too far
   ═══════════════════════════════════════════════════════════════════ */
.page-wrap {
  max-width: 1440px;
  margin-left: auto !important;
  margin-right: auto !important;
}


/* ═══════════════════════════════════════════════════════════════════
   1. LAPTOP (≤1280px) — shrink sidebar so main content has more room
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 1280px) {
  .main-grid { grid-template-columns: 1fr 320px !important; }
}

@media (max-width: 1100px) {
  .main-grid { grid-template-columns: 1fr 280px !important; }
  .page-wrap { padding: 20px 20px !important; }
}


/* ═══════════════════════════════════════════════════════════════════
   1b. TABLET / SMALL LAPTOP (≤1024px)
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  /* Loosen wide footer */
  .pxf-inner { grid-template-columns: 1fr 1fr 1fr 1fr !important; gap: 24px !important; }

  /* Pricing: 5-col → 3-col */
  [id="pricingGrid"] { grid-template-columns: repeat(3, 1fr) !important; }

  /* Profile setup emoji grid */
  .avatar-emoji-grid { grid-template-columns: repeat(6, 1fr) !important; }

  /* Sidebar just one narrow column before we fully collapse at 900px */
  .main-grid { grid-template-columns: 1fr 240px !important; }
  .page-wrap { padding: 16px 16px !important; }
}


/* ── HOMEPAGE PRICING GRID ───────────────────────────────────────────
   Inline styles can't be overridden by class selectors, so we use the
   id we added to the grid div. Collapses 5-col → 3 → 2 → 1 as the
   screen gets smaller. Each card also gets a sensible min-width reset.
   ─────────────────────────────────────────────────────────────────── */
#hp-pricing-grid {
  min-width: 0 !important;
}
@media (max-width: 1100px) {
  #hp-pricing-grid { grid-template-columns: repeat(3, 1fr) !important; }
}
@media (max-width: 720px) {
  #hp-pricing-grid { grid-template-columns: repeat(2, 1fr) !important; }
}
@media (max-width: 480px) {
  #hp-pricing-grid { grid-template-columns: 1fr !important; gap: 12px !important; }
}

/* ═══════════════════════════════════════════════════════════════════
   2. COMPACT (≤900px) — stack sidebar layouts
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  /* Common two-column main layouts */
  .main-wrap  { grid-template-columns: 1fr !important; }
  .main-grid  { grid-template-columns: 1fr !important; }
  .news-body  { grid-template-columns: 1fr !important; }
  .profile-body { grid-template-columns: 1fr !important; }

  /* Topics layout on Learn page */
  .topics-layout { grid-template-columns: 1fr !important; }

  /* Page padding */
  .page-wrap { padding: 16px 14px !important; }
}


/* ═══════════════════════════════════════════════════════════════════
   3. MOBILE NAV BREAKPOINT (≤768px) — main mobile target
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* ── NAVBAR ─────────────────────────────────────────────────────── */
  .nav-links      { display: none !important; }
  .nav-right      { display: none !important; }
  .nav-search-outer { display: none !important; }
  .hamburger      { display: flex !important; }
  .navbar         { padding: 0 14px !important; }
  .nav-logo svg   { width: 100px !important; height: 30px !important; }
  .top-bar        { display: none !important; }

  /* ── PAGE PADDING ────────────────────────────────────────────────── */
  .page-wrap  { padding: 14px 10px !important; }
  .main-wrap  { padding: 14px 10px !important; }

  /* ── LAYOUT GRIDS → 1 COL ────────────────────────────────────────── */
  .main-grid        { grid-template-columns: 1fr !important; gap: 14px !important; }
  .main-wrap        { grid-template-columns: 1fr !important; gap: 14px !important; }
  .profile-body     { grid-template-columns: 1fr !important; }
  .col-side         { position: static !important; top: auto !important; }
  .checkout-wrap    { grid-template-columns: 1fr !important; }
  .news-body        { grid-template-columns: 1fr !important; }

  /* News grid (class used on news & homepage) */
  .news-grid { grid-template-columns: 1fr !important; }

  /* ── SETTINGS SIDEBAR → HIDDEN, SHOW MOBILE SELECT ──────────────── */
  .settings-sidebar { display: none !important; }
  .settings-page    { flex-direction: column !important; }
  .settings-main    { padding: 16px !important; flex: 1 !important; min-width: 0 !important; }
  .px-mobile-section-select { display: block !important; }

  /* ── MESSAGES: 3-panel → stacked ────────────────────────────────── */
  /* Default: show conversation list, hide chat panel */
  .app-body     { flex-direction: column !important; height: calc(100vh - 64px) !important; }
  .left-panel   { display: none !important; }
  .mid-panel    { width: 100% !important; border-right: none !important; flex: 1 !important; }
  .chat-panel   { display: none !important; flex-direction: column !important; flex: 1 !important; }
  /* When chat is active (JS adds .chat-open to .app-body) */
  .app-body.chat-open .mid-panel  { display: none !important; }
  .app-body.chat-open .chat-panel { display: flex !important; }

  /* ── POLLY AI: sidebar → collapsible header ──────────────────────── */
  .polly-layout  { flex-direction: column !important; }
  .polly-sidebar {
    width: 100% !important;
    max-height: 160px !important;
    overflow-y: auto !important;
    border-right: none !important;
    border-bottom: 1px solid #e2e8f0 !important;
  }
  .polly-messages   { padding: 14px 14px !important; }
  .polly-suggestions { padding: 0 14px 10px !important; flex-wrap: wrap !important; }
  .polly-input-area { padding: 8px 12px !important; }

  /* ── NOTIFICATIONS: hide sidebars ───────────────────────────────── */
  .notif-sidebar { display: none !important; }
  .notif-right   { display: none !important; }
  .notif-main    { border-left: none !important; border-right: none !important; }

  /* ── LEARN: hide sidebar category nav ───────────────────────────── */
  .topics-layout { grid-template-columns: 1fr !important; }
  .learn-sidebar,.topic-sidebar { display: none !important; }

  /* ── CARDS ───────────────────────────────────────────────────────── */
  .card-body { padding: 14px 14px !important; }
  .card-head { padding: 12px 14px !important; }

  /* ── PRICING ─────────────────────────────────────────────────────── */
  [id="pricingGrid"] { grid-template-columns: 1fr !important; }
  [id="wpGrid"]      { grid-template-columns: 1fr !important; }

  /* ── FOOTER ──────────────────────────────────────────────────────── */
  .pxf-inner { grid-template-columns: 1fr 1fr !important; gap: 20px !important; }
  .pxf-brand { grid-column: 1/-1 !important; }
  .pxf-bottom-inner {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 6px !important;
  }

  /* ── AUTH PAGE ───────────────────────────────────────────────────── */
  .auth-wrap,.auth-card { margin: 16px !important; }
  .auth-split { grid-template-columns: 1fr !important; }
  .auth-left  { display: none !important; }

  /* ── PROFILE: banner + avatar ────────────────────────────────────── */
  .prof-banner { height: 120px !important; }
  .prof-header { padding: 0 14px 14px !important; }
  .prof-meta-row { flex-wrap: wrap !important; gap: 8px !important; }

  /* ── DEBATES ─────────────────────────────────────────────────────── */
  .debate-header { padding: 16px 14px !important; }

  /* ── TABLES (MP/Lords/Bill tracker) ─────────────────────────────── */
  .tracker-table-wrap,
  table { display: block !important; overflow-x: auto !important; -webkit-overflow-scrolling: touch !important; }

  /* ── ELECTIONS / FOLLOWING ───────────────────────────────────────── */
  .elections-grid { grid-template-columns: 1fr !important; }

  /* ── BILLS ───────────────────────────────────────────────────────── */
  .bill-detail-grid { grid-template-columns: 1fr !important; }

  /* ── QUIZ ────────────────────────────────────────────────────────── */
  .quiz-wrap { padding: 16px 10px !important; }
  .quiz-options { grid-template-columns: 1fr !important; }
}


/* ═══════════════════════════════════════════════════════════════════
   4. SMALL MOBILE (≤480px)
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 480px) {

  /* ── TYPOGRAPHY ──────────────────────────────────────────────────── */
  .hero-title        { font-size: 18px !important; }
  h1                 { font-size: 20px !important; }
  h2                 { font-size: 16px !important; }

  /* ── NAV LOGO ────────────────────────────────────────────────────── */
  .nav-logo svg { width: 84px !important; height: 24px !important; }

  /* ── FOOTER → 1 COL ─────────────────────────────────────────────── */
  .pxf-inner { grid-template-columns: 1fr !important; }

  /* ── PROFILE SETUP GRIDS ─────────────────────────────────────────── */
  .avatar-emoji-grid { grid-template-columns: repeat(5, 1fr) !important; }
  .banner-grid       { grid-template-columns: repeat(2, 1fr) !important; }
  .iep-grid          { grid-template-columns: 1fr !important; }
  .leaning-grid      { grid-template-columns: repeat(2, 1fr) !important; }

  /* ── ONBOARDING TILES ────────────────────────────────────────────── */
  .ob-tiles       { grid-template-columns: 1fr 1fr !important; }
  .ob-feature-row { grid-template-columns: 1fr !important; }
  .ob-location-opts { grid-template-columns: 1fr !important; }

  /* ── SETTINGS ────────────────────────────────────────────────────── */
  .setting-row {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 10px !important;
  }
  .account-hero {
    flex-direction: column !important;
    text-align: center !important;
    gap: 12px !important;
  }

  /* ── MESSAGES: full-width bubbles ────────────────────────────────── */
  .msg-group { max-width: 90% !important; }
  .msg-bubble { font-size: 13px !important; }

  /* ── POLLS GRID ──────────────────────────────────────────────────── */
  .polls-grid { grid-template-columns: 1fr !important; }

  /* ── DISCUSSIONS ─────────────────────────────────────────────────── */
  .post-meta  { flex-wrap: wrap !important; gap: 4px !important; }
  .post-actions { flex-wrap: wrap !important; gap: 6px !important; }

  /* ── COMMUNITY GRID ──────────────────────────────────────────────── */
  .comm-grid  { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)) !important; }

  /* ── PARTY COMPARE ───────────────────────────────────────────────── */
  .compare-header { flex-direction: column !important; align-items: flex-start !important; }

  /* ── PARTY COMPARE GRID ──────────────────────────────────────────── */
  .compare-grid   { grid-template-columns: 1fr !important; }

  /* ── POLLY suggestions ───────────────────────────────────────────── */
  .polly-suggestions { gap: 6px !important; }
  .polly-sug         { font-size: 12px !important; padding: 6px 10px !important; }

  /* ── ELECTIONS ───────────────────────────────────────────────────── */
  .result-bar-wrap { flex-direction: column !important; gap: 6px !important; }

  /* ── QUIZ OPTIONS ────────────────────────────────────────────────── */
  .quiz-option { padding: 12px !important; font-size: 13px !important; }

  /* ── VERIFICATION GRID ───────────────────────────────────────────── */
  .badge-grid { grid-template-columns: 1fr 1fr !important; }
}
