/* The system both sites share: tokens, type, layout, and common components. Studied from
   lightfield.com (docs/lightfield-study.md): a grey page, text in one ink at a few strengths,
   hairlines, small radii, black actions, and colour only where it means something. IBM Plex Sans
   and Mono. Each site sets its own brand colour (--brand-day, --brand-night) and may warm or
   cool the page and ink in its own stylesheet.

   The themes are styled once each: light on :root, dark under [data-theme="dark"], which theme.js
   always resolves on <html>. Any element can take either theme with its own data-theme, so a
   light and a dark specimen can sit side by side; it then needs its own background. */

@font-face {
  font-family: "Plex";
  font-weight: 400;
  font-display: swap;
  src: url("/assets/fonts/IBMPlexSans-Regular-Latin1.woff2") format("woff2");
}
@font-face {
  font-family: "Plex";
  font-weight: 500;
  font-display: swap;
  src: url("/assets/fonts/IBMPlexSans-Medium-Latin1.woff2") format("woff2");
}
@font-face {
  font-family: "Plex Mono";
  font-weight: 400;
  font-display: swap;
  src: url("/assets/fonts/IBMPlexMono-Regular-Latin1.woff2") format("woff2");
}

:root,
[data-theme="light"] {
  --sans: "Plex", system-ui, sans-serif;
  --mono: "Plex Mono", ui-monospace, monospace;
  color-scheme: light;
  --page: #f5f5f5;
  --panel: #ededed;
  --raised: #fafafa;
  --window: #ffffff;
  /* One ink, with a faint blue cast, used at four strengths. */
  --ink: oklch(0.2 0.025 268);
  --text-1: color-mix(in oklab, var(--ink) 90%, transparent);
  --text-2: color-mix(in oklab, var(--ink) 64%, transparent);
  --text-3: color-mix(in oklab, var(--ink) 48%, transparent);
  --text-4: color-mix(in oklab, var(--ink) 24%, transparent);
  --line: color-mix(in oklab, var(--ink) 8%, transparent);
  --line-strong: color-mix(in oklab, var(--ink) 15%, transparent);
  --fill: color-mix(in oklab, var(--ink) 5%, transparent);
  --fill-hover: color-mix(in oklab, var(--ink) 9%, transparent);
  --action: #0c0c0e;
  --action-hover: #2b2b30;
  --on-action: #ffffff;
  --exception: #d0312d;
  --shadow-control: 0 1px 2px rgb(0 0 0 / 0.07), 0 0 0 0.5px rgb(0 0 0 / 0.05);
  /* A hairline edge and a wide, faint lift, as Lightfield's windows have. */
  --shadow-window: 0 0 0 1px rgb(0 0 0 / 0.05), 0 1px 3px rgb(0 0 0 / 0.03), 0 16px 56px rgb(0 0 0 / 0.05);
  /* Windows inside a grey panel sit lower, so they need less lift. */
  --shadow-card: 0 1px 2px rgb(0 0 0 / 0.04), 0 12px 40px rgb(0 0 0 / 0.045);
  --radius-tag: 4px;
  --radius-control: 6px;
  --radius-window: 10px;
  --radius-card: 12px;
  --gutter: clamp(16px, 3.4vw, 56px);
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.2, 0, 0, 1);
  /* The brand colour, set by each site: posted entries and the active state, never an action.
     It has a day and a night value; --brand is the one for the current theme. */
  --brand-day: var(--ink);
  --brand-night: var(--ink);
  --brand: var(--brand-day);
}

[data-theme="dark"] {
  color-scheme: dark;
  --page: #0b0b0c;
  --panel: #121214;
  --raised: #161618;
  --window: #1b1b1e;
  --ink: oklch(0.98 0.004 268);
  --text-1: color-mix(in oklab, var(--ink) 92%, transparent);
  --text-2: color-mix(in oklab, var(--ink) 62%, transparent);
  --text-3: color-mix(in oklab, var(--ink) 45%, transparent);
  --text-4: color-mix(in oklab, var(--ink) 24%, transparent);
  --line: color-mix(in oklab, var(--ink) 9%, transparent);
  --line-strong: color-mix(in oklab, var(--ink) 16%, transparent);
  --fill: color-mix(in oklab, var(--ink) 7%, transparent);
  --fill-hover: color-mix(in oklab, var(--ink) 11%, transparent);
  --action: #f5f5f5;
  --action-hover: #ffffff;
  --on-action: #0b0b0c;
  --exception: #ff6b63;
  --shadow-control: 0 0 0 0.5px rgb(255 255 255 / 0.08);
  --shadow-window: 0 0 0 1px rgb(255 255 255 / 0.04), 0 24px 72px rgb(0 0 0 / 0.5);
  --shadow-card: 0 0 0 1px rgb(255 255 255 / 0.04), 0 16px 48px rgb(0 0 0 / 0.35);
  --brand: var(--brand-night);
}

/* Base */
*,
*::before,
*::after {
  box-sizing: border-box;
}
* {
  margin: 0;
}
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  background: var(--page);
  color: var(--text-1);
  font: 400 17px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
a {
  color: inherit;
}
button {
  font: inherit;
  color: inherit;
}
/* Headings take their size from a type class and never turn bold. */
h1,
h2,
h3,
h4 {
  font-size: inherit;
  font-weight: 400;
}
img,
svg {
  display: block;
}
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
::selection {
  background: color-mix(in oklab, var(--brand) 22%, transparent);
}

/* Type: one weight, hierarchy by size, ink strength, and position. */
.t-d1 {
  font-size: clamp(32px, 3.6vw, 42px);
  line-height: 1.06;
  letter-spacing: -0.04em;
}
.t-d2 {
  font-size: clamp(26px, 2.6vw, 32px);
  line-height: 1.15;
  letter-spacing: -0.032em;
}
.t-h1 {
  font-size: 28px;
  line-height: 1.2;
  letter-spacing: -0.028em;
}
.t-h2 {
  font-size: 24px;
  line-height: 1.25;
  letter-spacing: -0.02em;
}
.t-h3 {
  font-size: 19px;
  line-height: 1.3;
  letter-spacing: -0.01em;
}
.t-lg {
  font-size: 17px;
  line-height: 1.5;
}
.t-base {
  font-size: 15px;
  line-height: 1.5;
}
.t-sm {
  font-size: 13px;
  line-height: 1.5;
}
.t-label {
  font: 500 10px/1 var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
}
/* The grey continuation of a two-tone heading. */
.quiet {
  color: var(--text-3);
}
.dim {
  color: var(--text-2);
}

/* Layout */
.container {
  width: 100%;
  max-width: 1600px;
  margin-inline: auto;
  padding-inline: var(--gutter);
}
/* Text in the first third, content in the other two. */
.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  column-gap: 16px;
}
.section {
  padding-block: 128px 0;
}
.section-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  align-items: baseline;
  column-gap: 16px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.section-head + * {
  margin-top: 56px;
}
.section-head .t-label:last-child {
  font-weight: 400;
}

/* Navigation: a floating bar, translucent over what scrolls beneath it. */
.nav {
  position: fixed;
  inset: 16px 0 auto;
  z-index: 50;
  display: flex;
  justify-content: center;
  pointer-events: none;
}
.nav-bar {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  height: 40px;
  padding: 0 4px 0 12px;
  border-radius: 10px;
  background: color-mix(in oklab, var(--raised) 76%, transparent);
  box-shadow: var(--shadow-control);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: 12px;
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.015em;
  color: var(--text-1);
}
.brand .mark {
  width: 20px;
  height: 20px;
  color: var(--brand);
}
.nav-link {
  padding: 4px 8px;
  border-radius: var(--radius-control);
  font-size: 14px;
  color: var(--text-2);
  text-decoration: none;
  transition: color 0.2s var(--ease);
}
.nav-link:hover {
  color: var(--text-1);
}
.nav-divider {
  width: 1px;
  height: 16px;
  margin-inline: 6px;
  background: var(--line-strong);
}

/* Controls */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-control);
  background: var(--fill);
  color: var(--text-1);
  font-size: 14px;
  letter-spacing: -0.005em;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color 0.2s var(--ease),
    color 0.2s var(--ease);
}
.btn:hover {
  background: var(--fill-hover);
}
.btn-primary {
  background: var(--action);
  color: var(--on-action);
}
.btn-primary:hover {
  background: var(--action-hover);
}
/* The arrow slides in on hover. */
.btn .arrow {
  width: 14px;
  height: 14px;
  margin-right: -2px;
  opacity: 0.7;
  transition:
    transform 0.25s var(--ease-out),
    opacity 0.25s var(--ease-out);
}
.btn:hover .arrow {
  transform: translateX(2px);
  opacity: 1;
}

/* A product window: white, with a hairline edge and one faint lift. */
.window {
  overflow: hidden;
  border-radius: var(--radius-window);
  background: var(--window);
  box-shadow: var(--shadow-window);
  font-family: var(--sans);
}

/* States drawn as in the product: posted is solid brand colour, pending is dithered, an exception is a
   red outline. */
.state {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex: none;
}
.state-posted {
  background: var(--brand);
}
.state-pending {
  background: repeating-conic-gradient(var(--brand) 0 25%, transparent 0 50%) 0 0 / 2px 2px;
  opacity: 0.75;
}
.state-exception {
  box-shadow: inset 0 0 0 1.5px var(--exception);
}

/* Entrances: content below the fold fades in from a slight blur once it is reached. Nothing in
   the first screen ever waits (page.js marks only what starts out of view). */
.reveal-pending {
  opacity: 0;
  filter: blur(6px);
  transform: translateY(8px);
}
.reveal-in {
  transition:
    opacity 0.7s var(--ease-out),
    filter 0.7s var(--ease-out),
    transform 0.7s var(--ease-out);
}

/* A mark slot (page.js) takes the mark's colour. */
[data-mark-slot] {
  display: inline-flex;
  color: var(--brand);
}

/* The reader's theme switch (theme.js), in the footer. */
.theme-switch {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border-radius: 8px;
  background: var(--fill);
}
.theme-switch button {
  display: grid;
  place-items: center;
  width: 28px;
  height: 24px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  transition:
    color 0.2s var(--ease),
    background-color 0.2s var(--ease);
}
.theme-switch button:hover {
  color: var(--text-1);
}
.theme-switch button[aria-pressed="true"] {
  background: var(--window);
  box-shadow: var(--shadow-control);
  color: var(--text-1);
}
.theme-switch svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* The site's mark (its mark.js). */
.mark {
  display: block;
  flex: none;
}

@media (max-width: 900px) {
  /* The section's title takes the first row; its label and number share the second. */
  .section-head {
    grid-template-columns: minmax(0, 1fr) auto;
    row-gap: 12px;
  }
  .section-head > :first-child {
    grid-column: 1 / -1;
  }
  .split {
    grid-template-columns: minmax(0, 1fr);
    row-gap: 32px;
  }
  .section {
    padding-top: 96px;
  }
  .nav-link,
  .nav-divider {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
  .reveal-pending {
    opacity: 1;
    filter: none;
    transform: none;
  }
}
