/* ============================================================
   EMS TEXTILES — base.css
   Design Tokens · Reset · Typography · Layout
   ============================================================ */

/* ── Google Fonts ─────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700;800&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

/* ── Brand Design Tokens (Light Theme Default) ────────────── */
:root {
  /* Core brand gradient — extracted from new EMS logo */
  --ems-navy-900:    #07123f;
  --ems-navy-800:    #0a1e6e;
  --ems-blue-700:    #0d2a8c;
  --ems-blue-600:    #1747d1;
  --ems-blue-500:    #2563eb;
  --ems-blue-400:    #3b82f6;
  --ems-cyan-400:    #38bdf8;
  --ems-cyan-300:    #7dd3fc;

  /* Signal / accent */
  --signal-glow:     #60d4ff;
  --success:         #22c55e;
  --warning:         #f59e0b;
  --danger:          #ef4444;

  /* ── Light theme surfaces ── */
  --bg:              #f7f9fc;
  --bg-alt:          #eef2f9;
  --surface:         #ffffff;
  --surface-2:       #f0f5ff;

  /* ── Light theme text ── */
  --text-primary:    #0a1330;
  --text-secondary:  #4b5675;
  --text-muted:      #7a89a8;

  /* ── Light theme borders ── */
  --border:          rgba(10, 30, 110, 0.10);
  --border-strong:   rgba(10, 30, 110, 0.20);

  /* ── Semantic shortcuts (used in components) ── */
  --brand:           var(--ems-blue-500);
  --brand-dark:      var(--ems-navy-800);
  --brand-light:     var(--ems-cyan-400);
  --brand-gradient:  linear-gradient(135deg, var(--ems-navy-800) 0%, var(--ems-blue-500) 55%, var(--ems-cyan-400) 100%);
  --brand-gradient-r: linear-gradient(225deg, var(--ems-navy-800) 0%, var(--ems-blue-500) 55%, var(--ems-cyan-400) 100%);

  /* ── Shadows ── */
  --shadow-sm:       0 1px 3px rgba(7, 18, 63, 0.08), 0 1px 2px rgba(7, 18, 63, 0.06);
  --shadow-md:       0 4px 16px rgba(7, 18, 63, 0.10), 0 2px 6px rgba(7, 18, 63, 0.06);
  --shadow-lg:       0 16px 48px rgba(7, 18, 63, 0.14), 0 4px 12px rgba(7, 18, 63, 0.08);
  --shadow-glow:     0 0 32px rgba(37, 99, 235, 0.25);
  --shadow-glow-sm:  0 0 12px rgba(56, 189, 248, 0.30);

  /* ── Spacing scale ── */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  24px;
  --space-6:  32px;
  --space-7:  48px;
  --space-8:  64px;
  --space-9:  80px;
  --space-10: 96px;
  --space-11: 128px;

  /* ── Border radius ── */
  --radius-sm:  8px;
  --radius-md:  12px;
  --radius-lg:  16px;
  --radius-xl:  20px;
  --radius-2xl: 24px;
  --radius-full: 9999px;

  /* ── Motion tokens ── */
  --ease-out:    cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.45, 0, 0.55, 1);
  --duration-fast:   150ms;
  --duration-base:   250ms;
  --duration-slow:   400ms;
  --duration-reveal: 600ms;

  /* ── Typography ── */
  --font-heading: 'Space Grotesk', system-ui, sans-serif;
  --font-body:    'Plus Jakarta Sans', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', 'Fira Code', monospace;

  /* ── Nav ── */
  --nav-height:    72px;
  --nav-bg:        rgba(255, 255, 255, 0.90);
  --nav-border:    rgba(10, 30, 110, 0.08);

  /* ── Logo display per theme ── */
  --logo-src-main:  url('/assets/ems-logo-transparent.png');
}

/* ── Dark Theme Overrides ─────────────────────────────────── */
[data-theme="dark"] {
  --bg:              #060b1f;
  --bg-alt:          #0a1228;
  --surface:         #0e1630;
  --surface-2:       #111e3a;

  --text-primary:    #f3f6ff;
  --text-secondary:  #9aa6c8;
  --text-muted:      #5a6a90;

  --border:          rgba(59, 130, 246, 0.12);
  --border-strong:   rgba(59, 130, 246, 0.25);

  --shadow-sm:       0 1px 3px rgba(0, 0, 0, 0.30);
  --shadow-md:       0 4px 16px rgba(0, 0, 0, 0.40);
  --shadow-lg:       0 16px 48px rgba(0, 0, 0, 0.55);
  --shadow-glow:     0 0 40px rgba(37, 99, 235, 0.35);
  --shadow-glow-sm:  0 0 16px rgba(56, 189, 248, 0.40);

  --nav-bg:          rgba(6, 11, 31, 0.92);
  --nav-border:      rgba(59, 130, 246, 0.12);
  --surface:         #0e1630;
}

/* ── Prefers-color-scheme fallback (before JS loads) ─────── */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:              #060b1f;
    --bg-alt:          #0a1228;
    --surface:         #0e1630;
    --surface-2:       #111e3a;
    --text-primary:    #f3f6ff;
    --text-secondary:  #9aa6c8;
    --text-muted:      #5a6a90;
    --border:          rgba(59, 130, 246, 0.12);
    --border-strong:   rgba(59, 130, 246, 0.25);
    --shadow-sm:       0 1px 3px rgba(0,0,0,.30);
    --shadow-md:       0 4px 16px rgba(0,0,0,.40);
    --shadow-lg:       0 16px 48px rgba(0,0,0,.55);
    --shadow-glow:     0 0 40px rgba(37,99,235,.35);
    --shadow-glow-sm:  0 0 16px rgba(56,189,248,.40);
    --nav-bg:          rgba(6,11,31,.92);
    --nav-border:      rgba(59,130,246,.12);
  }
}

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--text-primary);
  background-color: var(--bg);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--duration-slow) var(--ease-out),
              color var(--duration-slow) var(--ease-out);
}

body.modal-open {
  overflow: hidden;
}

img, video, svg {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

ul, ol { list-style: none; }

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  line-height: 1.15;
  font-weight: 700;
  color: var(--text-primary);
}

p { color: var(--text-secondary); }

/* ============================================================
   TYPOGRAPHY SCALE
   ============================================================ */
.text-display {
  font-size: clamp(2.4rem, 5.5vw, 4.2rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.text-h1 {
  font-size: clamp(2rem, 4vw, 3.25rem);
  font-weight: 800;
  letter-spacing: -0.025em;
}

.text-h2 {
  font-size: clamp(1.6rem, 3vw, 2.5rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.text-h3 {
  font-size: clamp(1.15rem, 2vw, 1.4rem);
  font-weight: 600;
}

.text-body-lg {
  font-size: clamp(1rem, 1.5vw, 1.125rem);
  line-height: 1.75;
}

.text-body {
  font-size: 1rem;
  line-height: 1.7;
}

.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }

/* Gradient text utility */
.text-gradient {
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Eyebrow label */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ems-blue-500);
  margin-bottom: var(--space-3);
}

.eyebrow::before {
  content: '';
  display: block;
  width: 20px;
  height: 2px;
  background: var(--brand-gradient);
  border-radius: 2px;
  flex-shrink: 0;
}

/* ============================================================
   LAYOUT UTILITIES
   ============================================================ */
.container {
  width: min(100% - 40px, 1280px);
  margin-inline: auto;
}

.container--narrow {
  width: min(100% - 40px, 860px);
  margin-inline: auto;
}

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

.section--sm {
  padding-block: var(--space-8);
}

.section--lg {
  padding-block: var(--space-11);
}

/* Section heading block */
.section-heading {
  text-align: center;
  margin-bottom: var(--space-8);
}

.section-heading h2 {
  font-size: clamp(1.75rem, 3.5vw, 2.75rem);
  font-weight: 800;
  letter-spacing: -0.022em;
  line-height: 1.15;
  margin-bottom: var(--space-3);
}

.section-heading p {
  font-size: 1.05rem;
  max-width: 560px;
  margin-inline: auto;
}

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

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

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

/* Flex helpers */
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-gap-2 { gap: var(--space-2); }
.flex-gap-4 { gap: var(--space-4); }

/* ============================================================
   BUTTON SYSTEM
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 14px 28px;
  border-radius: var(--radius-md);
  font-family: var(--font-heading);
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: transform var(--duration-base) var(--ease-out),
              box-shadow var(--duration-base) var(--ease-out),
              opacity var(--duration-fast);
  position: relative;
  overflow: hidden;
  white-space: nowrap;
}

/* Shine sweep on hover */
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,0.18) 50%, transparent 60%);
  transform: translateX(-100%);
  transition: transform var(--duration-slow) var(--ease-out);
}

.btn:hover::after { transform: translateX(100%); }
.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-glow); }
.btn:active { transform: translateY(0); }

/* Primary — gradient brand */
.btn-primary {
  background: var(--brand-gradient);
  color: #ffffff;
  box-shadow: 0 4px 20px rgba(37, 99, 235, 0.30);
}

/* Dark — navy */
.btn-dark {
  background: var(--ems-navy-800);
  color: #ffffff;
  box-shadow: var(--shadow-md);
}

[data-theme="dark"] .btn-dark {
  background: var(--ems-blue-600);
}

/* Outline */
.btn-outline {
  background: transparent;
  color: var(--brand);
  border: 2px solid var(--brand);
  box-shadow: none;
}

.btn-outline:hover {
  background: var(--brand);
  color: #ffffff;
}

/* Ghost (white on dark bg) */
.btn-ghost {
  background: rgba(255,255,255,0.12);
  color: #ffffff;
  border: 1px solid rgba(255,255,255,0.25);
  backdrop-filter: blur(8px);
}

.btn-ghost:hover {
  background: rgba(255,255,255,0.22);
  box-shadow: none;
}

/* Sizes */
.btn-sm { padding: 10px 20px; font-size: 0.8125rem; }
.btn-lg { padding: 18px 38px; font-size: 1.0625rem; }

/* ============================================================
   SURFACE / CARD
   ============================================================ */
.surface {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: background var(--duration-slow) var(--ease-out),
              border-color var(--duration-slow) var(--ease-out);
}

.surface-glass {
  background: rgba(255,255,255,0.70);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.40);
}

[data-theme="dark"] .surface-glass {
  background: rgba(14,22,48,0.75);
  border-color: rgba(59,130,246,0.15);
}

/* ============================================================
   SIGNAL / LIVE DOT COMPONENT
   ============================================================ */
.signal-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--signal-glow);
  position: relative;
  flex-shrink: 0;
}

.signal-dot::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--signal-glow);
  opacity: 0;
  animation: signalPulse 2s ease-out infinite;
}

.signal-dot::after {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 1px solid var(--signal-glow);
  opacity: 0;
  animation: signalPulse 2s ease-out infinite 0.4s;
}

/* ============================================================
   BADGE / TAG
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.badge-brand {
  background: rgba(37, 99, 235, 0.10);
  color: var(--ems-blue-500);
  border: 1px solid rgba(37, 99, 235, 0.20);
}

[data-theme="dark"] .badge-brand {
  background: rgba(37,99,235,0.18);
  border-color: rgba(56,189,248,0.25);
  color: var(--ems-cyan-300);
}

/* ============================================================
   DIVIDER / DECORATIVE SHAPES
   ============================================================ */
.divider-wave {
  width: 100%;
  overflow: hidden;
  line-height: 0;
}

.divider-wave svg { display: block; width: 100%; }

/* Diagonal clip-path section transition */
.clip-top { clip-path: polygon(0 5%, 100% 0, 100% 100%, 0 100%); }
.clip-bottom { clip-path: polygon(0 0, 100% 0, 100% 95%, 0 100%); }
.clip-both { clip-path: polygon(0 4%, 100% 0, 100% 96%, 0 100%); }

/* ============================================================
   SCROLL PROGRESS BAR
   ============================================================ */
#scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 3px;
  background: var(--brand-gradient);
  z-index: 9999;
  transition: width 80ms linear;
  pointer-events: none;
}

/* ============================================================
   RESPONSIVE UTILITIES
   ============================================================ */
@media (max-width: 768px) {
  .hide-mobile { display: none !important; }
  .section { padding-block: var(--space-8); }
  .section--lg { padding-block: var(--space-9); }
}

@media (min-width: 769px) {
  .hide-desktop { display: none !important; }
}

@media (max-width: 480px) {
  .container { width: min(100% - 32px, 100%); }
}
