/* Follow the Bill — design tokens (v2)
   A civic-register/gazette identity: dark masthead like an official
   letterhead, paper-white body, one red rule underneath (flag red, used
   with intent, not decoration), plus a small numbered seal instead of
   an emoji mark. */
:root {
  --ink: #11182b;
  --ink-soft: #4b5a72;
  --ink-faint: #8b96a6;
  --paper: #ffffff;
  --surface: #eef1f5;
  --line: #d7dbe2;
  --on-dark: #f4f6fa;
  --on-dark-soft: #a9b3c6;

  --red: #c8102e;
  --green: #1e7a4c;
  --amber: #a6742c;
  --gold: #9c6f0b;

  --serif: "Source Serif 4", Georgia, serif;
  --sans: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
}
html { scroll-behavior: smooth; }

a { color: var(--ink); }
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--red);
  outline-offset: 2px;
}

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1.25rem 4rem;
}

/* Masthead: dark letterhead band + a single red rule, not a thin grey line */
.masthead {
  background: var(--ink);
  color: var(--on-dark);
  border-bottom: 3px solid var(--red);
  padding: 1.4rem 1.25rem 1.1rem;
}
.masthead-row {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.wordmark {
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--on-dark);
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}
.seal {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  border: 1.5px solid var(--on-dark);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  font-size: 0.85rem;
  font-weight: 600;
  flex-shrink: 0;
}
.masthead-right {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.masthead-session {
  font-size: 0.8rem;
  color: var(--on-dark-soft);
  white-space: nowrap;
}
.masthead-actions {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  padding-left: 1.1rem;
  border-left: 1px solid rgba(244, 246, 250, 0.18);
}
.nav-link {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--on-dark-soft);
  text-decoration: none;
  padding-bottom: 2px;
  border-bottom: 2px solid transparent;
}
.nav-link:hover { color: var(--on-dark); }
.nav-link.is-active { color: var(--on-dark); border-bottom-color: var(--red); }
.nav-link--button {
  padding: 0.4rem 0.75rem;
  border: 1px solid rgba(244, 246, 250, 0.35);
  border-radius: 2px;
}
.nav-link--button:hover { border-color: var(--on-dark); background: rgba(244, 246, 250, 0.08); }
.masthead-user {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.8rem;
  color: var(--on-dark-soft);
  white-space: nowrap;
}
.user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--red);
  color: var(--on-dark);
  font-family: var(--serif);
  font-size: 0.7rem;
  font-weight: 600;
  flex-shrink: 0;
}
.masthead-tag {
  max-width: 1200px;
  margin: 0.9rem auto 0;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(244, 246, 250, 0.14);
  color: var(--on-dark-soft);
  font-size: 1rem;
}
.back-link {
  display: inline-block;
  max-width: 1200px;
  margin: 0.9rem auto 0;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(244, 246, 250, 0.14);
  font-size: 0.9rem;
  color: var(--on-dark-soft);
  background: none;
  border-left: none;
  border-right: none;
  border-bottom: none;
  cursor: pointer;
  font-family: inherit;
}
.back-link:hover { color: var(--on-dark); }

/* List controls + search */
.list-controls {
  margin-top: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.list-controls label {
  font-size: 0.85rem;
  color: var(--ink-soft);
}
.list-controls input[type="search"] {
  font: inherit;
  font-size: 1rem;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--surface);
  color: var(--ink);
}

/* Status / loading / errors */
.status {
  color: var(--ink-soft);
  font-size: 0.95rem;
  margin: 1.5rem 0;
}
.field-error {
  color: var(--red);
  font-size: 0.9rem;
  margin: 0.5rem 0 0;
}

/* Status filter pills */
.filters {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 1.1rem 0 0;
}
.filter-pill {
  font: inherit;
  font-size: 0.82rem;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink-soft);
  border-radius: 999px;
  cursor: pointer;
}
.filter-pill.is-active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.filter-pill:not(.is-active):hover { background: var(--surface); color: var(--ink); }

/* Two-column homepage: search + list on the left, status filters on the right */
.index-wrap { max-width: 1040px; }

.index-layout {
  display: grid;
  grid-template-columns: 1fr 240px;
  gap: 2.5rem;
  align-items: start;
}

.index-sidebar {
  position: sticky;
  top: 1.5rem;
}

.sidebar-heading {
  font-family: var(--serif);
  font-size: 1rem;
  color: var(--ink-soft);
  margin: 2rem 0 0.9rem;
}

.index-sidebar .filters {
  flex-direction: column;
  gap: 0.4rem;
  margin: 0;
}

.index-sidebar .filter-pill {
  width: 100%;
  text-align: left;
  border-radius: 2px;
}

/* Status filter as a dropdown -- swapped in for the pill list on phones and
   tablets (see the media query below), where a column of a dozen-plus pills
   would push the actual bill list off the first screen. */
.status-select {
  display: none;
  width: 100%;
  font: inherit;
  font-size: 0.9rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--paper);
  color: var(--ink);
}

@media (max-width: 780px) {
  .index-layout { grid-template-columns: 1fr; gap: 1.5rem; }
  .index-sidebar { position: static; order: -1; }
  .index-main { order: 1; }
  .index-sidebar .filters { display: none; }
  .status-select:not([hidden]) { display: block; }
}

/* Gazette bill list */
.gazette {
  list-style: none;
  margin: 1.5rem 0 0;
  padding: 0;
  border-top: 1px solid var(--line);
}
.gazette-item { border-bottom: 1px solid var(--line); }
.gazette-item a {
  display: grid;
  grid-template-columns: 3.5rem 1fr;
  align-items: start;
  gap: 1rem;
  padding: 1.1rem 0.25rem;
  text-decoration: none;
  color: var(--ink);
}
.gazette-item a:hover .gazette-title { text-decoration: underline; }
.gazette-code {
  font-family: var(--serif);
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--ink);
}
.gazette-title {
  font-family: var(--serif);
  font-size: 1.15rem;
  line-height: 1.35;
}
.gazette-meta {
  font-size: 0.8rem;
  color: var(--ink-soft);
  margin-top: 0.3rem;
}
.gazette-empty { padding: 2rem 0.25rem; color: var(--ink-soft); }

/* Bookmarks page: same row, plus a remove button */
.gazette-item--bookmark {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.gazette-item--bookmark a { flex: 1; }
.bookmark-remove {
  flex-shrink: 0;
  font: inherit;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink-soft);
  border-radius: 2px;
  cursor: pointer;
}
.bookmark-remove:hover { background: var(--surface); color: var(--red); border-color: var(--red); }

/* Bill article */
.bill-heading {
  margin-top: 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.bill-code { font-family: var(--serif); font-size: 1.1rem; color: var(--ink-soft); }
.bill-heading-actions { display: flex; align-items: center; gap: 0.75rem; }
.bookmark-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font: inherit;
  font-size: 0.85rem;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink-soft);
  border-radius: 2px;
  cursor: pointer;
}
.bookmark-btn:hover { background: var(--surface); color: var(--ink); }
.bookmark-btn.is-saved { color: var(--paper); background: var(--ink); border-color: var(--ink); }
.bookmark-btn.is-saved svg { fill: currentColor; }
.lang-toggle { display: flex; gap: 0.4rem; }
.lang-btn {
  font: inherit;
  font-size: 0.85rem;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink-soft);
  border-radius: 2px;
  cursor: pointer;
}
.lang-btn.is-active { color: var(--paper); background: var(--ink); border-color: var(--ink); }
.lang-btn:not(.is-active):hover { background: var(--surface); color: var(--ink); }

/* Description / Financial analytics tabs */
.section-tabs {
  display: flex;
  gap: 0.5rem;
  border-bottom: 2px solid var(--line);
  margin: 0 0 1.75rem;
}
.tab-btn {
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.7rem 1.1rem 0.65rem;
  border: none;
  background: none;
  color: var(--ink-soft);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}
.tab-btn:hover { color: var(--ink); background: none; }  /* override the global dark button:hover */
.tab-btn.is-active { color: var(--ink); border-bottom-color: var(--red); }
.tab-panel { max-width: 68ch; }

h1 { font-family: var(--serif); font-size: 2rem; line-height: 1.25; margin: 0.4rem 0 1.5rem; }
h2 { font-family: var(--serif); font-size: 1.3rem; margin: 2.2rem 0 0.8rem; }

.tldr {
  margin: 0 0 1.5rem;
  padding-left: 1.1rem;
  border-left: 3px solid var(--red);
  font-family: var(--serif);
  font-size: 1.2rem;
  color: var(--ink);
  max-width: 62ch;
}
.summary { max-width: 68ch; color: var(--ink); white-space: pre-line; }
.changes { max-width: 68ch; padding-left: 1.2rem; }
.changes li { margin-bottom: 0.5rem; }
.source-line { margin-top: 2rem; font-size: 0.85rem; color: var(--ink-faint); }
.source-line a { color: var(--ink-soft); }

/* Listen button: reads the summary aloud (ElevenLabs) */
.listen {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 0.9rem;
  margin: 0 0 1.25rem;
}
.listen-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  border-radius: 2px;
  cursor: pointer;
}
.listen-btn:hover { background: var(--surface); }
.listen-btn:focus-visible { outline: 3px solid var(--red); outline-offset: 2px; }
.listen-btn:disabled { cursor: progress; opacity: 0.6; }
.listen-status { font-size: 0.85rem; color: var(--ink-soft); }
.listen audio { width: 100%; max-width: 28rem; }

/* Official summary from Parliament: collapsed by default (can be very long) */
.official-summary {
  max-width: 68ch;
  margin-top: 2rem;
  border-top: 1px solid var(--line);
  padding-top: 1rem;
}
.official-summary summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--ink-soft);
}
.official-summary summary:hover { color: var(--ink); }
.official-summary summary:focus-visible { outline: 3px solid var(--red); outline-offset: 2px; }
.official-summary p { color: var(--ink); font-size: 0.95rem; }

/* Bill description */
#description-text { max-width: 68ch; color: var(--ink); }

/* Financial analysis: holdings table */
#holdings-table-wrap { margin-top: 1.5rem; max-width: 66ch; overflow-x: auto; -webkit-overflow-scrolling: touch; }
#holdings-table-wrap h3 {
  font-family: var(--serif);
  font-size: 1.05rem;
  margin: 0 0 0.6rem;
}
#holdings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
#holdings-table th, #holdings-table td {
  text-align: left;
  padding: 0.55rem 0.6rem;
  border-bottom: 1px solid var(--line);
}
#holdings-table th {
  font-weight: 600;
  color: var(--ink-soft);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* Conflict of interest: disclaimer banner */
.coi-disclaimer {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  max-width: 66ch;
  margin: 0 0 1.1rem;
  padding: 0.8rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-soft);
}
.coi-disclaimer svg { flex-shrink: 0; margin-top: 0.15rem; }
.coi-disclaimer p { margin: 0; font-size: 0.8rem; line-height: 1.5; }

/* Conflict of interest: sectors line */
.sector-line {
  font-size: 0.85rem;
  color: var(--ink-soft);
  max-width: 66ch;
  margin: 0 0 1rem;
}
.sector-line strong { color: var(--ink); font-weight: 600; }

/* Companies & market impact */
.company-note {
  font-size: 0.85rem;
  color: var(--ink-soft);
  max-width: 66ch;
  margin: -0.3rem 0 1rem;
}
.company-list { list-style: none; margin: 0; padding: 0; max-width: 66ch; }
.company-row {
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.company-row:last-child { border-bottom: none; }
.company-name { font-weight: 600; }
.company-ticker {
  font-family: var(--serif);
  font-size: 0.85rem;
  color: var(--ink-soft);
}
.company-price { font-size: 0.9rem; margin-left: auto; white-space: nowrap; }
.company-price.up { color: var(--green); }
.company-price.down { color: var(--red); }
.company-sector {
  font-size: 0.78rem;
  color: var(--ink-soft);
  background: var(--surface);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
}
.conflict-flag {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  width: 100%;
  font-size: 0.82rem;
  color: var(--gold);
  margin-top: 0.3rem;
}
.conflict-flag strong { font-weight: 600; }
.conflict-cta {
  margin-left: auto;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--paper);
  background: var(--ink);
  padding: 0.3rem 0.7rem;
  border-radius: 2px;
  text-decoration: none;
  white-space: nowrap;
}
.conflict-cta:hover { background: #060b17; }

/* Step sections */
.step { margin-top: 2.5rem; padding-top: 2rem; border-top: 1px solid var(--line); }
.inline-form { display: flex; align-items: end; gap: 0.75rem; flex-wrap: wrap; }
.inline-form label { font-size: 0.85rem; color: var(--ink-soft); display: block; margin-bottom: 0.3rem; }
.inline-form input {
  font: inherit;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--surface);
  min-width: 10rem;
}

button, .btn {
  font: inherit;
  font-size: 0.95rem;
  padding: 0.6rem 1.1rem;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  border-radius: 2px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
button:hover, .btn:hover { background: #060b17; }
.btn-quiet { background: var(--paper); color: var(--ink); border-color: var(--line); }
.btn-quiet:hover { background: var(--surface); }

.mp-card { margin-top: 1.25rem; display: flex; gap: 1rem; align-items: center; }
.mp-photo { width: 3rem; height: 3rem; border-radius: 50%; background: var(--surface); border: 1px solid var(--line); flex-shrink: 0; }
.mp-name { font-weight: 600; margin: 0; }
.mp-meta { margin: 0.15rem 0 0; color: var(--ink-soft); font-size: 0.9rem; }

.letter-form { display: flex; flex-direction: column; gap: 0.9rem; max-width: 42rem; }
.letter-form fieldset { border: none; padding: 0; margin: 0; display: flex; gap: 1.25rem; flex-wrap: wrap; }
.letter-form legend { font-size: 0.85rem; color: var(--ink-soft); padding: 0; margin-bottom: 0.4rem; }
.radio { font-size: 0.95rem; display: flex; align-items: center; gap: 0.4rem; }
.letter-form label:not(.radio) { font-size: 0.85rem; color: var(--ink-soft); }
.letter-form textarea, .letter-form input[type="text"] {
  font: inherit;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--surface);
  resize: vertical;
}
.letter-form button { align-self: start; margin-top: 0.3rem; }

.letter-paper { margin-top: 1.5rem; padding: 1.75rem; background: var(--surface); border: 1px solid var(--line); max-width: 42rem; }
.letter-subject { margin: 0 0 1rem; }
.letter-body { font-family: var(--serif); font-size: 1.02rem; white-space: pre-wrap; margin: 0 0 1.25rem; }
.letter-actions { display: flex; gap: 0.6rem; }

.site-footer {
  max-width: 720px;
  margin: 3rem auto 0;
  padding: 1.25rem;
  border-top: 1px solid var(--line);
  color: var(--ink-faint);
  font-size: 0.8rem;
}

/* Phone-width tightening: masthead stacking, single-column headings, and
   letting anything genuinely too wide (the lobbying table) scroll on its
   own instead of squeezing the whole page. */
@media (max-width: 640px) {
  .wrap, .index-wrap { padding: 0 1rem 3rem; }
  .masthead { padding: 1.1rem 1rem 1rem; }

  .masthead-row { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
  .masthead-right { width: 100%; flex-direction: column; align-items: flex-start; gap: 0.65rem; }
  .masthead-actions {
    width: 100%;
    flex-wrap: wrap;
    border-left: none;
    padding-left: 0;
    padding-top: 0.65rem;
    border-top: 1px solid rgba(244, 246, 250, 0.14);
  }
  .masthead-tag, .back-link { font-size: 0.88rem; }

  h1 { font-size: 1.55rem; }

  .bill-heading { flex-direction: column; align-items: flex-start; gap: 0.85rem; }
  .bill-heading-actions { width: 100%; justify-content: space-between; }

  .section-tabs { gap: 0.15rem; }
  .tab-btn { font-size: 0.85rem; padding: 0.6rem 0.75rem 0.55rem; }

  #holdings-table { min-width: 480px; }

  .letter-paper { padding: 1.15rem; }
  .letter-actions { flex-wrap: wrap; }
  .company-price { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  html { scroll-behavior: auto; }
}
