/* WebMoki site — "Moki 8-Bit" theme */
:root {
  --page: #d9d4c3;
  --panel: #fffdf5;
  --panel-2: #f3efe2;
  --ink: #1b1b2f;
  --ink-soft: #4a4a5e;
  --line: #1b1b2f;
  --link: #1d4ed8;
  --link-hover: #b91c1c;
  --primary: #c81e1e;
  --on-primary: #ffffff;
  --accent: #15803d;
  --on-accent: #ffffff;
  --code-bg: #1b1b2f;
  --code-ink: #b6f7c1;
  --sky-1: #7ec8ff;
  --sky-2: #a5dbff;
  --sky-3: #cdeeff;
  --cloud: #ffffff;
  --hill-1: #3f9c4b;
  --hill-2: #2f7a3a;
  --ground: #8a5a2b;
  --ground-top: #5fbf4a;
  --moki-fur: #8a4b2a;
  --moki-face: #f6d7b0;
  --moki-ear: #e9a07a;
  --moki-flame: #f2781f;
  --moki-core: #ffd23f;
  --moki-flicker: #ffb02e;
  --moki-cheek: #ff8fa3;
  --focus: #c81e1e;
  --ok-bg: #dcfce7;
  --err-bg: #fee2e2;
  --shadow: 4px 4px 0 var(--line);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --page: #070b16;
  --panel: #131b2e;
  --panel-2: #1a2440;
  --ink: #eef2ff;
  --ink-soft: #a9b4d0;
  --line: #000000;
  --link: #8fb4ff;
  --link-hover: #ff8080;
  --primary: #ff5c5c;
  --on-primary: #12060a;
  --accent: #4ade80;
  --on-accent: #052e16;
  --code-bg: #05070f;
  --code-ink: #7dfc9a;
  --sky-1: #0b1030;
  --sky-2: #141b4d;
  --sky-3: #232c6e;
  --cloud: #3a4486;
  --hill-1: #1f4b5c;
  --hill-2: #153644;
  --ground: #2b1d14;
  --ground-top: #2f6b3a;
  --moki-fur: #a65c35;
  --moki-face: #f6d7b0;
  --moki-ear: #e9a07a;
  --moki-flame: #ff8a2a;
  --moki-core: #ffe066;
  --moki-flicker: #ffb84d;
  --moki-cheek: #ff6b8a;
  --focus: #ffd23f;
  --ok-bg: #0f3a22;
  --err-bg: #4a1414;
  --shadow: 4px 4px 0 #000;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background-color: var(--page);
  background-image:
    linear-gradient(45deg, rgba(0,0,0,.05) 25%, transparent 25%, transparent 75%, rgba(0,0,0,.05) 75%),
    linear-gradient(45deg, rgba(0,0,0,.05) 25%, transparent 25%, transparent 75%, rgba(0,0,0,.05) 75%);
  background-size: 16px 16px;
  background-position: 0 0, 8px 8px;
  color: var(--ink);
  font: 22px/1.35 "VT323", ui-monospace, monospace;
  -webkit-font-smoothing: none;
}
h1, h2, h3, h4, .pixel { font-family: "Press Start 2P", ui-monospace, monospace; font-weight: 400; line-height: 1.5; letter-spacing: 0; }
h1 { font-size: clamp(16px, 3.2vw, 24px); }
h2 { font-size: clamp(14px, 2.4vw, 18px); margin: 0 0 8px; }
h3 { font-size: 13px; margin: 0 0 12px; }
p { margin: 0 0 14px; }
a { color: var(--link); text-underline-offset: 3px; text-decoration-thickness: 2px; }
a:hover { color: var(--link-hover); }
:focus-visible { outline: 3px dashed var(--focus); outline-offset: 3px; }
img, svg { image-rendering: pixelated; }
svg.px { shape-rendering: crispEdges; }

.skip { position: absolute; left: -9999px; top: 8px; background: var(--panel); color: var(--ink); padding: 8px 12px; border: 3px solid var(--line); z-index: 10; }
.skip:focus { left: 8px; }

/* ---- frame ---- */
.wrap { max-width: 1080px; margin: 24px auto; padding: 0 16px; }
.frame { background: var(--panel); border: 4px solid var(--line); box-shadow: 8px 8px 0 var(--line); }

/* ---- header banner ---- */
.banner { position: relative; height: 210px; overflow: hidden; border-bottom: 4px solid var(--line); background: var(--sky-1); }
.banner svg.scene { position: absolute; inset: 0; width: 100%; height: 100%; }
.sky-1 { fill: var(--sky-1); } .sky-2 { fill: var(--sky-2); } .sky-3 { fill: var(--sky-3); }
.cloud { fill: var(--cloud); } .hill-1 { fill: var(--hill-1); } .hill-2 { fill: var(--hill-2); }
.ground { fill: var(--ground); } .ground-top { fill: var(--ground-top); }
.star { fill: #fff7c2; opacity: 0; }
:root[data-theme="dark"] .star { opacity: 1; }
.title-card { position: absolute; left: 24px; top: 22px; max-width: calc(100% - 48px); background: var(--panel); border: 4px solid var(--line); box-shadow: var(--shadow); padding: 14px 18px 12px; }
.site-title { margin: 0; font-size: clamp(18px, 4vw, 30px); }
.site-title a { color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; gap: 12px; }
.site-title a:hover { color: var(--primary); }
.tagline { margin: 6px 0 0; color: var(--ink-soft); font-size: 22px; }

/* Moki the monkey: see MOKI_* in build.py */
.moki { width: 42px; height: 44px; flex: none; }
.moki .o, .moki .k { fill: var(--line); }
.moki .f { fill: var(--moki-fur); } .moki .l { fill: var(--moki-face); } .moki .e { fill: var(--moki-ear); }
.moki .h { fill: var(--moki-flame); } .moki .g { fill: var(--moki-core); }
.moki .w { fill: #fff; } .moki .p { fill: var(--moki-cheek); } .moki .r { fill: #d62839; } .moki .t { fill: #ff7a8a; }
.moki .face, .moki .heart { display: none; }
.moki .face.on { display: inline; }

.banner .walker { position: absolute; right: 9%; bottom: 30px; width: 78px; height: 81px; padding: 0; border: 0; background: none; cursor: pointer; line-height: 0; -webkit-tap-highlight-color: transparent; }
.banner .walker .moki { width: 100%; height: 100%; }
.banner .walker:focus-visible { outline-offset: 4px; }
.walker.heart .heart { display: inline; }
.moki-say { position: absolute; right: calc(9% + 58px); bottom: 116px; font: 11px/1.4 "Press Start 2P", monospace; color: var(--ink); background: var(--panel); border: 3px solid var(--line); box-shadow: 3px 3px 0 var(--line); padding: 6px 8px; white-space: nowrap; pointer-events: none; }
.moki-say::after { content: ""; position: absolute; right: -3px; bottom: -11px; width: 8px; height: 8px; background: var(--panel); border-right: 3px solid var(--line); border-bottom: 3px solid var(--line); }
@media (prefers-reduced-motion: no-preference) {
  .banner .walker { animation: hop 1.2s steps(2) infinite; }
  .banner .walker.poke { animation: jump .5s steps(4); }
  .banner .walker .tail { transform-origin: 20px 24px; animation: wag 1.6s steps(2) infinite; }
  .banner .walker:hover .tail { animation-duration: .5s; }
  .banner .walker .g { animation: flicker .7s steps(1) infinite; }
  .walker.heart .heart { animation: float 1.6s steps(8) forwards; }
  @keyframes hop { 50% { transform: translateY(-6px); } }
  @keyframes jump { 50% { transform: translateY(-24px); } }
  @keyframes wag { 50% { transform: rotate(-12deg); } }
  @keyframes flicker { 50% { fill: var(--moki-flicker); } }
  @keyframes float { to { transform: translateY(-8px); opacity: 0; } }
}

/* ---- nav (page tabs) ---- */
.nav { display: flex; flex-wrap: wrap; align-items: stretch; gap: 0; background: var(--panel-2); border-bottom: 4px solid var(--line); }
.nav a, .nav button { font: 11px/1 "Press Start 2P", monospace; color: var(--ink); text-decoration: none; padding: 16px 16px; min-height: 48px; display: inline-flex; align-items: center; gap: 8px; border: 0; border-right: 4px solid var(--line); background: transparent; cursor: pointer; }
.nav a:hover, .nav button:hover { background: var(--panel); color: var(--primary); }
.nav a[aria-current="page"] { background: var(--panel); color: var(--primary); box-shadow: inset 0 -4px 0 var(--primary); }
.nav .spacer { flex: 1; border-right: 4px solid var(--line); }
.nav .theme-toggle { border-right: 0; }
.nav .nav-item { position: relative; display: flex; }
.nav .nav-item > [aria-haspopup]::after { content: ""; border: 4px solid transparent; border-top-color: currentColor; margin-top: 4px; }
.nav .nav-sub { display: none; position: absolute; top: 100%; left: -4px; z-index: 20; min-width: 230px; flex-direction: column; background: var(--panel-2); border: 4px solid var(--line); box-shadow: var(--shadow); }
.nav .nav-item:hover > .nav-sub, .nav .nav-item:focus-within > .nav-sub { display: flex; }
.nav .nav-sub a, .nav .nav-sub span { border-right: 0; border-bottom: 2px dotted var(--ink-soft); min-height: 44px; padding: 12px 14px; line-height: 1.5; }
.nav .nav-sub span { font: 11px/1.5 "Press Start 2P", monospace; color: var(--ink-soft); display: flex; align-items: center; }
.nav .nav-sub > :last-child { border-bottom: 0; }
.nav .nav-sub .deep { padding-left: 30px; }
.nav .nav-empty { padding: 16px; font-size: 20px; color: var(--ink-soft); align-self: center; }
.theme-toggle svg { width: 16px; height: 16px; }
.theme-toggle .sun { display: none; } :root[data-theme="dark"] .theme-toggle .sun { display: block; } :root[data-theme="dark"] .theme-toggle .moon { display: none; }

/* ---- layout ---- */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; }
.content { padding: 28px; border-right: 4px solid var(--line); min-width: 0; background: var(--panel); }
.sidebar { padding: 28px 20px; background: var(--panel-2); min-width: 0; }
/* No sidebar (the owner emptied it): the page takes the full width. */
.sidebar:empty { display: none; }
.layout:not(:has(> .sidebar)), .layout:has(> .sidebar:empty) { grid-template-columns: 1fr; }
.layout:not(:has(> .sidebar)) > .content, .layout:has(> .sidebar:empty) > .content { border-right: 0; }
/* The request page doesn't advertise itself. */
.layout:has(#request-form) .widget.cta { display: none; }
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .content { border-right: 0; border-bottom: 4px solid var(--line); padding: 22px 18px; }
  .sidebar { padding: 22px 18px; }
  .banner { height: 190px; }
  .title-card { left: 12px; top: 14px; max-width: calc(100% - 24px); }
  .banner .walker { right: 14px; bottom: 22px; width: 54px; height: 56px; }
  .moki-say { right: 60px; bottom: 74px; }
}
@media (max-width: 520px) {
  .wrap { margin: 12px auto; padding: 0 8px; }
  .frame { box-shadow: 4px 4px 0 var(--line); }
  .nav a, .nav button { padding: 14px 10px; font-size: 10px; }
  .nav .spacer { display: none; }
  .banner { height: 262px; }
  .banner .walker { bottom: 18px; }
  .moki-say { right: 80px; bottom: 36px; }
  .moki-say::after { right: -11px; bottom: 6px; border-bottom: 0; border-top: 3px solid var(--line); transform: rotate(45deg); }
}

/* ---- posts ---- */
.post { margin: 0 0 32px; padding-bottom: 28px; border-bottom: 4px dotted var(--ink-soft); }
.post:last-child { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }
.post-title { margin: 0 0 6px; font-size: clamp(14px, 2.4vw, 18px); }
.post-title a { color: var(--ink); text-decoration: none; }
.post-title a:hover { color: var(--primary); text-decoration: underline; }
.postmeta { color: var(--ink-soft); font-size: 20px; margin: 0 0 14px; display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; }
.postmeta svg { width: 14px; height: 14px; vertical-align: -1px; margin-right: 4px; fill: currentColor; }
.entry ul { margin: 0 0 14px; padding-left: 0; list-style: none; }
.entry li { padding-left: 26px; position: relative; margin-bottom: 4px; }
.entry li::before { content: ""; position: absolute; left: 4px; top: 8px; width: 10px; height: 10px; background: var(--primary); box-shadow: 2px 2px 0 var(--line); }
.postfoot { color: var(--ink-soft); font-size: 20px; margin-top: 10px; }
.postfoot svg { width: 14px; height: 14px; vertical-align: -1px; margin-right: 4px; }
.postmeta .ico .k, .postfoot .ico .k { fill: currentColor; }
.sticky-label { display: inline-block; font: 9px/1 "Press Start 2P", monospace; background: var(--accent); color: var(--on-accent); padding: 6px 8px; border: 3px solid var(--line); margin-bottom: 10px; }

pre, code { font-family: "VT323", ui-monospace, monospace; }
pre { background: var(--code-bg); color: var(--code-ink); padding: 14px 16px; border: 4px solid var(--line); box-shadow: var(--shadow); overflow-x: auto; font-size: 22px; line-height: 1.3; margin: 0 0 16px; }
pre .p { color: #ffd23f; }
code { background: var(--panel-2); padding: 0 5px; border: 2px solid var(--ink-soft); }
pre code { background: none; border: 0; padding: 0; }

.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin: 6px 0 16px; }
.feature { border: 4px solid var(--line); background: var(--panel-2); padding: 14px; box-shadow: var(--shadow); }
.feature h3 { display: flex; align-items: center; gap: 10px; font-size: 11px; margin-bottom: 8px; }
.feature svg { width: 24px; height: 24px; flex: none; }
.feature p { margin: 0; font-size: 21px; }
.ico .f { fill: var(--primary); } .ico .g { fill: var(--accent); } .ico .k { fill: var(--ink); } .ico .l { fill: var(--link); }

/* ---- buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; font: 12px/1.4 "Press Start 2P", monospace; text-decoration: none; cursor: pointer; padding: 14px 18px; min-height: 48px; border: 4px solid var(--line); background: var(--primary); color: var(--on-primary); box-shadow: var(--shadow); transition: transform 80ms steps(2), box-shadow 80ms steps(2); }
.btn:hover { color: var(--on-primary); transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--line); }
.btn:active { transform: translate(4px, 4px); box-shadow: 0 0 0 var(--line); }
.btn.secondary { background: var(--panel); color: var(--ink); }
.btn.secondary:hover { color: var(--ink); }
.btn[disabled] { opacity: .6; cursor: progress; }
.btn-row { display: flex; flex-wrap: wrap; gap: 14px; margin: 8px 0 4px; }

/* ---- sidebar widgets ---- */
.widget { margin: 0 0 26px; }
.widget:last-child { margin-bottom: 0; }
.widget-title { font: 11px/1.5 "Press Start 2P", monospace; margin: 0 0 10px; padding: 8px 10px; background: var(--ink); color: var(--panel); }
.widget ul { list-style: none; margin: 0; padding: 0; }
.widget li { padding: 5px 0; border-bottom: 2px dotted var(--ink-soft); }
.widget li:last-child { border-bottom: 0; }
.widget li a::before { content: "» "; color: var(--primary); }
.widget p { font-size: 21px; }
.widget.cta { border: 4px solid var(--line); background: var(--panel); padding: 14px; box-shadow: var(--shadow); }
.widget.cta .btn { width: 100%; font-size: 11px; }
.counter { display: inline-flex; gap: 3px; padding: 6px; background: #000; border: 4px solid var(--line); }
.counter span { font: 16px/1 "Press Start 2P", monospace; color: #7dfc9a; background: #0b1a0f; padding: 8px 5px; min-width: 22px; text-align: center; }
.tagcloud { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.tagcloud a { text-decoration: none; }
.tagcloud a:hover { text-decoration: underline; }

/* ---- footer ---- */
.footer { border-top: 4px solid var(--line); background: var(--ink); color: var(--panel); padding: 18px 24px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 20px; font-size: 20px; }
.footer a { color: var(--panel); }
.footer a:hover { color: var(--focus); }
:root[data-theme="dark"] .footer { background: #000; color: var(--ink); }
:root[data-theme="dark"] .footer a { color: var(--ink); }

.blink { display: inline-block; width: .6em; height: 1em; background: currentColor; vertical-align: -2px; margin-left: 4px; }
@media (prefers-reduced-motion: no-preference) { .blink { animation: blink 1s steps(1) infinite; } @keyframes blink { 50% { opacity: 0; } } }

/* ---- forms ---- */
.form { display: grid; gap: 18px; }
.form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 600px) { .form .row { grid-template-columns: 1fr; } }
.field { display: grid; gap: 6px; }
.field label, .field legend { font: 10px/1.6 "Press Start 2P", monospace; }
.field .req { color: var(--primary); }
.field .hint { color: var(--ink-soft); font-size: 19px; margin: 0; }
.field input, .field select, .field textarea {
  font: 22px/1.2 "VT323", monospace; color: var(--ink); background: var(--panel);
  border: 4px solid var(--line); padding: 10px 12px; min-height: 48px; width: 100%; border-radius: 0;
  box-shadow: inset 3px 3px 0 rgba(0,0,0,.12);
}
.field textarea { min-height: 150px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 3px dashed var(--focus); outline-offset: 2px; }
.field [aria-invalid="true"] { border-color: var(--primary); background: var(--err-bg); }
.field .err { color: var(--primary); font-size: 20px; margin: 0; min-height: 0; }
:root[data-theme="dark"] .field .err { color: #ff9b9b; }
.check { display: grid; grid-template-columns: 28px 1fr; gap: 12px; align-items: start; font-size: 21px; }
.check input { width: 28px; height: 28px; margin: 2px 0 0; accent-color: var(--primary); }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.notice { border: 4px solid var(--line); padding: 14px 16px; box-shadow: var(--shadow); margin: 0 0 22px; }
.notice.ok { background: var(--ok-bg); }
.notice.err { background: var(--err-bg); }
.notice h2 { font-size: 13px; margin-bottom: 8px; }
.notice p:last-child { margin: 0; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* ---- WebMoki content blocks ---- */
.figure { margin: 0 0 16px; }
.figure img { display: block; max-width: 100%; height: auto; border: 4px solid var(--line); box-shadow: var(--shadow); }
.figure figcaption { color: var(--ink-soft); font-size: 20px; margin-top: 8px; }
.text-block > .moki-rich > :last-child { margin-bottom: 14px; }
.entry h2, .entry h3 { margin: 18px 0 10px; }
