/* DE-MAJ Architecture - Modern Base Styles */

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

/* CSS Custom Properties - Modern Design System */
:root {
  /* Color Palette - Client Specified */
  --bg: #546572;            /* base background (no black) */
  --bg-secondary: #6b8aa4;  /* secondary surface */
  --fg: #ebebeb;            /* light text */
  --fg-muted: #9cc0c9;      /* muted text */
  --muted: #6b8aa4;         /* surface */
  --accent: #6b8aa4;        /* primary accent */
  --accent2: #9cc0c9;       /* secondary accent */
  --accent-dark: #546572;   /* accent dark */
  --primary: #6b8aa4;       /* primary color */
  --line: rgba(235,235,235,0.06);
  --border: rgba(235,235,235,0.1);
  /* Light surface to break up blue-heavy UI */
  --paper: #ebebeb;        /* light section surface */
  --ink: #546572;          /* text on light surfaces */
  
  /* Neutral Palette mapped to client colors */
  --grey-950: #546572;
  --grey-900: #546572;
  --grey-800: #6b8aa4;
  --grey-700: #6b8aa4;
  --grey-600: #6b8aa4;
  --grey-500: #9cc0c9;
  --grey-400: #9cc0c9;
  --grey-300: #ebebeb;
  --grey-200: #ebebeb;
  --grey-100: #ebebeb;
  --grey-50: #ebebeb;
  
  /* Typography - Modern & Clean */
  --font-heading: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', monospace;
  
  /* Text Sizes */
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  
  /* Enhanced Spacing Scale */
  --space-0: 0;
  --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 */
  --space-32: 8rem;     /* 128px */
  
  /* Layout */
  --container-max: 1280px;
  --container-padding: var(--space-6);
  
  /* Modern Transitions */
  --transition-all: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-colors: color 0.2s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.2s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-transform: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-opacity: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  
  /* Modern Shadows */
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  
  /* Border Radius */
  --radius-none: 0;
  --radius-sm: 0.125rem;
  --radius-md: 0.375rem;
  --radius-lg: 0.5rem;
  --radius-xl: 0.75rem;
  --radius-2xl: 1rem;
  --radius-full: 9999px;
  
  /* Z-Index Scale */
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal-backdrop: 1040;
  --z-modal: 1050;
  --z-popover: 1060;
  --z-tooltip: 1070;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Enhanced Smooth Scrolling */
html {
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
}

/* Custom scrollbar for webkit browsers */
::-webkit-scrollbar {
  width: 6px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 3px;
  transition: background 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent-dark);
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--accent) var(--bg);
}

/* Performance optimizations */
* {
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  -webkit-perspective: 1000;
  perspective: 1000;
}

img {
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

body {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--fg);
  background-color: var(--bg);
  /* Subtle professional background pattern */
  background-image:
    radial-gradient(circle at 12% 18%, rgba(235, 235, 235, 0.035) 1.2px, transparent 1.2px),
    radial-gradient(circle at 78% 72%, rgba(156, 192, 201, 0.03) 1.4px, transparent 1.4px),
    radial-gradient(circle at 42% 54%, rgba(107, 138, 164, 0.03) 1.1px, transparent 1.1px);
  background-size: 26px 26px, 30px 30px, 28px 28px;
  background-attachment: fixed;
  font-feature-settings: 'kern' 1, 'liga' 1, 'calt' 1;
  text-rendering: optimizeLegibility;
}

/* Modern Typography */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.025em;
  color: var(--fg);
  margin: 0;
}

h1 {
  font-size: clamp(2.5rem, 5vw, 4rem);
  font-weight: 700;
  letter-spacing: -0.05em;
}

h2 {
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 600;
  letter-spacing: -0.025em;
}

h3 {
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 600;
}

h4 {
  font-size: clamp(1.25rem, 2.5vw, 1.5rem);
  font-weight: 600;
}

h5 {
  font-size: 1.125rem;
  font-weight: 600;
}

h6 {
  font-size: 1rem;
  font-weight: 600;
}

p {
  margin: 0 0 var(--space-4) 0;
  color: var(--grey-300);
  line-height: 1.7;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: var(--transition-colors);
}

a:hover,
a:focus {
  color: var(--accent2);
  outline: none;
}

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

/* Modern Button System */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: var(--transition-all);
  position: relative;
  overflow: hidden;
  white-space: nowrap;
  user-select: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn--primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: white;
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.btn--primary:hover {
  background: linear-gradient(135deg, var(--accent-dark) 0%, var(--accent) 100%);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn--primary:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

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

.btn--secondary:hover {
  background: var(--muted);
  border-color: var(--accent);
  color: var(--accent);
}

.btn--outline {
  background: transparent;
  color: var(--fg);
  border-color: var(--fg);
}

.btn--outline:hover {
  background: var(--fg);
  color: var(--bg);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn--ghost {
  background: transparent;
  color: var(--grey-400);
  border-color: transparent;
}

.btn--ghost:hover {
  background: var(--muted);
  color: var(--fg);
}

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

.btn--lg {
  padding: var(--space-4) var(--space-8);
  font-size: 1rem;
}

.btn--xl {
  padding: var(--space-5) var(--space-10);
  font-size: 1.125rem;
}

/* Modern Form Elements */
input,
textarea,
select {
  font-family: var(--font-body);
  font-size: 0.875rem;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line);
  background-color: var(--muted);
  color: var(--fg);
  border-radius: var(--radius-lg);
  transition: var(--transition-all);
  width: 100%;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

input::placeholder,
textarea::placeholder {
  color: var(--grey-500);
}

textarea {
  resize: vertical;
  min-height: 120px;
}

/* Modern Lists */
ul, ol {
  margin: 0 0 var(--space-4) 0;
  padding-left: var(--space-6);
}

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

/* Modern Images */
img {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius-lg);
}

/* 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: 0;
}

.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--container-padding);
}

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

.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

.text-sm { font-size: 0.875rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }

.text-grey-400 { color: var(--grey-400); }
.text-grey-300 { color: var(--grey-300); }
.text-grey-200 { color: var(--grey-200); }

/* Loading States */
.loading {
  opacity: 0.6;
  pointer-events: none;
  position: relative;
}

.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Error States */
.error {
  color: #EF4444;
  border-color: #EF4444;
}

.error:focus {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* Success States */
.success {
  color: #10B981;
  border-color: #10B981;
}

.success:focus {
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* Mobile-First Optimizations */
@media (max-width: 768px) {
  /* Enhanced touch targets */
  .btn {
    min-height: 44px;
    min-width: 44px;
    padding: var(--space-4) var(--space-6);
    font-size: 1rem;
  }
  
  /* Better text sizing for mobile */
  h1 {
    font-size: clamp(2rem, 8vw, 3rem);
    line-height: 1.1;
  }
  
  h2 {
    font-size: clamp(1.5rem, 6vw, 2.25rem);
    line-height: 1.2;
  }
  
  h3 {
    font-size: clamp(1.25rem, 5vw, 1.75rem);
    line-height: 1.3;
  }
  
  /* Improved paragraph spacing */
  p {
    line-height: 1.7;
    margin-bottom: var(--space-5);
  }
  
  /* Better form elements for mobile */
  input, textarea, select {
    font-size: 16px; /* Prevents zoom on iOS */
    padding: var(--space-4) var(--space-5);
    min-height: 44px;
  }
  
  /* Enhanced focus states for touch */
  input:focus, textarea:focus, select:focus {
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.2);
    border-width: 2px;
  }
  
  /* Better link spacing for touch */
  a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  /* Remove hover effects on touch devices */
  .btn:hover {
    transform: none;
  }
  
  .card:hover {
    transform: none;
  }
  
  .project-card:hover {
    transform: none;
  }
  
  /* Make interactive elements more prominent */
  .btn {
    box-shadow: var(--shadow-md);
  }
  
  .card {
    box-shadow: var(--shadow-lg);
  }
}

/* High DPI display optimizations */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
}

/* 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;
  }
}

/* Focus Management */
.focus-trap {
  outline: none;
}

/* Modern Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--muted);
}

::-webkit-scrollbar-thumb {
  background: var(--grey-600);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--grey-500);
}

/* Selection */
::selection {
  background: rgba(107, 138, 164, 0.2);
  color: var(--fg);
}