/* mobile.css — mobile-first responsive overrides
   Politilens is now smartphone-primary. Loaded last so wins specificity.
   Strategy: shrink everything to a single column under 720px,
   restore desktop grids above. */

/* ── Source link styles (used on all platforms) ── */
.src-link {
  display: inline-flex; align-items: center; gap: 4px;
  margin-top: 8px;
  font-size: 11.5px; font-weight: 500;
  color: var(--accent, #2A6FDB);
  text-decoration: none;
  border-bottom: 1px dashed currentColor;
  width: fit-content;
}
.src-link:hover { color: var(--ink); border-bottom-style: solid; }
.src-link-block { display: block; grid-column: 1 / -1; margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--line); border-bottom: none; }
.src-link-strong {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  margin-top: 12px;
  font-weight: 600;
}
.src-link-strong:hover { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.src-mini {
  display: block;
  margin-top: 6px;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--accent, #2A6FDB);
  text-decoration: none;
  letter-spacing: 0.02em;
}
.src-mini:hover { text-decoration: underline; }

/* ── Programme tab ── */
.program { max-width: 720px; }
.program-head {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 20px;
  margin-bottom: 24px;
}
.program-meta { display: flex; gap: 10px; align-items: baseline; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); margin-bottom: 4px; }
.program-elec { font-weight: 600; }
.program-year { font-size: 13px; color: var(--ink-2); }
.program-title { font-family: var(--ff-serif, 'Newsreader', Georgia, serif); font-size: 24px; font-weight: 500; margin: 0 0 10px; line-height: 1.2; }
.program-legend { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; font-size: 11px; color: var(--ink-3); }
.program-section { margin-bottom: 24px; }
.program-theme { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3); margin: 0 0 10px; font-weight: 600; }
.promise-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.promise {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 14px;
  align-items: start;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.promise-text { margin: 0; font-size: 14px; line-height: 1.5; color: var(--ink-2); }

/* Promise status pills */
.pst { display: inline-flex; align-items: center; justify-content: center; padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; text-transform: lowercase; letter-spacing: .02em; height: fit-content; }
.pst-pos     { background: color-mix(in srgb, var(--pos) 18%, transparent); color: var(--pos); }
.pst-mid     { background: color-mix(in srgb, var(--abs) 22%, transparent); color: color-mix(in srgb, var(--abs) 70%, var(--ink)); }
.pst-neg     { background: color-mix(in srgb, var(--neg) 18%, transparent); color: var(--neg); }
.pst-neutral { background: var(--surface-2); color: var(--ink-3); border: 1px solid var(--line); }

/* ── Mobile-first layout (default = phone) ── */
@media (max-width: 720px) {
  body { font-size: 15px; }

  .shell { padding: 14px 16px 80px !important; }
  .back { margin-bottom: 12px; font-size: 13px; }

  /* Profile head: single column on mobile */
  .profile-head {
    grid-template-columns: 1fr !important;
    gap: 14px !important;
    padding: 0 0 18px !important;
    border-bottom: 1px solid var(--line);
    margin-bottom: 18px;
  }
  .profile-head .photo {
    width: 96px !important; height: 96px !important;
    margin: 0 auto;
  }
  .profile-head h1 { font-size: 26px !important; line-height: 1.15; text-align: center; }
  .profile-head .subline { justify-content: center; flex-wrap: wrap; font-size: 12px; text-align: center; }
  .profile-head .subline > * { font-size: 12px; }
  .profile-head .mandate-line { text-align: center; font-size: 13px; }
  .profile-head .bio { font-size: 14px; line-height: 1.55; }
  .profile-head .actions {
    flex-direction: row !important; flex-wrap: wrap;
    justify-content: center;
    width: 100%;
    gap: 8px;
  }
  .profile-head .actions .btn { flex: 1 1 auto; min-width: 90px; justify-content: center; padding: 10px 14px; font-size: 13px; }

  /* Stats: 2-col grid on mobile */
  .stats-strip {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0 !important;
    margin-bottom: 18px;
  }
  .stat-cell { padding: 12px 14px !important; }
  .stat-cell .val { font-size: 18px !important; }
  .stat-cell .lab { font-size: 10.5px !important; }

  /* Tabs: horizontal scroll */
  .detail.layout-tabs .tabs,
  .detail.layout-sidebar { display: block !important; }
  .tabs {
    overflow-x: auto; overflow-y: hidden;
    flex-wrap: nowrap !important;
    white-space: nowrap;
    margin: 0 -16px 16px;
    padding: 0 16px 8px;
    border-bottom: 1px solid var(--line);
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { display: inline-flex !important; padding: 10px 14px !important; font-size: 13px !important; flex: 0 0 auto !important; }

  /* Sidebar layout collapses to tabs on mobile */
  .detail.layout-sidebar { grid-template-columns: 1fr !important; }
  .detail.layout-sidebar .sidenav {
    display: flex; flex-direction: row;
    overflow-x: auto; white-space: nowrap;
    margin: 0 -16px 16px; padding: 0 16px 8px;
    border-bottom: 1px solid var(--line); border-right: none !important;
    scrollbar-width: none;
  }
  .detail.layout-sidebar .sidenav::-webkit-scrollbar { display: none; }
  .detail.layout-sidebar .sidenav .tab { padding: 10px 14px; }

  /* Long-scroll layout: tighten section headers */
  .section-h { font-size: 16px !important; padding-top: 16px; }

  /* Votes summary */
  .vote-chart { padding: 14px !important; }
  .vote-chart h4 { font-size: 13px !important; }
  .legend { font-size: 10.5px; gap: 12px; flex-wrap: wrap; }
  .bars-row { grid-template-columns: 1fr !important; gap: 4px !important; }
  .bars-row .lab { font-size: 12px; }
  .heat-row { grid-template-columns: 1fr !important; gap: 4px !important; }
  .heat-cells { font-size: 9px; }
  .dots-grid { grid-template-columns: repeat(10, 1fr) !important; }

  /* Votes toolbar wraps */
  .votes-toolbar {
    flex-wrap: wrap !important;
    gap: 8px !important;
  }
  .search-mini { flex: 1 1 100%; min-width: 0; }
  .search-mini input { font-size: 14px; }
  .seg { flex: 1 1 auto; overflow-x: auto; }
  .seg button { padding: 6px 10px; font-size: 12px; }
  .sel { font-size: 13px !important; min-width: 0; }

  /* Vote row: stack */
  .vote-row {
    grid-template-columns: auto 1fr !important;
    gap: 10px 12px !important;
    padding: 12px 0 !important;
    align-items: start !important;
  }
  .vote-row > div:last-child {
    grid-column: 1 / -1;
    text-align: left !important;
    display: flex; gap: 12px; align-items: center;
    padding-left: 56px;
  }
  .vote-row .src-mini { margin-top: 0; }
  .vote-title { font-size: 14px !important; line-height: 1.4; }
  .vote-meta { font-size: 11px !important; flex-wrap: wrap; gap: 6px !important; }
  .icon-stack { gap: 6px !important; }
  .pdot { width: 22px !important; height: 22px !important; font-size: 11px !important; }
  .leg { font-size: 9px !important; }

  /* List rows (amendments, gov laws, local) */
  .list-row {
    grid-template-columns: 1fr !important;
    gap: 4px !important;
    padding: 12px 0 !important;
  }
  .list-row .date { font-size: 11px; color: var(--ink-3); }
  .list-row .title { font-size: 14px !important; line-height: 1.4; }
  .list-row .status { justify-self: start; margin-top: 4px; }

  /* Statements timeline */
  .timeline { padding-left: 0; }
  .stmt { grid-template-columns: 36px 1fr !important; gap: 12px !important; }
  .stmt-glyph { width: 32px !important; height: 32px !important; font-size: 12px !important; }
  .stmt-title { font-size: 15px !important; line-height: 1.35; }
  .stmt-excerpt { font-size: 13px !important; }
  .stmt-meta { font-size: 10.5px !important; flex-wrap: wrap; gap: 6px !important; }

  /* Program tab on mobile */
  .program-head { padding: 14px 16px; border-radius: 12px; }
  .program-title { font-size: 20px; }
  .promise { grid-template-columns: 1fr; gap: 8px; padding: 12px; }
  .promise .pst { justify-self: start; }
  .promise-text { font-size: 13.5px; }

  /* Alignment banner stack */
  .shell > div[style*="Aligné"] { padding: 12px 14px !important; gap: 8px !important; flex-direction: column !important; align-items: flex-start !important; }

  /* Related people: single column */
  .results { grid-template-columns: 1fr !important; gap: 8px !important; }

  /* Modal: full-screen sheet */
  .modal-bg { padding: 0 !important; align-items: flex-end !important; }
  .modal {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 92vh !important;
    border-radius: 18px 18px 0 0 !important;
    padding: 18px 18px 32px !important;
    overflow-y: auto;
  }
  .modal h2 { font-size: 20px !important; line-height: 1.2; margin: 6px 0 10px !important; }
  .modal-text { font-size: 14px !important; }
  .modal-meta { font-size: 12px !important; flex-wrap: wrap; gap: 6px !important; }
  .position-grid { grid-template-columns: 1fr !important; gap: 10px !important; }

  /* ── Search screen on mobile ── */
  .topbar { padding: 12px 16px !important; gap: 8px !important; flex-wrap: wrap; }
  .topbar .logo { font-size: 16px !important; }
  .search-main { flex: 1 1 100%; }
  .search-main input { font-size: 16px !important; padding: 12px 16px 12px 40px !important; }

  .filters-bar {
    flex-wrap: wrap !important;
    gap: 6px !important;
    padding: 10px 16px !important;
  }
  .filters-bar select, .filters-bar .chip {
    font-size: 12px !important; padding: 6px 10px !important;
  }

  /* Result cards: single column */
  .results, .results-grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
    padding: 12px 16px !important;
  }
  .card { padding: 14px !important; }
  .card .name { font-size: 16px !important; }
  .card .meta { font-size: 12px !important; }

  /* Tweaks panel: bottom-sheet style */
  .tp-panel {
    position: fixed !important;
    inset: auto 0 0 0 !important;
    width: 100% !important;
    max-height: 70vh !important;
    border-radius: 18px 18px 0 0 !important;
    overflow-y: auto;
  }
}

/* Touch target floor (anywhere small) */
@media (hover: none) and (pointer: coarse) {
  .btn, .tab, .seg button, .chip, .src-link-strong {
    min-height: 38px;
  }
}

/* Larger phones / tablets — sweet spot adjustments */
@media (min-width: 480px) and (max-width: 720px) {
  .stats-strip { grid-template-columns: repeat(4, 1fr) !important; }
  .profile-head { grid-template-columns: 100px 1fr !important; text-align: left !important; }
  .profile-head .photo { width: 100px !important; height: 100px !important; margin: 0 !important; }
  .profile-head h1,
  .profile-head .subline,
  .profile-head .mandate-line { text-align: left !important; }
  .profile-head .subline { justify-content: flex-start; }
  .profile-head .actions { grid-column: 1 / -1; justify-content: flex-start; }
}
