/* ============================================================
   base.css — design tokens, reset, typography, layout, motion
   ============================================================ */

/* ---------- Design tokens ---------- */
:root {
  /* Color palette (dark theme, blue/purple accents) */
  --bg: #05070f;
  --bg-alt: #090c1a;
  --surface: rgba(148, 163, 216, 0.055);
  --surface-strong: rgba(148, 163, 216, 0.1);
  --border: rgba(148, 163, 216, 0.14);
  --border-strong: rgba(148, 163, 216, 0.28);

  --text: #e8ecf8;
  --text-muted: #9aa5c4;
  --text-faint: #67718f;

  --accent: #6d8dff;        /* blue   */
  --accent-2: #a06bff;      /* purple */
  --accent-3: #4cc9f0;      /* cyan, sparingly */
  --ok: #4ade80;
  --err: #f87171;

  --gradient: linear-gradient(120deg, var(--accent) 0%, var(--accent-2) 100%);
  --glow: 0 0 40px rgba(109, 141, 255, 0.25);

  /* Glassmorphism recipe */
  --glass-bg: rgba(12, 16, 32, 0.55);
  --glass-blur: 14px;

  /* Typography */
  --font-heading: "Space Grotesk", system-ui, -apple-system, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "Cascadia Code", monospace;

  /* Layout */
  --container: 1140px;
  --container-narrow: 860px;
  --nav-h: 72px;
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;

  /* Motion */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --speed: 220ms;
}

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

html {
  scroll-behavior: smooth;
  /* Keep anchored sections clear of the sticky nav */
  scroll-padding-top: calc(var(--nav-h) + 12px);
}

body {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Site-wide interactive constellation (js/modules/datafield.js):
   fixed behind all content, above the body background. Hidden
   wherever the effect never initializes so no dead canvas sits
   in the page. */
.data-field {
  position: fixed;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
}

@media (hover: none), (prefers-reduced-motion: reduce) {
  .data-field {
    display: none;
  }
}

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

ul,
ol {
  list-style: none;
}

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

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

input,
textarea {
  font: inherit;
}

/* ---------- Typography ---------- */
h1,
h2,
h3,
h4 {
  font-family: var(--font-heading);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

strong {
  color: var(--text);
  font-weight: 600;
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.85em;
}

.accent {
  color: var(--accent);
}

/* Gradient text helper (used on headings/logo) */
.gradient-text {
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------- Layout ---------- */
.container {
  width: min(var(--container), 100% - 3rem);
  margin-inline: auto;
}

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

.section {
  padding: clamp(4.5rem, 9vw, 7.5rem) 0;
}

/* Alternate band to give the page rhythm. Translucent so the
   fixed constellation canvas stays visible (dimmed) behind it. */
.section-alt {
  background:
    radial-gradient(60% 80% at 80% 10%, rgba(160, 107, 255, 0.05), transparent 60%),
    rgba(9, 12, 26, 0.72);
}

.section-head {
  max-width: 640px;
  margin-bottom: clamp(2.5rem, 5vw, 4rem);
}

.section-eyebrow {
  color: var(--accent);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  margin-bottom: 0.6rem;
}

.section-title {
  font-size: clamp(1.9rem, 4vw, 2.6rem);
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Decorative rule after each section title */
.section-title::after {
  content: "";
  flex: 1;
  max-width: 180px;
  height: 2px;
  background: linear-gradient(90deg, var(--border-strong), transparent);
}

.section-sub {
  color: var(--text-muted);
  margin-top: 0.9rem;
}

/* ---------- Accessibility ---------- */
.skip-link {
  position: fixed;
  top: -100px;
  left: 1rem;
  z-index: 200;
  padding: 0.6rem 1rem;
  background: var(--accent);
  color: #0b1020;
  font-weight: 600;
  border-radius: var(--radius-sm);
  transition: top var(--speed) var(--ease);
}

.skip-link:focus {
  top: 1rem;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

::selection {
  background: rgba(109, 141, 255, 0.35);
}

/* ---------- Scrollbar (WebKit) ---------- */
::-webkit-scrollbar {
  width: 10px;
}

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

::-webkit-scrollbar-thumb {
  background: #232a45;
  border-radius: 6px;
}

::-webkit-scrollbar-thumb:hover {
  background: #2f3860;
}

/* ---------- Scroll-reveal system ----------
   Elements with .reveal start hidden and slide in when they
   enter the viewport (see js/modules/scroll.js). The .js guard
   ensures content stays visible if JavaScript is disabled. */
.js .reveal {
  opacity: 0;
  transform: translateY(26px);
  transition:
    opacity 0.7s var(--ease),
    transform 0.7s var(--ease);
}

.js .reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* Stagger helper: children fade in one after another */
.js .reveal[data-stagger] > * {
  opacity: 0;
  transform: translateY(20px);
  transition:
    opacity 0.6s var(--ease),
    transform 0.6s var(--ease);
  transition-delay: calc(var(--i, 0) * 90ms);
}

.js .reveal[data-stagger].is-visible > * {
  opacity: 1;
  transform: none;
}

/* ---------- Reduced motion: disable all non-essential movement ---------- */
@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;
  }

  .js .reveal,
  .js .reveal[data-stagger] > * {
    opacity: 1;
    transform: none;
  }
}
