/* =================================================================
   DMA Academy Design System
   A refined, production-grade design system built for scale
   ================================================================= */

/* Typography Scale - Fluid, Responsive */
:root {
  /* Brand Colors - Warm, Academic, Premium */
  --color-surface-base: #fdfbf7;
  --color-surface-elevated: #ffffff;
  --color-surface-sunken: #f5f1ea;
  --color-border-subtle: #e8e2d6;
  --color-border-default: #d4cabb;
  --color-border-strong: #b8ac94;
  
  /* Semantic Colors */
  --color-text-primary: #1a1816;
  --color-text-secondary: #625a4a;
  --color-text-tertiary: #948975;
  --color-text-inverse: #ffffff;
  
  --color-brand-primary: #c4521a;
  --color-brand-primary-hover: #a64416;
  --color-brand-secondary: #16534f;
  --color-brand-secondary-hover: #0f3d3a;
  
  --color-accent-rust: #d4672e;
  --color-accent-teal: #1e7a73;
  --color-accent-sand: #e6d7c3;
  
  --color-success: #0e7c5a;
  --color-warning: #b57219;
  --color-error: #c93838;
  --color-info: #1e7a73;
  
  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Bricolage Grotesque', 'Inter', sans-serif;
  
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.825rem + 0.25vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.125rem,1.05rem + 0.375vw, 1.375rem);
  --text-xl: clamp(1.25rem, 1.15rem + 0.5vw, 1.625rem);
  --text-2xl: clamp(1.5rem, 1.35rem + 0.75vw, 2rem);
  --text-3xl: clamp(1.875rem, 1.65rem + 1.125vw, 2.625rem);
  --text-4xl: clamp(2.25rem, 1.95rem + 1.5vw, 3.25rem);
  
  /* Spacing Scale - T-shirt sizing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;
  
  /* Layout */
  --container-sm: 640px;
  --container-md: 768px;
  --container-lg: 1024px;
  --container-xl: 1280px;
  --container-2xl: 1440px;
  
  /* Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-2xl: 1.5rem;
  --radius-full: 9999px;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.05);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.05);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.08), 0 8px 10px -6px rgb(0 0 0 / 0.05);
  
  /* Transitions */
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
  --duration-fast: 150ms;
  --duration-base: 250ms;
  --duration-slow: 350ms;
}

/* Dark Theme Override */
[data-theme="dark"] {
  --color-surface-base: #111315;
  --color-surface-elevated: #1b1f24;
  --color-surface-sunken: #0f1216;
  --color-border-subtle: #2e3640;
  --color-border-default: #46525f;
  --color-border-strong: #6d7a89;
  
  --color-text-primary: #f5f7fa;
  --color-text-secondary: #d9e0e8;
  --color-text-tertiary: #b7c1cd;
  --color-text-inverse: #ffffff;
  
  --color-brand-primary: #ff8a3d;
  --color-brand-primary-hover: #ff9f5c;
  --color-brand-secondary: #35c4b5;
  --color-brand-secondary-hover: #5ed7ca;
  
  --color-accent-rust: #ffab6f;
  --color-accent-teal: #79e4d9;
  --color-accent-sand: #8d99a8;
  
  --color-success: #40d17f;
  --color-warning: #ffb25b;
  --color-error: #ff6f6f;
  --color-info: #4fd6c8;
  
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.6);
  --shadow-md: 0 4px 8px -2px rgb(0 0 0 / 0.7), 0 2px 4px -2px rgb(0 0 0 / 0.6);
  --shadow-lg: 0 12px 20px -4px rgb(0 0 0 / 0.8), 0 4px 8px -4px rgb(0 0 0 / 0.7);
  --shadow-xl: 0 24px 32px -8px rgb(0 0 0 / 0.9), 0 8px 12px -6px rgb(0 0 0 / 0.8);
}

/* =================================================================
   Reset & Base
   ================================================================= */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
 scroll-behavior: smooth;
}

@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-sans);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--color-text-primary);
  background: var(--color-surface-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  position: relative;
  min-height: 100vh;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* =================================================================
   Typography
   ================================================================= */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl); }
h5 { font-size: var(--text-lg); }
h6 { font-size: var(--text-base); font-weight: 600; }

p { margin-bottom: var(--space-4); }
p:last-child { margin-bottom: 0; }

.text-muted {
  color: var(--color-text-secondary);
}

.text-subtle {
  color: var(--color-text-tertiary);
}

/* =================================================================
   Layout Components
   ================================================================= */

.background-grain {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: 
    radial-gradient(circle at 30% 20%, rgba(228, 211, 187, 0.15) 0%, transparent 50%),
    radial-gradient(circle at 70% 80%, rgba(196, 82, 26, 0.08) 0%, transparent 50%),
    var(--color-surface-base);
  
}

[data-theme="dark"] .background-grain {
  background:
    radial-gradient(circle at 30% 20%, rgba(53, 196, 181, 0.12) 0%, transparent 50%),
    radial-gradient(circle at 70% 80%, rgba(255, 138, 61, 0.1) 0%, transparent 52%),
    var(--color-surface-base);
}

.background-grain::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.5' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.03'/%3E%3C/svg%3E");
  opacity: 0.5;
  pointer-events: none;
}

.container {
  width: 100%;
  max-width: var(--container-xl);
  margin-inline: auto;
  padding-inline: var(--space-4);
}

@media (min-width: 769px) {
  .container {
    padding-inline: var(--space-6);
  }
}

.container-narrow {
  max-width: var(--container-lg);
}

/* =================================================================
   Navigation
   ================================================================= */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--color-surface-base);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  backdrop-filter: blur(12px) saturate(180%);
  border-bottom: 1px solid var(--color-border-subtle);
  transition: box-shadow var(--duration-base) var(--ease-smooth), border-color var(--duration-base) var(--ease-smooth), background-color var(--duration-base) var(--ease-smooth);
  will-change: box-shadow;
  transform: translateZ(0);
  backface-visibility: hidden;
}

.site-header.scrolled {
  box-shadow: var(--shadow-sm);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  gap: var(--space-3);
  padding-block: var(--space-2);
  flex-wrap: wrap;
}

@media (min-width: 769px) {
  .header-inner {
    min-height: 72px;
    padding-block: 0;
    flex-wrap: nowrap;
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  color: inherit;
  transition: opacity var(--duration-fast);
}

.brand:hover {
  opacity: 0.8;
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-lg);
  object-fit: cover;
  border: 1px solid var(--color-border-subtle);
}

@media (min-width: 769px) {
  .brand-logo {
    width: 48px;
    height: 48px;
  }
}

.brand-text h1 {
  font-size: var(--text-base);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.brand-text p {
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
  margin: 0;
  display: none;
}

@media (min-width: 769px) {
  .brand-text h1 {
    font-size: var(--text-xl);
  }
  .brand-text p {
    display: block;
  }
}

/* Main Navigation */
.main-nav {
  display: flex;
  align-items: center;
  gap: 0;
  order: 3;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: var(--space-1);
}

.main-nav::-webkit-scrollbar {
  display: none;
}

@media (min-width: 769px) {
  .main-nav {
    order: 0;
    width: auto;
    overflow-x: visible;
    gap: var(--space-2);
    padding-bottom: 0;
  }
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-secondary);
  text-decoration: none;
  border-radius: var(--radius-md);
  transition: all var(--duration-fast) var(--ease-smooth);
  position: relative;
  white-space: nowrap;
  min-height: 44px;
}

@media (min-width: 769px) {
  .nav-link {
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-sm);
    min-height: auto;
  }
}

.nav-link:hover {
  color: var(--color-text-primary);
  background: var(--color-surface-sunken);
}

.nav-link.active {
  color: var(--color-brand-primary);
  background: var(--color-accent-sand);
}

.nav-link.active::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: var(--space-4);
  right: var(--space-4);
  height: 2px;
  background: var(--color-brand-primary);
  border-radius: var(--radius-full);
}

/* =================================================================
   Form Elements
   ================================================================= */

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-primary);
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-base);
  font-family: inherit;
  color: var(--color-text-primary);
  background: var(--color-surface-elevated);
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-md);
  transition: all var(--duration-fast) var(--ease-smooth);
  outline: none;
}

.form-input:hover,
.form-textarea:hover,
.form-select:hover {
  border-color: var(--color-border-strong);
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  border-color: var(--color-brand-primary);
  box-shadow: 0 0 0 3px rgba(196, 82, 26, 0.1);
}

.form-input:disabled,
.form-textarea:disabled,
.form-select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.form-textarea {
  min-height: 120px;
  resize: vertical;
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
}

.form-error {
  font-size: var(--text-xs);
  color: var(--color-error);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

/* =================================================================
   Buttons
   ================================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-sm);
  font-weight: 600;
  font-family: inherit;
  text-decoration: none;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--duration-base) var(--ease-smooth);
  white-space: nowrap;
  outline: none;
}

.btn:focus-visible {
  outline: 2px solid var(--color-brand-primary);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Button Variants */
.btn-primary {
  background: var(--color-brand-primary);
  color: var(--color-text-inverse);
}

.btn-primary:hover {
  background: var(--color-brand-primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--color-brand-secondary);
  color: var(--color-text-inverse);
}

.btn-secondary:hover {
  background: var(--color-brand-secondary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border-default);
}

.btn-ghost:hover {
  background: var(--color-surface-sunken);
  border-color: var(--color-border-strong);
  color: var(--color-text-primary);
}

.btn-danger {
  background: var(--color-error);
  color: var(--color-text-inverse);
}

.btn-danger:hover {
  background: #b02f2f;
}

/* Button Sizes */
.btn-sm {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
}

.btn-lg {
  padding: var(--space-4) var(--space-6);
  font-size: var(--text-base);
}

/* =================================================================
   Cards & Panels
   ================================================================= */

.card {
  background: var(--color-surface-elevated);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
  transition: all var(--duration-base) var(--ease-smooth);
}

.card-interactive {
  cursor: pointer;
}

.card-interactive:hover {
  border-color: var(--color-border-default);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-border-subtle);
}

.card-title {
  font-size: var(--text-lg);
  font-weight: 600;
  margin: 0;
}

.card-body {
  color: var(--color-text-secondary);
}

/* =================================================================
   Utility Classes
   ================================================================= */

.hidden {
  display: none !important;
}

.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;
}

.stack {
  display: flex;
  flex-direction: column;
}

.stack > * + * {
  margin-top: var(--space-4);
}

.stack-sm > * + * {
  margin-top: var(--space-2);
}

.stack-lg > * + * {
  margin-top: var(--space-6);
}

.cluster {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
}

.grid {
  display: grid;
  gap: var(--space-6);
}

.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
}

.grid-3 {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr));
}

/* =================================================================
   Status & Feedback
   ================================================================= */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  font-weight: 600;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-success {
  background: rgba(14, 124, 90, 0.1);
  color: var(--color-success);
}

.badge-warning {
  background: rgba(181, 114, 25, 0.1);
  color: var(--color-warning);
}

.badge-error {
  background: rgba(201, 56, 56, 0.1);
  color: var(--color-error);
}

.badge-info {
  background: rgba(30, 122, 115, 0.1);
  color: var(--color-info);
}

.alert {
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  border: 1px solid;
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}

.alert-success {
  background: rgba(14, 124, 90, 0.05);
  border-color: rgba(14, 124, 90, 0.2);
  color: var(--color-success);
}

.alert-error {
  background: rgba(201, 56, 56, 0.05);
  border-color: rgba(201, 56, 56, 0.2);
  color: var(--color-error);
}

/* =================================================================
   Animations
   ================================================================= */

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.fade-in {
  animation: fadeIn var(--duration-base) var(--ease-smooth) backwards;
}

.slide-up {
  animation: slideUp var(--duration-slow) var(--ease-smooth) backwards;
}

.stagger-children > * {
  animation: fadeIn var(--duration-base) var(--ease-smooth) backwards;
}

.stagger-children > *:nth-child(1) { animation-delay: 0ms; }
.stagger-children > *:nth-child(2) { animation-delay: 50ms; }
.stagger-children > *:nth-child(3) { animation-delay: 100ms; }
.stagger-children > *:nth-child(4) { animation-delay: 150ms; }
.stagger-children > *:nth-child(5) { animation-delay: 200ms; }
.stagger-children > *:nth-child(6) { animation-delay: 250ms; }

/* =================================================================
   Responsive (mobile-first overrides handled inline above)
   ================================================================= */

@media (max-width: 768px) {
  .card {
    padding: var(--space-4);
  }
}
