/* ========================================
   JACKWEB DESIGN SYSTEM
   Core Design Tokens & CSS Variables
   ======================================== */

/* ========================================
   ROOT VARIABLES & THEMES
   ======================================== */

:root {
  /* Color Palette - Light Theme (Default) */
  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fa;
  --bg-tertiary: #e9ecef;
  --bg-overlay-light: rgba(0, 0, 0, 0.02);
  --bg-overlay-medium: rgba(0, 0, 0, 0.05);
  --bg-overlay-dark: rgba(0, 0, 0, 0.08);

  /* Text Colors - Light Theme */
  --text-primary: #1a1a2e;
  --text-secondary: #4a5568;
  --text-muted: rgba(0, 0, 0, 0.5);
  --text-faint: rgba(0, 0, 0, 0.3);

  /* Brand Colors */
  --color-navy: #002783;
  --color-navy-dark: #001a5f;
  --color-navy-light: #003da5;
  --color-teal: #06b6d4;
  --color-teal-dark: #0891b2;
  --color-teal-light: #22d3ee;

  /* Accent Colors (Legacy - mapped to brand colors) */
  --accent-cvagent: #002783;
  --accent-cvagent-dark: #001a5f;
  --accent-etpattern: #06b6d4;
  --accent-etpattern-dark: #0891b2;
  --accent-teal: #78cdd1;
  --accent-coral: #ff6b6b;
  --accent-success: #51cf66;
  --accent-warning: #ffa94d;

  /* Border Colors - Light Theme */
  --border-subtle: rgba(0, 0, 0, 0.08);
  --border-medium: rgba(0, 0, 0, 0.12);
  --border-strong: rgba(0, 0, 0, 0.2);

  /* Shadows - Subtle, professional */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.12);
  --shadow-xl: 0 20px 32px rgba(0, 0, 0, 0.15);
  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.08);

  /* Glass Morphism Variables */
  --glass-bg: rgba(0, 0, 0, 0.03);
  --glass-border: rgba(0, 0, 0, 0.1);
  --glass-blur: 8px;

  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-regular: 400;
  --font-semibold: 600;
  --font-bold: 700;
  --font-extrabold: 800;

  /* Type Scale - Fixed sizes for clarity */
  --text-4xl: 42px;
  --text-3xl: 36px;
  --text-2xl: 24px;
  --text-xl: 20px;
  --text-lg: 18px;
  --text-base: 16px;
  --text-sm: 14px;
  --text-xs: 13px;

  /* Line Heights */
  --leading-tight: 1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.75;

  /* Letter Spacing */
  --tracking-tight: -0.01em;
  --tracking-normal: 0;
  --tracking-wide: 0.025em;
  --tracking-wider: 0.05em;

  /* Spacing System (4px base) */
  --space-0: 0;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;
  --space-32: 8rem;

  /* Border Radius */
  --radius-sm: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --radius-xl: 1.5rem;
  --radius-2xl: 2rem;
  --radius-3xl: 2.5rem;
  --radius-full: 9999px;

  /* Transitions & Timing - Simplified */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;
  --transition-slowest: 400ms ease;

  /* Z-Index Scale */
  --z-hide: -1;
  --z-base: 0;
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal-backdrop: 1040;
  --z-modal: 1050;
  --z-popover: 1060;
  --z-tooltip: 1070;

  /* Container Queries */
  --container-sm: 24rem;
  --container-md: 28rem;
  --container-lg: 32rem;
  --container-xl: 36rem;
  --container-2xl: 42rem;
  --container-3xl: 48rem;
  --container-4xl: 56rem;
  --container-5xl: 64rem;
  --container-6xl: 72rem;

  /* Reading Column Width */
  --reading-width: 760px;
}

/* Dark Theme */
[data-theme="dark"] {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-tertiary: #0f3460;
  --bg-overlay-light: rgba(255, 255, 255, 0.05);
  --bg-overlay-medium: rgba(255, 255, 255, 0.1);
  --bg-overlay-dark: rgba(255, 255, 255, 0.15);

  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --text-muted: rgba(255, 255, 255, 0.5);
  --text-faint: rgba(255, 255, 255, 0.3);

  --border-subtle: rgba(255, 255, 255, 0.1);
  --border-medium: rgba(255, 255, 255, 0.2);
  --border-strong: rgba(255, 255, 255, 0.3);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.4);
  --shadow-xl: 0 20px 32px rgba(0, 0, 0, 0.5);
  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.3);

  /* Glass Morphism Variables - Dark Theme */
  --glass-bg: rgba(255, 255, 255, 0.06);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-blur: 8px;
}

/* ========================================
   RESETS & BASE STYLES
   ======================================== */

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family);
  font-size: 17px;
  font-weight: var(--font-regular);
  line-height: 1.8;
  letter-spacing: var(--tracking-normal);
  color: var(--text-primary);
  background: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--transition-base), color var(--transition-base);
}

/* ========================================
   BACKGROUND
   ======================================== */

/* Content sits above background */
body > * {
  position: relative;
  z-index: var(--z-base);
}

/* ========================================
   TYPOGRAPHY
   ======================================== */

h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: var(--font-bold);
  line-height: 1.2;
  margin-bottom: 0.5rem;
  color: var(--color-navy);
}

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

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

h3 {
  font-size: 1.75rem;
}

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

h5 {
  font-size: var(--text-lg);
}

h6 {
  font-size: var(--text-base);
}

p {
  margin-bottom: 1rem;
  line-height: 1.8;
  color: var(--text-secondary);
}

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

strong,
b {
  font-weight: var(--font-bold);
}

em,
i {
  font-style: italic;
}

/* ========================================
   LINKS
   ======================================== */

a {
  color: var(--color-navy);
  text-decoration: none;
  transition: color var(--transition-base);
}

a:hover {
  color: var(--color-navy-dark);
  text-decoration: underline;
}

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

/* ========================================
   LISTS
   ======================================== */

ul,
ol {
  margin-bottom: 1rem;
  margin-left: var(--space-6);
}

li {
  margin-bottom: var(--space-2);
}

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

/* ========================================
   CODE & PREFORMATTED TEXT
   ======================================== */

code,
pre {
  font-family: 'Monaco', 'Courier New', monospace;
  font-size: 0.9em;
}

code {
  background: var(--bg-overlay-medium);
  color: var(--accent-teal);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  word-break: break-word;
}

pre {
  background: var(--bg-overlay-dark);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  overflow-x: auto;
  margin-bottom: var(--space-4);
}

pre code {
  background: none;
  color: inherit;
  padding: 0;
}

/* ========================================
   IMAGES & MEDIA
   ======================================== */

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

img {
  height: auto;
}

figure {
  margin-bottom: var(--space-8);
}

figcaption {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--space-2);
}

/* ========================================
   FORM ELEMENTS
   ======================================== */

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

input[type="text"],
input[type="email"],
input[type="url"],
input[type="search"],
input[type="number"],
textarea {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  color: var(--text-primary);
  transition: all var(--transition-base);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="url"]:focus,
input[type="search"]:focus,
input[type="number"]:focus,
textarea:focus {
  outline: none;
  border-color: var(--color-navy);
  box-shadow: 0 0 0 3px rgba(0, 39, 131, 0.1);
}

textarea {
  resize: vertical;
}

button {
  cursor: pointer;
}

/* ========================================
   TABLE STYLES
   ======================================== */

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--space-8);
}

thead {
  background: var(--bg-overlay-medium);
}

th {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-weight: var(--font-semibold);
}

td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
}

tbody tr:hover {
  background: var(--bg-overlay-light);
}

/* ========================================
   BLOCKQUOTES & CALLOUTS
   ======================================== */

blockquote {
  border-left: 4px solid var(--accent-cvagent);
  padding-left: var(--space-4);
  margin: var(--space-6) 0;
  color: var(--text-secondary);
  font-style: italic;
}

/* ========================================
   HORIZONTAL RULES
   ======================================== */

hr {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: var(--space-8) 0;
}

/* ========================================
   UTILITY CLASSES
   ======================================== */

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

.gradient-text {
  background: linear-gradient(135deg, var(--accent-cvagent) 0%, var(--accent-etpattern) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.text-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.text-break {
  word-break: break-word;
  overflow-wrap: break-word;
}

/* ========================================
   SCROLLBAR STYLING
   ======================================== */

/* Chrome, Safari, and Opera */
::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

::-webkit-scrollbar-track {
  background: var(--bg-overlay-light);
}

::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* Firefox */
* {
  scrollbar-color: var(--text-muted) var(--bg-overlay-light);
  scrollbar-width: thin;
}

/* ========================================
   FOCUS VISIBLE STYLES
   ======================================== */

:focus-visible {
  outline: 2px solid var(--accent-cvagent);
  outline-offset: 2px;
}

button:focus-visible,
a:focus-visible {
  border-radius: var(--radius-sm);
}

/* ========================================
   PREFERS REDUCED MOTION
   ======================================== */

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

/* ========================================
   RESPONSIVE TYPOGRAPHY
   ======================================== */

@media (max-width: 768px) {
  body {
    font-size: 16px;
  }

  h1 {
    font-size: clamp(1.75rem, 5vw, 2.5rem);
  }

  h2 {
    font-size: clamp(1.5rem, 4vw, 2rem);
  }

  h3 {
    font-size: 1.5rem;
  }

  h4 {
    font-size: 1.125rem;
  }
}
