/* ─── Reset & base ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #f5f6f8;
  --surface:   #ffffff;
  --border:    #e2e5ea;
  --text:      #1a1d23;
  --text-muted:#5c6370;
  --accent:    #1a56db;
  --header-bg: #0f172a;
  --nav-bg:    #1e2a3b;
  --radius:    10px;
  --shadow:    0 1px 4px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  font-size: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── Header ─────────────────────────────────────────────────────────────── */
header {
  background: var(--header-bg);
  color: #fff;
  padding: 2rem 1.5rem 1.75rem;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -.02em;
}

header p {
  font-size: .95rem;
  color: #94a3b8;
  max-width: 600px;
  line-height: 1.55;
}

/* Search */
.search-wrap {
  width: 100%;
  max-width: 480px;
}

#search {
  width: 100%;
  padding: .65rem 1rem;
  border: 2px solid #334155;
  border-radius: 8px;
  background: #1e293b;
  color: #f1f5f9;
  font-size: .95rem;
  outline: none;
  transition: border-color .15s;
}

#search::placeholder { color: #64748b; }
#search:focus { border-color: #3b82f6; }

/* ─── Category nav ───────────────────────────────────────────────────────── */
nav#category-nav {
  background: var(--nav-bg);
  padding: .65rem 1.5rem;
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  border-bottom: 1px solid #0f172a;
}

.cat-btn {
  padding: .35rem .85rem;
  border: 1.5px solid transparent;
  border-radius: 20px;
  background: transparent;
  color: #94a3b8;
  font-size: .82rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s;
}

.cat-btn:hover {
  background: rgba(255,255,255,.08);
  color: #e2e8f0;
}

.cat-btn.active {
  background: rgba(255,255,255,.12);
  color: #f1f5f9;
  border-color: rgba(255,255,255,.2);
}

/* colored dot next to each category button */
.cat-btn .dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: .35rem;
  vertical-align: middle;
  margin-top: -1px;
}

/* ─── Main / grid ────────────────────────────────────────────────────────── */
main {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem;
}

.summary {
  font-size: .82rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

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

/* ─── Source card ────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: box-shadow .15s, transform .1s;
}

.card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,.12), 0 8px 32px rgba(0,0,0,.1);
  transform: translateY(-1px);
}

/* top color bar */
.card-stripe {
  height: 4px;
  flex-shrink: 0;
}

.card-body {
  padding: 1rem 1.1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: .55rem;
}

/* name row */
.card-title-row {
  display: flex;
  align-items: baseline;
  gap: .5rem;
  flex-wrap: wrap;
}

.card-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.card-acronym {
  font-size: .72rem;
  font-weight: 600;
  color: #fff;
  padding: .1rem .4rem;
  border-radius: 4px;
  flex-shrink: 0;
}

/* owner / agency */
.card-owner {
  font-size: .78rem;
  color: var(--text-muted);
  font-style: italic;
}

/* description */
.card-desc {
  font-size: .875rem;
  color: #374151;
  line-height: 1.6;
  flex: 1;
}

/* meta tags row */
.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin-top: .25rem;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  font-size: .72rem;
  font-weight: 500;
  padding: .18rem .55rem;
  border-radius: 4px;
  background: #f1f3f6;
  color: #4b5563;
  border: 1px solid #e2e5ea;
}

.tag-icon { font-style: normal; }

/* notes */
.card-notes {
  font-size: .78rem;
  color: var(--text-muted);
  border-left: 3px solid var(--border);
  padding-left: .6rem;
  line-height: 1.5;
}

/* links */
.card-links {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  padding: .75rem 1.1rem;
  border-top: 1px solid var(--border);
  background: #fafbfc;
}

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .78rem;
  font-weight: 600;
  padding: .3rem .7rem;
  border-radius: 6px;
  text-decoration: none;
  transition: opacity .15s;
}

.link-btn:hover { opacity: .8; }

.link-btn-primary {
  background: var(--accent);
  color: #fff;
}

.link-btn-free {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #6ee7b7;
}

.link-btn-key {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
}

/* ─── States ─────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

.empty, .error-msg {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text-muted);
  font-size: .95rem;
}

.error-msg { color: #dc2626; }

/* Loading skeleton */
.skeleton-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  height: 240px;
  position: relative;
  overflow: hidden;
}

.skeleton-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,.6) 50%, transparent 100%);
  animation: shimmer 1.2s infinite;
  background-size: 200% 100%;
}

@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

/* ─── Footer ─────────────────────────────────────────────────────────────── */
footer {
  text-align: center;
  padding: 1.25rem;
  font-size: .78rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: var(--surface);
}

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  header { padding: 1.25rem 1rem 1rem; }
  header h1 { font-size: 1.35rem; }
  main { padding: 1rem; }
  .grid { grid-template-columns: 1fr; }
  nav#category-nav { padding: .5rem 1rem; }
}

@media (min-width: 900px) {
  .header-inner {
    flex-direction: row;
    align-items: flex-end;
    justify-content: space-between;
  }
}
