/* static/css/base.css — Design tokens and global reset */

/* ─── Design Tokens ─────────────────────────────────────────────────────── */
:root {
  /* Brand */
  --brand-primary:    #123b4a;
  --brand-primary-dk: #092a35;
  --brand-primary-lt: #1b5966;
  --brand-accent:     #d89b2b;
  --brand-accent-lt:  #f2bd58;
  --brand-light:      #e7f2f1;

  /* Semantic */
  --color-success:    #166534;
  --color-success-bg: #f0fdf4;
  --color-success-bd: #bbf7d0;
  --color-warning:    #92400e;
  --color-warning-bg: #fffbeb;
  --color-warning-bd: #fde68a;
  --color-danger:     #991b1b;
  --color-danger-bg:  #fef2f2;
  --color-danger-bd:  #fecaca;
  --color-info:       #1e40af;
  --color-info-bg:    #eff6ff;
  --color-info-bd:    #bfdbfe;

  /* Neutrals */
  --color-page-bg:      #f4f3ef;
  --color-surface:      #ffffff;
  --color-surface-2:    #f8f8f5;
  --color-border:       #c9d2d1;
  --color-border-light: #e2e6e3;
  --color-text:         #102a33;
  --color-text-2:       #38515a;
  --color-text-muted:   #687c82;
  --color-text-disabled:#94a3b8;
  --color-link:         var(--brand-primary);

  /* Typography */
  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;

  --text-2xs:  0.6875rem;
  --text-xs:   0.75rem;
  --text-sm:   0.875rem;
  --text-base: 1rem;
  --text-lg:   1.125rem;
  --text-xl:   1.25rem;
  --text-2xl:  1.5rem;
  --text-3xl:  1.875rem;

  --font-normal:  400;
  --font-medium:  500;
  --font-semibold:600;
  --font-bold:    700;
  --leading-tight:  1.25;
  --leading-snug:   1.375;
  --leading-normal: 1.5;

  /* Spacing */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* Layout */
  --sidebar-width:    264px;
  --topbar-height:    68px;
  --content-max-width:1400px;

  /* Shape */
  --radius-sm:   0.375rem;
  --radius-md:   0.625rem;
  --radius-lg:   0.875rem;
  --radius-xl:   1.125rem;
  --radius-full: 9999px;

  /* Shadow */
  --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.08), 0 1px 2px -1px rgb(0 0 0 / 0.06);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.06);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.05);

  /* Motion */
  --transition-fast:   150ms ease;
  --transition-normal: 200ms ease;
  --transition-slow:   300ms ease;

  /* Z-index */
  --z-base:    0;
  --z-sticky:  100;
  --z-sidebar: 200;
  --z-topbar:  300;
  --z-modal:   400;
  --z-toast:   500;
}

/* ─── Modern Reset ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  color: var(--color-text);
  background: var(--color-page-bg);
  -webkit-font-smoothing: antialiased;
}

.skip-link {
  position: fixed;
  top: var(--space-2);
  left: var(--space-2);
  z-index: var(--z-toast);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  background: var(--brand-primary);
  color: #ffffff;
  transform: translateY(-150%);
  transition: transform var(--transition-fast);
}

.skip-link:focus { transform: translateY(0); color: #ffffff; }

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-weight: var(--font-semibold);
  line-height: var(--leading-tight);
  color: var(--color-text);
}

h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }
h4 { font-size: var(--text-base); }

p { margin: 0 0 var(--space-4); }
p:last-child { margin-bottom: 0; }

a {
  color: var(--color-link);
  text-decoration: none;
}
a:hover { text-decoration: underline; }
a:focus-visible {
  outline: 2px solid var(--brand-accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

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

ul, ol { margin: 0; padding: 0; list-style: none; }

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

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

/* ─── HTMX Loading Indicator ─────────────────────────────────────────────── */
.htmx-indicator { opacity: 0; transition: opacity var(--transition-fast); }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { opacity: 1; }

/* ─── Spinner ────────────────────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid var(--color-border);
  border-top-color: var(--brand-primary);
  border-radius: 50%;
  animation: spin 600ms linear infinite;
  vertical-align: middle;
}
.spinner--sm { width: 12px; height: 12px; }
.spinner--lg { width: 24px; height: 24px; border-width: 3px; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Screen reader only ─────────────────────────────────────────────────── */
.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;
}
