/* Expeditions map-making guide
   Visual language: a field survey sheet. Cool paper rather than warm cream,
   engineering-drawing display type, and one high-visibility accent borrowed from
   surveyor's flagging tape. */

:root {
  --ink:        #1B2124;
  --ink-soft:   #55605A;
  --ink-faint:  #8B948D;
  --paper:      #EDF0EC;
  --lift:       #F7F9F6;
  --lift-2:     #E3E8E0;
  --rule:       #C4CCC0;
  --rule-soft:  #D8DED4;
  --flag:       #6E8600;
  --flag-lift:  #9FBF00;
  --signal:     #B93B14;
  --signal-bg:  #FAE9E3;
  --warn:       #7E6010;
  --warn-bg:    #F8F1DC;
  --ok:         #2F6B45;
  --ok-bg:      #E4F0E7;

  --display: "Archivo", ui-sans-serif, system-ui, sans-serif;
  --body:    "Source Sans 3", ui-sans-serif, system-ui, sans-serif;
  --mono:    "IBM Plex Mono", ui-monospace, Consolas, monospace;

  --measure: 68ch;
  --sidebar: 17.5rem;
  --aside: 13rem;
  --shadow: 0 1px 2px rgb(27 33 36 / .06), 0 6px 20px rgb(27 33 36 / .08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink:        #E3E8E1; --ink-soft: #99A49C; --ink-faint: #6E7972;
    --paper:      #151917; --lift: #1D2220; --lift-2: #262C29;
    --rule:       #323B36; --rule-soft: #262D29;
    --flag:       #B6D92B; --flag-lift: #C8E84A;
    --signal:     #F0785A; --signal-bg: #2A1712;
    --warn:       #DFBB61; --warn-bg: #241E12;
    --ok:         #79C795; --ok-bg: #16271C;
    --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 8px 24px rgb(0 0 0 / .45);
  }
}
:root[data-theme="dark"] {
  --ink:        #E3E8E1; --ink-soft: #99A49C; --ink-faint: #6E7972;
  --paper:      #151917; --lift: #1D2220; --lift-2: #262C29;
  --rule:       #323B36; --rule-soft: #262D29;
  --flag:       #B6D92B; --flag-lift: #C8E84A;
  --signal:     #F0785A; --signal-bg: #2A1712;
  --warn:       #DFBB61; --warn-bg: #241E12;
  --ok:         #79C795; --ok-bg: #16271C;
  --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 8px 24px rgb(0 0 0 / .45);
}
:root[data-theme="light"] {
  --ink:        #1B2124; --ink-soft: #55605A; --ink-faint: #8B948D;
  --paper:      #EDF0EC; --lift: #F7F9F6; --lift-2: #E3E8E0;
  --rule:       #C4CCC0; --rule-soft: #D8DED4;
  --flag:       #6E8600; --flag-lift: #9FBF00;
  --signal:     #B93B14; --signal-bg: #FAE9E3;
  --warn:       #7E6010; --warn-bg: #F8F1DC;
  --ok:         #2F6B45; --ok-bg: #E4F0E7;
  --shadow: 0 1px 2px rgb(27 33 36 / .06), 0 6px 20px rgb(27 33 36 / .08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 5rem; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation: none !important; transition: none !important; }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 1.0625rem;
  line-height: 1.68;
  -webkit-font-smoothing: antialiased;
}

.vh, .skip:not(:focus) {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}
.skip:focus {
  position: fixed; top: .5rem; left: .5rem; z-index: 100;
  background: var(--flag-lift); color: #10140f;
  padding: .5rem .9rem; border-radius: 3px; font-weight: 600;
}
:focus-visible { outline: 2px solid var(--flag-lift); outline-offset: 2px; border-radius: 2px; }

/* ------------------------------------------------------------ topbar */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 1.5rem;
  padding: .7rem 1.5rem;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule);
}
.brand { display: flex; align-items: center; gap: .7rem; text-decoration: none; color: inherit; }
.brand-mark {
  font-family: var(--mono); font-size: .8rem; font-weight: 500;
  letter-spacing: .08em;
  background: var(--ink); color: var(--paper);
  padding: .3rem .45rem; border-radius: 2px;
}
:root[data-theme="dark"] .brand-mark,
.brand-mark { }
.brand-name {
  font-family: var(--display); font-weight: 600; font-size: 1.0625rem;
  line-height: 1.15; display: flex; flex-direction: column;
}
.brand-sub {
  font-family: var(--body); font-weight: 400; font-size: .75rem;
  color: var(--ink-faint); letter-spacing: .01em;
}
.topbar-tools { margin-left: auto; display: flex; align-items: center; gap: .6rem; }

.search { position: relative; }
.search input {
  font: inherit; font-size: .9375rem;
  width: 15rem; max-width: 42vw;
  padding: .4rem .7rem;
  color: var(--ink);
  background: var(--lift);
  border: 1px solid var(--rule);
  border-radius: 3px;
}
.search input::placeholder { color: var(--ink-faint); }
#results {
  position: absolute; right: 0; top: calc(100% + .4rem);
  width: min(26rem, 80vw);
  background: var(--lift); border: 1px solid var(--rule);
  border-radius: 3px; box-shadow: var(--shadow);
  max-height: 60vh; overflow-y: auto; z-index: 50;
}
#results a {
  display: block; padding: .6rem .8rem; text-decoration: none; color: var(--ink);
  border-bottom: 1px solid var(--rule-soft);
}
#results a:last-child { border-bottom: none; }
#results a:hover, #results a:focus { background: var(--lift-2); }
#results strong { display: block; font-family: var(--display); font-weight: 600; }
#results em {
  font-family: var(--mono); font-style: normal; font-size: .68rem;
  letter-spacing: .08em; text-transform: uppercase; color: var(--flag);
}
#results span { display: block; font-size: .875rem; color: var(--ink-soft); margin-top: .15rem; }
#results .nohit { margin: 0; padding: .8rem; font-size: .9rem; color: var(--ink-soft); }

#theme, #menu {
  font: inherit; font-size: .875rem;
  color: var(--ink); background: var(--lift);
  border: 1px solid var(--rule); border-radius: 3px;
  padding: .4rem .65rem; cursor: pointer; line-height: 1;
}
#theme { font-size: 1rem; }
#theme:hover, #menu:hover { border-color: var(--flag); color: var(--flag); }
#menu { display: none; }

/* ------------------------------------------------------------ shell */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr) var(--aside);
  gap: 3rem;
  max-width: 88rem; margin: 0 auto; padding: 2.5rem 1.5rem 5rem;
  align-items: start;
}

.sidebar { position: sticky; top: 5rem; max-height: calc(100vh - 7rem); overflow-y: auto; }
.sidebar section + section { margin-top: 1.6rem; }
.sidebar h2 {
  font-family: var(--mono); font-size: .69rem; font-weight: 500;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-faint); margin: 0 0 .5rem;
  padding-bottom: .4rem; border-bottom: 1px solid var(--rule-soft);
}
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar li { display: flex; align-items: baseline; gap: .4rem; margin-bottom: .1rem; }
.sidebar a {
  display: block; padding: .2rem 0;
  font-size: .9375rem; color: var(--ink-soft); text-decoration: none;
  border-left: 2px solid transparent; padding-left: .6rem; margin-left: -.6rem;
}
.sidebar a:hover { color: var(--ink); }
.sidebar a[aria-current="page"] {
  color: var(--flag); font-weight: 600; border-left-color: var(--flag);
}
.pill {
  font-family: var(--mono); font-size: .6rem; letter-spacing: .07em;
  text-transform: uppercase; padding: .1em .32em; border-radius: 2px;
  border: 1px solid currentColor; white-space: nowrap;
}
.pill-draft { color: var(--ink-faint); }
.pill-outline { color: var(--ink-faint); }
.pill-unverified { color: var(--warn); }

/* ------------------------------------------------------------ page head */
.page-head { border-bottom: 2px solid var(--ink); padding-bottom: 1.1rem; margin-bottom: 2rem; }
.eyebrow {
  font-family: var(--mono); font-size: .69rem; font-weight: 500;
  letter-spacing: .13em; text-transform: uppercase;
  color: var(--flag); margin: 0 0 .6rem;
}
.page-head h1 {
  font-family: var(--display); font-weight: 700;
  font-size: clamp(2rem, 4.6vw, 2.75rem); line-height: 1.04;
  letter-spacing: -.015em; text-wrap: balance; margin: 0;
}
.lede {
  font-size: 1.1875rem; color: var(--ink-soft);
  max-width: var(--measure); margin: .7rem 0 0; text-wrap: pretty;
}

/* the custom-module verdict, first thing under a module page's title */
.verdict {
  display: block; margin: 1rem 0 0; padding: .9rem 1.1rem;
  max-width: var(--measure); border-left: 6px solid; font-size: 1.0625rem;
}
.verdict-label { display: block; font-family: var(--display); font-weight: 800; font-size: 1.25rem; letter-spacing: .02em; }
.verdict-text { display: block; margin-top: .3rem; }
.verdict-works    { border-color: var(--ok);     background: var(--ok-bg); }
.verdict-works    .verdict-label { color: var(--ok); }
.verdict-broken   { border-color: var(--signal); background: var(--signal-bg); }
.verdict-broken   .verdict-label { color: var(--signal); }
.verdict-partly, .verdict-untested { border-color: var(--warn); background: var(--warn-bg); }
.verdict-partly   .verdict-label, .verdict-untested .verdict-label { color: var(--warn); }
.pill-v-works { color: var(--ok); }
.pill-v-broken { color: var(--signal); }
.pill-v-partly, .pill-v-untested { color: var(--warn); }

.banner {
  border-left: 3px solid var(--warn); background: var(--warn-bg);
  padding: .8rem 1.1rem; margin-bottom: 2rem;
  max-width: var(--measure); font-size: .9375rem;
}

/* ------------------------------------------------------------ prose */
.prose { max-width: var(--measure); }
.prose > * + * { margin-top: 1.15rem; }
.prose p, .prose li { text-wrap: pretty; }
.prose > h2 {
  font-family: var(--display); font-weight: 600;
  font-size: 1.75rem; line-height: 1.15; letter-spacing: -.01em;
  text-wrap: balance;
  margin-top: 3rem; padding-top: 1.1rem; border-top: 1px solid var(--rule);
}
.prose > h3 {
  font-family: var(--display); font-weight: 600;
  font-size: 1.3125rem; line-height: 1.25; text-wrap: balance;
  margin-top: 2.25rem;
}
.prose > h4 { font-size: 1rem; font-weight: 600; margin-top: 1.75rem; }
/* heading permalinks: present for linking, quiet until wanted. h1 was missing
   from this rule, so the home page's title carried a bright green # at rest. */
.prose :is(h1, h2, h3, h4) .headerlink {
  font-family: var(--mono); font-size: .7em; color: var(--rule);
  text-decoration: none; margin-left: .45rem;
  opacity: 0; transition: opacity .12s ease;
}
.prose :is(h1, h2, h3, h4):hover .headerlink { opacity: 1; }
.prose .headerlink:hover, .prose .headerlink:focus-visible { color: var(--flag); opacity: 1; }
@media (hover: none) { .prose :is(h1, h2, h3, h4) .headerlink { opacity: .5; } }

.prose a { color: var(--flag); text-decoration-thickness: 1px; text-underline-offset: 2px; }
.prose strong { font-weight: 600; }
.prose ul, .prose ol { padding-left: 1.4rem; }
.prose li + li { margin-top: .45rem; }
.prose li > ul, .prose li > ol { margin-top: .45rem; }

.prose code {
  font-family: var(--mono); font-size: .86em;
  background: var(--lift-2); padding: .12em .34em; border-radius: 2px;
  overflow-wrap: anywhere;
}
.prose pre {
  font-family: var(--mono); font-size: .845rem; line-height: 1.6;
  background: var(--lift); border: 1px solid var(--rule);
  border-left: 3px solid var(--flag);
  padding: 1rem 1.15rem; overflow-x: auto;
}
.prose pre code { background: none; padding: 0; font-size: inherit; }
.prose blockquote {
  margin: 1.5rem 0; padding: .1rem 0 .1rem 1.15rem;
  border-left: 3px solid var(--rule); color: var(--ink-soft);
}

/* tables: always allowed to scroll inside themselves */
/* The table is ONE table. It was display:block with thead and tbody each set
   to display:table -- two independent tables, sizing their columns
   independently, so no header could ever line up with the data beneath it.
   The wrapper scrolls instead. */
.prose .table-scroll { overflow-x: auto; max-width: 100%; margin-top: 1.15rem; }
.prose table {
  border-collapse: collapse; width: 100%; font-size: .9375rem;
}
/* An identifier that wraps mid-token reads as two different names. These
   columns are field names and symbols -- keep each one whole, and let the
   table scroll sideways if that will not fit. */
.prose :is(td, th) code {
  white-space: nowrap; overflow-wrap: normal;
  padding-left: 0; margin-left: -0.02em;   /* sit flush with the column edge */
}
.prose td:first-child, .prose th:first-child { padding-right: 1.6rem; }
.prose td + td, .prose th + th { padding-right: 1.4rem; }
.prose tbody tr:hover td { background: var(--lift); }
.prose th {
  text-align: left; font-family: var(--mono); font-weight: 500;
  font-size: .69rem; letter-spacing: .09em; text-transform: uppercase;
  color: var(--ink-soft); border-bottom: 1px solid var(--ink);
  padding: .5rem .9rem .45rem 0; vertical-align: bottom;
}
.prose td {
  padding: .6rem .9rem .6rem 0;
  border-bottom: 1px solid var(--rule-soft); vertical-align: top;
}
.prose tbody tr:last-child td { border-bottom: none; }
.prose td code { font-size: .82em; }

/* admonitions from python-markdown */
.admonition {
  border-left: 3px solid var(--flag); background: var(--lift);
  padding: .9rem 1.15rem; font-size: .9375rem;
}
.admonition > :first-child { margin-top: 0; }
.admonition-title {
  font-family: var(--mono); font-size: .69rem; letter-spacing: .11em;
  text-transform: uppercase; color: var(--flag);
  margin: 0 0 .35rem; font-weight: 500;
}
.admonition.danger, .admonition.crash {
  border-left-color: var(--signal); background: var(--signal-bg);
}
.admonition.danger .admonition-title, .admonition.crash .admonition-title { color: var(--signal); }
.admonition.warning, .admonition.silent {
  border-left-color: var(--warn); background: var(--warn-bg);
}
.admonition.warning .admonition-title, .admonition.silent .admonition-title { color: var(--warn); }
.admonition.tip, .admonition.success {
  border-left-color: var(--ok); background: var(--ok-bg);
}
.admonition.tip .admonition-title, .admonition.success .admonition-title { color: var(--ok); }

/* provenance labels, written inline in the markdown */
.prov {
  font-family: var(--mono); font-size: .66rem; letter-spacing: .1em;
  text-transform: uppercase; padding: .16em .45em;
  border: 1px solid currentColor; border-radius: 2px;
  white-space: nowrap; vertical-align: .12em;
}
.prov-doc { color: var(--ink-faint); }
.prov-schema { color: var(--flag); }
.prov-unver { color: var(--warn); }

/* a numbered walkthrough step */
.prose .step {
  display: grid; grid-template-columns: 2.2rem 1fr; gap: 0 1rem;
  border-top: 1px solid var(--rule-soft); padding-top: 1.1rem;
}
.prose .step > .n {
  font-family: var(--mono); font-size: .875rem; color: var(--flag);
  font-variant-numeric: tabular-nums;
}
.prose .step > div > :first-child { margin-top: 0; }

/* home page cards */
.home .cards {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1rem; margin-top: 1.5rem; padding: 0; list-style: none;
}
.home .cards li { margin: 0; }
.home .cards a {
  display: block; height: 100%; text-decoration: none; color: inherit;
  background: var(--lift); border: 1px solid var(--rule);
  border-left: 3px solid var(--flag);
  padding: 1rem 1.15rem;
}
.home .cards a:hover { border-color: var(--flag); background: var(--lift-2); }
.home .cards strong {
  display: block; font-family: var(--display); font-weight: 600; font-size: 1.0625rem;
}
.home .cards span { display: block; font-size: .9375rem; color: var(--ink-soft); margin-top: .2rem; }
.home { max-width: 58rem; }

/* ------------------------------------------------------------ on this page */
.onthispage { position: sticky; top: 5rem; font-size: .875rem; }
.onthispage > p {
  font-family: var(--mono); font-size: .69rem; font-weight: 500;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-faint); margin: 0 0 .5rem;
  padding-bottom: .4rem; border-bottom: 1px solid var(--rule-soft);
}
.onthispage ul { list-style: none; margin: 0; padding: 0; }
.onthispage ul ul { padding-left: .8rem; }
.onthispage a {
  display: block; padding: .2rem 0; color: var(--ink-soft); text-decoration: none;
}
.onthispage a:hover { color: var(--flag); }
.onthispage .toctitle { display: none; }

/* ------------------------------------------------------------ prev / next */
.seq {
  display: flex; gap: 1rem; justify-content: space-between;
  margin-top: 4rem; padding-top: 1.25rem; border-top: 2px solid var(--ink);
  max-width: var(--measure);
}
.seq a {
  flex: 1; text-decoration: none; color: var(--ink);
  font-family: var(--display); font-weight: 600;
  border: 1px solid var(--rule); padding: .8rem 1rem;
}
.seq a:hover { border-color: var(--flag); color: var(--flag); }
.seq-next { text-align: right; }
.seq a span {
  display: block; font-family: var(--mono); font-weight: 400;
  font-size: .69rem; letter-spacing: .11em; text-transform: uppercase;
  color: var(--ink-faint); margin-bottom: .2rem;
}

.sitefoot {
  border-top: 1px solid var(--rule);
  padding: 1.75rem 1.5rem 3rem;
  font-size: .875rem; color: var(--ink-faint);
}
.sitefoot p { max-width: 60ch; margin: 0 auto; }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1180px) {
  .shell { grid-template-columns: var(--sidebar) minmax(0, 1fr); gap: 2.5rem; }
  .onthispage { display: none; }
}
@media (max-width: 860px) {
  #menu { display: block; }
  .shell { grid-template-columns: minmax(0, 1fr); padding-top: 1.5rem; }
  .sidebar {
    display: none; position: static; max-height: none;
    border: 1px solid var(--rule); background: var(--lift);
    padding: 1.25rem; margin-bottom: 2rem;
  }
  .sidebar.open { display: block; }
  .brand-sub { display: none; }
  .search input { width: 9rem; }
  .seq { flex-direction: column; }
  .seq-next { text-align: left; }
}

/* pygments, minimal and theme-aware */
.hl .k, .hl .kd, .hl .kn { color: var(--flag); font-weight: 500; }
.hl .s, .hl .s1, .hl .s2, .hl .sb { color: var(--ok); }
.hl .c, .hl .c1, .hl .cm { color: var(--ink-faint); font-style: italic; }
.hl .nt { color: var(--flag); }
.hl .na { color: var(--signal); }
.hl .mi, .hl .mf { color: var(--signal); }

/* Images must never exceed their column. Without this a full-size crop
   overflows the body and lands on top of the on-this-page rail. */
article img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.2rem 0;
  border-radius: 3px;
}

/* module artwork: show the asset box */
/* These assets are mostly transparent. Without a frame the reader cannot see
   where the image actually ends, which is the whole point when the brief is
   "author a 380x92 PNG". The checker board makes transparency unambiguous. */
article img[src*="/bases/"] {
  border: 1px solid #6c7a7a;
  background-color: #2a3030;
  background-image:
    linear-gradient(45deg, #333b3b 25%, transparent 25%, transparent 75%, #333b3b 75%),
    linear-gradient(45deg, #333b3b 25%, transparent 25%, transparent 75%, #333b3b 75%);
  background-size: 16px 16px;
  background-position: 0 0, 8px 8px;
  image-rendering: auto;
}

/* A reading measure belongs on PROSE, not on the whole article. Capping the
   article squeezed every table into the text width -- long field names broke
   mid-token (popupModul / eBg) -- while the column beside them sat empty.
   Text keeps its measure; tables, images and the store card get the column. */
.prose { max-width: none; }
.prose > :is(p, ul, ol, dl, blockquote, h1, h2, h3, h4, pre, .admonition, .step, .seq) {
  max-width: var(--measure);
}
.prose > :is(table, figure, .table-scroll) { max-width: 100%; }

/* the store card: its own space at the top right, clear of the text */
.prose > p:has(> img[src$="_card.png"]) {
  float: right;
  width: clamp(15rem, 31%, 21rem);
  max-width: none;
  margin: .25rem 0 1.75rem 2.5rem;
}
article img[src$="_card.png"] {
  width: 100%;
  margin: 0;
  border: 1px solid #6c7a7a;
  border-radius: 2px;
  background: none;
}
/* A block box does not shrink for a float -- only its inline content does, so
   a panel with a background slides UNDER the card. Establishing a block
   formatting context makes the box itself keep clear. */
.prose .admonition, .prose pre, .prose blockquote { display: flow-root; }
@media (max-width: 760px) {
  article img[src$="_card.png"] { float: none; width: 100%; max-width: 360px; margin: 1rem 0; }
}
