/* Millcraft App Design System — see docs/millcraft-app-design.md (v1.0).
   Shared by the admin portal (src/admin/views.js) and the buyer catalog page
   (buildCatalogHTML in server.js). Components reference semantic tokens only. */

/* ---------- §2 Theme tokens ---------- */
:root {
  /* Surfaces */
  --bg:          #f5f4f0;
  --bg-raised:   #ffffff;
  --bg-well:     #edece6;
  --border:      #dedcd3;
  --dotgrid:     #d8d6cc;

  /* Ink */
  --ink:         #363534;
  --ink-muted:   #6a685f;
  --ink-faint:   #8b8980;

  /* Green — two-tier rule (§5) */
  --accent:      #5b8f22;
  --accent-text: #4a751b;
  --accent-wash: #eef3e4;

  /* Interactive */
  --btn-fill:    #4a751b;
  --btn-ink:     #ffffff;
  --btn-fill-hover: #3f6416;
  --focus-ring:  #4a751b;

  /* Status */
  --danger:      #a8442c;
  --danger-text: #a8442c;
  --warn:        #8f6510;
  --warn-text:   #8f6510;

  /* Logo */
  --logo-ink:    #363534;

  /* Brand fixtures */
  --band: linear-gradient(90deg, #5b8f22, #82b84a, #5b8f22);
  --chevron-left:  polygon(0 0, 100% 0, 82% 100%, 0 100%);
  --chevron-right: polygon(18% 0, 100% 0, 100% 100%, 0 100%);

  /* Geometry & motion */
  --radius-control: 2px;
  --radius-card:    0;
  --ease-brand: cubic-bezier(.16, 1, .3, 1);
  --t-fast: 150ms;  --t-med: 250ms;  --t-slow: 400ms;

  color-scheme: light;
}

[data-theme="dark"] {
  --bg:          #262524;
  --bg-raised:   #363534;
  --bg-well:     #1b1a1a;
  --border:      #45433d;
  --dotgrid:     #3a3833;

  --ink:         #f5f4f0;
  --ink-muted:   #a8a69d;
  --ink-faint:   #6a685f;

  --accent:      #5b8f22;
  --accent-text: #82b84a;
  --accent-wash: rgba(91, 143, 34, .14);

  --btn-fill:    #82b84a;
  --btn-ink:     #1b1a1a;
  --btn-fill-hover: #8fc45c;
  --focus-ring:  #82b84a;

  --danger:      #a8442c;
  --danger-text: #d98d76;
  --warn:        #8f6510;
  --warn-text:   #d9a84e;

  --logo-ink:    #f5f4f0;

  color-scheme: dark;
}

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

body {
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.6 'Jost', system-ui, sans-serif;
  transition: background var(--t-med) var(--ease-brand), color var(--t-med) var(--ease-brand);
}

:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* ---------- §6 Signature elements ---------- */
.mc-band { height: 4px; background: var(--band); }

.mc-wordmark {
  font-family: 'Jost', system-ui, sans-serif;
  font-weight: 300;
  font-size: 18px;
  text-transform: uppercase;
  letter-spacing: .3em;
  margin-right: -.32em;
  color: var(--logo-ink);
  line-height: 1;
  white-space: nowrap;
}

.mc-eyebrow {
  font-family: 'Jost', system-ui, sans-serif;
  font-size: 11px; font-weight: 600;
  letter-spacing: .24em; text-transform: uppercase;
  color: var(--accent-text);
}

.mc-divider { width: 64px; height: 2px; background: var(--accent); margin: 16px 0 32px; }

.mc-dots {
  background-image: radial-gradient(var(--dotgrid) 1.2px, transparent 1.2px);
  background-size: 36px 36px;
}

/* ---------- §4 Typography ---------- */
h1 { font: 300 32px/1.15 'Jost', system-ui, sans-serif; letter-spacing: .01em; }
h2 { font: 500 19px/1.3 'Jost', system-ui, sans-serif; margin: 32px 0 12px; }
h1 em, .display em { font-style: italic; color: var(--accent); }
.muted { color: var(--ink-muted); font-size: 13px; }
code, .mono { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- App header ---------- */
.mc-header {
  display: flex; align-items: center; gap: 28px;
  padding: 14px 28px;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
}
[data-theme="dark"] .mc-header { background: var(--bg-well); }
.mc-header nav { display: flex; gap: 20px; }
.mc-header nav a {
  color: var(--ink-muted); text-decoration: none;
  font-weight: 500; font-size: 14px; letter-spacing: .02em;
  padding: 8px 2px; border-bottom: 2px solid transparent;
  transition: color var(--t-fast) var(--ease-brand);
}
.mc-header nav a:hover { color: var(--ink); }
.mc-header nav a.active, .mc-header nav a[aria-current] {
  color: var(--accent-text); border-bottom-color: var(--accent);
}
.mc-header .mc-right { margin-left: auto; display: flex; align-items: center; gap: 16px; font-size: 13px; color: var(--ink-muted); }
.mc-header .mc-right a { color: var(--accent-text); text-decoration: none; }
.mc-header .mc-right a:hover { text-decoration: underline; }

/* ---------- §7 Buttons ---------- */
.btn, button.btn, .checkout-btn, .add-btn {
  display: inline-block;
  font-family: 'Jost', system-ui, sans-serif;
  font-weight: 500; font-size: 14px; letter-spacing: .02em;
  padding: 10px 20px;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  background: var(--btn-fill); color: var(--btn-ink);
  cursor: pointer; text-decoration: none; text-align: center;
  transition: background var(--t-fast) var(--ease-brand), color var(--t-fast) var(--ease-brand),
              border-color var(--t-fast) var(--ease-brand);
}
.btn:hover, .checkout-btn:hover, .add-btn:hover { background: var(--btn-fill-hover); }
.btn.secondary {
  background: transparent; color: var(--ink); border-color: var(--border);
}
.btn.secondary:hover { color: var(--accent-text); border-color: var(--accent-text); background: var(--accent-wash); }
.btn.ghost { background: none; border-color: transparent; color: var(--accent-text); padding: 6px 2px; }
.btn.ghost:hover { background: none; text-decoration: underline; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn:disabled, button:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- §7 Forms ---------- */
label {
  display: block;
  font-family: 'Jost', system-ui, sans-serif;
  font-size: 11px; font-weight: 600; letter-spacing: .24em;
  text-transform: uppercase; color: var(--ink-muted);
  margin: 0 0 6px;
}
input, select, textarea {
  font-family: 'Jost', system-ui, sans-serif; font-size: 15px;
  padding: 10px 12px;
  background: var(--bg-raised); color: var(--ink);
  border: 1px solid var(--border); border-radius: var(--radius-control);
  transition: border-color var(--t-fast) var(--ease-brand);
}
input::placeholder { color: var(--ink-faint); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
form:focus-within > label, .field:focus-within > label { color: var(--accent-text); }

/* ---------- §6③ Accent-top cards ---------- */
.card, .mc-card, .tile {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-top: 2px solid var(--accent);
  border-radius: var(--radius-card);
  padding: 20px 24px;
  margin-bottom: 16px;
}
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 8px; }
.tile { margin-bottom: 0; }
.tile .n { font: 300 34px/1 'Jost', system-ui, sans-serif; color: var(--ink); font-variant-numeric: tabular-nums; }
.tile .l { font-size: 11px; font-weight: 600; letter-spacing: .24em; text-transform: uppercase; color: var(--accent-text); margin-bottom: 10px; }

/* ---------- §7 Tables ---------- */
table { width: 100%; border-collapse: collapse; background: var(--bg-raised); border: 1px solid var(--border); }
th {
  text-align: left; background: var(--bg-well);
  font-size: 11px; font-weight: 600; letter-spacing: .24em; text-transform: uppercase;
  color: var(--ink-muted); padding: 12px 14px;
}
td { padding: 12px 14px; font-size: 14px; border-top: 1px solid var(--border); vertical-align: middle; }
tbody tr:hover, table tr:hover td { background: var(--accent-wash); }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- §7 Badges ---------- */
.pill {
  display: inline-block; padding: 3px 10px;
  font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
  background: var(--accent-wash); color: var(--accent-text);
  border-radius: var(--radius-control);
}
.pill.def { background: var(--bg-well); color: var(--ink-muted); }
.pill.sql { background: var(--accent-wash); color: var(--accent-text); }
.pill.apim { background: var(--bg-well); color: var(--ink-muted); }

/* ---------- §7 Alerts ---------- */
.notice {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-left: 2px solid var(--warn);
  color: var(--ink);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 14px;
}
.notice.error { border-left-color: var(--danger); }
.notice.error strong, .notice strong { font-weight: 600; }

/* ---------- §8 Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: 1ms !important; }
}
