/**
 * KTS GLOBAL - QUANTUM DESIGN SYSTEM V4.0
 * Complete Redesign - Option C Implementation
 * Date: 2026-03-04
 * 
 * FEATURES:
 * ✅ 8px base spacing system
 * ✅ Glassmorphism & 3D depth
 * ✅ Advanced animations & transitions
 * ✅ Bento box grid layouts
 * ✅ Persona-adaptive styling
 * ✅ Mobile-first responsive
 * ✅ RTL support
 * ✅ Language-specific typography
 * ✅ Micro-interactions
 * ✅ Performance optimized
 * 
 * Federation: @archon @crius @persephone @athena @hades
 */

/* ============================================
   1. DESIGN TOKENS & CSS VARIABLES
   ============================================ */

:root {
  /* 8px Base Spacing System */
  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;
  --space-4: 32px;
  --space-5: 40px;
  --space-6: 48px;
  --space-7: 56px;
  --space-8: 64px;
  --space-10: 80px;
  --space-12: 96px;
  --space-16: 128px;
  --space-20: 160px;
  
  /* Enhanced Color System */
  --color-primary: #00D9FF;
  --color-primary-dark: #00B8D9;
  --color-primary-light: #33E1FF;
  --color-secondary: #0EA5E9;
  --color-accent: #FFD700;
  --color-accent-dark: #FFC700;
  
  /* Background Layers */
  --bg-base: #0A0E27;
  --bg-elevated: #0F1629;
  --bg-overlay: #1A1D2E;
  --bg-glass: rgba(15, 22, 41, 0.7);
  
  /* Text Colors */
  --text-primary: #FFFFFF;
  --text-secondary: #CBD5E1;
  --text-tertiary: #94A3B8;
  --text-muted: #64748B;
  
  /* Borders */
  --border-subtle: rgba(0, 217, 255, 0.1);
  --border-default: rgba(0, 217, 255, 0.2);
  --border-strong: rgba(0, 217, 255, 0.4);
  
  /* Shadows & Depth */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.3);
  --shadow-xl: 0 16px 64px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 40px rgba(0, 217, 255, 0.3);
  
  /* 3D Depth Layers */
  --depth-1: 4px;
  --depth-2: 8px;
  --depth-3: 16px;
  --depth-4: 24px;
  
  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 24px;
  --radius-full: 9999px;
  
  /* Typography Scale */
  --font-size-xs: 0.75rem;   /* 12px */
  --font-size-sm: 0.875rem;  /* 14px */
  --font-size-base: 1rem;    /* 16px */
  --font-size-lg: 1.125rem;  /* 18px */
  --font-size-xl: 1.25rem;   /* 20px */
  --font-size-2xl: 1.5rem;   /* 24px */
  --font-size-3xl: 1.875rem; /* 30px */
  --font-size-4xl: 2.25rem;  /* 36px */
  --font-size-5xl: 3rem;     /* 48px */
  --font-size-6xl: 3.75rem;  /* 60px */
  --font-size-7xl: 4.5rem;   /* 72px */
  --font-size-8xl: 6rem;     /* 96px */
  
  /* Line Heights */
  --leading-none: 1;
  --leading-tight: 1.25;
  --leading-snug: 1.375;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;
  --leading-loose: 2;
  
  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 300ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 500ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 600ms cubic-bezier(0.68, -0.55, 0.265, 1.55);
  
  /* Z-Index Scale */
  --z-base: 0;
  --z-dropdown: 1000;
  --z-sticky: 1100;
  --z-fixed: 1200;
  --z-modal: 1300;
  --z-popover: 1400;
  --z-tooltip: 1500;
  
  /* Glassmorphism */
  --glass-blur: 20px;
  --glass-opacity: 0.7;
  --glass-border: 1px solid rgba(255, 255, 255, 0.1);
  
  /* Persona Variables (overridden by quantum system) */
  --persona-primary: #3498DB;
  --persona-secondary: #5DADE2;
  --persona-accent: #1ABC9C;
  --persona-gradient-start: #3498DB;
  --persona-gradient-end: #1ABC9C;
}

/* ============================================
   2. ENHANCED BASE STYLES
   ============================================ */

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 16px;
  overflow-x: hidden;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(180deg, var(--bg-base) 0%, var(--bg-elevated) 50%, #1C2541 100%);
  background-attachment: fixed;
  color: var(--text-primary);
  line-height: var(--leading-normal);
  overflow-x: hidden;
  font-size: var(--font-size-base);
}

/* Enhanced Scrollbar */
::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

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

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--color-primary) 0%, var(--color-secondary) 100%);
  border-radius: 6px;
  border: 2px solid var(--bg-base);
  transition: background var(--transition-base);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-primary);
}

/* ============================================
   3. ADVANCED TYPOGRAPHY SYSTEM
   ============================================ */

h1, h2, h3, h4, h5, h6 {
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: var(--space-3);
  line-height: var(--leading-tight);
}

h1 {
  font-size: clamp(var(--font-size-5xl), 8vw, var(--font-size-8xl));
  line-height: var(--leading-none);
  text-transform: uppercase;
  font-weight: 900;
  letter-spacing: -0.04em;
}

h2 {
  font-size: clamp(var(--font-size-4xl), 6vw, var(--font-size-6xl));
  line-height: 1.1;
  text-transform: uppercase;
  font-weight: 800;
}

h3 {
  font-size: clamp(var(--font-size-3xl), 4vw, var(--font-size-5xl));
  line-height: var(--leading-tight);
  font-weight: 700;
}

h4 {
  font-size: clamp(var(--font-size-xl), 3vw, var(--font-size-3xl));
  line-height: var(--leading-snug);
  font-weight: 700;
}

p {
  font-size: var(--font-size-lg);
  line-height: var(--leading-relaxed);
  color: var(--text-secondary);
  margin-bottom: var(--space-3);
}

/* Language-Specific Typography */
:lang(ar) {
  font-family: 'Tajawal', 'Arial', sans-serif;
  direction: rtl;
  line-height: var(--leading-loose);
}

:lang(ko), :lang(ja) {
  line-height: var(--leading-relaxed);
  letter-spacing: 0.02em;
}

:lang(zh) {
  line-height: var(--leading-relaxed);
  letter-spacing: 0.05em;
}

/* ============================================
   4. GLASSMORPHISM CARD SYSTEM
   ============================================ */

.glass-card {
  background: var(--bg-glass);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: var(--glass-border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  position: relative;
  overflow: hidden;
  transition: all var(--transition-base);
}

.glass-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--color-primary), transparent);
  opacity: 0;
  transition: opacity var(--transition-base);
}

.glass-card:hover {
  transform: translateY(-8px) scale(1.02);
  border-color: var(--color-primary);
  box-shadow: var(--shadow-xl), var(--shadow-glow);
}

.glass-card:hover::before {
  opacity: 1;
}

/* 3D Depth Effect */
.depth-3d {
  position: relative;
  transform-style: preserve-3d;
  transition: transform var(--transition-slow);
}

.depth-3d::after {
  content: '';
  position: absolute;
  top: var(--depth-2);
  left: var(--depth-2);
  right: calc(-1 * var(--depth-2));
  bottom: calc(-1 * var(--depth-2));
  background: linear-gradient(135deg, var(--bg-elevated) 0%, transparent 100%);
  border-radius: var(--radius-xl);
  z-index: -1;
  opacity: 0.5;
  filter: blur(8px);
}

.depth-3d:hover {
  transform: translateZ(var(--depth-3));
}

/* ============================================
   5. BENTO BOX GRID SYSTEM
   ============================================ */

.bento-grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(12, 1fr);
  grid-auto-rows: minmax(200px, auto);
}

/* Featured Card - 2x2 */
.bento-featured {
  grid-column: span 6;
  grid-row: span 2;
  min-height: 500px;
}

/* Large Card - 2x1 */
.bento-large {
  grid-column: span 6;
  grid-row: span 1;
  min-height: 250px;
}

/* Medium Card - 1x1 */
.bento-medium {
  grid-column: span 4;
  grid-row: span 1;
  min-height: 250px;
}

/* Small Card - 1x1 */
.bento-small {
  grid-column: span 3;
  grid-row: span 1;
  min-height: 200px;
}

/* Wide Card - 3x1 */
.bento-wide {
  grid-column: span 12;
  grid-row: span 1;
  min-height: 300px;
}

/* Tall Card - 1x2 */
.bento-tall {
  grid-column: span 4;
  grid-row: span 2;
  min-height: 500px;
}

/* ============================================
   6. ADVANCED ANIMATIONS
   ============================================ */

/* Fade In with Blur */
@keyframes fadeInBlur {
  from {
    opacity: 0;
    filter: blur(10px);
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    filter: blur(0);
    transform: translateY(0);
  }
}

/* Scale In */
@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Slide In with Bounce */
@keyframes slideInBounce {
  0% {
    opacity: 0;
    transform: translateX(-50px);
  }
  60% {
    opacity: 1;
    transform: translateX(10px);
  }
  100% {
    transform: translateX(0);
  }
}

/* Glow Pulse */
@keyframes glowPulse {
  0%, 100% {
    box-shadow: 0 0 20px rgba(0, 217, 255, 0.3);
  }
  50% {
    box-shadow: 0 0 40px rgba(0, 217, 255, 0.6);
  }
}

/* Floating Animation */
@keyframes float {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-20px);
  }
}

/* Rotate Subtle */
@keyframes rotateSubtle {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Animation Classes */
.animate-fade-in-blur {
  animation: fadeInBlur 0.8s var(--transition-base) both;
}

.animate-scale-in {
  animation: scaleIn 0.6s var(--transition-base) both;
}

.animate-slide-bounce {
  animation: slideInBounce 0.8s var(--transition-bounce) both;
}

.animate-glow {
  animation: glowPulse 2s ease-in-out infinite;
}

.animate-float {
  animation: float 3s ease-in-out infinite;
}

.animate-rotate {
  animation: rotateSubtle 20s linear infinite;
}

/* Stagger Delays */
.delay-100 { animation-delay: 100ms; }
.delay-200 { animation-delay: 200ms; }
.delay-300 { animation-delay: 300ms; }
.delay-400 { animation-delay: 400ms; }
.delay-500 { animation-delay: 500ms; }
.delay-600 { animation-delay: 600ms; }
.delay-700 { animation-delay: 700ms; }
.delay-800 { animation-delay: 800ms; }

/* ============================================
   7. MICRO-INTERACTIONS
   ============================================ */

/* Enhanced Button Hover */
.btn-interactive {
  position: relative;
  overflow: hidden;
  transition: all var(--transition-base);
}

.btn-interactive::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.btn-interactive:hover::before {
  width: 300px;
  height: 300px;
}

.btn-interactive:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
}

/* Card Tilt Effect */
.card-tilt {
  transition: transform var(--transition-slow);
  transform-style: preserve-3d;
}

.card-tilt:hover {
  transform: perspective(1000px) rotateX(2deg) rotateY(2deg);
}

/* Icon Spin on Hover */
.icon-spin:hover {
  animation: rotateSubtle 1s ease-in-out;
}

/* Ripple Effect */
.ripple {
  position: relative;
  overflow: hidden;
}

.ripple::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.ripple:active::after {
  width: 200px;
  height: 200px;
}

/* ============================================
   8. PERSONA-ADAPTIVE LAYOUTS
   ============================================ */

/* Executive Persona - Premium & Minimal */
[data-persona="C_Suite_Executive"] .hero {
  background: radial-gradient(ellipse at top, rgba(52, 152, 219, 0.1) 0%, transparent 70%);
}

[data-persona="C_Suite_Executive"] .glass-card {
  background: linear-gradient(135deg, rgba(52, 152, 219, 0.1) 0%, rgba(15, 22, 41, 0.7) 100%);
}

/* Government Persona - Authoritative */
[data-persona="Government_Official"] .hero {
  background: radial-gradient(ellipse at top, rgba(46, 204, 113, 0.1) 0%, transparent 70%);
}

[data-persona="Government_Official"] .glass-card {
  border-color: rgba(46, 204, 113, 0.3);
}

/* Royal Persona - Luxurious */
[data-persona="Royal_Family"] .hero {
  background: radial-gradient(ellipse at top, rgba(184, 154, 106, 0.15) 0%, transparent 70%);
}

[data-persona="Royal_Family"] .glass-card {
  background: linear-gradient(135deg, rgba(184, 154, 106, 0.15) 0%, rgba(15, 22, 41, 0.7) 100%);
  border-color: rgba(184, 154, 106, 0.4);
}

/* Startup Persona - Energetic */
[data-persona="Startup_Founder"] .hero {
  background: radial-gradient(ellipse at top, rgba(241, 196, 15, 0.1) 0%, transparent 70%);
}

[data-persona="Startup_Founder"] .bento-grid {
  gap: var(--space-3);
}

/* ============================================
   9. MOBILE-FIRST RESPONSIVE
   ============================================ */

/* Base Mobile Styles (< 640px) */
@media (max-width: 639px) {
  :root {
    --space-6: 32px;
    --space-8: 48px;
    --space-10: 64px;
  }
  
  .bento-grid {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }
  
  .bento-featured,
  .bento-large,
  .bento-medium,
  .bento-small,
  .bento-wide,
  .bento-tall {
    grid-column: span 1;
    grid-row: span 1;
    min-height: 250px;
  }
  
  .glass-card {
    padding: var(--space-4);
  }
}

/* Tablet (640px - 1023px) */
@media (min-width: 640px) and (max-width: 1023px) {
  .bento-grid {
    grid-template-columns: repeat(6, 1fr);
    gap: var(--space-3);
  }
  
  .bento-featured {
    grid-column: span 6;
    grid-row: span 2;
  }
  
  .bento-large,
  .bento-wide {
    grid-column: span 6;
  }
  
  .bento-medium,
  .bento-tall {
    grid-column: span 3;
  }
  
  .bento-small {
    grid-column: span 2;
  }
}

/* Desktop (1024px+) */
@media (min-width: 1024px) {
  .bento-grid {
    grid-template-columns: repeat(12, 1fr);
  }
}

/* Touch-Friendly Targets */
@media (hover: none) {
  a, button, .btn-interactive {
    min-height: 44px;
    min-width: 44px;
  }
}

/* ============================================
   10. RTL SUPPORT
   ============================================ */

[dir="rtl"] {
  direction: rtl;
}

[dir="rtl"] .bento-grid {
  direction: rtl;
}

[dir="rtl"] .glass-card {
  direction: rtl;
}

/* Mirror animations for RTL */
[dir="rtl"] .animate-slide-bounce {
  animation-name: slideInBounceRTL;
}

@keyframes slideInBounceRTL {
  0% {
    opacity: 0;
    transform: translateX(50px);
  }
  60% {
    opacity: 1;
    transform: translateX(-10px);
  }
  100% {
    transform: translateX(0);
  }
}

/* ============================================
   11. LOADING & SKELETON STATES
   ============================================ */

.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-elevated) 0%,
    var(--bg-overlay) 50%,
    var(--bg-elevated) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 2s infinite;
  border-radius: var(--radius-md);
}

@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

.skeleton-text {
  height: 1em;
  margin-bottom: var(--space-2);
}

.skeleton-heading {
  height: 2em;
  width: 60%;
  margin-bottom: var(--space-3);
}

.skeleton-card {
  height: 200px;
  width: 100%;
}

/* ============================================
   12. PERFORMANCE OPTIMIZATIONS
   ============================================ */

/* GPU Acceleration */
.gpu-accelerated {
  transform: translateZ(0);
  will-change: transform;
}

/* Reduce Motion for Accessibility */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Dark Mode Enhancement */
@media (prefers-color-scheme: dark) {
  :root {
    --glass-opacity: 0.8;
  }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
  .glass-card {
    border-width: 2px;
  }
}

/* ============================================
   13. UTILITY CLASSES
   ============================================ */

/* Spacing Utilities */
.m-0 { margin: 0; }
.m-1 { margin: var(--space-1); }
.m-2 { margin: var(--space-2); }
.m-3 { margin: var(--space-3); }
.m-4 { margin: var(--space-4); }
.m-5 { margin: var(--space-5); }
.m-6 { margin: var(--space-6); }
.m-8 { margin: var(--space-8); }

.p-0 { padding: 0; }
.p-1 { padding: var(--space-1); }
.p-2 { padding: var(--space-2); }
.p-3 { padding: var(--space-3); }
.p-4 { padding: var(--space-4); }
.p-5 { padding: var(--space-5); }
.p-6 { padding: var(--space-6); }
.p-8 { padding: var(--space-8); }

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

/* Text Utilities */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

/* Display Utilities */
.hidden { display: none; }
.block { display: block; }
.inline-block { display: inline-block; }

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

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

/* ============================================
   14. PRINT STYLES
   ============================================ */

@media print {
  body {
    background: white;
    color: black;
  }
  
  .glass-card {
    background: white;
    border: 1px solid black;
  }
  
  nav,
  footer,
  .btn-interactive {
    display: none;
  }
}
