/*
 * tokens.css - the single source of the app's look.
 *
 * Two layers:
 *   1. Primitives (--p-*): raw values. Change these to re-skin everything.
 *   2. Semantic tokens: what every page and component uses. Pages never use
 *      a hex value or a primitive directly - only these names.
 *
 * Current look: barebones, contemporary, black and white. Colour is kept for
 * meaning only (success, warning, danger). To add a brand colour later, point
 * --color-accent (and --color-primary if wanted) at a new primitive.
 */

:root {
  /* ---- 1. Primitives ------------------------------------------------- */
  --p-black:    #0a0a0a;
  --p-grey-900: #1f1f1f;
  --p-grey-700: #3d3d3d;
  --p-grey-500: #6b6b6b;
  --p-grey-300: #d4d4d4;
  --p-grey-200: #e5e5e5;
  --p-grey-100: #f2f2f2;
  --p-grey-50:  #fafafa;
  --p-white:    #ffffff;

  --p-green-700: #1f7a45;
  --p-green-50:  #edf7f0;
  --p-amber-700: #94600d;
  --p-amber-50:  #fdf6e7;
  --p-red-700:   #b42318;
  --p-red-50:    #fdeeec;

  /* ---- 2. Semantic: colour ------------------------------------------ */
  --color-bg:            var(--p-white);
  --color-surface:       var(--p-white);
  --color-surface-muted: var(--p-grey-50);
  --color-surface-sunken: var(--p-grey-100);
  --color-text:          var(--p-black);
  --color-text-muted:    var(--p-grey-500);
  --color-border:        var(--p-grey-200);
  --color-border-strong: var(--p-grey-300);

  --color-primary:        var(--p-black);      /* main buttons */
  --color-primary-hover:  var(--p-grey-700);
  --color-on-primary:     var(--p-white);
  --color-accent:         var(--p-black);      /* links, active states */
  --color-focus:          var(--p-black);

  --color-success:      var(--p-green-700);
  --color-success-soft: var(--p-green-50);
  --color-warning:      var(--p-amber-700);
  --color-warning-soft: var(--p-amber-50);
  --color-danger:       var(--p-red-700);
  --color-danger-soft:  var(--p-red-50);

  /* ---- Typography ---------------------------------------------------- */
  /* System fonts only: fast, and no third-party font requests (GDPR). */
  --font-body: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font-ipa:  "Charis SIL", "Doulos SIL", var(--font-body);

  --text-xs:   0.75rem;
  --text-sm:   0.875rem;
  --text-base: 1rem;
  --text-lg:   1.125rem;
  --text-xl:   1.5rem;
  --text-2xl:  2rem;
  --weight-regular: 400;
  --weight-medium:  500;
  --weight-bold:    650;
  --leading-tight:  1.2;
  --leading-normal: 1.5;
  --tracking-tight: -0.02em;
  --tracking-wide:  0.06em;

  /* ---- Space, shape, depth ------------------------------------------ */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-pill: 999px;

  --border-width: 1px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
  --focus-ring: 0 0 0 2px var(--color-bg), 0 0 0 4px var(--color-focus);

  /* ---- Layout -------------------------------------------------------- */
  --content-max: 1040px;
  --form-max: 380px;
  --control-height: 44px;

  /* ---- Motion -------------------------------------------------------- */
  --duration-fast: 120ms;
  --easing: cubic-bezier(0.2, 0, 0, 1);
}

/* ---- Base elements: plain HTML already looks right -------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { color-scheme: light; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: var(--leading-tight); letter-spacing: var(--tracking-tight); margin: 0; }
a { color: var(--color-accent); text-underline-offset: 3px; }
:focus-visible { outline: none; box-shadow: var(--focus-ring); }
[hidden] { display: none !important; }

/* ---- Shared components ------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: var(--control-height); padding: 0 var(--space-4);
  border: var(--border-width) solid var(--color-border-strong); border-radius: var(--radius-md);
  background: var(--color-surface); color: var(--color-text);
  font: inherit; font-size: var(--text-sm); font-weight: var(--weight-medium);
  text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background var(--duration-fast) var(--easing), border-color var(--duration-fast) var(--easing);
}
.btn:hover { background: var(--color-surface-muted); border-color: var(--color-text-muted); }
.btn-primary { background: var(--color-primary); border-color: var(--color-primary); color: var(--color-on-primary); }
.btn-primary:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); }
.btn-block { width: 100%; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.btn-sm { height: 34px; padding: 0 var(--space-3); }

.input {
  width: 100%; height: var(--control-height); padding: 0 var(--space-3);
  border: var(--border-width) solid var(--color-border-strong); border-radius: var(--radius-md);
  background: var(--color-surface); color: var(--color-text); font: inherit;
}
.input::placeholder { color: var(--color-text-muted); }
.input:focus { outline: none; border-color: var(--color-focus); box-shadow: var(--focus-ring); }

.label { display: block; font-size: var(--text-sm); font-weight: var(--weight-medium); margin-bottom: var(--space-1); }

.badge {
  display: inline-block; padding: 2px var(--space-2); border-radius: var(--radius-pill);
  background: var(--color-surface-sunken); color: var(--color-text);
  font-size: var(--text-xs); font-weight: var(--weight-medium); white-space: nowrap;
}

.wordmark { font-weight: 800; font-style: italic; letter-spacing: var(--tracking-tight); font-size: var(--text-xl); color: var(--color-text); text-decoration: none; }
.wordmark small { font-style: normal; font-weight: var(--weight-medium); font-size: var(--text-xs); letter-spacing: var(--tracking-wide); text-transform: uppercase; color: var(--color-text-muted); margin-left: var(--space-1); }

.notice { padding: var(--space-3); border-radius: var(--radius-md); font-size: var(--text-sm); }
.notice-error { background: var(--color-danger-soft); color: var(--color-danger); }
.notice-info { background: var(--color-surface-sunken); color: var(--color-text); }
.notice-success { background: var(--color-success-soft); color: var(--color-success); }
