:root {
  --bg: #f7f6f3;
  --surface: #ffffff;
  --surface-2: #f0efeb;
  --ink: #16150f;
  --ink-soft: #55534a;
  --ink-faint: #85837a;
  --line: #e0ded6;
  --line-strong: #c9c6ba;
  --accent: #9a3412;
  --accent-soft: #fdf0e9;
  --ok: #15803d;
  --ok-soft: #e9f5ec;
  --warn: #a16207;
  --warn-soft: #fdf5e3;
  --cold: #3f4b63;
  --cold-soft: #eef0f5;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(22, 21, 15, .05), 0 6px 20px rgba(22, 21, 15, .05);
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: ui-serif, Georgia, "Iowan Old Style", "Times New Roman", serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14130f;
    --surface: #1d1c17;
    --surface-2: #26251f;
    --ink: #f2f0e9;
    --ink-soft: #b3b0a4;
    --ink-faint: #85837a;
    --line: #322f28;
    --line-strong: #46433a;
    --accent: #f08a5d;
    --accent-soft: #2e2119;
    --ok: #6ee7a0;
    --ok-soft: #16261c;
    --warn: #e8c468;
    --warn-soft: #2a2317;
    --cold: #a8b4cc;
    --cold-soft: #1d2029;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
}

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 16px;
}

.skip-link {
  position: absolute;
  left: -9999px;
}
.skip-link:focus {
  left: 16px;
  top: 8px;
  z-index: 10;
  background: var(--surface);
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
}

/* ---------- masthead ---------- */

.masthead {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.masthead-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
  justify-content: space-between;
  padding-top: 22px;
  padding-bottom: 20px;
}

.brand { display: flex; gap: 14px; align-items: flex-start; }
.brand-mark { font-size: 30px; line-height: 1.2; }

.masthead h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 30px;
  line-height: 1.15;
  letter-spacing: -.015em;
}

.tagline {
  margin: 4px 0 0;
  color: var(--ink-soft);
  font-size: 14.5px;
  max-width: 54ch;
}

.freshness {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-soft);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
  white-space: nowrap;
}

.freshness .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--ok);
  flex: none;
}

/* ---------- layout ---------- */

.layout {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
  padding-top: 26px;
  padding-bottom: 48px;
}

@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 20px; }
}

/* Grid and flex tracks size to min-content by default, and the country
   <select> reports the width of its longest option ("Saint Vincent and the
   Grenadines") as its minimum. Without these the whole page is pushed wider
   than a phone screen. */
.filters,
#results { min-width: 0; }

input[type="search"],
select { min-width: 0; max-width: 100%; }

/* ---------- filters ---------- */

.filters {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 16px;
  position: sticky;
  top: 16px;
}

@media (max-width: 860px) {
  .filters { position: static; }
}

.field { margin: 0 0 18px; border: 0; padding: 0; }

/* The first question a reader has is which of the two things they want. */
.field-primary {
  background: var(--surface-2);
  border-radius: 9px;
  padding: 12px 12px 10px;
  margin-bottom: 20px;
}
.field-primary > legend { padding: 0 0 0 12px; }
.field-primary .segmented { background: var(--surface); }
.field-primary .hint { margin-top: 8px; }
.field:last-of-type { margin-bottom: 14px; }

.field > label,
.field > legend {
  display: block;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 7px;
  padding: 0;
}

input[type="search"],
select {
  width: 100%;
  font: inherit;
  font-size: 14.5px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 8px 10px;
}

input[type="search"]:focus-visible,
select:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.hint {
  margin: 6px 0 0;
  font-size: 12.5px;
  color: var(--ink-faint);
  line-height: 1.4;
}

.segmented {
  display: grid;
  /* minmax(0,…) so a long label such as "Media outlet" cannot push the track
     past the viewport on a phone. */
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  background: var(--surface-2);
  border-radius: 8px;
  padding: 3px;
}

.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }

.segmented span {
  display: block;
  text-align: center;
  font-size: 12.5px;
  line-height: 1.25;
  hyphens: auto;
  padding: 6px 3px;
  border-radius: 6px;
  color: var(--ink-soft);
  cursor: pointer;
}

.segmented input:checked + span {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .08);
}

.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }

.checks { display: flex; flex-direction: column; gap: 5px; }

.checks label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--ink-soft);
  cursor: pointer;
}

.checks input { accent-color: var(--accent); width: 15px; height: 15px; flex: none; }

.soon {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px solid var(--line);
  font-size: 14px;
  color: var(--ink-soft);
  cursor: pointer;
}
.soon input { accent-color: var(--accent); width: 15px; height: 15px; flex: none; }

.actions { display: flex; flex-direction: column; gap: 6px; }

.btn-ghost {
  font: inherit;
  font-size: 13.5px;
  text-align: left;
  color: var(--ink-soft);
  background: none;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px 10px;
  cursor: pointer;
}
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }

/* ---------- results ---------- */

.results-head { margin-bottom: 14px; }

.results-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 21px;
  letter-spacing: -.01em;
}

.result-context {
  margin: 3px 0 0;
  font-size: 13.5px;
  color: var(--ink-faint);
}

.subscribe {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--ink-faint);
}
.subscribe a { color: var(--accent); }
#feed-scope { color: var(--ink-faint); }

.cards { display: flex; flex-direction: column; gap: 12px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.card.is-urgent { border-left-color: var(--accent); }
.card.is-rolling { border-left-color: var(--ok); }
.card.is-closed { opacity: .72; }

.card-head {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  align-items: baseline;
  justify-content: space-between;
}

.card-funder {
  font-size: 12.5px;
  font-weight: 650;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.card h3 {
  margin: 2px 0 0;
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.25;
  width: 100%;
}

.card h3 a { color: inherit; text-decoration: none; border-bottom: 1px solid var(--line-strong); }
.card h3 a:hover { color: var(--accent); border-bottom-color: var(--accent); }

.card-summary {
  margin: 8px 0 0;
  font-size: 14.5px;
  color: var(--ink-soft);
  max-width: 76ch;
}

.card-angle {
  margin: 10px 0 0;
  font-size: 14px;
  color: var(--ink-soft);
  background: var(--cold-soft);
  border-radius: 7px;
  padding: 9px 12px;
  max-width: 76ch;
}
.card-angle strong { color: var(--cold); }

.card-note {
  margin: 8px 0 0;
  font-size: 13.5px;
  color: var(--ink-faint);
  border-left: 2px solid var(--line);
  padding-left: 10px;
}

.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }

.badge {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge-deadline { background: var(--cold-soft); color: var(--cold); }
.badge-urgent   { background: var(--accent-soft); color: var(--accent); }
.badge-rolling  { background: var(--ok-soft); color: var(--ok); }
.badge-money    { background: var(--surface-2); color: var(--ink-soft); }
.badge-who      { background: var(--surface-2); color: var(--ink-soft); }
.badge-where    { background: var(--surface-2); color: var(--ink-soft); }
.badge-kind     { background: var(--surface-2); color: var(--ink-soft); }
.badge-check    { background: var(--warn-soft); color: var(--warn); }
.badge-adjacent { background: var(--cold-soft); color: var(--cold); border-color: currentColor; }

.card-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  justify-content: space-between;
  margin-top: 13px;
  padding-top: 11px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--ink-faint);
}

.apply {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  border: 1px solid currentColor;
  border-radius: 7px;
  padding: 5px 12px;
}
.apply:hover { background: var(--accent-soft); }

.empty {
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  color: var(--ink-soft);
}

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

.site-foot {
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 26px 0 40px;
  font-size: 13.5px;
  color: var(--ink-soft);
}

.site-foot p { margin: 0 0 10px; max-width: 78ch; }
.site-foot code {
  background: var(--surface-2);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 12.5px;
}
.foot-meta { color: var(--ink-faint); }
