/* ------------------------------------------------------------------
   Nece Labs — visual system
   Palette: borosilicate paper, bottle ink, copper-sulfate blue.
   Type: Archivo (width axis) for display + body, IBM Plex Mono for labels.
   Spacing: 4 · 8 · 16 · 32 · 64 · 128.
   Radius: none. Geometry stays precise.
------------------------------------------------------------------- */

:root {
  --paper: #edf1ee;
  --paper-2: #e2e8e4;
  --ink: #0e1714;
  --ink-2: #16211d;
  --muted: #4e5e57;
  --line: #c6d1cb;
  --grid: #d9e1dc;
  --accent: #1e3df0;
  --accent-ink: #1531c2;
  --white: #ffffff;

  --font-sans: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --s1: 0.25rem;
  --s2: 0.5rem;
  --s3: 1rem;
  --s4: 2rem;
  --s5: 4rem;
  --s6: 8rem;

  --gutter: clamp(1.25rem, 5vw, 4rem);
  --section: clamp(4.5rem, 10vw, 8.5rem);
  --nav-h: 4.25rem;

  --text: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-sm: 0.875rem;
  --text-xs: 0.75rem;
  --lede: clamp(1.125rem, 1rem + 0.6vw, 1.375rem);
  --h3: clamp(1.25rem, 1.1rem + 0.6vw, 1.625rem);
  --h2: clamp(2rem, 1.35rem + 2.8vw, 3.9rem);
  --h1: clamp(2.75rem, 1.4rem + 5.6vw, 6.25rem);

  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* ---------- Base ---------- */

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 1rem);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text);
  line-height: 1.55;
  font-stretch: 100%;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
p,
ul,
ol,
figure,
pre {
  margin: 0;
}

ul,
ol {
  padding: 0;
  list-style: none;
}

a {
  color: inherit;
}

svg {
  display: block;
}

/* Shared symbol/clip definitions: kept in the render tree (so <use> and clipPath resolve everywhere) but invisible. */
.svg-defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

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

.section--ink :focus-visible,
.section--accent :focus-visible {
  outline-color: var(--paper);
}

.skip-link {
  position: absolute;
  top: -100%;
  left: var(--s3);
  z-index: 100;
  padding: var(--s2) var(--s3);
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  text-decoration: none;
}

.skip-link:focus {
  top: var(--s3);
}

.container {
  width: min(100% - 2 * var(--gutter), 82rem);
  margin-inline: auto;
}

/* ---------- Type roles ---------- */

.eyebrow {
  display: flex;
  align-items: center;
  gap: 0.8em;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.eyebrow::before {
  content: "";
  flex: none;
  width: 0.55em;
  height: 0.55em;
  background: currentColor;
}

.tag {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

h1 {
  font-size: var(--h1);
  font-weight: 700;
  font-stretch: 118%;
  line-height: 0.94;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

h2 {
  font-size: var(--h2);
  font-weight: 650;
  font-stretch: 112%;
  line-height: 1.02;
  letter-spacing: -0.02em;
  text-wrap: balance;
  max-width: 20ch;
}

h3 {
  font-size: var(--h3);
  font-weight: 600;
  font-stretch: 106%;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.lede,
.section-lede {
  font-size: var(--lede);
  line-height: 1.45;
  color: var(--muted);
  max-width: 52ch;
  text-wrap: pretty;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.7em;
  padding: 0.95em 1.4em;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 500;
  font-stretch: 105%;
  line-height: 1;
  letter-spacing: 0.005em;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease), border-color 0.2s var(--ease);
}

.btn:hover {
  background: var(--ink);
  color: var(--paper);
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--white);
}

.btn--primary:hover {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

.btn--paper {
  background: var(--paper);
  border-color: var(--paper);
  color: var(--ink);
}

.btn--paper:hover {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

.btn--small {
  padding: 0.75em 1.1em;
  font-size: 0.875rem;
}

.btn--large {
  padding: 1.1em 1.7em;
  font-size: 1.05rem;
}

.btn span {
  transition: transform 0.2s var(--ease);
}

.btn:hover span {
  transform: translateX(3px);
}

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.nav {
  display: flex;
  align-items: center;
  gap: var(--s4);
  min-height: var(--nav-h);
}

.brand {
  display: inline-flex;
  color: var(--ink);
  text-decoration: none;
}

.logo {
  height: 1.55rem;
  width: auto;
}

.mark-ink {
  fill: currentColor;
}

.mark-liquid {
  fill: var(--accent);
}

.mark-void {
  fill: var(--paper);
}

.nav-links {
  display: flex;
  gap: var(--s4);
  margin-left: auto;
}

.nav-links a {
  position: relative;
  display: inline-block;
  padding: var(--s2) 0;
  font-size: var(--text-sm);
  font-weight: 500;
  font-stretch: 104%;
  text-decoration: none;
  color: var(--muted);
  transition: color 0.2s var(--ease);
}

.nav-links a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 100%;
  bottom: 0.15rem;
  height: 2px;
  background: var(--accent);
  transition: right 0.25s var(--ease);
}

.nav-links a:hover,
.nav-links a[aria-current="true"] {
  color: var(--ink);
}

.nav-links a:hover::after,
.nav-links a[aria-current="true"]::after {
  right: 0;
}

.nav-toggle {
  display: none;
  margin-left: auto;
  padding: var(--s2) var(--s3);
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

.nav-toggle[aria-expanded="true"] {
  background: var(--ink);
  color: var(--paper);
}

/* ---------- Hero ---------- */

.hero {
  position: relative;
  overflow: hidden;
}

/* Lab-notebook dot grid, fading out toward the first section. */
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: radial-gradient(var(--grid) 1.1px, transparent 1.1px);
  background-size: 24px 24px;
  background-position: center top;
  -webkit-mask-image: linear-gradient(to bottom, #000 50%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 50%, transparent 100%);
}

.hero-inner {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--s4) var(--s3);
  align-items: center;
  min-height: calc(100svh - var(--nav-h));
  padding-block: clamp(3rem, 6vw, 5rem);
}

.hero-copy {
  grid-column: 1 / span 7;
  display: grid;
  gap: var(--s4);
}

.hero-copy h1 {
  margin-top: var(--s1);
}

.hero-figure {
  grid-column: 8 / -1;
  display: flex;
  justify-content: center;
}

.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s3);
}

.flask {
  width: 100%;
  max-width: 380px;
  height: auto;
  overflow: visible;
}

.glass,
.liquid {
  transform-box: view-box;
}

.liquid-body {
  fill: var(--accent);
}

.glass-outline {
  fill: none;
  stroke: var(--ink);
  stroke-width: 2.5;
  stroke-linejoin: round;
}

.glass-highlight {
  fill: none;
  stroke: var(--paper);
  stroke-width: 3;
  stroke-linecap: square;
  opacity: 0.55;
}

.ticks path {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.5;
  opacity: 0.6;
}

.ticks text {
  font-family: var(--font-mono);
  font-size: 11px;
  fill: var(--muted);
}

.bubble,
.caret {
  fill: var(--paper);
}

.caret {
  animation: blink 1.1s steps(1) infinite;
}

.bubble {
  opacity: 0;
  animation: bubble var(--d, 4s) linear infinite;
  animation-delay: var(--dl, 0s);
}

.liquid-fill {
  animation: fill 1.4s var(--ease) both;
  animation-delay: 0.25s;
}

.reveal {
  animation: rise 0.8s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 110ms);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes fill {
  from {
    transform: translateY(150px);
  }
  to {
    transform: none;
  }
}

@keyframes bubble {
  0% {
    opacity: 0;
    transform: translateY(0);
  }
  12% {
    opacity: 0.95;
  }
  88% {
    opacity: 0.95;
  }
  100% {
    opacity: 0;
    transform: translateY(-88px);
  }
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

/* ---------- Sections ---------- */

.section {
  padding-block: var(--section);
}

.section--rule {
  border-top: 1px solid var(--line);
}

.section-head {
  display: grid;
  gap: var(--s3);
  margin-bottom: clamp(var(--s4), 6vw, var(--s5));
}

.section-head h2 {
  margin-top: var(--s2);
}

.section--ink {
  background: var(--ink);
  color: var(--paper);
}

.section--ink .section-lede,
.section--ink .tag {
  color: #a7b5ae;
}

.section--ink .eyebrow {
  color: #8da3ff;
}

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

.section--accent .eyebrow {
  color: var(--white);
}

.section--accent .section-lede {
  color: #d5dcff;
}

/* ---------- Services ---------- */

.services-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s4) var(--s4);
}

.service {
  display: grid;
  align-content: start;
  gap: var(--s3);
  padding-top: var(--s3);
  border-top: 1px solid var(--ink);
}

.service h3 {
  margin-top: var(--s2);
}

.service p:not(.tag) {
  color: var(--muted);
}

.pixel-list {
  display: grid;
  gap: var(--s2);
  margin-top: var(--s2);
}

.pixel-list li {
  position: relative;
  padding-left: 1.25em;
  font-size: var(--text-sm);
  line-height: 1.5;
}

.pixel-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 0.45em;
  height: 0.45em;
  background: var(--accent);
}

/* ---------- Bench ---------- */

.bench-grid {
  display: grid;
  grid-template-columns: 7fr 5fr;
  gap: var(--s5);
  align-items: start;
}

.bench-grid > * {
  min-width: 0;
}

.code-panel {
  border: 1px solid #2a3731;
  background: var(--ink-2);
}

.code-head {
  display: flex;
  justify-content: space-between;
  gap: var(--s3);
  padding: var(--s2) var(--s3);
  border-bottom: 1px solid #2a3731;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.04em;
}

.code-file {
  color: var(--paper);
}

.code-note {
  color: #7f8f88;
  font-style: italic;
}

.code-panel pre {
  padding: var(--s3) var(--s3) var(--s4);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: clamp(0.78rem, 0.72rem + 0.25vw, 0.9rem);
  line-height: 1.65;
  color: #d3dcd7;
  tab-size: 2;
}

.tk-cm {
  color: #7f8f88;
  font-style: italic;
}

.tk-kw {
  color: #8da3ff;
}

.tk-fn {
  color: var(--paper);
  font-weight: 500;
}

.tk-str {
  color: #b8f0d8;
}

.tk-pn {
  color: #7f8f88;
}

.bench-notes {
  display: grid;
  gap: var(--s4);
  counter-reset: note;
}

.bench-notes li {
  display: grid;
  gap: var(--s2);
  padding-top: var(--s3);
  border-top: 1px solid #2a3731;
}

.bench-notes h3 {
  font-size: 1.125rem;
}

.bench-notes p {
  color: #a7b5ae;
  font-size: var(--text-sm);
  line-height: 1.6;
}

/* ---------- Work ---------- */

.work-list {
  display: grid;
  border-top: 1px solid var(--ink);
}

.work-item {
  display: grid;
  grid-template-columns: 5fr 5fr 2fr;
  gap: var(--s4);
  padding-block: var(--s4);
  border-bottom: 1px solid var(--line);
}

.work-title {
  display: grid;
  gap: var(--s2);
  align-content: start;
}

.work-body p {
  color: var(--muted);
  text-wrap: pretty;
}

.work-meta {
  display: grid;
  gap: var(--s2);
  align-content: start;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.5;
  color: var(--muted);
}

.work-meta li::before {
  content: "— ";
  color: var(--accent);
}

/* ---------- Process ---------- */

.process-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s4);
}

.step {
  display: grid;
  align-content: start;
  gap: var(--s3);
  padding-top: var(--s3);
  border-top: 1px solid var(--ink);
}

.step-index {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--accent);
}

.step > p:not(.step-index):not(.step-label) {
  color: var(--muted);
}

.step-label {
  margin-top: var(--s2);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
}

/* ---------- Contact ---------- */

.contact .section-head {
  margin-bottom: var(--s4);
}

.contact h2 {
  max-width: 16ch;
  font-size: clamp(2.5rem, 1.5rem + 4.5vw, 5.5rem);
}

.contact-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s3) var(--s4);
}

.contact-alt {
  color: #d5dcff;
}

.contact-alt a {
  color: var(--white);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

/* ---------- Footer ---------- */

.site-footer {
  padding-block: var(--s4);
  border-top: 1px solid var(--line);
}

.footer-inner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--s3) var(--s4);
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: var(--s3);
}

.footer-brand .logo {
  height: 1.25rem;
}

.footer-name {
  font-size: var(--text-sm);
  color: var(--muted);
}

.footer-name strong {
  color: var(--ink);
  font-weight: 600;
}

.footer-nav {
  display: flex;
  gap: var(--s3) var(--s4);
  flex-wrap: wrap;
}

.footer-nav a {
  font-size: var(--text-sm);
  color: var(--muted);
  text-decoration: none;
}

.footer-nav a:hover {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.footer-copy {
  justify-self: end;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--muted);
}

/* ---------- Responsive ---------- */

@media (max-width: 1024px) {
  .hero-copy {
    grid-column: 1 / span 8;
  }

  .hero-figure {
    grid-column: 9 / -1;
  }

  .flask {
    max-width: 300px;
  }

  .bench-grid {
    grid-template-columns: 1fr;
    gap: var(--s4);
  }

  .work-item {
    grid-template-columns: 1fr 1fr;
  }

  .work-meta {
    grid-column: 1 / -1;
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    gap: var(--s3);
  }
}

@media (max-width: 820px) {
  .nav {
    flex-wrap: wrap;
    gap: var(--s3);
  }

  .nav-toggle {
    display: inline-flex;
  }

  .nav-cta {
    display: none;
  }

  .nav-links {
    display: none;
    flex-direction: column;
    gap: 0;
    width: 100%;
    margin: 0;
    padding-bottom: var(--s3);
  }

  .nav-links.is-open {
    display: flex;
  }

  .nav-links a {
    display: block;
    padding: var(--s3) 0;
    font-size: var(--lede);
    border-top: 1px solid var(--line);
  }

  .nav-links a::after {
    display: none;
  }

  .hero-inner {
    min-height: 0;
    align-items: start;
  }

  .hero-copy {
    grid-column: 1 / -1;
  }

  .hero-figure {
    grid-column: 1 / -1;
    justify-content: flex-start;
    margin-top: var(--s4);
  }

  .flask {
    max-width: 260px;
  }

  .services-grid,
  .process-grid {
    grid-template-columns: 1fr;
  }

  .work-item {
    grid-template-columns: 1fr;
    gap: var(--s3);
  }

  .work-meta {
    grid-auto-flow: row;
    gap: var(--s2);
  }

  .footer-inner {
    grid-template-columns: 1fr;
  }

  .footer-copy {
    justify-self: start;
  }
}

@media (max-width: 480px) {
  .cta-row .btn {
    flex: 1 1 100%;
    justify-content: center;
  }

  .contact-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .contact-actions .btn {
    justify-content: center;
  }
}

/* ---------- Motion preferences ---------- */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .reveal,
  .liquid-fill,
  .caret {
    animation: none;
  }

  .bubble {
    animation: none;
    opacity: 0.9;
    transform: translateY(-44px);
  }

  .btn span,
  .nav-links a::after,
  .btn {
    transition: none;
  }
}
