/* ============================================================
   COMPONENTS — buttons, inputs, cards, tables, nav, etc.
   ============================================================ */

/* ---- BUTTONS ---------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 20px;
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  font-weight: 500;
  letter-spacing: var(--tracking-normal);
  border-radius: var(--r-2);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--dur-base) var(--ease-out);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-primary {
  background: var(--ink);
  color: var(--ink-inverse);
  border-color: var(--ink);
}
.btn-primary:hover { background: var(--ink-2); transform: translateY(-1px); }

.btn-accent {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}
.btn-accent:hover {
  box-shadow: 0 0 0 1px var(--accent), 0 0 24px var(--accent-glow);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line-2);
}
.btn-ghost:hover { border-color: var(--ink); background: var(--bg-raised); }

.btn-link {
  height: auto;
  padding: 0;
  background: transparent;
  color: var(--ink);
  border: 0;
  border-bottom: 1px solid currentColor;
  border-radius: 0;
  padding-bottom: 2px;
}
.btn-link:hover { color: var(--accent); }

.btn-sm { height: 34px; padding: 0 14px; font-size: var(--fs-xs); }
.btn-lg { height: 52px; padding: 0 28px; font-size: var(--fs-body); }

.btn .arrow {
  transition: transform var(--dur-base) var(--ease-out);
  font-family: var(--font-mono);
}
.btn:hover .arrow { transform: translateX(4px); }

/* ---- INPUTS / FORMS --------------------------------------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field-label {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--ink-4);
  font-weight: 500;
}
.input, .textarea, .select {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  background: var(--bg-raised);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  transition: border-color var(--dur-base), box-shadow var(--dur-base);
}
.textarea { height: auto; padding: 12px 14px; min-height: 96px; resize: vertical; line-height: var(--lh-body); }
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px var(--accent-weak);
}
.input::placeholder, .textarea::placeholder { color: var(--ink-4); }

.field-help {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--ink-4);
}

.checkbox, .radio {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: var(--fs-sm);
  cursor: pointer;
  user-select: none;
}
.checkbox input, .radio input { display: none; }
.checkbox .box, .radio .box {
  width: 18px;
  height: 18px;
  border: 1px solid var(--line-2);
  background: var(--bg-raised);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--dur-fast);
}
.checkbox .box { border-radius: 3px; }
.radio .box { border-radius: 50%; }
.checkbox input:checked + .box {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--ink-inverse);
}
.checkbox input:checked + .box::after {
  content: '✓';
  font-size: 11px;
  font-weight: 700;
}
.radio input:checked + .box::after {
  content: '';
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--ink);
}

/* Toggle switch */
.toggle {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 22px;
}
.toggle input { display: none; }
.toggle .track {
  position: absolute;
  inset: 0;
  background: var(--line-2);
  border-radius: var(--r-full);
  transition: background var(--dur-base);
}
.toggle .thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  background: var(--bg-raised);
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur-base) var(--ease-out);
}
.toggle input:checked ~ .track { background: var(--accent); }
.toggle input:checked ~ .thumb { transform: translateX(16px); }

/* ---- BADGES / CHIPS --------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--r-1);
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  font-weight: 500;
  background: var(--bg-sunken);
  color: var(--ink-3);
  border: 1px solid var(--line);
}
.badge-live {
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 30%, transparent);
  background: color-mix(in srgb, var(--ok) 10%, transparent);
}
.badge-live .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 8px var(--ok);
  animation: pulse-glow 2s ease-in-out infinite;
}
.badge-dev { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); background: color-mix(in srgb, var(--warn) 10%, transparent); }
.badge-verified { color: var(--info); border-color: color-mix(in srgb, var(--info) 30%, transparent); background: color-mix(in srgb, var(--info) 10%, transparent); }
.badge-accent { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); background: var(--accent-weak); }

/* ---- CARDS ------------------------------------------------ */
.card {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  padding: var(--s-6);
  transition: border-color var(--dur-base), transform var(--dur-base);
}
.card-hover:hover {
  border-color: var(--ink);
  transform: translateY(-2px);
}
.card-flat {
  background: transparent;
  border-radius: 0;
  border: 0;
  border-top: 1px solid var(--line);
  padding: var(--s-6) 0;
}

/* Stat card */
.stat {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  padding: var(--s-5);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  background: var(--bg-raised);
  position: relative;
  overflow: hidden;
}
.stat-label {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--ink-4);
}
.stat-value {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1;
  letter-spacing: var(--tracking-tight);
  color: var(--ink);
}
.stat-delta {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--ok);
}
.stat-delta.neg { color: var(--err); }
.stat::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 24px; height: 1px;
  background: var(--accent);
}

/* Spec card — tech callout */
.spec {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: var(--s-4);
  padding: var(--s-5);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  background: var(--bg-raised);
  align-items: start;
}
.spec-idx {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--ink-4);
  padding-top: 2px;
}
.spec-title { font-weight: 500; margin-bottom: 4px; }
.spec-body { color: var(--ink-3); font-size: var(--fs-sm); line-height: var(--lh-body); }

/* Project card */
.proj {
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  background: var(--bg-raised);
  overflow: hidden;
  transition: border-color var(--dur-base), transform var(--dur-base);
}
.proj:hover { border-color: var(--ink); }
.proj-media {
  aspect-ratio: 16/10;
  background: var(--bg-sunken);
  border-bottom: 1px solid var(--line);
  position: relative;
  overflow: hidden;
}
.proj-media .placeholder {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-4);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  background:
    linear-gradient(135deg, transparent 48%, var(--line) 48% 52%, transparent 52%) 0 0/12px 12px;
}
.proj-body { padding: var(--s-5); }
.proj-meta {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--ink-4);
  margin-bottom: var(--s-3);
}

/* ---- TABLES (explorer style) ------------------------------ */
.explorer {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
}
.explorer th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--ink-4);
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-sunken);
}
.explorer td {
  padding: var(--s-row, 14px) 16px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.explorer tbody tr { transition: background var(--dur-fast); }
.explorer tbody tr:hover { background: var(--accent-tint); }
.explorer .hash { color: var(--ink); }
.explorer .addr { color: var(--info); }
.explorer .num { text-align: right; }

/* ---- NAV -------------------------------------------------- */
.topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 32px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(12px);
}
.topnav-logo {
  font-family: var(--font-display);
  font-size: 1.375rem;
  letter-spacing: var(--tracking-normal);
}
.topnav-logo sup {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: var(--tracking-mega);
  color: var(--ink-4);
  text-transform: uppercase;
  margin-left: 8px;
  vertical-align: 6px;
}
.topnav-links {
  display: flex;
  gap: var(--s-6);
  font-size: var(--fs-sm);
  color: var(--ink-3);
}
.topnav-links a { position: relative; transition: color var(--dur-fast); }
.topnav-links a:hover { color: var(--ink); }
.topnav-links a.active { color: var(--ink); }
.topnav-links a.active::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -4px;
  height: 1px; background: var(--accent);
}

/* Footer */
.footer {
  padding: var(--s-9) var(--s-6);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: 2fr repeat(3, 1fr);
  gap: var(--s-7);
}
.footer h4 {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--ink-4);
  font-weight: 500;
  margin: 0 0 var(--s-4) 0;
}
.footer ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.footer a { color: var(--ink-3); font-size: var(--fs-sm); transition: color var(--dur-fast); }
.footer a:hover { color: var(--ink); }

/* ---- HERO / SECTION HEADERS ------------------------------- */
.section {
  padding: var(--s-9) var(--s-6);
  border-top: 1px solid var(--line);
}
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: var(--s-7);
  gap: var(--s-5);
}
.section-index {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--ink-4);
}

/* ---- TERMINAL --------------------------------------------- */
.terminal {
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  overflow: hidden;
}
.terminal-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-raised);
  font-size: var(--fs-xs);
  color: var(--ink-4);
}
.terminal-head .dots {
  display: flex; gap: 6px;
}
.terminal-head .dots span {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--line-2);
}
.terminal-body {
  padding: 16px;
  line-height: 1.7;
  color: var(--ink-2);
}
.terminal-body .ts { color: var(--ink-4); }
.terminal-body .ok { color: var(--ok); }
.terminal-body .info { color: var(--info); }
.terminal-body .warn { color: var(--warn); }

/* ---- CHART PRIMITIVES ------------------------------------- */
.chart-card {
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  padding: var(--s-5);
  background: var(--bg-raised);
}
.chart-axis { stroke: var(--line); stroke-width: 1; }
.chart-grid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 4; }
.chart-line { stroke: var(--accent); stroke-width: 1.5; fill: none; }
.chart-area { fill: var(--accent-weak); }
.chart-dot { fill: var(--bg-raised); stroke: var(--accent); stroke-width: 1.5; }

/* Sparkbar */
.sparkbar {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 32px;
}
.sparkbar span {
  flex: 1;
  background: var(--ink);
  opacity: 0.15;
  transition: opacity var(--dur-base), height var(--dur-base);
}
.sparkbar span.hot { opacity: 1; background: var(--accent); }

/* ---- DS PAGE CHROME --------------------------------------- */
.ds-container { max-width: 1440px; margin: 0 auto; }

.ds-hero {
  padding: var(--s-10) var(--s-6) var(--s-9);
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: var(--s-8);
  align-items: end;
  border-bottom: 1px solid var(--line);
}
.ds-hero .meta {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--ink-4);
}
.ds-hero .meta .row-line {
  display: grid;
  grid-template-columns: 140px 1fr;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.ds-hero .meta .row-line:last-child { border-bottom: 1px solid var(--line); }

/* Token swatch */
.swatch {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: var(--s-4);
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  align-items: center;
  background: var(--bg-raised);
}
.swatch .chip {
  width: 56px; height: 40px;
  border-radius: var(--r-1);
  border: 1px solid var(--line);
}
.swatch .name { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--ink-2); }
.swatch .val { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--ink-4); }

/* Tweak panel */
.tweak-toggle {
  position: fixed;
  bottom: 20px; right: 20px;
  z-index: 100;
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--ink-inverse);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-lg);
  transition: transform var(--dur-base);
  font-family: var(--font-mono);
  font-size: 18px;
}
.tweak-toggle:hover { transform: scale(1.05); }
.tweak-panel {
  position: fixed;
  bottom: 80px; right: 20px;
  z-index: 101;
  width: 320px;
  max-height: 80vh;
  overflow-y: auto;
  background: var(--bg-raised);
  border: 1px solid var(--line-2);
  border-radius: var(--r-3);
  box-shadow: var(--shadow-lg);
  font-family: var(--font-body);
  transform: translateY(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-base), transform var(--dur-base);
}
.tweak-panel.open { opacity: 1; transform: translateY(0); pointer-events: auto; }
.tweak-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--ink-3);
}
.tweak-group { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.tweak-group:last-child { border-bottom: 0; }
.tweak-group h5 {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  text-transform: uppercase;
  letter-spacing: var(--tracking-mega);
  color: var(--ink-4);
  margin: 0 0 10px 0;
  font-weight: 500;
}
.tweak-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 0;
  font-size: var(--fs-sm);
}
.tweak-row label { color: var(--ink-2); }
.tweak-options {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.tweak-chip {
  padding: 6px 10px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-1);
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--ink-3);
  cursor: pointer;
  transition: all var(--dur-fast);
  background: transparent;
}
.tweak-chip:hover { border-color: var(--ink); color: var(--ink); }
.tweak-chip.active {
  background: var(--ink);
  color: var(--ink-inverse);
  border-color: var(--ink);
}
.tweak-swatch {
  width: 28px; height: 28px;
  border-radius: var(--r-1);
  border: 1px solid var(--line-2);
  cursor: pointer;
  padding: 0;
  transition: transform var(--dur-fast);
}
.tweak-swatch.active {
  box-shadow: 0 0 0 2px var(--bg-raised), 0 0 0 3px var(--ink);
}
.tweak-swatch:hover { transform: scale(1.06); }
