/* FILE: assets/css/main.css */
/* =============================================================================
   MAIN STYLES - DESIGN SYSTEM & CORE UTILITIES
   ============================================================================= */

/* -----------------------------------------------------------------------------
   CSS CUSTOM PROPERTIES (DESIGN TOKENS)
   ----------------------------------------------------------------------------- */
:root {
  /* Core Palette - Purple Theme (WCAG AA Compliant) */
  /* Primary: Used for headings, strong links, active states */
  /* Light mode: #5a1f99 on white = 7.8:1 contrast ratio ✓ */
  --primary-color: #5a1f99;
  /* Primary Light: Used for gradients, hover states */
  /* #6b2bab on white = 6.5:1 contrast ratio ✓ */
  --primary-light: #6b2bab;
  /* Secondary: Used for accents, decorative elements */
  --secondary-color: #8b5fbf;

  /* Functional Colors (WCAG AA Compliant) */
  /* Gold on white: 3.1:1 - use for large text/icons only */
  --highlight-color: #b8860b; /* Darker gold for better contrast */
  /* Error red on white: 5.9:1 ✓ */
  --error-color: #b91c1c;
  /* Success green on white: 4.7:1 ✓ */
  --success-color: #047857;
  /* Warning amber: used with dark text */
  --warning-color: #d97706;
  --accent-teal: #0d9488;
  --accent-rose: #e11d48;

  /* Neutrals & Backgrounds (Light Mode Default) */
  --background-light: #fafafa;
  --white: #ffffff;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  /* Gray-600 on white: 5.9:1 ✓ */
  --gray-600: #4b5563;
  /* Gray-700 on white: 8.6:1 ✓ */
  --gray-700: #374151;
  /* Text-dark on white: 15.4:1 ✓ */
  --text-dark: #0f172a;

  /* Focus ring color */
  --focus-ring: #5a1f99;
  --focus-ring-offset: 3px;

  /* Typography */
  --font-heading: "Playfair Display", Georgia, serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", "Courier New", Courier, monospace;

  /* Font Weights */
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  /* Fluid Font Scale */
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1.05rem + 0.35vw, 1.25rem);
  --text-xl: clamp(1.25rem, 1.15rem + 0.5vw, 1.5rem);
  --text-2xl: clamp(1.5rem, 1.35rem + 0.75vw, 1.875rem);
  --text-3xl: clamp(1.875rem, 1.65rem + 1vw, 2.25rem);
  --text-4xl: clamp(2.25rem, 1.95rem + 1.5vw, 3rem);

  /* Line Heights */
  --lh-tight: 1.2;
  --lh-snug: 1.375;
  --lh-normal: 1.5;
  --lh-relaxed: 1.625;
  --lh-loose: 2;

  /* Letter Spacing */
  --ls-tight: -0.025em;
  --ls-normal: 0;
  --ls-wide: 0.025em;
  --ls-wider: 0.05em;
  --ls-widest: 0.1em;

  /* Spacing */
  --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-24: 6rem;

  /* UI Elements */
  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --radius-lg: 1rem;
  --radius-xl: 1.5rem;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  --shadow-purple: 0 10px 30px -5px rgba(108, 46, 185, 0.3);
  --shadow-hover: 0 14px 28px rgba(0, 0, 0, 0.12),
    0 10px 10px rgba(0, 0, 0, 0.08);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 350ms ease;

  /* Background Patterns */
  --pattern-dots: radial-gradient(
    circle,
    rgba(108, 46, 185, 0.08) 1px,
    transparent 1px
  );
  --pattern-grid: linear-gradient(rgba(108, 46, 185, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(108, 46, 185, 0.05) 1px, transparent 1px);
}

/* -----------------------------------------------------------------------------
   RESET & GLOBAL STYLES
   ----------------------------------------------------------------------------- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  scroll-padding-top: 80px; /* Accounts for fixed navbar */
  -webkit-font-smoothing: antialiased;
}

/* Responsive images by default */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Video/iframe responsive */
video,
iframe {
  max-width: 100%;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.7;
  color: var(--text-dark);
  background-color: var(--background-light);
  background-image: var(--pattern-dots);
  background-size: 24px 24px;
  background-attachment: fixed;
  transition: background-color var(--transition-base),
    color var(--transition-base);
}

/* Prevent transitions on page load (handled by JS) */
body.no-transition * {
  transition: none !important;
}

/* -----------------------------------------------------------------------------
   TYPOGRAPHY
   ----------------------------------------------------------------------------- */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-dark);
  margin-bottom: var(--space-4);
}

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

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

a {
  color: var(--primary-color);
  text-decoration: underline;
  text-decoration-color: rgba(90, 31, 153, 0.4);
  text-underline-offset: 3px;
  transition: all var(--transition-fast);
}

a:hover {
  color: var(--primary-light);
  text-decoration-color: var(--primary-light);
}

/* Enhanced focus states for accessibility */
a:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: var(--focus-ring-offset);
  border-radius: 2px;
}

/* Global focus styles */
:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: var(--focus-ring-offset);
}

/* Remove default focus for mouse users, keep for keyboard */
:focus:not(:focus-visible) {
  outline: none;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --primary-color: #4a1080;
    --gray-600: #333333;
    --text-dark: #000000;
  }
}

/* Reduced motion support */
@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;
  }
}

/* -----------------------------------------------------------------------------
   LAYOUT & UTILITIES
   ----------------------------------------------------------------------------- */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-6);
}

.container-narrow {
  max-width: 800px;
}
.container-wide {
  max-width: 1400px;
}

.section {
  padding: var(--space-20) 0;
  position: relative;
}

.section-title {
  margin-bottom: var(--space-4);
}

.section-intro {
  max-width: 700px;
  margin: 0 auto var(--space-12);
  font-size: var(--text-lg);
  line-height: 1.7;
  color: var(--gray-700);
}

body.dark-mode .section-intro {
  color: var(--gray-400);
}

.section-alt {
  background-color: var(--white);
  background-image: var(--pattern-grid);
  background-size: 40px 40px;
}

.text-center {
  text-align: center;
}
.text-left {
  text-align: left;
}
.text-right {
  text-align: right;
}

/* Text Utilities */
.text-muted {
  color: var(--gray-600);
}
.text-primary {
  color: var(--primary-color);
}
.text-gradient {
  background: linear-gradient(
    135deg,
    var(--primary-color),
    var(--primary-light)
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.text-balance {
  text-wrap: balance;
}

/* Font Weight Utilities */
.font-normal {
  font-weight: var(--font-weight-normal);
}
.font-medium {
  font-weight: var(--font-weight-medium);
}
.font-semibold {
  font-weight: var(--font-weight-semibold);
}
.font-bold {
  font-weight: var(--font-weight-bold);
}

/* Spacing Utilities */
.mt-0 {
  margin-top: 0;
}
.mt-2 {
  margin-top: var(--space-2);
}
.mt-4 {
  margin-top: var(--space-4);
}
.mt-6 {
  margin-top: var(--space-6);
}
.mt-8 {
  margin-top: var(--space-8);
}
.mb-0 {
  margin-bottom: 0;
}
.mb-2 {
  margin-bottom: var(--space-2);
}
.mb-4 {
  margin-bottom: var(--space-4);
}
.mb-6 {
  margin-bottom: var(--space-6);
}
.mb-8 {
  margin-bottom: var(--space-8);
}
.my-4 {
  margin-top: var(--space-4);
  margin-bottom: var(--space-4);
}
.my-8 {
  margin-top: var(--space-8);
  margin-bottom: var(--space-8);
}

.pt-0 {
  padding-top: 0;
}
.pt-4 {
  padding-top: var(--space-4);
}
.pt-8 {
  padding-top: var(--space-8);
}
.pb-0 {
  padding-bottom: 0;
}
.pb-4 {
  padding-bottom: var(--space-4);
}
.pb-8 {
  padding-bottom: var(--space-8);
}
.py-4 {
  padding-top: var(--space-4);
  padding-bottom: var(--space-4);
}
.py-8 {
  padding-top: var(--space-8);
  padding-bottom: var(--space-8);
}

/* Flexbox Utilities */
.flex {
  display: flex;
}
.flex-col {
  flex-direction: column;
}
.flex-wrap {
  flex-wrap: wrap;
}
.items-center {
  align-items: center;
}
.items-start {
  align-items: flex-start;
}
.justify-center {
  justify-content: center;
}
.justify-between {
  justify-content: space-between;
}
.gap-2 {
  gap: var(--space-2);
}
.gap-4 {
  gap: var(--space-4);
}
.gap-6 {
  gap: var(--space-6);
}
.gap-8 {
  gap: var(--space-8);
}

/* Grid Utilities */
.grid {
  display: grid;
  gap: var(--space-8);
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-8);
}
.grid-cols-1 {
  grid-template-columns: repeat(1, 1fr);
}
.grid-cols-2 {
  grid-template-columns: repeat(2, 1fr);
}
.grid-cols-3 {
  grid-template-columns: repeat(3, 1fr);
}
.grid-cols-4 {
  grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 1024px) {
  .grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .grid-3 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1024px) {
  .lg\:grid-cols-2 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .md\:grid-cols-1 {
    grid-template-columns: repeat(1, 1fr);
  }
  .md\:flex-col {
    flex-direction: column;
  }
}

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

/* -----------------------------------------------------------------------------
   COMPONENTS: BUTTONS
   ----------------------------------------------------------------------------- */
.btn {
  display: inline-block;
  padding: var(--space-4) var(--space-8);
  font-family: var(--font-body);
  font-weight: 600;
  text-decoration: none;
  text-align: center;
  border-radius: var(--radius-md);
  border: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.btn-primary {
  background: linear-gradient(
    135deg,
    var(--primary-color),
    var(--primary-light)
  );
  color: var(--white);
  box-shadow: var(--shadow-md);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px -4px rgba(90, 31, 153, 0.4);
  color: var(--white);
  text-decoration: none;
}

.btn-secondary {
  background: transparent;
  color: var(--primary-color);
  border-color: var(--primary-color);
}

.btn-secondary:hover {
  background: var(--primary-color);
  color: var(--white);
  text-decoration: none;
  transform: translateY(-2px);
}

/* Button focus states for accessibility */
.btn:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.btn-primary:focus-visible {
  box-shadow: 0 0 0 3px rgba(90, 31, 153, 0.3);
}

.btn-sm {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
}

.btn-lg {
  padding: var(--space-6) var(--space-12);
  font-size: var(--text-lg);
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.btn-icon svg {
  width: 1.25em;
  height: 1.25em;
  transition: transform var(--transition-fast);
}

.btn-icon:hover svg {
  transform: translateX(4px);
}

/* -----------------------------------------------------------------------------
   COMPONENTS: CARDS
   ----------------------------------------------------------------------------- */
.card {
  background: var(--white);
  padding: var(--space-10);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  transition: all var(--transition-base);
  border: 1px solid transparent;
  margin-bottom: var(--space-6);
}

.card p {
  line-height: 1.7;
  margin-bottom: var(--space-4);
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: rgba(90, 31, 153, 0.1);
}

.card-flat {
  box-shadow: none;
  border: 1px solid var(--gray-200);
}

.card-flat:hover {
  box-shadow: var(--shadow-md);
  border-color: rgba(90, 31, 153, 0.2);
}

.card-header {
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--gray-200);
}

.card-title {
  font-size: var(--text-xl);
  margin-bottom: var(--space-2);
}

.card-body {
  flex: 1;
}

.card-footer {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--gray-200);
}

/* -----------------------------------------------------------------------------
   COMPONENTS: TAGS & BADGES
   ----------------------------------------------------------------------------- */
.tag {
  display: inline-block;
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  font-weight: var(--font-weight-medium);
  background: var(--gray-100);
  color: var(--gray-700);
  border-radius: var(--radius-full);
  transition: all var(--transition-fast);
}

.tag-primary {
  background: rgba(90, 31, 153, 0.1);
  color: var(--primary-color);
}

.tag:hover {
  background: var(--primary-color);
  color: var(--white);
}

/* Code blocks */
code,
pre {
  font-family: var(--font-mono);
}

code {
  padding: var(--space-1) var(--space-2);
  background: var(--gray-100);
  border-radius: var(--radius-sm);
  font-size: 0.9em;
}

pre {
  padding: var(--space-4);
  background: var(--gray-100);
  border-radius: var(--radius-md);
  overflow-x: auto;
}

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

/* -----------------------------------------------------------------------------
   ACCESSIBILITY SKIP LINK
   ----------------------------------------------------------------------------- */
.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  background: var(--primary-color);
  color: var(--white);
  padding: var(--space-2) var(--space-4);
  z-index: 9999;
  text-decoration: none;
  transition: top 0.3s;
}

.skip-link:focus {
  top: 0;
}

/* -----------------------------------------------------------------------------
   FOOTER
   ----------------------------------------------------------------------------- */
.site-footer {
  background-color: #0f172a;
  color: var(--gray-300);
  padding: var(--space-12) 0 var(--space-6);
  margin-top: auto;
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-6);
  padding-bottom: var(--space-8);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.footer-brand {
  flex: 1;
  min-width: 250px;
}

.footer-tagline {
  font-size: var(--text-sm);
  color: var(--gray-400);
  margin: 0;
  max-width: 300px;
}

.footer-nav {
  display: flex;
  gap: var(--space-6);
  flex-wrap: wrap;
}

.footer-nav a {
  color: var(--gray-400);
  text-decoration: none;
  font-size: var(--text-sm);
  transition: color var(--transition-fast);
}

.footer-nav a:hover {
  color: var(--primary-light);
}

.footer-social {
  display: flex;
  gap: var(--space-4);
}

.footer-social a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: var(--gray-300);
  transition: all var(--transition-fast);
}

.footer-social a:hover {
  background: var(--primary-color);
  color: white;
  transform: translateY(-2px);
}

.footer-social svg {
  width: 18px;
  height: 18px;
}

.footer-bottom {
  padding-top: var(--space-6);
  text-align: center;
}

.footer-bottom p {
  font-size: var(--text-xs);
  color: var(--gray-500);
  margin: 0;
}

/* -----------------------------------------------------------------------------
   RESPONSIVE
   ----------------------------------------------------------------------------- */
/* Mobile-first touch targets */
@media (max-width: 768px) {
  :root {
    --space-16: 3rem;
    --space-24: 4rem;
  }

  .section {
    padding: var(--space-12) 0;
  }

  html {
    font-size: 15px;
  }

  /* Ensure all interactive elements have 44px touch targets */
  .btn {
    min-height: 44px;
    min-width: 44px;
    padding: var(--space-3) var(--space-6);
  }

  a:not(.navbar-brand) {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }

  .footer-content {
    flex-direction: column;
    text-align: center;
  }

  .footer-nav {
    justify-content: center;
    flex-wrap: wrap;
    gap: var(--space-4);
  }

  .footer-nav a {
    padding: var(--space-2) var(--space-3);
  }

  .footer-social {
    justify-content: center;
  }

  .footer-social a {
    padding: var(--space-2);
  }
}

/* Small mobile screens */
@media (max-width: 480px) {
  :root {
    --space-8: 1.5rem;
    --space-12: 2.5rem;
    --space-16: 2.5rem;
  }

  html {
    font-size: 14px;
  }

  .container {
    padding: 0 var(--space-4);
  }

  /* Stack all grids */
  .grid {
    grid-template-columns: 1fr !important;
  }

  /* Reduce button padding on very small screens */
  .btn {
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-sm);
  }
}

/* Prevent horizontal overflow */
html,
body {
  overflow-x: hidden;
  max-width: 100%;
}
