/* =============================================================================
   Alex Bores Bills, Components
   -----------------------------------------------------------------------------
   Reusable, framework-free component classes built on tokens.css.
   Patterns drawn from parvmahajan.com (typography, links, prose, footer) and
   parvmahajan.com/petri (controls, chips, segmented toggle, cards, tables).
   Load order:  tokens.css  →  components.css
   ============================================================================= */

/* ---- Reset / base ---------------------------------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-weight: var(--fw-light);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  font-feature-settings: var(--font-features);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

:where(:focus-visible) {
  outline: var(--focus-ring);
  outline-offset: var(--focus-offset);
  border-radius: var(--radius-sm);
}

::selection { background: var(--accent-tint); color: var(--ink); }

/* ---- Layout helpers -------------------------------------------------------- */
.container       { max-width: var(--measure-max);  margin-inline: auto; padding-inline: var(--gutter); }
.container--wide { max-width: var(--measure-wide); margin-inline: auto; padding-inline: var(--gutter); }
.container--prose{ max-width: var(--measure-prose);margin-inline: auto; padding-inline: var(--gutter); }
.stack > * + *   { margin-top: var(--space-4); }
.section         { padding-block: var(--space-8); }

/* ===========================================================================
   Typography
   =========================================================================== */
.h-display { font-weight: var(--fw-bold); font-size: var(--fs-display); line-height: var(--lh-tight); letter-spacing: var(--tracking-tight); color: var(--ink); margin: 0; }
h1, .h1    { font-weight: var(--fw-bold); font-size: var(--fs-h1);      line-height: var(--lh-tight); letter-spacing: var(--tracking-tight); color: var(--ink); margin: 0; }
h2, .h2    { font-weight: var(--fw-bold); font-size: var(--fs-h2);      line-height: var(--lh-snug);  color: var(--ink); margin: 0; }
h3, .h3    { font-weight: var(--fw-bold); font-size: var(--fs-h3);      line-height: var(--lh-snug);  color: var(--ink); margin: 0; }

.lead     { font-size: var(--fs-lg); color: var(--ink-soft); }
.subtitle { font-size: var(--fs-sm); color: var(--ink-soft); margin: 0; }
.meta     { font-size: var(--fs-meta); color: var(--ink-muted); letter-spacing: var(--tracking-wide); }
.muted    { color: var(--ink-muted); }
.faint    { color: var(--ink-faint); }
.italic   { font-style: italic; }
.tnum     { font-variant-numeric: tabular-nums; }

/* uppercase micro-label (control captions, eyebrows) */
.label, .control-label {
  display: inline-block;
  font-size: var(--fs-micro);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  color: var(--ink-faint);
}

/* dot separator used between inline meta items */
.dot { color: var(--ink-faint); opacity: 0.7; margin-inline: var(--space-1); }

/* ===========================================================================
   Links
   --------------------------------------------------------------------------
   Signature blog behavior: no underline at rest; an underline grows in on
   hover (fast) and recedes slowly. In-prose links stay underlined for clarity.
   =========================================================================== */
a { color: var(--ink); text-decoration: none; }

.link {
  color: var(--ink);
  border-bottom: 1px solid transparent;
  padding-bottom: 1px;
  transition: border-color var(--t-med);
}
.link:hover { border-bottom-color: currentColor; transition: border-color var(--t-slow); }

.link-muted { color: var(--ink-muted); }
.link-accent { color: var(--accent); }

/* ===========================================================================
   Buttons
   =========================================================================== */
.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 36px;
  padding-inline: var(--space-4);
  font: inherit;
  font-size: var(--fs-xs);
  line-height: 1;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-pill);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.btn:hover { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.btn--primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn--primary:hover { background: var(--accent); border-color: var(--accent); }

.btn--ghost { border-color: transparent; }
.btn--ghost:hover { background: var(--hover); color: var(--ink); }

.btn--sm { height: 30px; font-size: var(--fs-xs); padding-inline: var(--space-3); }
.btn .icon { flex: 0 0 auto; width: 1em; height: 1em; }

/* icon-only button (e.g. save/bookmark) */
.icon-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  border: none; background: transparent;
  color: var(--ink-faint);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}
.icon-btn:hover { background: var(--hover); color: var(--ink); }

/* ===========================================================================
   Segmented control (sort / session switcher)
   =========================================================================== */
.seg {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  height: 36px;
  background: var(--bg);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-pill);
}
.seg-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: var(--fs-xs);
  line-height: 1;
  padding-inline: var(--space-4);
  border-radius: var(--radius-pill);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  transition: background var(--t-fast), color var(--t-fast);
}
.seg-btn:hover { color: var(--ink); }
.seg-btn.is-active { background: var(--ink); color: var(--bg); }

/* ===========================================================================
   Chips (multi-select filters, with optional colored swatch)
   =========================================================================== */
.chip {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: 32px;
  padding: 0 var(--space-4) 0 var(--space-3);
  font: inherit;
  font-size: var(--fs-xs);
  line-height: 1;
  color: var(--ink-soft);
  background: var(--bg);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast), opacity var(--t-fast);
}
.chip:hover { background: var(--hover); }
.chip.is-active { color: var(--ink); border-color: var(--ink); background: var(--bg); }
.chip:not(.is-active) { opacity: 0.55; }
.chip .swatch { width: 10px; height: 10px; border-radius: var(--radius-pill); background: var(--swatch, var(--ink)); }

/* ===========================================================================
   Inputs
   =========================================================================== */
.input, input[type="search"], input[type="text"], select {
  appearance: none;
  height: 36px;
  width: 100%;
  min-width: 200px;
  padding-inline: var(--space-4);
  font: inherit;
  font-size: var(--fs-meta);
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-pill);
  outline: none;
  transition: border-color var(--t-fast);
}
.input::placeholder, input::placeholder { color: var(--ink-faint); }
.input:focus, input:focus, select:focus { border-color: var(--accent); }

/* a labeled control column (matches petri's control-group) */
.control-group { display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; }
.control-group--grow { flex: 1 1 200px; }

/* ===========================================================================
   Masthead + sticky controls bar
   =========================================================================== */
.masthead {
  border-bottom: 1px solid var(--rule);
  padding: var(--space-7) var(--gutter) var(--space-6);
}
.masthead-inner {
  max-width: var(--measure-wide);
  margin-inline: auto;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: var(--space-6);
  flex-wrap: wrap;
}

.controls {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--rule);
  padding: var(--space-4) var(--gutter);
}
.controls-inner {
  max-width: var(--measure-wide);
  margin-inline: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-5);
}

/* ===========================================================================
   Status badges (bill stages), small dot + label, optional tinted pill
   Use:  <span class="badge badge--enacted"><i class="badge-dot"></i> Enacted</span>
   =========================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: 22px;
  padding-inline: var(--space-3);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  line-height: 1;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: var(--radius-pill);
  white-space: nowrap;
}
.badge-dot { width: 7px; height: 7px; border-radius: var(--radius-pill); background: var(--ink-faint); flex: 0 0 auto; }

.badge--enacted   { color: var(--st-enacted);   background: var(--st-enacted-tint);   border-color: transparent; }
.badge--enacted   .badge-dot { background: var(--st-enacted); }
.badge--passed    { color: var(--st-passed);    background: var(--st-passed-tint);    border-color: transparent; }
.badge--passed    .badge-dot { background: var(--st-passed); }
.badge--progress  { color: var(--st-progress);  background: var(--st-progress-tint);  border-color: transparent; }
.badge--progress  .badge-dot { background: var(--st-progress); }
.badge--committee { color: var(--st-committee); background: var(--st-committee-tint); border-color: transparent; }
.badge--committee .badge-dot { background: var(--st-committee); }
.badge--stricken  { color: var(--st-stricken);  background: var(--st-stricken-tint);  border-color: transparent; }
.badge--stricken  .badge-dot { background: var(--st-stricken); }

/* ===========================================================================
   Cards
   =========================================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-card);
  padding: var(--space-5);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.card:hover { border-color: var(--rule-strong); box-shadow: var(--shadow-1); }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); margin-bottom: var(--space-2); }
.card-title { font-size: var(--fs-sm); font-weight: var(--fw-semibold); line-height: var(--lh-snug); letter-spacing: -0.005em; color: var(--ink); }
.card-axis  { font-size: var(--fs-micro); color: var(--ink-faint); letter-spacing: 0.04em; font-variant-numeric: tabular-nums; white-space: nowrap; }

.grid {
  display: grid;
  gap: var(--space-5);
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
}

/* ---- Bill card (project-specific composition) ----------------------------- */
.bill-card { display: flex; flex-direction: column; gap: var(--space-3); }
.bill-card .bill-no {
  font-size: var(--fs-meta);
  font-weight: var(--fw-semibold);
  font-variant-numeric: tabular-nums;
  letter-spacing: var(--tracking-wide);
  color: var(--ink);
}
.bill-card .bill-title { font-size: var(--fs-sm); color: var(--ink-soft); line-height: var(--lh-snug); }
.bill-card .bill-summary { font-size: var(--fs-meta); color: var(--ink-body); }
.bill-card .bill-foot { display: flex; align-items: center; gap: var(--space-3); margin-top: auto; padding-top: var(--space-2); }

/* ===========================================================================
   Bill list (dense, scannable rows, the primary index view)
   =========================================================================== */
.bill-list { list-style: none; margin: 0; padding: 0; }
.bill-list li { border-top: 1px solid var(--rule); }
.bill-list li:last-child { border-bottom: 1px solid var(--rule); }
.bill-row {
  display: grid;
  grid-template-columns: 5.5rem 1fr auto;
  align-items: baseline;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-2);
  transition: background var(--t-fast);
}
.bill-row:hover { background: var(--hover); }
.bill-row .bill-no { font-variant-numeric: tabular-nums; font-weight: var(--fw-semibold); font-size: var(--fs-meta); color: var(--ink); }
.bill-row .bill-main .t { color: var(--ink); }
.bill-row .bill-main .s { display: block; color: var(--ink-muted); font-size: var(--fs-meta); margin-top: 2px; }
.bill-row .bill-status { justify-self: end; }

@media (max-width: 700px) {
  .bill-row { grid-template-columns: 1fr; gap: var(--space-2); }
  .bill-row .bill-status { justify-self: start; }
}

/* ===========================================================================
   Prose (bill detail body / long-form), from the blog post styles
   =========================================================================== */
.prose { max-width: var(--measure-prose); color: var(--ink-body); line-height: var(--lh-prose); }
.prose > * + * { margin-top: var(--space-4); }
.prose h2 { margin-top: var(--space-6); margin-bottom: calc(-1 * var(--space-1)); }
.prose h3 { margin-top: var(--space-5); margin-bottom: calc(-1 * var(--space-2)); }
.prose a { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; }
.prose a:hover { color: var(--accent); }
.prose ul, .prose ol { padding-left: var(--space-5); }
.prose li + li { margin-top: var(--space-2); }
.prose strong { font-weight: var(--fw-semibold); }

.prose blockquote {
  border-left: 3px solid var(--ink);
  padding-left: var(--space-4);
  color: var(--ink-soft);
  font-style: italic;
}
.prose code { background: var(--code-bg); padding: 0.2em 0.4em; border-radius: var(--radius-code); font-family: var(--font-mono); font-size: 0.9em; }
.prose pre  { background: var(--code-bg); padding: var(--space-4); border-radius: var(--radius-code); overflow-x: auto; }
.prose pre code { background: none; padding: 0; }
.prose hr { border: none; border-top: 1px solid var(--rule-strong); opacity: 0.5; margin-block: var(--space-6); }

/* ===========================================================================
   Tables (status/data), from petri + blog
   =========================================================================== */
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-meta); }
.table th, .table td { border: 1px solid var(--rule); padding: var(--space-2) var(--space-3); text-align: left; vertical-align: top; }
.table th { font-weight: var(--fw-semibold); background: var(--surface-warm); color: var(--ink); }
.table td { color: var(--ink-body); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* compact key/value fact box (bill metadata) */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: var(--space-2) var(--space-5); font-size: var(--fs-meta); }
.facts dt { color: var(--ink-faint); }
.facts dd { margin: 0; color: var(--ink-body); }

/* ===========================================================================
   Footer
   =========================================================================== */
.site-footer {
  max-width: var(--measure-wide);
  margin: var(--space-9) auto 0;
  padding: var(--space-6) var(--gutter);
  border-top: 1px solid var(--rule);
  color: var(--ink-muted);
  font-size: var(--fs-meta);
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}
.site-footer a { color: var(--ink-soft); border-bottom: 1px solid var(--rule-strong); transition: color var(--t-fast), border-color var(--t-fast); }
.site-footer a:hover { color: var(--ink); border-bottom-color: var(--ink); }

/* ===========================================================================
   Theme toggle (the blog's pill switch)
   =========================================================================== */
.theme-toggle {
  position: relative;
  width: 44px; height: 24px;
  padding: 2px;
  border: none;
  border-radius: var(--radius-pill);
  background: #888;
  cursor: pointer;
  transition: background var(--t-med);
}
.theme-toggle::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 20px; height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--t-med);
}
[data-theme="dark"] .theme-toggle { background: #555; }
[data-theme="dark"] .theme-toggle::after { transform: translateX(20px); }

/* ===========================================================================
   Section divider (spaced dots, from the blog)
   =========================================================================== */
.section-divider { margin-block: var(--space-6); letter-spacing: 0.5em; color: var(--ink-faint); text-align: center; }

/* ---- Responsive ----------------------------------------------------------- */
@media (max-width: 700px) {
  .masthead { padding: var(--space-6) var(--gutter) var(--space-4); }
  .grid { grid-template-columns: 1fr; }
}
