/* mopm.dev shared stylesheet, loaded first by every page: tokens (light and dark), base, header, footer, forms,
   code, tags, the big search box, notices, tables, prose, the pager, not-found. Area sheets follow it
   (tools/layout.ts). No external resources (CSP 'self'). The look follows the design mock: warm neutrals, orange brand. */

:root {
  color-scheme: light dark;
  --bg: #fbfaf7;
  /* The header, footer and package head: a tint of the page. */
  --bg-soft: #f4f1ea;
  --surface: #ffffff;
  --surface-2: #f6f4ef;
  --bg-code: #f5f2ec;
  --fg: #16141a;
  --fg-2: #3a3641;
  --fg-muted: #5d5867;
  --border: #e7e2d9;
  --border-strong: #d3ccc0;
  /* Form control borders: at least 3:1 against --bg and --bg-soft (WCAG 1.4.11). */
  --control-border: #8a8378;
  --accent: #c2410c;
  --accent-strong: #9a3412;
  --accent-soft: #fff1e6;
  --accent-fg: #ffffff;
  --btn-top: #c2410c;
  --btn-bottom: #a3360a;
  --magenta: #be185d;
  --link: #1d4ed8;
  --focus: #2563eb;
  --ok: #15803d;
  --ok-soft: #e9f7ee;
  --warn-bg: #fff6e0;
  --warn-border: #e8b64c;
  --error-bg: #fdeeee;
  --error-border: #e5534b;
  --glow-a: rgb(234 88 12 / 16%);
  --glow-b: rgb(190 24 93 / 10%);
  --grid-line: rgb(22 20 26 / 5%);
  --shadow: 0 1px 2px rgb(40 30 20 / 5%), 0 8px 24px -12px rgb(40 30 20 / 18%);
  --shadow-lg: 0 2px 4px rgb(40 30 20 / 4%), 0 24px 48px -20px rgb(120 50 10 / 28%);
  --radius: 12px;
  --radius-sm: 8px;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, "Cascadia Mono", Consolas, "DejaVu Sans Mono", monospace;
  --wrap: 76rem;
  /* The sticky header's height: two rows (brand and nav, then the search and the account box) below 64rem, one row
     from 64rem. The two-row value holds from a 320px viewport up (the max-width: 25rem rule below keeps brand and nav on one row there); under
     320px the nav wraps to a third row. Anchor targets and sticky columns offset by it, so a heading reached by a #link
     is not hidden under the header. */
  --header-h: 106px;
}
@media (min-width: 64rem) { :root { --header-h: 65px; } }

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0b0f;
    --bg-soft: #121017;
    --surface: #15131a;
    --surface-2: #1b1921;
    --bg-code: #111015;
    --fg: #eeecf2;
    --fg-2: #d3d0da;
    --fg-muted: #a49fb0;
    --border: #2a2731;
    --border-strong: #3a3643;
    --control-border: #6f697b;
    --accent: #fb923c;
    --accent-strong: #fdba74;
    --accent-soft: #2a1a10;
    --accent-fg: #1a0f08;
    --btn-top: #fdba74;
    --btn-bottom: #fb923c;
    --magenta: #f472b6;
    --link: #8ab4ff;
    --focus: #8ab4ff;
    --ok: #4ade80;
    --ok-soft: #10251a;
    --warn-bg: #2a2010;
    --warn-border: #8a6a1c;
    --error-bg: #2c1214;
    --error-border: #c4453f;
    --glow-a: rgb(251 146 60 / 14%);
    --glow-b: rgb(244 114 182 / 9%);
    --grid-line: rgb(255 255 255 / 4%);
    --shadow: 0 0 0 1px rgb(255 255 255 / 2%), 0 12px 28px -14px rgb(0 0 0 / 70%);
    --shadow-lg: 0 0 0 1px rgb(255 255 255 / 3%), 0 30px 60px -24px rgb(0 0 0 / 80%);
  }
}

/* ---- base ---- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column; overflow-x: clip;
  background: var(--bg); color: var(--fg); font-family: var(--sans); font-size: 1rem; line-height: 1.6;
  overflow-wrap: break-word; -webkit-font-smoothing: antialiased;
}
main { flex: 1 0 auto; width: 100%; }
main.wrap { padding-top: 2rem; padding-bottom: 4rem; }
main:focus { outline: none; }
[id] { scroll-margin-top: calc(var(--header-h) + 16px); }
.wrap { max-width: var(--wrap); margin: 0 auto; padding-left: 16px; padding-right: 16px; }
@media (min-width: 48rem) { .wrap { padding-left: 32px; padding-right: 32px; } }

h1, h2, h3, h4, h5, h6 { line-height: 1.2; letter-spacing: -0.02em; margin: 1.75em 0 0.6em; font-weight: 700; }
h1 { font-size: clamp(1.75rem, 1.4rem + 1.5vw, 2.4rem); font-weight: 750; margin-top: 0; overflow-wrap: anywhere; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.1rem; font-weight: 650; }
h4, h5, h6 { font-size: 1rem; }
p, ul, ol, dl, pre, blockquote, table { margin: 0 0 1rem; }
a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }

code, kbd, pre { font-family: var(--mono); font-size: 0.9em; }
code { background: var(--bg-code); border: 1px solid var(--border); border-radius: 6px; padding: 0.08em 0.36em; font-size: 0.86em; }
pre {
  background: var(--bg-code); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px 16px; overflow-x: auto; line-height: 1.65; max-width: 100%;
}
pre code { background: none; border: 0; padding: 0; font-size: 0.875rem; white-space: pre; }
kbd {
  display: inline-block; min-width: 1.6em; padding: 0.05em 0.42em; border: 1px solid var(--border-strong);
  border-bottom-width: 2px; border-radius: 6px; background: var(--surface); color: var(--fg-2);
  font-size: 0.78em; line-height: 1.5; text-align: center;
}
hr { border: 0; border-top: 1px solid var(--border); margin: 2rem 0; }
blockquote { margin-left: 0; padding: 0.1rem 1rem; border-left: 4px solid var(--border-strong); color: var(--fg-muted); }

.muted { color: var(--fg-muted); }
.small { font-size: 0.875rem; }
.lede { font-size: 1.1875rem; color: var(--fg-2); max-width: 40rem; line-height: 1.55; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* Focus: always visible for keyboard users. */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.skip {
  position: absolute; left: 16px; top: -100px; z-index: 10; padding: 8px 12px; border-radius: var(--radius-sm);
  background: var(--fg); color: var(--bg); font-weight: 600; text-decoration: none;
}
.skip:focus { top: 8px; }

/* ---- header ---- */

.site-header {
  position: sticky; top: 0; z-index: 5; border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-soft) 85%, transparent); backdrop-filter: saturate(160%) blur(12px);
}
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; min-height: 64px; padding-top: 10px; padding-bottom: 10px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--fg); text-decoration: none; font-size: 1.35rem; font-weight: 800; letter-spacing: -0.045em; }
.logo {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, #f97316, #db2777); color: #ffffff; font-size: 1.1rem; font-weight: 800; line-height: 1;
  box-shadow: 0 1px 0 rgb(255 255 255 / 25%) inset; padding-bottom: 3px;
}
.site-search { order: 3; flex: 1 1 100%; display: flex; align-items: center; gap: 8px; position: relative; }
.site-nav { margin-left: auto; }
.site-nav ul { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; }
.site-nav a { display: block; color: var(--fg-2); text-decoration: none; font-weight: 550; font-size: 0.9375rem; padding: 6px 10px; border-radius: 8px; }
.site-nav a:hover { background: var(--surface-2); color: var(--fg); }
.site-nav a[aria-current] { color: var(--fg); background: var(--surface-2); box-shadow: inset 0 -2px 0 var(--accent); }
/* Below 25rem the brand and the nav are tightened so they share one row down to a 320px viewport (measured in headless
   Chrome, 6px padding: 286px of a 288px box at 320px; the untightened pair needs 353px, so it wraps below a 385px viewport). */
@media (max-width: 25rem) {
  .bar { column-gap: 8px; }
  .brand { font-size: 1.2rem; gap: 8px; }
  .brand .logo { width: 28px; height: 28px; }
  .site-nav ul { gap: 0; }
  .site-nav a { padding: 6px 5px; font-size: 0.875rem; }
}
/* GitHub gives way to Tutorial (4th entry) below 30rem: one row (estimated) */
@media (max-width: 30rem) { #nav-tutorial ~ li { display: none; } }
@media (min-width: 64rem) {
  .site-search { order: 0; flex: 1 1 18rem; max-width: 30rem; margin-left: auto; }
  .site-search + .site-nav { margin-left: 0; }
}
/* The account box (src/account.ts). Below 64rem it ends row two: ::before breaks the line after the nav, and its 10px is
   the space between the rows (row-gap is 0). The login and " with GitHub" are hidden visually, not from names, where
   there is no room. The status of a failed sign-out sits under the box, so it never changes the header's height. */
.site-account { position: relative; display: flex; align-items: center; gap: 8px; min-width: 0; }
.site-account .button { padding: 7px 14px; font-size: 0.875rem; }
.account-login { max-width: 9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.account-status { position: absolute; top: 100%; right: 0; white-space: nowrap; font-size: 0.875rem; background: var(--bg); }
@media not all and (min-width: 64rem) {
  .bar { row-gap: 0; }
  .bar::before { content: ""; order: 2; flex: 0 0 100%; height: 10px; }
  .site-search { flex: 1 1 0; }
  .site-account { order: 4; margin-left: auto; }
}
@media (max-width: 40rem) { .sign-in-more { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); } }
@media (max-width: 30rem) { .account-login { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); } }

/* ---- forms ---- */

input, select, button { font: inherit; color: inherit; }
input[type="search"],
select {
  min-width: 0; width: 100%; padding: 8px 12px; line-height: 1.4; font-size: 0.9375rem;
  border: 1px solid var(--control-border); border-radius: 10px; background: var(--surface); color: var(--fg);
}
input::placeholder { color: var(--fg-muted); opacity: 1; }
.site-search input[type="search"] { flex: 1 1 auto; }
.site-search .button { padding: 7px 14px; font-size: 0.875rem; }
.button {
  flex: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 8px 16px; border: 1px solid var(--control-border); border-radius: 10px; background: var(--surface);
  font-weight: 650; line-height: 1.4; cursor: pointer; white-space: nowrap;
}
.button:hover { border-color: var(--fg-muted); }
.button-primary {
  border-color: transparent; color: var(--accent-fg); background: linear-gradient(180deg, var(--btn-top), var(--btn-bottom));
  box-shadow: 0 1px 0 rgb(255 255 255 / 25%) inset;
}
.button-primary:hover { filter: brightness(1.08); border-color: transparent; }
a.button { color: var(--fg); text-decoration: none; }
a.button-primary { color: var(--accent-fg); }
label { display: block; font-weight: 600; font-size: 0.875rem; margin-bottom: 0.3rem; }

/* ---- command blocks and copy buttons ---- */

.cmd {
  display: flex; align-items: center; gap: 10px; background: var(--bg-code); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 6px 8px 6px 14px; min-width: 0;
}
.cmd pre { flex: 1; min-width: 0; margin: 0; padding: 6px 0; border: 0; background: none; border-radius: 0; scrollbar-width: thin; }
.cmd-lg { padding: 8px 8px 8px 16px; }
.cmd-lg code { font-size: 1rem; }
.prompt { color: var(--accent); font-family: var(--mono); user-select: none; }
.copy {
  flex: none; align-self: flex-start; font-size: 0.8125rem; font-weight: 600; padding: 6px 12px; border-radius: 7px; cursor: pointer;
  min-width: 5rem; text-align: center; /* wide enough for "Copied", so the label change never reflows the command */
  background: var(--surface); color: var(--fg-2); border: 1px solid var(--control-border);
}
.copy:hover { border-color: var(--fg-muted); color: var(--fg); }
.copy.done { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 50%, var(--border)); }
.cmd-lg .copy, .cmd .copy:only-of-type { align-self: center; }

/* ---- tags and glyphs ---- */

.tag {
  display: inline-flex; align-items: center; gap: 5px; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
  padding: 4px 9px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); color: var(--fg-2);
  font-size: 0.75rem; font-weight: 650; line-height: 1; white-space: nowrap; vertical-align: middle;
}
.tag-muted { color: var(--fg-muted); }
.tag-ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.tag-ok::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag-planned { background: transparent; color: var(--fg-muted); border-style: dashed; border-color: var(--border-strong); }
.tag.state-published { color: var(--ok); border-color: currentColor; background: var(--ok-soft); }
.tag.state-yanked { border-color: var(--warn-border); background: var(--warn-bg); }
.tag.state-tombstoned, .tag.state-unknown { border-color: var(--error-border); background: var(--error-bg); }

.glyph {
  display: inline-grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 11px;
  font-family: var(--mono); font-weight: 700; font-size: 0.85rem; color: #ffffff; text-shadow: 0 1px 1px rgb(0 0 0 / 30%);
  background: linear-gradient(140deg, #c2410c, #9d174d); box-shadow: 0 1px 0 rgb(255 255 255 / 25%) inset;
}
.glyph.g1 { background: linear-gradient(140deg, #2563eb, #6d28d9); }
.glyph.g2 { background: linear-gradient(140deg, #0f766e, #1d4ed8); }
.glyph-lg { width: 56px; height: 56px; border-radius: 15px; font-size: 1.2rem; }
.avatar {
  display: inline-grid; place-items: center; flex: none; width: 24px; height: 24px; border-radius: 50%;
  background: linear-gradient(135deg, #c2410c, #9d174d); color: #ffffff; font-size: 0.625rem; font-weight: 750;
}

/* ---- big search box (home hero, search page, not-found pages) ---- */

.big-search {
  position: relative; display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--control-border); box-shadow: var(--shadow-lg);
}
.big-search:focus-within { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 35%, transparent), var(--shadow-lg); }
.big-search input[type="search"] { border: 0; background: transparent; font-size: 1.125rem; padding: 10px 4px; outline: 0; }
.big-search .button { padding: 11px 20px; border-radius: 11px; }
.search-icon { position: relative; flex: none; width: 18px; height: 18px; margin-left: 10px; border: 2px solid var(--fg-muted); border-radius: 50%; }
.search-icon::after { content: ""; position: absolute; width: 2px; height: 8px; right: -5px; bottom: -7px; background: var(--fg-muted); transform: rotate(-45deg); border-radius: 1px; }

/* ---- page heads, crumbs, scripts off ---- */

.page-band {
  margin-top: -2rem; padding-top: 1.5rem; padding-bottom: 1.5rem;
  /* The band's background runs the full width (an outset border image is not scrollable overflow). */
  border-image: linear-gradient(to top, var(--border) 1px, var(--bg-soft) 1px) fill 0 / 0 / 0 100vw;
}
.crumb { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 16px; font-size: 0.875rem; color: var(--fg-muted); }
.crumb a { color: var(--fg-2); text-decoration: none; }
.crumb a:hover { text-decoration: underline; }
.crumb .sep { color: var(--border-strong); }
.crumb [aria-current] { color: var(--fg); font-weight: 600; }
.pager { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; margin-top: 8px; }
.pager a[rel="next"] { margin-left: auto; }
.pager .button { flex: 0 1 auto; white-space: normal; }
.ver { font-family: var(--mono); color: var(--fg-muted); }
.no-js { display: none; }
@media (scripting: none) {
  .no-js { display: block; }
  .js-only, .loading { display: none; }
}

/* ---- notices ---- */

.notice { padding: 1rem 1.25rem; border: 1px solid var(--border); border-left-width: 4px; border-radius: var(--radius); background: var(--surface); margin-bottom: 1.5rem; }
.notice > :last-child { margin-bottom: 0; }
.notice h1 { font-size: 1.5rem; }
.notice-warn { background: var(--warn-bg); border-color: var(--warn-border); }
.notice-error { background: var(--error-bg); border-color: var(--error-border); }
.detail { font-family: var(--mono); font-size: 0.875rem; }
.banner { background: var(--warn-bg); border-bottom: 1px solid var(--warn-border); padding: 0.6rem 1rem; text-align: center; font-size: 0.925rem; }
.banner p { margin: 0; }
.loading h1 { color: var(--fg-muted); font-weight: 500; }

/* ---- tables ---- */

.scroll { overflow-x: auto; max-width: 100%; margin-bottom: 1rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.scroll table { margin: 0; }
table { border-collapse: collapse; width: 100%; font-size: 0.925rem; }
caption { text-align: left; padding: 0.6rem 0.75rem; font-weight: 600; color: var(--fg-muted); font-size: 0.85rem; }
th, td { text-align: left; vertical-align: top; padding: 0.5rem 0.75rem; border-top: 1px solid var(--border); }
thead th { background: var(--surface-2); font-weight: 600; white-space: nowrap; }
tbody th { font-weight: 500; }
td.num { white-space: nowrap; font-variant-numeric: tabular-nums; }
.align-center { text-align: center; }
.align-right { text-align: right; }
tr.state-yanked th, tr.state-yanked td, tr.state-tombstoned th, tr.state-tombstoned td { color: var(--fg-muted); }

/* ---- prose: readmes and docs ---- */

.prose { max-width: 48rem; }
.prose h1:first-child, .prose h2:first-child, .prose h3:first-child { margin-top: 0; }
.prose ul, .prose ol { padding-left: 1.5rem; }
.prose li + li { margin-top: 0.25rem; }

/* ---- footer ---- */

.site-footer { border-top: 1px solid var(--border); background: var(--bg-soft); color: var(--fg-muted); font-size: 0.875rem; }
.site-footer .wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; padding-top: 24px; padding-bottom: 24px; }
.site-footer p { margin: 0; }
.site-footer ul { display: flex; flex-wrap: wrap; gap: 6px 18px; list-style: none; margin: 0; padding: 0; }
.site-footer a { color: var(--fg-2); }

/* ---- not found and failed pages ---- */

.lost { position: relative; max-width: 40rem; margin: 2rem auto 1rem; text-align: center; }
.lost::before {
  content: ""; position: absolute; z-index: -1; inset: -6rem -14rem; pointer-events: none;
  background: radial-gradient(28rem 16rem at 50% 25%, var(--glow-a), transparent 70%), radial-gradient(22rem 14rem at 20% 70%, var(--glow-b), transparent 70%);
}
.lost-error::before { content: none; }
.lost-code {
  margin: 0 0 4px; font-size: clamp(4.5rem, 16vw, 7.5rem); font-weight: 820; line-height: 1; letter-spacing: -0.06em;
  background: linear-gradient(95deg, var(--accent) 10%, var(--magenta) 90%); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.lost h1 { margin-bottom: 12px; }
.lost-lede { color: var(--fg-2); font-size: 1.0625rem; }
.lost-search { margin: 24px 0 20px; text-align: left; }
.lost-error { padding: 28px 24px; border: 1px solid var(--error-border); border-radius: var(--radius); background: var(--error-bg); }
.lost-error .lost-code { font-size: 0.75rem; font-weight: 750; letter-spacing: 0.12em; text-transform: uppercase; color: var(--fg-muted); background: none; }
.lost-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 20px 0 0; }
.way-on { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 22px; list-style: none; padding: 0; margin: 0; font-size: 0.9375rem; font-weight: 600; }

/* ---- narrow screens, motion, forced colours ---- */

@media (max-width: 40rem) {
  .big-search kbd { display: none; }
  .big-search .button { padding: 11px 14px; }
  .big-search input[type="search"] { font-size: 1rem; }
  .cmd-lg code { font-size: 0.8125rem; }
  .cmd-lg { padding-left: 12px; }
  .cmd-lg .prompt { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

@media (forced-colors: active) {
  .logo, .glyph, .avatar, .button-primary { forced-color-adjust: none; }
  .lost-code { color: CanvasText; background: none; }
  :focus-visible { outline-color: Highlight; }
}
