/* Plain A11y website. Same design language as bereg.dev ("Engineering Blueprint"): dark only, IBM Plex, one stylesheet.
   Order: fonts, tokens, base, header and footer, layout, components, motion, accessibility, print.
   No scripts, no external fonts, no trackers. */

/* ---------- Fonts: self-hosted IBM Plex (latin), the same files as on bereg.dev. Sans is one variable file, 200-700. ---------- */
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/plex-mono-400.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;
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 200 700;
  font-display: swap;
  src: url('fonts/plex-sans-var.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;
}
/* Metric-matched fallbacks: system text is scaled to Plex's size and line box, so the swap does not shift the layout. */
@font-face { font-family: 'IBM Plex Sans Fallback'; font-weight: 100 500; src: local('Arial'); size-adjust: 100.8%; ascent-override: 101.7%; descent-override: 27.3%; line-gap-override: 0%; }
@font-face { font-family: 'IBM Plex Sans Fallback'; font-weight: 600 900; src: local('Arial Bold'), local('Arial-BoldMT'); size-adjust: 98.7%; ascent-override: 103.8%; descent-override: 27.9%; line-gap-override: 0%; }
@font-face { font-family: 'IBM Plex Mono Fallback'; src: local('Courier New'); size-adjust: 100%; ascent-override: 102.5%; descent-override: 27.5%; line-gap-override: 0%; }

/* ---------- Tokens. Dark only, as on bereg.dev. All colors live here. ---------- */
@property --tick { syntax: '<length>'; inherits: false; initial-value: 11px; }

:root {
  --bg: #0a1220;
  --surface: #0d1829;
  --text: #dbe6f5;
  --muted: #8ea3bf;
  --line: #1f3350;
  --accent: #78c2ff;
  --accent-ink: #06101d;
  --amber: #f2b45e;
  /* Channels, for translucent versions of the accent and of the drawing grid. */
  --accent-rgb: 120 194 255;
  --grid: rgb(120 170 255 / 0.055);
  --grid-major: rgb(120 170 255 / 0.1);
  color-scheme: dark;

  --font: 'IBM Plex Sans', 'IBM Plex Sans Fallback', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: var(--font);
  --mono: 'IBM Plex Mono', 'IBM Plex Mono Fallback', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --wrap: 1040px;
  --s1: 8px;
  --s2: 16px;
  --s3: 24px;
  --s4: 32px;
  --s8: 64px;

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

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 16px; }

body {
  position: relative;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.65 var(--font);
  -webkit-font-smoothing: antialiased;
}

/* The drawing grid: top of the page only, fades out downwards, with crosshair dots on the major lines. */
body::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 1100px; z-index: -1; pointer-events: none;
  background-image:
    linear-gradient(to right, var(--grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid) 1px, transparent 1px),
    linear-gradient(to right, var(--grid-major) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-major) 1px, transparent 1px),
    radial-gradient(circle at 50% 50%, rgb(var(--accent-rgb) / 0.5) 1.5px, transparent 2.5px);
  background-size: 24px 24px, 24px 24px, 120px 120px, 120px 120px, 120px 120px;
  background-position: 0 0, 0 0, 0 0, 0 0, -60px -60px;
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 0%, transparent 100%);
  animation: appear 1.4s ease-out both;
}

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

a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--amber); text-decoration-thickness: 2px; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
::selection { background: rgb(var(--accent-rgb) / 0.28); color: #fff; }

.skip {
  position: absolute; left: var(--s2); top: -100px; z-index: 10;
  background: var(--accent); color: var(--accent-ink); padding: var(--s1) var(--s2); border-radius: 6px;
}
.skip:focus { top: var(--s2); }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 var(--s3); }

h1, h2, h3 { font-family: var(--display); line-height: 1.1; letter-spacing: -0.02em; margin: 0; }
h1 { font-size: clamp(38px, 6.4vw, 68px); font-weight: 700; letter-spacing: -0.04em; line-height: 1.04; }
h2 { font-size: clamp(28px, 3.6vw, 38px); font-weight: 600; }
h3 { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0 0 var(--s2); }
code { font-family: var(--mono); font-size: 0.9em; background: var(--surface); border: 1px solid var(--line); border-radius: 2px; padding: 1px 5px; }

.meta { font-family: var(--mono); font-size: 13px; color: var(--muted); letter-spacing: 0.01em; }
.muted { color: var(--muted); }

/* ---------- Header and footer ---------- */
header.site { border-bottom: 1px solid var(--line); background: color-mix(in oklab, var(--bg) 88%, transparent); }
header.site .wrap { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; min-height: 72px; padding-top: var(--s1); padding-bottom: var(--s1); }
.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; font-family: var(--display); font-weight: 700; font-size: 18px; letter-spacing: -0.02em; }
.brand img { height: 36px; width: 36px; }
.brand:hover { color: var(--text); }
nav ul { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s3); list-style: none; margin: 0; padding: 0; }
nav a { display: inline-block; color: var(--muted); text-decoration: none; font-family: var(--mono); font-size: 13px; letter-spacing: 0.04em; padding: 12px 0 10px; border-bottom: 2px solid transparent; }
nav a:hover { color: var(--text); }
nav a[aria-current='page'] { color: var(--accent); border-bottom-color: var(--accent); }

footer.site { border-top: 1px solid var(--line); padding: var(--s4) 0; color: var(--muted); font-family: var(--mono); font-size: 13px; }
footer.site .wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s2); }
footer.site ul { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s3); list-style: none; margin: 0; padding: 0; }
footer.site a { display: inline-block; padding: 8px 0; color: var(--muted); }
footer.site a:hover { color: var(--text); }
footer.site p { margin: 0; }
footer.site .site-note { flex-basis: 100%; font-size: 12px; letter-spacing: 0.02em; }

/* ---------- Layout ---------- */
main { padding: var(--s8) 0; counter-reset: sec; }
section.block { margin-top: var(--s8); }
section.block:first-child { margin-top: 0; }

/* Section head: numbered, with a dimension line (end ticks) that draws itself. */
.block-head { position: relative; display: flex; align-items: baseline; justify-content: space-between; gap: var(--s2); margin-bottom: var(--s3); padding-bottom: var(--s2); flex-wrap: wrap; }
.block-head::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 9px; transform-origin: left center;
  background:
    linear-gradient(var(--line), var(--line)) left bottom / 1px 9px no-repeat,
    linear-gradient(var(--line), var(--line)) right bottom / 1px 9px no-repeat,
    linear-gradient(var(--line), var(--line)) center bottom / 100% 1px no-repeat;
}
.block-head h2::before {
  counter-increment: sec;
  content: counter(sec, decimal-leading-zero) ' /';
  content: counter(sec, decimal-leading-zero) ' /' / ''; /* empty alt text: not read out by screen readers */
  font: 400 13px var(--mono); letter-spacing: 0.04em; color: var(--amber); margin-right: 0.9em; vertical-align: 0.35em;
}

.lede { font-size: clamp(18px, 2.2vw, 21px); line-height: 1.55; font-weight: 300; color: var(--muted); max-width: 62ch; }
.lead { font-size: 19px; line-height: 1.55; color: var(--muted); max-width: 62ch; }

.hero { display: grid; gap: var(--s4); padding-bottom: var(--s2); align-items: center; }
@media (min-width: 900px) { .hero { grid-template-columns: 1fr 1.05fr; } }
.hero h1 span { display: block; color: var(--muted); font-weight: 300; font-size: max(0.36em, 19px); letter-spacing: -0.01em; text-wrap: balance; margin-top: var(--s2); }
.hero .lede { margin: var(--s2) 0 0; color: var(--text); font-weight: 400; }
.hero img { border: 1px solid var(--line); border-radius: 2px; box-shadow: 0 0 40px rgb(var(--accent-rgb) / 0.12); }
.actions { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; margin-top: var(--s3); }
.actions .meta { margin: 0; }

.btn {
  display: inline-block; padding: 12px 20px; border-radius: 2px; text-decoration: none;
  font-family: var(--mono); font-size: 13px; font-weight: 400; letter-spacing: 0.06em; text-transform: uppercase;
  border: 1px solid var(--accent);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--amber); border-color: var(--amber); color: var(--accent-ink); }

/* Facts as a drawing title block */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1px; margin: var(--s4) 0 0; padding: 0; list-style: none; background: var(--line); border: 1px solid var(--line); }
.facts li { background: var(--surface); padding: var(--s2) var(--s3) var(--s3); }
.facts strong { display: block; font-family: var(--display); font-size: 48px; font-weight: 600; letter-spacing: -0.03em; line-height: 1.05; }
.facts span { color: var(--muted); font-size: 15px; }

/* ---------- Cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--s3); margin: 0; padding: 0; list-style: none; }

.card {
  position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 2px;
  padding: var(--s3); display: flex; flex-direction: column; gap: var(--s1);
  transition: border-color 0.15s;
}
.card h3 { margin-bottom: 4px; font-size: 20px; }
.card p { color: var(--muted); margin: 0; font-size: 16px; }
.tag { align-self: flex-start; font: 12px var(--mono); color: var(--muted); border: 1px solid var(--line); border-radius: 2px; padding: 2px 10px; }

/* Corner ticks: grow and turn amber on hover. */
.card::before {
  --tc: var(--accent);
  content: ''; position: absolute; inset: -1px; pointer-events: none; opacity: 0.5;
  background:
    linear-gradient(var(--tc), var(--tc)) top left / var(--tick) 1px no-repeat,
    linear-gradient(var(--tc), var(--tc)) top left / 1px var(--tick) no-repeat,
    linear-gradient(var(--tc), var(--tc)) top right / var(--tick) 1px no-repeat,
    linear-gradient(var(--tc), var(--tc)) top right / 1px var(--tick) no-repeat,
    linear-gradient(var(--tc), var(--tc)) bottom left / var(--tick) 1px no-repeat,
    linear-gradient(var(--tc), var(--tc)) bottom left / 1px var(--tick) no-repeat,
    linear-gradient(var(--tc), var(--tc)) bottom right / var(--tick) 1px no-repeat,
    linear-gradient(var(--tc), var(--tc)) bottom right / 1px var(--tick) no-repeat;
  transition: opacity 0.15s, --tick 0.25s var(--ease);
}
.card:hover { border-color: color-mix(in oklab, var(--amber) 45%, var(--line)); }
.card:hover::before { --tick: 22px; --tc: var(--amber); opacity: 1; }

/* Steps: numbered cards. */
.steps { counter-reset: step; list-style: none; margin: var(--s3) 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--s3); }
.steps li { counter-increment: step; }
.steps li h3::before { content: 'Step ' counter(step); display: block; margin-bottom: var(--s1); font: 400 13px var(--mono); letter-spacing: 0.04em; color: var(--amber); }

/* ---------- Screenshots ---------- */
.gallery { display: grid; gap: var(--s4); margin: var(--s3) 0 0; grid-template-columns: repeat(auto-fit, minmax(min(100%, 24rem), 1fr)); }
.gallery figure { margin: 0; }
.gallery img { width: 100%; border: 1px solid var(--line); border-radius: 2px; }
.gallery figcaption { margin-top: var(--s1); color: var(--muted); font-size: 15px; }
.gallery figcaption strong { color: var(--text); font-weight: 600; }

/* ---------- Lists ---------- */
.columns { display: grid; gap: var(--s4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr)); margin-top: var(--s3); }
.columns h3 { font: 400 13px var(--mono); letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); margin-bottom: var(--s2); }
.columns ul, .bullets { margin: 0 0 var(--s2); padding-left: 1.2em; }
.columns li, .bullets li { margin-bottom: 8px; }

dl.perm { margin: var(--s3) 0 0; display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); }
dl.perm div { background: var(--surface); padding: var(--s2) var(--s3); display: grid; grid-template-columns: 140px 1fr; gap: var(--s2); }
dl.perm dt { font-family: var(--mono); font-size: 14px; color: var(--accent); }
dl.perm dd { margin: 0; color: var(--muted); }
@media (max-width: 640px) { dl.perm div { grid-template-columns: 1fr; gap: 4px; } }

.code { margin: var(--s2) 0 var(--s3); overflow-x: auto; border: 1px solid var(--line); border-radius: 2px; background: var(--surface); }
.code pre { margin: 0; padding: var(--s2); font: 14px/1.6 var(--mono); }
.code code { background: none; border: 0; padding: 0; font-size: inherit; }

details { background: var(--surface); border: 1px solid var(--line); border-radius: 2px; margin: 0 0 var(--s1); }
summary { cursor: pointer; padding: var(--s2) var(--s3); font-weight: 600; min-height: 48px; }
summary:hover { color: var(--accent); }
details p { margin: 0; padding: 0 var(--s3) var(--s2); color: var(--muted); }

/* ---------- Text pages (privacy, license, 404) ---------- */
.article { max-width: 68ch; }
.article h1 { margin: var(--s1) 0 var(--s2); }
.article h2 { margin: var(--s4) 0 var(--s2); font-size: 30px; }
.article ul { padding-left: 1.3em; margin: 0 0 var(--s2); }
.article li { margin-bottom: 6px; }
.legal { overflow-x: auto; margin: var(--s2) 0 var(--s3); padding: var(--s3); background: var(--surface); border: 1px solid var(--line); border-radius: 2px; }
.legal pre { margin: 0; white-space: pre-wrap; font: 14px/1.6 var(--mono); }

/* ---------- Motion ---------- */
@keyframes appear { from { opacity: 0; } }
@keyframes draw { from { transform: scaleX(0); } }

/* Scroll reveal of the dimension lines, only where the browser can do it without JavaScript. */
@supports (animation-timeline: view()) {
  .block-head::after { animation: draw linear both; animation-timeline: view(); animation-range: entry 0% entry 70%; }
}

/* ---------- Accessibility and print ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Forced colors (Windows high contrast): no decoration layers. */
@media (forced-colors: active) {
  body::before, .card::before { display: none; }
  .btn.primary { forced-color-adjust: none; background: ButtonFace; color: ButtonText; border-color: ButtonText; }
}

@media print {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  body::before { display: none; }
}
