/* ============================================
   NEURAPHIC WORKERS — base.css
   Resets, tokens, typography, utilities, components
   ============================================ */

:root {
  --bg: #f0f1f3;
  --black: #131314;
  --gray: #6b7280;
  --head: 'Space Grotesk', -apple-system, system-ui, sans-serif;
  --sans: 'Inter', -apple-system, system-ui, sans-serif;
  --w: 1280px;
  --nav-h: 72px;
  --line: rgba(19,19,20,0.08);
  --ink-hover: #2a2a2e;

  /* Spacing scale */
  --s-0: 0;
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-7: 32px;
  --s-8: 40px;
  --s-9: 56px;
  --s-10: 72px;
  --s-11: 96px;
  --s-12: 128px;

  /* Section scale */
  --sec-sm: clamp(48px, 6vh, 72px);
  --sec-md: clamp(60px, 10vh, 100px);
  --sec-lg: clamp(80px, 12vh, 140px);

  /* Radii */
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 14px;
  --r-xl: 20px;

  /* State colors */
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
}

/* --- Reset --- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--gray);
  font-size: 16px;
  line-height: 1.7;
  overflow-x: hidden;
  overflow-wrap: break-word;
}
a { color: inherit; text-decoration: none; }
img, video, svg { display: block; max-width: 100%; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--head);
  color: var(--black);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
h1 { font-size: clamp(36px, 5vw, 64px); letter-spacing: -0.04em; line-height: 1.08; }
h2 { font-size: clamp(26px, 3vw, 36px); letter-spacing: -0.03em; }
h3 { font-size: clamp(20px, 2vw, 24px); }
h4 { font-size: 18px; font-weight: 600; }
h5 { font-size: 15px; font-weight: 600; }
h6 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; }
p { line-height: 1.7; }

/* --- Utilities --- */
.wrap { max-width: var(--w); margin: 0 auto; padding: 0 clamp(24px, 4vw, 48px); }

.stack { display: flex; flex-direction: column; }
.stack > * + * { margin-top: var(--s-4); }
.stack--sm > * + * { margin-top: var(--s-2); }
.stack--lg > * + * { margin-top: var(--s-6); }

.row { display: flex; align-items: center; gap: var(--s-4); }
.row--between { justify-content: space-between; }
.row--end { justify-content: flex-end; }
.col { display: flex; flex-direction: column; }

.grid { display: grid; gap: var(--s-6); }
.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--4 { grid-template-columns: repeat(4, 1fr); }

.hidden { display: none !important; }
.mono { font-family: 'SF Mono', 'JetBrains Mono', 'Fira Code', ui-monospace, monospace; font-size: 13px; }
.muted { color: var(--gray); }
.small { font-size: 13px; }
.ink { color: var(--black); }
.nowrap { white-space: nowrap; }
.center { text-align: center; }

/* --- Divider --- */
.divider {
  border: none;
  border-top: 1px solid var(--line);
  margin: 0 auto;
  max-width: calc(var(--w) - clamp(48px, 8vw, 96px));
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--black);
  cursor: pointer;
  transition: background .2s, color .2s, border-color .2s, opacity .2s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn--primary { background: var(--black); color: var(--bg); }
.btn--primary:hover:not(:disabled) { background: var(--ink-hover); }

.btn--ghost { background: transparent; color: var(--black); border-color: var(--line); }
.btn--ghost:hover:not(:disabled) { border-color: var(--black); }

.btn--danger { background: var(--red); color: #fff; }
.btn--danger:hover:not(:disabled) { background: #b91c1c; }

.btn--small { font-size: 13px; padding: 6px 12px; border-radius: var(--r-sm); }
.btn--block { width: 100%; }

/* --- Pill --- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--black);
  background: rgba(19,19,20,0.06);
  padding: 4px 10px;
  border-radius: 999px;
  line-height: 1.4;
}
.pill--green { color: var(--green); background: rgba(22,163,74,0.1); }
.pill--amber { color: var(--amber); background: rgba(217,119,6,0.1); }
.pill--red { color: var(--red); background: rgba(220,38,38,0.1); }
.pill--dark { color: var(--bg); background: var(--black); }

/* --- Card --- */
.card {
  background: #e6e7e9;
  border-radius: var(--r-lg);
  padding: clamp(20px, 2.5vw, 32px);
  transition: background .2s;
}
.card--link { display: block; }
.card--link:hover { background: #dddee1; }
.card--outline {
  background: transparent;
  border: 1px solid var(--line);
}
.card--outline:hover { border-color: rgba(19,19,20,0.18); }
.card__title {
  font-family: var(--head);
  font-size: 20px;
  font-weight: 700;
  color: var(--black);
  margin-bottom: 8px;
  letter-spacing: -0.015em;
}
.card__desc { font-size: 14px; color: var(--gray); line-height: 1.6; }
.card__meta { font-size: 12px; color: var(--gray); margin-bottom: 10px; }

/* --- Forms --- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field__label {
  font-size: 13px;
  font-weight: 500;
  color: var(--black);
}
.field__hint { font-size: 12px; color: var(--gray); }
.field__error { font-size: 12px; color: var(--red); }

.input, .select, .textarea {
  width: 100%;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 10px 14px;
  font-size: 14px;
  color: var(--black);
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--black);
  box-shadow: 0 0 0 3px rgba(19,19,20,0.06);
}
.textarea { min-height: 120px; resize: vertical; font-family: inherit; line-height: 1.6; }

/* --- Table --- */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.table th, .table td {
  text-align: left;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.table th {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  color: var(--gray);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.table td { color: var(--black); }
.table tbody tr:hover { background: rgba(19,19,20,0.02); }

/* --- Toast host --- */
.toast-host {
  position: fixed;
  top: calc(var(--nav-h) + 16px);
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
  pointer-events: none;
}
.toast {
  background: var(--black);
  color: var(--bg);
  padding: 12px 18px;
  border-radius: var(--r-md);
  font-size: 14px;
  box-shadow: 0 12px 32px rgba(19,19,20,0.18);
  pointer-events: auto;
  max-width: 340px;
  animation: toast-in .25s ease-out;
}
.toast--success { background: var(--green); }
.toast--error { background: var(--red); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

::selection { background: rgba(19,19,20,0.12); color: var(--black); }
