/*
 * Category Hub & Archive Stylesheet — /categories/ and /category/{slug}/
 *
 * Scoped to .as-cat-* classes only.
 * Full integration with apstyle.css design tokens, Syne & Inter typography,
 * dark mode support, fluid grids, and accessible components.
 */

/* ── Shell ─────────────────────────────────────────────────────────────── */

.as-cat-wrap {
  max-width: var(--wrap-w, 1360px);
  margin: 0 auto;
  padding: 40px 24px 96px;
  font-family: var(--font-body, 'Inter', system-ui, sans-serif);
  color: var(--ink, #0f172a);
}

/* ── Breadcrumbs ───────────────────────────────────────────────────────── */

.as-cat-crumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--font-xs, 12px);
  font-weight: var(--font-semibold, 600);
  color: var(--ink-mut, #64748b);
  margin-bottom: 24px;
}

.as-cat-crumbs a {
  color: var(--ink-mut, #64748b);
  text-decoration: none;
  transition: color 0.15s ease;
}

.as-cat-crumbs a:hover {
  color: var(--brand, #ff4500);
}

.as-cat-crumbs span[aria-current="page"] {
  color: var(--brand, #ff4500);
}

/* ── Hero Banner ───────────────────────────────────────────────────────── */

.as-cat-hero {
  position: relative;
  background: var(--bg-soft, #ffffff);
  border: 1px solid var(--line, #e2e8f0);
  border-radius: var(--r-xl, 24px);
  padding: clamp(32px, 5vw, 56px);
  margin-bottom: 36px;
  box-shadow: var(--shadow-sm, 0 4px 20px rgba(0, 0, 0, 0.04));
  overflow: hidden;
}

.as-cat-hero-glow {
  position: absolute;
  top: -120px;
  right: -100px;
  width: 380px;
  height: 380px;
  background: radial-gradient(circle, rgba(255, 69, 0, 0.15) 0%, rgba(255, 69, 0, 0) 70%);
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
}

.as-cat-hero-inner {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 28px;
}

.as-cat-hero-text {
  max-width: 760px;
}

.as-cat-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--brand-bg-soft, rgba(255, 69, 0, 0.08));
  color: var(--brand, #ff4500);
  border: 1px solid var(--brand-border-soft, rgba(255, 69, 0, 0.2));
  font-size: var(--font-xs, 12px);
  font-weight: var(--font-extrabold, 800);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider, 0.08em);
  padding: 6px 16px;
  border-radius: var(--r-pill, 100px);
  margin-bottom: 16px;
}

.as-cat-h1 {
  font-family: var(--font-display, 'Syne', sans-serif);
  font-size: clamp(32px, 4.5vw, 48px);
  font-weight: var(--font-extrabold, 800);
  line-height: var(--leading-tight, 1.15);
  letter-spacing: var(--tracking-tight, -0.02em);
  color: var(--ink, #0f172a);
  margin: 0 0 14px;
}

.as-cat-h1 em {
  font-style: normal;
  background: linear-gradient(135deg, #ff4500 0%, #ff8c00 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.as-cat-desc {
  font-size: var(--font-base, 15px);
  line-height: var(--leading-relaxed, 1.65);
  color: var(--ink-soft, #475569);
  margin: 0;
}

.as-cat-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.as-cat-btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--brand, #ff4500);
  color: #ffffff !important;
  font-weight: var(--font-bold, 700);
  font-size: var(--font-sm, 13.5px);
  padding: 12px 24px;
  border-radius: var(--r-pill, 100px);
  text-decoration: none;
  box-shadow: 0 4px 16px rgba(255, 69, 0, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.as-cat-btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(255, 69, 0, 0.45);
}

.as-cat-btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg, #f8fafc);
  color: var(--ink, #0f172a) !important;
  border: 1px solid var(--line, #e2e8f0);
  font-weight: var(--font-bold, 700);
  font-size: var(--font-sm, 13.5px);
  padding: 12px 22px;
  border-radius: var(--r-pill, 100px);
  text-decoration: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.as-cat-btn-ghost:hover {
  border-color: var(--brand, #ff4500);
  background: var(--brand-bg-soft, rgba(255, 69, 0, 0.05));
}

/* ── Live Search & Filter Bar ─────────────────────────────────────────── */

.as-cat-filter-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 32px;
  background: var(--bg-soft, #ffffff);
  border: 1px solid var(--line, #e2e8f0);
  border-radius: var(--r-lg, 16px);
  padding: 12px 20px;
}

.as-cat-search-box {
  position: relative;
  flex: 1 1 300px;
  max-width: 440px;
}

.as-cat-search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-mut, #64748b);
  font-size: 14px;
  pointer-events: none;
}

.as-cat-search-input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 16px 10px 38px;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: var(--r-pill, 100px);
  background: var(--bg, #f8fafc);
  color: var(--ink, #0f172a);
  font-size: var(--font-sm, 13.5px);
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.as-cat-search-input:focus {
  border-color: var(--brand, #ff4500);
  box-shadow: 0 0 0 3px rgba(255, 69, 0, 0.15);
}

.as-cat-filter-stats {
  font-size: var(--font-sm, 13.5px);
  color: var(--ink-mut, #64748b);
  font-weight: var(--font-semibold, 600);
}

.as-cat-filter-stats strong {
  color: var(--ink, #0f172a);
}

/* ── Category Chips Bar ────────────────────────────────────────────────── */

.as-cat-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 28px;
  scrollbar-width: thin;
}

.as-cat-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--bg-soft, #ffffff);
  border: 1px solid var(--line, #e2e8f0);
  border-radius: var(--r-pill, 100px);
  color: var(--ink-soft, #475569);
  font-size: var(--font-xs, 12px);
  font-weight: var(--font-semibold, 600);
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.as-cat-chip:hover {
  border-color: var(--brand, #ff4500);
  color: var(--brand, #ff4500);
}

.as-cat-chip.is-active {
  background: var(--ink, #0f172a);
  border-color: var(--ink, #0f172a);
  color: #ffffff;
}

.as-cat-chip-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 99px;
  font-size: 10.5px;
  font-weight: var(--font-bold, 700);
  background: rgba(255, 69, 0, 0.12);
  color: var(--brand, #ff4500);
}

.as-cat-chip.is-active .as-cat-chip-count {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

/* ── Directory Hub Grid (/categories/) ─────────────────────────────────── */

.as-cat-hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 24px;
  margin-bottom: 56px;
}

.as-cat-card {
  position: relative;
  background: var(--bg-soft, #ffffff);
  border: 1px solid var(--line, #e2e8f0);
  border-radius: var(--r-lg, 18px);
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-decoration: none;
  box-shadow: var(--shadow-sm, 0 4px 15px rgba(0, 0, 0, 0.02));
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.as-cat-card:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 69, 0, 0.35);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.07);
}

.as-cat-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.as-cat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--brand-bg-soft, rgba(255, 69, 0, 0.08));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.as-cat-card-count {
  font-size: var(--font-xs, 12px);
  font-weight: var(--font-bold, 700);
  color: var(--brand, #ff4500);
  background: var(--brand-bg-soft, rgba(255, 69, 0, 0.08));
  padding: 4px 12px;
  border-radius: var(--r-pill, 100px);
}

.as-cat-card-title {
  font-family: var(--font-display, 'Syne', sans-serif);
  font-size: var(--font-xl, 18px);
  font-weight: var(--font-bold, 700);
  color: var(--ink, #0f172a);
  margin: 0 0 8px;
  line-height: var(--leading-snug, 1.3);
}

.as-cat-card-desc {
  font-size: var(--font-sm, 13.5px);
  color: var(--ink-soft, #475569);
  line-height: var(--leading-normal, 1.5);
  margin: 0 0 18px;
  flex-grow: 1;
}

.as-cat-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft, #f1f5f9);
  font-size: var(--font-xs, 12px);
  font-weight: var(--font-bold, 700);
  color: var(--brand, #ff4500);
}

.as-cat-card-arrow {
  transition: transform 0.15s ease;
}

.as-cat-card:hover .as-cat-card-arrow {
  transform: translateX(4px);
}

/* ── Category Archive Layout (/category/{slug}/) ───────────────────────── */

.as-cat-archive-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 40px;
  align-items: start;
}

.as-cat-posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
  margin-bottom: 40px;
}

.as-cat-post-card {
  background: var(--bg-soft, #ffffff);
  border: 1px solid var(--line, #e2e8f0);
  border-radius: var(--r-lg, 18px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.as-cat-post-card:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 69, 0, 0.35);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.06);
}

.as-cat-post-thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--bg, #0f172a);
  overflow: hidden;
  display: block;
}

.as-cat-post-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.as-cat-post-card:hover .as-cat-post-thumb img {
  transform: scale(1.04);
}

.as-cat-post-thumb-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display, 'Syne', sans-serif);
  font-size: 36px;
  font-weight: 800;
  color: #ffffff;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}

.as-cat-post-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.as-cat-post-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: var(--font-xs, 12px);
  color: var(--ink-mut, #64748b);
  margin-bottom: 10px;
}

.as-cat-post-title {
  font-family: var(--font-display, 'Syne', sans-serif);
  font-size: var(--font-lg, 16.5px);
  font-weight: var(--font-bold, 700);
  line-height: var(--leading-snug, 1.3);
  margin: 0 0 10px;
}

.as-cat-post-title a {
  color: var(--ink, #0f172a);
  text-decoration: none;
  transition: color 0.15s ease;
}

.as-cat-post-title a:hover {
  color: var(--brand, #ff4500);
}

.as-cat-post-excerpt {
  font-size: var(--font-sm, 13.5px);
  color: var(--ink-soft, #475569);
  line-height: var(--leading-normal, 1.5);
  margin: 0 0 16px;
  flex-grow: 1;
}

.as-cat-post-more {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--font-xs, 12px);
  font-weight: var(--font-bold, 700);
  color: var(--brand, #ff4500);
  text-decoration: none;
}

/* ── Sidebar Cards ─────────────────────────────────────────────────────── */

.as-cat-side {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.as-cat-side-card {
  background: var(--bg-soft, #ffffff);
  border: 1px solid var(--line, #e2e8f0);
  border-radius: var(--r-lg, 18px);
  padding: 24px;
}

.as-cat-side-card h3 {
  font-family: var(--font-display, 'Syne', sans-serif);
  font-size: var(--font-base, 14.5px);
  font-weight: var(--font-extrabold, 800);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider, 0.08em);
  color: var(--ink, #0f172a);
  margin: 0 0 16px;
}

.as-cat-side-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.as-cat-side-list li a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--font-sm, 13.5px);
  color: var(--ink-soft, #475569);
  text-decoration: none;
  transition: color 0.15s ease;
}

.as-cat-side-list li a:hover {
  color: var(--brand, #ff4500);
}

.as-cat-side-cta {
  background: linear-gradient(135deg, #090a0f 0%, #1e293b 100%);
  color: #ffffff;
  border-radius: var(--r-lg, 18px);
  padding: 28px 24px;
}

.as-cat-side-cta h3 {
  color: #ffffff;
}

.as-cat-side-cta p {
  font-size: var(--font-sm, 13.5px);
  color: #94a3b8;
  line-height: var(--leading-normal, 1.5);
  margin: 0 0 18px;
}

/* ── Dark Mode Harmonization ───────────────────────────────────────────── */

html.dark .as-cat-wrap,
body.dark .as-cat-wrap,
.dark .as-cat-wrap {
  --ink: #f8fafc;
  --ink-soft: #cbd5e1;
  --ink-mut: #94a3b8;
  --bg-soft: #0f172a;
  --bg: #020617;
  --line: #1e293b;
  --line-soft: #1e293b;
}

/* ── Responsive Rules ──────────────────────────────────────────────────── */

@media (max-width: 1024px) {
  .as-cat-archive-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  .as-cat-wrap {
    padding: 24px 16px 64px;
  }
  .as-cat-hero {
    padding: 24px 20px;
  }
  .as-cat-actions {
    width: 100%;
  }
  .as-cat-actions a {
    width: 100%;
    justify-content: center;
  }
  .as-cat-hub-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .as-cat-posts-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}
