/* Detour Through The Junk Drawer
   A small, framework-free stylesheet. No JavaScript is needed for anything here except
   the light/dark switch, which degrades to the reader's OS preference without it.

   Theme colors are defined three times on purpose:
     1. bare :root            -> the light palette, and the fallback for everything
     2. prefers-color-scheme  -> the dark palette when the OS asks for dark...
        :root:not([data-theme="light"])   ...unless the reader explicitly chose light
     3. :root[data-theme="dark"]          -> the reader explicitly chose dark
   Dropping any one of the three leaves a combination of OS setting and reader choice
   that renders with the wrong palette. */

:root {
  --bg: #fdfdfc;
  --fg: #1b1b1d;
  --muted: #6c6c74;
  --rule: #e5e4e1;
  --accent: #9c4f1b;
  --accent-hover: #c26322;
  --code-bg: #f4f3f0;
  --switch-bg: #e8e5e0;
  --switch-knob: #ffffff;
  --selection: #f4e3d5;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --measure: 36rem;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141416;
    --fg: #e7e6e3;
    --muted: #9a9aa1;
    --rule: #2b2b2f;
    --accent: #e9a269;
    --accent-hover: #f6bd8c;
    --code-bg: #202024;
    --switch-bg: #2b2b2f;
    --switch-knob: #0e0e10;
    --selection: #3a2a1c;

    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #141416;
  --fg: #e7e6e3;
  --muted: #9a9aa1;
  --rule: #2b2b2f;
  --accent: #e9a269;
  --accent-hover: #f6bd8c;
  --code-bg: #202024;
  --switch-bg: #2b2b2f;
  --switch-knob: #0e0e10;
  --selection: #3a2a1c;

  color-scheme: dark;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--selection); }

.wrapper {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 1.5rem;
}

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

a:hover, a:focus-visible { color: var(--accent-hover); border-bottom-color: currentColor; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

img { max-width: 100%; height: auto; display: block; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  padding: 0.5rem 1rem;
  background: var(--bg);
  z-index: 2;
}

.skip-link:focus { left: 0; }

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

#site-header { padding: 1.75rem 0 1.5rem; }

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.breadcrumb {
  margin: 0;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.breadcrumb a { color: inherit; }
.breadcrumb a::after { content: " \2192"; }

.site-title {
  margin: 0;
  font-size: 1.75rem;
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: -0.015em;
}

p.site-title { font-size: 1.1875rem; font-weight: 600; }

.site-title a { color: var(--fg); border: 0; }
.site-title a:hover { color: var(--accent); }

.site-subtitle {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.9375rem;
}

#site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem 1.25rem;
  margin-top: 1.25rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--rule);
  font-size: 0.875rem;
}

#site-nav a { color: var(--muted); }

/* The feed links are a pair, set apart at the end of the row from the page links. */
#site-nav .feed-links {
  display: flex;
  gap: 0.75rem;
  margin-left: auto;
}

#site-nav a:hover, #site-nav a:focus-visible { color: var(--accent); }

/* ---- Light/dark switch ----------------------------------------------------- */

/* Hidden until the inline script adds .js to <html>, so there is never a control
   that does nothing. */
.theme-switch { display: none; }

.js .theme-switch {
  display: block;
  flex: none;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.switch-track {
  position: relative;
  display: block;
  width: 3.5rem;
  height: 1.875rem;
  border-radius: 1rem;
  background: var(--switch-bg);
  transition: background-color 0.2s ease;
}

.switch-knob {
  position: absolute;
  top: 0.1875rem;
  left: 0.1875rem;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--switch-knob);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.25);
  transition: transform 0.22s ease;
  z-index: 0;
}

.theme-switch[aria-checked="true"] .switch-knob { transform: translateX(1.625rem); }

.switch-track .icon {
  position: absolute;
  top: 50%;
  width: 0.9375rem;
  height: 0.9375rem;
  margin-top: -0.46875rem;
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 0.2s ease, opacity 0.2s ease;
  z-index: 1;  /* above the knob, so the active icon reads as the one that's selected */
}

.icon-sun { left: 0.4375rem; }
.icon-moon { right: 0.4375rem; }

/* The icon the knob is sitting on is the active one, so dim the other. */
.theme-switch[aria-checked="false"] .icon-sun { stroke: var(--accent); }
.theme-switch[aria-checked="false"] .icon-moon { opacity: 0.55; }
.theme-switch[aria-checked="true"] .icon-moon { stroke: var(--accent); }
.theme-switch[aria-checked="true"] .icon-sun { opacity: 0.55; }

.theme-switch:hover .switch-track { background: var(--rule); }
.theme-switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 1rem; }

@media (prefers-reduced-motion: reduce) {
  .switch-knob, .switch-track, .switch-track .icon { transition: none; }
}

/* ---- Content --------------------------------------------------------------- */

#content { padding: 2.5rem 0 3.5rem; }

h1, h2, h3 { line-height: 1.25; letter-spacing: -0.01em; font-weight: 600; }

.page-title { margin: 0 0 2rem; font-size: 1.375rem; }
.page-intro { margin: -1.75rem 0 2rem; color: var(--muted); font-size: 0.9375rem; }

/* Post listings */

.post-summary { margin-bottom: 3rem; }
.post-summary:last-of-type { margin-bottom: 0; }

.post-summary h2 { margin: 0 0 0.35rem; font-size: 1.3125rem; }
.post-summary h2 a { color: var(--fg); }
.post-summary h2 a:hover { color: var(--accent); }

.post-meta, .translations {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--muted);
}

.post-meta .tag { color: inherit; }
.post-meta a.tag:hover { color: var(--accent); }
.post-meta .sep { opacity: 0.5; padding: 0 0.1rem; }

.summary { margin-top: 0.9rem; }
.summary p { margin: 0; }

.read-more { margin: 0.75rem 0 0; font-size: 0.875rem; }

.translations { margin-top: 0.6rem; }

/* Single post */

.post-title { margin: 0 0 0.4rem; font-size: 1.75rem; }
.post-header { margin-bottom: 2rem; }
.post-body > :first-child { margin-top: 0; }
.post-body p, .post-body ul, .post-body ol { margin: 1.15rem 0; }
.post-body li { margin: 0.35rem 0; }
.post-body h2 { margin: 2.25rem 0 0.75rem; font-size: 1.25rem; }
.post-body h3 { margin: 2rem 0 0.6rem; font-size: 1.0625rem; }
.post-image { margin: 1.75rem 0; }

blockquote {
  margin: 1.5rem 0;
  padding-left: 1.25rem;
  border-left: 2px solid var(--rule);
  color: var(--muted);
}

code, pre { font-family: var(--font-mono); font-size: 0.875em; }

code {
  background: var(--code-bg);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}

pre {
  background: var(--code-bg);
  margin: 1.5rem 0;
  padding: 1rem 1.15rem;
  border-radius: 4px;
  overflow-x: auto;
  line-height: 1.55;
}

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

table {
  width: 100%;
  margin: 1.75rem 0;
  border-collapse: collapse;
  font-size: 0.9375rem;
  display: block;
  overflow-x: auto;
}

th, td { padding: 0.5rem 0.75rem 0.5rem 0; text-align: left; border-bottom: 1px solid var(--rule); }
th { font-weight: 600; }

hr { border: 0; border-top: 1px solid var(--rule); margin: 2.5rem 0; }

/* ---- Archive and tag listings ---------------------------------------------- */

.archive-list { margin: 0; }

.archive-list dt {
  float: left;
  clear: left;
  width: 8.5rem;
  padding-top: 0.05rem;
  color: var(--muted);
  font-size: 0.8125rem;
}

.archive-list dd { margin: 0 0 0.85rem 8.5rem; }

@media (max-width: 30rem) {
  .archive-list dt { float: none; width: auto; }
  .archive-list dd { margin: 0 0 1.25rem; }
}

.tag-list { list-style: none; margin: 0; padding: 0; }
.tag-list li { display: inline; margin-right: 1.1rem; white-space: nowrap; line-height: 2.2; }
.tag-list .count { color: var(--muted); font-size: 0.8125rem; }

/* ---- Pagination and post footer -------------------------------------------- */

.pagination, .post-nav {
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.pagination .page-of { color: var(--muted); margin-left: auto; margin-right: auto; }
.pagination .older { margin-left: auto; }
.pagination .newer + .page-of { margin-left: 0; }

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

#site-footer {
  margin-top: 1rem;
  padding: 1.5rem 0 2.5rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.8125rem;
}

#site-footer p { margin: 0 0 0.5rem; }
#site-footer .links { list-style: none; margin: 0 0 0.5rem; padding: 0; }
#site-footer .links li { display: inline; margin-right: 1.1rem; }
#site-footer .colophon { margin: 0; }
