/* The mimihubd site. Haven's type system (Newsreader, Geist, IBM Plex Mono, self-hosted under the SIL Open Font
   License, see fonts/OFL-*.txt) and its palette: obsidian, espresso, sand and linen, with gold and clay accents. */

@font-face { font-family: "Newsreader"; src: url("fonts/newsreader-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Newsreader"; src: url("fonts/newsreader-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Geist"; src: url("fonts/geist-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Geist"; src: url("fonts/geist-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Geist"; src: url("fonts/geist-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("fonts/plex-mono-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }

:root {
  --display: "Newsreader", Georgia, serif;
  --body: "Geist", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --bg: #fbf8f2;
  --surface: #f2ece1;
  --text: #1a1816;
  --muted: #5e554b;
  --line: #e2d9ca;
  --accent: #7a5a3d;
  --accent-strong: #5e4430;
  --mark: #c5a059;
  --code-bg: #efe8db;
  --focus: #c5a059;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0a09;
    --surface: #1a1816;
    --text: #ffffff;
    --muted: #c9bfae;
    --line: #2b2723;
    --accent: #c5a059;
    --accent-strong: #e0bf7d;
    --mark: #c5a059;
    --code-bg: #1f1c19;
    --focus: #c5a059;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 1rem/1.65 var(--body);
}

a { color: var(--accent); text-underline-offset: 0.18em; }
a:hover { color: var(--accent-strong); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 2px; }

.vh {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

.skip { position: absolute; left: -999px; top: 0; padding: 0.5rem 1rem; background: var(--surface); }
.skip:focus { left: 1rem; z-index: 10; }

/* Header: the name, the search box, then the navigation. */
header.site {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky; top: 0; z-index: 5;
}
header.site .bar {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  max-width: 76rem; margin: 0 auto; padding: 0.75rem 1.25rem 0.25rem;
}
.brand {
  font: 600 1.5rem/1 var(--display); color: var(--text); text-decoration: none; letter-spacing: 0.01em;
}
.brand::before {
  content: ""; display: inline-block; width: 0.55em; height: 0.55em; margin-right: 0.45em;
  border-radius: 50%; background: var(--mark); vertical-align: 0.08em;
}
header.site nav ul {
  list-style: none; display: flex; gap: 0.25rem 1.1rem; flex-wrap: wrap;
  max-width: 76rem; margin: 0 auto; padding: 0.25rem 1.25rem 0.65rem;
}
header.site nav a { color: var(--muted); text-decoration: none; font-size: 0.93rem; white-space: nowrap; }
header.site nav a:hover { color: var(--text); }
header.site nav a[aria-current="page"] { color: var(--text); font-weight: 600; box-shadow: inset 0 -2px 0 var(--mark); }

.search { position: relative; margin-left: auto; flex: 0 1 18rem; }
.search input {
  width: 100%; font: inherit; font-size: 0.95rem; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 0.4rem 0.65rem;
}
.search ol {
  position: absolute; right: 0; left: 0; top: calc(100% + 0.35rem); margin: 0; padding: 0.35rem 0;
  list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: 6px;
  max-height: 70vh; overflow: auto; box-shadow: 0 8px 24px rgb(0 0 0 / 18%); min-width: min(26rem, 92vw);
}
.search li a { display: block; padding: 0.45rem 0.8rem; text-decoration: none; color: var(--text); }
.search li a:hover, .search li a:focus, .search li a[aria-selected="true"] { background: var(--code-bg); outline: none; }
.search li small { display: block; color: var(--muted); font-size: 0.8rem; }
.search li.none { padding: 0.45rem 0.8rem; color: var(--muted); }

/* Haven's hub at a glance, on the home page. */
.glance {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 0.9rem 1.5rem;
  margin: 1.75rem 0 0.5rem; padding: 1.1rem 1.25rem; background: var(--surface);
  border: 1px solid var(--line); border-left: 3px solid var(--mark); border-radius: 6px;
}
.glance div { min-width: 0; }
.glance dt { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.glance dd { margin: 0.15rem 0 0; overflow-wrap: anywhere; }

/* The page: an optional table of contents beside the content. */
.page { max-width: 76rem; margin: 0 auto; padding: 2rem 1.25rem 3rem; }
.page.with-toc { display: grid; grid-template-columns: 15rem minmax(0, 1fr); gap: 3rem; }
.page-toc { position: sticky; top: 7.5rem; align-self: start; max-height: calc(100vh - 9rem); overflow: auto; font-size: 0.88rem; }
.page-toc p { margin: 0 0 0.5rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.75rem; }
.page-toc ul { list-style: none; margin: 0; padding: 0; }
.page-toc ul ul { padding-left: 0.9rem; }
.page-toc li { margin: 0.25rem 0; }
.page-toc a { color: var(--muted); text-decoration: none; }
.page-toc a:hover { color: var(--text); }

main { max-width: 46rem; min-width: 0; }
.page:not(.with-toc) main { margin: 0 auto; }

h1, h2, h3 { font-family: var(--display); font-weight: 600; line-height: 1.2; color: var(--text); }
h1 { font-size: clamp(2rem, 4vw, 2.7rem); margin: 0 0 1.25rem; letter-spacing: -0.01em; }
h2 { font-size: 1.6rem; margin: 2.6rem 0 0.75rem; padding-top: 0.25rem; border-top: 1px solid var(--line); padding-top: 1.4rem; }
h3 { font-size: 1.25rem; margin: 2rem 0 0.5rem; }
h4 { font: 600 1rem/1.4 var(--body); margin: 1.5rem 0 0.4rem; }
h1 + p, main > p:first-of-type { font-size: 1.08rem; }

.headerlink { margin-left: 0.4rem; color: var(--line); text-decoration: none; font-family: var(--body); font-size: 0.8em; opacity: 0; }
h2:hover .headerlink, h3:hover .headerlink, .headerlink:focus { opacity: 1; color: var(--muted); }

p, ul, ol, dl { margin: 0 0 1rem; }
li { margin: 0.3rem 0; }
li > ul, li > ol { margin: 0.3rem 0; }
blockquote { margin: 1rem 0; padding: 0.25rem 1rem; border-left: 3px solid var(--mark); color: var(--muted); }
hr { border: 0; border-top: 1px solid var(--line); margin: 2rem 0; }

code, pre, kbd { font-family: var(--mono); font-size: 0.88em; }
:not(pre) > code { background: var(--code-bg); padding: 0.08em 0.32em; border-radius: 4px; overflow-wrap: anywhere; }
pre { background: var(--code-bg); padding: 0.9rem 1rem; border-radius: 6px; overflow-x: auto; line-height: 1.5; }
pre code { background: none; padding: 0; font-size: 0.85rem; }

.table-wrap { overflow-x: auto; margin: 0 0 1.25rem; border: 1px solid var(--line); border-radius: 6px; }
table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
th, td { text-align: left; vertical-align: top; padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--line); }
thead th { background: var(--surface); font-weight: 600; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }

footer.site { border-top: 1px solid var(--line); color: var(--muted); font-size: 0.88rem; }
footer.site p { max-width: 76rem; margin: 0 auto; padding: 0.4rem 1.25rem; }
footer.site p:first-child { padding-top: 1.5rem; }
footer.site p:last-child { padding-bottom: 2rem; }
footer.site a { color: var(--muted); }

@media (max-width: 60rem) {
  .page.with-toc { display: block; }
  .page-toc { position: static; max-height: none; margin-bottom: 2rem; padding: 1rem 1rem 0.5rem; background: var(--surface); border-radius: 6px; }
  header.site nav ul { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; padding-bottom: 0.75rem; }
  .search { flex-basis: 100%; margin-left: 0; }
  header.site { position: static; }
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

@media print {
  header.site, .page-toc, footer.site .stamp { display: none; }
  .page.with-toc { display: block; }
}
