/* ============================================================
   KNQ Internal Navigation Portal — style.css
   Design: Dark Glassmorphism + Modern Card Grid
   ============================================================ */

/* ----- CSS Custom Properties (Theme System) ----- */
:root {
  /* Brand colors */
  --brand-primary: #0516FF;
  --brand-accent: #05E6FF;
  --brand-gradient: linear-gradient(135deg, var(--brand-primary), var(--brand-accent));

  /* Status colors */
  --status-production: #00d4aa;
  --status-internal: #0516FF;
  --status-internal-end: #05E6FF;
  --status-demo: #ffa726;
  --status-mvp: #ab47bc;
  --status-staging: #78909c;
  --status-offline: #616161;

  /* Spacing (8px grid) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* Border radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Typography — system fonts only, no external CDN dependency */
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'SF Mono', SFMono-Regular, 'Cascadia Code', Consolas, 'Liberation Mono', Menlo, monospace;

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-base: 0.25s ease;
  --transition-slow: 0.4s ease;
  --transition-theme: 0.3s ease;

  /* Layout */
  --header-height: 72px;
  --max-width: 1320px;
  --card-min-width: 280px;
}

/* ----- Dark Theme (Default) ----- */
[data-theme="dark"] {
  --bg-primary: #0a0e27;
  --bg-secondary: #0d1033;
  --bg-card: rgba(255, 255, 255, 0.04);
  --bg-card-hover: rgba(255, 255, 255, 0.07);
  --bg-header: rgba(10, 14, 39, 0.82);
  --bg-input: rgba(255, 255, 255, 0.06);
  --bg-input-focus: rgba(255, 255, 255, 0.1);
  --bg-filter: rgba(255, 255, 255, 0.04);
  --bg-filter-active: var(--brand-gradient);

  --border-card: rgba(255, 255, 255, 0.06);
  --border-card-hover: rgba(5, 230, 255, 0.3);
  --border-input: rgba(255, 255, 255, 0.1);
  --border-input-focus: rgba(5, 230, 255, 0.4);
  --border-header: rgba(255, 255, 255, 0.06);

  --text-primary: #e8eaed;
  --text-secondary: rgba(255, 255, 255, 0.55);
  --text-tertiary: rgba(255, 255, 255, 0.35);
  --text-inverse: #0a0e27;

  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.2);
  --shadow-card-hover: 0 8px 40px rgba(5, 22, 255, 0.12), 0 0 24px rgba(5, 230, 255, 0.06);
  --shadow-header: 0 1px 32px rgba(0, 0, 0, 0.3);

  /* Orb colors */
  --orb-primary: rgba(5, 22, 255, 0.08);
  --orb-accent: rgba(5, 230, 255, 0.05);
  --orb-tertiary: rgba(171, 71, 188, 0.04);

  color-scheme: dark;
}

/* ----- Light Theme ----- */
[data-theme="light"] {
  --bg-primary: #f0f2f8;
  --bg-secondary: #e8ecf1;
  --bg-card: rgba(255, 255, 255, 0.75);
  --bg-card-hover: rgba(255, 255, 255, 0.95);
  --bg-header: rgba(240, 242, 248, 0.88);
  --bg-input: rgba(0, 0, 0, 0.04);
  --bg-input-focus: rgba(0, 0, 0, 0.06);
  --bg-filter: rgba(0, 0, 0, 0.04);
  --bg-filter-active: var(--brand-gradient);

  --border-card: rgba(0, 0, 0, 0.07);
  --border-card-hover: rgba(5, 22, 255, 0.25);
  --border-input: rgba(0, 0, 0, 0.08);
  --border-input-focus: rgba(5, 22, 255, 0.4);
  --border-header: rgba(0, 0, 0, 0.06);

  --text-primary: #1a1a2e;
  --text-secondary: rgba(26, 26, 46, 0.6);
  --text-tertiary: rgba(26, 26, 46, 0.4);
  --text-inverse: #ffffff;

  --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.05), 0 4px 24px rgba(0, 0, 0, 0.04);
  --shadow-card-hover: 0 8px 32px rgba(5, 22, 255, 0.1), 0 4px 16px rgba(0, 0, 0, 0.06);
  --shadow-header: 0 1px 24px rgba(0, 0, 0, 0.08);

  --orb-primary: rgba(5, 22, 255, 0.1);
  --orb-accent: rgba(5, 230, 255, 0.08);
  --orb-tertiary: rgba(171, 71, 188, 0.06);

  color-scheme: light;
}

/* Light mode glass reflection — brighter to stand out on light BG */
[data-theme="light"] .card::before {
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.6) 20%,
    rgba(255, 255, 255, 0.85) 50%,
    rgba(255, 255, 255, 0.6) 80%,
    transparent 100%
  );
}

/* Light mode external link arrow color */
[data-theme="light"] .card::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%230516FF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 17L17 7'/%3E%3Cpath d='M7 7h10v10'/%3E%3C/svg%3E");
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  font-weight: 400;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background-color var(--transition-theme), color var(--transition-theme);
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  border: none;
  background: none;
  cursor: pointer;
  color: inherit;
}

input {
  font: inherit;
  border: none;
  background: none;
  outline: none;
  color: inherit;
}

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

/* Remove search input default styling */
input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-results-button,
input[type="search"]::-webkit-search-results-decoration {
  -webkit-appearance: none;
}

/* ----- Background Noise Texture ----- */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='256' height='256' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 128px;
}

[data-theme="light"] body::before {
  opacity: 0.04;
}

/* ----- Background Gradient Orbs ----- */
.bg-orbs {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
  transition: opacity var(--transition-theme);
}

.bg-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  transition: background var(--transition-theme);
}

.bg-orb--primary {
  width: 600px;
  height: 600px;
  top: -10%;
  right: -5%;
  background: var(--orb-primary);
}

.bg-orb--accent {
  width: 500px;
  height: 500px;
  bottom: -8%;
  left: -5%;
  background: var(--orb-accent);
}

.bg-orb--tertiary {
  width: 400px;
  height: 400px;
  top: 40%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--orb-tertiary);
}

/* ----- Header (Two-row: Brand+Search | Filters) ----- */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-header);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-bottom: none;
  box-shadow: var(--shadow-header);
  transition: background var(--transition-theme),
              box-shadow var(--transition-theme);
}

/* Decorative gradient light line at header bottom */
.header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--border-header) 15%,
    var(--brand-accent) 50%,
    var(--border-header) 85%,
    transparent 100%
  );
  opacity: 0.6;
  transition: opacity var(--transition-theme);
}

.header__inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-6);
  height: var(--header-height);
  display: flex;
  align-items: center;
  gap: var(--space-6);
}

/* Second row: filter pills inside header */
.header__filters {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-6) var(--space-4);
}

.header__filters-inner {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.header__filters-inner::-webkit-scrollbar {
  display: none;
}

.header__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
  transition: opacity var(--transition-fast);
}

.header__brand:hover {
  opacity: 0.85;
}

.header__logo {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.header__title {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  background: var(--brand-gradient);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ----- Search ----- */
.header__search {
  flex: 1;
  max-width: 480px;
  position: relative;
  display: flex;
  align-items: center;
}

.search__icon {
  position: absolute;
  left: var(--space-4);
  color: var(--text-tertiary);
  pointer-events: none;
  transition: color var(--transition-fast);
}

.search__input {
  width: 100%;
  height: 42px;
  padding: 0 var(--space-10) 0 var(--space-12);
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  color: var(--text-primary);
  transition: all var(--transition-base);
}

.search__input::placeholder {
  color: var(--text-tertiary);
  font-size: 0.8125rem;
}

.search__input:focus {
  background: var(--bg-input-focus);
  border-color: var(--border-input-focus);
  box-shadow: 0 0 0 3px rgba(5, 230, 255, 0.1);
}

.search__input:focus ~ .search__kbd {
  opacity: 0;
}

/* Icon is before input in DOM, so use parent :focus-within */
.header__search:focus-within .search__icon {
  color: var(--brand-accent);
}

/* Search clear button */
.search__clear {
  position: absolute;
  right: var(--space-4);
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text-tertiary);
  background: var(--bg-filter);
  transition: all var(--transition-fast);
  z-index: 2;
}

.search__clear:hover {
  color: var(--text-primary);
  background: var(--bg-card-hover);
}

.search__clear.hidden {
  display: none;
}

/* When clear button is visible, hide the kbd hint */
.search__clear:not(.hidden) ~ .search__kbd {
  display: none;
}

.search__kbd {
  position: absolute;
  right: var(--space-4);
  padding: 2px 8px;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-tertiary);
  background: var(--bg-filter);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  pointer-events: none;
  transition: opacity var(--transition-fast);
}

/* ----- Header Actions ----- */
.header__actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.btn-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: var(--bg-filter);
  border: 1px solid var(--border-card);
  color: var(--text-secondary);
  transition: all var(--transition-base);
}

.btn-icon:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--border-card-hover);
}

/* Theme toggle icon switching with rotation */
.btn-icon svg {
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.btn-icon:active svg {
  transform: rotate(30deg) scale(0.85);
}

[data-theme="dark"] .icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }

.filter-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
  border-radius: var(--radius-full);
  background: var(--bg-filter);
  border: 1px solid var(--border-card);
  color: var(--text-secondary);
  transition: all var(--transition-base);
}

.filter-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--border-card-hover);
}

.filter-btn.active {
  background: var(--brand-gradient);
  border-color: transparent;
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 2px 12px rgba(5, 22, 255, 0.3);
}

.filter-btn.active .status-dot {
  background: rgba(255, 255, 255, 0.8);
}

/* ----- Status Dots ----- */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot--production {
  background: var(--status-production);
  box-shadow: 0 0 6px var(--status-production);
  animation: pulse 2.5s ease-in-out infinite;
}

.status-dot--internal {
  background: var(--brand-gradient);
  box-shadow: 0 0 6px var(--brand-accent);
}

.status-dot--demo {
  background: var(--status-demo);
  box-shadow: 0 0 6px rgba(255, 167, 38, 0.4);
}

.status-dot--mvp {
  background: var(--status-mvp);
  box-shadow: 0 0 6px rgba(171, 71, 188, 0.4);
}

.status-dot--staging {
  background: var(--status-staging);
}

.status-dot--offline {
  background: var(--status-offline);
}

/* Production pulse animation */
@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 6px var(--status-production); }
  50% { opacity: 0.7; box-shadow: 0 0 12px var(--status-production), 0 0 24px rgba(0, 212, 170, 0.2); }
}

/* ----- Main Content ----- */
.main {
  position: relative;
  z-index: 1;
  padding-top: var(--space-8);
  padding-bottom: var(--space-16);
  min-height: calc(100vh - var(--header-height) - 120px);
}

.main > .categories,
.main > .empty-state,
.main > .result-count,
.main > .skeleton-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-6);
}

.main > .result-count {
  padding-top: var(--space-2);
}

/* ----- Category Sections ----- */
.category {
  margin-bottom: var(--space-12);
}

.category__header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  transition: border-color var(--transition-theme);
}

.category__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--cat-gradient, var(--brand-gradient));
  color: #ffffff;
  font-size: 0.875rem;
  flex-shrink: 0;
}

/* Category-specific icon gradients */
.category[data-cat="sports-tech"] .category__icon {
  --cat-gradient: linear-gradient(135deg, #00b894, #00d4aa);
}
.category[data-cat="equine-intelligence"] .category__icon {
  --cat-gradient: linear-gradient(135deg, #0516FF, #05E6FF);
}
.category[data-cat="ai-infrastructure"] .category__icon {
  --cat-gradient: linear-gradient(135deg, #6c5ce7, #a29bfe);
}
.category[data-cat="enterprise"] .category__icon {
  --cat-gradient: linear-gradient(135deg, #e17055, #fab1a0);
}
.category[data-cat="official"] .category__icon {
  --cat-gradient: linear-gradient(135deg, #0516FF, #05E6FF);
}

.category__name {
  font-size: 1.1875rem;
  font-weight: 650;
  letter-spacing: -0.015em;
  color: var(--text-primary);
}

.category__count {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-tertiary);
  padding: 2px 8px;
  background: var(--bg-filter);
  border-radius: var(--radius-full);
  border: 1px solid var(--border-card);
  transition: all var(--transition-theme);
}

/* ----- Card Grid ----- */
.category__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--card-min-width), 1fr));
  gap: var(--space-5);
}

/* ----- Cards ----- */
.card {
  display: flex;
  flex-direction: column;
  padding: var(--space-5) var(--space-5) var(--space-5) var(--space-6);
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  cursor: pointer;
  position: relative;
  overflow: hidden;

  /* Left accent border — colored by status via JS inline style */
  border-left: 3px solid var(--card-accent, var(--border-card));

  /* Hover/interaction transitions */
  transition: transform var(--transition-base),
              background var(--transition-base),
              border-color var(--transition-base),
              box-shadow var(--transition-base);

  /* Consistent card height */
  min-height: 180px;

  /* Initial hidden state for entrance animation */
  opacity: 0;
  transform: translateY(16px);
}

.card.visible {
  animation: cardEntrance 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
  animation-delay: var(--entrance-delay, 0ms);
}

/* Once entrance completes, reset to static state for hover to work */
.card.entered {
  opacity: 1;
  transform: translateY(0);
  animation: none;
}

@keyframes cardEntrance {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Glass top reflection highlight — subtle shine across card top edge */
.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 3px;
  right: 0;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.15) 20%,
    rgba(255, 255, 255, 0.25) 50%,
    rgba(255, 255, 255, 0.15) 80%,
    transparent 100%
  );
  pointer-events: none;
  z-index: 1;
}

/* External link arrow indicator */
.card::after {
  content: '';
  position: absolute;
  bottom: var(--space-4);
  right: var(--space-4);
  width: 20px;
  height: 20px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2305E6FF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 17L17 7'/%3E%3Cpath d='M7 7h10v10'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  opacity: 0;
  transform: translate(4px, 4px);
  transition: all var(--transition-base);
  pointer-events: none;
}

@media (hover: hover) {
  .card:hover {
    transform: translateY(-4px);
    background: var(--bg-card-hover);
    border-top-color: var(--border-card-hover);
    border-right-color: var(--border-card-hover);
    border-bottom-color: var(--border-card-hover);
    box-shadow: var(--shadow-card-hover);
  }

  /* Expand description from 2 to 4 lines on hover */
  .card:hover .card__description {
    -webkit-line-clamp: 4;
  }

  .card:hover .card__url {
    color: var(--brand-accent);
  }

  .card:hover::after {
    opacity: 0.6;
    transform: translate(0, 0);
  }
}

.card:active {
  transform: scale(0.98) !important;
  transition-duration: 0.1s;
}

/* Touch device: subtle tap feedback without sticky hover */
@media (hover: none) {
  .card {
    -webkit-tap-highlight-color: transparent;
  }
}

/* Card filtered out */
.card.filtered-out {
  display: none;
}

/* ----- Card Internals ----- */
.card__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-3);
}

.card__status {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.status-label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

/* Status label theme variants */
.status-label--production {
  color: var(--status-production);
  background: rgba(0, 212, 170, 0.1);
}
.status-label--internal {
  color: var(--brand-accent);
  background: rgba(5, 230, 255, 0.1);
}
.status-label--demo {
  color: var(--status-demo);
  background: rgba(255, 167, 38, 0.1);
}
.status-label--mvp {
  color: var(--status-mvp);
  background: rgba(171, 71, 188, 0.12);
}
.status-label--staging {
  color: var(--status-staging);
  background: rgba(120, 144, 156, 0.12);
}
.status-label--offline {
  color: var(--status-offline);
  background: rgba(97, 97, 97, 0.12);
}

/* ----- Favorite Button ----- */
.card__favorite {
  opacity: 0;
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  transition: all var(--transition-base);
  z-index: 2;
  flex-shrink: 0;
}

@media (hover: hover) {
  .card:hover .card__favorite {
    opacity: 1;
  }

  .card__favorite:hover {
    color: #ffd700;
    transform: scale(1.15);
  }
}

.card__favorite.active {
  opacity: 1;
  color: #ffd700;
}

.card__favorite.active svg {
  fill: #ffd700;
}

.card__favorite.bounce {
  animation: favBounce 0.4s ease;
}

@keyframes favBounce {
  0% { transform: scale(1); }
  30% { transform: scale(1.35); }
  60% { transform: scale(0.9); }
  100% { transform: scale(1); }
}

/* ----- Card Content ----- */
.card__name {
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.35;
  margin-bottom: var(--space-2);
  color: var(--text-primary);
  transition: color var(--transition-theme);
}

.card__description {
  font-size: 0.8125rem;
  font-weight: 400;
  line-height: 1.6;
  color: var(--text-secondary);
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: var(--space-4);
  transition: color var(--transition-theme);
}

.card__footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: var(--space-2);
  margin-top: auto;
}

.card__url {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60%;
  transition: color var(--transition-fast);
}

.card__tags {
  display: flex;
  gap: var(--space-1);
  flex-wrap: wrap;
  justify-content: flex-end;
}

.card__tag {
  font-size: 0.625rem;
  font-weight: 500;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: var(--bg-filter);
  border: 1px solid var(--border-card);
  color: var(--text-tertiary);
  transition: all var(--transition-theme);
}

/* ----- Result Count Indicator ----- */
.result-count {
  font-size: 0.8125rem;
  color: var(--text-tertiary);
  padding: 0 0 var(--space-4);
  transition: color var(--transition-theme);
}

.result-count.hidden {
  display: none;
}

.result-count__highlight {
  color: var(--brand-accent);
  font-weight: 600;
}

/* ----- Loading Skeleton ----- */
.skeleton-container {
  padding: var(--space-2) 0;
}

.skeleton-container.hidden {
  display: none;
}

.skeleton-category {
  margin-bottom: var(--space-10);
}

.skeleton-header {
  padding-bottom: var(--space-5);
  margin-bottom: var(--space-5);
  border-bottom: 1px solid var(--border-card);
}

.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--card-min-width), 1fr));
  gap: var(--space-5);
}

.skeleton-card {
  padding: var(--space-5);
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  min-height: 160px;
}

.skeleton-line {
  height: 12px;
  border-radius: 6px;
  background: var(--bg-input);
  margin-bottom: var(--space-3);
  animation: shimmer 1.5s ease-in-out infinite;
}

.skeleton-line--badge {
  width: 56px;
  height: 20px;
  border-radius: var(--radius-full);
  margin-bottom: var(--space-4);
}

.skeleton-line--title {
  width: 65%;
  height: 16px;
  margin-bottom: var(--space-4);
}

.skeleton-line--text {
  width: 100%;
  height: 10px;
}

.skeleton-line--80 {
  width: 80%;
}

.skeleton-line--short {
  width: 120px;
  height: 20px;
}

@keyframes shimmer {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.8; }
}

/* ----- Empty State ----- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-16) var(--space-6);
  color: var(--text-tertiary);
  text-align: center;
}

.empty-state.hidden {
  display: none;
}

.empty-state svg {
  margin-bottom: var(--space-6);
  opacity: 0.4;
}

.empty-state__text {
  font-size: 1.125rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

.empty-state__hint {
  font-size: 0.875rem;
  color: var(--text-tertiary);
}

/* ----- Footer ----- */
.footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: var(--space-8) var(--space-6);
  font-size: 0.8125rem;
  color: var(--text-tertiary);
  border-top: none;
  transition: color var(--transition-theme);
}

/* Mirror the header's gradient line at footer top */
.footer::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--border-header) 15%,
    var(--brand-accent) 50%,
    var(--border-header) 85%,
    transparent 100%
  );
  opacity: 0.4;
  transition: opacity var(--transition-theme);
}

/* ----- Utility Classes ----- */
.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
  white-space: nowrap;
}

/* ----- Responsive Design ----- */

/* Large desktop */
@media (min-width: 1200px) {
  .category__grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Laptop */
@media (max-width: 1199px) and (min-width: 1025px) {
  .category__grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Tablet */
@media (max-width: 1024px) and (min-width: 769px) {
  .category__grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Mobile */
@media (max-width: 768px) {
  :root {
    --header-height: 64px;
    --card-min-width: 100%;
  }

  .header__inner {
    padding: 0 var(--space-4);
    gap: var(--space-3);
  }

  .header__title {
    display: none;
  }

  .header__search {
    max-width: none;
  }

  .search__input {
    height: 38px;
    font-size: 0.8125rem;
  }

  .search__kbd {
    display: none;
  }

  .header__filters {
    padding: 0 var(--space-4) var(--space-3);
  }

  .main > .categories,
  .main > .empty-state,
  .main > .result-count,
  .main > .skeleton-container {
    padding: 0 var(--space-4);
  }

  .main {
    padding-bottom: var(--space-12);
  }

  .category__grid {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }

  .card {
    padding: var(--space-4) var(--space-4) var(--space-4) var(--space-5);
  }

  .card__favorite {
    opacity: 1;
  }

  .bg-orb--primary {
    width: 300px;
    height: 300px;
  }

  .bg-orb--accent {
    width: 250px;
    height: 250px;
  }

  .bg-orb--tertiary {
    display: none;
  }
}

/* Small mobile */
@media (max-width: 480px) {
  .filter-btn {
    font-size: 0.75rem;
    padding: var(--space-2) var(--space-3);
  }
}

/* ----- Accessibility: Reduced Motion ----- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }

  .card {
    opacity: 1;
    transform: none;
  }

  html {
    scroll-behavior: auto;
  }
}

/* ----- Focus Visible (Keyboard Navigation) ----- */
:focus-visible {
  outline: 2px solid var(--brand-accent);
  outline-offset: 2px;
}

.card:focus-visible {
  outline: 2px solid var(--brand-accent);
  outline-offset: 2px;
  border-top-color: var(--border-card-hover);
  border-right-color: var(--border-card-hover);
  border-bottom-color: var(--border-card-hover);
  box-shadow: var(--shadow-card-hover);
}

/* ----- Scrollbar (WebKit) ----- */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--text-tertiary);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}
