/* ==========================================================================
   variables.css — Design tokens & global foundations
   Mobile-first · WCAG AA contrast · Light/Dark theming
   ========================================================================== */

/* --------------------------------------------------------------------------
   Breakpoints (reference only — use in min-width media queries)
   Mobile: baseline | Tablet: 768px | Desktop: 1024px | Ultra-wide: 1440px
   -------------------------------------------------------------------------- */

:root {
  /* —— Breakpoint tokens (for documentation & calc(); not valid in @media) —— */
  --bp-tablet: 48rem;   /* 768px */
  --bp-desktop: 64rem;  /* 1024px */
  --bp-ultra: 90rem;    /* 1440px */

  /* —— Brand —— */
  --color-brand-50: #eef2ff;
  --color-brand-100: #e0e7ff;
  --color-brand-200: #c7d2fe;
  --color-brand-300: #a5b4fc;
  --color-brand-400: #818cf8;
  --color-brand-500: #6366f1;
  --color-brand-600: #4f46e5;
  --color-brand-700: #4338ca;
  --color-brand-800: #3730a3;
  --color-brand-900: #312e81;

  --color-accent-400: #22d3ee;
  --color-accent-500: #06b6d4;
  --color-accent-600: #0891b2;

  /* —— Neutral (shared ramps) —— */
  --color-neutral-0: #ffffff;
  --color-neutral-50: #f8fafc;
  --color-neutral-100: #f1f5f9;
  --color-neutral-200: #e2e8f0;
  --color-neutral-300: #cbd5e1;
  --color-neutral-400: #94a3b8;
  --color-neutral-500: #64748b;
  --color-neutral-600: #475569;
  --color-neutral-700: #334155;
  --color-neutral-800: #1e293b;
  --color-neutral-900: #0f172a;
  --color-neutral-950: #020617;

  /* —— Semantic surfaces (light default) —— */
  --surface-page: var(--color-neutral-50);
  --surface-elevated: var(--color-neutral-0);
  --surface-card: var(--color-neutral-0);
  --surface-card-hover: var(--color-neutral-100);
  --surface-muted: var(--color-neutral-100);
  --surface-overlay: rgb(15 23 42 / 0.55);
  --surface-nav: rgb(248 250 252 / 0.82);
  --surface-input: var(--color-neutral-0);
  --surface-focus-ring: var(--color-brand-500);

  /* —— Semantic text —— */
  --text-primary: var(--color-neutral-900);
  --text-secondary: var(--color-neutral-600);
  --text-muted: var(--color-neutral-500);
  --text-inverse: var(--color-neutral-0);
  --text-on-brand: var(--color-neutral-0);
  --text-link: var(--color-brand-700);
  --text-link-hover: var(--color-brand-800);

  /* —— Semantic borders & dividers —— */
  --border-default: var(--color-neutral-200);
  --border-strong: var(--color-neutral-300);
  --border-focus: var(--color-brand-500);

  /* —— Status —— */
  --color-success: #15803d;
  --color-warning: #b45309;
  --color-error: #b91c1c;

  /* —— Gradients —— */
  --gradient-hero: linear-gradient(
    135deg,
    var(--color-brand-600) 0%,
    var(--color-accent-500) 50%,
    var(--color-brand-400) 100%
  );
  --gradient-card-shine: linear-gradient(
    145deg,
    rgb(255 255 255 / 0.12) 0%,
    transparent 55%
  );
  --gradient-radial-glow: radial-gradient(
    ellipse 80% 60% at 50% -20%,
    rgb(99 102 241 / 0.18),
    transparent 70%
  );

  /* —— Typography families —— */
  --font-sans: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont,
    "Roboto", "Helvetica Neue", Arial, sans-serif;
  --font-display: var(--font-sans);
  --font-mono: ui-monospace, "Cascadia Code", "Segoe UI Mono", monospace;

  /* —— Fluid type scale —— */
  --text-xs: clamp(0.75rem, 0.7rem + 0.2vw, 0.8125rem);
  --text-sm: clamp(0.8125rem, 0.78rem + 0.25vw, 0.875rem);
  --text-base: clamp(1rem, 0.95rem + 0.3vw, 1.0625rem);
  --text-lg: clamp(1.125rem, 1.05rem + 0.4vw, 1.25rem);
  --text-xl: clamp(1.25rem, 1.1rem + 0.6vw, 1.5rem);
  --text-2xl: clamp(1.5rem, 1.25rem + 1vw, 2rem);
  --text-3xl: clamp(1.875rem, 1.5rem + 1.5vw, 2.5rem);
  --text-4xl: clamp(2.25rem, 1.75rem + 2.25vw, 3.25rem);
  --text-5xl: clamp(2.75rem, 2rem + 3vw, 4.25rem);

  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  --leading-tight: 1.2;
  --leading-snug: 1.35;
  --leading-normal: 1.6;
  --leading-relaxed: 1.75;

  --tracking-tight: -0.025em;
  --tracking-normal: 0;
  --tracking-wide: 0.04em;
  --tracking-wider: 0.08em;

  /* —— Spacing scale (4px base) —— */
  --space-0: 0;
  --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;
  --space-20: 5rem;
  --space-24: 6rem;

  --container-padding: clamp(var(--space-4), 4vw, var(--space-8));
  --section-gap: clamp(var(--space-12), 8vw, var(--space-24));
  --content-max: 72rem;
  --content-narrow: 42rem;

  /* —— Radii —— */
  --radius-sm: 0.375rem;
  --radius-md: 0.625rem;
  --radius-lg: 1rem;
  --radius-xl: 1.5rem;
  --radius-full: 9999px;

  /* —— Elevation —— */
  --shadow-xs: 0 1px 2px rgb(15 23 42 / 0.06);
  --shadow-sm: 0 2px 8px rgb(15 23 42 / 0.08);
  --shadow-md: 0 8px 24px rgb(15 23 42 / 0.1);
  --shadow-lg: 0 16px 48px rgb(15 23 42 / 0.12);
  --shadow-glow: 0 0 0 1px rgb(99 102 241 / 0.15),
    0 12px 40px rgb(79 70 229 / 0.2);

  /* —— Motion —— */
  --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-emphasized: cubic-bezier(0.2, 0, 0, 1);
  --duration-fast: 150ms;
  --duration-base: 300ms;
  --duration-slow: 500ms;
  --transition-interactive: all var(--duration-base) var(--ease-standard);
  --transition-color: color var(--duration-base) var(--ease-standard),
    background-color var(--duration-base) var(--ease-standard),
    border-color var(--duration-base) var(--ease-standard),
    box-shadow var(--duration-base) var(--ease-standard);

  /* —— Layout —— */
  --header-height: 4rem;
  --aspect-project: 16 / 10;
  --aspect-avatar: 1 / 1;
  --z-base: 1;
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-modal: 300;
}

/* —— System dark preference —— */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --surface-page: var(--color-neutral-950);
    --surface-elevated: var(--color-neutral-900);
    --surface-card: var(--color-neutral-900);
    --surface-card-hover: var(--color-neutral-800);
    --surface-muted: var(--color-neutral-800);
    --surface-overlay: rgb(2 6 23 / 0.72);
    --surface-nav: rgb(15 23 42 / 0.78);
    --surface-input: var(--color-neutral-900);

    --text-primary: var(--color-neutral-50);
    --text-secondary: var(--color-neutral-300);
    --text-muted: var(--color-neutral-400);
    --text-link: var(--color-brand-300);
    --text-link-hover: var(--color-brand-200);

    --border-default: var(--color-neutral-700);
    --border-strong: var(--color-neutral-600);

    --shadow-xs: 0 1px 2px rgb(0 0 0 / 0.35);
    --shadow-sm: 0 2px 8px rgb(0 0 0 / 0.4);
    --shadow-md: 0 8px 24px rgb(0 0 0 / 0.45);
    --shadow-lg: 0 16px 48px rgb(0 0 0 / 0.5);
    --shadow-glow: 0 0 0 1px rgb(129 140 248 / 0.2),
      0 12px 40px rgb(99 102 241 / 0.25);

    --gradient-radial-glow: radial-gradient(
      ellipse 80% 60% at 50% -20%,
      rgb(99 102 241 / 0.28),
      transparent 70%
    );
  }
}

/* —— Manual dark override —— */
[data-theme="dark"] {
  --surface-page: var(--color-neutral-950);
  --surface-elevated: var(--color-neutral-900);
  --surface-card: var(--color-neutral-900);
  --surface-card-hover: var(--color-neutral-800);
  --surface-muted: var(--color-neutral-800);
  --surface-overlay: rgb(2 6 23 / 0.72);
  --surface-nav: rgb(15 23 42 / 0.78);
  --surface-input: var(--color-neutral-900);

  --text-primary: var(--color-neutral-50);
  --text-secondary: var(--color-neutral-300);
  --text-muted: var(--color-neutral-400);
  --text-link: var(--color-brand-300);
  --text-link-hover: var(--color-brand-200);

  --border-default: var(--color-neutral-700);
  --border-strong: var(--color-neutral-600);

  --shadow-xs: 0 1px 2px rgb(0 0 0 / 0.35);
  --shadow-sm: 0 2px 8px rgb(0 0 0 / 0.4);
  --shadow-md: 0 8px 24px rgb(0 0 0 / 0.45);
  --shadow-lg: 0 16px 48px rgb(0 0 0 / 0.5);
  --shadow-glow: 0 0 0 1px rgb(129 140 248 / 0.2),
    0 12px 40px rgb(99 102 241 / 0.25);

  --gradient-radial-glow: radial-gradient(
    ellipse 80% 60% at 50% -20%,
    rgb(99 102 241 / 0.28),
    transparent 70%
  );
}

/* —— Manual light override (when OS is dark) —— */
[data-theme="light"] {
  --surface-page: var(--color-neutral-50);
  --surface-elevated: var(--color-neutral-0);
  --surface-card: var(--color-neutral-0);
  --surface-card-hover: var(--color-neutral-100);
  --surface-muted: var(--color-neutral-100);
  --surface-overlay: rgb(15 23 42 / 0.55);
  --surface-nav: rgb(248 250 252 / 0.82);
  --surface-input: var(--color-neutral-0);

  --text-primary: var(--color-neutral-900);
  --text-secondary: var(--color-neutral-600);
  --text-muted: var(--color-neutral-500);
  --text-link: var(--color-brand-700);
  --text-link-hover: var(--color-brand-800);

  --border-default: var(--color-neutral-200);
  --border-strong: var(--color-neutral-300);

  --shadow-xs: 0 1px 2px rgb(15 23 42 / 0.06);
  --shadow-sm: 0 2px 8px rgb(15 23 42 / 0.08);
  --shadow-md: 0 8px 24px rgb(15 23 42 / 0.1);
  --shadow-lg: 0 16px 48px rgb(15 23 42 / 0.12);
  --shadow-glow: 0 0 0 1px rgb(99 102 241 / 0.15),
    0 12px 40px rgb(79 70 229 / 0.2);

  --gradient-radial-glow: radial-gradient(
    ellipse 80% 60% at 50% -20%,
    rgb(99 102 241 / 0.18),
    transparent 70%
  );
}

/* ==========================================================================
   Global reset & base typography
   ========================================================================== */

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

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

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--font-weight-normal);
  line-height: var(--leading-normal);
  letter-spacing: var(--tracking-normal);
  color: var(--text-primary);
  background-color: var(--surface-page);
  background-image: var(--gradient-radial-glow);
  background-repeat: no-repeat;
  background-size: 100% 40vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: var(--transition-color);
}

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

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

a {
  color: var(--text-link);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: var(--transition-color);
}

a:hover {
  color: var(--text-link-hover);
}

a:focus-visible {
  outline: 2px solid var(--surface-focus-ring);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: var(--font-weight-bold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--text-primary);
}

h1 {
  font-size: var(--text-5xl);
}

h2 {
  font-size: var(--text-3xl);
}

h3 {
  font-size: var(--text-xl);
}

p {
  margin: 0 0 var(--space-4);
  color: var(--text-secondary);
}

p:last-child {
  margin-bottom: 0;
}

.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;
}
