/* DallasBudget.com
   1. Tokens
   2. Base & layout
   3. Typography
   4. Stat tiles & hero figure
   5. Stacked bars
   6. Ranked bars
   7. Tables
   8. Notes, sources, footer
*/

/* ---------------------------------------------------------------- 1. Tokens */

:root {
  color-scheme: light;

  --surface:        #fcfcfb;
  --plane:          #f9f9f7;
  --ink:            #0b0b0b;
  --ink-2:          #52514e;
  --ink-muted:      #898781;
  --rule:           #e1e0d9;
  --baseline:       #c3c2b7;

  --series-1:       #2a78d6;  /* blue    */
  --series-2:       #eb6834;  /* orange  */
  --series-3:       #1baf7a;  /* aqua    */
  --series-4:       #eda100;  /* yellow  */
  --series-5:       #e87ba4;  /* magenta */

  --red:            #c22d20;

  --track:          #e8e7e1;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;

    --surface:      #1a1a19;
    --plane:        #0d0d0d;
    --ink:          #ffffff;
    --ink-2:        #c3c2b7;
    --ink-muted:    #898781;
    --rule:         #2c2c2a;
    --baseline:     #383835;

    --series-1:     #3987e5;
    --series-2:     #d95926;
    --series-3:     #199e70;
    --series-4:     #c98500;
    --series-5:     #d55181;

    --red:          #e4564a;

    --track:        #2c2c2a;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --surface:        #1a1a19;
  --plane:          #0d0d0d;
  --ink:            #ffffff;
  --ink-2:          #c3c2b7;
  --ink-muted:      #898781;
  --rule:           #2c2c2a;
  --baseline:       #383835;

  --series-1:       #3987e5;
  --series-2:       #d95926;
  --series-3:       #199e70;
  --series-4:       #c98500;
  --series-5:       #d55181;

  --red:            #e4564a;

  --track:          #2c2c2a;
}

/* ------------------------------------------------------ 2. Base & layout */

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font: 17px/1.6 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
}

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

section { margin: 3.5rem 0 0; }

hr.rule {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 3.5rem 0 0;
}

/* -------------------------------------------------------- 3. Typography */

.masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .25rem .75rem;
  padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--rule);
}
.masthead b { font-size: 1rem; font-weight: 600; letter-spacing: -0.01em; }
.masthead b a { color: inherit; text-decoration: none; }
.masthead span { font-size: .9rem; color: var(--ink-muted); }

.masthead nav { margin-left: auto; display: flex; gap: 1rem; font-size: .9rem; }
.masthead nav a { color: var(--ink-2); text-decoration: none; }
.masthead nav a:hover { text-decoration: underline; }
.masthead nav a[aria-current="page"] { color: var(--ink); font-weight: 600; }

.notice {
  margin: 1.75rem 0 0;
  padding: 1rem 1.25rem;
  border: 1px solid var(--rule);
  border-left: 3px solid var(--red);
  border-radius: 4px;
  background: var(--plane);
  font-size: .98rem;
}
.notice p { margin: 0 0 .6rem; }
.notice ul { margin: 0; padding-left: 1.2rem; }
.notice li { margin: .3rem 0; }
.proposed { color: var(--red); font-variant-numeric: tabular-nums; }

h1 {
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 2.5rem 0 .75rem;
}

.standfirst {
  font-size: 1.1rem;
  color: var(--ink-2);
  margin: 0 0 .5rem;
  max-width: 34rem;
}

h2 {
  font-size: 1.3rem;
  letter-spacing: -0.01em;
  margin: 0 0 .35rem;
}

.math {
  display: flex;
  flex-wrap: wrap;
  gap: .2rem .6rem;
  font-size: clamp(1.25rem, 4.2vw, 1.9rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  margin: 2.25rem 0 .4rem;
}
.math-note { color: var(--ink-2); margin: 0; }

.step {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: .5rem;
}

p { margin: 1rem 0; max-width: 36rem; }
h3 { font-size: 1rem; margin: 2rem 0 .5rem; }

a { color: inherit; text-underline-offset: 2px; text-decoration-color: var(--baseline); }
a:hover { text-decoration-color: currentColor; }

.lede { font-size: 1.05rem; color: var(--ink-2); }

/* ------------------------------------------ 4. Stat tiles & hero figure */

.hero {
  font-size: clamp(2.6rem, 9vw, 4rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1;
  margin: 1.5rem 0 .5rem;
}
.hero-note { color: var(--ink-2); margin-top: 0; }

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  margin: 2rem 0;
}
.tile { background: var(--surface); padding: 1rem 1.1rem; }
.tile .label { display: block; font-size: .82rem; color: var(--ink-muted); margin-bottom: .3rem; }
.tile .value { display: block; font-size: 1.5rem; font-weight: 600; letter-spacing: -0.02em; }
.tile .sub   { display: block; font-size: .8rem; color: var(--ink-muted); margin-top: .2rem; }

/* ------------------------------------------------------ 5. Stacked bars */

.stack {
  display: flex;
  gap: 2px;              /* the surface gap — white does the separating */
  height: 3.25rem;
  margin: 1.5rem 0 1.25rem;
}
.stack > div {
  min-width: 3px;
  border-radius: 1px;
}
.stack > div:first-child { border-radius: 4px 1px 1px 4px; }
.stack > div:last-child  { border-radius: 1px 4px 4px 1px; }

.key {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
  gap: .4rem 2rem;
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
  font-size: .92rem;
}
.key li {
  display: grid;
  grid-template-columns: .7rem 1fr auto;
  align-items: baseline;
  gap: .55rem;
  padding: .2rem 0;
  border-bottom: 1px solid var(--rule);
}
.key i {
  width: .7rem; height: .7rem;
  border-radius: 2px;
  align-self: center;
}
.key b { font-weight: 400; }
.key span {
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.s1 { background: var(--series-1); }
.s2 { background: var(--series-2); }
.s3 { background: var(--series-3); }
.s4 { background: var(--series-4); }
.s5 { background: var(--series-5); }

/* ------------------------------------------------------- 6. Ranked bars */

.ranked { margin: 1.5rem 0; font-size: .92rem; }

/* Each row is its own grid, so the mobile reflow below can't interleave rows. */
.ranked .row {
  display: grid;
  grid-template-columns: minmax(6rem, 13rem) 1fr 5.75rem;
  align-items: center;
  gap: .75rem;
  padding: .3rem 0;
}
.ranked dt {
  color: var(--ink-2);
  overflow-wrap: anywhere;
  line-height: 1.3;
}
.ranked .track {
  height: 18px;
  background: var(--track);
  border-radius: 1px 4px 4px 1px;
}
.ranked .track > i {
  display: block;
  height: 100%;
  background: var(--series-1);
  border-radius: 1px 4px 4px 1px;   /* square at the baseline, rounded at the data end */
}
.ranked dd {
  margin: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--ink);
}
.ranked .muted > i { background: var(--baseline); }

/* ------------------------------------------------------------ 7. Tables */

details.more {
  margin: 1rem 0 0;
  border-top: 1px solid var(--rule);
  padding-top: .75rem;
}
details.more summary {
  cursor: pointer;
  font-size: .92rem;
  color: var(--ink-2);
}
details.more[open] summary { margin-bottom: .75rem; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .92rem;
  margin: 1rem 0;
}
caption {
  text-align: left;
  color: var(--ink-muted);
  font-size: .85rem;
  padding-bottom: .5rem;
}
th, td {
  text-align: left;
  padding: .4rem .6rem .4rem 0;
  border-bottom: 1px solid var(--rule);
  vertical-align: baseline;
}
th { font-weight: 600; color: var(--ink-2); }
td.n, th.n {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  padding-right: 0;
}
tr.total td, tr.total th { border-bottom: 0; border-top: 1px solid var(--baseline); font-weight: 600; }

.scroll { overflow-x: auto; }

/* ----------------------------------------- 8. Notes, sources, footer */

.callout {
  margin: 1.75rem 0;
  padding: 1rem 1.1rem;
  background: var(--plane);
  border-left: 3px solid var(--series-1);
}
.callout p { margin: 0; max-width: none; }
.callout p + p { margin-top: .6rem; }

ol.notes, ul.notes { padding-left: 1.2rem; max-width: 36rem; }
ol.notes li, ul.notes li { margin: .6rem 0; }

.sources { font-size: .92rem; color: var(--ink-2); }
.sources li { margin: .5rem 0; }

footer {
  margin-top: 4rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  font-size: .88rem;
  color: var(--ink-muted);
}
footer p { max-width: 36rem; }

@media (max-width: 34rem) {
  .ranked .row { grid-template-columns: 1fr auto; gap: .2rem .75rem; padding: .45rem 0; }
  .ranked dt    { grid-area: 1 / 1; }
  .ranked dd    { grid-area: 1 / 2; }
  .ranked .track { grid-area: 2 / 1 / 3 / 3; }
}
