/* SF Housing Construction Tracker
   House style: ported from the user's analytical-chart system (design-style.md) - white
   ground, ink greys, one workhorse accent and a validated second accent, Archivo throughout
   with tabular figures. That system's blue/orange pair encodes "a share or count" vs. "a
   ratio of two things"; this subject has no natural ratio, so the role is re-read for it:
     --blue    the workhorse - the page's subject, the primary count -> under construction
     --orange  the secondary, less-common case                       -> permitted, not started
     --green   a third categorical accent (same lightness band)      -> completions / BMR share
   Never alternate blue/orange for variety - each always means the same stage.
*/

@font-face { font-family: "Archivo"; src: url("vendor/fonts/archivo-variable.woff2") format("woff2");
  font-weight: 400; font-display: swap; }
@font-face { font-family: "Archivo"; src: url("vendor/fonts/archivo-variable.woff2") format("woff2");
  font-weight: 500; font-display: swap; }
@font-face { font-family: "Archivo"; src: url("vendor/fonts/archivo-variable.woff2") format("woff2");
  font-weight: 600; font-display: swap; }
@font-face { font-family: "Archivo"; src: url("vendor/fonts/archivo-variable.woff2") format("woff2");
  font-weight: 700; font-display: swap; }

:root {
  color-scheme: light;

  --bg:        #ffffff;
  --bg-sunk:   #f7f8f9;
  --ink:       #0f1113;
  --ink-2:     #5c636b;
  --ink-3:     #9aa0a8;
  --ink-label: #7b8189;   /* section eyebrows + stat labels: between ink-2 and ink-3 */
  --rule:      #e7e9eb;
  --rule-2:    #d8dbde;
  --axis:      #c9cdd1;
  --blue:      #006e93;
  --orange:    #b0491f;
  --green:     #2e6e4e;
  --blue-soft:   rgba(0, 110, 147, .13);
  --orange-soft: rgba(176, 73, 31, .13);
  --green-soft:  rgba(46, 110, 78, .13);

  --sans: "Archivo", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --code: ui-monospace, "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  font-feature-settings: "tnum" 1;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration-color: var(--rule-2); text-underline-offset: 2px; }
h1, h2, h3 { font-weight: 700; margin: 0; }
code { font-family: var(--code); }

.wrap { max-width: 1280px; margin: 0 auto; padding: 0 24px 80px; }

/* ---------- masthead --------------------------------------------------- */
.masthead { padding: 28px 0 0; }
.masthead .kicker {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.masthead h1 {
  font-size: clamp(34px, 5.2vw, 58px);
  font-weight: 700;
  letter-spacing: -0.028em;
  line-height: 1.02;
  margin: 8px 0 8px;
  max-width: 17ch;
}
.masthead .dateline {
  font-size: 15.5px;
  line-height: 1.5;
  color: var(--ink-2);
  margin-bottom: 20px;
}

/* key-figure strip: value / UPPERCASE LABEL, bounded by hairlines */
.standings {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 2px solid var(--ink);
  border-bottom: 1px solid var(--rule);
}
.standings .fig {
  padding: 16px 22px 16px 22px;
  border-right: 1px solid var(--rule);
  min-width: 0;
}
.standings .fig:first-child { padding-left: 0; }
.standings .fig:last-child { padding-right: 0; border-right: 0; }
.standings .n {
  font-weight: 700;
  font-size: clamp(26px, 3vw, 38px);
  letter-spacing: -0.02em;
  line-height: 1;
  display: block;
}
.standings .fig.built   .n { color: var(--blue); }
.standings .fig.permit  .n { color: var(--orange); }
.standings .fig.done    .n { color: var(--green); }
.standings .fig.aff     .n { color: var(--green); }
.standings .lbl {
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-label);
  margin-top: 10px;
  display: block;
}
.standings .sub { font-size: 11.5px; color: var(--ink-3); margin-top: 4px; display: block; }

/* below ~720px the four-across row gets cramped - go 2x2 */
@media (max-width: 720px) {
  .standings { grid-template-columns: 1fr 1fr; }
  .standings .fig { padding: 14px 20px; border-bottom: 1px solid var(--rule); }
  .standings .fig:nth-child(odd)  { padding-left: 0; }
  .standings .fig:nth-child(even) { padding-right: 0; border-right: 0; }
  .standings .fig:nth-last-child(-n+2) { border-bottom: 0; }
}

/* ---------- main split: map + ledger --------------------------------- */
.split {
  display: grid;
  grid-template-columns: 1.85fr 1fr;
  gap: 26px;
  margin-top: 34px;
}
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }

#map {
  height: 560px;
  border: 1px solid var(--rule-2);
  background: var(--bg-sunk);
}
.leaflet-container { background: var(--bg-sunk); font-family: var(--sans); }
.map-frame .cap {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 8px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
}
.legend-key { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.legend-key .g { width: 11px; height: 11px; display: inline-block; }
.legend-key.off { opacity: 0.35; text-decoration: line-through; }
.g.built { background: var(--blue); }
.g.permit { background: var(--orange); }
.g.done { background: var(--green); border-radius: 50%; }
.g.hollow { border: 1.5px solid var(--orange); background: transparent; transform: rotate(45deg); }

/* section eyebrows: uppercase label hanging off a 2px ink rule above it */
.ledger h2, .charts h2, .index h2, .mega h2 {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-label);
  border-top: 2px solid var(--ink);
  padding-top: 12px;
  margin: 0 0 16px;
}

/* ledger */
.ledger ol { list-style: none; margin: 0; padding: 0; }
.ledger li {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--rule);
  cursor: pointer;
}
.ledger li:hover { background: var(--bg-sunk); }
.ledger li.active { background: var(--bg-sunk); box-shadow: inset 3px 0 0 var(--blue); }
.ledger .place { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ledger .place .sub { font-size: 12px; color: var(--ink-3); }
.ledger .val { font-weight: 600; }
.ledger .all { font-size: 12px; color: var(--ink-3); margin-top: 8px; cursor: pointer; text-decoration: underline; }

/* ---------- charts -------------------------------------------------- */
.charts { margin-top: 48px; }
.chart-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 44px;
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
  margin-top: 32px;
}
@media (max-width: 900px) {
  .chart-grid { grid-template-columns: 1fr; gap: 30px; }
}
.chart { min-width: 0; align-self: start; }
.chart .hd { font-weight: 600; font-size: 17px; letter-spacing: -0.01em; margin-bottom: 4px; }
.chart .note {
  font-size: 13.5px; line-height: 1.5;
  color: var(--ink-2); margin-bottom: 10px; max-width: 66ch;
}
.chart svg { width: 100%; height: auto; overflow: visible; display: block; margin-top: 2px; }
.chart svg text { font-family: var(--sans); fill: var(--ink-3); font-size: 10px; }
.chart .gl { stroke: var(--rule); stroke-width: 1; }
.chart .axis { stroke: var(--axis); stroke-width: 1.4; }
.series-cur { stroke: var(--blue); }
.series-prev { stroke: var(--rule-2); stroke-dasharray: 3 3; }
.bar-uc { fill: var(--blue); }
.bar-permit { fill: var(--orange); }
.bar-aff { fill: var(--green); }

/* ---------- project index (table) --------------------------------- */
.index { margin-top: 48px; }
.controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin: 12px 0;
  font-size: 12.5px;
}
.controls input, .controls select {
  font-family: var(--sans);
  font-size: 12.5px;
  padding: 6px 8px;
  border: 1px solid var(--rule-2);
  background: var(--bg);
  color: var(--ink);
}
.controls input { min-width: 200px; }
.controls .clear { cursor: pointer; color: var(--ink-3); text-decoration: underline; }

table.idx { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 620px; }
/* own scroll area so the long list doesn't take over the page */
.idx-scroll { max-height: 560px; overflow: auto; border-bottom: 1px solid var(--rule); }
table.idx th {
  position: sticky; top: 0; z-index: 1; background: var(--bg, #fff);
  text-align: left;
  border-bottom: 2px solid var(--ink);
  padding: 6px 14px 6px 0;
  cursor: pointer;
  white-space: nowrap;
  font-weight: 600;
}
table.idx th .arr { color: var(--ink-3); }
table.idx td { padding: 8px 14px 8px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
table.idx td:last-child, table.idx th:last-child { padding-right: 0; }
table.idx tr:hover td { background: var(--bg-sunk); }
table.idx .num { text-align: right; font-weight: 600; white-space: nowrap; }
table.idx .glyph { width: 16px; padding-right: 8px; }
table.idx .st-built .glyph::before { content: "\25A0"; color: var(--blue); }
table.idx .st-permit .glyph::before { content: "\25E7"; color: var(--orange); }
table.idx .replaces { color: var(--ink-3); min-width: 15ch; }
table.idx .addr { font-weight: 600; line-height: 1.3; }
table.idx .addr .sub { font-weight: 400; color: var(--ink-3); }
table.idx td:last-child { white-space: nowrap; color: var(--ink-3); }

/* ---------- hover card (project preview) -------------------------- */
#card {
  position: fixed;
  z-index: 9999;
  width: 260px;
  background: var(--bg);
  border: 1px solid var(--ink);
  box-shadow: 3px 3px 0 rgba(15, 17, 19, .07);
  padding: 0;
  pointer-events: none;
}
#card img {
  width: 100%;
  height: 150px;
  object-fit: cover;
  display: block;
  border-bottom: 1px solid var(--ink);
  background: var(--bg-sunk);
}
#card .noimg {
  height: 92px; display: flex; align-items: center; justify-content: center;
  background: var(--bg-sunk); color: var(--ink-3); font-size: 11px;
  border-bottom: 1px solid var(--ink); letter-spacing: 0.05em;
}
#card .body { padding: 9px 11px 11px; }
#card .nm { font-weight: 700; font-size: 13.5px; line-height: 1.2; }
#card .meta { font-size: 11.5px; color: var(--ink-3); margin-top: 3px; }
#card .u { color: var(--blue); font-weight: 600; }
#card .rep { font-size: 11.5px; margin-top: 6px; border-top: 1px solid var(--rule); padding-top: 5px; }
#card .rep b { color: var(--ink); font-weight: 600; }

/* ---------- entitled megaprojects ---------------------------------- */
.mega { margin-top: 48px; }
.mega .lede { font-size: 13.5px; color: var(--ink-2); max-width: 70ch; margin: 0 0 14px; }
.mega ol { list-style: none; margin: 0; padding: 0; }
.mega li { border-top: 1px solid var(--rule); padding: 12px 0; }
.mega .mh { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; }
.mega .mn { font-weight: 700; font-size: 15px; }
.mega .ma { font-size: 12px; color: var(--ink-3); }
.mega .mu { font-size: 12.5px; color: var(--orange); margin-left: auto; }
.mega .ms { font-size: 13.5px; color: var(--ink); margin-top: 4px; max-width: 80ch; }
.mega .mg { font-size: 12px; color: var(--ink-3); margin-top: 4px; max-width: 90ch; }
.mega .msrc { white-space: nowrap; }
.mega .msrc a { color: inherit; text-decoration: none; border-bottom: 1px solid var(--rule); }

/* ---------- footer ------------------------------------------------- */
footer {
  margin-top: 60px;
  border-top: 2px solid var(--ink);
  padding-top: 18px;
  font-size: 13.5px;
  color: var(--ink-2);
  line-height: 1.65;
}
footer a { text-decoration: none; border-bottom: 1px solid var(--rule); }
footer .src { display: flex; flex-wrap: wrap; gap: 4px 22px; margin-top: 8px; color: var(--ink-3); }
footer .method {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid var(--rule-2);
  background: var(--bg-sunk);
  color: var(--ink);
}

.loading { color: var(--ink-3); padding: 40px 0; }
