/* Dark by default; the topbar's moon button switches to light (saved per browser).
   Palette: green-tinted darks, teal accents (--em), sky-blue notes (--am). */
:root, :root[data-theme="dark"] {
  --bg: #0b1311; --fg: #ecf5f1; --side: #101c18; --acc: #1a2b25; --muted: #93a9a0; --line: rgba(178, 245, 220, .1);
  --em: #5eead4; --em-t: #2dd4bf; --em-line: rgba(45, 212, 191, .45); --em-bg: rgba(45, 212, 191, .06);
  --am-t: #7dd3fc; --am-line: rgba(125, 211, 252, .45); --am-bg: rgba(56, 189, 248, .06); --code: #15231e;
  --glow: rgba(45, 212, 191, .4);
  --sb: #284640;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f7fbf9; --fg: #0c1a15; --side: #eef6f2; --acc: #dfede7; --muted: #5b7068; --line: #d5e5de;
  --em: #0f766e; --em-t: #0d9488; --em-line: rgba(13, 148, 136, .45); --em-bg: rgba(20, 184, 166, .07);
  --am-t: #0369a1; --am-line: rgba(2, 132, 199, .4); --am-bg: rgba(14, 165, 233, .07); --code: #e3efe9;
  --glow: rgba(13, 148, 136, .35);
  --sb: #b6d4c9;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 16px/1.75 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--fg); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--muted); }
a:hover { text-decoration-color: var(--fg); }
code { background: var(--code); padding: .1em .35em; border-radius: 5px; font-size: .88em; }

/* sidebar: a floating card */
.side {
  position: fixed; top: 8px; left: 8px; bottom: 8px; width: 240px; z-index: 30; display: flex; flex-direction: column;
  background: var(--side); border: 1px solid var(--line); border-radius: 12px; transition: transform .2s, visibility .2s;
}
.side-head { display: flex; align-items: center; gap: 10px; padding: 12px; text-decoration: none; }
.side-head b { display: block; font-size: 14px; font-weight: 600; line-height: 1.25; }
.logo { width: 48px; flex: none; display: grid; place-items: center; }
.logo img { width: 48px; height: auto; }
.ver {
  display: inline-block; margin-top: 3px; padding: 0 7px; border-radius: 6px; background: var(--acc);
  font-size: 11px; font-weight: 600; line-height: 18px;
}
/* search: sidebar button, topbar button, dialog (search.js) */
.search-btn {
  display: flex; align-items: center; gap: 8px; height: 34px; margin: 0 12px 8px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--muted); cursor: pointer;
  font: 14px Inter, ui-sans-serif, system-ui, sans-serif; text-align: left;
}
.search-btn:hover { color: var(--fg); }
.search-btn span { flex: 1; }
kbd {
  padding: 1px 5px; border: 1px solid var(--line); border-radius: 5px; background: var(--side); color: var(--muted);
  font: 600 11px Inter, ui-sans-serif, system-ui, sans-serif;
}
.s-dlg {
  width: min(560px, calc(100vw - 24px)); margin: 12vh auto auto; padding: 0; overflow: hidden;
  border: 1px solid var(--line); border-radius: 12px; background: var(--side); color: var(--fg);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .5);
}
.s-dlg::backdrop { background: rgba(0, 0, 0, .6); }
.s-in { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); color: var(--muted); }
.s-in input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--fg);
  font: 16px Inter, ui-sans-serif, system-ui, sans-serif;
}
.s-results { list-style: none; margin: 0; padding: 6px; max-height: min(60vh, 440px); overflow-y: auto; }
.s-results li { margin: 0; }
.s-results a { display: block; padding: 8px 10px; border-radius: 8px; text-decoration: none; }
.s-results a.on, .s-results a:hover { background: var(--acc); }
.s-t { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; font-weight: 600; line-height: 1.4; }
.s-t small { flex: none; color: var(--muted); font-size: 12px; font-weight: 500; }
.s-s { display: block; margin-top: 2px; color: var(--muted); font-size: 13px; line-height: 1.4; }
.s-empty { padding: 16px; color: var(--muted); font-size: 14px; text-align: center; }

.side-nav { flex: 1; overflow-y: auto; padding: 2px 8px 16px; font-size: 14px; line-height: 1.3; }
.side-nav a { display: block; padding: 6px 8px; border-radius: 8px; text-decoration: none; }
.side-nav a:hover { background: var(--acc); }
.side-nav a.on { background: var(--acc); font-weight: 500; box-shadow: inset 2px 0 0 var(--em-t); }
.side-nav a.top { font-weight: 500; }
.grp-t { padding: 12px 8px 4px; font-weight: 500; }
.grp-i { margin-left: 14px; padding-left: 6px; border-left: 1px solid var(--line); }
.grp-i a { color: var(--muted); }
.grp-i a:hover { color: var(--fg); }
.grp-i a.on { color: var(--em); }
.shade { display: none; }

main { margin-left: 256px; min-height: 100vh; display: flex; flex-direction: column; transition: margin .2s; }
body.side-hidden .side { transform: translateX(calc(-100% - 16px)); visibility: hidden; }
body.side-hidden main { margin-left: 0; }

/* top bar */
.topbar { display: flex; gap: 8px; padding: 12px 16px; }
.ib {
  height: 32px; min-width: 32px; padding: 0 8px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--fg); cursor: pointer;
  font: 500 13px Inter, ui-sans-serif, system-ui, sans-serif; text-decoration: none;
}
.ib:hover { background: var(--acc); }
.ib.wide { margin-left: auto; }

/* page column */
.doc { width: 100%; max-width: 640px; margin: 0 auto; padding: 24px 16px 0; flex: 1; }
.crumb { margin: 0 0 4px; font-size: 13px; color: var(--muted); }
.crumb a { color: var(--muted); }
.crumb span { margin: 0 6px; }
h1 {
  margin: 0 0 24px; padding-bottom: 12px; border-bottom: 1px solid var(--line);
  font-size: 30px; font-weight: 700; line-height: 1.2; letter-spacing: -.02em;
}
h2 {
  margin: 40px 0 14px; padding-left: 12px; border-left: 3px solid var(--em-t);
  font-size: 24px; font-weight: 600; line-height: 1.3; letter-spacing: -.01em;
}
h3 { margin: 28px 0 8px; font-size: 18px; font-weight: 600; }
p { margin: 0 0 16px; }
ul { padding-left: 1.3em; margin: 0 0 16px; }
li { margin: .3em 0; }
.muted { color: var(--muted); }
.toc { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 14px; }

/* intro + the page's sprite, glowing */
.hero { display: flex; align-items: center; gap: 24px; margin-bottom: 8px; }
.hero .intro { flex: 1; min-width: 0; }
.sprite { flex: none; image-rendering: pixelated; }
.hero .sprite { filter: drop-shadow(0 0 26px var(--glow)); }
.hero .sprite.mon { width: 192px; height: 192px; margin: -24px 0; }
.hero .sprite.item { width: 144px; height: 144px; }

/* callouts: Feature notes (emerald), Note (amber) */
.callout { margin: 24px 0; padding: 14px 16px; border: 1px solid; border-radius: 10px; }
.callout.feat { border-color: var(--em-line); background: var(--em-bg); }
.callout.note { border-color: var(--am-line); background: var(--am-bg); }
.callout-t {
  display: flex; align-items: center; gap: 8px; padding-bottom: 8px;
  font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
}
.callout.feat .callout-t { color: var(--em-t); }
.callout.note .callout-t { color: var(--am-t); }
.callout p { margin: 0 0 8px; }
.callout > :last-child { margin-bottom: 0; }
.fn { display: flex; align-items: center; gap: 12px; padding: 4px 0; }
.fn .sprite { width: 48px; height: 48px; }
.fn b { display: block; font-size: 15px; line-height: 1.3; }
.fn span { font-size: 14px; line-height: 1.4; }

/* tables */
.tbl { overflow-x: auto; margin: 16px 0 24px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 1.5; }
th, td { padding: 8px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--line); }
th { font-weight: 600; white-space: nowrap; }
.opts th { padding: 4px 8px 10px; font-size: 24px; letter-spacing: -.01em; }
.opts td { padding: 14px 8px; }
.ov { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 16px; }
.od { margin-top: 4px; }
.badge {
  display: inline-block; padding: 0 8px; border-radius: 6px; background: var(--em-bg); color: var(--em);
  border: 1px solid var(--em-line);
  font-size: 11px; font-weight: 600; line-height: 20px;
}
.idx td { white-space: nowrap; }
.idx td:first-child { white-space: normal; min-width: 140px; }
.idx td.since { color: var(--muted); }

/* screenshots: the caption sits on the picture */
figure.shot {
  position: relative; margin: 16px 0; overflow: hidden;
  border: 1px solid var(--line); border-radius: 10px; background: #000;
}
figure.shot img { display: block; width: 100%; height: auto; image-rendering: pixelated; }
figure.shot figcaption {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 6px 10px;
  background: rgba(0, 0, 0, .65); color: #fff; font-size: 13px; line-height: 1.4;
}
.see { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 15px; }

/* previous / next chips, riding the bottom of the screen */
.pager {
  position: sticky; bottom: 16px; z-index: 5; display: flex; justify-content: space-between;
  margin: 40px 0 24px; pointer-events: none;
}
.pager a {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; max-width: 48%; padding: 6px 10px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg); text-decoration: none;
  font-size: 13px; font-weight: 600; line-height: 1.25; box-shadow: 0 4px 16px rgba(0, 0, 0, .25);
}
.pager a:hover { background: var(--acc); }
.pager a.next { text-align: right; color: var(--em); }
.pager small { display: block; font-size: 11px; font-weight: 500; color: var(--muted); }
.arr { color: var(--muted); font-size: 16px; }

/* footer */
footer { margin-top: 48px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.made { padding: 14px; text-align: center; }
.foot { display: flex; justify-content: space-between; gap: 24px; padding: 14px 16px 20px; border-top: 1px solid var(--line); }
.foot p { max-width: 440px; margin: 0 0 6px; line-height: 1.5; }
.foot nav { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.foot nav a { color: var(--muted); }

/* landing page */
.landing { padding: 10vh 0 4vh; text-align: center; }
.float { width: min(300px, 80%); margin: 0 auto 28px; }
.cart-wrap { position: relative; transition: transform .2s ease-out; will-change: transform; }
.cart-big { display: block; width: 100%; height: auto; filter: drop-shadow(0 0 28px var(--glow)); }
.cart-wrap::after {  /* sheen that follows the mouse, clipped to the cartridge's shape */
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .25s;
  background: radial-gradient(circle at var(--mx, 50%) var(--my, 50%), rgba(255, 255, 255, .35), transparent 55%);
  -webkit-mask: url(/img/cart.png) center / contain no-repeat; mask: url(/img/cart.png) center / contain no-repeat;
}
.cart-wrap:hover::after { opacity: 1; }
.nf-mon { width: 192px; height: 192px; margin: 0 auto -8px; display: block; image-rendering: pixelated;
  filter: drop-shadow(0 0 26px var(--glow)); }
.nf h1 { font-size: 64px; letter-spacing: .02em; }
.landing h1 { margin: 0 0 12px; padding: 0; border: 0; font-size: 40px; font-weight: 800; }
.ver.big { font-size: 12px; padding: 0 9px; line-height: 22px; }
.tag { max-width: 520px; margin: 20px auto 0; color: var(--muted); font-size: 15px; line-height: 1.6; }
.cta { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 24px; }
.banners { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 22px; }
.banners img { display: block; width: 190px; height: auto; }
.btn {
  display: inline-flex; gap: 8px; align-items: center; padding: 6px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--side); font-size: 14px; font-weight: 600; text-decoration: none;
}
.btn:hover { background: var(--acc); }
.btn.glow { color: var(--em); border-color: var(--em-line); box-shadow: 0 0 18px var(--glow); }

/* scrollbars in the site's colours */
html, .side-nav, .s-results, .tbl { scrollbar-color: var(--sb) transparent; scrollbar-width: thin; }

/* small motions; all of them stop when the system asks for less motion */
@media (prefers-reduced-motion: no-preference) {
  .doc { animation: fade-up .35s ease-out both; }
  .hero .sprite, .nf-mon { animation: pop-in .45s cubic-bezier(.2, 1.4, .4, 1) both .1s; }
  /* keep pop-in in the list: replacing it would restart it (and its delay hides the sprite) */
  .hero .sprite:hover, .nf-mon:hover { animation: pop-in .45s cubic-bezier(.2, 1.4, .4, 1) both .1s, hop .5s ease-out; }
  .fn:hover .sprite { animation: hop .5s ease-out; }
  .float { animation: float 5s ease-in-out infinite; }
  .logo img { transition: transform .3s; }
  .side-head:hover .logo img { transform: rotate(-8deg) scale(1.08); }
  .btn, .ib, .pager a, figure.shot { transition: transform .15s, box-shadow .2s, background-color .15s, border-color .2s; }
  .btn:hover { transform: translateY(-1px); }
  .banners a { display: block; transition: transform .15s; }
  .banners a:hover { transform: translateY(-2px); }
  .btn.glow:hover { box-shadow: 0 0 26px var(--glow); }
  .pager a:hover .arr { transform: translateX(3px); }
  .pager a:not(.next):hover .arr { transform: translateX(-3px); }
  .arr { display: inline-block; transition: transform .15s; }
  figure.shot:hover { transform: translateY(-2px); border-color: var(--em-line); }
  .callout { transition: border-color .2s; }
  .s-dlg[open] { animation: pop-in .18s ease-out; }
}
@keyframes fade-up { from { opacity: 0; transform: translateY(8px); } }
@keyframes pop-in { from { opacity: 0; transform: scale(.85); } }
@keyframes hop { 30% { transform: translateY(-10px); } 55% { transform: translateY(0); } 70% { transform: translateY(-4px); } }
@keyframes float { 50% { transform: translateY(-8px); } }
.idx tbody tr:hover { background: var(--acc); }

/* phone and narrow windows: the sidebar becomes a drawer */
@media (max-width: 899px) {
  .side { transform: translateX(calc(-100% - 16px)); visibility: hidden; width: min(280px, 85vw); }
  body.nav-open .side { transform: none; visibility: visible; }
  body.nav-open .shade { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(0, 0, 0, .55); }
  main { margin-left: 0; }
  .topbar { padding: 10px 12px; }
  .doc { padding: 12px 16px 0; }
  h1 { font-size: 26px; }
  .landing h1 { font-size: 30px; }
  .foot { flex-direction: column; }
  .search-btn kbd, .s-in kbd { display: none; }
  .s-dlg { margin-top: 8vh; }
}
@media (max-width: 560px) {
  .hero { flex-direction: column-reverse; align-items: flex-start; gap: 8px; }
  .hero .sprite.mon { width: 128px; height: 128px; margin: 0; }
  .hero .sprite.item { width: 96px; height: 96px; }
}
