:root {
  color-scheme: dark;
  --bg: #08080a;
  --fg: #f5f5f7;
  /* Both dim tones clear WCAG AA on --bg: 5.85:1 and 4.72:1. Going darker
     than #7a7a86 for --fg-faint drops the card link below 4.5:1. */
  --fg-dim: #8a8a94;
  --fg-faint: #7a7a86;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --accent: #7c8cff;
  --pad: clamp(1.5rem, 5vw, 6rem);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* Typed so an invalid value falls back to the initial value instead of
   invalidating the whole declaration at computed-value time. */
@property --mx {
  syntax: "<length-percentage>";
  inherits: false;
  initial-value: 50%;
}
@property --my {
  syntax: "<length-percentage>";
  inherits: false;
  initial-value: 50%;
}
@property --d {
  syntax: "<number>";
  inherits: false;
  initial-value: 0;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: ui-sans-serif, -apple-system, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  /* Percentage, not px, so the reader's browser font-size setting survives. */
  font-size: 100%;
  line-height: 1.5;
  letter-spacing: -0.011em;
  -webkit-font-smoothing: antialiased;
}

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

/* No border-radius here: the outline already follows each element's own
   radius, and setting one would square off the card on focus. */
:where(a):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- backdrop ---------- */

#stars {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 55% at 50% -10%, rgba(124, 140, 255, 0.14), transparent 70%),
    radial-gradient(ellipse 60% 40% at 85% 15%, rgba(180, 120, 255, 0.07), transparent 70%);
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E");
}

main, .nav { position: relative; z-index: 3; }

/* ---------- nav ---------- */

.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem var(--pad);
  font-size: 0.875rem;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: linear-gradient(to bottom, rgba(8, 8, 10, 0.7), rgba(8, 8, 10, 0));
}

.wordmark {
  font-weight: 500;
  letter-spacing: -0.02em;
}

/* ---------- hero ---------- */

.hero {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(7rem, 18vh, 11rem) var(--pad) clamp(4rem, 10vh, 7rem);
}

h1 {
  margin: 0;
  font-size: clamp(2.5rem, 8vw, 5.5rem);
  /* background-clip: text crops to the line box, so a line-height under the
     font's full em clips descenders. 1.15 + the padding clears the "g". */
  line-height: 1.15;
  padding-block-end: 0.08em;
  letter-spacing: -0.04em;
  font-weight: 500;
  text-wrap: balance;
  background: linear-gradient(180deg, #fff 25%, #a7a7b4 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Forced-colors mode overrides the background but not the transparent text,
   which would leave the hero blank. */
@media (forced-colors: active) {
  h1 {
    color: CanvasText;
    -webkit-text-fill-color: CanvasText;
  }
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

/* ---------- work ---------- */

.work {
  padding: 6rem var(--pad) 8rem;
  max-width: 1100px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 2.5rem;
}

.section-head h2 {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-dim);
}

.count {
  font-size: 0.75rem;
  color: var(--fg-faint);
  font-variant-numeric: tabular-nums;
}

.card {
  display: block;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.01));
  transition: border-color 0.4s var(--ease), transform 0.4s var(--ease);
}

.card:hover {
  border-color: var(--line-strong);
  transform: translateY(-2px);
}

.card-glow {
  position: absolute;
  inset: -1px;
  opacity: 0;
  transition: opacity 0.4s var(--ease);
  background: radial-gradient(400px circle at var(--mx, 50%) var(--my, 50%), rgba(124, 140, 255, 0.16), transparent 65%);
}
.card:hover .card-glow { opacity: 1; }

.card-body {
  position: relative;
  padding: clamp(1.5rem, 3vw, 2.25rem);
}

.card h3 {
  margin: 0;
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 500;
  letter-spacing: -0.03em;
  text-wrap: balance;
}

.card p {
  margin: 0.75rem 0 2rem;
  color: var(--fg-dim);
  max-width: 44ch;
  text-wrap: pretty;
}

.card-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.875rem;
  color: var(--fg-faint);
  transition: color 0.3s var(--ease);
}
.card:hover .card-link { color: var(--accent); }

.arrow { transition: transform 0.3s var(--ease); }
.card:hover .arrow { transform: translate(2px, -2px); }

/* ---------- reveal ---------- */

/* Motion is opt-in: with no media query matched the content is simply
   visible, so a reduced-motion reader never depends on JS to reveal it. */
@media (prefers-reduced-motion: no-preference) {
  .reveal {
    opacity: 0;
    transform: translateY(14px);
    transition: opacity 0.9s var(--ease), transform 0.9s var(--ease);
    transition-delay: calc(var(--d) * 110ms);
  }
  .reveal.in { opacity: 1; transform: none; }
  .reveal[data-delay="1"] { --d: 1; }
  .reveal[data-delay="2"] { --d: 2; }
}
