/* ==========================================================================
   NIMZELIO — base.css
   Tokens, reset, typography, primitives (buttons, inputs, chips, badges)
   ========================================================================== */

:root {
  /* Palette */
  --bg: #F8F8F5;
  --surface: #FFFFFF;
  --text: #242722;
  --text-2: #777B75;
  --border: #E8E9E2;
  --border-strong: #D6D8CE;

  --sage: #C8D5C2;
  --sage-soft: #EDF2E9;
  --lavender: #E8E3F5;
  --lavender-soft: #F4F1FA;
  --peach: #F4D4C7;
  --peach-soft: #FBEEE9;
  --blue: #DCE8F1;
  --blue-soft: #EEF4F9;
  --rose: #F3DCD8;
  --rose-soft: #FBEFED;

  --ok: #4A7A52;
  --ok-bg: #E7F0E5;
  --err: #A24B48;
  --err-bg: #F5E3E1;

  /* Type */
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  /* Space — 4/8 system */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;
  --s8: 64px;
  --s9: 96px;

  /* Radii */
  --r-card: 14px;
  --r-btn: 10px;
  --r-chip: 999px;
  --r-sm: 8px;

  /* Elevation — barely there */
  --shadow-1: 0 1px 2px rgba(36, 39, 34, 0.04);
  --shadow-2: 0 6px 18px -8px rgba(36, 39, 34, 0.16), 0 1px 2px rgba(36, 39, 34, 0.04);

  /* Layout */
  --max: 1160px;
  --nav-h: 64px;

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.2; font-weight: 600; letter-spacing: -0.02em; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; }
img, svg, canvas, video { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }

:focus-visible {
  outline: 2px solid #6E7F68;
  outline-offset: 2px;
  border-radius: 4px;
}

::selection { background: var(--sage); color: var(--text); }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 200;
  background: var(--text);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--r-btn);
  font-size: 14px;
  text-decoration: none;
}
.skip-link:focus { left: 16px; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.noscript-note {
  max-width: var(--max);
  margin: var(--s6) auto;
  padding: var(--s4);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-card);
  background: var(--surface);
}

/* Typography helpers ----------------------------------------------------- */
.eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-2);
}

.muted { color: var(--text-2); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 0.92em; }
.nowrap { white-space: nowrap; }
.text-ok { color: var(--ok); }
.text-err { color: var(--err); }

/* Buttons ---------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: 44px;
  padding: 10px 18px;
  border-radius: var(--r-btn);
  border: 1px solid transparent;
  background: var(--text);
  color: #fff;
  font-size: 14.5px;
  font-weight: 500;
  letter-spacing: -0.005em;
  text-decoration: none;
  cursor: pointer;
  transition: background 160ms var(--ease), border-color 160ms var(--ease),
              transform 160ms var(--ease), box-shadow 160ms var(--ease), color 160ms var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: #383C35; }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-1);
}
.btn-secondary:hover { background: #FCFCFA; border-color: #C3C6BA; }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: transparent;
}
.btn-ghost:hover { background: #EFEFEA; }

.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 13.5px; border-radius: var(--r-sm); }
.btn-block { width: 100%; }

.btn-icon {
  width: 44px; height: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: var(--r-btn);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.btn-icon:hover { background: #EFEFEA; }

/* Inputs ----------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label,
.label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.005em;
}
.field .hint { font-size: 12px; color: var(--text-2); line-height: 1.45; }

.input, .select, .textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  font-size: 14.5px;
  transition: border-color 140ms var(--ease), box-shadow 140ms var(--ease);
}
.input:hover, .select:hover, .textarea:hover { border-color: #C3C6BA; }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: #8A9A84;
  box-shadow: 0 0 0 3px rgba(200, 213, 194, 0.55);
}
.input[aria-invalid="true"], .textarea[aria-invalid="true"] {
  border-color: var(--err);
  box-shadow: 0 0 0 3px rgba(162, 75, 72, 0.12);
}
.textarea { min-height: 140px; resize: vertical; font-family: var(--mono); font-size: 13px; line-height: 1.55; }

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%23777B75' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}

/* Range slider */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 32px;
  background: transparent;
  cursor: pointer;
  margin: 0;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: var(--border-strong);
}
input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 999px;
  background: var(--border-strong);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  margin-top: -7px;
  border-radius: 50%;
  background: var(--text);
  border: 2px solid var(--surface);
  box-shadow: var(--shadow-1);
}
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--text);
  border: 2px solid var(--surface);
  box-shadow: var(--shadow-1);
}

/* Checkbox */
.check { display: inline-flex; align-items: center; gap: var(--s2); font-size: 14px; cursor: pointer; }
.check input[type="checkbox"] {
  width: 18px; height: 18px;
  accent-color: var(--text);
  cursor: pointer;
  margin: 0;
}

/* Chips ------------------------------------------------------------------ */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 14px;
  border-radius: var(--r-chip);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 140ms var(--ease), border-color 140ms var(--ease), color 140ms var(--ease);
}
.chip:hover { border-color: #C3C6BA; background: #FCFCFA; }
.chip[aria-pressed="true"], .chip.is-active {
  background: var(--text);
  border-color: var(--text);
  color: #fff;
}

/* Badges ----------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: var(--r-chip);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text-2);
}
.badge-exp { background: var(--peach-soft); border-color: #EDCDBF; color: #8A5B47; }

/* Cards ------------------------------------------------------------------ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-1);
}

/* Notes ------------------------------------------------------------------ */
.note {
  display: flex;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  border-radius: var(--r-sm);
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-2);
}
.note strong { color: var(--text); font-weight: 600; }
.note-warn { background: var(--peach-soft); border-color: #EFD6C8; color: #7C5343; }
.note-warn strong { color: #6B4436; }
.note-err { background: var(--err-bg); border-color: #EBD2CF; color: var(--err); }
.note-ok { background: var(--ok-bg); border-color: #D7E5D3; color: var(--ok); }

/* Toasts ----------------------------------------------------------------- */
.toast-root {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  align-items: center;
  pointer-events: none;
  width: min(92vw, 460px);
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--s2);
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--r-btn);
  background: var(--text);
  color: #fff;
  font-size: 13.5px;
  line-height: 1.45;
  box-shadow: var(--shadow-2);
  animation: toast-in 220ms var(--ease) both;
}
.toast.is-ok { background: #33543A; }
.toast.is-err { background: #7E3A38; }
.toast.is-out { animation: toast-out 180ms var(--ease) both; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(6px); }
}

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