/* ════════════════════════════════════════════════════════════════
   Ballot Forge — Main CSS
   Fonts: DM Serif Display (headings) + DM Sans (body/UI)
   ════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap');

/* ── Design Tokens ─────────────────────────────────────────────── */

:root {
  /* Brand accent (overridable per org via JS) */
  --accent:        #2563eb;
  --accent-light:  #eff6ff;
  --accent-dark:   #1d4ed8;
  --accent-text:   #ffffff;

  /* Surface palette — Light Mode */
  --bg:            #f8f7f4;
  --bg-alt:        #f1efe9;
  --surface:       #ffffff;
  --surface-2:     #f8f7f4;
  --surface-3:     #f1efe9;
  --border:        #e4e2db;
  --border-strong: #c8c5bc;
  --shadow-sm:     0 1px 3px rgba(15,14,10,0.08), 0 1px 2px rgba(15,14,10,0.06);
  --shadow:        0 4px 12px rgba(15,14,10,0.08), 0 2px 4px rgba(15,14,10,0.05);
  --shadow-lg:     0 16px 40px rgba(15,14,10,0.12), 0 4px 12px rgba(15,14,10,0.06);

  /* Text palette — Light Mode */
  --text:          #18160f;
  --text-1:        #18160f;  /* alias for --text */
  --text-2:        #49463c;
  --text-3:        #7a7669;
  --text-4:        #a8a49b;

  /* Status colors */
  --green:         #16a34a;
  --green-light:   #f0fdf4;
  --green-border:  #bbf7d0;
  --yellow:        #ca8a04;
  --yellow-light:  #fefce8;
  --yellow-border: #fef08a;
  --red:           #dc2626;
  --red-light:     #fef2f2;
  --red-border:    #fecaca;
  --danger:        #dc2626;  /* alias for --red */
  --danger-border: #fecaca;  /* alias for --red-border */
  --blue:          #2563eb;
  --blue-light:    #eff6ff;
  --blue-border:   #bfdbfe;
  --gray:          #64748b;
  --gray-light:    #f1f5f9;
  --gray-border:   #e2e8f0;

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* Border radius */
  --radius-sm:  6px;
  --radius:     10px;
  --radius-lg:  16px;
  --radius-xl:  24px;
  --radius-full: 9999px;

  /* Typography */
  --font-sans:    'DM Sans', system-ui, -apple-system, sans-serif;
  --font-display: 'DM Serif Display', Georgia, serif;
  --font-mono:    'Fira Code', 'Cascadia Code', ui-monospace, monospace;

  /* Transitions */
  --ease:         cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in:      cubic-bezier(0.4, 0, 1, 1);
  --ease-out:     cubic-bezier(0, 0, 0.2, 1);
  --duration-fast: 120ms;
  --duration:     200ms;
  --duration-slow: 350ms;

  /* Z-index layers */
  --z-dropdown: 100;
  --z-modal:    200;
  --z-toast:    300;
  --z-tooltip:  400;
}

/* ── Dark Mode ─────────────────────────────────────────────────── */

@media (prefers-color-scheme: dark) {
  :root {
    --bg:            #0d0d10;
    --bg-alt:        #121215;
    --surface:       #17171c;
    --surface-2:     #1d1d23;
    --surface-3:     #232329;
    --border:        #2a2a33;
    --border-strong: #3d3d4a;
    --shadow-sm:     0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
    --shadow:        0 4px 12px rgba(0,0,0,0.3), 0 2px 4px rgba(0,0,0,0.2);
    --shadow-lg:     0 16px 40px rgba(0,0,0,0.4), 0 4px 12px rgba(0,0,0,0.25);

    --text:          #f0efe8;
    --text-1:        #f0efe8;
    --text-2:        #b8b6af;
    --text-3:        #7d7b74;
    --text-4:        #4f4d48;

    --accent-light:  rgba(37,99,235,0.12);
    --green-light:   rgba(22,163,74,0.12);
    --green-border:  rgba(22,163,74,0.25);
    --yellow-light:  rgba(202,138,4,0.12);
    --yellow-border: rgba(202,138,4,0.25);
    --red-light:     rgba(220,38,38,0.12);
    --red-border:    rgba(220,38,38,0.25);
    --blue-light:    rgba(37,99,235,0.12);
    --blue-border:   rgba(37,99,235,0.25);
    --gray-light:    rgba(100,116,139,0.12);
    --gray-border:   rgba(100,116,139,0.25);
  }
}

/* ── Reset ─────────────────────────────────────────────────────── */

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

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

body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, video, svg {
  display: block;
  max-width: 100%;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }

/* ── Typography ────────────────────────────────────────────────── */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.2;
  color: var(--text);
  letter-spacing: -0.01em;
}

h1 { font-size: clamp(2rem, 5vw, 3.5rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2.25rem); }
h3 { font-size: clamp(1.2rem, 2vw, 1.5rem); }
h4 { font-size: 1.125rem; }
h5 { font-size: 1rem; font-family: var(--font-sans); font-weight: 600; }
h6 { font-size: 0.875rem; font-family: var(--font-sans); font-weight: 600; }

p { color: var(--text-2); }

strong { font-weight: 600; color: var(--text); }
em { font-style: italic; }

code, pre, kbd {
  font-family: var(--font-mono);
  font-size: 0.875em;
}

code {
  background: var(--surface-3);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  color: var(--accent);
}

/* ── Selection ─────────────────────────────────────────────────── */

::selection {
  background: var(--accent);
  color: #fff;
}

/* ── Scrollbar ─────────────────────────────────────────────────── */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-4); }

/* ── Focus ─────────────────────────────────────────────────────── */

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ── Utility Classes ───────────────────────────────────────────── */

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

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }

/* Accent color override (set via JS for org branding) */
[data-accent] { --accent: attr(data-accent); }
