/**
 * Hub Cards - Shared Component Styles
 *
 * Reusable patterns for landing page hubs (tracks, api-hub, etc.)
 * Provides hero sections, card grids, neumorphic tiles, and preview lists.
 *
 * Usage:
 * - Use .hub-hero for hero sections
 * - Use .hub-grid for card grids
 * - Use .hub-card for neumorphic cards
 * - Use .hub-preview for "Includes:" lists
 *
 * Customization:
 * - Override with specific selectors (.tracks-*, .api-hub-*)
 * - Use CSS custom properties for theming
 */

/* ============================================
   HUB HERO SECTION
   ============================================ */

.hub-hero {
  text-align: center;
  margin-bottom: var(--space-10);
  padding-bottom: var(--space-8);
  border-bottom: 2px solid var(--color-border);
}

.hub-hero__container {
  max-width: 800px;
  margin: 0 auto;
}

.hub-hero__badge {
  display: inline-block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.5rem 1rem;
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border-radius: var(--radius-full);
  margin-bottom: var(--space-4);
}

.hub-hero__title {
  font-size: var(--text-4xl);
  font-weight: var(--weight-bold);
  margin: 0 0 var(--space-4);
  line-height: 1.1;
  color: var(--color-text-primary);
}

.hub-hero__title .fluid-text {
  background: linear-gradient(135deg, var(--color-primary), var(--color-warning));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hub-hero__subtitle {
  font-size: var(--text-xl);
  line-height: 1.6;
  color: var(--color-text-secondary);
  margin: 0 0 var(--space-6);
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.hub-hero__intro {
  font-size: var(--text-lg);
  line-height: 1.7;
  color: var(--color-text-secondary);
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

/* Stats Bar */
.hub-hero__stats {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin-top: var(--space-6);
}

.hub-stat {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: linear-gradient(180deg,
    var(--color-surface, var(--color-bg-elevated)),
    var(--color-bg-tertiary));
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--neumorphic-subtle);
}

.hub-stat__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
}

.hub-stat__value {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--color-text-primary);
}

.hub-stat__label {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* ============================================
   HUB GRID
   ============================================ */

.hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: var(--space-6);
  margin-top: var(--space-8);
}

/* Staggered fade-in animation */
.hub-grid > * {
  opacity: 0;
  transform: translateY(20px);
  animation: hub-card-fade-in 0.6s ease-out forwards;
}

.hub-grid > *:nth-child(1) { animation-delay: 0ms; }
.hub-grid > *:nth-child(2) { animation-delay: 100ms; }
.hub-grid > *:nth-child(3) { animation-delay: 200ms; }
.hub-grid > *:nth-child(4) { animation-delay: 300ms; }
.hub-grid > *:nth-child(5) { animation-delay: 400ms; }
.hub-grid > *:nth-child(n+6) { animation-delay: 500ms; }

@keyframes hub-card-fade-in {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .hub-grid > * {
    animation: none;
    opacity: 1;
    transform: none;
  }
}

/* ============================================
   HUB CARD (Neumorphic Tile)
   ============================================ */

.hub-card {
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg,
    var(--color-surface, var(--color-bg-elevated)),
    var(--color-bg-secondary));
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--neumorphic-base);
  overflow: hidden;
  transition:
    transform var(--motion-medium) var(--ease-out),
    box-shadow var(--motion-medium) var(--ease-out),
    border-color var(--motion-fast);
  height: 100%;
  position: relative;
}

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

/* Card Header */
.hub-card__header {
  padding: var(--space-6);
  padding-bottom: var(--space-4);
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
}

.hub-card__icon {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg,
    var(--color-surface, var(--color-bg-elevated)),
    var(--color-bg-tertiary));
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--neumorphic-subtle);
  color: var(--color-primary);
  font-size: 1.5rem;
  transition: transform var(--motion-fast), box-shadow var(--motion-fast);
}

.hub-card:hover .hub-card__icon {
  transform: scale(1.05);
  box-shadow: var(--neumorphic-hover);
}

.hub-card__title {
  flex: 1;
  margin: 0;
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  line-height: 1.3;
}

.hub-card__title a {
  color: var(--color-text-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.hub-card__title a:hover {
  color: var(--color-primary);
}

/* Card Content */
.hub-card__content {
  flex: 1;
  padding: 0 var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.hub-card__description {
  font-size: var(--text-base);
  font-weight: var(--weight-normal);
  line-height: 1.6;
  color: var(--color-text-secondary);
  margin: 0;
}

/* Card Meta */
.hub-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.hub-card__meta-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  padding: var(--space-2) var(--space-3);
  background: linear-gradient(180deg,
    var(--color-surface, var(--color-bg-elevated)),
    var(--color-bg-tertiary));
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--neumorphic-subtle);
}

.hub-card__meta-item svg {
  flex-shrink: 0;
  opacity: 0.7;
}

/* Card Footer */
.hub-card__footer {
  padding: var(--space-6);
  padding-top: var(--space-4);
  margin-top: auto;
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.hub-card__footer-meta {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* ============================================
   HUB PREVIEW LIST
   ============================================ */

.hub-preview {
  margin-top: var(--space-2);
}

.hub-preview__label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}

.hub-preview__list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.hub-preview__item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

/* Numbered preview (for tracks) */
.hub-preview__number {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg,
    var(--color-surface, var(--color-bg-elevated)),
    var(--color-bg-tertiary));
  border: 1px solid var(--color-border);
  color: var(--color-primary);
  border-radius: 50%;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  box-shadow: var(--neumorphic-subtle);
}

/* Bullet preview (for api-hub) */
.hub-preview__bullet {
  flex-shrink: 0;
  width: 6px;
  height: 6px;
  background: var(--color-primary);
  border-radius: 50%;
}

.hub-preview__title {
  flex: 1;
  min-width: 0;
  line-height: 1.4;
}

.hub-preview__more {
  margin-top: var(--space-1);
}

.hub-preview__more--numbered {
  padding-left: calc(20px + var(--space-2));
}

.hub-preview__more--bulleted {
  padding-left: calc(6px + var(--space-2));
}

.hub-preview__more-text {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-style: italic;
}

/* ============================================
   HUB BUTTON
   ============================================ */

.hub-button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  background: linear-gradient(180deg,
    var(--color-primary),
    var(--color-primary-dark));
  color: var(--color-text-inverse);
  border: 1px solid var(--color-primary-dark);
  border-radius: var(--radius-md);
  text-decoration: none;
  font-weight: var(--weight-semibold);
  font-size: var(--text-base);
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.15),
    inset 0 -1px 0 rgba(0, 0, 0, 0.1),
    0 2px 4px rgba(0, 0, 0, 0.1);
  transition:
    transform var(--motion-fast) var(--ease-out),
    box-shadow var(--motion-fast),
    background var(--motion-fast);
}

.hub-button:hover {
  background: linear-gradient(180deg,
    var(--color-primary-hover),
    var(--color-primary));
  transform: translateY(-1px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    inset 0 -1px 0 rgba(0, 0, 0, 0.08),
    0 4px 8px rgba(0, 0, 0, 0.12);
}

.hub-button:active {
  transform: translateY(0) scale(0.98);
  background: linear-gradient(180deg,
    var(--color-primary-dark),
    var(--color-primary-active));
  box-shadow:
    inset 2px 2px 4px rgba(0, 0, 0, 0.2),
    inset -1px -1px 2px rgba(255, 255, 255, 0.1);
}

.hub-button svg {
  flex-shrink: 0;
  transition: transform var(--transition-fast);
}

.hub-button:hover svg {
  transform: translateX(2px);
}

.hub-button--small {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
}

.hub-button--full {
  width: 100%;
  justify-content: center;
}

.hub-button--disabled {
  background: var(--color-surface-elevated);
  color: var(--color-text-muted);
  cursor: not-allowed;
  opacity: 0.6;
}

.hub-button--disabled:hover {
  background: var(--color-surface-elevated);
  transform: none;
  box-shadow: none;
}

/* ============================================
   HUB EMPTY STATE
   ============================================ */

.hub-empty {
  text-align: center;
  padding: var(--space-12) var(--space-6);
  margin-top: var(--space-8);
}

.hub-empty__icon {
  margin: 0 auto var(--space-4);
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface-elevated);
  border-radius: 50%;
  color: var(--color-text-muted);
}

.hub-empty__title {
  font-size: var(--text-2xl);
  font-weight: var(--weight-semibold);
  margin-bottom: var(--space-2);
  color: var(--color-text-primary);
}

.hub-empty__text {
  font-size: var(--text-base);
  color: var(--color-text-secondary);
  max-width: 500px;
  margin: 0 auto;
}

.hub-empty__text code {
  background: var(--color-surface-elevated);
  padding: 0.125rem 0.375rem;
  border-radius: var(--radius-sm);
  font-size: 0.875em;
}

/* ============================================
   HUB TYPE BADGE
   ============================================ */

.hub-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--color-bg-tertiary);
  color: var(--color-text-muted);
}

.hub-badge--success {
  background: var(--color-success-bg);
  color: var(--color-success-text);
}

.hub-badge--info {
  background: var(--color-info-bg);
  color: var(--color-info-text);
}

.hub-badge--warning {
  background: var(--color-warning-bg);
  color: var(--color-warning-text);
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 1024px) {
  .hub-grid {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--space-5);
  }
}

@media (max-width: 768px) {
  .hub-hero {
    margin-bottom: var(--space-8);
    padding-bottom: var(--space-6);
  }

  .hub-hero__title {
    font-size: var(--text-3xl);
  }

  .hub-hero__subtitle {
    font-size: var(--text-lg);
  }

  .hub-hero__intro {
    font-size: var(--text-base);
  }

  .hub-hero__stats {
    gap: var(--space-3);
  }

  .hub-grid {
    grid-template-columns: 1fr;
    gap: var(--space-5);
    margin-top: var(--space-6);
  }

  .hub-card__header {
    padding: var(--space-5);
    padding-bottom: var(--space-3);
  }

  .hub-card__content {
    padding: 0 var(--space-5);
  }

  .hub-card__footer {
    padding: var(--space-5);
    padding-top: var(--space-3);
  }
}

@media (max-width: 480px) {
  .hub-hero__title {
    font-size: var(--text-2xl);
  }

  .hub-card__icon {
    width: 40px;
    height: 40px;
  }

  .hub-card__title {
    font-size: var(--text-base);
  }

  .hub-card__footer {
    flex-direction: column;
    gap: var(--space-3);
    align-items: stretch;
  }

  .hub-card__meta {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ============================================
   DARK MODE
   ============================================ */

@media (prefers-color-scheme: dark) {
  .hub-card:hover {
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.05);
  }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

.hub-card:focus-within {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.hub-button:focus-visible {
  outline: 2px solid var(--color-text-inverse);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .hub-card,
  .hub-card__icon,
  .hub-button {
    transition: none;
  }

  .hub-card:hover {
    transform: none;
  }
}
