/* Workbench: a cosy pixel-art workshop.
   Text stays readable; the pixel touches are in the headings, labels,
   navigation, and the wooden frame around the page. No external resources. */

/* Workbench Pixel is an original 5x7 pixel font made for this site
   (uppercase, digits, and punctuation; lowercase shows as uppercase). */
@font-face {
  font-family: "Workbench Pixel";
  src: url("/fonts/workbench-pixel.ttf") format("truetype");
  font-display: swap;
}

:root {
  /* Wood */
  --wood-darkest: #26150f;
  --wood-dark: #3f2418;
  --wood: #6b3d26;
  --wood-light: #9a5d34;
  --wood-shine: #c4834e;

  /* Accents */
  --rug: #a3362e;
  --moss: #2f6b5e;
  --gold: #e8b04a;

  /* Constant cream, for text on wood in both light and dark mode */
  --cream: #f6e7c9;

  /* The page */
  --paper: #f4e4c6;
  --paper-shade: #e6cfa4;
  --ink: #2b1a12;
  --ink-soft: #6e5240;
  --link: #8a2f24;
  --link-hover: #2f6b5e;
  --title: var(--wood-dark);
  --title-shadow: var(--gold);

  --pixel: 2px;
  --frame: 18px;
  --pixel-font: "Workbench Pixel", ui-monospace, Menlo, Consolas, monospace;
  --text-font: "Iowan Old Style", "Palatino Linotype", Palatino, Charter, Georgia, serif;
  --max: 44rem;
  color-scheme: light;
}

/* Dark mode: the same workshop, with the lamps turned down. */
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #2a1c15;
    --paper-shade: #3a281e;
    --ink: #f1e0c2;
    --ink-soft: #c7a783;
    --link: #f0b45a;
    --link-hover: #8fd1bd;
    --title: var(--gold);
    --title-shadow: var(--wood-darkest);
    color-scheme: dark;
  }
}

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

html {
  background: var(--paper);
}

/* The whole page sits in a stepped wooden frame, top to bottom. */
body {
  margin: 0;
  min-height: 100vh;
  padding: 0 calc(var(--frame) + 1rem);
  color: var(--ink);
  background: var(--paper);
  font-family: var(--text-font);
  font-size: 1.125rem;
  line-height: 1.7;
  box-shadow:
    inset 0 0 0 6px var(--wood-light),
    inset 0 0 0 12px var(--wood),
    inset 0 0 0 16px var(--wood-dark),
    inset 0 0 0 var(--frame) var(--wood-darkest);
}

/* ---- Header ---- */

.site-header {
  max-width: var(--max);
  margin: 0 auto;
  padding: calc(var(--frame) + 2rem) 0 1.75rem;
  text-align: center;
  background: repeating-linear-gradient(90deg, var(--paper-shade) 0 6px, transparent 6px 12px) bottom / 100% 3px no-repeat;
}

.site-title {
  display: inline-block;
  font-family: var(--pixel-font);
  font-size: 32px;
  line-height: 1;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--title);
  text-decoration: none;
  text-shadow: 2px 2px 0 var(--title-shadow);
  padding: 0.25rem 0.5rem 0.5rem;
}

.site-title:hover,
.site-title:focus-visible {
  color: var(--rug);
}

/* On the home page the title is the page's main heading. */
.site-heading {
  margin: 0;
  font-size: inherit;
  line-height: 1;
  text-shadow: none;
}

@media (prefers-color-scheme: dark) {
  .site-title:hover,
  .site-title:focus-visible {
    color: var(--cream);
  }
}

.nav {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--pixel-font);
  font-size: 16px;
  letter-spacing: 1px;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--cream);
  background: var(--wood);
  padding: 6px 10px 4px;
  box-shadow:
    inset 0 calc(var(--pixel) * 2) 0 var(--wood-shine),
    inset 0 calc(var(--pixel) * -2) 0 var(--wood-dark),
    0 0 0 var(--pixel) var(--wood-darkest);
}

.nav a:hover,
.nav a:focus-visible {
  background: var(--wood-light);
  color: #fff8e8;
}

.nav a[aria-current="page"] {
  background: var(--gold);
  color: var(--wood-darkest);
  box-shadow:
    inset 0 calc(var(--pixel) * 2) 0 #f7d58a,
    inset 0 calc(var(--pixel) * -2) 0 #b07a26,
    0 0 0 var(--pixel) var(--wood-darkest);
}

/* ---- The page ---- */

.page {
  max-width: var(--max);
  margin: 0 auto;
  padding: 2rem 0 2.5rem;
}

@media (max-width: 36rem) {
  :root {
    --frame: 10px;
  }

  body {
    padding: 0 calc(var(--frame) + 1rem);
    box-shadow:
      inset 0 0 0 4px var(--wood-light),
      inset 0 0 0 8px var(--wood),
      inset 0 0 0 var(--frame) var(--wood-darkest);
  }

  .site-title {
    font-size: 24px;
    letter-spacing: 1px;
  }

  .nav {
    gap: 0.5rem;
  }

  .nav a {
    padding: 4px 7px 2px;
    letter-spacing: 0;
  }
}

/* ---- Type ---- */

h1,
h2,
h3 {
  font-family: var(--pixel-font);
  font-weight: normal;
  text-transform: uppercase;
  line-height: 1.25;
  letter-spacing: 1px;
}

h1 {
  font-size: 24px;
  margin: 0 0 1rem;
  color: var(--ink);
  text-shadow: 2px 2px 0 var(--paper-shade);
}

h2 {
  font-size: 16px;
  letter-spacing: 2px;
  margin: 2.5rem 0 0.75rem;
  color: var(--rug);
}

h3 {
  font-size: 16px;
  margin: 2rem 0 0.5rem;
  color: var(--moss);
}

@media (prefers-color-scheme: dark) {
  h1 {
    text-shadow: 2px 2px 0 var(--wood-darkest);
  }

  h2 {
    color: var(--gold);
  }

  h3 {
    color: var(--link-hover);
  }
}

h2 a {
  color: inherit;
  text-decoration: none;
}

h2 a::after {
  content: " \2192";
}

h2 a:hover {
  color: var(--link-hover);
}

p,
ul,
ol {
  margin: 0 0 1.1rem;
}

a {
  color: var(--link);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--link-hover);
}

a:focus-visible,
button:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

.intro {
  font-size: 1.25rem;
}

strong {
  color: var(--ink);
}

hr {
  border: 0;
  height: 6px;
  margin: 2rem 0;
  background: repeating-linear-gradient(90deg, var(--wood-light) 0 6px, transparent 6px 12px);
}

/* ---- Labels: little pixel tags ---- */

.meta,
.labels {
  color: var(--ink-soft);
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.6rem;
  align-items: center;
  margin: 0 0 1.75rem;
  font-size: 1rem;
}

.label {
  display: inline-block;
  font-family: var(--pixel-font);
  font-size: 16px;
  line-height: 1;
  letter-spacing: 1px;
  text-transform: uppercase;
  white-space: nowrap;
  color: #fff4dc;
  background: var(--moss);
  padding: 5px 7px 3px;
  box-shadow:
    inset 0 calc(var(--pixel) * -2) 0 rgba(0, 0, 0, 0.25),
    0 0 0 var(--pixel) var(--wood-darkest);
}

.label-made {
  background: var(--wood);
}

.label-draft {
  background: var(--rug);
}

.label-try {
  background: var(--gold);
  color: var(--wood-darkest);
  text-decoration: none;
}

.label-try::before {
  content: "\25B6\00a0";
  font-family: var(--text-font);
  font-size: 12px;
}

.label-try:hover {
  background: #f7d58a;
  color: var(--wood-darkest);
}

.updated {
  font-style: italic;
}

/* ---- Lists of pieces, notes, and weeks ---- */

.list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.list-item {
  padding: 1rem 0 1.1rem;
  background: repeating-linear-gradient(90deg, var(--paper-shade) 0 6px, transparent 6px 12px) bottom / 100% 3px no-repeat;
}

.list-item:last-child {
  background: none;
}

.list-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin-right: 0.6rem;
}

.labels {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.5rem;
  align-items: center;
  vertical-align: 2px;
  font-size: 1rem;
}

.list-summary {
  margin: 0.4rem 0 0;
}

.list-empty {
  color: var(--ink-soft);
  font-style: italic;
  padding: 1rem 0;
}

/* ---- Everything else in a page ---- */

img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1.5rem 0;
  box-shadow:
    0 0 0 4px var(--paper),
    0 0 0 8px var(--wood),
    0 0 0 10px var(--wood-darkest);
}

code {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: var(--paper-shade);
  padding: 0.05em 0.3em;
}

pre {
  overflow-x: auto;
  padding: 1rem 1.1rem;
  margin: 0 0 1.25rem;
  background: #1c110c;
  color: #f1e0c2;
  font-size: 0.95rem;
  line-height: 1.55;
  box-shadow:
    inset 0 0 0 var(--pixel) var(--wood-dark),
    0 0 0 var(--pixel) var(--wood-darkest);
}

pre code {
  background: none;
  padding: 0;
  color: inherit;
}

blockquote {
  margin: 1.5rem 0;
  padding: 0.5rem 0 0.5rem 1.25rem;
  color: var(--ink-soft);
  font-style: italic;
  box-shadow: inset 6px 0 0 var(--gold);
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 1.25rem;
  font-size: 1rem;
}

th,
td {
  text-align: left;
  padding: 0.4rem 0.6rem;
  border-bottom: 2px solid var(--paper-shade);
}

th {
  font-family: var(--pixel-font);
  font-weight: normal;
  text-transform: uppercase;
  font-size: 16px;
}

/* ---- Footer ---- */

.site-footer {
  max-width: var(--max);
  margin: 0 auto;
  padding: 1.25rem 0 calc(var(--frame) + 2rem);
  text-align: center;
  font-family: var(--pixel-font);
  font-size: 16px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--ink-soft);
  background: repeating-linear-gradient(90deg, var(--paper-shade) 0 6px, transparent 6px 12px) top / 100% 3px no-repeat;
}

.site-footer p {
  margin: 0;
}

.site-footer a {
  color: var(--link);
}

/* ---- Pixel art: section icons and the workbench scene ---- */

img.icon {
  display: inline-block;
  flex: none;
  width: 24px;
  height: 24px;
  margin: 0;
  box-shadow: none;
  image-rendering: pixelated;
}

h2 img.icon-heading {
  width: 24px;
  height: 24px;
  margin-right: 8px;
  vertical-align: -6px;
}

.scene {
  display: block;
  width: 100%;
  max-width: 640px;
  height: auto;
  margin: 0 auto 0.75rem;
}

/* Only the first puff of steam shows when nothing moves. */
.scene-steam {
  opacity: 0;
}

.scene-steam-1 {
  opacity: 1;
}

@keyframes scene-flicker {
  0%, 40%, 44%, 70%, 74%, 100% { opacity: 1; }
  42% { opacity: 0.55; }
  72% { opacity: 0.8; }
}

@keyframes scene-blink {
  0%, 49.9% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

@keyframes scene-steam {
  0%, 24.9% { opacity: 1; }
  25%, 100% { opacity: 0; }
}

@media (prefers-reduced-motion: no-preference) {
  .nav a,
  .label-try {
    transition: background-color 0.1s steps(2);
  }

  .scene-glow {
    animation: scene-flicker 6s linear infinite;
  }

  .scene-cursor {
    animation: scene-blink 1.1s linear infinite;
  }

  .scene-power {
    animation: scene-blink 2.6s linear infinite;
  }

  .scene-steam {
    animation: scene-steam 2s linear infinite;
  }

  .scene-steam-2 { animation-delay: -1.5s; }
  .scene-steam-3 { animation-delay: -1s; }
  .scene-steam-4 { animation-delay: -0.5s; }
}
