/* ==========================================================================
   Pipsy — a personal research archive
   Plain CSS, no build step. Palette and type are set as custom properties
   at the top of :root — change values there to re-theme the whole site.
   ========================================================================== */

:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --ink: #26231d;
  --ink-muted: #736c5e;
  --ink-faint: #a39c8c;
  --border: #e6dfd2;
  --accent: #9a4b32;
  --accent-ink: #ffffff;
  --accent-tint: #f3e3db;
  --focus: #4a6b63;

  --font-serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --radius: 6px;
  --wrap: 1080px;
}

* {
  box-sizing: border-box;
}

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

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

.wrap {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 24px;
}

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

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

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

.site-header {
  border-bottom: 1px solid var(--border);
  padding: 48px 0 32px;
}

.wordmark {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 2.4rem;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}

.tagline {
  margin: 0;
  color: var(--ink-muted);
  font-size: 1.02rem;
}

/* ---------- controls: search + filters ---------- */

.controls {
  padding: 32px 0 8px;
}

.search-row {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

#search-input {
  flex: 1 1 320px;
  font-family: var(--font-sans);
  font-size: 1rem;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}

#search-input:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(74, 107, 99, 0.15);
}

#search-input::placeholder {
  color: var(--ink-faint);
}

.count {
  margin: 0;
  white-space: nowrap;
  color: var(--ink-muted);
  font-size: 0.9rem;
}

.filter-groups {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 20px 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.filter-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

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

.chip:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.clear-btn {
  align-self: flex-end;
  margin-left: auto;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.clear-btn:hover {
  color: var(--ink);
}

/* ---------- grid + cards ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
  padding: 32px 0 24px;
}

.note-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.note-card:hover {
  border-color: var(--ink-faint);
  box-shadow: 0 6px 20px rgba(38, 35, 29, 0.07);
  transform: translateY(-1px);
}

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

.card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.badge {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent-tint);
  color: var(--accent);
}

.badge-geography,
.badge-year {
  background: #f0efe9;
  color: var(--ink-muted);
}

.card-title {
  font-family: var(--font-serif);
  font-size: 1.28rem;
  font-weight: 600;
  line-height: 1.3;
  margin: 0 0 8px;
}

.card-byline {
  margin: 0 0 12px;
  font-size: 0.82rem;
  color: var(--ink-faint);
}

.card-summary {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.95rem;
  line-height: 1.6;
  flex: 1;
}

.note-card template {
  display: none;
}

/* ---------- empty state ---------- */

.empty-state {
  text-align: center;
  color: var(--ink-muted);
  font-size: 1rem;
  padding: 64px 24px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  margin: 0 0 48px;
}

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

.site-footer {
  border-top: 1px solid var(--border);
  padding: 28px 0 48px;
  margin-top: 24px;
}

.site-footer p {
  margin: 0;
  color: var(--ink-faint);
  font-size: 0.85rem;
}

.site-footer code {
  background: var(--accent-tint);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.85em;
}

/* ---------- modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(38, 35, 29, 0.5);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 5vh 20px;
  z-index: 100;
  overflow-y: auto;
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  max-width: 680px;
  width: 100%;
  padding: 40px 40px 48px;
  position: relative;
  box-shadow: 0 24px 60px rgba(38, 35, 29, 0.25);
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.modal-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 16px;
  padding-right: 40px;
}

.modal-title {
  font-family: var(--font-serif);
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1.3;
  margin: 0 0 8px;
  padding-right: 20px;
}

.modal-byline {
  margin: 0 0 24px;
  color: var(--ink-faint);
  font-size: 0.85rem;
}

.modal-body {
  font-size: 1rem;
  line-height: 1.75;
  color: var(--ink);
}

.modal-body p {
  margin: 0 0 18px;
}

.modal-body p:last-child {
  margin-bottom: 0;
}

/* ---------- responsive ---------- */

@media (max-width: 640px) {
  .wrap {
    padding: 0 16px;
  }

  .site-header {
    padding: 36px 0 24px;
  }

  .wordmark {
    font-size: 2rem;
  }

  .search-row {
    flex-direction: column;
    align-items: stretch;
  }

  #search-input {
    flex: none;
    width: 100%;
  }

  .count {
    order: 2;
  }

  .clear-btn {
    margin-left: 0;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .modal {
    padding: 32px 24px 36px;
  }

  .modal-title {
    font-size: 1.4rem;
  }
}
