/* EB Garamond, self-hosted (variable, latin subset). SIL OFL license. */
@font-face {
  font-family: 'EB Garamond';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("fonts/eb-garamond-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215,
    U+FEFF, U+FFFD;
}

:root {
  color-scheme: dark;
  --bg: #0A0A0A;
  --ink: #F2F0EC;
  --ink-secondary: #8A8A85;
  --ink-muted: #B8B6B0;
  --accent: #4FA3B8;
  --hairline: #232323;
  --selection: #1E3A42;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'EB Garamond', Georgia, 'Times New Roman', serif;
  font-size: 20px;
  line-height: 1.7;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}

/* matte grain — the black reads as material, not void */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.035;
  filter: grayscale(100%);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

::selection {
  background: var(--selection);
  color: var(--ink);
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 3px;
  transition: text-decoration-color 150ms ease, color 150ms ease, background 150ms ease;
}

a:hover {
  text-decoration-color: currentColor;
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px; /* fallback for engines without clamp() */
  padding: 0 clamp(20px, 4vw, 48px);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

header {
  padding: 28px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--hairline);
}

.wordmark {
  font-size: 24px;
  font-weight: 500;
  letter-spacing: 0.02em;
  line-height: 1;
  color: var(--ink);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.logo {
  height: 30px;
  width: auto;
  transform: translateY(1px); /* optical: sit the mark on the lowercase x-height band */
}

nav {
  display: flex;
  align-items: center;
  gap: 24px;
  font-size: 16px;
}

.navlink {
  color: var(--ink-secondary);
  text-decoration: none;
}

.navlink:hover {
  color: var(--ink);
  text-decoration: none;
}

.navlink[aria-current] {
  color: var(--ink);
}

/* contact button — machined rectangle, the only outlined control */
.pill {
  border: 1px solid var(--ink);
  border-radius: 4px;
  padding: 10px 22px;
  font-size: 16px;
  font-weight: 400;
  line-height: 1;
  color: var(--ink);
  text-decoration: none;
}

.pill:hover {
  background: var(--ink);
  color: var(--bg);
  text-decoration: none;
}

main {
  flex: 1;
}

/* 404: the block is centred in the viewport */
.home-main {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-bottom: 6vh; /* optical centre sits slightly high */
}

h1 {
  font-size: 44px;
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

/* landing hero: sized by its own padding, not locked to the viewport */
.hero {
  position: relative; /* positioning context for the lava canvas */
  isolation: isolate; /* the canvas at z-index -1 stays inside the hero, above the page background */
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 5rem 0 6rem; /* fallback for engines without clamp() */
  padding: clamp(3.5rem, 9vh, 6rem) 0 clamp(4rem, 10vh, 7rem);
}

.hero h1 {
  font-size: clamp(2.75rem, 2rem + 2.5vw, 4rem);
  line-height: 1.08;
  letter-spacing: -0.02em;
  max-width: 16ch;
  text-wrap: balance;
}

.hero .lede {
  margin-top: 2rem;
  font-size: 1.15rem;
  line-height: 1.6;
  max-width: 44ch; /* 46ch leaves a lone word on the last line in Firefox */
  color: var(--ink-muted);
  text-wrap: pretty; /* no lone word on the last line, where supported */
}

.hero .cta {
  margin-top: 3rem;
  font-size: 1.15rem;
  line-height: 1.4;
}

/* pixel lava lamp behind the hero copy (drawn by lava.js); never taller than the hero, so nothing is clipped */
#lava {
  position: absolute;
  z-index: -1;
  top: 0;
  bottom: 0;
  right: 0; /* flush to the column edge, like everything else on the grid */
  margin: auto 0; /* vertically centred on the copy block */
  height: 100%; /* fallback for engines without min() */
  height: min(100%, 44vw); /* shrinks on tablets before it can slide under the headline (same ink colour) */
  width: auto;
  aspect-ratio: 1;
  image-rendering: crisp-edges; /* Firefox < 93 */
  image-rendering: pixelated; /* 96 cells scaled up: keep the grid crisp */
  pointer-events: none;
  /* soft disc: fully transparent at 70%, where the box edge sits, so it never shows a hard edge */
  -webkit-mask-image: radial-gradient(circle at center, #000 45%, transparent 70%);
  mask-image: radial-gradient(circle at center, #000 45%, transparent 70%);
}

/* below 820px the copy needs the width: the disc becomes a faint backdrop bleeding off the right edge */
@media (max-width: 820px) {
  .page {
    overflow-x: hidden; /* fallback for engines without clip */
    overflow-x: clip; /* cut at the viewport edge, never a horizontal scrollbar */
  }
  #lava {
    bottom: auto; /* anchored to the top: behind the large ink headline, not the muted lede */
    right: -30%;
    height: min(100%, 90vw);
    opacity: 0.35;
  }
}

/* landing: the whole page fits one screen, so nothing scrolls.
   Padding is viewport-scaled and the two bands absorb whatever height is left over,
   so the page ends exactly at the fold instead of running past it.
   Desktop only — phones keep the natural rhythm below and simply scroll. */
@media (min-width: 821px) {
  .landing {
    display: flex;
    flex-direction: column;
  }
  /* the two bands grow equally into the leftover height, each keeping its copy centred,
     so the page ends exactly at the fold at any window height */
  .landing .hero,
  .landing .stat-band {
    flex: 1 1 auto;
    justify-content: center;
  }
  .landing .hero {
    padding: 2rem 0; /* fallback for engines without clamp() */
    padding: clamp(1.25rem, 4vh, 4.5rem) 0;
  }
  /* on a short window the hero's own rhythm gives way first, so the two bands stay apart */
  .landing .hero .lede {
    margin-top: 1.5rem; /* fallback for engines without clamp() */
    margin-top: clamp(1rem, 2.5vh, 2rem);
  }
  .landing .hero .cta {
    margin-top: 2rem; /* fallback for engines without clamp() */
    margin-top: clamp(1.25rem, 4vh, 3rem);
  }
  /* the hero band now grows with the window; the disc must not follow it under the headline */
  .landing #lava {
    height: min(100%, 44vw, 33rem);
  }
  .landing .stat-band {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 0 0 2rem; /* fallback for engines without clamp() */
    padding: 0 0 clamp(1.25rem, 4vh, 4.5rem);
  }
}

/* the one statistic, alone in its band */
.stat-band {
  padding: 9rem 0;
}

.stat {
  font-size: clamp(1.75rem, 1.4rem + 1.2vw, 2rem);
  line-height: 1.25;
  letter-spacing: -0.01em;
  max-width: 24ch;
  text-wrap: balance;
}

.context {
  margin-top: 20px;
  color: var(--ink-secondary);
  max-width: 60ch;
}

.cta {
  margin-top: 40px;
}

.sub-main {
  padding: 64px 0 96px;
}

/* solutions + writing: the measure sits centred in the wide column, not hard left */
.sub-main.centered {
  width: 100%;
  max-width: 62ch;
  margin-left: auto;
  margin-right: auto;
}

.section + .section {
  margin-top: 72px;
}

/* section label — also carries the h1/h2 on the sub-pages, so the outline exists without a visual change */
.label {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-secondary);
  margin-bottom: 24px;
}

.section p {
  max-width: 62ch;
}

.section p + p {
  margin-top: 1.2em;
}

/* the two engagements (solutions.html): each one named on its own line, dot-marked,
   so the two things Cytokai does are scannable before the sentence is read */
.offer-list {
  list-style: none;
  margin-top: 32px;
}

.offer-list li {
  position: relative;
  max-width: 62ch;
  padding-left: 26px;
  color: var(--ink-muted);
}

.offer-list li + li {
  margin-top: 28px;
}

.offer-list li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0.72em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink-secondary);
}

.offer-name {
  display: block;
  font-weight: 600;
  color: var(--ink);
}

.muted {
  color: var(--ink-secondary);
}

footer {
  padding: 24px 0 32px;
  border-top: 1px solid var(--hairline);
  font-size: 16px;
  color: var(--ink-secondary);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

@media (max-width: 600px) {
  h1 {
    font-size: 33px;
  }
  .stat-band {
    padding: 5.5rem 0;
  }
  nav {
    gap: 12px;
  }
  .pill {
    padding: 8px 16px;
  }
  .wordmark {
    font-size: 22px;
    gap: 10px;
  }
  .logo {
    height: 27px;
  }
}

/* narrow phones: the mark alone carries the identity */
@media (max-width: 420px) {
  .wordmark-text {
    display: none;
  }
}

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

/* post index (writing.html) */
.post-list {
  list-style: none;
}

.post-list li {
  display: flex;
  align-items: baseline;
  gap: 20px;
}

.post-list li + li {
  margin-top: 14px;
}

.post-list time {
  flex-shrink: 0;
  font-size: 16px;
  color: var(--ink-secondary);
  font-variant-numeric: tabular-nums;
}

/* long-form articles (posts/) */
.post-meta {
  font-size: 15px;
  color: var(--ink-secondary);
  margin-bottom: 12px;
}

article {
  max-width: 62ch; /* keep the article measure inside the wide container */
  overflow-wrap: break-word;
}

article h1 {
  margin-bottom: 40px;
}

article h2 {
  font-size: 25px;
  font-weight: 500;
  line-height: 1.35;
  margin: 2.2em 0 0.7em;
}

article h3 {
  font-size: 20px;
  font-weight: 500;
  margin: 2em 0 0.6em;
}

article p,
article ul,
article ol,
article blockquote {
  max-width: 62ch;
}

article p + p {
  margin-top: 1.2em;
}

article ul,
article ol {
  margin: 1.2em 0;
  padding-left: 1.4em;
}

article li + li {
  margin-top: 0.5em;
}

article blockquote {
  margin: 1.6em 0;
  padding-left: 20px;
  border-left: 2px solid var(--hairline);
  color: var(--ink-secondary);
}

article code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88em;
}

article pre {
  margin: 1.6em 0;
  padding: 16px 20px;
  border: 1px solid var(--hairline);
  overflow-x: auto;
  line-height: 1.6;
}

article pre code {
  font-size: 15px;
}

article hr {
  border: 0;
  border-top: 1px solid var(--hairline);
  margin: 3em 0;
}

article img {
  max-width: 100%;
  height: auto;
}

article figure {
  margin: 2em 0;
}

article figcaption {
  margin-top: 10px;
  font-size: 15px;
  color: var(--ink-secondary);
}

article table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.6em 0;
  font-size: 16px;
}

article th,
article td {
  text-align: left;
  padding: 8px 16px 8px 0;
  border-bottom: 1px solid var(--hairline);
}

article th {
  font-weight: 500;
}

.post-back {
  margin-top: 72px;
  font-size: 15px;
}

/* cross-document page transitions — progressive enhancement, no JS */
@media (prefers-reduced-motion: no-preference) {
  @view-transition {
    navigation: auto;
  }
}
