@font-face {
  font-family: "Plex Sans";
  src: url("fonts/ibm-plex-sans-var.woff2") format("woff2");
  font-weight: 100 700;
  font-display: swap;
}
@font-face {
  font-family: "Plex Mono";
  src: url("fonts/ibm-plex-mono-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

:root {
  --ink: #15131a;
  --soft: #3f3c49;
  --muted: #6d6a78;
  --line: #e5e2ea;
  --bg: #fff;
  --tint: #f6f4f9;
  --accent: #612499;
  --wrap: 1120px;
  --pad: clamp(18px, 4vw, 40px);
  --sans: "Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 76px; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}

body {
  margin: 0;
  font: 400 17px/1.6 var(--sans);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

img { display: block; max-width: 100%; height: auto; }
a { color: inherit; }
h1, h2, h3, p, figure { margin: 0; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.wrap { max-width: var(--wrap); margin-inline: auto; padding-inline: var(--pad); }

.label {
  font: 400 12px/1.4 var(--mono);
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}

.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: #fff; padding: 8px 12px; border-radius: 6px; z-index: 50; }
.skip:focus { left: 8px; }

/* header */

.site-head {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, .9);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 60px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; }
.brand img { height: 30px; width: auto; }

#nav { display: flex; align-items: center; gap: 2px; }
#nav a, .drop > button, .menu-btn {
  font-size: 15px;
  line-height: 1.2;
  padding: 9px 12px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
}
#nav a:hover, .drop > button:hover, .menu-btn:hover { color: var(--ink); background: var(--tint); }
#nav a[aria-current="page"], .drop.here > button { color: var(--ink); font-weight: 500; }

.drop { position: relative; }
.drop > button { display: inline-flex; align-items: center; gap: 6px; }
.drop > button svg { transition: transform .15s; }
.drop.open > button svg { transform: rotate(180deg); }
.drop-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 232px;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 14px 32px -14px rgba(21, 19, 26, .28);
}
.drop.open .drop-menu { display: grid; }
.drop-menu a { display: block; }

.menu-btn { display: none; color: var(--ink); border: 1px solid var(--line); }

@media (max-width: 760px) {
  .menu-btn { display: block; }
  #nav {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 8px var(--pad) 16px;
    background: #fff;
    border-bottom: 1px solid var(--line);
  }
  #nav.open { display: flex; }
  #nav a { padding: 12px 4px; }
  .drop > button { padding: 12px 4px; pointer-events: none; }
  .drop > button svg { display: none; }
  .drop-menu, .drop.open .drop-menu {
    display: grid;
    position: static;
    min-width: 0;
    padding: 0 0 0 16px;
    border: 0;
    border-left: 1px solid var(--line);
    border-radius: 0;
    box-shadow: none;
  }
}

/* home */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr);
  gap: clamp(28px, 5vw, 72px);
  align-items: end;
  padding-block: clamp(40px, 8vw, 104px) clamp(44px, 7vw, 88px);
}
.hero h1 {
  margin-top: 18px;
  font-weight: 500;
  font-size: clamp(2.5rem, 6.4vw, 4.75rem);
  line-height: 1.02;
  letter-spacing: -.035em;
  text-wrap: balance;
}
.hero h1 span { color: var(--accent); }
.lede { margin-top: 24px; max-width: 34em; font-size: clamp(1.05rem, 1.6vw, 1.22rem); color: var(--soft); }
.hero-links { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 22px; margin-top: 30px; }
.hero-photo img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; object-position: 44% 30%; border-radius: 4px; }

.btn {
  display: inline-block;
  padding: 12px 18px;
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  font-weight: 500;
  font-size: 16px;
  text-decoration: none;
  transition: background .15s;
}
.btn:hover { background: var(--accent); }
.text-link { text-decoration: underline; text-decoration-color: var(--line); text-decoration-thickness: 2px; text-underline-offset: 5px; }
.text-link:hover { text-decoration-color: var(--accent); }

.sec { padding-block: clamp(48px, 7vw, 96px); border-top: 1px solid var(--line); }
.sec h2 { font-weight: 500; font-size: clamp(1.7rem, 3.2vw, 2.4rem); line-height: 1.1; letter-spacing: -.028em; }

.lab-intro {
  display: grid;
  grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr);
  gap: clamp(24px, 5vw, 72px);
  align-items: end;
  margin-bottom: clamp(28px, 4vw, 48px);
}
.lab-intro p:not(.label) { margin-top: 14px; max-width: 26em; color: var(--soft); }
.lab-intro figcaption { margin-top: 10px; }

.compare { position: relative; }
.compare-frame { position: relative; overflow: hidden; border-radius: 4px; }
.compare-frame > img { width: 100%; }
.cmp-before { position: absolute; inset: 0; height: 100%; object-fit: cover; clip-path: inset(0 calc(100% - var(--pos, 50%)) 0 0); }
.compare input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: ew-resize;
}
.cmp-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--pos, 50%);
  width: 2px;
  margin-left: -1px;
  background: #fff;
  pointer-events: none;
}
.cmp-handle::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 36px;
  height: 36px;
  margin: -18px 0 0 -18px;
  border-radius: 50%;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2315131a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 7l-5 5 5 5M15 7l5 5-5 5'/%3E%3C/svg%3E") center / 20px no-repeat;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .35);
}
.compare-frame:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

.strip {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  padding-inline: max(var(--pad), calc((100% - var(--wrap)) / 2 + var(--pad)));
  scroll-padding-inline: max(var(--pad), calc((100% - var(--wrap)) / 2 + var(--pad)));
}
.strip::-webkit-scrollbar { display: none; }
.strip figure { flex: none; scroll-snap-align: start; }
.strip img { width: auto; max-width: none; height: clamp(220px, 44vw, 500px); border-radius: 4px; background: var(--tint); }

.strip-ctl { display: flex; align-items: center; justify-content: space-between; margin-top: 18px; }
.strip-ctl div { display: flex; gap: 8px; }
.strip-ctl button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.strip-ctl button:hover:not(:disabled) { background: var(--tint); border-color: var(--ink); }
.strip-ctl button:disabled { opacity: .35; cursor: default; }

.work-head { display: flex; align-items: baseline; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
.work-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--ink); }
.work-list li { border-bottom: 1px solid var(--line); }
.row {
  display: grid;
  grid-template-columns: 3rem minmax(0, 1fr) 64px 5rem;
  align-items: center;
  gap: 16px;
  min-height: 96px;
  margin-inline: -12px;
  padding: 16px 12px;
  text-decoration: none;
}
.row .n { font: 400 13px/1 var(--mono); color: var(--muted); }
.row .t { font-weight: 500; font-size: clamp(1.15rem, 2.5vw, 1.7rem); line-height: 1.2; letter-spacing: -.022em; }
.row .t small { display: inline-block; margin-left: 10px; font: 400 12px/1 var(--mono); letter-spacing: .06em; color: var(--muted); vertical-align: middle; }
.row img { width: 64px; height: 64px; object-fit: cover; border-radius: 4px; }
.row .go { justify-self: end; font-size: 15px; color: var(--muted); white-space: nowrap; transition: transform .15s, color .15s; }
a.row { transition: background .15s; }
a.row:hover { background: var(--tint); }
a.row:hover .go { color: var(--accent); transform: translateX(4px); }

/* footer */

.foot { border-top: 1px solid var(--line); padding-block: clamp(48px, 8vw, 104px) 28px; }
.mail {
  display: inline-block;
  margin-top: 14px;
  font-weight: 500;
  font-size: clamp(1.15rem, 4.6vw, 3.4rem);
  line-height: 1.15;
  letter-spacing: -.03em;
  text-decoration: none;
  overflow-wrap: anywhere;
  border-bottom: 2px solid var(--accent);
  transition: color .15s;
}
.mail:hover { color: var(--accent); }
.foot-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px 24px;
  margin-top: clamp(40px, 6vw, 80px);
  font-size: 14px;
  color: var(--muted);
}
.foot-meta nav { display: flex; flex-wrap: wrap; gap: 6px 20px; }
.foot-meta a { text-decoration: none; }
.foot-meta a:hover { color: var(--ink); }

/* inner pages */

.page-head { padding-block: clamp(36px, 6vw, 76px) clamp(24px, 3.5vw, 44px); }
.page-head h1 {
  margin-top: 14px;
  font-weight: 500;
  font-size: clamp(2.1rem, 5.2vw, 3.6rem);
  line-height: 1.05;
  letter-spacing: -.032em;
  text-wrap: balance;
}
.page-head .label a { text-decoration: none; }
.page-head .label a:hover { color: var(--ink); }
.page-body { padding-bottom: clamp(56px, 8vw, 104px); }

.prose { max-width: 66ch; font-size: 1.06rem; color: var(--soft); }
.prose p + p { margin-top: 1.25em; }
.prose p:first-child { color: var(--ink); }
.prose ul { margin: 1.1em 0 0; padding-left: 1.2em; }
.prose li + li { margin-top: .35em; }
.prose a { text-decoration-color: var(--accent); text-underline-offset: 4px; }

.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, .72fr); gap: clamp(28px, 5vw, 72px); align-items: start; }
.split figure { position: sticky; top: 84px; }
.split figure img { width: 100%; border-radius: 4px; }
.split figcaption { margin-top: 10px; }

.empty { padding: 28px 0; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--line); color: var(--muted); max-width: 66ch; }

/* calculators */

.calc { max-width: 820px; border: 1px solid var(--line); border-radius: 8px; }
.tabs { display: flex; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  flex: none;
  margin-bottom: -1px;
  padding: 15px 18px 13px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  font-size: 15px;
  color: var(--muted);
  cursor: pointer;
}
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); font-weight: 500; border-bottom-color: var(--accent); }
.tabs button:focus-visible { outline-offset: -3px; }

.panel { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; padding: 24px; }
.panel[hidden] { display: none; }
.fields { display: grid; gap: 14px; align-content: start; }
.fields label { display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
.fields input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font: 400 16px/1.3 var(--mono);
  color: var(--ink);
}
.fields input:hover { border-color: #c9c5d2; }
.fields input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.out { display: flex; flex-direction: column; justify-content: space-between; gap: 28px; padding: 20px; border-radius: 6px; background: var(--tint); }
.out output { display: block; margin-top: 8px; font-weight: 500; font-size: clamp(1.9rem, 4.4vw, 2.7rem); line-height: 1.1; letter-spacing: -.03em; overflow-wrap: anywhere; }
.out output small { margin-left: 6px; font-size: .45em; font-weight: 400; letter-spacing: 0; color: var(--muted); }
.formula { font: 400 13px/1.6 var(--mono); color: var(--muted); }

@media (max-width: 760px) {
  .hero, .lab-intro, .split, .panel { grid-template-columns: minmax(0, 1fr); }
  .hero { align-items: start; }
  .hero-photo img { aspect-ratio: 4 / 3; }
  .split figure { position: static; }
  .row { grid-template-columns: 2rem minmax(0, 1fr) 48px; min-height: 76px; gap: 12px; }
  .row img { width: 48px; height: 48px; }
  .row .go { display: none; }
  .row .t small { display: block; margin: 6px 0 0; }
  .panel { padding: 18px; }
}
