/* base.css — FreeRadar Design Foundation */

/* ============================================
   TYPE SCALE (Fluid with clamp)
   ============================================ */
:root {
  --text-xs:   clamp(0.75rem,  0.7rem  + 0.25vw, 0.875rem);
  --text-sm:   clamp(0.875rem, 0.8rem  + 0.35vw, 1rem);
  --text-base: clamp(1rem,     0.9rem  + 0.5vw,  1.125rem);
  --text-lg:   clamp(1.125rem, 0.95rem + 0.85vw, 1.5rem);
  --text-xl:   clamp(1.5rem,   1rem    + 1.5vw,  2.25rem);
  --text-2xl:  clamp(2rem,     1.2rem  + 2.5vw,  3.5rem);
  --text-3xl:  clamp(2.5rem,   1rem    + 4vw,    5rem);
  --text-hero: clamp(3rem,     0.5rem  + 7vw,    8rem);
}

/* ============================================
   4px SPACING SYSTEM
   ============================================ */
:root {
  --space-1:  0.25rem;   /*  4px */
  --space-2:  0.5rem;    /*  8px */
  --space-3:  0.75rem;   /* 12px */
  --space-4:  1rem;      /* 16px */
  --space-5:  1.25rem;   /* 20px */
  --space-6:  1.5rem;    /* 24px */
  --space-8:  2rem;      /* 32px */
  --space-10: 2.5rem;    /* 40px */
  --space-12: 3rem;      /* 48px */
  --space-16: 4rem;      /* 64px */
  --space-20: 5rem;      /* 80px */
  --space-24: 6rem;      /* 96px */
  --space-32: 8rem;      /* 128px */
}

/* ============================================
   CUSTOM PALETTE: FREERADAR
   Clean white/light-gray chrome, cool blue accent.
   Dark map background for radar readability.
   ============================================ */

:root, [data-theme="light"] {
  /* --- Surfaces (Cool White) --- */
  --color-bg:               #f5f6f8;
  --color-surface:          #ffffff;
  --color-surface-2:        #fafbfc;
  --color-surface-offset:   #eef0f3;
  --color-surface-offset-2: #e5e8ec;
  --color-surface-dynamic:  #dde0e5;
  --color-divider:          #d2d6dc;
  --color-border:           #c5cad2;

  /* --- Text (Slate) --- */
  --color-text:           #1a1f2e;
  --color-text-muted:     #5c6478;
  --color-text-faint:     #9aa2b1;
  --color-text-inverse:   #f5f6f8;

  /* --- Primary Accent (Radar Blue) --- */
  --color-primary:          #0066CC;
  --color-primary-hover:    #0052a3;
  --color-primary-active:   #003d7a;
  --color-primary-highlight: #e0edf9;

  /* --- Semantic: Success (Green) --- */
  --color-success:          #1a8a3f;
  --color-success-hover:    #136e31;
  --color-success-active:   #0d5224;
  --color-success-highlight: #dcf0e3;

  /* --- Semantic: Warning (Amber) --- */
  --color-warning:          #c27800;
  --color-warning-hover:    #9e6200;
  --color-warning-active:   #7a4c00;
  --color-warning-highlight: #fef3dc;

  /* --- Semantic: Error (Red) --- */
  --color-error:            #cc3340;
  --color-error-hover:      #a32934;
  --color-error-active:     #7a1f27;
  --color-error-highlight:  #fde8ea;

  /* --- Accent: Storm Purple --- */
  --color-purple:           #6b3fa0;
  --color-purple-hover:     #563280;
  --color-purple-active:    #412560;
  --color-purple-highlight: #ede5f6;

  /* --- Map-Specific --- */
  --color-map-chrome:       rgba(255, 255, 255, 0.92);
  --color-map-chrome-border: rgba(0, 0, 0, 0.08);

  /* --- Radius --- */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;

  /* --- Transitions --- */
  --transition-interactive: 180ms cubic-bezier(0.16, 1, 0.3, 1);

  /* --- Shadows --- */
  --shadow-sm: 0 1px 2px oklch(0.25 0.01 250 / 0.06);
  --shadow-md: 0 4px 12px oklch(0.25 0.01 250 / 0.1);
  --shadow-lg: 0 12px 32px oklch(0.25 0.01 250 / 0.14);

  /* --- Content widths --- */
  --content-narrow: 640px;
  --content-default: 960px;
  --content-wide: 1200px;
  --content-full: 100%;

  /* --- Font families --- */
  --font-display: 'DM Sans', 'Helvetica Neue', sans-serif;
  --font-body: 'Inter', 'Helvetica Neue', sans-serif;
}

/* ============================================
   DARK MODE
   ============================================ */
[data-theme="dark"] {
  /* --- Surfaces (Slate Dark) --- */
  --color-bg:               #0f1117;
  --color-surface:          #161921;
  --color-surface-2:        #1c1f29;
  --color-surface-offset:   #13151d;
  --color-surface-offset-2: #1a1d26;
  --color-surface-dynamic:  #252832;
  --color-divider:          #282c38;
  --color-border:           #343845;

  /* --- Text (Light Slate) --- */
  --color-text:           #e0e2e8;
  --color-text-muted:     #8b90a0;
  --color-text-faint:     #565b6e;
  --color-text-inverse:   #1a1f2e;

  /* --- Primary Accent (Radar Blue — Dark) --- */
  --color-primary:          #4d9de6;
  --color-primary-hover:    #3388dd;
  --color-primary-active:   #2070c0;
  --color-primary-highlight: #1d2a3f;

  /* --- Semantic: Success (Green — Dark) --- */
  --color-success:          #4dbb6f;
  --color-success-hover:    #38a55a;
  --color-success-active:   #2a8a46;
  --color-success-highlight: #1a2e22;

  /* --- Semantic: Warning (Amber — Dark) --- */
  --color-warning:          #e8a832;
  --color-warning-hover:    #d49520;
  --color-warning-active:   #b87d10;
  --color-warning-highlight: #2e2618;

  /* --- Semantic: Error (Red — Dark) --- */
  --color-error:            #e8606e;
  --color-error-hover:      #d44a58;
  --color-error-active:     #b83644;
  --color-error-highlight:  #2e1a1d;

  /* --- Accent: Storm Purple — Dark --- */
  --color-purple:           #a070d4;
  --color-purple-hover:     #8c5cc0;
  --color-purple-active:    #7848ac;
  --color-purple-highlight: #251e32;

  /* --- Map-Specific (Dark) --- */
  --color-map-chrome:       rgba(22, 25, 33, 0.92);
  --color-map-chrome-border: rgba(255, 255, 255, 0.08);

  /* --- Shadows (softened for dark surfaces) --- */
  --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.2);
  --shadow-md: 0 4px 12px oklch(0 0 0 / 0.3);
  --shadow-lg: 0 12px 32px oklch(0 0 0 / 0.4);
}

/* System preference fallback (when no data-theme is set) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg:               #0f1117;
    --color-surface:          #161921;
    --color-surface-2:        #1c1f29;
    --color-surface-offset:   #13151d;
    --color-surface-offset-2: #1a1d26;
    --color-surface-dynamic:  #252832;
    --color-divider:          #282c38;
    --color-border:           #343845;
    --color-text:           #e0e2e8;
    --color-text-muted:     #8b90a0;
    --color-text-faint:     #565b6e;
    --color-text-inverse:   #1a1f2e;
    --color-primary:          #4d9de6;
    --color-primary-hover:    #3388dd;
    --color-primary-active:   #2070c0;
    --color-primary-highlight: #1d2a3f;
    --color-success:          #4dbb6f;
    --color-success-hover:    #38a55a;
    --color-success-active:   #2a8a46;
    --color-success-highlight: #1a2e22;
    --color-warning:          #e8a832;
    --color-warning-hover:    #d49520;
    --color-warning-active:   #b87d10;
    --color-warning-highlight: #2e2618;
    --color-error:            #e8606e;
    --color-error-hover:      #d44a58;
    --color-error-active:     #b83644;
    --color-error-highlight:  #2e1a1d;
    --color-purple:           #a070d4;
    --color-purple-hover:     #8c5cc0;
    --color-purple-active:    #7848ac;
    --color-purple-highlight: #251e32;
    --color-map-chrome:       rgba(22, 25, 33, 0.92);
    --color-map-chrome-border: rgba(255, 255, 255, 0.08);
    --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.2);
    --shadow-md: 0 4px 12px oklch(0 0 0 / 0.3);
    --shadow-lg: 0 12px 32px oklch(0 0 0 / 0.4);
  }
}


/* ============================================
   BOX MODEL & BASE RESETS
   ============================================ */

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

html {
  -moz-text-size-adjust: none;
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
  hanging-punctuation: first last;
  scroll-padding-top: var(--space-16);
}

body {
  min-height: 100dvh;
  line-height: 1.6;
  font-family: var(--font-body, sans-serif);
  font-size: var(--text-base);
  color: var(--color-text);
  background-color: var(--color-bg);
}

img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
  height: auto;
}

ul[role="list"], ol[role="list"] {
  list-style: none;
}

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

h1, h2, h3, h4, h5, h6 {
  text-wrap: balance;
  line-height: 1.15;
}

p, li, figcaption {
  text-wrap: pretty;
  max-width: 72ch;
}

::selection {
  background: oklch(from var(--color-primary) l c h / 0.25);
  color: var(--color-text);
}

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

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

button {
  cursor: pointer;
  background: none;
  border: none;
}

table {
  border-collapse: collapse;
  width: 100%;
}

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