/* ==========================================================================
   Data Island — Design System & Global Styles
   ========================================================================== */

/* ---------- CSS Custom Properties ---------- */
:root {
  /* Primary palette */
  --color-primary: #1c96ca;
  --color-primary-light: #e6f4fa;
  --color-primary-dark: #147ba3;
  --color-primary-deep: #0a678f;
  --color-primary-rgb: 28, 150, 202;

  /* Text */
  --color-text: #1e293b;
  --color-text-secondary: #64748b;
  --color-text-muted: #94a3b8;
  --color-text-inverse: #ffffff;

  /* Backgrounds */
  --color-bg: #f3f6fb;
  --color-bg-white: #ffffff;
  --color-bg-card: #ffffff;
  --color-bg-code: #f1f5f9;
  --color-bg-dark: #0a678f;
  --color-bg-darker: #064a66;

  /* Semantic */
  --color-success: #10b981;
  --color-success-light: #ecfdf5;
  --color-error: #ef4444;
  --color-error-light: #fef2f2;
  --color-warning: #f59e0b;
  --color-warning-light: #fffbeb;

  /* Borders */
  --border-color: #e2e8f0;
  --border-color-light: #f1f5f9;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-3xl: 2rem;
  --font-size-4xl: 2.5rem;
  --font-size-5xl: 3.5rem;
  --line-height: 1.6;

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-7: 1.75rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, 0.1);
  --shadow-xl: 0 20px 50px rgba(15, 23, 42, 0.15);

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-xl: 16px;
  --radius-2xl: 20px;
  --radius-full: 9999px;

  /* Transitions */
  --ease: cubic-bezier(0.25, 0.8, 0.25, 1);
  --transition-fast: 0.15s var(--ease);
  --transition: 0.25s var(--ease);
  --transition-slow: 0.4s var(--ease);

  /* Layout */
  --container-max: 1200px;
  --container-wide: 1400px;
  --navbar-height: 72px;
}

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

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

body {
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  line-height: var(--line-height);
  color: var(--color-text);
  background: var(--color-bg);
  overflow-x: hidden;
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--color-primary); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--color-primary-dark); }

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

h1 { font-size: clamp(2.25rem, 5vw, var(--font-size-5xl)); }
h2 { font-size: clamp(1.75rem, 3.5vw, var(--font-size-3xl)); }
h3 { font-size: clamp(1.25rem, 2.5vw, var(--font-size-xl)); }
h4 { font-size: var(--font-size-lg); }

p { margin-bottom: var(--space-4); }
p:last-child { margin-bottom: 0; }

code, pre {
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
}

/* ---------- Layout ---------- */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--space-6);
}

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

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

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

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

.section--dark {
  background: var(--color-bg-dark);
  color: var(--color-text-inverse);
}

.section--dark h2,
.section--dark h3,
.section--dark h4 {
  color: var(--color-text-inverse);
}

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

/* ---------- Grid ---------- */
.grid {
  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--6 { grid-template-columns: repeat(6, 1fr); }

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

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

/* ---------- Flex ---------- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }

/* ---------- Text Utilities ---------- */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-secondary { color: var(--color-text-secondary); }
.text-muted { color: var(--color-text-muted); }
.text-primary { color: var(--color-primary); }
.text-inverse { color: var(--color-text-inverse); }
.text-sm { font-size: var(--font-size-sm); }
.text-lg { font-size: var(--font-size-lg); }
.text-xl { font-size: var(--font-size-xl); }
.text-2xl { font-size: var(--font-size-2xl); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.uppercase { text-transform: uppercase; letter-spacing: 0.05em; }

/* ---------- Spacing Utilities ---------- */
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mt-12 { margin-top: var(--space-12); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }
.mb-12 { margin-bottom: var(--space-12); }
.mx-auto { margin-left: auto; margin-right: auto; }

/* ---------- Section Headers ---------- */
.section-header {
  text-align: center;
  max-width: 700px;
  margin: 0 auto var(--space-12);
}

.section-header h2 {
  margin-bottom: var(--space-4);
}

.section-header p {
  font-size: var(--font-size-lg);
  color: var(--color-text-secondary);
}

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

/* ---------- Max Width ---------- */
.max-w-sm { max-width: 500px; }
.max-w-md { max-width: 700px; }
.max-w-lg { max-width: 900px; }

/* ---------- Scroll margin for anchors ---------- */
[id] {
  scroll-margin-top: calc(var(--navbar-height) + var(--space-4));
}

/* ---------- Selection ---------- */
::selection {
  background: var(--color-primary-light);
  color: var(--color-primary-deep);
}

/* ---------- Smooth Reveal Animations ----------
 * Only active when JS is ready AND the user has not opted out of motion.
 * Without .js-ready on <html>, reveals are shown immediately (no FOUC).
 */
.reveal {
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
}

html.js-ready .reveal:not(.visible) {
  opacity: 0;
  transform: translateY(24px);
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Stagger children */
html.js-ready .reveal-stagger > .reveal:nth-child(1) { transition-delay: 0s; }
html.js-ready .reveal-stagger > .reveal:nth-child(2) { transition-delay: 0.1s; }
html.js-ready .reveal-stagger > .reveal:nth-child(3) { transition-delay: 0.2s; }
html.js-ready .reveal-stagger > .reveal:nth-child(4) { transition-delay: 0.3s; }
html.js-ready .reveal-stagger > .reveal:nth-child(5) { transition-delay: 0.4s; }
html.js-ready .reveal-stagger > .reveal:nth-child(6) { transition-delay: 0.5s; }

/* Respect user motion preference: skip reveal animation entirely. */
@media (prefers-reduced-motion: reduce) {
  html.js-ready .reveal,
  html.js-ready .reveal:not(.visible) {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
}
