/* ==========================================================================
   VOXELCLICKS — Design Foundation
   Tokens, reset, typography, utilities
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokens
   -------------------------------------------------------------------------- */

:root {
  /* Surfaces — cool blue-black. The blue cast (rather than a green one) is
     what reads as "technology" instead of "nature". */
  --bg-void: #05090f;
  --bg-deep: #080e17;
  --bg-surface: #0c141f;
  --bg-raised: #121c29;
  --bg-elevated: #182534;

  /* Accents — electric teal into cyan and signal blue.
     Still a green family, but a screen green rather than a leaf green. */
  --green: #00e5c0;
  --green-bright: #3df5d5;
  --green-soft: #8cfce8;
  --cyan: #4dd8ff;
  --teal: #38bdf8;

  /* Text — cool off-white. Warm bone read organic; this reads instrument. */
  --text-hi: #eaf0f6;
  --text: #c2ced8;
  --text-lo: #8496a8;
  --text-faint: #55677a;

  /* Lines & glass */
  --line: rgba(0, 229, 192, 0.12);
  --line-strong: rgba(0, 229, 192, 0.3);
  --glass: rgba(255, 255, 255, 0.026);
  --glass-hi: rgba(255, 255, 255, 0.05);

  /* Signature gradients */
  --grad-brand: linear-gradient(115deg, var(--cyan) 0%, var(--green) 48%, var(--teal) 100%);
  --grad-text: linear-gradient(100deg, var(--text-hi) 0%, var(--green-soft) 50%, var(--cyan) 100%);
  --grad-glow: radial-gradient(circle at 50% 50%, rgba(0, 229, 192, 0.24), transparent 68%);

  /* Type families */
  --font-display: "Space Grotesk", "Segoe UI", system-ui, sans-serif;
  --font-body: "Inter", "Segoe UI", system-ui, sans-serif;
  --font-serif: "Instrument Serif", "Times New Roman", serif;
  --font-mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", monospace;

  /* Fluid type scale — 380px → 1600px viewport */
  --step--1: clamp(0.78rem, 0.75rem + 0.14vw, 0.86rem);
  --step-0: clamp(0.94rem, 0.9rem + 0.2vw, 1.05rem);
  --step-1: clamp(1.1rem, 1rem + 0.42vw, 1.35rem);
  --step-2: clamp(1.35rem, 1.15rem + 0.85vw, 1.9rem);
  --step-3: clamp(1.75rem, 1.35rem + 1.7vw, 2.9rem);
  --step-4: clamp(2.2rem, 1.5rem + 2.9vw, 4.2rem);
  --step-5: clamp(2.7rem, 1.5rem + 5vw, 6.2rem);
  --step-6: clamp(3.2rem, 1.2rem + 8.4vw, 9rem);

  /* Space */
  --sp-1: 0.5rem;
  --sp-2: 0.875rem;
  --sp-3: 1.25rem;
  --sp-4: 2rem;
  --sp-5: 3rem;
  --sp-6: 4.5rem;
  --sp-7: 7rem;
  --sp-8: 10rem;

  /* Layout */
  --gutter: clamp(1.15rem, 4vw, 4.5rem);
  --maxw: 1440px;
  --maxw-text: 46rem;

  /* Radii */
  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 22px;
  --r-xl: 34px;
  --r-pill: 999px;

  /* Motion */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.76, 0, 0.24, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-fast: 0.25s;
  --dur: 0.5s;
  --dur-slow: 0.9s;

  /* Chrome */
  --nav-h: 76px;
  --z-grain: 9000;
  --z-nav: 800;
  --z-loader: 9800;
}

/* --------------------------------------------------------------------------
   2. Reset
   -------------------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scrollbar-color: var(--green) var(--bg-deep);
}

/* Contain sideways overflow from animated/oversized decorative elements.
   `clip` is preferred over `hidden` because it does NOT create a scroll
   container — which would break the `position: sticky` sections. The
   `hidden` line is the fallback for engines without `clip`. */
html,
body {
  overflow-x: hidden;
  overflow-x: clip;
}

body {
  min-height: 100vh;
  background: var(--bg-void);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.65;
  font-synthesis-weight: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body.is-locked {
  overflow: hidden;
}

img,
picture,
svg,
video,
canvas {
  display: block;
  max-width: 100%;
}

input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

ul,
ol {
  list-style: none;
}

table {
  border-collapse: collapse;
  width: 100%;
}

::selection {
  background: var(--green);
  color: var(--bg-void);
}

/* Scrollbar — WebKit */
::-webkit-scrollbar {
  width: 10px;
}
::-webkit-scrollbar-track {
  background: var(--bg-deep);
}
::-webkit-scrollbar-thumb {
  background: linear-gradient(var(--green), var(--teal));
  border-radius: var(--r-pill);
  border: 2px solid var(--bg-deep);
}

/* Focus — visible, on-brand, never suppressed */
:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
  border-radius: 3px;
}

/* --------------------------------------------------------------------------
   3. Typography
   -------------------------------------------------------------------------- */

h1,
h2,
h3,
h4,
h5 {
  font-family: var(--font-display);
  font-weight: 500;
  line-height: 1.02;
  letter-spacing: -0.035em;
  color: var(--text-hi);
  text-wrap: balance;
}

h1 {
  font-size: var(--step-5);
}
h2 {
  font-size: var(--step-4);
}
h3 {
  font-size: var(--step-2);
  line-height: 1.15;
  letter-spacing: -0.025em;
}
h4 {
  font-size: var(--step-1);
  line-height: 1.25;
  letter-spacing: -0.02em;
}

p {
  text-wrap: pretty;
}

strong {
  color: var(--text-hi);
  font-weight: 600;
}

/* Serif italic accent inside display headings */
.serif {
  font-family: var(--font-serif);
  font-weight: 400;
  font-style: italic;
  letter-spacing: -0.015em;
  background: var(--grad-text);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  padding-right: 0.06em;
}

/* Gradient-filled text */
.grad {
  background: var(--grad-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Small technical eyebrow label */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  font-family: var(--font-mono);
  font-size: var(--step--1);
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--green);
}

.eyebrow::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 12px var(--green);
  flex: none;
  animation: pulse-dot 2.4s var(--ease-in-out) infinite;
}

.eyebrow--plain::before {
  display: none;
}

@keyframes pulse-dot {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.35;
    transform: scale(0.7);
  }
}

.lead {
  font-size: var(--step-1);
  line-height: 1.55;
  color: var(--text);
  max-width: 42ch;
}

.muted {
  color: var(--text-lo);
}

/* --------------------------------------------------------------------------
   4. Layout utilities
   -------------------------------------------------------------------------- */

.shell {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.section {
  position: relative;
  padding-block: clamp(3.25rem, 6.5vw, 6rem);
}

.section--tight {
  padding-block: clamp(2.25rem, 4vw, 3.5rem);
}

.section-head {
  display: grid;
  gap: var(--sp-2);
  margin-bottom: clamp(1.75rem, 3.2vw, 2.75rem);
  max-width: 60rem;
}

.section-head--split {
  grid-template-columns: 1fr;
  max-width: none;
}

@media (min-width: 900px) {
  .section-head--split {
    grid-template-columns: 1.15fr 0.85fr;
    align-items: end;
    gap: var(--sp-5);
  }
}

.stack {
  display: grid;
  gap: var(--sp-3);
}

.flow > * + * {
  margin-top: var(--sp-3);
}

/* Screen-reader only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Skip link */
.skip-link {
  position: absolute;
  top: -100px;
  left: var(--gutter);
  z-index: 9999;
  padding: 0.75rem 1.25rem;
  background: var(--green);
  color: var(--bg-void);
  font-weight: 600;
  border-radius: var(--r-sm);
  transition: top var(--dur-fast) var(--ease-out);
}

.skip-link:focus {
  top: 1rem;
}

/* Hairline divider */
.rule {
  height: 1px;
  border: 0;
  background: linear-gradient(90deg, transparent, var(--line-strong) 20%, var(--line-strong) 80%, transparent);
}

/* --------------------------------------------------------------------------
   5. Ambient effects — grain, glow, vignette
   -------------------------------------------------------------------------- */

/* Film grain overlay across the whole document */
.grain {
  position: fixed;
  inset: -150%;
  z-index: var(--z-grain);
  pointer-events: none;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain-shift 7s steps(9) infinite;
  will-change: transform;
}

@keyframes grain-shift {
  0% {
    transform: translate(0, 0);
  }
  10% {
    transform: translate(-4%, -3%);
  }
  20% {
    transform: translate(-7%, 2%);
  }
  30% {
    transform: translate(3%, -6%);
  }
  40% {
    transform: translate(-2%, 7%);
  }
  50% {
    transform: translate(-6%, 3%);
  }
  60% {
    transform: translate(5%, 0);
  }
  70% {
    transform: translate(0, 5%);
  }
  80% {
    transform: translate(-4%, -4%);
  }
  90% {
    transform: translate(4%, 3%);
  }
  100% {
    transform: translate(0, 0);
  }
}

/* Soft radial brand glow — drop into any positioned parent */
.glow {
  position: absolute;
  border-radius: 50%;
  background: var(--grad-glow);
  filter: blur(60px);
  pointer-events: none;
  z-index: 0;
}

/* Faint engineering grid backdrop */
.gridlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image: linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 40%, #000 20%, transparent 78%);
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 40%, #000 20%, transparent 78%);
  opacity: 0.7;
}

/* --------------------------------------------------------------------------
   6. Scroll-reveal primitives (driven by main.js)
   -------------------------------------------------------------------------- */

[data-reveal] {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.85s var(--ease-out), transform 0.85s var(--ease-out);
  transition-delay: var(--reveal-delay, 0s);
}

[data-reveal].is-in {
  opacity: 1;
  transform: none;
}

[data-reveal="fade"] {
  transform: none;
}

[data-reveal="left"] {
  transform: translateX(-34px);
}

[data-reveal="right"] {
  transform: translateX(34px);
}

[data-reveal="scale"] {
  transform: scale(0.94);
}

/* On narrow screens a sideways offset both reads poorly and widens the
   document before the element reveals. Slide vertically instead. */
@media (max-width: 760px) {
  [data-reveal="left"],
  [data-reveal="right"] {
    transform: translateY(28px);
  }
}

[data-reveal="clip"] {
  opacity: 1;
  transform: none;
  clip-path: inset(0 0 100% 0);
  transition: clip-path 1.1s var(--ease-out);
  transition-delay: var(--reveal-delay, 0s);
}

[data-reveal="clip"].is-in {
  clip-path: inset(0 0 0 0);
}

/* Per-line masked heading reveal (split by main.js) */
.line-mask {
  display: block;
  overflow: hidden;
  padding-bottom: 0.06em;
  margin-bottom: -0.06em;
}

.line-mask > span {
  display: block;
  transform: translateY(105%);
  transition: transform 1.05s var(--ease-out);
  transition-delay: var(--line-delay, 0s);
}

.is-in .line-mask > span,
.line-mask.is-in > span {
  transform: none;
}

/* --------------------------------------------------------------------------
   7. Reduced motion — honour the user's system preference
   -------------------------------------------------------------------------- */

@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;
    scroll-behavior: auto !important;
  }

  .grain {
    animation: none;
  }

  [data-reveal] {
    opacity: 1 !important;
    transform: none !important;
    clip-path: none !important;
  }

  .line-mask > span {
    transform: none !important;
  }
}
