/* WRISES Tools & Resources
   Light, minimal design system. Colors are defined once below; every pairing meets WCAG AA. */

@font-face {
  font-family: "Public Sans";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/public-sans-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308,
    U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light;

  --font-sans: "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --bg: #ffffff;
  --surface: #f8fafc;
  --surface-strong: #f1f5f9;
  --text: #0f172a;
  --text-body: #334155;
  --muted: #475569;
  --border: #e2e8f0;
  --border-hover: #cbd5e1;
  --border-input: #64748b;
  --accent: #245b91;
  --accent-hover: #1d4a77;
  --accent-soft: #eef3f8;
  --accent-line: #b6cbe0;
  --status-bg: #fdf6ec;
  --status-text: #8a4b08;
  --status-line: #f1d9b5;

  --radius: 6px;
  --radius-lg: 8px;
  --container: 1120px;
  --gutter: 24px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.55;
  font-feature-settings: "kern";
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4,
p,
ul {
  margin: 0;
}

ul {
  padding: 0;
  list-style: none;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--accent-hover);
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.container {
  width: 100%;
  max-width: calc(var(--container) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.icon {
  flex: none;
  width: 1em;
  height: 1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

/* Skip link */

.skip-link {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 10;
  padding: 8px 14px;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-160%);
}

.skip-link:focus,
.skip-link:focus-visible {
  transform: none;
  color: #fff;
}

/* Header */

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 24px;
  min-height: 60px;
  padding-top: 10px;
  padding-bottom: 10px;
}

.brand {
  color: var(--text);
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: -0.005em;
  text-decoration: none;
}

.brand:hover {
  color: var(--text);
}

.brand-mark {
  color: var(--accent);
}

.site-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
}

.site-nav a {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 32px;
  color: var(--muted);
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
}

.site-nav a:hover {
  color: var(--text);
  text-decoration: underline;
}

.site-nav .icon {
  width: 0.85em;
  height: 0.85em;
}

/* Intro */

.intro {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  padding: 52px 0 40px;
}

.intro h1 {
  font-size: clamp(1.75rem, 1.45rem + 1vw, 2.25rem);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.lede {
  max-width: 44rem;
  margin-top: 12px;
  color: var(--text-body);
  font-size: 1.125rem;
  line-height: 1.5;
}

.intro-text {
  max-width: 44rem;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.9375rem;
}

.search {
  max-width: 40rem;
  margin-top: 28px;
}

.search-label {
  display: block;
  margin-bottom: 6px;
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 600;
}

.search-field {
  position: relative;
}

.search-icon {
  position: absolute;
  top: 50%;
  left: 14px;
  width: 18px;
  height: 18px;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 48px;
  padding: 0 14px 0 42px;
  border: 1px solid var(--border-input);
  border-radius: var(--radius-lg);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
}

.search-input::placeholder {
  color: #64748b;
  opacity: 1;
}

.search-input:focus {
  border-color: var(--accent);
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* Sections */

.section {
  padding: 40px 0 56px;
  scroll-margin-top: 12px;
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 16px;
  margin-bottom: 16px;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 650;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.result-status {
  color: var(--muted);
  font-size: 0.875rem;
}

/* Filters */

.filters {
  margin: 0 0 8px;
  padding: 0;
  border: 0;
  min-width: 0;
}

.filters-legend {
  float: left;
  width: 100%;
  margin-bottom: 8px;
  padding: 0;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 600;
}

.filter-options {
  clear: both;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-chip {
  position: relative;
  display: inline-flex;
  cursor: pointer;
}

.filter-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.filter-text {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-body);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.3;
  transition: border-color 120ms ease, background-color 120ms ease;
}

.filter-count {
  color: var(--muted);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}

.filter-chip:hover .filter-text {
  border-color: var(--border-hover);
}

.filter-input:checked + .filter-text {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.filter-input:checked + .filter-text .filter-count {
  color: var(--accent);
}

.filter-input:focus-visible + .filter-text {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.filter-chip.is-empty .filter-text {
  color: var(--muted);
}

/* Category groups */

.category-group {
  margin-top: 28px;
}

.group-head {
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.group-title {
  font-size: 1.0625rem;
  font-weight: 650;
  line-height: 1.35;
}

.group-count {
  margin-left: 6px;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.group-description {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.875rem;
}

/* Cards */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr));
  gap: 16px;
}

.card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg);
  overflow-wrap: anywhere;
  transition: border-color 120ms ease;
}

.card:hover {
  border-color: var(--border-hover);
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.4;
  text-transform: uppercase;
}

.badge {
  display: inline-block;
  padding: 1px 7px;
  border: 1px solid var(--status-line);
  border-radius: 4px;
  background: var(--status-bg);
  color: var(--status-text);
  font-size: 0.6875rem;
  letter-spacing: 0.04em;
}

.card-title {
  color: var(--text);
  font-size: 1.0625rem;
  font-weight: 650;
  line-height: 1.3;
  letter-spacing: -0.005em;
}

.card-subtitle {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.4;
}

.card-description {
  margin-top: 10px;
  color: var(--text-body);
  font-size: 0.9375rem;
  line-height: 1.55;
}

.card-note {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.45;
}

.card-note .icon {
  margin-top: 0.15em;
}

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

.tag {
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--surface-strong);
  color: var(--text-body);
  font-size: 0.75rem;
  line-height: 1.5;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  margin-top: auto;
  padding-top: 14px;
}

.card-actions::before {
  content: "";
  flex-basis: 100%;
  height: 0;
  margin-top: 2px;
  margin-bottom: 8px;
  border-top: 1px solid var(--border);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 34px;
  padding: 6px 13px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.button:hover {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
  color: #fff;
}

.button-secondary {
  background: var(--bg);
  color: var(--accent);
}

.button-secondary:hover {
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.action-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  color: var(--accent);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
}

.action-link:hover {
  text-decoration: underline;
}

/* States */

.loading,
.notice {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--muted);
}

.notice p + p {
  margin-top: 6px;
}

.notice-error {
  border-color: var(--status-line);
  background: var(--status-bg);
  color: var(--text-body);
}

.empty-state {
  margin-top: 20px;
  padding: 32px 20px;
  border: 1px dashed var(--border-hover);
  border-radius: var(--radius-lg);
  text-align: center;
}

.empty-state p {
  margin-bottom: 14px;
  color: var(--muted);
}

/* Footer */

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  font-size: 0.875rem;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
  padding-top: 20px;
  padding-bottom: 24px;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
}

/* 404 page */

.not-found {
  padding: 72px 0 96px;
}

.not-found p {
  max-width: 40rem;
  margin-top: 12px;
  color: var(--text-body);
}

.not-found .button {
  margin-top: 24px;
}

/* Small screens */

@media (max-width: 640px) {
  :root {
    --gutter: 16px;
  }

  .header-inner {
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .site-nav ul {
    gap: 2px 16px;
  }

  .intro {
    padding: 32px 0 28px;
  }

  .lede {
    font-size: 1.0625rem;
  }

  .search {
    margin-top: 22px;
  }

  .section {
    padding-top: 32px;
  }

  .card {
    padding: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
  }
}

@media (forced-colors: active) {
  .filter-input:checked + .filter-text {
    border: 2px solid Highlight;
  }

  .button {
    border: 1px solid ButtonText;
  }

  .badge,
  .tag {
    border: 1px solid CanvasText;
  }
}

@media print {
  .site-nav,
  .search,
  .filters,
  .skip-link {
    display: none !important;
  }

  .card {
    break-inside: avoid;
  }

  .action-link::after {
    content: " (" attr(href) ")";
    font-weight: 400;
  }
}
