/* Copyright (c) 2026 LandmarkLouie. Complete design token system — Phase 1 unified. */

:root {
  /* ────────────────────────────────────────────────────────────── */
  /* CORE PALETTE (no aliases, canonical values only)               */
  /* ────────────────────────────────────────────────────────────── */

  /* Neutrals: dark backgrounds */
  --color-dark-1: #1a2234;    /* primary dark nav/header bg */
  --color-dark-2: #111827;    /* deepest dark, modals */
  --color-dark-3: #1e293b;    /* tertiary dark variant */

  /* Neutrals: light backgrounds */
  --color-surface: #ffffff;   /* main card/content bg */
  --color-surface-hover: #f8f9fb;  /* card hover, panel bg */
  --color-surface-tertiary: #f3f4f6;  /* subtle surface */

  /* ────────────────────────────────────────────────────────────── */
  /* GOLD SYSTEM (brand identity + accessible variants)             */
  /* ────────────────────────────────────────────────────────────── */

  --color-gold-bright: #c9a84c;      /* brand-only, dark bg fills only (buttons, badges on dark) */
  --color-gold-standard: #8a6520;    /* WCAG AA 4.8:1 on white, primary for text/labels */
  --color-gold-light: #e8d5a3;       /* subtle highlight, borders, very light fills */
  --color-gold-bg: #fdf8ee;          /* page/card accent bg */
  --color-gold-border: rgba(201, 168, 76, 0.25);  /* border rgba from bright */

  /* Semantic aliases for clarity (text vs fill context) */
  --color-accent-bright: var(--color-gold-bright);    /* fill/button on dark */
  --color-accent-standard: var(--color-gold-standard);  /* text, label, border dark */
  --color-accent-light: var(--color-gold-light);      /* decorative, faint border */

  /* ────────────────────────────────────────────────────────────── */
  /* TEXT COLORS (WCAG AA verified on respective backgrounds)       */
  /* ────────────────────────────────────────────────────────────── */

  --color-text-primary: #1a1a2e;     /* default body text on light (5.8:1) */
  --color-text-secondary: #3f4d63;   /* secondary on light (5.2:1) */
  --color-text-muted: #5a6a7f;       /* tertiary, helper text on light (3.8:1) */
  --color-text-on-dark: #f1f0ec;     /* text on dark backgrounds (12:1) */
  --color-text-muted-dark: #a3b1c1;  /* secondary on dark (5.8:1) */

  /* ────────────────────────────────────────────────────────────── */
  /* SEMANTIC COLORS (status, feedback, validation)                 */
  /* ────────────────────────────────────────────────────────────── */

  --color-success: #22c55e;
  --color-success-bg: #f0fdf4;
  --color-success-border: #bbf7d0;

  --color-warning: #f59e0b;
  --color-warning-bg: #fffbeb;
  --color-warning-border: #fce7b6;

  --color-danger: #ef4444;
  --color-danger-bg: #fef2f2;
  --color-danger-border: #fecaca;

  --color-info: #3b82f6;
  --color-info-bg: #eff6ff;
  --color-info-border: #bfdbfe;

  /* ────────────────────────────────────────────────────────────── */
  /* TYPOGRAPHY SCALE (intentional, 6 deliberate steps)              */
  /* ────────────────────────────────────────────────────────────── */

  --text-xs: 11px;       /* micro label, footnote */
  --text-sm: 12px;       /* small text, badge */
  --text-base: 14px;     /* body, default */
  --text-md: 16px;       /* slightly larger body, small heading */
  --text-lg: 18px;       /* heading-like */
  --text-xl: 20px;       /* prominent heading */
  --text-2xl: 24px;      /* section heading */
  --text-3xl: 28px;      /* page title, hero */

  /* Line heights (unitless, multiply text size) */
  --line-height-tight: 1.2;    /* headings, labels */
  --line-height-snug: 1.4;     /* body text, default */
  --line-height-relaxed: 1.6;  /* long-form reading */

  /* Letter spacing */
  --letter-spacing-tight: -0.01em;   /* headings, tight UI */
  --letter-spacing-normal: 0;        /* default */
  --letter-spacing-wide: 0.05em;     /* labels, SMALL CAPS */
  --letter-spacing-wider: 0.1em;     /* accent pills, spaced */

  /* Font families (two-family system) */
  --font-sans: 'Plus Jakarta Sans', -apple-system, system-ui, sans-serif;
  --font-serif: 'Georgia', 'Times New Roman', serif;

  /* Font weights (use deliberately) */
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  --font-weight-extrabold: 800;

  /* ────────────────────────────────────────────────────────────── */
  /* SPACING SCALE (4px base, 12 levels)                             */
  /* ────────────────────────────────────────────────────────────── */

  --space-1: 4px;       /* micro, icon spacing, tight gutters */
  --space-2: 8px;       /* small, input padding, tight stacks */
  --space-3: 12px;      /* default small spacing */
  --space-4: 16px;      /* standard spacing, padding */
  --space-5: 20px;      /* moderate spacing, vertical rhythm */
  --space-6: 24px;      /* section spacing */
  --space-7: 28px;      /* larger section spacing */
  --space-8: 32px;      /* major spacing, modal padding */
  --space-9: 40px;      /* large gap, section separator */
  --space-10: 48px;     /* very large gap */
  --space-11: 56px;     /* huge spacing */
  --space-12: 64px;     /* hero spacing */

  /* ────────────────────────────────────────────────────────────── */
  /* BORDER RADIUS SCALE (intentional hierarchy)                    */
  /* ────────────────────────────────────────────────────────────── */

  --radius-xs: 3px;      /* small badge, tight UI */
  --radius-sm: 6px;      /* input, small button */
  --radius-md: 10px;     /* standard button, card */
  --radius-lg: 14px;     /* modal, large component */
  --radius-xl: 20px;     /* hero, prominent shape */
  --radius-full: 9999px; /* pills, full circular */

  /* ────────────────────────────────────────────────────────────── */
  /* SHADOW SCALE (3 elevations, consistent depth)                   */
  /* ────────────────────────────────────────────────────────────── */

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);

  /* Blur backdrop for overlays */
  --backdrop-blur: blur(8px);

  /* ────────────────────────────────────────────────────────────── */
  /* ELEVATION / Z-INDEX SCALE (stacking context)                    */
  /* ────────────────────────────────────────────────────────────── */

  --z-hide: -1;
  --z-base: 0;
  --z-dropdown: 10;
  --z-sticky: 20;
  --z-fixed: 30;
  --z-modal-bg: 300;
  --z-modal: 301;
  --z-toast: 400;
  --z-tooltip: 500;

  /* ────────────────────────────────────────────────────────────── */
  /* TRANSITION / ANIMATION TIMING                                   */
  /* ────────────────────────────────────────────────────────────── */

  --duration-fast: 150ms;
  --duration-base: 200ms;
  --duration-slow: 300ms;
  --easing-in: cubic-bezier(0.4, 0, 1, 1);
  --easing-out: cubic-bezier(0, 0, 0.2, 1);
  --easing-in-out: cubic-bezier(0.4, 0, 0.2, 1);

  /* ────────────────────────────────────────────────────────────── */
  /* LAYOUT / BREAKPOINTS (mobile-first)                             */
  /* ────────────────────────────────────────────────────────────── */

  --breakpoint-sm: 640px;
  --breakpoint-md: 768px;
  --breakpoint-lg: 1024px;
  --breakpoint-xl: 1280px;
  --breakpoint-2xl: 1536px;

  --container-sm: 640px;
  --container-md: 768px;
  --container-lg: 1024px;
  --container-xl: 1280px;

  /* ────────────────────────────────────────────────────────────── */
  /* COMPONENT PRESETS (reusable patterns)                           */
  /* ────────────────────────────────────────────────────────────── */

  /* Default transitions for interactive elements */
  --transition-base: background var(--duration-base) var(--easing-out), color var(--duration-base) var(--easing-out);
  --transition-elevation: box-shadow var(--duration-base) var(--easing-out);
}

/* ═════════════════════════════════════════════════════════════════ */
/* COMPONENT PRIMITIVES — Use these as base classes                 */
/* ═════════════════════════════════════════════════════════════════ */

/* ── Button system: three styles, consistent sizing ── */
.btn-primary,
.louie-btn-primary {
  padding: var(--space-2) var(--space-5);
  background: var(--color-accent-bright);
  color: var(--color-dark-2);
  border: none;
  border-radius: var(--radius-md);
  font-weight: var(--font-weight-semibold);
  font-size: var(--text-base);
  font-family: var(--font-sans);
  cursor: pointer;
  transition: var(--transition-base), var(--transition-elevation);
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover,
.louie-btn-primary:hover {
  background: var(--color-accent-standard);
  box-shadow: var(--shadow-md);
}
.btn-primary:focus-visible,
.louie-btn-primary:focus-visible {
  outline: 3px solid var(--color-accent-standard);
  outline-offset: 2px;
}

.btn-secondary,
.louie-btn-secondary {
  padding: var(--space-2) var(--space-5);
  background: transparent;
  color: var(--color-accent-standard);
  border: 1.5px solid var(--color-accent-standard);
  border-radius: var(--radius-md);
  font-weight: var(--font-weight-semibold);
  font-size: var(--text-base);
  font-family: var(--font-sans);
  cursor: pointer;
  transition: var(--transition-base);
}
.btn-secondary:hover,
.louie-btn-secondary:hover {
  background: var(--color-gold-bg);
}

.btn-ghost,
.louie-btn-ghost {
  padding: var(--space-2) var(--space-5);
  background: transparent;
  color: var(--color-text-secondary);
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  font-weight: var(--font-weight-medium);
  font-size: var(--text-base);
  font-family: var(--font-sans);
  cursor: pointer;
  transition: var(--transition-base);
}
.btn-ghost:hover,
.louie-btn-ghost:hover {
  background: var(--color-surface-hover);
}

/* ── Badge system: consistent sizing & spacing ── */
.badge {
  display: inline-block;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--font-weight-bold);
  letter-spacing: var(--letter-spacing-wide);
  text-transform: uppercase;
  font-family: var(--font-sans);
}

.badge-gold {
  background: var(--color-accent-bright);
  color: var(--color-dark-2);
}

.badge-dark {
  background: var(--color-dark-2);
  color: var(--color-accent-bright);
}

.badge-success {
  background: var(--color-success-bg);
  color: var(--color-success);
}

.badge-warning {
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

.badge-danger {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}

.badge-info {
  background: var(--color-info-bg);
  color: var(--color-info);
}

/* ── Card primitive — surfaces with intentional elevation ── */
.card {
  background: var(--color-surface);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: var(--radius-md);
  padding: var(--space-8);
  box-shadow: var(--shadow-sm);
  transition: var(--transition-elevation);
}
.card:hover {
  background: var(--color-surface-hover);
  box-shadow: var(--shadow-md);
}

/* ── Form elements — consistent sizing ── */
input,
textarea,
select {
  padding: var(--space-2);
  border: 1px solid #dde1eb;
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  font-family: var(--font-sans);
  line-height: var(--line-height-snug);
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--color-accent-standard);
  outline-offset: 2px;
}

label {
  display: block;
  font-size: var(--text-xs);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wide);
  margin-bottom: var(--space-2);
}

/* ── Modal system — full overlay with intentional z-index ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: var(--backdrop-blur);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal-bg);
  padding: var(--space-8);
}
.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  max-width: 780px;
  width: 100%;
  max-height: 85vh;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: var(--z-modal);
}

.modal-header {
  background: var(--color-dark-1);
  color: var(--color-text-on-dark);
  padding: var(--space-4);
  border-left: 4px solid var(--color-accent-bright);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-4);
}

.modal-header-title {
  font-size: var(--text-lg);
  font-weight: var(--font-weight-semibold);
  font-family: var(--font-sans);
}

.modal-header-subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted-dark);
  margin-top: var(--space-1);
}

.modal-header-close {
  background: none;
  border: none;
  color: var(--color-accent-bright);
  font-size: var(--text-2xl);
  cursor: pointer;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
}

.modal-body {
  padding: var(--space-8);
  overflow-y: auto;
  flex: 1;
  background: var(--color-surface);
  color: var(--color-text-primary);
}

.modal-footer {
  padding: var(--space-5) var(--space-8);
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-4);
  background: var(--color-surface-hover);
}

/* ── State components: error, empty, loading ── */
.state-error,
.state-empty,
.state-loading {
  padding: var(--space-8);
  border-radius: var(--radius-md);
  text-align: center;
}

.state-error {
  background: var(--color-danger-bg);
  border: 1px solid var(--color-danger-border);
  color: var(--color-danger);
}
.state-error-icon {
  font-size: var(--text-3xl);
  margin-bottom: var(--space-4);
}
.state-error-title {
  font-weight: var(--font-weight-semibold);
  font-size: var(--text-md);
  margin-bottom: var(--space-2);
}
.state-error-message {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-4);
}

.state-empty {
  background: var(--color-surface-hover);
  border: 1px solid rgba(0, 0, 0, 0.06);
  color: var(--color-text-secondary);
}
.state-empty-icon {
  font-size: var(--text-3xl);
  margin-bottom: var(--space-4);
  opacity: 0.6;
}
.state-empty-title {
  font-weight: var(--font-weight-semibold);
  font-size: var(--text-md);
  margin-bottom: var(--space-2);
  color: var(--color-text-primary);
}
.state-empty-message {
  font-size: var(--text-sm);
  margin-bottom: var(--space-4);
}

.state-loading {
  background: var(--color-info-bg);
  border: 1px solid var(--color-info-border);
  color: var(--color-info);
}
.state-loading-icon {
  font-size: var(--text-2xl);
  margin-bottom: var(--space-4);
  animation: spin 1s linear infinite;
}
.state-loading-title {
  font-weight: var(--font-weight-semibold);
  font-size: var(--text-md);
}

/* ── Keyboard navigation (WCAG AA required) ── */
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
a:focus-visible,
[role="button"]:focus-visible,
[role="menuitem"]:focus-visible,
[role="link"]:focus-visible {
  outline: 3px solid var(--color-accent-standard) !important;
  outline-offset: 2px !important;
}

button:focus:not(:focus-visible),
input:focus:not(:focus-visible),
textarea:focus:not(:focus-visible),
select:focus:not(:focus-visible) {
  outline: none;
}

/* ── Animations ── */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

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