/* XKDR-inspired palette
   primary  : #f57d6a   coral accent
   secondary: #000000   text / nav
   theme    : #f2f1f0   warm off-white background
   white    : #ffffff   card surface
*/
:root {
  --primary: #f57d6a;
  --primary-dark: #e0654f;
  --secondary: #000000;
  --theme: #f2f1f0;
  --white: #ffffff;
  --fg: #1a1a1a;
  --muted: #6a6a6a;
  --line: #e1ddd9;
  --warn: #b91c1c;

  --font-sans:  "Montserrat", system-ui, -apple-system, BlinkMacSystemFont,
                "Segoe UI", Helvetica, Arial, sans-serif;
  --font-serif: "Merriweather", Georgia, serif;
  --font-mono:  ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --radius: 0;          /* XKDR uses sharp, not pill, edges */
  --shadow: 0 1px 0 var(--line);
}

* { box-sizing: border-box; }

html, body {
  background: var(--theme);
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--fg);
  font-weight: 400;
}

.page {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 32px 80px;
}
@media (min-width: 1800px) {
  .page { padding-left: 64px; padding-right: 64px; }
}

/* ---------- header / hero ---------- */

header.hero {
  padding: 56px 0 32px;
  border-bottom: 2px solid var(--secondary);
  margin-bottom: 40px;
}
header.hero h1 {
  margin: 0;
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: 44px;
  line-height: 1.1;
  letter-spacing: -0.01em;
  color: var(--secondary);
  text-transform: uppercase;
}
header.hero h1 .accent { color: var(--primary); }
header.hero h1 .dot    { color: var(--primary); margin: 0 6px; font-weight: 800; }
header.hero p.sub {
  margin: 16px 0 0;
  font-family: var(--font-serif);
  font-size: 15px;
  color: var(--secondary);
  max-width: 760px;
  line-height: 1.7;
}
header.hero p.sub a { color: var(--primary); }
header.hero p.sub a:hover { color: var(--primary-dark); text-decoration: underline; }

/* ---------- motivation ---------- */

#motivation { margin: 32px 0 8px; }
#motivation h2 {
  border-bottom: 1px solid var(--secondary);
}
#motivation p {
  font-family: var(--font-serif);
  font-size: 15px;
  line-height: 1.75;
  color: var(--fg);
  margin: 0 0 12px;
}
#motivation p:last-child { margin-bottom: 0; }
#motivation b { font-weight: 700; color: var(--secondary); }

/* ---------- primer ---------- */

#primer .row { gap: 20px; }
#primer .primer-card p + p { margin-top: 12px; }
#primer .primer-card .caveat {
  font-size: 13px;
  background: var(--theme);
  border-left: 3px solid var(--primary);
  padding: 9px 12px;
  color: var(--secondary);
}
#primer .primer-card a {
  color: var(--primary);
  text-decoration: none;
  border-bottom: 1px dotted var(--primary);
}
#primer .primer-card a:hover {
  color: var(--primary-dark);
  border-bottom-style: solid;
}
.primer-card {
  background: var(--white);
  border: 1px solid var(--line);
  padding: 22px 24px;
}
.primer-card h3 {
  margin: 0 0 12px;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.005em;
  color: var(--secondary);
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.primer-card h3 .flow,
.primer-card h3 .stock {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 0;
}
.primer-card h3 .flow  { background: var(--primary); color: var(--white); }
.primer-card h3 .stock { background: var(--secondary); color: var(--theme); }
.primer-card p {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 14px;
  line-height: 1.65;
  color: var(--fg);
}
.primer-foot {
  margin: 14px 4px 0;
  font-family: var(--font-serif);
  font-size: 13px;
  font-style: italic;
  color: var(--muted);
}

/* ---------- status pill ---------- */

.status {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--secondary);
  color: var(--theme);
  padding: 6px 14px;
  border: 0;
}
.status.error {
  background: var(--warn);
  color: var(--white);
}

/* ---------- sections ---------- */

section { margin: 44px 0; }

section h2 {
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: 20px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin: 0 0 18px;
  color: var(--secondary);
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--secondary);
}
section h2 .year-tag {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  font-size: 14px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--primary);
}

.controls {
  margin: 0 0 18px;
  font-size: 13px;
  color: var(--muted);
  font-family: var(--font-sans);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.controls label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.controls select {
  font: inherit;
  font-family: var(--font-mono);
  text-transform: none;
  letter-spacing: 0;
  padding: 5px 32px 5px 10px;
  border: 1px solid var(--secondary);
  border-radius: 0;
  background: var(--white);
  color: var(--secondary);
  appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' stroke='%23f57d6a' stroke-width='2' fill='none' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.controls select:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
.row > div { min-width: 0; }
@media (max-width: 1000px) { .row { grid-template-columns: 1fr; } }

/* Plot cards */
.row > div,
section > div:not(.row):not(.controls):not(.year-tag) {
  background: var(--white);
  border: 1px solid var(--line);
  padding: 16px;
}

/* ---------- downloads ---------- */

.tip {
  margin: 10px 4px 0;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 12px;
  color: var(--muted);
}

/* ---------- reproduce / adapt section ---------- */

#reproduce .repro-lead {
  font-family: var(--font-serif);
  font-size: 15px;
  line-height: 1.7;
  color: var(--fg);
  margin: 0 0 22px;
}
#reproduce .repro-adapt {
  font-family: var(--font-serif);
  font-size: 14px;
  line-height: 1.7;
  color: var(--secondary);
  background: var(--white);
  border-left: 3px solid var(--primary);
  padding: 12px 16px;
  margin: 22px 0 0;
}
#reproduce .row { gap: 20px; }

.reproduce-card {
  background: var(--white);
  border: 1px solid var(--line);
  padding: 22px 24px;
}
.reproduce-card h3 {
  margin: 0 0 10px;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 18px;
  color: var(--secondary);
}
.reproduce-card p {
  margin: 0 0 16px;
  font-family: var(--font-serif);
  font-size: 14px;
  line-height: 1.65;
  color: var(--fg);
}
.reproduce-card p a {
  color: var(--primary);
  text-decoration: none;
  border-bottom: 1px dotted var(--primary);
}
.reproduce-card p a:hover {
  color: var(--primary-dark);
  border-bottom-style: solid;
}
a.open-colab {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--primary);
  color: var(--white);
  padding: 8px 14px;
  text-decoration: none;
  transition: background 0.15s;
}
a.open-colab:hover { background: var(--primary-dark); }
a.open-colab:active { transform: translateY(1px); }

/* ---------- district detail panel ---------- */

.detail-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 0 18px;
  flex-wrap: wrap;
}
.detail-controls input[type="search"] {
  flex: 1;
  min-width: 240px;
  max-width: 420px;
  font: 15px/1.4 var(--font-sans);
  padding: 10px 14px;
  border: 1px solid var(--secondary);
  background: var(--white);
  color: var(--secondary);
  border-radius: 0;
  appearance: none;
}
.detail-controls select {
  font: 14px/1.4 var(--font-sans);
  font-weight: 600;
  padding: 10px 38px 10px 14px;
  border: 1px solid var(--secondary);
  background: var(--white);
  color: var(--secondary);
  border-radius: 0;
  appearance: none;
  cursor: pointer;
  /* custom coral chevron — the native arrow isn't on-brand */
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' stroke='%23f57d6a' stroke-width='2' fill='none' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.detail-controls input[type="search"]:focus,
.detail-controls select:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.detail-controls input[type="search"]::placeholder {
  color: var(--muted);
  font-style: italic;
  font-family: var(--font-serif);
}
.detail-controls button {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 8px 14px;
  background: var(--secondary);
  color: var(--theme);
  border: 0;
  cursor: pointer;
}
.detail-controls button:hover { background: var(--primary); }

#downloads {
  list-style: none;
  padding: 0;
  margin: 0;
  background: var(--white);
  border: 1px solid var(--line);
}
#downloads li {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
#downloads li:last-child { border-bottom: 0; }
#downloads li:hover { background: var(--theme); }
#downloads a {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  flex: 0 0 auto;
}
#downloads a:hover { color: var(--primary-dark); text-decoration: underline; }
#downloads .desc { color: var(--secondary); flex: 1; font-family: var(--font-serif); }
#downloads .size {
  color: var(--muted);
  font-size: 11px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ---------- footer ---------- */

footer {
  color: var(--muted);
  font-family: var(--font-serif);
  font-size: 12px;
  line-height: 1.85;
  margin-top: 72px;
  padding-top: 24px;
  border-top: 2px solid var(--secondary);
}
footer code {
  background: var(--white);
  border: 1px solid var(--line);
  padding: 1px 6px;
  border-radius: 0;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--secondary);
}
footer a { color: var(--primary); text-decoration: none; }
footer a:hover { color: var(--primary-dark); text-decoration: underline; }
footer p { margin: 0 0 8px; }
footer .cite-head {
  margin: 18px 0 6px;
  font-family: var(--font-sans);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--secondary);
}
footer .cite-self {
  font-family: var(--font-serif);
  font-size: 14px;
  background: var(--white);
  border-left: 3px solid var(--primary);
  padding: 10px 14px;
  margin: 6px 0 18px;
  color: var(--secondary);
}
footer .cites { padding-left: 18px; margin: 0; }
footer .cites li { margin: 4px 0; }

/* ---------- phone / narrow screens ---------- */
@media (max-width: 640px) {
  body { font-size: 14px; }
  .page { padding: 0 16px 56px; }

  header.hero { padding: 32px 0 20px; margin-bottom: 24px; }
  header.hero h1 { font-size: 28px; letter-spacing: 0; }
  header.hero h1 .dot { margin: 0 2px; }

  section { margin: 32px 0; }
  section h2 {
    font-size: 16px;
    flex-wrap: wrap;
    gap: 8px;
  }
  section h2 .year-tag { font-size: 12px; }

  .row { gap: 16px; }
  .row > div,
  section > div:not(.row):not(.controls):not(.year-tag) { padding: 12px; }

  .primer-card,
  .reproduce-card { padding: 16px 16px; }
  .primer-card h3,
  .reproduce-card h3 { font-size: 16px; flex-wrap: wrap; }

  .controls { display: flex; flex-wrap: wrap; gap: 10px; }
  .controls label { font-size: 12px; }

  .detail-controls { gap: 8px; }
  .detail-controls input[type="search"],
  .detail-controls select {
    flex: 1 1 100%;
    min-width: 0;
    max-width: none;
    font-size: 14px;
    padding: 8px 12px;
  }
  .detail-controls select { padding-right: 34px; }

  #downloads li {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 12px 14px;
  }

  footer { font-size: 12px; }
  footer .cite-self { font-size: 13px; }
}
