:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #1a1d23;
  --muted: #5b6270;
  --accent: #4f46e5;
  --border: #e4e6eb;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  --shadow-hover: 0 4px 12px rgba(16, 24, 40, 0.12), 0 2px 6px rgba(16, 24, 40, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --surface: #1e2128;
    --text: #f0f1f3;
    --muted: #9aa1ac;
    --accent: #818cf8;
    --border: #2c3038;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 6px 16px rgba(0, 0, 0, 0.4);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
}

.page-header {
  text-align: center;
  padding: 3rem 1.5rem 2rem;
}

.page-header h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.75rem, 4vw, 2.5rem);
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem 3rem;
}

.section-title {
  margin: 0 0 0.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
}

.section-title + .grid,
.section-note + .grid {
  margin-top: 1rem;
}

.grid + .section-title {
  margin-top: 2.75rem;
}

.section-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ---- recherche ---- */

.search-bar {
  position: relative;
  display: flex;
  align-items: center;
  margin-bottom: 1rem;
}

.search-icon {
  position: absolute;
  left: 1rem;
  font-size: 0.95rem;
  opacity: 0.55;
  pointer-events: none;
}

#q {
  width: 100%;
  padding: 0.85rem 2.6rem;
  font: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  -webkit-appearance: none;
  appearance: none;
}

#q::-webkit-search-cancel-button { display: none; }

#q:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

#clear {
  position: absolute;
  right: 0.6rem;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

#clear:hover { color: var(--text); background: var(--bg); }

/* ---- tags ---- */

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 2rem;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.7rem;
  font: inherit;
  font-size: 0.82rem;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

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

.tag.on {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.tag-count {
  font-size: 0.72rem;
  opacity: 0.65;
  font-variant-numeric: tabular-nums;
}

.tag-clear { border-style: dashed; }

/* les tags portés par une card : plus discrets, et cliquables par-dessus le
   lien qui couvre la card */
.card-tags {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.9rem;
}

.tag-sm {
  padding: 0.15rem 0.5rem;
  font-size: 0.72rem;
  background: var(--bg);
}

/* ---- résultats ---- */

.result-count {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.empty {
  margin: 2rem 0;
  color: var(--muted);
  text-align: center;
}

/* ---- cards de catégorie ---- */

.cat-card {
  padding: 1.6rem 1.4rem;
  text-align: left;
  font: inherit;
  cursor: pointer;
}

.cat-card .card-icon { font-size: 2.6rem; }
.cat-card .card-title { font-size: 1.3rem; }
.cat-card .card-link { color: var(--muted); transition: color 0.15s ease; }

.cat-card:hover .card-link,
.cat-card:focus-visible .card-link { color: var(--accent); }

.badge {
  display: inline-block;
  vertical-align: middle;
  margin-left: 0.4rem;
  padding: 0.1rem 0.4rem;
  border: 1px solid var(--accent);
  border-radius: 999px;
  color: var(--accent);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
  text-decoration: none;
  color: var(--text);
  text-align: left;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

/* le lien du titre couvre toute la card : elle reste cliquable partout, mais
   les tags posés au-dessus gardent leur propre clic */
.card-title a {
  color: inherit;
  text-decoration: none;
}

.card-title a::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.card:has(.card-title a:hover),
.card:has(.card-title a:focus-visible) {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
  border-color: var(--accent);
}

.card:hover,
.card:focus-visible {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
  border-color: var(--accent);
}

.card-icon {
  font-size: 2.25rem;
  margin-bottom: 0.75rem;
  line-height: 1;
}

.card-title {
  margin: 0 0 0.5rem;
  font-size: 1.2rem;
}

.card-desc {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.95rem;
  flex-grow: 1;
}

.card-link {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
}

.page-footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.page-footer a {
  color: var(--accent);
}
