/* GlideAPI — Models catalog. Tokens per DESIGN.md (dark-only marketing surface). */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #07131b;
  --bg-subtle: #0b1e29;
  --surface: #102733;
  --surface-hover: #15313e;
  --surface-raised: #183743;
  --border: #234450;
  --border-strong: #315b66;
  --text: #e8f5f2;
  --text-secondary: #9bb8b2;
  --text-tertiary: #66857f;

  --accent: #2bb7a4;
  --accent-hover: #239784;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;

  --btn-primary-bg: #e8f5f2;
  --btn-primary-text: #07131b;
  --btn-primary-hover: #ffffff;

  --font-sans: 'Inter', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-pill: 999px;

  --shadow-border: 0 0 0 1px var(--border);
  --shadow-border-hover: 0 0 0 1px var(--border-strong);
  --shadow-modal: 0 0 0 1px var(--border), 0 8px 30px rgba(0, 0, 0, 0.35);
  --focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);

  color-scheme: dark;
}

html { scroll-padding-top: 80px; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-stopped { overflow: hidden; }

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 22px;
  -webkit-font-smoothing: antialiased;
}

body.drawer-open { overflow: hidden; }

a { color: inherit; text-decoration: none; }
button, select, input { font: inherit; }

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm);
}

/* ---------- Navigation (64px full-width bar) ---------- */

.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 64px;
  background: rgba(10, 10, 10, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  height: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.brand-mark {
  display: flex;
  align-items: center;
  width: 158px;
  height: 38px;
}

.brand-mark img { display: block; width: 100%; height: 100%; object-fit: contain; }

.brand-ai { color: var(--text); font-size: 14px; font-weight: 600; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 24px;
  flex: 1;
}

.nav-links a {
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: color 0.15s ease-out;
}

.nav-links a:hover { color: var(--text); }
.nav-links a.active { color: var(--text); }

.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.nav-menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s ease-out;
}

.nav-menu-toggle:hover { background: var(--surface-hover); }
.nav-menu-toggle .icon-close { display: none; }
.nav-menu-toggle[aria-expanded="true"] .icon-menu { display: none; }
.nav-menu-toggle[aria-expanded="true"] .icon-close { display: block; }

/* Full-screen drawer (<768px) */

.nav-drawer {
  position: fixed;
  inset: 64px 0 0 0;
  z-index: 99;
  display: flex;
  flex-direction: column;
  padding: 24px;
  background: var(--bg);
  overflow-y: auto;
}

.nav-drawer[hidden] { display: none; }

.drawer-links {
  display: flex;
  flex-direction: column;
}

.drawer-links a {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 16px;
  font-weight: 500;
  transition: color 0.15s ease-out;
}

.drawer-links a:hover,
.drawer-links a.active { color: var(--text); }

.drawer-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: auto;
  padding-top: 32px;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease-out, border-color 0.15s ease-out, color 0.15s ease-out;
}

.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-md { height: 36px; padding: 0 16px; }
.btn-lg { height: 40px; padding: 0 20px; }

.btn-primary {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
}

.btn-primary:hover { background: var(--btn-primary-hover); }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text);
}

.btn-ghost:hover { background: var(--surface-hover); }

.btn:disabled { opacity: 0.5; pointer-events: none; }

.btn svg { flex-shrink: 0; }

/* ---------- Page layout ---------- */

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 64px 24px 96px;
}

.page-header { max-width: 640px; }

.eyebrow {
  color: var(--text-tertiary);
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.page-header h1 {
  margin-top: 12px;
  color: var(--text);
  font-size: 32px;
  line-height: 40px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.page-lede {
  margin-top: 12px;
  color: var(--text-secondary);
  font-size: 16px;
  line-height: 26px;
}

/* ---------- Toolbar ---------- */

.catalog { margin-top: 48px; }

.catalog-toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(160px, 220px) auto;
  align-items: end;
  gap: 16px;
}

.field { min-width: 0; }

.field label {
  display: block;
  margin-bottom: 6px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 20px;
  font-weight: 500;
}

.input-icon-wrap { position: relative; }

.input-icon-wrap svg {
  position: absolute;
  top: 50%;
  left: 12px;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  pointer-events: none;
}

input[type="search"],
select {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease-out;
}

.input-icon-wrap input[type="search"] { padding-left: 36px; }

input[type="search"]::placeholder { color: var(--text-tertiary); }

input[type="search"]:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

select { color-scheme: dark; }
select option { background: var(--surface-raised); color: var(--text); }

.toolbar-end {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 36px;
}

.model-count {
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 20px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.catalog-note {
  margin-top: 16px;
  color: var(--text-tertiary);
  font-size: 13px;
  line-height: 20px;
}

/* ---------- Lab groups ---------- */

.catalog-groups { margin-top: 32px; }

.lab-group { margin-top: 40px; }
.lab-group:first-child { margin-top: 0; }

.lab-group-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.lab-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-border);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  overflow: hidden;
}

.lab-logo img { display: block; width: 18px; height: 18px; object-fit: contain; }

.lab-name {
  color: var(--text);
  font-size: 18px;
  line-height: 28px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.lab-count {
  margin-left: auto;
  color: var(--text-tertiary);
  font-size: 13px;
  line-height: 20px;
  font-variant-numeric: tabular-nums;
}

.lab-models {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

/* ---------- Model cards ---------- */

.model-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-border);
  transition: box-shadow 0.15s ease-out, background 0.15s ease-out;
}

.model-card:hover {
  background: var(--surface-hover);
  box-shadow: var(--shadow-border-hover);
}

.model-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.model-name {
  color: var(--text);
  font-size: 15px;
  line-height: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  min-width: 0;
  overflow-wrap: anywhere;
}

.model-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: flex-end;
  flex-shrink: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--radius-xs);
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-accent {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
}

.badge-success {
  background: color-mix(in srgb, var(--success) 12%, transparent);
  color: var(--success);
}

.badge-neutral {
  background: color-mix(in srgb, var(--text-tertiary) 12%, transparent);
  color: var(--text-secondary);
}

.model-id-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.model-id {
  flex: 1;
  min-width: 0;
  padding: 6px 10px;
  background: var(--bg);
  border-radius: var(--radius-xs);
  box-shadow: var(--shadow-border);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 20px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s ease-out, color 0.15s ease-out, border-color 0.15s ease-out;
}

.copy-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.copy-btn.copied {
  border-color: color-mix(in srgb, var(--success) 40%, transparent);
  color: var(--success);
}

.copy-btn .icon-check { display: none; }
.copy-btn.copied .icon-copy { display: none; }
.copy-btn.copied .icon-check { display: block; }

.model-pricing {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.price-item {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}

.price-label {
  color: var(--text-tertiary);
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.price-value {
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 20px;
  font-variant-numeric: tabular-nums;
}

.price-unit {
  color: var(--text-tertiary);
  font-size: 12px;
  line-height: 16px;
}

.price-custom {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 20px;
}

/* ---------- Empty / loading / error states ---------- */

.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 48px;
  text-align: center;
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-border);
}

.state svg { color: var(--text-tertiary); }

.state-title {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 22px;
  font-weight: 500;
}

.state-hint {
  color: var(--text-tertiary);
  font-size: 13px;
  line-height: 20px;
}

.state .btn { margin-top: 8px; }

@keyframes state-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.state-loading svg { animation: state-spin 0.9s linear infinite; }

@media (prefers-reduced-motion: reduce) {
  .state-loading svg { animation: none; }
  html { scroll-behavior: auto; }
  * { transition-duration: 0.01ms !important; }
}

/* ---------- Footer ---------- */

.site-footer {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px 48px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.footer-note {
  color: var(--text-tertiary);
  font-size: 13px;
  line-height: 20px;
  text-align: center;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
}

.footer-links a {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 20px;
  font-weight: 500;
  transition: color 0.15s ease-out;
}

.footer-links a:hover { color: var(--text); }

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .catalog-toolbar {
    grid-template-columns: 1fr 1fr;
  }
  .search-field { grid-column: 1 / -1; }
  .toolbar-end { justify-content: flex-end; }
}

@media (max-width: 767px) {
  .nav-links { display: none; }
  .nav-actions .btn { display: none; }
  .nav-menu-toggle { display: inline-flex; }

  .page { padding: 48px 16px 64px; }
  .site-footer { padding: 24px 16px 40px; }

  .page-header h1 { font-size: 28px; line-height: 36px; }

  .catalog { margin-top: 40px; }

  .catalog-toolbar { grid-template-columns: 1fr; }
  .toolbar-end { justify-content: space-between; }

  .lab-models { grid-template-columns: 1fr; }

  .model-pricing {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
}

@media (min-width: 768px) {
  .nav-drawer { display: none; }
}
