/* Free Parameter LLC: site styles. Tokens live in tokens.css.
   Ideas used here: cross-document view transitions (a focus-pull between pages), scroll-driven reveals
   (blur → sharp as a section enters the frame), @property-animated blur, color-mix, :has(), container
   queries, text-wrap: balance. Everything degrades to a plain, readable page. */

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--bg-deep); }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: var(--step-0);
  line-height: 1.6;
  color: var(--fg-soft);
  background:
    radial-gradient(120vmax 80vmax at 78% -10%, color-mix(in oklab, var(--cool) 22%, transparent), transparent 60%),
    radial-gradient(90vmax 70vmax at -10% 110%, color-mix(in oklab, var(--accent) 7%, transparent), transparent 55%),
    var(--bg-deep);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}
/* film grain over everything, very light */
body::after {
  content: ""; position: fixed; inset: -50%; z-index: 100; pointer-events: none;
  background-image: url("../assets/grain.png");
  opacity: 0.07; mix-blend-mode: overlay;
  animation: grain 1.2s steps(6) infinite;
}
@keyframes grain { to { transform: translate3d(-4%, 3%, 0); } }

::selection { background: var(--selection); color: var(--fg); }
a { color: inherit; text-decoration-color: var(--line-hot); text-underline-offset: 0.25em; }
a:hover { color: var(--fg); text-decoration-color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
h1, h2, h3 { color: var(--fg); font-weight: 800; letter-spacing: var(--track-tight); line-height: 1.04; text-wrap: balance; margin: 0; }
p { text-wrap: pretty; max-width: var(--measure); }
.eyebrow { font-size: var(--step--1); letter-spacing: var(--track-wide); text-transform: uppercase; color: var(--cyan); }
.eyebrow::before { content: "// "; color: var(--fg-dim); }
.accent { color: var(--accent); text-shadow: var(--glow-accent); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------------------------------------------------------------------------------- header / tabs */
.site-header {
  position: fixed; inset: 0 0 auto 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 18px var(--gutter);
  background: linear-gradient(to bottom, color-mix(in oklab, var(--bg-deep) 85%, transparent), transparent);
  view-transition-name: site-header;
}
/* once the page scrolls, the header becomes frosted glass so content never clashes with it */
@supports (animation-timeline: scroll()) {
  .site-header { animation: header-glass linear both; animation-timeline: scroll(root); animation-range: 0 140px; }
  @keyframes header-glass {
    to { background: color-mix(in oklab, var(--bg-deep) 78%, transparent); backdrop-filter: blur(16px) saturate(1.3);
         box-shadow: 0 1px 0 var(--line); }
  }
}
@supports not (animation-timeline: scroll()) {
  .site-header { background: color-mix(in oklab, var(--bg-deep) 78%, transparent); backdrop-filter: blur(16px); }
}
.brand { display: inline-flex; align-items: center; gap: 0.6rem; color: var(--fg); text-decoration: none; font-weight: 800; letter-spacing: 0.02em; }
.brand-mark { width: 28px; height: 28px; flex: none; }
.brand small { color: var(--fg-dim); font-weight: 500; }
.tabs { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg-glass); backdrop-filter: blur(14px) saturate(1.3); }
.tabs a {
  position: relative; padding: 0.45rem 0.95rem; border-radius: 999px; text-decoration: none;
  font-size: var(--step--1); letter-spacing: 0.06em; color: var(--fg-soft);
  transition: color var(--t-fast), background var(--t-fast);
}
.tabs a:hover { color: var(--fg); background: color-mix(in oklab, var(--cyan) 10%, transparent); }
.tabs a[aria-current="page"] { color: var(--accent-ink); background: var(--accent); box-shadow: var(--glow-accent); }
.tabs a .count { margin-left: 0.4em; padding: 0 0.45em; border-radius: 999px; background: color-mix(in oklab, var(--accent) 22%, transparent); color: var(--accent); font-size: 0.85em; }
.tabs a[aria-current="page"] .count { background: color-mix(in oklab, var(--accent-ink) 18%, transparent); color: var(--accent-ink); }
@media (max-width: 640px) {
  .site-header { flex-direction: column; align-items: stretch; gap: 10px; padding-top: 12px; }
  .tabs { justify-content: space-between; }
  .tabs a { padding: 0.45rem 0.6rem; }
  .brand small { display: none; }
}

/* ---------------------------------------------------------------------------------- hero */
.hero { position: relative; height: 100dvh; min-height: 560px; overflow: clip; isolation: isolate; }
.hero.hero--short { height: 64dvh; min-height: 440px; }
.hero canvas, .hero .stage-fallback { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hero canvas { outline: none; cursor: text; }
.hero::before { /* scrim behind the headline: the copy always reads, the scene stays visible */
  content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: linear-gradient(90deg, color-mix(in oklab, var(--bg-deep) 82%, transparent) 0%, color-mix(in oklab, var(--bg-deep) 40%, transparent) 38%, transparent 62%);
}
@media (max-aspect-ratio: 1/1) {
  .hero::before { background: linear-gradient(to top, color-mix(in oklab, var(--bg-deep) 92%, transparent) 0%, color-mix(in oklab, var(--bg-deep) 55%, transparent) 42%, transparent 62%); }
  .hero-copy { bottom: 28px; }
}
.hero::after { /* letterbox fade into the page */
  content: ""; position: absolute; inset: auto 0 0 0; height: 28%; z-index: 1; pointer-events: none;
  background: linear-gradient(to bottom, transparent, var(--bg-deep));
}
.hero-copy {
  position: absolute; z-index: 2; left: var(--gutter); bottom: clamp(32px, 9vh, 96px); right: var(--gutter);
  display: grid; gap: 0.9rem; max-width: 46rem; pointer-events: none;
  animation: copy-in var(--t-film) var(--ease-lens) 900ms both;
}
.hero-copy h1 { font-size: var(--step-4); }
.hero-copy p { font-size: var(--step-1); color: var(--fg-soft); margin: 0; }
.hero-copy .cta-row { pointer-events: auto; }
.hint {
  position: absolute; z-index: 2; right: var(--gutter); bottom: clamp(32px, 9vh, 96px);
  font-size: var(--step--1); color: var(--fg-dim); letter-spacing: 0.08em;
  animation: copy-in var(--t-film) var(--ease-lens) 2.4s both;
}
.hint kbd { padding: 0.1em 0.45em; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; color: var(--fg-soft); font: inherit; }
@keyframes copy-in { from { opacity: 0; filter: blur(14px); transform: translateY(14px); } }
@media (max-width: 640px) { .hint { display: none; } }

/* the no-WebGL / reduced-motion stage: a DOM terminal in CSS 3D with real CSS depth blur */
.stage-fallback { display: grid; place-items: center; perspective: 1400px; }
.stage-fallback .term {
  width: min(86vw, 980px); aspect-ratio: 16 / 10; padding: 2.2rem 2.4rem; border-radius: 18px;
  background: linear-gradient(160deg, color-mix(in oklab, var(--bg-raise) 88%, #fff 2%), var(--bg));
  border: 1px solid var(--line); box-shadow: var(--shadow-deep), inset 0 0 80px color-mix(in oklab, var(--cool) 14%, transparent);
  transform: rotateY(-14deg) rotateX(6deg) translateZ(0);
  color: var(--fg); font-size: clamp(12px, 1.4vw, 20px); white-space: pre-wrap; overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, #000 55%, #0006);   /* far edge falls out of focus */
  filter: blur(var(--blur));
}
.stage-fallback .term .ps { color: var(--cyan); }
.stage-fallback .term .cur { display: inline-block; width: 0.6em; height: 1.15em; vertical-align: -0.2em; background: var(--accent); box-shadow: var(--glow-accent); animation: blink 1.05s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------------------------------------------------------------------------------- buttons */
.cta-row { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 0.4rem; }
.btn {
  display: inline-flex; align-items: center; gap: 0.6em; padding: 0.8em 1.3em; border-radius: 999px;
  font: inherit; font-size: var(--step--1); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  text-decoration: none; cursor: pointer; border: 1px solid var(--line);
  color: var(--fg); background: var(--bg-glass); backdrop-filter: blur(12px);
  transition: transform var(--t-fast) var(--ease-out), border-color var(--t-fast), box-shadow var(--t-fast);
}
.btn:hover { transform: translateY(-2px); border-color: var(--cyan); color: var(--fg); }
.btn--primary { color: var(--accent-ink); background: var(--accent); border-color: transparent; box-shadow: var(--glow-accent); }
.btn--primary:hover { border-color: transparent; box-shadow: 0 0 1.4em color-mix(in oklab, var(--accent) 60%, transparent); color: var(--accent-ink); }
.btn .arrow { transition: transform var(--t-fast) var(--ease-out); }
.btn:hover .arrow { transform: translateX(4px); }

/* ---------------------------------------------------------------------------------- sections */
main { position: relative; z-index: 2; }
.section { padding: clamp(72px, 14vh, 160px) var(--gutter); display: grid; gap: 1.4rem; max-width: 1280px; margin-inline: auto; }
.section h2 { font-size: var(--step-3); }
.section > p { font-size: var(--step-1); }
.grid-3 { display: grid; gap: 1px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.cell { container-type: inline-size; padding: clamp(20px, 3vw, 36px); background: color-mix(in oklab, var(--bg) 92%, transparent); display: grid; gap: 0.6rem; align-content: start; transition: background var(--t-med); }
.cell:hover { background: color-mix(in oklab, var(--bg-raise) 92%, transparent); }
.cell h3 { font-size: var(--step-1); }
.cell .k { color: var(--accent); font-weight: 700; }
.cell p { margin: 0; color: var(--fg-soft); }
@container (min-width: 360px) { .cell h3 { font-size: var(--step-2); } }

.feature {
  display: grid; gap: clamp(24px, 4vw, 64px); align-items: center;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr));
}
.feature figure { margin: 0; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); box-shadow: var(--shadow-deep); aspect-ratio: 16 / 10; background: var(--bg); }
.feature figure img, .feature figure video { width: 100%; height: 100%; object-fit: cover; display: block; }
.code-card {
  margin: 0; padding: 1.4rem 1.6rem; border-radius: var(--radius); border: 1px solid var(--line);
  background: linear-gradient(170deg, var(--bg-raise), var(--bg)); color: var(--fg);
  font-size: var(--step--1); line-height: 1.75; white-space: pre-wrap; box-shadow: var(--shadow-deep);
}
.code-card .ps { color: var(--cyan); } .code-card .ok { color: var(--cool-soft); } .code-card .hl { color: var(--accent); }

/* scroll-driven reveal: each block pulls into focus as it enters the frame */
@supports (animation-timeline: view()) {
  .reveal {
    animation: focus-in linear both;
    animation-timeline: view();
    animation-range: entry 0% cover 32%;
  }
  @keyframes focus-in { from { opacity: 0; filter: blur(16px); transform: translateY(40px) scale(0.985); } }
}

/* ---------------------------------------------------------------------------------- careers */
.roles { display: grid; gap: 14px; }
.role {
  border: 1px solid var(--line); border-radius: var(--radius); background: color-mix(in oklab, var(--bg) 90%, transparent);
  transition: border-color var(--t-med), background var(--t-med), box-shadow var(--t-med);
}
.role:hover, .role:has(details[open]) { border-color: color-mix(in oklab, var(--accent) 40%, transparent); background: color-mix(in oklab, var(--bg-raise) 90%, transparent); }
.role:has(details[open]) { box-shadow: var(--shadow-deep); }
.role summary {
  list-style: none; cursor: pointer; display: grid; grid-template-columns: 1fr auto; gap: 0.4rem 1.2rem; align-items: center;
  padding: clamp(18px, 2.4vw, 28px) clamp(18px, 3vw, 36px);
}
.role summary::-webkit-details-marker { display: none; }
.role h3 { font-size: var(--step-2); }
.role .meta { grid-column: 1; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.role .tag { font-size: var(--step--1); padding: 0.15em 0.7em; border-radius: 999px; border: 1px solid var(--line); color: var(--cyan); }
.role .tag.hot { color: var(--accent); border-color: var(--line-hot); }
.role .plus { grid-column: 2; grid-row: 1 / span 2; width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); display: grid; place-items: center; color: var(--fg); transition: transform var(--t-med) var(--ease-lens), background var(--t-med); }
.role details[open] .plus { transform: rotate(45deg); background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.role .body { padding: 0 clamp(18px, 3vw, 36px) clamp(18px, 2.4vw, 32px); display: grid; gap: 1rem; }
.role .body ul { margin: 0; padding-left: 1.2em; display: grid; gap: 0.35rem; }
.role .body li::marker { content: "› "; color: var(--accent); }
/* open/close animates height on engines that can (interpolate-size), else snaps */
@supports (interpolate-size: allow-keywords) {
  :root { interpolate-size: allow-keywords; }
  .role details::details-content { height: 0; overflow: clip; opacity: 0; filter: blur(8px); transition: height var(--t-med) var(--ease-lens), opacity var(--t-med), filter var(--t-med), content-visibility var(--t-med) allow-discrete; }
  .role details[open]::details-content { height: auto; opacity: 1; filter: none; }
}
.perks { display: grid; gap: 1px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--line); }
.perks div { padding: 1.2rem 1.4rem; background: var(--bg); }
.perks b { color: var(--fg); display: block; }

dialog.apply {
  width: min(560px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--fg-soft); background: linear-gradient(170deg, var(--bg-raise), var(--bg)); box-shadow: var(--shadow-deep);
}
dialog.apply[open] { animation: dialog-in var(--t-med) var(--ease-lens); }
dialog.apply::backdrop { background: color-mix(in oklab, var(--bg-deep) 70%, transparent); backdrop-filter: blur(10px); }
@keyframes dialog-in { from { opacity: 0; filter: blur(12px); transform: translateY(16px) scale(0.98); } }
.apply form { display: grid; gap: 0.9rem; padding: 1.6rem; }
.apply label { display: grid; gap: 0.3rem; font-size: var(--step--1); color: var(--cyan); letter-spacing: 0.06em; }
.apply input, .apply textarea { font: inherit; color: var(--fg); background: var(--bg-deep); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0.7em 0.9em; }
.apply input:focus, .apply textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--glow-accent); }
.apply .row { display: flex; gap: 0.6rem; justify-content: flex-end; }

/* ---------------------------------------------------------------------------------- footer */
.site-footer { padding: 48px var(--gutter) 40px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 1rem 2rem; justify-content: space-between; color: var(--fg-dim); font-size: var(--step--1); position: relative; z-index: 2; }
.site-footer nav { display: flex; gap: 1.2rem; }

/* ---------------------------------------------------------------------------------- page transitions:
   a focus pull. The old page racks out of focus and dims; the new one racks in. */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: rack-out 560ms var(--ease-lens) both; }
::view-transition-new(root) { animation: rack-in 780ms var(--ease-lens) 120ms both; }
::view-transition-group(site-header) { animation-duration: 560ms; }
@keyframes rack-out { to { opacity: 0; filter: blur(22px) brightness(0.7); transform: scale(1.02); } }
@keyframes rack-in { from { opacity: 0; filter: blur(22px) brightness(0.7); transform: scale(0.985); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; transition-duration: 1ms !important; }
  body::after { animation: none; }
  .reveal { animation: none !important; }
}

/* ?clean (screenshots, reels): hide the page copy over the hero */
.clean .hero-copy, .clean .hint, .clean .site-header { display: none; }
