/* ============================================================
   KommunalDesign Pro — Design Tokens
   Modular & WCAG 2.2 AA / AAA compliant
   ============================================================ */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/assets/fonts/InterVariable.woff2")
    format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
  src: url("/assets/fonts/InterVariable-Italic.woff2")
    format("woff2");
}

:root {
  /* ===== COLOR PRESETS — primary brand color slot ===== */
  /* Default: deep authoritative blue */
  --c-primary-50:  #EEF2F8;
  --c-primary-100: #D7E0EE;
  --c-primary-200: #A9BBD5;
  --c-primary-300: #7B95BC;
  --c-primary-400: #4D70A3;
  --c-primary-500: #2B5189;
  --c-primary-600: #1B3A6B;   /* base */
  --c-primary-700: #15305A;
  --c-primary-800: #0F2444;
  --c-primary-900: #0A192F;

  /* Accent — warm amber, for CTAs */
  --c-accent-50:  #FEF6EC;
  --c-accent-100: #FCE6C7;
  --c-accent-300: #F4B870;
  --c-accent-500: #D97706;   /* base */
  --c-accent-600: #B45309;
  --c-accent-700: #92400E;

  /* Neutrals */
  --c-white: #FFFFFF;
  --c-bg:        #FFFFFF;
  --c-bg-muted:  #F8FAFC;
  --c-bg-sunken: #F1F5F9;
  --c-border:    #E2E8F0;
  --c-border-strong: #CBD5E1;
  --c-text-muted:    #64748B;
  --c-text-soft:     #475569;
  --c-text:          #1E293B;
  --c-text-strong:   #0F172A;

  /* Status (all AA on white at 16px+) */
  --c-success: #15803D;
  --c-success-bg: #DCFCE7;
  --c-warning: #A16207;
  --c-warning-bg: #FEF9C3;
  --c-error:   #B91C1C;
  --c-error-bg: #FEE2E2;
  --c-info:    #1D4ED8;
  --c-info-bg: #DBEAFE;

  /* Focus ring — high contrast, never just color */
  --focus-ring: 0 0 0 3px var(--c-bg), 0 0 0 6px var(--c-accent-500);

  /* Type */
  --font-sans: "Inter", "Source Sans 3", -apple-system, BlinkMacSystemFont,
    "Segoe UI", Roboto, sans-serif;
  --fs-base: 18px;          /* body min */
  --fs-sm:   16px;
  --fs-xs:   14px;
  --lh-base: 1.6;
  --lh-tight: 1.2;

  /* Type scale (modular ~1.2) */
  --fs-h1: clamp(2.25rem, 1.6rem + 2.6vw, 3.5rem);
  --fs-h2: clamp(1.75rem, 1.4rem + 1.4vw, 2.5rem);
  --fs-h3: clamp(1.375rem, 1.2rem + 0.6vw, 1.75rem);
  --fs-h4: 1.25rem;
  --fs-lead: clamp(1.1rem, 1rem + 0.4vw, 1.3rem);

  /* Spacing */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;
  --sp-8: 64px;
  --sp-9: 96px;

  /* Radii */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --r-xl: 24px;
  --r-pill: 999px;

  /* Shadows — subtle, soft */
  --sh-1: 0 1px 2px rgba(15, 23, 42, 0.05);
  --sh-2: 0 4px 14px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --sh-3: 0 12px 32px rgba(15, 23, 42, 0.08), 0 2px 6px rgba(15, 23, 42, 0.04);
  --sh-glass: 0 1px 0 rgba(255,255,255,0.6) inset, 0 12px 40px rgba(15,23,42,0.08);

  /* Layout */
  --content-max: 1280px;
  --content-pad: clamp(20px, 4vw, 56px);
  --hit: 44px;

  /* Motion */
  --t-fast: 120ms;
  --t-med: 220ms;
  --t-slow: 320ms;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ===== Color preset variants ===== */
[data-preset="green"] {
  --c-primary-50:  #ECF5EF;
  --c-primary-100: #CFE5D6;
  --c-primary-200: #9DCBAB;
  --c-primary-300: #6BB180;
  --c-primary-400: #3F8F5C;
  --c-primary-500: #2E7547;
  --c-primary-600: #1F5A36;
  --c-primary-700: #184A2C;
  --c-primary-800: #103620;
  --c-primary-900: #0A2516;
}
[data-preset="bordeaux"] {
  --c-primary-50:  #F8ECEE;
  --c-primary-100: #ECCCD2;
  --c-primary-200: #D89AA4;
  --c-primary-300: #C26876;
  --c-primary-400: #A23E50;
  --c-primary-500: #862838;
  --c-primary-600: #6B1F2C;
  --c-primary-700: #561822;
  --c-primary-800: #3E1118;
  --c-primary-900: #2A0B10;
}

/* ===== Dark mode ===== */
[data-mode="dark"] {
  --c-bg:        #0F1729;
  --c-bg-muted:  #15203A;
  --c-bg-sunken: #1B2A48;
  --c-border:    #2A3A5C;
  --c-border-strong: #3D5079;
  --c-text-muted:    #94A3B8;
  --c-text-soft:     #CBD5E1;
  --c-text:          #E2E8F0;
  --c-text-strong:   #F8FAFC;

  --c-primary-50:  #15203A;
  --c-primary-100: #1B2A48;
  --c-primary-600: #6B8FCB;
  --c-primary-700: #8AA8DD;

  --c-accent-500: #F4A554;
  --c-accent-600: #F4B870;

  --c-success-bg: #052E1A;
  --c-warning-bg: #2A1F08;
  --c-error-bg:   #2A0B0B;
  --c-info-bg:    #0B1B3A;

  --sh-1: 0 1px 2px rgba(0,0,0,0.4);
  --sh-2: 0 4px 14px rgba(0,0,0,0.35), 0 1px 2px rgba(0,0,0,0.25);
  --sh-3: 0 12px 32px rgba(0,0,0,0.45), 0 2px 6px rgba(0,0,0,0.25);
  --focus-ring: 0 0 0 3px var(--c-bg), 0 0 0 6px var(--c-accent-500);
}

/* ===== High-contrast (AAA) toggle ===== */
[data-contrast="high"] {
  --c-text:        #000000;
  --c-text-strong: #000000;
  --c-text-muted:  #1E293B;
  --c-border:      #000000;
  --c-border-strong: #000000;
  --c-primary-600: #0A192F;
  --c-primary-700: #000000;
  --c-accent-500:  #8C4A00;
  --c-accent-600:  #6B3700;
  --c-bg:          #FFFFFF;
  --c-bg-muted:    #FFFFFF;
  --c-bg-sunken:   #F1F5F9;
}
[data-mode="dark"][data-contrast="high"] {
  --c-text:        #FFFFFF;
  --c-text-strong: #FFFFFF;
  --c-text-muted:  #E2E8F0;
  --c-border:      #FFFFFF;
  --c-border-strong: #FFFFFF;
  --c-bg:          #000000;
  --c-bg-muted:    #0A0A0A;
  --c-bg-sunken:   #141414;
}

/* ===== Font-size accessibility scale ===== */
[data-fs="lg"]  { --fs-base: 20px; }
[data-fs="xl"]  { --fs-base: 22px; }
[data-fs="xxl"] { --fs-base: 24px; }

/* ============================================================
   Base
   ============================================================ */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; display: block; }
button { font-family: inherit; }

a {
  color: var(--c-primary-600);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1.5px;
}
a:hover { color: var(--c-primary-700); }

/* Universal focus ring — never relying on color alone */
:focus { outline: none; }
:focus-visible {
  outline: 3px solid var(--c-accent-500);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Reduced motion respect */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* Skip link */
.skip-link {
  position: absolute;
  left: 8px;
  top: -100px;
  background: var(--c-primary-700);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--r-md);
  font-weight: 600;
  z-index: 9999;
  transition: top var(--t-fast) var(--ease);
}
.skip-link:focus {
  top: 8px;
  color: #fff;
  text-decoration: none;
}

/* ============================================================
   Reusable utilities
   ============================================================ */
.kd-container {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--content-pad);
}

.kd-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--r-pill);
  font-size: 0.78em;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: var(--c-primary-50);
  color: var(--c-primary-700);
  border: 1px solid var(--c-primary-100);
}
.kd-pill--accent {
  background: var(--c-accent-50);
  color: var(--c-accent-700);
  border-color: var(--c-accent-100);
}

.kd-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--hit);
  padding: 10px 22px;
  border-radius: var(--r-md);
  border: 1.5px solid transparent;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease);
  text-decoration: none;
}
.kd-btn--primary {
  background: var(--c-accent-500);
  color: #fff;
  box-shadow: var(--sh-1);
}
.kd-btn--primary:hover {
  background: var(--c-accent-600);
  color: #fff;
  text-decoration: none;
}
.kd-btn--ghost {
  background: transparent;
  color: var(--c-primary-700);
  border-color: var(--c-border-strong);
}
.kd-btn--ghost:hover {
  background: var(--c-primary-50);
  color: var(--c-primary-700);
  text-decoration: none;
}
.kd-btn--outline {
  background: var(--c-bg);
  color: var(--c-text);
  border-color: var(--c-border-strong);
}

.kd-card {
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  transition: box-shadow var(--t-med) var(--ease),
              transform var(--t-med) var(--ease),
              border-color var(--t-med) var(--ease);
}
.kd-card:hover {
  box-shadow: var(--sh-2);
  border-color: var(--c-border-strong);
}

.kd-headline-2c {
  color: var(--c-text-strong);
}
.kd-headline-2c em {
  font-style: normal;
  color: var(--c-accent-600);
}

/* Visually hidden for ARIA helpers */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  border: 0;
}

/* Dotted leader for placeholder images */
.kd-placeholder {
  position: relative;
  background: var(--c-bg-sunken);
  border: 1.5px dashed var(--c-border-strong);
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-text-muted);
  font-size: 0.85em;
  font-weight: 500;
  letter-spacing: 0.02em;
  overflow: hidden;
}
.kd-placeholder svg { width: 100%; height: 100%; display: block; }
