/* ==========================================================================
   Trump District — base styles and components
   Requires tokens.css. All classes are prefixed td-.
   ========================================================================== */

/* ---- Base ---------------------------------------------------------------- */

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

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-body);
  line-height: var(--leading-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

[data-theme] { color: var(--text); }

h1, h2, h3, h4, p, figure, blockquote, ul, ol, dl, dd { margin: 0; }
ul[class], ol[class] { padding: 0; list-style: none; }
img, svg, video { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }

a {
  color: var(--link);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
::selection { background: var(--highlight); color: var(--highlight-text); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---- Type ---------------------------------------------------------------- */

.td-hero-title, .td-display, .td-h2, .td-h3, .td-h4 {
  font-family: var(--font-display);
  font-weight: 400;
  text-wrap: balance;
}
.td-hero-title { font-size: var(--text-hero); line-height: 0.92; letter-spacing: var(--tracking-heading); }
.td-display    { font-size: var(--text-display); line-height: var(--leading-display); letter-spacing: var(--tracking-display); }
.td-h2         { font-size: var(--text-h2); line-height: var(--leading-heading); letter-spacing: var(--tracking-display); }
.td-h3         { font-size: var(--text-h3); line-height: var(--leading-heading); letter-spacing: var(--tracking-heading); }
.td-h4         { font-size: var(--text-h4); line-height: 1.2; letter-spacing: -0.01em; }

.td-lead {
  font-size: var(--text-lead);
  line-height: 1.5;
  letter-spacing: -0.01em;
  color: var(--text-secondary);
  text-wrap: pretty;
}
.td-body-lg { font-size: var(--text-body-lg); line-height: 1.5; }
.td-small   { font-size: var(--text-sm); line-height: 1.43; }
.td-caption { font-size: var(--text-xs); line-height: 1.5; color: var(--text-muted); }
.td-mono    { font-family: var(--font-mono); font-size: var(--text-sm); line-height: 1.43; }
.td-eyebrow {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.5;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--text-secondary);
}

/* ---- Layout -------------------------------------------------------------- */

.td-container {
  width: min(100% - 2 * var(--gutter), var(--width-content));
  margin-inline: auto;
}
.td-container--wide { width: min(100% - 2 * var(--gutter), var(--width-wide)); }
.td-container--text { width: min(100% - 2 * var(--gutter), var(--width-text)); }

.td-section { padding-block: var(--section); }
.td-rule { margin: 0; border: 0; border-top: 1px solid var(--border-strong); }

/* ---- Disclosure banner --------------------------------------------------- */
/* Sits where the reference sites put "An official website of the United
   States government". Here it says the opposite, on every page. */

.td-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 2.5rem;
  padding: var(--space-2) var(--gutter);
  background: var(--bg-sunken);
  color: var(--text-secondary);
  font-size: 0.8125rem;
  line-height: 1.4;
  text-align: center;
}
.td-banner__flag {
  flex: none;
  width: 1.375rem;
  height: auto;
  border-radius: 2px;
  box-shadow: 0 0 0 1px var(--border);
}

/* ---- Nav and wordmark ---------------------------------------------------- */

.td-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(16px);
  backdrop-filter: saturate(1.4) blur(16px);
}
.td-nav__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-height: 4.5rem;
}
.td-nav__links { display: flex; align-items: center; gap: var(--space-1); }
.td-nav__link {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: 500;
  text-decoration: none;
  transition: background-color var(--duration-fast);
}
.td-nav__link:hover { background: var(--chip); }
@media (max-width: 44rem) { .td-nav__link { display: none; } }

.td-wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 1.625rem;
  line-height: 1;
  letter-spacing: -0.02em;
  text-decoration: none;
  white-space: nowrap;
}
.td-wordmark em { font-style: italic; }
/* The gold D.C. emblem (assets/logo/, built by tools/build_logo.py): the
   ivory cut by default, the brighter cut on midnight. */
.td-wordmark__mark { flex: none; height: 2.25rem; width: auto; }
.td-wordmark__mark--midnight { display: none; }
[data-theme="midnight"] .td-wordmark__mark--ivory { display: none; }
[data-theme="midnight"] .td-wordmark__mark--midnight { display: block; }
.td-wordmark__name { display: flex; flex-direction: column; gap: 0.25rem; }
.td-wordmark__pre {
  font-family: var(--font-sans);
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold-800);
}
[data-theme="midnight"] .td-wordmark__pre { color: var(--gold-400); }
.td-wordmark__main { font-size: 1.5rem; }

/* ---- Buttons ------------------------------------------------------------- */

.td-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 3rem;
  padding: 0 var(--space-5);
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--action);
  color: var(--action-text);
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--duration-fast), transform var(--duration-fast);
}
.td-btn:hover { background: var(--action-hover); }
.td-btn:active { transform: scale(0.98); }

.td-btn--lg { height: 3.5rem; padding: 0 var(--space-6); font-size: 1.125rem; }
.td-btn--sm { height: 2.25rem; padding: 0 var(--space-4); font-size: var(--text-sm); }

.td-btn--gold { background: var(--highlight); color: var(--highlight-text); }
.td-btn--gold:hover { background: var(--gold-200); }

/* Square, utilitarian: the trumprx.gov header controls. */
.td-btn--outline {
  height: 2.25rem;
  padding: 0 var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: 0;
}
.td-btn--outline:hover { background: var(--chip); }

.td-btn--ghost { background: transparent; color: var(--text); }
.td-btn--ghost:hover { background: var(--chip); }

/* ---- Pills --------------------------------------------------------------- */

.td-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: 1.75rem;
  padding: 0 0.625rem;
  border-radius: var(--radius-pill);
  background: var(--chip);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1;
  white-space: nowrap;
}
.td-pill--positive { background: var(--positive-bg); color: var(--positive-text); }
.td-pill--negative { background: var(--negative-bg); color: var(--negative-text); }
.td-pill--gold     { background: var(--highlight); color: var(--highlight-text); }
.td-pill__dot { width: 0.375rem; height: 0.375rem; border-radius: 50%; background: currentColor; }

/* ---- Hero ---------------------------------------------------------------- */

.td-hero { padding-block: clamp(4rem, 11vw, 9rem) var(--section); text-align: center; }
.td-hero__inner { display: flex; flex-direction: column; align-items: center; gap: var(--space-5); }
.td-hero__kicker {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}
.td-hero__lead { max-width: 36rem; }
.td-hero__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-3);
  margin-top: var(--space-3);
}

/* ---- Search -------------------------------------------------------------- */
/* The floating dark field from trumprx.gov. Colors are fixed in both themes. */

.td-search {
  display: flex;
  gap: 2px;
  width: min(100%, 36rem);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-float);
}
.td-search__field {
  display: flex;
  flex: 1;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
  height: 3.5rem;
  padding: 0 var(--space-4);
  border-radius: var(--radius-md) 0 0 var(--radius-md);
  background: rgb(30 30 28 / 0.82);
  color: #fffef1;
}
.td-search__field:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.td-search__field svg { flex: none; width: 1rem; height: 1rem; }
.td-search__input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: none;
  color: inherit;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}
.td-search__input::placeholder { color: rgb(255 254 241 / 0.6); }
.td-search__submit {
  height: 3.5rem;
  padding: 0 var(--space-6);
  border: 0;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  background: #1e1e1c;
  color: #fffef1;
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
}
.td-search__submit:hover { background: #000000; }

/* ---- Panel --------------------------------------------------------------- */
/* Light-fixed panels take data-theme="ivory"; dark ones data-theme="midnight". */

.td-panel {
  padding: clamp(1.5rem, 4vw, 3.5rem);
  border-radius: clamp(var(--radius-lg), 5vw, var(--radius-2xl));
  background: var(--surface-tint);
  color: var(--text);
}
.td-panel--gold { background: var(--gold-400); --text-secondary: rgb(33 44 51 / 0.78); --border: rgb(33 44 51 / 0.2); }
.td-panel--sand { background: var(--sand-500); }
.td-panel--ink { background: var(--ink-800); }
.td-panel--midnight { background: var(--midnight-900); }

/* ---- Exhibit card -------------------------------------------------------- */

.td-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  color: var(--text);
  text-decoration: none;
  transition: transform var(--duration) var(--ease-out);
}
a.td-card:hover { transform: translateY(-4px); }
.td-card__media {
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--gold-400);
}
.td-card__media--sand { background: var(--sand-500); }
.td-card__media--ink { background: var(--ink-800); }
.td-card__media img { width: 100%; height: 100%; object-fit: cover; }
.td-card__numeral {
  color: rgb(33 44 51 / 0.85);
  font-family: var(--font-display);
  font-size: clamp(4.5rem, 3rem + 6vw, 7.5rem);
  line-height: 1;
  letter-spacing: -0.04em;
}
.td-card__media--ink .td-card__numeral { color: var(--gold-400); }
.td-card__body { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-3); padding: var(--space-5); }
.td-card__title { font-family: var(--font-display); font-size: 2rem; font-weight: 400; line-height: 1.05; letter-spacing: -0.02em; }
.td-card__meta { color: var(--text-secondary); font-size: var(--text-sm); line-height: 1.43; }

/* ---- Stat ---------------------------------------------------------------- */

.td-stat { display: flex; flex-direction: column; gap: var(--space-2); }
.td-stat__value {
  font-family: var(--font-display);
  font-size: var(--text-display);
  line-height: 1;
  letter-spacing: var(--tracking-display);
  white-space: nowrap;
}
.td-stat__unit {
  margin-left: 0.3em;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  letter-spacing: 0;
}
.td-stat__label { color: var(--text-secondary); font-family: var(--font-mono); font-size: var(--text-sm); line-height: 1.43; }

/* ---- Comparison bars ----------------------------------------------------- */
/* The trumprx.gov price chart. Set --v (0–1) on each column for bar height. */

.td-compare { padding-top: var(--space-4); border-top: 1px solid var(--border-strong); }
.td-compare__caption {
  margin-bottom: var(--space-6);
  font-family: var(--font-display);
  font-size: var(--text-h4);
  line-height: 1.15;
  letter-spacing: -0.02em;
}
.td-compare__caption span { display: block; color: var(--text-secondary); }
.td-compare__cols {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  grid-template-rows: 1fr auto;
  column-gap: var(--space-3);
}
.td-compare__col { display: grid; grid-row: 1 / span 2; grid-template-rows: subgrid; }
.td-compare__top { display: flex; flex-direction: column; justify-content: flex-end; }
.td-compare__value {
  margin-bottom: var(--space-2);
  font-family: var(--font-display);
  font-size: var(--text-h3);
  line-height: 1;
  letter-spacing: var(--tracking-display);
}
.td-compare__unit {
  margin-left: 0.2em;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0;
}
.td-compare__bar {
  height: calc(var(--v, 1) * var(--compare-height, 16rem));
  min-height: 4px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: var(--bar-after);
}
.td-compare__bar--accent { background: var(--bar-before); }
.td-compare__label {
  margin-top: var(--space-3);
  font-family: var(--font-display);
  font-size: var(--text-h4);
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.td-compare__note { margin-top: var(--space-1); color: var(--text-secondary); font-family: var(--font-mono); font-size: var(--text-xs); line-height: 1.5; }
.td-compare__note--accent { color: var(--negative-text); }

/* ---- Accordion ----------------------------------------------------------- */

.td-accordion { border-top: 1px solid var(--border-strong); }
.td-accordion__item { border-bottom: 1px solid var(--border); }
.td-accordion__item summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-5) 0;
  font-family: var(--font-display);
  font-size: clamp(1.375rem, 1.1rem + 1vw, 1.75rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  list-style: none;
  cursor: pointer;
}
.td-accordion__item summary::-webkit-details-marker { display: none; }
.td-accordion__item summary::after {
  content: "";
  flex: none;
  width: 1.125rem;
  height: 1.125rem;
  background:
    linear-gradient(currentColor, currentColor) center / 100% 1.5px no-repeat,
    linear-gradient(currentColor, currentColor) center / 1.5px 100% no-repeat;
  transition: transform var(--duration) var(--ease-out);
}
.td-accordion__item[open] summary::after { transform: rotate(45deg); }
.td-accordion__body { max-width: 44rem; padding-bottom: var(--space-5); color: var(--text-secondary); }

/* ---- Quote --------------------------------------------------------------- */

.td-quote { text-align: center; }
.td-quote__text {
  font-family: var(--font-display);
  font-size: var(--text-h2);
  line-height: var(--leading-heading);
  letter-spacing: var(--tracking-display);
  text-wrap: balance;
}
.td-quote__source { margin-top: var(--space-5); color: var(--text-secondary); font-family: var(--font-mono); font-size: var(--text-sm); }

/* ---- Footer -------------------------------------------------------------- */

.td-footer { padding-block: var(--space-7); background: var(--bg-sunken); }
.td-footer__inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-4) var(--space-6);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.5;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
}
.td-footer__links { display: flex; flex-wrap: wrap; gap: var(--space-4) var(--space-5); }
.td-footer a { color: inherit; text-decoration: none; }
.td-footer a:hover { text-decoration: underline; }
.td-footer__disclaimer { max-width: 62ch; margin-top: var(--space-5); color: var(--text-muted); font-size: var(--text-xs); line-height: 1.5; }
