/*
 * Kupi Club — UI token contract + baseline stylesheet (T-0025; design-system v1.0 values T-0044).
 * SINGLE SoT of UI semantics. Design input: docs/incoming-design/design-tokens.css + README.md
 * (Kupi Club Design System v1.0 — cream/coral, Plus Jakarta Sans + Space Mono). Raw v1.0 hex values
 * are mapped INTO the existing SEMANTIC names here (decision A — NO --kc-* parallel store). Raw color
 * values live ONLY in this :root block (the no-raw-hex lint, T-0028/T-0040, allows hex here and forbids
 * it in app/templates/** and frontend/src/**). Authored semantically so a future Tailwind layer maps from it.
 */

:root {
  /* --- color (v1.0 cream/coral; provenance docs/incoming-design/design-tokens.css) --- */
  --bg: #FBF6EF;            /* cream — app background */
  --surface: #FFFFFF;       /* white — card/surface */
  --surface-2: #F4EEE5;     /* cream-2 — alt surface (chrome bars) */
  --text: #2A2018;          /* ink — primary text */
  --text-muted: #6F6256;    /* muted — secondary text */
  --text-faint: #9A8A78;    /* faint — captions */
  --text-faint-2: #A89A88;  /* faint-2 — hints */
  --border: #EDE3D6;        /* default border */
  --border-strong: #E5D8C8; /* input/control border */
  --primary: #FF6B35;       /* coral — primary action */
  --primary-hover: #F2531C; /* coral-deep — primary hover/active */
  --primary-contrast: #FFFFFF;
  --accent: #FFB627;        /* sun — accent */
  --accent-hover: #F5A800;  /* sun-deep — accent hover */
  --tint: #FFE9D0;          /* peach — tint / chips / soft fills */
  --success: #1E9E6A;
  --warning: #E08600;
  --danger: #E03E2F;        /* error */
  --focus-ring: rgba(255, 107, 53, .5); /* coral-derived; outline color for :focus-visible */
  /* status triplets (text / soft bg / border) — info reuses --primary on --tint */
  --success-text: #127A50;
  --success-bg: #E6F6EF;
  --success-border: #C5EAD8;
  --warning-text: #B96E00;
  --warning-bg: #FFF3DD;
  --warning-border: #FAE2B0;
  --danger-text: #C9301F;
  --danger-bg: #FDECEA;
  --danger-border: #F7CCC6;
  /* chart series (T-0040) — concrete hex (NOT var() aliases): the SPA reads these via
     getComputedStyle().getPropertyValue(), which does not resolve nested var(). Provenance:
     --chart-hits tracks --success, --chart-misses tracks --danger. */
  --chart-hits: #1E9E6A;
  --chart-misses: #E03E2F;

  /* --- type (v1.0 §Typography; Plus Jakarta Sans + Space Mono, system fallbacks retained) --- */
  --font-sans: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-mono: "Space Mono", ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;
  --text-xs: .8125rem;   /* 13px — caption */
  --text-sm: .875rem;    /* 14px — label */
  --text-base: 1rem;     /* 16px — body */
  --text-lg: 1.125rem;   /* 18px — body-lg */
  --text-xl: 1.25rem;    /* 20px — h3 */
  --text-2xl: 1.875rem;  /* 30px — h2 */
  --text-3xl: 3rem;      /* 48px — h1 */
  --text-display: 4rem;  /* 64px — hero wordmark */
  --text-mono-input: 1.375rem;             /* 22px — article code field */
  --mono-input: 700 1.375rem/1 var(--font-mono); /* article code field font shorthand */
  --mono-input-tracking: .04em;            /* article code field letter-spacing */

  /* --- spacing (v1.0 §Spacing, 4px base) --- */
  --space-1: .25rem;   /* 4px */
  --space-2: .5rem;    /* 8px */
  --space-3: .75rem;   /* 12px */
  --space-4: 1rem;     /* 16px */
  --space-5: 1.25rem;  /* 20px */
  --space-6: 1.5rem;   /* 24px */
  --space-8: 2rem;     /* 32px */
  --space-10: 2.5rem;  /* 40px */
  --space-12: 3rem;    /* 48px */

  /* --- radius / border (v1.0 §Radius) --- */
  --radius-sm: .5625rem;  /* 9px — chips, small controls */
  --radius-md: .6875rem;  /* 11px — small buttons */
  --radius-lg: .875rem;   /* 14px — buttons, inputs */
  --radius-xl: 1.125rem;  /* 18px — cards */
  --radius-2xl: 1.375rem; /* 22px — feature cards */
  --radius-pill: 999px;
  --border-width: 1px;

  /* --- shadow (v1.0 §Shadows, warm-tinted) + motion --- */
  --shadow-sm: 0 4px 20px rgba(42, 32, 24, .05);   /* card */
  --shadow-md: 0 18px 44px rgba(42, 32, 24, .16);  /* pop */
  --shadow-coral: 0 8px 18px rgba(255, 107, 53, .34);    /* primary button */
  --shadow-coral-sm: 0 4px 12px rgba(255, 107, 53, .30);
  --focus-ring-shadow: 0 0 0 4px rgba(255, 107, 53, .14);
  --scrim: rgba(42, 32, 24, .45); /* ink-tinted dialog/modal backdrop (ConfirmDialog, SPEC-0016) */
  --z-modal: 50;                  /* layer: confirmation dialog above the cabinet chrome */
  --ease: .16s ease;
}

/* --- base layout --- */
body {
  font-family: var(--font-sans);
  margin: 0;
  padding: var(--space-4);
  max-width: 720px;
  margin-inline: auto;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}
h1 { font-size: var(--text-2xl); line-height: 1.2; }
h2 { font-size: var(--text-xl); line-height: 1.2; }
h3 { font-size: var(--text-lg); line-height: 1.2; }
a { color: var(--primary); }
a:hover { color: var(--primary-hover); }

/* --- focus-visible (baseline §5; all interactive controls) --- */
:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* --- table (baseline §5) --- */
table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: var(--space-3) var(--space-2);
  border-bottom: var(--border-width) solid var(--border);
  vertical-align: top;
  word-break: break-all;
}
th { font-size: var(--text-xs); color: var(--text-muted); text-transform: uppercase; }
tbody tr:hover { background: var(--surface-2); }

/* --- button (baseline §5; primary by default, ≥44px touch target) --- */
a.button, button {
  display: inline-block;
  min-height: 44px;
  padding: var(--space-2) var(--space-4);
  margin: var(--space-1) 0;
  font-size: var(--text-base);
  font-weight: 600;
  line-height: 1.6;
  border: var(--border-width) solid var(--primary);
  border-radius: var(--radius-md);
  background: var(--primary);
  color: var(--primary-contrast);
  text-decoration: none;
  cursor: pointer;
}
a.button:hover, button:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--primary-contrast); }
/* secondary variant (opt-in) */
a.button.secondary, button.secondary {
  background: var(--surface); color: var(--text); border-color: var(--border);
}

/* --- inputs (baseline §5; ≥16px to avoid iOS zoom, ≥44px target) --- */
input[type=text], input[type=url], input[type=email], input[type=password] {
  width: 100%;
  min-height: 44px;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-base);
  color: var(--text);
  background: var(--surface);
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius-md);
  box-sizing: border-box;
}
/* textarea — same field tokens as the inputs above (T-0053; reusable on-style multiline control) */
textarea {
  width: 100%;
  min-height: 4.5rem;
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.4;
  color: var(--text);
  background: var(--surface);
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius-md);
  resize: vertical;
  box-sizing: border-box;
}
input:focus-visible, textarea:focus-visible { border-color: var(--primary); }
label { display: block; margin: var(--space-3) 0; }

/* --- utility / shared classes (ported from the former base.html <style>) --- */
.code { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 600; }
.muted { color: var(--text-muted); }
.err { color: var(--danger); }
.right { text-align: right; margin: 0; }

/* --- landing hero (baseline §5/§6 public surface) --- */
.hero { text-align: center; padding-block: var(--space-12); }
.hero h1 { font-size: var(--text-3xl); }
.hero input[type=text] { font-size: var(--text-xl); text-align: center; }

/* ===========================================================================
 * Design System v1.0 — component layer (T-0046). Realizes the reference design
 * (docs/incoming-design/reference-design-system.html) as reusable classes over
 * the token SoT above. Surfaced live in /styleguide. No new tokens — every value
 * references a var(--…) declared in :root. =========================================== */

/* --- button variants (primary = base `button`/`a.button` above; these are the v1.0 extensions) --- */
a.button.ghost, button.ghost {
  background: transparent; color: var(--text-muted); border-color: transparent; box-shadow: none;
}
a.button.ghost:hover, button.ghost:hover {
  background: var(--tint); color: var(--primary-hover); border-color: transparent;
}
a.button.accent, button.accent {
  background: var(--accent-hover); color: var(--primary-contrast); border-color: var(--accent-hover);
}
a.button.accent:hover, button.accent:hover {
  background: var(--accent); border-color: var(--accent);
}
button:disabled, a.button.disabled, button.disabled {
  background: var(--surface-2); color: var(--text-faint); border-color: var(--border);
  box-shadow: none; cursor: not-allowed;
}

/* --- input states (default + :focus-visible covered in the base input block above) --- */
input.input--filled { background: var(--surface); border-color: var(--border-strong); }
input.input--error {
  border-color: var(--danger); background: var(--danger-bg); color: var(--danger-text);
}
input.input--error:focus-visible { outline-color: var(--danger); border-color: var(--danger); }

/* --- status messages (success / warning / danger / info; v1.0 §Сообщения и статусы) --- */
.status {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm); font-weight: 600;
  margin: var(--space-3) 0;
}
.status__icon {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 1.625rem; height: 1.625rem; border-radius: var(--radius-pill);
  color: var(--primary-contrast); font-weight: 800; font-size: var(--text-sm);
}
.status--success { background: var(--success-bg); border-color: var(--success-border); color: var(--success-text); }
.status--success .status__icon { background: var(--success); }
.status--warning { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning-text); }
.status--warning .status__icon { background: var(--warning); }
.status--danger  { background: var(--danger-bg);  border-color: var(--danger-border);  color: var(--danger-text); }
.status--danger .status__icon  { background: var(--danger); }
.status--info    { background: var(--tint);       border-color: var(--border-strong);  color: var(--primary-hover); }
.status--info .status__icon    { background: var(--primary); }

/* --- header + navigation (v1.0 §Хедер и навигация; coral logo-arrow mark) --- */
.sg-header {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
  padding: var(--space-3) var(--space-5);
  background: var(--surface);
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
}
.sg-brand { display: flex; align-items: center; gap: var(--space-3); font-weight: 800; letter-spacing: -.02em; }
.logo-mark {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; border-radius: var(--radius-sm);
  background: var(--primary); color: var(--primary-contrast);
  font-weight: 800; font-size: var(--text-lg); line-height: 1;
  box-shadow: var(--shadow-coral-sm);
}
.sg-nav { display: flex; align-items: center; gap: var(--space-1); }
.sg-nav a {
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-md);
  color: var(--text-muted); text-decoration: none; font-weight: 600; font-size: var(--text-sm);
}
.sg-nav a:hover { background: var(--tint); color: var(--primary-hover); }

/* --- cards / containers (v1.0 §Карточки и контейнеры) --- */
.card {
  background: var(--surface);
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-sm);
  padding: var(--space-6);
}
.card + .card { margin-top: var(--space-4); }
.card h3 { margin-top: 0; }
