/* 0xbf.ch — handwritten. One stylesheet, no build step, no JavaScript.
   Modern CSS: light-dark(), oklch(), color-mix(), clamp(), :is(), :where(),
   text-wrap, fluid type, entry animations, prefers-reduced-motion. */

@font-face {
  font-family: "Commit Mono";
  src: url("/assets/fonts/commit-mono-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Commit Mono";
  src: url("/assets/fonts/commit-mono-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Dark listed first: users with no expressed preference get dark. */
  color-scheme: dark light;

  /* Fallback for engines without light-dark() — dark first, light below. */
  --bg: #161615;
  --fg: #e9e9e6;
  --muted: #8f8f88;
  --line: #2c2c29;
  --accent: oklch(0.78 0.12 255);

  --sans: "Helvetica Neue", ui-sans-serif, sans-serif;
  --mono: "Commit Mono", ui-monospace, monospace;

  --measure: 44rem;
  --gutter: clamp(1.25rem, 5vw, 3rem);

  /* Fluid type scale. */
  --step--1: clamp(0.83rem, 0.80rem + 0.15vw, 0.90rem);
  --step-0: clamp(1.00rem, 0.96rem + 0.20vw, 1.09rem);
  --step-1: clamp(1.20rem, 1.10rem + 0.50vw, 1.45rem);
  --step-2: clamp(1.60rem, 1.40rem + 1.00vw, 2.10rem);
  --step-3: clamp(2.20rem, 1.70rem + 2.40vw, 3.40rem);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #fbfbf9;
    --fg: #161615;
    --muted: #6f6f68;
    --line: #e2e2dc;
    --accent: oklch(0.52 0.15 255);
  }
}

@supports (color: light-dark(#000, #fff)) {
  :root {
    --bg: light-dark(#fbfbf9, #161615);
    --fg: light-dark(#161615, #e9e9e6);
    --muted: light-dark(#6f6f68, #8f8f88);
    --line: light-dark(#e2e2dc, #2c2c29);
    --accent: light-dark(oklch(0.52 0.15 255), oklch(0.78 0.12 255));
  }
}

:where(*, *::before, *::after) {
  box-sizing: border-box;
  margin: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100svh;
  padding: clamp(3rem, 8vw, 6rem) var(--gutter) clamp(4rem, 10vw, 8rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(3rem, 7vw, 5.5rem);

  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: var(--step-0);
  line-height: 1.65;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body > * {
  inline-size: 100%;
  max-inline-size: var(--measure);
}

:is(h1, h2, h3) {
  line-height: 1.15;
  font-weight: 600;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: color-mix(in oklab, var(--accent) 50%, transparent);
  text-underline-offset: 0.2em;
  transition: color 0.2s ease, text-decoration-color 0.2s ease;
}

a:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

::selection {
  background: color-mix(in oklab, var(--accent) 28%, transparent);
}

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

.eyebrow {
  font-family: var(--mono);
  font-size: var(--step--1);
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-block-end: 0.85rem;
}

.eyebrow::before {
  content: "";
  display: inline-block;
  inline-size: 0.5em;
  block-size: 0.5em;
  border-radius: 50%;
  background: var(--accent);
  margin-inline-end: 0.55em;
  vertical-align: 0.05em;
  animation: pulse 2.4s ease-in-out infinite;
}

h1 {
  font-size: var(--step-3);
}

.lede {
  margin-block-start: 1.25rem;
  max-inline-size: 34rem;
  font-size: var(--step-1);
  line-height: 1.5;
  color: var(--muted);
}

.lede em {
  color: var(--fg);
}

.links {
  list-style: none;
  padding: 0;
  margin-block-start: 1.75rem;
  display: flex;
  flex-wrap: wrap;
  row-gap: 0.35rem;
  font-family: var(--mono);
  font-size: var(--step--1);
}

.links li + li::before {
  content: "·";
  margin-inline: 0.55em;
  color: var(--muted);
}

.links a {
  text-decoration-color: color-mix(in oklab, var(--muted) 45%, transparent);
}

main {
  display: flex;
  flex-direction: column;
  gap: clamp(3rem, 7vw, 5rem);
}

section {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

h2 {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  padding-block-end: 0.6rem;
  border-block-end: 1px solid var(--line);
  font-size: var(--step-2);
}

h2 .num {
  font-family: var(--mono);
  font-size: var(--step--1);
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--accent);
}

.tags {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.1rem;
  font-family: var(--mono);
  font-size: var(--step--1);
  color: var(--muted);
}

.tags li::before {
  content: "#";
  color: var(--accent);
  margin-inline-end: 0.1em;
}

.entries {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.entry {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.entry-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1rem;
}

.entry-head h3 {
  font-size: var(--step-0);
}

.when,
.where {
  font-family: var(--mono);
  font-size: var(--step--1);
  color: var(--muted);
}

.when {
  white-space: nowrap;
}

footer {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-block-start: 1.5rem;
  border-block-start: 1px solid var(--line);
  font-family: var(--mono);
  font-size: var(--step--1);
  color: var(--muted);
}

footer .links {
  margin-block: 0;
}

.colophon {
  font-size: 0.92em;
}

.notfound {
  justify-content: center;
  gap: 0;
}

.notfound h1 {
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: -0.04em;
}

@keyframes rise {
  from {
    opacity: 0;
    translate: 0 0.75rem;
  }
  to {
    opacity: 1;
    translate: 0 0;
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
    scale: 1;
  }
  50% {
    opacity: 0.4;
    scale: 0.78;
  }
}

:is(header, footer),
main > section {
  animation: rise 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

main > section:nth-child(1) {
  animation-delay: 0.06s;
}
main > section:nth-child(2) {
  animation-delay: 0.12s;
}
main > section:nth-child(3) {
  animation-delay: 0.18s;
}
main > section:nth-child(4) {
  animation-delay: 0.24s;
}
main > section:nth-child(5) {
  animation-delay: 0.30s;
}

footer {
  animation-delay: 0.34s;
}

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

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
