/* =========================================================
   R2V Unified Portal — mobile.css
   Mobile-first overrides. Majority of users are on phones,
   so this file does the heavy lifting for that experience.
   Breakpoints:
     <= 1024px : sidebar becomes a drawer, search hides
     <=  900px : event detail / profile stacks, narrower cards
     <=  768px : phone-style layout
     <=  480px : tightest phones
   ========================================================= */

/* ---------- Universal mobile safety net ---------- */
/* iOS zooms inputs when font-size < 16px — keep them at 16px on small screens. */
@media (max-width: 768px) {
  input, select, textarea { font-size: 16px !important; }
}

/* ---------- Sidebar drawer ---------- */
@media (max-width: 1024px) {
  .r2v-shell { grid-template-columns: 1fr; }
  .r2v-sidebar {
    position: fixed; top: var(--r2v-topbar-h); left: -280px;
    width: 280px; max-width: 80vw;
    height: calc(100vh - var(--r2v-topbar-h));
    transition: left .25s var(--r2v-ease);
    z-index: 40;
    box-shadow: 8px 0 30px rgba(0,0,0,.15);
  }
  body.r2v-mobile-nav-open .r2v-sidebar { left: 0; }
  body.r2v-mobile-nav-open .r2v-main::before {
    content: ''; position: fixed; inset: var(--r2v-topbar-h) 0 0 0;
    background: rgba(8,21,38,.40); z-index: 35;
  }
  .r2v-topbar__menu { display: inline-flex; }
  .r2v-topbar__center { display: none; }
}

/* ---------- 900px: tighten layout ---------- */
@media (max-width: 900px) {
  .r2v-quick-row    { grid-template-columns: 1fr 1fr; gap: 10px; }
  .r2v-kpi-row      { grid-template-columns: 1fr 1fr; gap: 10px; }
  .r2v-dash-grid,
  .r2v-dash-grid--3 { grid-template-columns: 1fr; gap: 16px; }
  .r2v-dash-grid--3 > * { grid-column: auto; }
}

/* ---------- 768px: phone layout ---------- */
@media (max-width: 768px) {
  .r2v-page { padding: 14px 12px 80px; }
  .r2v-page__head { flex-direction: column; align-items: stretch; gap: 10px; }
  .r2v-page__title h1 { font-size: 22px; }
  .r2v-page__title p  { font-size: 13px; }
  .r2v-page--wide { padding-left: 12px; padding-right: 12px; }

  /* Topbar */
  .r2v-topbar { padding: 0 10px; gap: 6px; }
  .r2v-topbar__logo { height: 32px; }
  .r2v-topbar__sublabel { display: none; }
  .r2v-roleswitcher__who { display: none; }
  .r2v-iconbtn { width: 38px; height: 38px; }

  /* Hero — more compact, single column, eyebrow on its own line */
  .r2v-hero { padding: 20px 18px; border-radius: 18px; margin-bottom: 14px; }
  .r2v-hero__greet { font-size: 24px; line-height: 1.15; }
  .r2v-hero__sub { font-size: 14px; }
  .r2v-hero__row { gap: 16px; }
  .r2v-hero__actions { width: 100%; }
  .r2v-hero__actions .r2v-btn { flex: 1; justify-content: center; min-height: 44px; }

  /* Quick actions: still readable, full-width tap targets */
  .r2v-quick-row { grid-template-columns: 1fr; gap: 10px; }
  .r2v-quick { padding: 14px 14px; min-height: 64px; }

  /* KPIs: stack 2x2 (one column on very small) */
  .r2v-kpi-row { gap: 10px; margin-bottom: 14px; }
  .r2v-kpi { padding: 12px 14px; }
  .r2v-kpi__num { font-size: 22px; }

  /* To-Do widget — tap-friendly, stacked CTA */
  .r2v-todo { padding: 12px; grid-template-columns: 34px 1fr; row-gap: 10px; }
  .r2v-todo__icon-wrap { width: 34px; height: 34px; }
  .r2v-todo__cta { grid-column: 1 / -1; justify-content: center; min-height: 44px; }

  /* Onboarding stepper — compact 3-col */
  .r2v-stepper { grid-template-columns: repeat(3, 1fr); row-gap: 14px; }
  .r2v-stepper__item:nth-child(3n)::after,
  .r2v-stepper__item:nth-child(3n+1)::before { background: transparent !important; }
  .r2v-stepper__name { font-size: 11px; }
  .r2v-stepper__sub { display: none; }

  /* Tables become cards */
  .r2v-table thead { display: none; }
  .r2v-table tr {
    display: grid; grid-template-columns: 1fr; gap: 4px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--r2v-border);
  }
  .r2v-table td { border-bottom: 0; padding: 4px 0; }
  .r2v-table td.is-num { text-align: left; }

  /* Event grid 1 col + tightened cards */
  .r2v-eventgrid { grid-template-columns: 1fr; gap: 14px; }
  .r2v-event-card { border-radius: 14px; }
  .r2v-event-card__body { padding: 12px 14px 14px; }
  .r2v-event-card__title { font-size: 16px; }

  /* Event bar / filter chips */
  .r2v-eventbar { padding: 10px; gap: 10px; }
  .r2v-eventbar__filters { width: 100%; }
  .r2v-eventbar__filters .r2v-search { width: 100%; min-width: 0 !important; }
  .r2v-tabs { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .r2v-tabs__btn { white-space: nowrap; }

  /* Map view: list stacks ABOVE the map (taller map, scrollable list) */
  .r2v-mapwrap { grid-template-columns: 1fr; gap: 12px; height: auto; }
  .r2v-maplist { max-height: 320px; order: 2; }
  .r2v-mapcol  { height: 60vh; min-height: 380px; order: 1; }
  .r2v-mapleg  { font-size: 10px; padding: 8px 10px; max-width: 180px; }
  .r2v-mapleg__grid { grid-template-columns: 1fr; gap: 3px; }
  .r2v-mapctl { width: 40px; height: 40px; }

  /* Profile side stacks horizontally */
  .r2v-prof { grid-template-columns: 1fr; }
  .r2v-prof__side { position: static; }
  .r2v-prof__nav { flex-direction: row; flex-wrap: wrap; gap: 6px; }
  .r2v-prof__nav button { flex: 1 1 130px; min-height: 44px; }

  /* Cal cells smaller */
  .r2v-cal__cell { min-height: 80px; padding: 5px; }
  .r2v-cal__chip { font-size: 10px; padding: 2px 5px; }

  /* Event detail */
  .r2v-evdetail__hero { aspect-ratio: 4/3; }
  .r2v-evdetail__heroinner h1 { font-size: 22px; }
  .r2v-evside { position: static; }

  /* Community feed — full width composer, scrollable filters */
  .r2v-feed-layout { grid-template-columns: 1fr; gap: 14px; }
  .r2v-feed-composer { padding: 14px; }
  .r2v-feed-composer__previews,
  .r2v-feed-composer__prompts { margin-left: 0; }
  .r2v-feed-composer__prompts { gap: 4px; }
  .r2v-feed-composer__prompt { padding: 8px 12px; min-height: 36px; }
  .r2v-feed-activity {
    padding: 10px 12px; gap: 12px;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
  }
  .r2v-feed-activity__stat { flex-shrink: 0; }
  .r2v-feed-activity__pulse { display: none; }
  .r2v-feed-filterbar {
    flex-wrap: nowrap;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
  }
  .r2v-feed-filterchip { flex-shrink: 0; padding: 10px 14px; min-height: 40px; }

  /* Community pulse single column on narrow */
  .r2v-pulse__body { grid-template-columns: 1fr; }

  /* Toasts */
  .r2v-toasts { right: 10px; left: 10px; }
  .r2v-toast { min-width: 0; max-width: 100%; }

  /* Buttons hit ≥ 44px on phone */
  .r2v-btn { min-height: 44px; }
  .r2v-btn--sm { min-height: 36px; }
}

/* ---------- 480px: tightest phones ---------- */
@media (max-width: 480px) {
  .r2v-stepper { grid-template-columns: repeat(2, 1fr); }
  .r2v-stepper__item:nth-child(2n)::after,
  .r2v-stepper__item:nth-child(2n+1)::before { background: transparent !important; }

  .r2v-kpi-row { grid-template-columns: 1fr; }
  .r2v-comm-gallery { grid-template-columns: 1fr 1fr; }

  .r2v-hero { padding: 18px 16px; }
  .r2v-hero__greet { font-size: 22px; }
  .r2v-hero__eyebrow { font-size: 10px; padding: 3px 8px; }

  /* Quick action: single column, vertical-ish look */
  .r2v-quick { grid-template-columns: 40px 1fr 16px; padding: 14px; }
  .r2v-quick__icon { width: 40px; height: 40px; }
  .r2v-quick__label { font-size: 14px; }
  .r2v-quick__sub   { font-size: 11px; }

  /* Election rows wrap nicer */
  .r2v-election { grid-template-columns: 56px 1fr; row-gap: 8px; }
  .r2v-election__countdown { grid-column: 1 / -1; text-align: left; display: flex; align-items: baseline; gap: 6px; }
  .r2v-election__state { width: 56px; }
  .r2v-election__countdown strong { font-size: 18px; }

  /* Map list takes a touch less height */
  .r2v-maplist { max-height: 260px; }
  .r2v-mapcol  { height: 50vh; min-height: 320px; }

  /* Profile nav: vertical chips for very small */
  .r2v-prof__nav button { flex-basis: calc(50% - 6px); }
}
