/* ==========================================================================
   Design System Tokens — TwinComp Portfolio
   Built with agency-ui-designer & agency-ux-architect standards
   WCAG 2.1 AA Compliant Light, Dark & System Themes
   ========================================================================== */

:root {
  /* Typography Tokens */
  --font-family-primary: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-family-mono: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;

  --text-xs: 0.75rem;
  /* 12px */
  --text-sm: 0.875rem;
  /* 14px */
  --text-base: 1rem;
  /* 16px */
  --text-lg: 1.125rem;
  /* 18px */
  --text-xl: 1.25rem;
  /* 20px */
  --text-2xl: 1.5rem;
  /* 24px */
  --text-3xl: 1.875rem;
  /* 30px */
  --text-4xl: 2.375rem;
  /* 38px */
  --text-5xl: 3.125rem;
  /* 50px */

  /* Spacing System (Base 4px / 8px rhythm) */
  --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 */

  /* Layout Containers */
  --container-sm: 640px;
  --container-md: 768px;
  --container-lg: 1024px;
  --container-xl: 1240px;

  /* Border Radius */
  --radius-sm: 0.375rem;
  /* 6px */
  --radius-md: 0.625rem;
  /* 10px */
  --radius-lg: 0.875rem;
  /* 14px */
  --radius-xl: 1.25rem;
  /* 20px */
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition-normal: 260ms cubic-bezier(0.16, 1, 0.3, 1);

  /* Light Theme Colors (Default) — High-Contrast Architectural Slate & Cobalt */
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --bg-elevated: rgba(255, 255, 255, 0.88);
  --bg-accent-subtle: #eff6ff;
  --bg-emerald-subtle: #ecfdf5;
  --bg-amber-subtle: #fffbeb;

  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --text-on-accent: #ffffff;

  --border-color: #e2e8f0;
  --border-strong: #cbd5e1;
  --border-accent: #93c5fd;

  /* Brand & Semantic Tokens */
  --primary-500: #1d4ed8;
  --primary-600: #1e40af;
  --primary-700: #1e3a8a;
  --accent-emerald: #059669;
  --accent-emerald-hover: #047857;
  --accent-amber: #d97706;

  /* Shadows */
  --shadow-xs: 0 1px 2px 0 rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 2px 8px -2px rgba(15, 23, 42, 0.07), 0 1px 3px -1px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 10px 24px -4px rgba(15, 23, 42, 0.08), 0 4px 8px -2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 20px 36px -8px rgba(15, 23, 42, 0.12), 0 8px 16px -4px rgba(15, 23, 42, 0.06);

  /* Subtle Structural Grid Pattern */
  --grid-line-color: rgba(15, 23, 42, 0.035);
}

/* Dark Theme Tokens */
[data-theme="dark"] {
  --bg-primary: #090d16;
  --bg-secondary: #111827;
  --bg-tertiary: #1e293b;
  --bg-elevated: rgba(17, 24, 39, 0.86);
  --bg-accent-subtle: rgba(37, 99, 235, 0.14);
  --bg-emerald-subtle: rgba(16, 185, 129, 0.13);
  --bg-amber-subtle: rgba(245, 158, 11, 0.14);

  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-on-accent: #ffffff;

  --border-color: #1e293b;
  --border-strong: #334155;
  --border-accent: #2563eb;

  --primary-500: #3b82f6;
  --primary-600: #2563eb;
  --primary-700: #60a5fa;
  --accent-emerald: #10b981;
  --accent-emerald-hover: #059669;
  --accent-amber: #f59e0b;

  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 4px 12px -2px rgba(0, 0, 0, 0.45);
  --shadow-md: 0 12px 28px -4px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 24px 48px -8px rgba(0, 0, 0, 0.65);

  --grid-line-color: rgba(248, 250, 252, 0.035);
}

/* System Theme Preference when not explicitly overridden */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-primary: #090d16;
    --bg-secondary: #111827;
    --bg-tertiary: #1e293b;
    --bg-elevated: rgba(17, 24, 39, 0.86);
    --bg-accent-subtle: rgba(37, 99, 235, 0.14);
    --bg-emerald-subtle: rgba(16, 185, 129, 0.13);
    --bg-amber-subtle: rgba(245, 158, 11, 0.14);

    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --text-on-accent: #ffffff;

    --border-color: #1e293b;
    --border-strong: #334155;
    --border-accent: #2563eb;

    --primary-500: #3b82f6;
    --primary-600: #2563eb;
    --primary-700: #60a5fa;
    --accent-emerald: #10b981;
    --accent-emerald-hover: #059669;
    --accent-amber: #f59e0b;

    --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.35);
    --shadow-sm: 0 4px 12px -2px rgba(0, 0, 0, 0.45);
    --shadow-md: 0 12px 28px -4px rgba(0, 0, 0, 0.55);
    --shadow-lg: 0 24px 48px -8px rgba(0, 0, 0, 0.65);

    --grid-line-color: rgba(248, 250, 252, 0.035);
  }
}

/* Reset & Base Accessibility Foundations */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 5.5rem;
  font-size: 16px;
}

@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 {
  font-family: var(--font-family-primary);
  font-size: var(--text-base);
  line-height: 1.65;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  background-image:
    linear-gradient(to right, var(--grid-line-color) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-line-color) 1px, transparent 1px);
  background-size: 48px 48px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--transition-normal), color var(--transition-normal);
  overflow-x: hidden;
}

/* Skip Link for Keyboard Accessibility */
.skip-link {
  position: absolute;
  top: -100px;
  left: var(--space-4);
  background: var(--primary-500);
  color: var(--text-on-accent);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-weight: 600;
  z-index: 9999;
  text-decoration: none;
  transition: top var(--transition-fast);
}

.skip-link:focus {
  top: var(--space-4);
  outline: 3px solid var(--border-accent);
}

/* Typography Hierarchy */
h1,
h2,
h3,
h4 {
  color: var(--text-primary);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.font-mono {
  font-family: var(--font-family-mono);
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}