/* ============================================================
   Chalkspace design system
   Shared tokens + base rules for all pages.
   Pages should link this file before any page-scoped <style>.
   ============================================================ */

:root {
  /* Brand */
  --primary:       #a84f2f;
  --primary-hover: #c4613a;
  --primary-dark:  #a84f2f; /* legacy alias — use --primary */
  --primary-dim:   rgba(168,79,47,0.10);

  /* Semantic */
  --danger:      #c0392b;
  --danger-dim:  rgba(192,57,43,0.09);
  --success:     #2d7a3a;
  --success-dim: rgba(45,125,58,0.09);
  --warning:     #b07020;
  --warning-dim: rgba(176,112,32,0.12);

  /* Neutrals (light) */
  --bg:       #faf5f0;
  --bg2:      #f4ede5;
  --card:     #ffffff;
  --surface:  #f4ede5;
  --surface2: #f9f3ee;
  --border:   #e5d9d0;
  --border2:  #d8c9bc;
  --text:     #271810;
  --muted:    #7a5a4a;
  --muted2:   #b09080;

  /* Type families */
  --display: 'Bricolage Grotesque', sans-serif;
  --body:    'DM Sans', sans-serif;
  --accent:  'Caveat', cursive;

  /* Avatar palette (vibrant-warm 10) */
  --av-1:  #c2410c;
  --av-2:  #b45309;
  --av-3:  #a16207;
  --av-4:  #4d7c0f;
  --av-5:  #15803d;
  --av-6:  #0f766e;
  --av-7:  #be185d;
  --av-8:  #a21caf;
  --av-9:  #6d28d9;
  --av-10: #b91c1c;

  /* Spacing (4/8 scale) */
  --sp-1:  4px;
  --sp-2:  8px;
  --sp-3:  12px;
  --sp-4:  16px;
  --sp-5:  20px;
  --sp-6:  24px;
  --sp-8:  32px;
  --sp-10: 40px;
  --sp-13: 52px;
  --sp-20: 80px;

  /* Radius */
  --r-sm:  4px;
  --r-md:  6px;
  --r-lg:  8px;
  --r-xl:  10px;
  --r-2xl: 16px;

  /* Shadow */
  --sh-1: 0 1px 2px rgba(39,24,16,0.04);
  --sh-2: 0 4px 12px rgba(39,24,16,0.08);
  --sh-3: 0 12px 32px rgba(39,24,16,0.12);
  --sh-4: 0 32px 80px rgba(39,24,16,0.20);

  /* Motion */
  --m-fast: 150ms;
  --m-base: 200ms;
  --m-slow: 300ms;
  --ease:   cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Dark mode — opt-in via `body.dark` */
body.dark {
  --primary:       #e8784e;
  --primary-hover: #f0926b;
  --primary-dark:  #e8784e; /* legacy alias */
  --primary-dim:   rgba(232,120,78,0.15);

  --danger:      #f06060;
  --danger-dim:  rgba(240,96,96,0.12);
  --success:     #5abf6a;
  --success-dim: rgba(90,191,106,0.12);
  --warning:     #e0a84a;
  --warning-dim: rgba(224,168,74,0.12);

  --bg:       #231a12;
  --bg2:      #2a1f16;
  --card:     #2e2018;
  --surface:  #3c2a1e;
  --surface2: #4a3224;
  --border:   #5c4030;
  --border2:  #7c5540;
  --text:     #f5e8e0;
  --muted:    #c8a890;
  --muted2:   #a07858;
}

/* Global focus ring for every interactive element */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
  box-shadow: 0 0 0 5px var(--primary-dim);
}

/* Handwritten accent for hero emphasis / empty-state titles.
   Usage is deliberately narrow — see design-system/PLAN.md. */
.hero-accent {
  font-family: var(--accent);
  font-weight: 700;
  font-style: normal;
}

/* ── Component utilities ─────────────────────────────────────
   Shared base styles. Page-scoped overrides (.btn-primary etc.)
   layer on top of these. See design-system/MASTER.md. */

/* Button reset — every button variant should start here. */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--sp-2);
  padding: 0 var(--sp-4);
  height: 36px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: transparent;
  font-family: var(--body);
  font-size: 0.875rem; font-weight: 600;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--m-fast) var(--ease),
              color var(--m-fast) var(--ease),
              border-color var(--m-fast) var(--ease),
              transform var(--m-fast) var(--ease);
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn--primary {
  background: var(--primary); color: #fff;
  border-color: var(--primary);
}
.btn--primary:hover:not(:disabled) {
  background: var(--primary-hover); border-color: var(--primary-hover);
  transform: translateY(-1px);
}

.btn--ghost {
  background: transparent; color: var(--muted);
  border-color: var(--border2);
}
.btn--ghost:hover:not(:disabled) {
  color: var(--text); border-color: var(--primary);
}

.btn--danger {
  background: var(--danger); color: #fff; border-color: var(--danger);
}
.btn--danger:hover:not(:disabled) {
  filter: brightness(0.92); transform: translateY(-1px);
}

.btn--sm { height: 28px; padding: 0 var(--sp-3); font-size: 0.78rem; }
.btn--lg { height: 44px; padding: 0 var(--sp-6); font-size: 1rem; }
.btn--block { display: flex; width: 100%; }

/* Icon-only button — keep ≥32×32 for touch comfort. */
.btn--icon {
  width: 32px; height: 32px; padding: 0;
}

/* Form input baseline — 36px height for parity with .btn. */
.input {
  display: block; width: 100%;
  height: 36px;
  padding: 0 var(--sp-3);
  background: var(--card);
  border: 1px solid var(--border2);
  border-radius: var(--r-md);
  color: var(--text);
  font-family: var(--body);
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--m-fast) var(--ease),
              box-shadow var(--m-fast) var(--ease);
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-dim); }
.input::placeholder { color: var(--muted2); }

/* Modal size scale. Apply .modal--sm / --md / --lg to .modal. */
.modal--sm { max-width: 380px; }
.modal--md { max-width: 440px; }
.modal--lg { max-width: 560px; }
