/* ---------- Fonts (self-hosted, SIL Open Font License; Latin and Latin Extended for Turkish and Czech) ---------- */
@font-face {
  font-family: "Bricolage Grotesque"; src: url("../fonts/bricolage-grotesque-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 800; font-style: normal; font-display: swap;
  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: "Atkinson Hyperlegible"; src: url("../fonts/atkinson-hyperlegible-latin-400-normal.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
  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: "Atkinson Hyperlegible"; src: url("../fonts/atkinson-hyperlegible-latin-400-italic.woff2") format("woff2");
  font-weight: 400; font-style: italic; font-display: swap;
  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: "Atkinson Hyperlegible"; src: url("../fonts/atkinson-hyperlegible-latin-700-normal.woff2") format("woff2");
  font-weight: 700; font-style: normal; font-display: swap;
  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: "Bricolage Grotesque"; src: url("../fonts/bricolage-grotesque-latin-ext-wght-normal.woff2") format("woff2");
  font-weight: 200 800; font-style: normal; font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Atkinson Hyperlegible"; src: url("../fonts/atkinson-hyperlegible-latin-ext-400-normal.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Atkinson Hyperlegible"; src: url("../fonts/atkinson-hyperlegible-latin-ext-400-italic.woff2") format("woff2");
  font-weight: 400; font-style: italic; font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Atkinson Hyperlegible"; src: url("../fonts/atkinson-hyperlegible-latin-ext-700-normal.woff2") format("woff2");
  font-weight: 700; font-style: normal; font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------- Tokens ---------- */
:root {
  --paper: #f3f5f7;
  --surface: #ffffff;
  --ink: #15203a;
  --muted: #55607a;
  --rule: #d3d9e2;
  --signal: #f5c400;
  --signal-soft: rgba(245, 196, 0, .28);
  --ok: #1d8656;
  --bad: #c03b34;
  --link: #1d4fd0;
  --chart: #15203a;
  --display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", sans-serif;
  --text: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  --code: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --measure: 66ch;
  --page: 1040px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0e1525; --surface: #151f35; --ink: #e5eaf3; --muted: #9ba7bf;
    --rule: #28344f; --signal-soft: rgba(245, 196, 0, .22); --ok: #3cc487;
    --bad: #f06a60; --link: #8fb0ff; --chart: #e5eaf3; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0e1525; --surface: #151f35; --ink: #e5eaf3; --muted: #9ba7bf;
  --rule: #28344f; --signal-soft: rgba(245, 196, 0, .22); --ok: #3cc487;
  --bad: #f06a60; --link: #8fb0ff; --chart: #e5eaf3; color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 17px/1.6 var(--text);
}
img, svg, canvas { max-width: 100%; }
a { color: var(--link); text-underline-offset: .18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--signal); outline-offset: 2px; border-radius: 2px; }
::selection { background: var(--signal-soft); }

h1, h2, h3 { font-family: var(--display); line-height: 1.12; letter-spacing: -.015em; margin: 0; }
h1 { font-size: clamp(2.5rem, 7vw, 4.4rem); font-weight: 760; letter-spacing: -.035em; }
h2 { font-size: 1.6rem; font-weight: 700; margin-top: 2.4em; margin-bottom: .5em; }
h3 { font-size: 1.18rem; font-weight: 680; margin-top: 1.6em; margin-bottom: .35em; }
p { margin: 0 0 1em; }
p, li { max-width: var(--measure); }
small, .muted { color: var(--muted); }
code, pre, kbd { font-family: var(--code); font-size: .88em; }
kbd { border: 1px solid var(--rule); border-bottom-width: 2px; border-radius: 4px; padding: 0 .35em; background: var(--surface); }
pre {
  background: var(--surface); border: 1px solid var(--rule); border-radius: 6px;
  padding: 14px 16px; overflow-x: auto; line-height: 1.4; font-size: 13px;
}
hr { border: 0; border-top: 1px solid var(--rule); margin: 2.5em 0; }

.wrap { max-width: var(--page); margin: 0 auto; padding: 0 20px; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 12px; background: var(--surface); padding: 8px 12px; z-index: 10; }

/* ---------- Header / nav ---------- */
.site-head { border-bottom: 1px solid var(--rule); }
.site-head .wrap { display: flex; align-items: center; gap: 12px 24px; flex-wrap: wrap; padding-top: 14px; padding-bottom: 14px; }
.brand {
  font-family: var(--display); font-weight: 760; font-size: 1.15rem; color: var(--ink);
  text-decoration: none; display: inline-flex; align-items: center; gap: 9px; margin-right: auto;
}
.beacon {
  width: 10px; height: 10px; border-radius: 50%; background: var(--signal);
  box-shadow: 0 0 0 0 var(--signal-soft); flex: none;
}
.beacon.live { animation: beacon 2.4s ease-out infinite; }
@keyframes beacon { 0% { box-shadow: 0 0 0 0 rgba(245,196,0,.55); } 70%, 100% { box-shadow: 0 0 0 9px rgba(245,196,0,0); } }
.nav { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 0; padding: 0; list-style: none; }
.nav a { color: var(--ink); text-decoration: none; font-size: .97rem; padding: 4px 0; border-bottom: 2px solid transparent; }
.nav a:hover { border-bottom-color: var(--rule); }
.nav a[aria-current="page"] { border-bottom-color: var(--signal); }
.langs { display: flex; gap: 2px; list-style: none; margin: 0; padding: 0; }
.langs a {
  display: inline-block; font-size: .82rem; font-weight: 700; color: var(--muted); text-decoration: none;
  padding: 3px 7px; border-radius: 6px; letter-spacing: .02em;
}
.langs a:hover { color: var(--ink); background: var(--surface); }
.langs a[aria-current="true"] { color: var(--ink); background: var(--signal-soft); }
.theme-btn {
  background: none; border: 1px solid var(--rule); color: var(--ink); border-radius: 999px;
  font: inherit; font-size: .85rem; padding: 3px 12px; cursor: pointer;
}
.theme-btn:hover { border-color: var(--muted); }
@media (max-width: 700px) {
  .site-head .wrap { gap: 8px 12px; padding-top: 12px; padding-bottom: 0; }
  .site-head nav { order: 3; flex-basis: 100%; overflow-x: auto; scrollbar-width: none; margin: 0 -20px; padding: 0 20px; }
  .site-head nav::-webkit-scrollbar { display: none; }
  .nav { flex-wrap: nowrap; gap: 0 18px; white-space: nowrap; padding-bottom: 6px; }
  .nav a { display: inline-block; padding: 6px 0 8px; }
}

/* ---------- Page layout ---------- */
main { padding: 48px 0 72px; }
.lede { font-size: 1.22rem; line-height: 1.5; color: var(--ink); max-width: 56ch; margin-top: .7em; }
.page-title { margin-bottom: .2em; }
.section-intro { color: var(--muted); }

.site-foot { border-top: 1px solid var(--rule); color: var(--muted); font-size: .9rem; }
.site-foot .wrap { padding-top: 22px; padding-bottom: 32px; display: flex; flex-wrap: wrap; gap: 6px 24px; justify-content: space-between; }
.site-foot a { color: var(--muted); }

/* ---------- Home ---------- */
.intro { display: grid; grid-template-columns: auto 1fr; gap: 28px; align-items: center; }
.avatar { width: 112px; height: 112px; border-radius: 22px; object-fit: cover; border: 1px solid var(--rule); background: var(--surface); }
@media (max-width: 560px) { .intro { grid-template-columns: 1fr; gap: 18px; } .avatar { width: 88px; height: 88px; border-radius: 18px; } }

.heartbeat { margin: 44px 0 8px; }
.heartbeat svg { display: block; width: 100%; height: 120px; overflow: visible; }
.heartbeat-cap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px; font-size: .9rem; color: var(--muted); }

.index-list + p { margin-top: 18px; }
.index-list { list-style: none; padding: 0; margin: 12px 0 0; border-top: 1px solid var(--rule); max-width: none; }
.index-list li { max-width: none; border-bottom: 1px solid var(--rule); }
.index-list a {
  display: grid; grid-template-columns: minmax(150px, 220px) 1fr; gap: 4px 24px;
  padding: 16px 4px; text-decoration: none; color: var(--ink);
}
.index-list a:hover { background: var(--surface); }
.index-list strong { font-family: var(--display); font-size: 1.2rem; font-weight: 700; }
.index-list span { color: var(--muted); }
@media (max-width: 560px) { .index-list a { grid-template-columns: 1fr; } }

/* ---------- Projects ---------- */
.project { display: grid; grid-template-columns: 200px 1fr; gap: 8px 32px; padding: 28px 0; border-top: 1px solid var(--rule); }
.project:last-of-type { border-bottom: 1px solid var(--rule); }
.project h2 { margin: 0; font-size: 1.35rem; }
.project .meta { color: var(--muted); font-size: .92rem; margin-top: 6px; }
.project p { margin-bottom: .6em; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 10px 0 0; }
.tags li { font-size: .82rem; border: 1px solid var(--rule); border-radius: 999px; padding: 1px 10px; color: var(--muted); }
@media (max-width: 700px) { .project { grid-template-columns: 1fr; } }

/* ---------- About ---------- */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 24px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

/* ---------- How it works ---------- */
.route-row { list-style: none; padding: 0; margin: 40px 0 8px; display: grid; grid-template-columns: repeat(5, 1fr); max-width: none; }
.route-row li { position: relative; max-width: none; padding: 16px 12px 0 0; border-top: 4px solid var(--rule); transition: border-color .35s; }
.route-row li::before {
  content: ""; position: absolute; left: 0; top: -10px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--paper); border: 3px solid var(--rule); transition: border-color .35s, background .35s;
}
.route-row li b { display: block; font-family: var(--display); font-size: 1.15rem; font-weight: 700; }
.route-row li span { color: var(--muted); font-size: .92rem; }
.route-row li.lit { border-top-color: var(--signal); }
.route-row li.lit::before { border-color: var(--signal); background: var(--signal); }
@media (max-width: 640px) {
  .route-row { grid-template-columns: 1fr; margin-top: 28px; }
  .route-row li { border-top: 0; border-left: 4px solid var(--rule); padding: 6px 0 14px 20px; }
  .route-row li::before { left: -10px; top: 8px; }
  .route-row li.lit { border-left-color: var(--signal); }
}
.steps { counter-reset: step; list-style: none; padding: 0; margin: 0; }
.steps > li { counter-increment: step; position: relative; padding: 0 0 4px 56px; max-width: calc(var(--measure) + 56px); }
.steps > li::before {
  content: counter(step); position: absolute; left: 0; top: .1em;
  font-family: var(--display); font-weight: 760; font-size: 1.6rem; color: var(--muted); width: 40px; text-align: right;
}
.steps h3 { margin-top: 1.4em; }
@media (max-width: 560px) { .steps > li { padding-left: 38px; } .steps > li::before { width: 26px; font-size: 1.35rem; } }
.timing { margin: 18px 0 6px; }
.timing-bar { display: flex; height: 30px; border-radius: 6px; overflow: hidden; border: 1px solid var(--rule); background: var(--surface); }
.timing-bar span { display: block; height: 100%; min-width: 2px; }
.timing-legend { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px 18px; list-style: none; padding: 0; margin: 12px 0 0; max-width: none; }
.timing-legend li { display: flex; align-items: baseline; gap: 8px; font-size: .93rem; }
.swatch { width: 11px; height: 11px; border-radius: 3px; flex: none; transform: translateY(1px); }
.t-dns { background: #7b8cff; } .t-tcp { background: #4bb3a6; } .t-tls { background: #f5c400; }
.t-wait { background: #e57a52; } .t-down { background: #9aa3b5; }
.headers { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: .95rem; }
.headers th, .headers td { text-align: left; vertical-align: top; padding: 10px 12px 10px 0; border-top: 1px solid var(--rule); }
.headers th { font-family: var(--code); font-weight: 600; font-size: .85rem; white-space: nowrap; }
.headers .val { font-family: var(--code); font-size: .78rem; color: var(--muted); word-break: break-word; margin-top: 4px; }
.headers .missing { color: var(--bad); }
@media (max-width: 700px) {
  .headers thead { display: none; }
  .headers tr { display: block; border-top: 1px solid var(--rule); padding: 8px 0; }
  .headers th, .headers td { display: block; border: 0; padding: 2px 0; }
}

.ping-bars { display: flex; align-items: flex-end; gap: 6px; height: 70px; margin-top: 10px; max-width: 520px; }
.ping-bars span { flex: 1; background: var(--ink); border-radius: 3px 3px 0 0; min-height: 3px; }

/* ---------- Charts ---------- */
.spark-line { fill: none; stroke: var(--chart); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.spark-area { fill: var(--signal-soft); stroke: none; }
.spark-grid { stroke: var(--rule); stroke-width: 1; vector-effect: non-scaling-stroke; }

/* ---------- Buttons & controls ---------- */
.btn {
  font: inherit; font-size: .95rem; font-weight: 700; cursor: pointer;
  background: var(--ink); color: var(--paper); border: 1px solid var(--ink);
  border-radius: 8px; padding: 7px 14px;
}
.btn:hover { opacity: .88; }
.btn.secondary { background: transparent; color: var(--ink); border-color: var(--rule); }
.btn.secondary:hover { border-color: var(--muted); opacity: 1; }
.btn:disabled { opacity: .45; cursor: default; }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: 12px 0; }
.controls label { display: inline-flex; align-items: center; gap: 6px; font-size: .95rem; }
select, input[type="number"] {
  font: inherit; font-size: .95rem; color: var(--ink); background: var(--surface);
  border: 1px solid var(--rule); border-radius: 8px; padding: 5px 8px;
}
input[type="range"] { accent-color: var(--ink); }
input[type="checkbox"] { accent-color: var(--ink); width: 16px; height: 16px; }

/* ---------- Status ---------- */
.readings { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; margin: 24px 0 8px; border-top: 1px solid var(--rule); }
.reading { padding: 16px 16px 16px 0; border-bottom: 1px solid var(--rule); }
.reading b { display: block; font-family: var(--display); font-size: 1.9rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.reading span { color: var(--muted); font-size: .92rem; }
@media (max-width: 560px) { .readings { grid-template-columns: repeat(2, minmax(0, 1fr)); } .reading b { font-size: 1.6rem; } }
.state { display: inline-flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 700; font-size: 1.25rem; margin-top: .6em; }
.state .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--muted); }
.state.ok .dot { background: var(--ok); }
.state.bad .dot { background: var(--bad); }
.chart { margin: 14px 0 4px; }
.chart svg { display: block; width: 100%; height: 150px; overflow: visible; }
.chart-cap { display: flex; justify-content: space-between; color: var(--muted); font-size: .85rem; }
details.plain { border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); padding: 10px 0; margin-top: 18px; }
details.plain summary { cursor: pointer; font-weight: 700; }
details.plain pre { margin: 12px 0 4px; }

/* ---------- Playground ---------- */
.toy { padding: 8px 0 28px; border-bottom: 1px solid var(--rule); }
.toy:last-of-type { border-bottom: 0; }
.toy-grid { display: grid; grid-template-columns: minmax(0, 360px) minmax(0, 1fr); gap: 24px 40px; align-items: start; }
.toy-grid.wide { grid-template-columns: 1fr; }
@media (max-width: 760px) { .toy-grid { grid-template-columns: 1fr; } }
.board { display: block; width: 100%; aspect-ratio: 1 / 1; border: 1px solid var(--rule); border-radius: 8px; background: var(--surface); touch-action: none; cursor: pointer; }
.board:focus-visible { outline: 3px solid var(--signal); outline-offset: 3px; }
.board.life { aspect-ratio: 16 / 9; cursor: crosshair; }
.board.sort { aspect-ratio: 16 / 7; cursor: default; }
.scoreline { display: flex; justify-content: space-between; font-size: .95rem; margin-bottom: 8px; }
.out {
  font-family: var(--code); font-size: 1.05rem; background: var(--surface); border: 1px solid var(--rule);
  border-radius: 8px; padding: 12px 14px; word-break: break-all; min-height: 3em; user-select: all;
}
.meter { height: 8px; border-radius: 4px; background: var(--rule); overflow: hidden; margin-top: 8px; }
.meter i { display: block; height: 100%; width: 0; background: var(--ok); transition: width .2s; }

/* ---------- Notes ---------- */
.notes-list { list-style: none; padding: 0; margin: 20px 0 0; border-top: 1px solid var(--rule); max-width: none; }
.notes-list li { max-width: none; padding: 18px 0; border-bottom: 1px solid var(--rule); }
.notes-list a { font-family: var(--display); font-size: 1.3rem; font-weight: 700; text-decoration: none; color: var(--ink); }
.notes-list a:hover { text-decoration: underline; }
.notes-list time { display: block; color: var(--muted); font-size: .9rem; margin-top: 2px; }
.notes-list p { margin: 6px 0 0; }
.prose { max-width: var(--measure); }
.prose h2 { font-size: 1.4rem; }
.prose img { border-radius: 6px; }
.prose blockquote { margin: 1.2em 0; padding: 2px 0 2px 18px; border-left: 3px solid var(--signal); color: var(--muted); }
.prose table { border-collapse: collapse; }
.prose th, .prose td { border-top: 1px solid var(--rule); padding: 6px 12px 6px 0; text-align: left; }
.post-meta { color: var(--muted); margin-top: .5em; }

/* ---------- 404 ---------- */
.lost { font-family: var(--display); font-size: clamp(5rem, 22vw, 11rem); font-weight: 800; letter-spacing: -.06em; line-height: .9; color: var(--rule); margin: 0 0 .1em; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
