/* ===== CSS Reset & Variables ===== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --clr-bg: #0f0f13;
  --clr-surface: #1a1a24;
  --clr-surface-hover: #22222f;
  --clr-border: #2a2a3a;
  --clr-primary: #a855f7;
  --clr-primary-light: #c084fc;
  --clr-primary-dark: #7c3aed;
  --clr-accent: #ec4899;
  --clr-accent-light: #f472b6;
  --clr-text: #e4e4eb;
  --clr-text-muted: #9494a8;
  --clr-text-dim: #6b6b80;
  --clr-tag-bg: rgba(168, 85, 247, 0.12);
  --clr-tag-text: #c084fc;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.25);
  --shadow-hover: 0 8px 30px rgba(168, 85, 247, 0.15);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Outfit', var(--font-sans);
  --max-width: 1200px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-sans);
  background: var(--clr-bg);
  color: var(--clr-text);
  line-height: 1.7;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--clr-primary-light);
  text-decoration: none;
  transition: color var(--transition);
}

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

img {
  max-width: 100%;
  display: block;
}

/* ===== Typography ===== */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  line-height: 1.2;
  font-weight: 700;
}

h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  letter-spacing: -0.03em;
}

h2 {
  font-size: clamp(1.5rem, 3vw, 2.25rem);
  letter-spacing: -0.02em;
}

h3 {
  font-size: clamp(1.15rem, 2vw, 1.5rem);
}

/* ===== Layout ===== */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ===== Header / Nav ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15, 15, 19, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--clr-border);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.nav__logo {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--clr-primary), var(--clr-accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav__links {
  display: flex;
  gap: 2rem;
  list-style: none;
}

.nav__links a {
  color: var(--clr-text-muted);
  font-size: 0.95rem;
  font-weight: 500;
  position: relative;
}

.nav__links a::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--clr-primary);
  transition: width var(--transition);
}

.nav__links a:hover {
  color: var(--clr-text);
}

.nav__links a:hover::after {
  width: 100%;
}

.nav__hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 4px;
}

.nav__hamburger span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--clr-text);
  border-radius: 2px;
  transition: var(--transition);
}

/* ===== Hero Section ===== */
.hero {
  padding: 5rem 0 4rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: -50%;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(168, 85, 247, 0.08) 0%, transparent 70%);
  pointer-events: none;
}

.hero__subtitle {
  color: var(--clr-text-muted);
  font-size: clamp(1rem, 2vw, 1.25rem);
  max-width: 640px;
  margin: 1rem auto 2rem;
}

.hero__search {
  max-width: 500px;
  margin: 0 auto;
  position: relative;
}

.hero__search input {
  width: 100%;
  padding: 0.9rem 1.25rem 0.9rem 3rem;
  border: 1px solid var(--clr-border);
  border-radius: 50px;
  background: var(--clr-surface);
  color: var(--clr-text);
  font-size: 1rem;
  font-family: var(--font-sans);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.hero__search input::placeholder {
  color: var(--clr-text-dim);
}

.hero__search input:focus {
  border-color: var(--clr-primary);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.15);
}

.hero__search svg {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--clr-text-dim);
  width: 20px;
  height: 20px;
}

/* ===== Category Filter ===== */
.filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 3rem;
}

.filter-btn {
  padding: 0.45rem 1.1rem;
  border: 1px solid var(--clr-border);
  border-radius: 50px;
  background: transparent;
  color: var(--clr-text-muted);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.filter-btn:hover,
.filter-btn.active {
  background: var(--clr-primary);
  border-color: var(--clr-primary);
  color: #fff;
}

/* ===== Card Grid ===== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
  margin-bottom: 4rem;
}

.card {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-md);
  padding: 1.75rem;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
  border-color: var(--clr-primary-dark);
}

.card__icon {
  font-size: 2rem;
  margin-bottom: 0.75rem;
}

.card__title {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
  color: var(--clr-text);
}

.card__desc {
  color: var(--clr-text-muted);
  font-size: 0.92rem;
  line-height: 1.6;
  flex: 1;
}

.card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 1rem;
}

.tag {
  padding: 0.2rem 0.65rem;
  background: var(--clr-tag-bg);
  color: var(--clr-tag-text);
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 500;
}

/* ===== Detail Page ===== */
.detail {
  max-width: 780px;
  margin: 0 auto;
  padding: 3rem 1.5rem 5rem;
}

.detail__back {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--clr-text-muted);
  font-size: 0.9rem;
  margin-bottom: 2rem;
}

.detail__back:hover {
  color: var(--clr-primary-light);
}

.detail__icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.detail h1 {
  margin-bottom: 1rem;
}

.detail__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 2rem;
}

.detail__content h2 {
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
  font-size: 1.4rem;
  color: var(--clr-primary-light);
}

.detail__content h3 {
  margin-top: 2rem;
  margin-bottom: 0.5rem;
  font-size: 1.15rem;
}

.detail__content p {
  margin-bottom: 1rem;
  color: var(--clr-text-muted);
}

.detail__content ul,
.detail__content ol {
  margin: 0.5rem 0 1.5rem 1.5rem;
  color: var(--clr-text-muted);
}

.detail__content li {
  margin-bottom: 0.4rem;
}

.detail__content blockquote {
  border-left: 3px solid var(--clr-primary);
  padding: 0.75rem 1.25rem;
  margin: 1.5rem 0;
  background: rgba(168, 85, 247, 0.05);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--clr-text-muted);
  font-style: italic;
}

.info-box {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  margin: 1.5rem 0;
}

.info-box__title {
  font-weight: 600;
  color: var(--clr-primary-light);
  margin-bottom: 0.4rem;
}

/* ===== Related Grid ===== */
.related {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--clr-border);
}

.related h2 {
  margin-bottom: 1.25rem;
  font-size: 1.3rem;
}

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

/* ===== Footer ===== */
.site-footer {
  border-top: 1px solid var(--clr-border);
  padding: 2.5rem 0;
  text-align: center;
  color: var(--clr-text-dim);
  font-size: 0.85rem;
}

.site-footer a {
  color: var(--clr-text-muted);
}

.site-footer p + p {
  margin-top: 0.4rem;
}

/* ===== About / Glossary Pages ===== */
.page-header {
  padding: 3rem 0 2rem;
  text-align: center;
}

.page-header p {
  color: var(--clr-text-muted);
  max-width: 600px;
  margin: 0.75rem auto 0;
}

.prose {
  max-width: 720px;
  margin: 0 auto;
  padding-bottom: 4rem;
}

.prose p {
  margin-bottom: 1rem;
  color: var(--clr-text-muted);
}

.prose h2 {
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
  color: var(--clr-primary-light);
  font-size: 1.35rem;
}

.prose ul {
  margin: 0.5rem 0 1.5rem 1.5rem;
  color: var(--clr-text-muted);
}

.prose li {
  margin-bottom: 0.35rem;
}

/* ===== Glossary Table ===== */
.glossary-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.glossary-list li {
  padding: 1rem 0;
  border-bottom: 1px solid var(--clr-border);
}

.glossary-list dt {
  font-weight: 600;
  color: var(--clr-text);
  margin-bottom: 0.25rem;
}

.glossary-list dd {
  color: var(--clr-text-muted);
  font-size: 0.93rem;
}

/* ===== Breadcrumb ===== */
.breadcrumb {
  font-size: 0.85rem;
  color: var(--clr-text-dim);
  padding: 1rem 0;
}

.breadcrumb a {
  color: var(--clr-text-muted);
}

.breadcrumb span {
  margin: 0 0.4rem;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .nav__links {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--clr-surface);
    border-bottom: 1px solid var(--clr-border);
    padding: 1rem 1.5rem;
    gap: 1rem;
  }

  .nav__links.open {
    display: flex;
  }

  .nav__hamburger {
    display: flex;
  }

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

  .hero {
    padding: 3rem 0 2.5rem;
  }

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

@media (max-width: 480px) {
  .related-grid {
    grid-template-columns: 1fr;
  }
}

/* ===== Skip link (a11y) ===== */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--clr-primary);
  color: #fff;
  padding: 0.5rem 1rem;
  z-index: 200;
  transition: top var(--transition);
}

.skip-link:focus {
  top: 0;
}

/* ===== No-results state ===== */
.no-results {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--clr-text-dim);
  display: none;
}

.no-results.visible {
  display: block;
}
