/* wiest-lab.eu
 *
 * Two cuts of one typeface, Iosevka: the monospace for structure and code, Iosevka Etoile for
 * prose. The page is exactly 80 columns of the monospace wide (80 x 0.5em at 17px = 680px), and
 * the name on the home page is sized so its twelve characters fill those 80 columns.
 */

@font-face { font-family: Iosevka; src: url(/fonts/iosevka-400.woff2) format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: Iosevka; src: url(/fonts/iosevka-400i.woff2) format('woff2'); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: Iosevka; src: url(/fonts/iosevka-700.woff2) format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: Iosevka; src: url(/fonts/iosevka-800.woff2) format('woff2'); font-weight: 800; font-style: normal; font-display: swap; }
@font-face { font-family: Etoile; src: url(/fonts/etoile-400.woff2) format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: Etoile; src: url(/fonts/etoile-400i.woff2) format('woff2'); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: Etoile; src: url(/fonts/etoile-700.woff2) format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }

:root {
  --paper: #ffffff;
  --ink: #1a1c20;
  --muted: #5f6570;
  --rule: #e2e4e8;
  --accent: #0b4fcf;
  --code-bg: #f4f5f7;
  --mark: #fff0a0;

  --k-keyword: #0b4fcf;
  --k-string: #1d7344;
  --k-number: #a03a00;
  --k-type: #0d6b7a;
  --k-title: #6b2fb0;
  --k-meta: #8a5600;

  --mono: Iosevka, ui-monospace, 'Cascadia Mono', Consolas, monospace;
  --prose: Etoile, Iosevka, Georgia, serif;
  --w: 42.5rem; /* 80 columns */
  --pad: clamp(1.25rem, 5vw, 2.5rem);

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #17191d;
    --ink: #e4e6ea;
    --muted: #9aa1ab;
    --rule: #2c3036;
    --accent: #8cb2ff;
    --code-bg: #1f2227;
    --mark: #4a4220;

    --k-keyword: #8cb2ff;
    --k-string: #8fd1a5;
    --k-number: #f0a575;
    --k-type: #7fd0dc;
    --k-title: #c9a5ff;
    --k-meta: #e6c06e;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1.0625rem/1.5 var(--mono);
  font-kerning: normal;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--mark); color: inherit; }

a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
a:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 1px; }

.skip { position: absolute; left: -999px; top: 0; }
.skip:focus { left: var(--pad); top: 0.5rem; background: var(--paper); padding: 0.25rem 0.5rem; z-index: 2; }

/* ---------- frame ---------- */

.bar, main, .foot {
  width: 100%;
  max-width: calc(var(--w) + 2 * var(--pad));
  margin-inline: auto;
  padding-inline: var(--pad);
}

.bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 1.5rem;
  font-size: 0.9375rem;
}
.bar .mark { font-weight: 700; text-decoration: none; }
.bar nav { display: flex; gap: 1.25rem; flex-wrap: wrap; justify-content: flex-end; }
.bar nav a { text-decoration: none; color: var(--muted); }
.bar nav a:hover { color: var(--accent); }
.bar a[aria-current='page'] { color: var(--ink); text-decoration: underline; }
.is-home .bar .mark[aria-current='page'] { text-decoration: none; }

.foot {
  margin-top: 6rem;
  padding-block: 1.5rem 3rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.875rem;
}
.foot p { margin: 0 0 0.35rem; }
.foot .stats { font-variant-numeric: tabular-nums; }

/* ---------- home ---------- */

.hero {
  container-type: inline-size;
  padding-top: clamp(2rem, 9vw, 5.5rem);
  margin-bottom: clamp(3rem, 8vw, 5rem);
}

/* Iosevka's advance is exactly half an em, so 12 characters are 6em: 100cqi / 6 fills the column. */
.name {
  margin: 0;
  font-size: calc(100cqi / 6);
  font-weight: 800;
  line-height: 0.95;
  letter-spacing: 0;
  white-space: nowrap;
  font-feature-settings: 'calt' 0;
}

/* The visit counter: 32 bits in 8 nibbles, as wide as the name */
.register { margin: 1.25rem 0 0; }
.register .bits { display: grid; grid-template-columns: repeat(8, 1fr); gap: calc(100cqi / 80); }
.register .bits span { display: grid; grid-template-columns: repeat(4, 1fr); gap: calc(100cqi / 240); }
.register i {
  display: block;
  aspect-ratio: 1;
  border: 1px solid var(--rule);
  border-radius: 1px;
}
.register i.on { background: var(--ink); border-color: var(--ink); }
.register i.flip { border-color: var(--accent); }
.register i.on.flip { background: var(--accent); }
.register .ends {
  display: flex;
  justify-content: space-between;
  margin-top: 0.35rem;
  font-size: 0.75rem;
  color: var(--muted);
}
.register figcaption { margin-top: 0.2rem; font-size: 0.8125rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* 78 characters of `hexdump -C` in 80 columns: scaled with the column like the name */
.dump {
  margin: 1.5rem 0 0;
  color: var(--muted);
  font-feature-settings: 'calt' 0;
}
.dump pre {
  margin: 0;
  font: calc(100cqi / 40) / 1.55 var(--mono);
  white-space: pre;
  overflow: hidden;
}
.dump b { font-weight: 700; color: var(--ink); }
.dump figcaption {
  margin-top: 0.6rem;
  font-size: 0.8125rem;
  color: var(--muted);
}

.intro {
  max-width: 34rem;
  margin-top: 2.25rem;
  font-family: var(--prose);
  font-size: 1.25rem;
  line-height: 1.55;
}
.intro p { margin: 0 0 0.8em; }
.intro a { color: var(--accent); }

.year {
  display: grid;
  grid-template-columns: 8ch 1fr;
  align-items: baseline;
  border-top: 1px solid var(--rule);
  padding-top: 1rem;
  margin-bottom: 2.25rem;
}
.year h2 {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 400;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.posts { list-style: none; margin: 0; padding: 0; }
.posts li {
  display: grid;
  grid-template-columns: 8ch 1fr;
  align-items: baseline;
  margin-bottom: 1.25rem;
}
.posts time { color: var(--muted); font-size: 0.9375rem; font-variant-numeric: tabular-nums; }
.posts a { font-weight: 700; font-size: 1.125rem; text-decoration: none; line-height: 1.3; }
.posts a:hover { text-decoration: underline; }
.posts p { margin: 0.2rem 0 0; font-family: var(--prose); color: var(--muted); font-size: 1rem; line-height: 1.5; }
.posts .is-draft a { color: var(--muted); }

.flag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 400;
  line-height: 1;
  padding: 0.2rem 0.35rem;
  border: 1px solid currentColor;
  border-radius: 2px;
  color: var(--k-meta);
  vertical-align: 0.15em;
}

.empty { color: var(--muted); font-family: var(--prose); font-size: 1.125rem; }

@media (max-width: 34rem) {
  .year { grid-template-columns: 1fr; }
  .year h2 { margin-bottom: 0.75rem; }
  .posts li { grid-template-columns: 7ch 1fr; }
}

/* ---------- posts ---------- */

.page-head { padding-top: clamp(1.5rem, 6vw, 3.5rem); margin-bottom: 2.25rem; }

.title {
  margin: 0;
  font-size: clamp(2rem, 1.2rem + 3.6vw, 3rem);
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: 0;
  text-wrap: balance;
}

.meta, .lede { margin: 1rem 0 0; color: var(--muted); font-size: 0.9375rem; }
.meta a { color: inherit; }

.draft-note {
  margin: 0 0 1.5rem;
  padding: 0.6rem 0.8rem;
  border-left: 3px solid var(--k-meta);
  background: var(--code-bg);
  font-size: 0.9375rem;
}

.edit { margin-top: 3rem; font-size: 0.9375rem; }

.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-top: 4rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
}
.pager a { text-decoration: none; font-weight: 700; line-height: 1.35; }
.pager a span { display: block; font-weight: 400; color: var(--muted); font-size: 0.875rem; margin-bottom: 0.2rem; }
.pager a[rel='next'] { text-align: right; grid-column: 2; }

.message { padding-top: clamp(1.5rem, 6vw, 3.5rem); }
.message .prose { margin-top: 1.5rem; }

/* ---------- prose ---------- */

.prose {
  font-family: var(--prose);
  font-size: 1.125rem;
  line-height: 1.7;
  overflow-wrap: break-word;
}
.prose > :first-child { margin-top: 0; }
.prose p, .prose ul, .prose ol, .prose blockquote, .prose table, .prose figure, .prose details { margin: 0 0 1.15em; }
.prose a { color: var(--accent); }
.prose strong { font-weight: 700; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li { margin-bottom: 0.3em; }
.prose li::marker { color: var(--muted); }

.prose h1, .prose h2, .prose h3, .prose h4 {
  position: relative;
  font-family: var(--mono);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: 0;
  margin: 2.4em 0 0.7em;
  scroll-margin-top: 1.5rem;
  text-wrap: balance;
}
.prose h1, .prose h2 { font-size: 1.375rem; }
.prose h3 { font-size: 1.15rem; }
.prose h4 { font-size: 1rem; }
.prose .anchor {
  position: absolute;
  left: -1.1em;
  color: var(--muted);
  text-decoration: none;
  font-weight: 400;
  opacity: 0;
}
.prose h2:hover .anchor, .prose h3:hover .anchor, .prose h4:hover .anchor, .prose .anchor:focus-visible { opacity: 1; }

.prose blockquote {
  padding-left: 1.1em;
  border-left: 2px solid var(--rule);
  color: var(--muted);
  font-style: italic;
}

.prose hr { border: 0; border-top: 1px solid var(--rule); margin: 2.5em 0; }

.prose img, .prose video { display: block; max-width: 100%; height: auto; margin: 2em auto; }
.prose p > img:only-child { margin-block: 0; }
.prose figure img { margin-bottom: 0.6em; }
.prose figcaption { font-family: var(--mono); font-size: 0.875rem; color: var(--muted); text-align: center; }
.prose iframe { display: block; width: 100%; aspect-ratio: 16 / 9; border: 0; margin: 2em 0; }

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 0.9375rem;
  font-variant-numeric: tabular-nums;
  display: block;
  overflow-x: auto;
}
.prose th, .prose td { text-align: left; padding: 0.4em 1.2em 0.4em 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
.prose th { font-weight: 700; border-bottom-color: var(--muted); }

.prose kbd {
  font-family: var(--mono);
  font-size: 0.85em;
  padding: 0.05em 0.35em;
  border: 1px solid var(--rule);
  border-bottom-width: 2px;
  border-radius: 3px;
}

.prose code, .prose kbd, .prose samp { font-family: var(--mono); }
.prose :not(pre) > code {
  font-size: 0.9em;
  padding: 0.08em 0.3em;
  background: var(--code-bg);
  border-radius: 2px;
}

.prose .footnotes { margin-top: 3.5em; font-size: 0.9375rem; color: var(--muted); }
.prose .footnotes-sep { margin-top: 3.5em; }
.prose .footnote-ref a, .prose .footnote-backref { text-decoration: none; }

/* ---------- code ---------- */

pre.code {
  position: relative;
  margin: 1.6em 0;
  padding: 1rem 1.25rem;
  background: var(--code-bg);
  border-radius: 2px;
  overflow-x: auto;
  font: 0.875rem/1.6 var(--mono);
  tab-size: 4;
  font-feature-settings: 'calt' 0;
}
pre.code code { font: inherit; }
pre.code[data-lang]::before {
  content: attr(data-lang);
  position: absolute;
  top: 0.4rem;
  right: 0.65rem;
  font-size: 0.75rem;
  color: var(--muted);
}
@media (min-width: 52rem) {
  .prose > pre.code { margin-inline: -1.25rem; }
}

.hljs-keyword, .hljs-selector-tag, .hljs-doctag { color: var(--k-keyword); }
.hljs-string, .hljs-regexp, .hljs-addition, .hljs-attribute, .hljs-template-tag { color: var(--k-string); }
.hljs-number, .hljs-literal, .hljs-symbol, .hljs-bullet { color: var(--k-number); }
.hljs-type, .hljs-built_in, .hljs-class .hljs-title, .hljs-title.class_ { color: var(--k-type); }
.hljs-title, .hljs-title.function_, .hljs-section, .hljs-name { color: var(--k-title); }
.hljs-meta, .hljs-meta .hljs-keyword, .hljs-variable.language_, .hljs-attr, .hljs-selector-class { color: var(--k-meta); }
.hljs-comment, .hljs-quote { color: var(--muted); font-style: italic; }
.hljs-deletion { color: var(--k-number); }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 700; }

/* ---------- controls ---------- */

.button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font: 0.875rem/1.2 var(--mono);
  padding: 0.5rem 0.85rem;
  border: 1px solid var(--ink);
  border-radius: 2px;
  background: var(--ink);
  color: var(--paper);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.button:hover { color: var(--paper); background: var(--accent); border-color: var(--accent); }
.button.quiet { background: transparent; color: var(--ink); border-color: var(--rule); }
.button.quiet:hover { color: var(--accent); border-color: var(--accent); background: transparent; }
.button:disabled { opacity: 0.5; cursor: default; }
.button input[type='file'] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
label.button { position: relative; }
label.button:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
select.button { appearance: none; padding-right: 0.85rem; }
.quiet { color: var(--muted); }

/* ---------- editor ---------- */

.is-admin main, .is-admin .bar { max-width: calc(72rem + 2 * var(--pad)); }
.is-editor main { max-width: none; padding-inline: 0; }
.is-editor .bar { max-width: none; padding-block: 0.9rem; border-bottom: 1px solid var(--rule); }

.admin-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; padding-top: 2rem; margin-bottom: 2rem; }
.admin-head .title { font-size: 2rem; }
.actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.import { margin: 0; }

.table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; font-variant-numeric: tabular-nums; }
.table th { text-align: left; font-weight: 400; color: var(--muted); padding: 0 1rem 0.5rem 0; border-bottom: 1px solid var(--muted); }
.table td { padding: 0.65rem 1rem 0.65rem 0; border-bottom: 1px solid var(--rule); vertical-align: baseline; }
.table td:first-child a { font-weight: 700; text-decoration: none; }
.table td:first-child a:hover { text-decoration: underline; }
.table .where { display: block; color: var(--muted); font-size: 0.8125rem; margin-top: 0.1rem; }
.table .num { text-align: right; }
@media (max-width: 44rem) {
  .table th:nth-child(2), .table td:nth-child(2), .table th:nth-child(5), .table td:nth-child(5), .table th:nth-child(6), .table td:nth-child(6) { display: none; }
}

.hint { margin-top: 1.5rem; color: var(--muted); font-size: 0.875rem; max-width: 46rem; line-height: 1.6; }
.hint code, .account code { background: var(--code-bg); padding: 0 0.25em; }
.account { margin-top: 3rem; padding-top: 1rem; border-top: 1px solid var(--rule); font-size: 0.9375rem; }
.account h2 { font-size: 1rem; margin: 0 0 0.5rem; }
.account form { margin-top: 1rem; }

.notice { padding: 0.6rem 0.8rem; border-left: 3px solid var(--k-string); background: var(--code-bg); font-size: 0.9375rem; }
.errors { padding: 0.6rem 0.9rem; border-left: 3px solid var(--k-number); background: var(--code-bg); font-size: 0.9375rem; margin: 0 0 1rem; }
.errors p, .errors ul { margin: 0; }
.errors ul { padding-left: 1.2rem; }

.editor { display: flex; flex-direction: column; height: calc(100dvh - 3.3rem); }
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.6rem;
  padding: 0.6rem var(--pad);
  border-bottom: 1px solid var(--rule);
  font-size: 0.9375rem;
}
.toolbar .grow { flex: 1; }
.toolbar .state { color: var(--muted); font-size: 0.875rem; }
.toolbar .state.is-dirty { color: var(--k-meta); }
.toolbar .state.is-error { color: var(--k-number); }
.editor > .errors { margin: 0; border-left-width: 3px; padding-inline: var(--pad); }

.panes { flex: 1; display: grid; grid-template-columns: 1fr 1fr; min-height: 0; }
.panes textarea {
  width: 100%;
  height: 100%;
  resize: none;
  border: 0;
  border-right: 1px solid var(--rule);
  padding: 1.25rem var(--pad);
  background: var(--code-bg);
  color: var(--ink);
  font: 0.9375rem/1.65 var(--mono);
  tab-size: 4;
  outline: none;
}
.panes textarea.is-dropping { background: var(--mark); }
.preview { overflow-y: auto; padding: 1.5rem var(--pad) 4rem; }
.preview > * { max-width: var(--w); }
.preview .page-head { padding-top: 0; }

.danger { padding: 0.5rem var(--pad); border-top: 1px solid var(--rule); margin: 0; }

@media (max-width: 52rem) {
  .editor { height: auto; }
  .panes { grid-template-columns: 1fr; }
  .panes textarea { height: 70vh; border-right: 0; border-bottom: 1px solid var(--rule); }
}

@media print {
  .bar, .foot, .pager, .edit { display: none; }
  body { font-size: 11pt; }
}
