/* Fatturenza: a 1-bit desktop. Every page is a window on a dithered desk.
   Two colours only (paper and ink); dark mode swaps them. The front-page
   tagline is the one rainbow exception.
   Pixel type for the interface, a bookish serif for reading. */

/* Fonts: self-hosted (CSP font-src 'self'), OFL, see third_party/fonts.
   Each face is split into latin and latin-ext; the browser only fetches
   latin-ext (ğ ş ı İ …) on pages that use those characters.
   Silkscreen has no ğ ş ı İ, so it is only used for fixed English labels and
   always falls back to Pixelify Sans. */
@font-face {
  font-family: "Literata";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/assets/literata-latin-ext-400-normal.726e1239ef.woff2) format("woff2");
  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-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Literata";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/assets/literata-latin-400-normal.a60c193b55.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: "Literata";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(/assets/literata-latin-ext-700-normal.559ab7b701.woff2) format("woff2");
  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-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Literata";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(/assets/literata-latin-700-normal.1f2985e0fc.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: "Literata";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url(/assets/literata-latin-ext-400-italic.3c5b9d0314.woff2) format("woff2");
  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-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Literata";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url(/assets/literata-latin-400-italic.1e98bfbbb4.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: "Pixelify Sans";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(/assets/pixelify-sans-latin-ext.0afa0101fd.woff2) format("woff2");
  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-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Pixelify Sans";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(/assets/pixelify-sans-latin.4a5633a0c9.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: "Silkscreen";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/assets/silkscreen-latin-ext.1006c6fc60.woff2) format("woff2");
  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-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Silkscreen";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/assets/silkscreen-latin.e6c72ea470.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: "Space Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/assets/space-mono-latin-ext.44ad50c760.woff2) format("woff2");
  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-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Space Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/assets/space-mono-latin.fb4a81a2d0.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: "Sixtyfour";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/assets/sixtyfour-latin-ext.0ccf2c4c2b.woff2) format("woff2");
  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-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Sixtyfour";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/assets/sixtyfour-latin.12f8351f30.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;
}

:root {
  --paper: #ffffff;
  --ink: #000000;
  --font-pixel: "Pixelify Sans", ui-monospace, monospace;
  --font-label: "Silkscreen", "Pixelify Sans", ui-monospace, monospace;
  --font-text: "Literata", Georgia, "Times New Roman", serif;
  --font-code: "Space Mono", ui-monospace, Menlo, Consolas, monospace;
  --measure: 40rem;
  --shadow: 4px 4px 0 var(--ink);
  /* 50% dither as a 2x2 image tile: crisper than a CSS gradient at 1px */
  --dither: url(/assets/dither-light.c15691f4dd.png);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  /* Slightly softened from pure black/white: easier on the eyes for long reads. */
  :root { --paper: #0b0b0b; --ink: #ececec; --dither: url(/assets/dither-dark.bb20d423a8.png); }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  /* the 50% dither of the desktop; pixelated so HiDPI scaling keeps it crisp */
  background: var(--dither) 0 0 / 2px 2px var(--paper);
  image-rendering: pixelated;
  font: 1.125rem/1.75 var(--font-text);
}
::selection { background: var(--ink); color: var(--paper); }
:focus-visible { outline: 2px dashed var(--ink); outline-offset: 3px; }
a { color: inherit; }
img { image-rendering: auto; } /* photos stay smooth; only the desk and thumbnails are pixelated */

.skip {
  position: absolute; left: -999px; top: 0; z-index: 2;
  background: var(--paper); border: 2px solid var(--ink); padding: .25rem .6rem;
  font: 12px/1.6 var(--font-label);
}
.skip:focus { left: max(16px, env(safe-area-inset-left, 0px)); top: .5rem; }

/* ---- Menu bar ---- */
.menubar {
  display: flex; flex-wrap: wrap; align-items: center; gap: .25rem 1.5rem;
  background: var(--paper); border-bottom: 2px solid var(--ink);
  padding-block: .3rem;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.menubar a { text-decoration: none; padding: .05rem .4rem; margin: 0 -.4rem; }
.menubar a:hover, .menubar a:focus-visible { background: var(--ink); color: var(--paper); outline: none; }
.menubar-home { font: 700 15px/1.4 var(--font-pixel); }
.menubar nav { display: flex; gap: 1.5rem; font: 12px/1.6 var(--font-label); }

/* ---- Window ---- */
.desk {
  padding-block: 2rem 3rem;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.window {
  width: min(46rem, 100%);
  margin: 0 auto;
  background: var(--paper);
  border: 2px solid var(--ink);
  box-shadow: var(--shadow);
}
.titlebar {
  position: relative; display: flex; align-items: center; justify-content: center;
  height: 1.5rem; padding: 0 2.25rem;
  border-bottom: 2px solid var(--ink);
  background: repeating-linear-gradient(to bottom, var(--ink) 0 2px, transparent 2px 4px) 4px 5px / calc(100% - 8px) 14px no-repeat var(--paper);
}
.titlebar-name {
  background: var(--paper); padding: 0 .75rem; min-width: 0;
  font: 600 15px/1.5rem var(--font-pixel);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.closebox {
  position: absolute; left: 8px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px;
  background: var(--paper); border: 2px solid var(--ink);
  box-shadow: 0 0 0 4px var(--paper); /* clear the stripes around the box */
}
a.closebox:hover, a.closebox:focus-visible { background: var(--ink); }
.window-body { padding: 2rem clamp(1rem, 5vw, 3rem) 2.5rem; }
.statusbar {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: .25rem 1rem;
  border-top: 2px solid var(--ink); padding: .45rem clamp(1rem, 5vw, 3rem);
  font: 14px/1.5 var(--font-pixel);
}
.statusbar a { text-decoration: none; }
/* Pixelify draws ©, and the cedilla in ş/ç, from half-size pixels that blur
   at 14px, so the copyright line (name included) uses the text face. */
.statusbar .copy { font: 13px/1.5 var(--font-text); }
.statusbar a:hover, .statusbar a:focus-visible { background: var(--ink); color: var(--paper); outline: none; }

/* ---- Type ---- */
/* Pixel face only where text is big: page and section titles (h1, h2) and
   post titles in the list. Smaller headings and tables use the text face,
   where Pixelify gets hard to read. */
h1, h2, h3, h4 { line-height: 1.15; text-wrap: balance; }
/* Pixelify has a small x-height, so it is set larger than the serif to look
   bigger than the h3 below it. */
h1, h2 { font-family: var(--font-pixel); }
h3, h4 { font-family: var(--font-text); line-height: 1.3; }
h1 { font-size: clamp(2rem, 5.5vw, 2.6rem); font-weight: 700; margin: 0 0 .5rem; }
h2 { font-size: 2rem; font-weight: 600; margin: 2.5rem 0 .75rem; }
h3 { font-size: 1.35rem; font-weight: 600; margin: 2rem 0 .5rem; }
h4 { font-size: 1.15rem; font-weight: 600; margin: 1.5rem 0 .5rem; }
.meta, time { font: 12px/1.6 var(--font-label); }
.meta { margin: 0 0 2rem; }

/* ---- Front page ---- */
.site-head { margin-bottom: 1.75rem; }
/* The one exception to the two colours: the tagline is Sixtyfour (a CRT
   home-computer face) in a slowly moving rainbow (still for reduced motion). */
.tagline {
  margin: 0; width: fit-content;
  font: 400 1.2rem/1.4 "Sixtyfour", var(--font-pixel);
  background: linear-gradient(90deg, #ff2a2a, #ff8a00, #f5c400, #1fc95b, #1e9bff, #7a4dff, #e83ad6, #ff2a2a) 0 0 / 200% 100%;
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  animation: tagline-rainbow 4s linear infinite;
}
@keyframes tagline-rainbow { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .tagline { animation: none; } }
.posts { list-style: none; margin: 0; padding: 0; border-top: 2px solid var(--ink); }
.posts li {
  display: grid; grid-template-columns: 7.5rem 1fr; gap: 1rem; align-items: baseline;
  padding: .6rem .25rem;
  /* a crisp 1px dotted rule: 2px on, 2px off */
  background: linear-gradient(to right, var(--ink) 50%, transparent 0) 0 100% / 4px 1px repeat-x;
}
.posts a { font: 600 1.15rem/1.35 var(--font-pixel); text-decoration: none; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.posts a:hover, .posts a:focus-visible { background: var(--ink); color: var(--paper); outline: none; }

/* ---- Post body ---- */
.prose { max-width: var(--measure); }
.prose > :first-child { margin-top: 0; }
.prose p, .prose ul, .prose ol, .prose blockquote, .prose pre, .prose table, .prose figure { margin: 0 0 1.25rem; }
.prose a { text-decoration-thickness: 1px; text-underline-offset: .18em; }
.prose a:hover { background: var(--ink); color: var(--paper); text-decoration: none; }
.prose ul { list-style: square; padding-left: 1.4em; }
.prose ol { padding-left: 1.6em; }
.prose li + li { margin-top: .3rem; }
.prose blockquote { padding: .1rem 0 .1rem 1.1rem; border-left: 4px solid var(--ink); font-style: italic; }
.prose hr, .footnotes hr {
  border: 0; height: 6px; margin: 2.5rem 0;
  background: var(--dither) 0 0 / 2px 2px;
}
.prose img { max-width: 100%; height: auto; display: block; border: 2px solid var(--ink); }
code, pre { font-family: var(--font-code); }
:not(pre) > code { font-size: .85em; border: 1px solid var(--ink); padding: 0 .25em; }
pre { font-size: .85rem; line-height: 1.55; border: 2px solid var(--ink); padding: 1rem; overflow-x: auto; }
.prose table { border-collapse: collapse; border: 2px solid var(--ink); display: block; width: max-content; max-width: 100%; overflow-x: auto; font-size: .95rem; }
.prose th { background: var(--ink); color: var(--paper); font: 700 .9rem/1.4 var(--font-text); text-align: left; padding: .4rem .6rem; }
.prose td { border: 1px solid var(--ink); padding: .4rem .6rem; }
.footnotes { font-size: .9rem; }

/* ---- YouTube: dithered thumbnail until clicked ---- */
figure.yt { margin: 2rem 0; }
.yt-link { position: relative; display: block; aspect-ratio: 16 / 9; max-width: 100%; border: 2px solid var(--ink); background: var(--ink); }
.yt-link img { display: block; width: 100%; height: 100%; border: 0; image-rendering: pixelated; image-rendering: crisp-edges; }
.yt-play {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  display: flex; align-items: center; gap: .5rem;
  background: var(--paper); color: var(--ink); border: 2px solid var(--ink); box-shadow: 3px 3px 0 var(--ink);
  padding: .45rem .8rem; font: 12px/1 var(--font-label);
}
.yt-play::before { content: ""; border-style: solid; border-width: .4rem 0 .4rem .65rem; border-color: transparent transparent transparent currentColor; }
.yt-play::after { content: "Play"; }
.yt-link:hover .yt-play, .yt-link:focus-visible .yt-play { background: var(--ink); color: var(--paper); box-shadow: 3px 3px 0 var(--paper); }
figure.yt iframe { display: block; width: 100%; aspect-ratio: 16 / 9; border: 2px solid var(--ink); background: #000; }
figure.yt figcaption { margin-top: .5rem; font: .95rem/1.4 var(--font-pixel); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- Buttons and the 404 alert ---- */
.button {
  display: inline-block; text-decoration: none;
  background: var(--paper); color: var(--ink); border: 2px solid var(--ink); box-shadow: 3px 3px 0 var(--ink);
  padding: .5rem .9rem; font: 12px/1.4 var(--font-label);
}
.button:hover, .button:focus-visible { background: var(--ink); color: var(--paper); outline: none; }
.button:active { transform: translate(3px, 3px); box-shadow: none; }
.back { margin: 3rem 0 0; }
.alert { display: grid; grid-template-columns: auto 1fr; gap: 1.25rem; align-items: start; }
.alert-icon {
  width: 3rem; height: 3rem; display: grid; place-items: center;
  border: 2px solid var(--ink); font: 700 2rem/1 var(--font-pixel);
}
.alert h1 { font-size: 1.6rem; }
.alert p { margin: 0 0 1rem; }

/* ---- Contents (posts with toc: true) ----
   Wide screens: a "contents" window in the free space right of the post,
   which stays centred; it stays in view while you scroll. Narrower screens:
   a closed box under the title instead. */
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc a {
  display: block; text-decoration: none; padding: .2rem .55rem;
  font: .86rem/1.4 var(--font-text);
}
.toc > ol > li > a { font-weight: 700; }
.toc > ol > li + li { margin-top: .3rem; }
.toc ol ol a { padding-left: 1.5rem; }
.toc a:hover { text-decoration: underline; }
.toc a[aria-current] { background: var(--ink); color: var(--paper); text-decoration: none; }

.toc-box { border: 2px solid var(--ink); margin: 0 0 2rem; max-width: var(--measure); }
.toc-box > summary {
  display: flex; justify-content: space-between; gap: 1rem;
  padding: .4rem .7rem; cursor: pointer; list-style: none;
  font: 12px/1.6 var(--font-label); letter-spacing: .04em; text-transform: uppercase;
}
.toc-box > summary::-webkit-details-marker { display: none; }
.toc-box > summary::after { content: "[+]"; font-family: var(--font-code); }
.toc-box[open] > summary { border-bottom: 2px solid var(--ink); }
.toc-box[open] > summary::after { content: "[-]"; }
.toc-box .toc { padding: .5rem .3rem .7rem; }

.toc-win { display: none; }
/* 81rem: the 46rem window plus a 15rem column and gaps on each side. */
@media (min-width: 81rem) {
  .desk.has-toc {
    display: grid; align-items: start; column-gap: 1.5rem;
    grid-template-columns: minmax(0, 1fr) min(46rem, 100%) minmax(0, 1fr);
  }
  .desk.has-toc > .window { grid-column: 2; width: auto; margin: 0; }
  .has-toc .toc-box { display: none; }
  .toc-win {
    display: block; grid-column: 3; justify-self: start;
    width: min(17rem, 100%); position: sticky; top: 1.25rem;
    background: var(--paper); border: 2px solid var(--ink); box-shadow: var(--shadow);
  }
  .toc-win .toc { max-height: calc(100vh - 5rem); overflow: auto; padding: .6rem .4rem .8rem; }
  /* toc.js marks the section being read; then only its subsections show. */
  .toc-win .toc.spy li:not(.open) > ol { display: none; }
}

@media (max-width: 30rem) {
  .posts li { grid-template-columns: 1fr; gap: 0; }
  .desk { padding-block: 1rem 2rem; }
}
@media (prefers-reduced-motion: reduce) {
  .button:active { transform: none; }
}
