/* Reset + base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: #FBF7F0;
  color: #1F1B16;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: #A8471C; text-decoration: none; border-bottom: 1px solid currentColor; }
a:hover { color: #7A330E; }
button { font: inherit; cursor: pointer; }

/* Layout containers */
.hero, .proof, .browse, .signup, footer {
  padding-left: max(24px, env(safe-area-inset-left));
  padding-right: max(24px, env(safe-area-inset-right));
}

/* Hero */
.hero { padding-top: 96px; padding-bottom: 96px; }
.hero-inner { max-width: 760px; margin: 0 auto; }
.brand {
  display: inline-block;
  font-family: 'Source Serif Pro', ui-serif, Georgia, serif;
  font-weight: 700;
  font-size: 20px;
  border: none;
  margin-bottom: 48px;
  color: #1F1B16;
}
.hero h1 {
  font-family: 'Source Serif Pro', ui-serif, Georgia, serif;
  font-weight: 700;
  font-size: clamp(36px, 5vw, 56px);
  line-height: 1.15;
  margin: 0 0 24px;
  letter-spacing: -0.02em;
}
.tagline { font-size: 20px; color: #6B6258; margin: 0 0 40px; max-width: 580px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 24px; align-items: center; }
.audience-picker { display: inline-flex; align-items: center; gap: 12px; color: #6B6258; }
.audience-picker select {
  font: inherit; padding: 10px 14px; border: 1px solid #1F1B16;
  background: #FFFFFF; border-radius: 4px; color: #1F1B16; cursor: pointer;
}
.browse-all { font-weight: 500; }
.hint { color: #6B6258; font-size: 14px; margin: 20px 0 0; font-style: italic; }
[hidden] { display: none !important; }

/* Proof strip */
.proof {
  padding-top: 16px; padding-bottom: 16px;
  border-top: 1px solid #EAE4D9; border-bottom: 1px solid #EAE4D9;
  text-align: center; color: #6B6258; font-size: 14px;
}
.proof p { margin: 0; }

/* Featured "Closing soon" strip */
.featured-section { padding: 72px 24px 24px; max-width: 1200px; margin: 0 auto; }
.featured-inner { }
.featured-section h2 {
  font-family: 'Source Serif Pro', ui-serif, Georgia, serif;
  font-size: 28px; margin: 0 0 4px;
}
.featured-sub { color: #6B6258; font-size: 16px; margin: 0 0 24px; }
.featured-grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .featured-grid { grid-template-columns: 1fr 1fr 1fr; gap: 20px; } }

/* Browse section */
.browse { padding-top: 48px; padding-bottom: 96px; max-width: 1200px; margin: 0 auto; }
#browse { scroll-margin-top: 80px; }
.filters {
  position: sticky; top: 0;
  padding: 16px; margin-bottom: 24px;
  background: #FBF7F0;
  border-bottom: 1px solid #EAE4D9;
  z-index: 10;
}
.filters-primary {
  display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: end;
}
.filters-primary .sort { margin-left: auto; }
.filters-secondary { margin-top: 12px; }
.filters-secondary summary {
  cursor: pointer; color: #6B6258; font-size: 13px; font-weight: 500;
  display: inline-block; padding: 4px 0;
  border-bottom: 1px dashed #C8C0B2; width: fit-content;
  list-style: none;
}
.filters-secondary summary::-webkit-details-marker { display: none; }
.filters-secondary summary::before { content: "+ "; display: inline; }
.filters-secondary[open] summary::before { content: "− "; }
.filters-secondary summary:hover { color: #1F1B16; }
.filters-grid {
  display: flex; flex-wrap: wrap; gap: 12px 20px;
  padding-top: 12px; margin-top: 8px;
  border-top: 1px dashed #EAE4D9; align-items: end;
}
.filters label { display: inline-flex; flex-direction: column; gap: 4px; font-size: 13px; color: #6B6258; }
.filters label.check { flex-direction: row; align-items: center; gap: 8px; color: #1F1B16; font-size: 14px; }
.filters select { font: inherit; padding: 6px 8px; border: 1px solid #8C8472; background: #FFFFFF; border-radius: 4px; min-width: 140px; }
.filters fieldset.effort { border: none; padding: 0; margin: 0; display: flex; gap: 12px; align-items: end; }
.filters fieldset.effort legend { color: #6B6258; font-size: 13px; margin-bottom: 4px; }
.filters fieldset.effort label { flex-direction: row; align-items: center; gap: 4px; color: #1F1B16; font-size: 14px; }

/* Type macro-category pills */
.filters .type-pills { border: none; padding: 0; margin: 0; flex: 1 1 100%; }
.filters .type-pills legend {
  color: #6B6258; font-size: 13px; margin-bottom: 6px; padding: 0;
}
.filters .pill-row {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.filters .pill {
  font: inherit; font-size: 13px; font-weight: 500;
  padding: 6px 14px; border: 1px solid #8C8472; border-radius: 999px;
  background: #FFFFFF; color: #1F1B16; cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
.filters .pill:hover { border-color: #1F1B16; }
.filters .pill.active {
  background: #1F1B16; color: #FBF7F0; border-color: #1F1B16;
}
.filters .pill.partial {
  background: #FBF7F0; color: #1F1B16; border-color: #8F4D14;
  border-style: dashed;
}

/* "I'm in" primary control */
.filters .my-country select {
  font-weight: 500;
  min-width: 180px;
}

/* Optgroup typography in country selects */
.filters select optgroup { font-style: italic; color: #6B6258; }
.filters select optgroup option { font-style: normal; color: #1F1B16; }

.active-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.active-chips:empty { display: none; margin-bottom: 0; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  background: #FFFFFF; border: 1px solid #EAE4D9;
  font-size: 13px; color: #1F1B16;
}
.chip button {
  border: none; background: none; padding: 0; color: #6B6258; font-size: 16px; line-height: 1;
  /* WCAG 2.5.8: minimum 24×24 hit target without enlarging the visible glyph */
  min-width: 24px; min-height: 24px;
  display: inline-flex; align-items: center; justify-content: center;
}
.result-count { color: #6B6258; font-size: 14px; margin: 0 0 16px; }

/* Card grid */
.grid {
  display: grid; gap: 16px;
  grid-template-columns: 1fr;
}
@media (min-width: 640px) { .grid { grid-template-columns: 1fr 1fr; gap: 20px; } }
@media (min-width: 1024px) { .grid { grid-template-columns: 1fr 1fr 1fr; gap: 24px; } }

.card {
  background: #FFFFFF;
  border: 1px solid #EAE4D9;
  border-radius: 6px;
  padding: 24px;
  display: flex; flex-direction: column;
  min-height: 280px;
  transition: border-color 120ms ease, transform 120ms ease;
}
.card:hover { border-color: #C8C0B2; }
.card.urgent {
  border-left: 4px solid #8F4D14;
  padding-left: 20px;          /* compensates for the thicker left border */
  background: linear-gradient(to right, #FFF8F0 0, #FFFFFF 80px);
}
.card.featured {
  border: 1px solid #1F1B16;
  background: #FFFFFF;
}
.card .meta-row {
  font-size: 12px; color: #6B6258; margin-bottom: 14px;
  display: flex; flex-wrap: wrap; column-gap: 6px; row-gap: 4px;
  align-items: baseline;
}
.card .meta-row .badge-type {
  color: #1F1B16; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.06em; font-size: 11px;
}
.card .meta-row .badge-country { color: #6B6258; }
.card .meta-row .badge-deadline { color: #6B6258; }
/* Visual middot separators live in CSS so screen readers don't announce "dot" before each.
   :not(:empty) avoids a stray leading dot when a card has no country or no deadline label. */
.card .meta-row .badge-country:not(:empty)::before,
.card .meta-row .badge-deadline:not(:empty)::before { content: "·"; margin-right: 6px; color: #6B6258; }
.card .meta-row .badge-deadline.urgent { color: #8F4D14; font-weight: 600; }
.card .meta-row .badge-deadline.rolling,
.card .meta-row .badge-deadline.continuous,
.card .meta-row .badge-deadline.annual { color: #3F7C4F; }
.card h3 {
  font-family: 'Source Serif Pro', ui-serif, Georgia, serif;
  font-size: 20px; line-height: 1.25; margin: 0 0 4px;
}
.card .org { color: #6B6258; font-size: 14px; margin: 0 0 12px; }
.card .summary { color: #1F1B16; font-size: 14px; margin: 0 0 16px; flex: 1; }
.card .stats { font-size: 13px; color: #6B6258; margin: 0 0 12px; }
.card .stats strong { color: #1F1B16; font-weight: 500; }
.card .stats .verified { font-style: italic; }
.card .eligibility { font-size: 13px; margin: 0 0 16px; }
.card .eligibility li { list-style: none; padding-left: 18px; position: relative; }
.card .eligibility li::before { position: absolute; left: 0; }
.card .eligibility .badge-good { color: #2F6B3F; }
.card .eligibility .badge-good::before { content: "✓"; }
.card .eligibility .badge-warn { color: #8F4D14; }
.card .eligibility .badge-warn::before { content: "⚠"; }
.card .eligibility .badge-info { color: #6B6258; }
.card .eligibility .badge-info::before { content: "ℹ"; }
.card .apply {
  align-self: flex-start;
  color: #A8471C;
  background: transparent; border: none; padding: 0;
  font-weight: 600; font-size: 14px;
  border-bottom: 1px solid currentColor;
  transition: color 120ms ease, transform 120ms ease;
}
.card .apply:hover { color: #7A330E; transform: translateX(2px); }
.card.featured .apply,
.card.urgent .apply {
  padding: 8px 16px;
  background: #A8471C; color: #FFFFFF;
  border: none; border-radius: 4px;
}
.card.featured .apply:hover,
.card.urgent .apply:hover { background: #7A330E; color: #FFFFFF; transform: none; }
.card .apply.disabled { background: #C8C0B2; pointer-events: none; }

/* Prose sections (About, Sources) */
.prose-section { padding: 96px 24px 0; max-width: 760px; margin: 0 auto; }
.prose-section:target { scroll-margin-top: 80px; }
#about, #sources { scroll-margin-top: 80px; }
.prose-inner { }
.prose-section h2 {
  font-family: 'Source Serif Pro', ui-serif, Georgia, serif;
  font-size: 32px; margin: 0 0 24px; letter-spacing: -0.01em;
}
.prose-section p { margin: 0 0 16px; color: #1F1B16; font-size: 16px; }
.prose-section .sources-list {
  list-style: none; padding: 0; margin: 16px 0 24px;
}
.prose-section .sources-list li {
  padding: 14px 0; border-bottom: 1px solid #EAE4D9;
  font-size: 15px; line-height: 1.55;
}
.prose-section .sources-list li:first-child { border-top: 1px solid #EAE4D9; }
.prose-section .sources-list a { font-weight: 600; }
.prose-section .sources-note {
  color: #6B6258; font-size: 14px; font-style: italic;
}

/* Signup */
.signup { padding-top: 96px; padding-bottom: 96px; max-width: 600px; margin: 0 auto; text-align: center; }
.signup h2 {
  font-family: 'Source Serif Pro', ui-serif, Georgia, serif;
  font-size: 32px; margin: 0 0 12px;
}
.signup p { color: #6B6258; margin: 0 0 32px; }
.signup .signup-soon {
  background: #FFFFFF; border: 1px solid #EAE4D9; border-radius: 6px;
  padding: 24px; max-width: 480px; margin: 0 auto; color: #1F1B16;
  font-size: 15px; line-height: 1.55;
}
.signup .signup-soon a { font-weight: 500; }

/* Signup form */
.signup-form {
  max-width: 480px; margin: 0 auto; text-align: left;
  background: #FFFFFF; border: 1px solid #EAE4D9; border-radius: 6px; padding: 24px;
}
.signup-row { display: flex; gap: 12px; }
.signup-row .signup-field { flex: 1; }
.signup-field { display: block; margin: 0 0 14px; }
.signup-label { display: block; font-size: 13px; font-weight: 500; color: #1F1B16; margin: 0 0 5px; }
.signup-optional { font-weight: 400; color: #8A8073; }
.signup-form input[type="text"], .signup-form input[type="email"], .signup-form select {
  width: 100%; box-sizing: border-box; padding: 10px 12px;
  font: inherit; font-size: 15px; color: #1F1B16;
  background: #FDFCFA; border: 1px solid #D9D2C5; border-radius: 5px;
}
.signup-form input:focus-visible, .signup-form select:focus-visible {
  outline: 2px solid #1F1B16; outline-offset: 1px; border-color: #1F1B16;
}
.signup-consent {
  display: flex; gap: 9px; align-items: flex-start; margin: 4px 0 16px;
  font-size: 13px; line-height: 1.5; color: #6B6258;
}
.signup-consent input { margin-top: 2px; flex-shrink: 0; }
.signup-form button[type="submit"] {
  width: 100%; padding: 12px 16px; font: inherit; font-size: 15px; font-weight: 600;
  color: #FDFCFA; background: #1F1B16; border: 0; border-radius: 5px; cursor: pointer;
}
.signup-form button[type="submit"]:hover { background: #34302A; }
.signup-form button[type="submit"]:disabled { opacity: .6; cursor: default; }
.signup-form .signup-status { margin: 12px 0 0; font-size: 14px; min-height: 1.2em; }
.signup-form .signup-status.is-error { color: #9B2C2C; }
.signup-form .signup-status.is-success { color: #2F6F4F; font-weight: 500; }
/* Honeypot — visually removed, kept off-screen in the tab/a11y flow */
.signup-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.signup .signup-fallback { font-size: 14px; color: #6B6258; margin: 16px auto 0; max-width: 480px; }

/* Privacy */
.privacy { max-width: 600px; margin: 0 auto; padding: 0 24px 64px; color: #6B6258; font-size: 14px; line-height: 1.6; text-align: center; }
.privacy h2 { font-family: 'Source Serif Pro', ui-serif, Georgia, serif; font-size: 22px; color: #1F1B16; margin: 0 0 10px; }
.privacy a { font-weight: 500; }

/* Footer */
footer { padding: 64px 24px 48px; color: #6B6258; font-size: 13px; border-top: 1px solid #EAE4D9; }
.footer-inner {
  max-width: 1200px; margin: 0 auto;
  display: flex; flex-wrap: wrap; gap: 16px 32px; align-items: center;
}
.footer-brand {
  font-family: 'Source Serif Pro', ui-serif, Georgia, serif;
  font-weight: 700; font-size: 16px; color: #1F1B16;
  margin: 0;
}
.footer-nav { display: flex; gap: 24px; flex-wrap: wrap; }
.footer-nav a { color: #6B6258; border-bottom: 1px solid #C8C0B2; }
.footer-nav a:hover { color: #1F1B16; }
.footer-meta { margin-left: auto; margin: 0; }
@media (max-width: 640px) {
  .footer-meta { margin-left: 0; }
}

/* Load more */
.load-more {
  display: block; margin: 32px auto 0; padding: 12px 24px;
  background: transparent; color: #1F1B16;
  border: 1px solid #1F1B16; border-radius: 4px;
  font-weight: 500;
}
.load-more:hover { background: #1F1B16; color: #FBF7F0; }

/* Focus visible — keyboard navigation affordance */
:where(a, button, select, input, [tabindex]):focus-visible {
  outline: 2px solid #1F1B16;
  outline-offset: 2px;
  border-radius: 2px;
}

/* Visually hidden but available to assistive tech */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* Skip link — first focusable element; visible only when focused */
.skip-link {
  position: absolute; left: 8px; top: -48px;
  background: #1F1B16; color: #FBF7F0; border: none;
  padding: 10px 16px; border-radius: 4px; z-index: 100;
  transition: top 120ms ease;
}
.skip-link:focus { top: 8px; }

/* Zero-result empty state (spans the full grid) */
.empty-state {
  grid-column: 1 / -1;
  text-align: center; padding: 64px 24px;
  border: 1px dashed #8C8472; border-radius: 8px;
  background: #FFFDF9;
}
.empty-state .empty-title {
  font-family: 'Source Serif Pro', ui-serif, Georgia, serif;
  font-size: 20px; color: #1F1B16; margin: 0 0 8px;
}
.empty-state .empty-sub { color: #6B6258; font-size: 15px; margin: 0 0 20px; }
.empty-state .empty-reset {
  padding: 10px 20px; background: #A8471C; color: #FFFFFF;
  border: none; border-radius: 4px; font-weight: 600;
}
.empty-state .empty-reset:hover { background: #7A330E; }

/* Respect reduced-motion preferences (WCAG 2.3.3) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
  .card .apply:hover { transform: none; }
}

/* Mobile filter stack */
@media (max-width: 640px) {
  .filters-primary { gap: 12px; }
  .filters-grid { gap: 12px; }
  .filters label { width: 100%; }
  .filters fieldset.effort { width: 100%; }
  .filters select { width: 100%; }
  .filters-primary .sort { margin-left: 0; }
  .hero { padding-top: 64px; padding-bottom: 64px; }
  /* Hero persona picker: stack the label + dropdown so the select doesn't overflow narrow screens */
  .hero-actions { gap: 16px; }
  .audience-picker { width: 100%; flex-wrap: wrap; gap: 6px; }
  .audience-picker select { width: 100%; }
}
