/**
 * tokens.css — flowxapi Design System Tokens & Base Primitives
 * Stack: plain HTML + CSS + vanilla JS
 * Conforms to DESIGN.md — flowxapi
 */

:root {
  /* Surfaces */
  --bg:            #000000;
  --surface-1:     #0a0a0c;   /* cards, panels */
  --surface-2:     #16181c;   /* inputs, code, hover */
  --surface-hover: #1c1f23;

  /* Border: ONE token only */
  --border:        rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.20);   /* hover, focus-adjacent */

  /* Text */
  --text:          #ffffff;
  --text-body:     #e7e9ea;
  --text-muted:    #71767b;   /* minimum dimness for readable copy */
  --text-subtle:   #536471;   /* placeholders, disabled only */

  /* Brand accent: flowxapi's own, used sparingly */
  --brand:         #ffffff;   /* default brand = white */

  /* Status (functional only) */
  --success:       #00ba7c;
  --warning:       #ffd400;
  --danger:        #f4212e;
  --info:          #71767b;

  /* Type */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Shape */
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 9999px;

  /* Motion */
  --ease: 150ms ease;
}

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

html {
  background-color: var(--bg);
  color: var(--text-body);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scrollbar-gutter: stable;
}

body {
  background-color: var(--bg);
  color: var(--text-body);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Headings: Sentence case & letter-spacing */
h1, h2, h3, h4, h5, h6 {
  color: var(--text);
  letter-spacing: -0.01em;
  font-weight: 700;
}

h1 {
  font-size: clamp(32px, 5vw, 44px);
  line-height: 1.1;
}

h2 {
  font-size: 24px;
  line-height: 1.25;
}

h3 {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.3;
}

p {
  max-width: 72ch;
  line-height: 1.6;
}

/* Links: white, underlined, not blue */
a {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color var(--ease);
}
a:hover {
  color: var(--text-body);
}

/* Tabular Numerals */
.tabular, .tabular-nums, table, .metric-value, .stat-value {
  font-variant-numeric: tabular-nums;
}

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

/* 5.1 Card */
.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: border-color var(--ease), background var(--ease);
  position: relative;
}

.card:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.card--dense {
  padding: 16px 20px;
}

/* Linked Card */
a.card {
  display: block;
  text-decoration: none;
  color: inherit;
}

/* Icons */
.icon, svg.icon {
  width: 24px;
  height: 24px;
  stroke-width: 1.5;
  stroke: currentColor;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: middle;
}

/* 5.2 Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 20px;
  border-radius: var(--radius-pill);
  font: 600 14px var(--font-sans);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--ease), transform var(--ease), border-color var(--ease), color var(--ease);
  white-space: nowrap;
}

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

.btn-primary {
  background: #ffffff;
  color: #000000;
  border: 1px solid #ffffff;
}

.btn-primary:hover {
  background: #e7e9ea;
  border-color: #e7e9ea;
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-strong);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
}

.btn-ghost:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}

.btn-danger:hover {
  background: rgba(244, 33, 46, 0.1);
}

.btn-sm {
  height: 32px;
  padding: 0 14px;
  font-size: 13px;
}

/* 5.3 Inputs, Selects, Textareas */
.input-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.input, .select, .textarea {
  width: 100%;
  height: 40px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0 14px;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  transition: border-color var(--ease);
}

.input:focus, .select:focus, .textarea:focus {
  border-color: var(--border-strong);
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

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

.textarea {
  height: auto;
  min-height: 80px;
  padding: 10px 14px;
  resize: vertical;
}

.input--error {
  border-color: var(--danger) !important;
}

.field-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* 5.4 Status Pills */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  padding: 2px 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-body);
}

.status-pill--success {
  border-color: rgba(0, 186, 124, 0.3);
  background: rgba(0, 186, 124, 0.12);
  color: var(--success);
}

.status-pill--warning {
  border-color: rgba(255, 212, 0, 0.3);
  background: rgba(255, 212, 0, 0.12);
  color: var(--warning);
}

.status-pill--danger {
  border-color: rgba(244, 33, 46, 0.3);
  background: rgba(244, 33, 46, 0.12);
  color: var(--danger);
}

.status-pill--info {
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}
.status-dot--success { background: var(--success); }
.status-dot--warning { background: var(--warning); }
.status-dot--danger { background: var(--danger); }
.status-dot--info { background: var(--info); }

/* 5.5 Method Chips (All Monochrome!) */
.method-chip {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  display: inline-block;
  line-height: 1.2;
}

.method-chip--del {
  color: var(--danger);
  border-color: rgba(244, 33, 46, 0.3);
}

/* 5.6 Code Blocks and Language Switcher */
.code-container {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin: 16px 0;
}

.code-tabs {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  background: var(--surface-1);
  padding: 0 8px;
  gap: 4px;
}

.code-tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  padding: 10px 14px;
  cursor: pointer;
  transition: color var(--ease);
}

.code-tab:hover {
  color: var(--text);
}

.code-tab.active {
  color: var(--text);
  border-bottom-color: var(--brand);
}

.code-copy-btn {
  margin-left: auto;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 12px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: color var(--ease), background var(--ease);
}
.code-copy-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.code-body {
  padding: 16px 20px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-body);
  overflow-x: auto;
  white-space: pre;
}

code.inline, .code-inline {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
}

/* 5.7 Callout / Tip */
.callout {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin: 16px 0;
}

.callout--warning {
  border-left: 2px solid var(--warning);
}

/* 5.8 Tables */
.table-wrapper {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-1);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 14px;
}

table.data-table th {
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--surface-1);
}

table.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-body);
}

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

table.data-table td.num, table.data-table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* 5.9 Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.modal-dialog {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-width: 480px;
  width: 100%;
  padding: 24px;
  position: relative;
}

/* Topbar */
.site-topbar {
  height: 64px;
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.01em;
}

.search-pill-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 6px 14px;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  transition: border-color var(--ease);
}
.search-pill-btn:hover {
  border-color: var(--border-strong);
  color: var(--text);
}
.kbd-hint {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  color: var(--text-subtle);
}

/* Site Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 40px 24px 32px;
  margin-top: auto;
  color: var(--text-muted);
  font-size: 13px;
  background: var(--bg);
}

.site-footer__inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
}

.site-footer__links {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 20px;
}

.site-footer__links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  transition: color var(--ease);
}

.site-footer__links a:hover {
  color: var(--text);
}

.site-footer__copy {
  font-size: 13px;
  color: var(--text-muted);
}

.site-footer p.disclaimer {
  max-width: 760px;
  margin: 4px auto 0;
  font-size: 12px;
  color: var(--text-subtle);
  line-height: 1.5;
}

/* Media Query: Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
