/* ============================================
   CARBONPESA DESIGN SYSTEM
   Version 2.0.0
   ============================================ */

/* --- Design Tokens --- */

:root {
  /* Brand Core - Green Scale */
  --green-900: #1B3A18;
  --green-800: #2D5A27;
  --green-700: #3A7332;
  --green-600: #4A8D3D;
  --green-500: #5BAA48;
  --green-100: #E8F5E3;
  --green-50:  #F4FAF2;

  /* Mint / Accent */
  --mint-500: #70E000;
  --mint-400: #8AE835;
  --mint-300: #A5F06A;
  --mint-100: #E7FBD1;

  /* Gold / Pesa */
  --gold-600: #D49D00;
  --gold-500: #F4B400;
  --gold-400: #F7C948;
  --gold-100: #FEF3D0;

  /* Neutral / Slate */
  --slate-900: #1A2428;
  --slate-800: #2F3E46;
  --slate-700: #3D5159;
  --slate-600: #4E6670;
  --slate-400: #8BA3AD;
  --slate-200: #C5D4DA;
  --slate-100: #E4ECEF;
  --slate-50:  #F3F7F8;

  /* Semantic aliases */
  --color-primary: var(--green-800);
  --color-primary-dark: var(--green-900);
  --color-primary-light: var(--green-100);
  --color-accent: var(--mint-500);
  --color-gold: var(--gold-500);
  --color-text: var(--slate-900);
  --color-text-secondary: var(--slate-600);
  --color-text-muted: var(--slate-400);
  --color-bg: #FFFFFF;
  --color-bg-alt: var(--slate-50);
  --color-bg-warm: var(--green-50);
  --color-border: var(--slate-200);

  /* Theme-aware surface colors (Light mode defaults) */
  --surface-primary: #FFFFFF;
  --surface-secondary: #F3F7F8;
  --surface-tertiary: #E4ECEF;
  --surface-elevated: #FFFFFF;
  --surface-glass: rgba(255, 255, 255, 0.85);
  --surface-glass-border: rgba(0, 0, 0, 0.08);

  /* Theme-aware text colors (Light mode defaults) */
  --text-primary: #1A2428;
  --text-secondary: #4E6670;
  --text-muted: #8BA3AD;
  --text-inverse: #FFFFFF;

  /* Theme-aware card colors (Light mode defaults) */
  --card-bg: #FFFFFF;
  --card-border: #E4ECEF;
  --card-hover-shadow: 0 8px 32px rgba(26, 36, 40, 0.12);

  /* Theme-aware border colors (Light mode defaults) */
  --border-default: #C5D4DA;
  --border-subtle: rgba(0, 0, 0, 0.06);

  /* Gradients */
  --gradient-hero: linear-gradient(135deg, #1B3A18 0%, #2D5A27 40%, #1A2428 100%);
  --gradient-forest: linear-gradient(180deg, #2D5A27 0%, #1B3A18 60%, #0F2210 100%);
  --gradient-dawn: linear-gradient(135deg, #F4FAF2 0%, #FEF3D0 50%, #E7FBD1 100%);
  --gradient-mesh: radial-gradient(ellipse at 20% 80%, rgba(112,224,0,0.12) 0%, transparent 50%),
                   radial-gradient(ellipse at 80% 20%, rgba(244,180,0,0.08) 0%, transparent 50%),
                   radial-gradient(ellipse at 50% 50%, rgba(45,90,39,0.04) 0%, transparent 70%);
  --gradient-glass: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.02) 100%);

  /* Functional */
  --color-error: #DC3545;
  --color-success: #28A745;
  --color-warning: #FFC107;
  --color-info: #17A2B8;

  /* Typography */
  --font-display: 'Montserrat', 'Public Sans', system-ui, sans-serif;
  --font-body: 'Inter', 'Public Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

  /* Type Scale */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 2rem;
  --text-4xl: 2.5rem;
  --text-5xl: 3.25rem;
  --text-6xl: 4rem;

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4rem;
  --space-9: 6rem;
  --space-10: 8rem;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(26, 36, 40, 0.05);
  --shadow-sm: 0 2px 8px rgba(26, 36, 40, 0.06);
  --shadow-md: 0 4px 16px rgba(26, 36, 40, 0.08);
  --shadow-lg: 0 8px 32px rgba(26, 36, 40, 0.12);
  --shadow-xl: 0 16px 48px rgba(26, 36, 40, 0.16);
  --shadow-glow-green: 0 0 40px rgba(45, 90, 39, 0.15);
  --shadow-glow-gold: 0 0 40px rgba(244, 180, 0, 0.15);

  /* Border Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.75rem;
  --radius-lg: 1.25rem;
  --radius-xl: 2rem;
  --radius-full: 9999px;

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --duration-fast: 200ms;
  --duration-normal: 350ms;
  --duration-slow: 600ms;

  /* Layout */
  --container-max: 1200px;
  --container-wide: 1400px;
  --header-height: 80px;
}

/* --- Dark Mode Overrides --- */

.dark {
  --surface-primary: #1A2428;
  --surface-secondary: #2F3E46;
  --surface-tertiary: #3D5159;
  --surface-elevated: #2F3E46;
  --surface-glass: rgba(47, 62, 70, 0.90);
  --surface-glass-border: rgba(255, 255, 255, 0.06);

  --text-primary: #E4ECEF;
  --text-secondary: #C5D4DA;
  --text-muted: #8BA3AD;
  --text-inverse: #1A2428;

  --card-bg: rgba(255, 255, 255, 0.05);
  --card-border: rgba(255, 255, 255, 0.10);
  --card-hover-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);

  --border-default: rgba(255, 255, 255, 0.10);
  --border-subtle: rgba(255, 255, 255, 0.05);

  --color-bg: var(--surface-primary);
  --color-bg-alt: var(--surface-secondary);
  --color-text: var(--text-primary);
  --color-text-secondary: var(--text-secondary);
  --color-text-muted: var(--text-muted);
  --color-border: var(--border-default);
}

/* Force-dark: locks dark values on hero/CTA sections regardless of theme */
.force-dark {
  --surface-primary: #1A2428;
  --surface-secondary: #2F3E46;
  --surface-tertiary: #3D5159;
  --surface-elevated: #2F3E46;
  --surface-glass: rgba(47, 62, 70, 0.90);
  --surface-glass-border: rgba(255, 255, 255, 0.06);

  --text-primary: #E4ECEF;
  --text-secondary: #C5D4DA;
  --text-muted: #8BA3AD;
  --text-inverse: #1A2428;

  --card-bg: rgba(255, 255, 255, 0.05);
  --card-border: rgba(255, 255, 255, 0.10);
  --card-hover-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);

  --border-default: rgba(255, 255, 255, 0.10);
  --border-subtle: rgba(255, 255, 255, 0.05);

  color: #E4ECEF;
}

/* --- Reset & Base ---
 * Wrapped in @layer base so Tailwind utility classes can override.
 */
@layer base {
  body {
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: 1.7;
    color: var(--color-text);
    background-color: var(--color-bg);
    overflow-x: hidden;
  }

  a {
    text-decoration: none;
    transition: color var(--duration-fast) var(--ease-out);
  }

  h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    line-height: 1.15;
  }

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

  strong, b { font-weight: 700; }

  pre {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    background: var(--slate-900);
    color: var(--mint-300);
    padding: var(--space-5);
    border-radius: var(--radius-md);
    overflow-x: auto;
    line-height: 1.6;
  }

  code {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    background: var(--green-50);
    color: var(--green-800);
    padding: 0.15em 0.4em;
    border-radius: var(--radius-sm);
  }

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

/* Design-system component classes (not in a layer — used directly) */
.lead {
  font-size: var(--text-xl);
  line-height: 1.6;
  color: var(--color-text-secondary);
}

.overline {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--color-accent);
  display: block;
  margin-bottom: var(--space-3);
}

.display-number {
  font-family: var(--font-display);
  font-size: clamp(var(--text-4xl), 7vw, var(--text-6xl));
  color: var(--color-gold);
  line-height: 1;
}

/* --- Layout --- */

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

.container--wide {
  max-width: var(--container-wide);
}

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

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

.section--dark {
  background: var(--gradient-hero);
  color: #FFFFFF;
}

.section--dark h1,
.section--dark h2,
.section--dark h3,
.section--dark h4,
.section--dark h5 {
  color: #FFFFFF;
}

.section--dark p {
  color: rgba(255, 255, 255, 0.75);
}

.section--dark .overline {
  color: var(--mint-400);
}

.section--alt {
  background: var(--color-bg-alt);
}

.section--warm {
  background: var(--gradient-dawn);
}

.section-header {
  max-width: 680px;
  margin-bottom: var(--space-8);
}

.section-header--center {
  text-align: center;
  margin-left: auto;
  margin-right: auto;
}

/* Grid system — BEM variants only (Tailwind handles .grid base) */
.grid--2, .grid--3, .grid--4, .grid--auto-fit {
  display: grid;
  gap: var(--space-6);
}

.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--4 { grid-template-columns: repeat(4, 1fr); }

.grid--auto-fit {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

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

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

  .section { padding: var(--space-8) 0; }
  .section--lg { padding: var(--space-9) 0; }
}

/* --- Texture Utilities --- */

.texture-grain {
  position: relative;
}

.texture-grain::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url('../images/grain-overlay.svg');
  background-repeat: repeat;
  opacity: 0.04;
  pointer-events: none;
  z-index: 1;
}

.texture-topo {
  position: relative;
}

.texture-topo::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url('../images/topo-pattern.svg');
  background-repeat: repeat;
  background-size: 400px 400px;
  opacity: 0.04;
  pointer-events: none;
  z-index: 1;
}

.texture-mesh {
  background-image: var(--gradient-mesh);
}

/* Ensure content sits above texture layers */
.texture-grain > *,
.texture-topo > * {
  position: relative;
  z-index: 2;
}

/* --- Scroll Animation Base --- */

.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity var(--duration-slow) var(--ease-out),
              transform var(--duration-slow) var(--ease-out);
}

.reveal--left {
  opacity: 0;
  transform: translateX(-40px);
  transition: opacity var(--duration-slow) var(--ease-out),
              transform var(--duration-slow) var(--ease-out);
}

.reveal--right {
  opacity: 0;
  transform: translateX(40px);
  transition: opacity var(--duration-slow) var(--ease-out),
              transform var(--duration-slow) var(--ease-out);
}

.reveal--scale {
  opacity: 0;
  transform: scale(0.92);
  transition: opacity var(--duration-slow) var(--ease-out),
              transform var(--duration-slow) var(--ease-out);
}

.reveal--fade {
  opacity: 0;
  transition: opacity var(--duration-slow) var(--ease-out);
}

.reveal.is-visible,
.reveal--left.is-visible,
.reveal--right.is-visible,
.reveal--scale.is-visible,
.reveal--fade.is-visible {
  opacity: 1;
  transform: none;
}

/* Stagger delays */
[data-stagger-index="1"] { transition-delay: 0.1s; }
[data-stagger-index="2"] { transition-delay: 0.2s; }
[data-stagger-index="3"] { transition-delay: 0.3s; }
[data-stagger-index="4"] { transition-delay: 0.4s; }
[data-stagger-index="5"] { transition-delay: 0.5s; }
[data-stagger-index="6"] { transition-delay: 0.6s; }

/* When GSAP is active, disable CSS reveals — GSAP handles everything */
.gsap-active .reveal,
.gsap-active .reveal--left,
.gsap-active .reveal--right,
.gsap-active .reveal--scale,
.gsap-active .reveal--fade {
  opacity: 1;
  transform: none;
  transition: none;
}

.gsap-active [data-stagger-index] {
  transition-delay: 0s;
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .reveal,
  .reveal--left,
  .reveal--right,
  .reveal--scale,
  .reveal--fade {
    opacity: 1;
    transform: none;
    transition: none;
  }

  [data-stagger-index] {
    transition-delay: 0s;
  }
}

/* --- Utility Classes ---
 * Layout/spacing utilities removed — Tailwind CSS provides all utilities.
 * Keeping only design-system-specific helpers not covered by Tailwind.
 */
