/* ---------------------------------------------------------------- tokens */

:root {
  --bg:   #e9e7e2;
  --ink:  #15160f;
  --dim:  #57574e;
  --line: #cbc8bf;
  --rule: #d6d3ca;
  --fill: #dedbd3;
  --accent: #b3121f;
}

html[data-theme="dark"] {
  --bg:   #0f1110;
  --ink:  #d8d5cd;
  --dim:  #7e837d;
  --line: #282b29;
  --rule: #1e211f;
  --fill: #151817;
}

/* ------------------------------------------------------------------ base */

* { box-sizing: border-box; }

html {
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--ink); text-decoration: none; }
a:hover { color: var(--ink); background: var(--fill); }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

input {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  outline: none;
}

::selection { background: var(--ink); color: var(--bg); }

[hidden] { display: none !important; }

:focus-visible { outline: 1px solid var(--ink); outline-offset: 2px; }

.page { min-height: 100vh; padding-bottom: 64px; }
.dim { color: var(--dim); }
.grow { flex: 1; }

/* Filler rules that stretch between two labels. */
.rule { flex: 1; min-width: 20px; }
.rule--dashed { border-top: 1px dashed var(--line); }
.rule--dotted { border-top: 1px dotted var(--line); min-width: 18px; }

.prompt { color: var(--dim); font-size: 12.5px; }

/* ---------------------------------------------------------------- header */

.bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 18px;
  padding: 9px 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
}

.host { color: var(--dim); white-space: nowrap; }

.nav { display: flex; gap: 14px; flex-wrap: wrap; }
.nav a { padding: 1px 4px; }

.langs { display: flex; align-items: center; gap: 8px; }
.slash { color: var(--dim); }

.lang {
  padding: 1px 5px;
  border: 1px solid var(--line);
  color: var(--dim);
}
.lang.is-on {
  border-color: transparent;
  color: var(--bg);
  background: var(--ink);
}
.lang[data-lang="pl"].is-on { background: var(--accent); }

.theme-toggle {
  padding: 1px 5px;
  border: 1px solid var(--line);
  color: var(--dim);
  white-space: nowrap;
}

/* ----------------------------------------------------------------- shell */

.main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
}

.section {
  padding: 56px 0 68px;
  border-top: 1px solid var(--rule);
  scroll-margin-top: 52px;
}
.section--hero { padding: 84px 0 68px; border-top: 0; }
.section--last { padding-bottom: 40px; }

.sec-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 36px;
}

/* ------------------------------------------------------------------ hero */

.name {
  margin: 0;
  font-size: clamp(32px, 6.4vw, 66px);
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.02;
  text-wrap: balance;
}

.ruled-row {
  margin: 22px 0 0;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--dim);
  font-size: 12px;
}

.bio {
  margin: 26px 0 0;
  max-width: 68ch;
  font-size: 15px;
  line-height: 1.8;
  color: var(--ink);
}

/* --------------------------------------------------------- cell / card grid */

.cells {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
}

.cell {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 14px;
  background: var(--bg);
  font-size: 13px;
}

.section--hero .cells { margin-top: 46px; }

/* Cards draw their own hairlines so empty slots in the last row stay blank. */
.cells--cards {
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  background: none;
  border: 0;
}

.card {
  display: block;
  padding: 14px;
  background: var(--bg);
  outline: 1px solid var(--line);
}

.card-slug { font-size: 14px; }

.card-desc {
  margin-top: 6px;
  color: var(--dim);
  font-size: 12px;
  line-height: 1.6;
}

/* --------------------------------------------------------------- status */

.status { white-space: nowrap; }
.status::before { content: "\25CF\00a0"; }

/* Which hands built it — mirrors data/tools.yaml on the sister site. */
.tool { white-space: nowrap; }
.tool::before { content: "\2317\00a0"; }

/* ------------------------------------------------------------------ tree */

.tree { font-size: 13.5px; line-height: 2.05; }

.row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0 14px;
  align-items: baseline;
}

.pre { white-space: pre; color: var(--dim); }

.row-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 14px;
  min-width: 0;
}

.label { color: var(--ink); }
.row--head .label { font-weight: 500; }
/* Spacer rows and headings keep the column rhythm without drawing a leader. */
.row--head .rule--dotted { opacity: 0; }

.meta { color: var(--dim); font-size: 12px; }

.when {
  color: var(--dim);
  font-size: 12px;
  min-width: 170px;
  text-align: right;
}
.when a { color: var(--dim); }
.when a:hover { color: var(--ink); }

/* Detail lines under an entry, hanging-indented behind a dash. */
.row--note { line-height: 1.75; padding: 1px 0; }
.row--note + .row:not(.row--note) { padding-top: 6px; }
.row-note {
  max-width: 96ch;
  padding-left: 2ch;
  text-indent: -2ch;
  color: var(--dim);
  font-size: 12.5px;
}
.row-note::before { content: "- "; }
.row-note a { color: var(--dim); border-bottom: 1px dotted var(--line); }
.row-note a:hover { color: var(--ink); border-bottom-color: var(--ink); }

/* --------------------------------------------------------------- console */

.console {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  background: var(--bg);
  border-top: 1px solid var(--line);
}

.console-out {
  max-height: 190px;
  overflow: auto;
  padding: 12px 20px 4px;
  font-size: 12.5px;
  line-height: 1.75;
  color: var(--dim);
  border-bottom: 1px dashed var(--line);
}
.console-out div { white-space: pre-wrap; }

.console-in {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 20px;
  height: 42px;
  font-size: 13px;
}
.console-in input { flex: 1; min-width: 0; height: 42px; }

.caret {
  width: 7px;
  height: 15px;
  background: var(--ink);
  animation: blink 1.1s step-end infinite;
}

@keyframes blink {
  0%, 49%   { opacity: 1; }
  50%, 100% { opacity: 0; }
}

/* --------------------------------------------------- project sub-pages */

.crumbs {
  padding: 22px 0 0;
  color: var(--dim);
  font-size: 12.5px;
}
.crumbs a { color: var(--dim); }
.crumbs a:hover { color: var(--ink); }

.section--proj { padding: 30px 0 48px; }

.name--proj { font-size: clamp(30px, 5.4vw, 54px); }

.proj-sum {
  margin: 20px 0 0;
  max-width: 68ch;
  font-size: 15px;
  line-height: 1.8;
}

.proj-meta {
  margin-top: 26px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 18px;
  font-size: 11.5px;
  color: var(--dim);
}

/* ----------------------------------------------------------------- prose */

.prose { font-size: 14.5px; line-height: 1.85; }
.prose > *:first-child { margin-top: 0; }

.prose h2 {
  margin: 52px 0 18px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--rule);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.prose h2::before { content: "## "; color: var(--dim); font-weight: 400; }

.prose h3 {
  margin: 34px 0 12px;
  font-size: 15.5px;
  font-weight: 600;
}
.prose h3::before { content: "### "; color: var(--dim); font-weight: 400; }

.prose h4 {
  margin: 26px 0 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--dim);
}

.prose p { margin: 16px 0; max-width: 74ch; }
.prose ul, .prose ol { margin: 16px 0; padding-left: 20px; max-width: 74ch; }
.prose li { margin: 7px 0; }
.prose li::marker { color: var(--dim); }

.prose a { border-bottom: 1px dotted var(--line); }
.prose a:hover { border-bottom-color: var(--ink); }

.prose strong { font-weight: 600; }
.prose em { font-style: italic; color: var(--dim); }

.prose hr {
  margin: 44px 0;
  border: 0;
  border-top: 1px dashed var(--line);
}

.prose blockquote {
  margin: 22px 0;
  padding: 2px 0 2px 16px;
  border-left: 2px solid var(--line);
  color: var(--dim);
  max-width: 74ch;
}
.prose blockquote p { margin: 10px 0; }

.prose code {
  padding: 1px 4px;
  background: var(--fill);
  font-size: 0.9em;
}

.prose pre {
  margin: 20px 0;
  padding: 14px 16px;
  overflow-x: auto;
  background: var(--fill);
  border: 1px solid var(--line);
  font-size: 12.5px;
  line-height: 1.7;
}
.prose pre code { padding: 0; background: none; font-size: inherit; }

/* Tables carry a lot of this content — keep them scrollable on phones. */
.tbl { margin: 20px 0; overflow-x: auto; }
.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.prose th, .prose td {
  padding: 8px 12px;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
.prose th {
  background: var(--fill);
  font-weight: 600;
  white-space: nowrap;
}
.prose td.num, .prose th.num { text-align: right; white-space: nowrap; }

.prose details {
  margin: 20px 0;
  border: 1px solid var(--line);
  padding: 0 14px;
}
.prose details[open] { padding-bottom: 12px; }
.prose summary {
  padding: 11px 0;
  cursor: pointer;
  color: var(--dim);
  font-size: 12.5px;
}
.prose summary:hover { color: var(--ink); }

/* Figures pulled from the sister site at hugokatzer.tech. */
.figs {
  margin: 22px 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}
.figs--one { grid-template-columns: minmax(0, 560px); }
.fig { margin: 0; }
.fig img {
  display: block;
  width: 100%;
  height: auto;
  background: var(--fill);
  border: 1px solid var(--line);
}
.fig figcaption {
  margin-top: 8px;
  color: var(--dim);
  font-size: 11.5px;
  line-height: 1.6;
}

.note {
  margin: 24px 0;
  padding: 13px 15px;
  border: 1px dashed var(--line);
  color: var(--dim);
  font-size: 12.5px;
  line-height: 1.7;
}
.note p { margin: 0; max-width: none; }

.tasks { list-style: none; padding-left: 0; }
.tasks li::before { content: "[ ] "; color: var(--dim); }

/* ------------------------------------------------------------- page foot */

.proj-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  padding: 34px 0 10px;
  border-top: 1px solid var(--rule);
  font-size: 12.5px;
}

/* ---------------------------------------------------------------- narrow */

@media (max-width: 560px) {
  .when { min-width: 0; text-align: left; }
  .tree { line-height: 1.9; }
  .section--hero { padding-top: 56px; }
  .prose { font-size: 14px; }
  .figs { grid-template-columns: minmax(0, 1fr); }
}

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