/* Design tokens mirror the WISE Data Collection map (jaimiechun/lib-map-v2)
   so the two sites read as one project: warm neutral surfaces, teal accent,
   Geist, soft tinted badges, and the same radii/shadow. */
:root {
  /* Warm neutral palette (surfaces, hairlines, ink) */
  --bg: #faf8f4;
  --surface: #fdfcfa;
  --surface-hover: #f4f1eb;
  --pill: #efece6;
  --border: #e6e1d8;
  --border-strong: #d6d0c5;
  --ink: #22211e;
  --muted: #76726a;
  --faint: #a8a39a;

  /* Brand accent */
  --teal: #0e7c7b;
  --teal-hover: #0b6362;

  /* Soft format tints — the blue matches the map's "ongoing" tint; the
     terracotta is its warm-palette counterpart for PDFs. */
  --doc-bg: #e3edf5;
  --doc-ink: #2f5d85;
  --doc-border: #cfdfec;
  --pdf-bg: #f6e4dd;
  --pdf-ink: #a04a2f;
  --pdf-border: #ecd2c7;

  --radius-card: 16px;
  --radius-control: 10px;
  --shadow-float: 0 1px 2px rgba(34, 33, 30, 0.04), 0 8px 24px rgba(34, 33, 30, 0.08);
  --font: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Header ---------- */

#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

#brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

#brand-logo {
  height: 30px;
  width: auto;
  flex-shrink: 0;
}

#brand h1 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
  line-height: 1.2;
}

#subtitle {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
}

#header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

#stats {
  font-size: 12.5px;
  color: var(--muted);
  display: flex;
  gap: 14px;
  white-space: nowrap;
}

#stats b {
  color: var(--ink);
  font-weight: 600;
}

#submit-open {
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #fff;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-control);
  padding: 8px 14px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s;
}

#submit-open:hover { background: #3a3833; }

/* ---------- Layout ---------- */

#main {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px 20px 48px;
}

/* ---------- Controls ---------- */

#controls {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-float);
  padding: 14px;
  margin-bottom: 14px;
}

#search-wrap {
  position: relative;
  margin-bottom: 12px;
}

#q {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  padding: 9px 36px 9px 12px;
  font-size: 13px;
  font-family: inherit;
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  appearance: none;
}

#q::placeholder { color: var(--faint); }
#q::-webkit-search-cancel-button { -webkit-appearance: none; }

#q:focus {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px var(--pill);
}

#search-icon {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  color: var(--muted);
  display: flex;
  pointer-events: none;
}

.control-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.control {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1 1 160px;
  min-width: 0;
}

.control[hidden] { display: none; }

.control-label {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
}

.control input,
.control select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  padding: 8px 11px;
  font-size: 13px;
  font-family: inherit;
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.control input::placeholder { color: var(--faint); }

.control input:focus,
.control select:focus {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px var(--pill);
}

/* ---------- Toolbar ---------- */

.toolbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 0 4px 10px;
}

.result-count {
  font-size: 12.5px;
  color: var(--muted);
}

.toolbar-bulk {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--faint);
}

.toolbar-bulk button {
  border: none;
  background: none;
  padding: 0;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
}

.toolbar-bulk button:hover { color: var(--ink); }

/* ---------- Groups ---------- */

#results {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.group {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
}

.group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  border: none;
  background: none;
  font-family: inherit;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}

.group-header:hover { background: var(--surface-hover); }

.group-heading {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.group-name {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.group-summary {
  font-size: 11.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.group-count {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
  background: var(--pill);
  border-radius: 999px;
  padding: 4px 10px;
  white-space: nowrap;
  flex-shrink: 0;
}

.group-chev {
  display: inline-flex;
  align-items: center;
  transition: transform 0.15s;
}

.group:not(.is-collapsed) .group-chev { transform: rotate(180deg); }
.group.is-collapsed .group-body { display: none; }

/* ---------- Entries ---------- */

.entry {
  border-top: 1px solid var(--border);
  padding: 12px 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.entry-body { min-width: 0; flex: 1 1 260px; }

.entry-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  margin: 0 0 3px;
}

.entry-meta {
  font-size: 12.5px;
  color: var(--muted);
  margin: 0;
}

.entry-note {
  font-size: 12.5px;
  color: var(--muted);
  margin: 6px 0 0;
}

.entry-source {
  font-size: 11.5px;
  color: var(--faint);
  margin: 3px 0 0;
}

.entry-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex-shrink: 0;
}

/* Format links: shaped like the map's info buttons, tinted by file type so
   Word and PDF stay distinguishable at a glance. */
.file-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius-control);
  padding: 6px 11px;
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: filter 0.15s, background 0.15s;
}

.file-btn:hover { filter: brightness(0.97); }

.file-btn.is-doc {
  background: var(--doc-bg);
  border-color: var(--doc-border);
  color: var(--doc-ink);
}

.file-btn.is-pdf {
  background: var(--pdf-bg);
  border-color: var(--pdf-border);
  color: var(--pdf-ink);
}

.file-btn-arrow { font-size: 11px; opacity: 0.75; }

/* ---------- Misc ---------- */

.empty {
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  padding: 28px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

.empty a { color: var(--ink); }

#site-footer {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--muted);
}

#site-footer a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 2px;
}

#site-footer a:hover { text-decoration-color: var(--ink); }

@media (max-width: 640px) {
  #header { padding: 12px 16px; }
  #header-right { width: 100%; justify-content: space-between; gap: 10px; }
  #stats { white-space: normal; gap: 10px; font-size: 12px; }
  #main { padding: 16px 16px 40px; }
  .group-summary { display: none; }
  .entry-links { width: 100%; }
}

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