/* ============================================
   Catwalk - Soft Data Garden
   A pastel, organic, friendly aesthetic
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
  /* Surface colors */
  --surface: #fffbf7;
  --surface-card: #ffffff;
  --surface-elevated: #fff8f3;

  /* Text colors */
  --text: #2d2a32;
  --text-muted: #7c7589;
  --text-subtle: #a8a1b4;

  /* Pastel palette */
  --lavender: #c4b5fd;
  --lavender-soft: #ede9fe;
  --mint: #a7f3d0;
  --mint-soft: #d1fae5;
  --peach: #fcd9bd;
  --peach-soft: #ffedd5;
  --sky: #bae6fd;
  --sky-soft: #e0f2fe;
  --butter: #fef08a;
  --butter-soft: #fef9c3;
  --rose: #fecdd3;
  --rose-soft: #ffe4e6;

  /* UI colors */
  --focus-ring: #a78bfa;
  --border: #e8e4ef;
  --border-soft: #f3f0f7;

  /* Shadows - soft and colored */
  --shadow-sm: 0 1px 2px oklch(0.8 0.03 280 / 0.06);
  --shadow-md: 0 4px 12px oklch(0.7 0.04 280 / 0.1);
  --shadow-lg: 0 8px 24px oklch(0.6 0.05 280 / 0.12);
  --shadow-glow: 0 0 20px oklch(0.8 0.1 280 / 0.15);

  /* Typography */
  --font-family: 'Atkinson Hyperlegible', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;

  /* Border radius - organic shapes */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-pill: 999px;

  /* Transitions */
  --transition-fast: 150ms ease-out;
  --transition-normal: 250ms ease-out;
  --transition-slow: 400ms ease-out;
}

/* --- Base Styles --- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-family);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--surface);
  min-height: 100vh;
}

/* --- Skip Link (Accessibility) --- */
.skip-link {
  position: absolute;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  padding: var(--space-sm) var(--space-md);
  background: var(--lavender);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  border-radius: var(--radius-md);
  z-index: 1000;
  transition: top var(--transition-fast);
}

.skip-link:focus {
  top: var(--space-md);
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

/* --- Visually Hidden (Screen reader only) --- */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --- App Container --- */
.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- Page Header --- */
.page-header {
  position: relative;
  padding: var(--space-2xl) var(--space-lg);
  background: linear-gradient(
    135deg,
    var(--lavender-soft) 0%,
    var(--peach-soft) 50%,
    var(--mint-soft) 100%
  );
  overflow: hidden;
  text-align: center;
}

.header-content {
  position: relative;
  z-index: 1;
}

.site-title {
  margin: 0 0 var(--space-sm);
  font-size: clamp(2.5rem, 8vw, 4rem);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.site-description {
  margin: 0;
  font-size: 1.125rem;
  color: var(--text-muted);
  font-weight: 500;
}

.site-description a {
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 2px solid var(--lavender);
  transition: border-color var(--transition-fast);
}

.site-description a:hover {
  border-color: var(--peach);
}

.site-description a:focus {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.site-description-sub {
  margin-top: var(--space-xs);
  font-size: 0.875rem;
  color: var(--text-subtle);
}

/* Decorative blobs */
.decorative-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.6;
  pointer-events: none;
}

.blob-1 {
  width: 300px;
  height: 300px;
  background: var(--lavender);
  top: -100px;
  left: -100px;
}

.blob-2 {
  width: 250px;
  height: 250px;
  background: var(--mint);
  bottom: -80px;
  right: -80px;
}

/* --- Main Content --- */
.main-content {
  flex: 1;
  padding: var(--space-lg);
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

.content {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

/* --- Loading State --- */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl);
  gap: var(--space-md);
  color: var(--text-muted);
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--lavender);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* --- Error State --- */
.error-state {
  text-align: center;
  padding: var(--space-2xl);
  background: var(--rose-soft);
  border-radius: var(--radius-lg);
  border: 1px solid var(--rose);
}

.error-title {
  margin: 0 0 var(--space-sm);
  color: #be123c;
  font-weight: 600;
}

.error-message {
  margin: 0 0 var(--space-md);
  color: var(--text);
}

.error-hint {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* --- Filters Section --- */
.filters-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  padding: var(--space-lg);
  background: var(--surface-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
}

.filters-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  align-items: center;
}

/* Search Input */
.search-container {
  flex: 1;
  min-width: 200px;
}

.search-input {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  font-family: var(--font-family);
  font-size: 1rem;
  color: var(--text);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-pill);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.search-input:focus {
  outline: none;
  border-color: var(--lavender);
  box-shadow: 0 0 0 3px var(--lavender-soft);
}

.search-input::placeholder {
  color: var(--text-subtle);
}

/* Sort Controls */
.sort-container {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.sort-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
}

.sort-buttons {
  display: flex;
  gap: var(--space-xs);
  flex-wrap: wrap;
}

.sort-button {
  padding: var(--space-xs) var(--space-sm);
  font-family: var(--font-family);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.sort-button:hover {
  background: var(--lavender-soft);
  border-color: var(--lavender);
}

.sort-button:focus {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.sort-button.active {
  background: var(--lavender);
  border-color: var(--lavender);
  color: var(--text);
  font-weight: 600;
}

/* Provider Chips */
.provider-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

.chip {
  padding: var(--space-xs) var(--space-md);
  font-family: var(--font-family);
  font-size: 0.875rem;
  font-weight: 500;
  border: 2px solid var(--border);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.chip:focus {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.clear-chip {
  background: var(--rose-soft);
  border-color: var(--rose);
  color: #be123c;
}

.clear-chip:hover {
  background: var(--rose);
}

.clear-chip.hidden {
  display: none;
}

.provider-chip {
  background: var(--surface);
  color: var(--text-muted);
}

.provider-chip:hover {
  background: var(--sky-soft);
  border-color: var(--sky);
}

.provider-chip.active {
  background: var(--sky);
  border-color: var(--sky);
  color: var(--text);
}

/* Capability Toggles */
.capability-toggles {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.toggle-button {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs) var(--space-md);
  font-family: var(--font-family);
  font-size: 0.875rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.toggle-button:focus {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.toggle-label {
  font-weight: 500;
  color: var(--text-muted);
}

.toggle-state {
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
}

.state-any {
  background: var(--surface);
}

.state-any .toggle-state {
  background: var(--border);
  color: var(--text-muted);
}

.state-yes {
  background: var(--mint-soft);
  border-color: var(--mint);
}

.state-yes .toggle-state {
  background: var(--mint);
  color: #065f46;
}

.state-no {
  background: var(--rose-soft);
  border-color: var(--rose);
}

.state-no .toggle-state {
  background: var(--rose);
  color: #be123c;
}

/* Column Toggles */
.column-toggles {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.toggles-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
}

.column-checkbox {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.8125rem;
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.column-checkbox:hover {
  background: var(--butter-soft);
  border-color: var(--butter);
}

.column-checkbox:has(input:checked) {
  background: var(--butter);
  border-color: var(--butter);
  color: var(--text);
}

.column-checkbox input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: #854d0e;
  cursor: pointer;
}

/* --- Copyable Values --- */
.copyable {
  position: relative;
  cursor: pointer;
  padding: 2px 6px;
  margin: -2px -6px;
  border-radius: var(--radius-sm);
  transition:
    background-color var(--transition-fast),
    transform var(--transition-fast),
    box-shadow var(--transition-fast);
}

.copyable::after {
  content: "Click to copy";
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  padding: 4px 8px;
  background: var(--text);
  color: var(--surface);
  font-size: 0.6875rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity var(--transition-fast),
    transform var(--transition-fast);
  z-index: 10;
}

.copyable:hover {
  background: var(--lavender-soft);
  transform: scale(1.02);
  box-shadow: 0 2px 8px oklch(0.7 0.08 280 / 0.15);
}

.copyable:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(-4px);
}

.copyable:focus {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.copyable:active {
  transform: scale(0.98);
}

/* Copied state */
.copyable.copied {
  background: var(--mint);
  animation: copy-pulse 0.3s ease-out;
}

.copyable.copied::after {
  content: "Copied!";
  opacity: 1;
  background: #065f46;
  transform: translateX(-50%) translateY(-4px);
}

@keyframes copy-pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  .copyable {
    transition: background-color var(--transition-fast);
  }

  .copyable:hover {
    transform: none;
  }

  .copyable:active {
    transform: none;
  }

  .copyable.copied {
    animation: none;
  }

  .copyable::after {
    transition: opacity var(--transition-fast);
  }

  .copyable:hover::after {
    transform: translateX(-50%) translateY(-4px);
  }
}

/* --- Results Summary --- */
.results-summary {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0;
  font-weight: 500;
}

/* --- Table View (Desktop) --- */
.table-container {
  overflow-x: auto;
  background: var(--surface-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
}

.models-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

.models-table thead {
  background: linear-gradient(135deg, var(--lavender-soft), var(--sky-soft));
}

.models-table th {
  padding: var(--space-md) var(--space-md);
  text-align: left;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  border-bottom: 2px solid var(--border);
}

.models-table td {
  padding: var(--space-md);
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}

.models-table tbody tr {
  transition: background var(--transition-fast);
}

.models-table tbody tr:hover {
  background: var(--lavender-soft);
}

.models-table tbody tr:last-child td {
  border-bottom: none;
}

/* Table columns */
.col-provider {
  width: 140px;
}

.col-model {
  min-width: 200px;
}

.col-context {
  width: 100px;
  text-align: right;
}

.col-cost {
  width: 100px;
  text-align: right;
}

.col-capabilities {
  min-width: 200px;
}

/* Provider badge in table */
.provider-badge {
  display: inline-block;
  padding: var(--space-xs) var(--space-sm);
  background: var(--peach-soft);
  color: #9a3412;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
}

.model-name {
  font-weight: 500;
  color: var(--text);
}

/* ID column */
.col-id {
  min-width: 180px;
}

.model-id {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.card-model-id {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: var(--space-xs);
  word-break: break-all;
}

/* Capability badges */
.capability-badges,
.card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
}

.badge-reason {
  background: var(--lavender-soft);
  color: #5b21b6;
}

.badge-attachments {
  background: var(--mint-soft);
  color: #065f46;
}

.badge-levels {
  background: var(--butter-soft);
  color: #854d0e;
}

/* --- Card View (Mobile) --- */
.cards-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-md);
}

.model-card {
  display: flex;
  flex-direction: column;
  background: var(--surface-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.model-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.card-header {
  padding: var(--space-md);
  background: linear-gradient(135deg, var(--lavender-soft), var(--peach-soft));
}

.card-provider {
  display: inline-block;
  padding: 2px 8px;
  background: var(--surface-card);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-xs);
}

.card-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
}

.card-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border-soft);
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-sm);
  background: var(--surface-card);
  text-align: center;
}

.stat-label {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-value {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
}

.card-footer {
  padding: var(--space-md);
  border-top: 1px solid var(--border-soft);
}

/* --- Page Footer --- */
.page-footer {
  padding: var(--space-lg);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.page-footer a {
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 2px solid var(--lavender);
  transition: border-color var(--transition-fast);
}

.page-footer a:hover {
  border-color: var(--peach);
}

.page-footer a:focus {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* --- Responsive Design --- */
@media (max-width: 768px) {
  .page-header {
    padding: var(--space-xl) var(--space-md);
  }

  .main-content {
    padding: var(--space-md);
  }

  .filters-section {
    padding: var(--space-md);
  }

  .filters-row {
    flex-direction: column;
    align-items: stretch;
  }

  .search-container {
    min-width: unset;
  }

  .sort-container {
    justify-content: center;
  }

  .provider-chips {
    justify-content: center;
  }

  .capability-toggles {
    justify-content: center;
  }

  .table-container {
    display: none;
  }

  .cards-container {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 769px) {
  .cards-container {
    display: none;
  }
}

/* --- Focus visible (better keyboard focus) --- */
@supports selector(:focus-visible) {
  .chip:focus:not(:focus-visible),
  .sort-button:focus:not(:focus-visible),
  .toggle-button:focus:not(:focus-visible),
  .search-input:focus:not(:focus-visible) {
    outline: none;
    box-shadow: none;
  }
}
