/* Marstopia docs: the Mars look of the home page and the arena (rust, dust and a sunrise
   orange, clean type, soft cards), a sticky contents column, and the town's own UI pieces
   (world.css) shown as examples. */
:root {
  --w-ui: "Space Grotesk", system-ui, sans-serif;
  --w-text: "Inter", system-ui, sans-serif;
  --d-bg: #f7ebe1;
  --d-paper: #fff8f2;
  --d-ink: #2a140c;
  --d-soft: #6b4636;
  --d-faint: #9a7564;
  --d-line: rgba(42, 20, 12, 0.14);
  --d-edge: rgba(42, 20, 12, 0.12);
  --d-accent: #c2471b;
  --d-accent-soft: rgba(194, 71, 27, 0.1);
  --d-warn: #b23b2a;
  --d-shadow: 0 10px 30px rgba(70, 30, 12, 0.1);
}
@media (prefers-color-scheme: dark) {
  :root {
    --d-bg: #1a0e0a;
    --d-paper: #2a1610;
    --d-ink: #fbeee4;
    --d-soft: #d8b9a6;
    --d-faint: #a8877a;
    --d-line: rgba(255, 214, 190, 0.14);
    --d-edge: rgba(255, 214, 190, 0.12);
    --d-accent: #ff8a3d;
    --d-accent-soft: rgba(255, 138, 61, 0.14);
    --d-shadow: 0 14px 40px rgba(0, 0, 0, 0.35);
    /* The town's night colours for the example pieces. */
    --w-card: #2a1610;
    --w-card-solid: #3a1d12;
    --w-ink: #fbeee4;
    --w-ink-soft: #d8b9a6;
    --w-ink-faint: #a8877a;
    --w-line: rgba(255, 214, 190, 0.14);
    --w-edge: #0d0604;
    --w-accent: #ff8a3d;
    --w-accent-soft: rgba(255, 138, 61, 0.14);
    --w-good: #4ade80;
    --w-bad: #ff5a4f;
    --w-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    --w-portrait-bg: #4a2618;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 84px; }
body { margin: 0; background: var(--d-bg); color: var(--d-ink); font: 400 16px/1.6 var(--w-text); -webkit-font-smoothing: antialiased; }
a { color: var(--d-accent); font-weight: 800; }
code { font: 700 0.86em ui-monospace, "Cascadia Code", Consolas, monospace; background: var(--d-accent-soft); padding: 1px 6px; border-radius: 3px; word-break: break-all; }

/* --- top bar ----------------------------------------------------------------- */
.d-top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 12px max(20px, env(safe-area-inset-left));
  background: var(--d-bg);
  border-bottom: 2px solid var(--d-edge);
}
.d-brand { display: flex; align-items: center; gap: 10px; color: var(--d-ink); text-decoration: none; }
.d-brand b { display: block; font: 600 20px/1 var(--w-ui); }
.d-brand small { display: block; color: var(--d-faint); font-size: 11px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; }
.d-mark { display: block; flex: none; width: 36px; height: 36px; image-rendering: pixelated; }
.d-back { margin-left: auto; padding: 8px 16px; border-radius: 3px; background: var(--d-accent); color: var(--d-paper); text-decoration: none; font-size: 13px; }
.d-narrow { display: none; }
.d-menu { display: none; margin-left: auto; padding: 8px 14px; border-radius: 3px; border: 1px solid var(--d-line); background: var(--d-paper); color: var(--d-ink); font: 800 13px var(--w-text); }

/* --- layout ------------------------------------------------------------------- */
.d-layout { display: grid; grid-template-columns: 230px minmax(0, 760px); gap: 48px; justify-content: center; padding: 28px 24px 80px; }
.d-nav { position: sticky; top: 84px; align-self: start; display: grid; gap: 2px; max-height: calc(100vh - 110px); overflow-y: auto; }
.d-nav a { padding: 7px 12px; border-radius: 3px; color: var(--d-soft); text-decoration: none; font-size: 14px; font-weight: 700; }
.d-nav a:hover { background: var(--d-accent-soft); color: var(--d-ink); }
.d-nav a.on { background: var(--d-accent-soft); color: var(--d-ink); box-shadow: inset 3px 0 0 var(--d-accent); }

.d-main section { padding: 8px 0 28px; border-bottom: 1px solid var(--d-line); margin-bottom: 28px; }
.d-main section:last-of-type { border-bottom: 0; }
h1, h2, h3, h4 { font-family: var(--w-ui); font-weight: 600; line-height: 1.15; margin: 0; }
h1 { font-size: clamp(34px, 5vw, 50px); letter-spacing: -0.01em; }
h2 { font-size: 30px; margin-bottom: 14px; }
h3 { font-size: 20px; margin: 22px 0 8px; }
h4 { font-size: 17px; margin-bottom: 6px; }
p, ul, ol, dl { margin: 0 0 12px; }
ul, ol { padding-left: 22px; }
li { margin: 4px 0; }
.d-kicker { color: var(--d-accent); font-size: 12px; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; margin-bottom: 8px; }
.d-lede { font-size: 18.5px; color: var(--d-soft); margin: 14px 0 20px; }

/* --- pictures ------------------------------------------------------------------- */
.d-figure { margin: 18px 0; }
.d-figure img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 3px; background: var(--d-accent-soft); border: 2px solid var(--d-edge); box-shadow: var(--d-shadow); }
.d-figure.wide img { aspect-ratio: 16 / 8; }
.d-figure.square img { aspect-ratio: 1; max-width: 380px; object-fit: contain; }
.d-figure figcaption { margin-top: 8px; color: var(--d-faint); font-size: 13px; font-weight: 700; }

/* --- blocks --------------------------------------------------------------------- */
.d-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.d-stats div { padding: 14px; border-radius: 3px; background: var(--d-paper); border: 2px solid var(--d-edge); box-shadow: var(--d-shadow); }
.d-stats b { display: block; font: 600 24px/1.1 var(--w-ui); }
.d-stats span { color: var(--d-soft); font-size: 12.5px; font-weight: 700; }
.d-steps { counter-reset: step; list-style: none; padding: 0; display: grid; gap: 10px; }
.d-steps li { counter-increment: step; position: relative; padding: 12px 14px 12px 54px; border-radius: 3px; background: var(--d-paper); border: 2px solid var(--d-edge); box-shadow: var(--d-shadow); margin: 0; }
.d-steps li::before { content: counter(step); position: absolute; left: 14px; top: 12px; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 2px; background: var(--d-accent); color: var(--d-paper); font-weight: 800; font-size: 14px; }
.d-note { color: var(--d-soft); font-size: 14.5px; }
.d-callout { margin: 0 0 14px; padding: 12px 16px; border-radius: 3px; background: var(--d-accent-soft); border-left: 4px solid var(--d-accent); font-weight: 700; }
.d-two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 12px 0; }
.d-card { padding: 14px 16px; border-radius: 3px; background: var(--d-paper); border: 2px solid var(--d-edge); box-shadow: var(--d-shadow); }
.d-card ul { margin: 0; padding-left: 18px; font-size: 15px; }
.d-defs { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; }
.d-defs dt { font-weight: 800; }
.d-defs dd { margin: 0; color: var(--d-soft); }
.d-table-wrap { overflow-x: auto; margin: 10px 0 14px; border-radius: 3px; border: 2px solid var(--d-edge); box-shadow: var(--d-shadow); background: var(--d-paper); }
.d-table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.d-table th { text-align: left; padding: 10px 14px; font-size: 11.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--d-faint); border-bottom: 1px solid var(--d-line); }
.d-table td { padding: 9px 14px; border-bottom: 1px solid var(--d-line); }
.d-table tr:last-child td { border-bottom: 0; }
.d-table td:first-child { font-weight: 800; text-transform: capitalize; }
.d-badge { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 3px; background: var(--d-accent-soft); font-size: 11px; font-weight: 800; text-transform: none; }
.d-tiers { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 14px; }
.d-tiers .w-tier { font-size: 12.5px; padding: 4px 11px; }
.d-mono { font-size: 14px; color: var(--d-soft); }
details { margin: 0 0 8px; padding: 12px 16px; border-radius: 3px; background: var(--d-paper); border: 2px solid var(--d-edge); box-shadow: var(--d-shadow); }
details summary { cursor: pointer; font-weight: 800; }
details p { margin: 8px 0 0; color: var(--d-soft); }
.d-foot { color: var(--d-faint); font-size: 13.5px; padding-top: 10px; }

/* --- the town's UI, shown as examples ------------------------------------------------ */
.d-demo { margin: 14px 0; padding: 16px; border-radius: 3px; background: repeating-linear-gradient(135deg, var(--d-accent-soft) 0 12px, transparent 12px 24px); border: 1px dashed var(--d-line); display: grid; gap: 10px; }
.d-demo .w-me.d-static { position: static; transform: none; max-width: 100%; flex-wrap: wrap; justify-self: start; }
.d-demo .w-me-btn { cursor: default; }
.d-demo .w-cta { margin: 0; }
.d-demo .w-btn { cursor: default; }

/* --- phones ---------------------------------------------------------------------------- */
@media (max-width: 900px) {
  .d-layout { grid-template-columns: minmax(0, 1fr); gap: 0; padding: 16px 16px 60px; }
  .d-menu { display: block; }
  .d-top { gap: 8px; padding: 10px 14px; }
  .d-back { margin-left: 0; padding: 8px 14px; }
  .d-wide { display: none; }
  .d-narrow { display: inline; }
  .d-nav { position: fixed; z-index: 19; top: 62px; left: 12px; right: 12px; max-height: 70vh; padding: 8px; border-radius: 3px; background: var(--d-paper); border: 1px solid var(--d-line); box-shadow: var(--d-shadow); display: none; }
  .d-nav.open { display: grid; }
  .d-stats { grid-template-columns: 1fr 1fr; }
  .d-two { grid-template-columns: 1fr; }
  .d-defs { grid-template-columns: 1fr; gap: 2px; }
  .d-defs dd { margin-bottom: 8px; }
  h2 { font-size: 26px; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

/* --- the town's look: pixel headings, flat stamps, raised buttons ---------------- */
h1, h2, h3, h4, .d-brand b, .d-mark, .d-stats b, .d-kicker, .d-back, .d-menu, .d-table th, .d-steps li::before, .d-badge { font-family: var(--w-ui); font-weight: 600; letter-spacing: 0.01em; }
h1 { letter-spacing: 0; }
.d-back, .d-menu { border: 2px solid var(--d-edge); box-shadow: var(--w-bevel); }
.d-back { color: var(--d-paper); }

.d-callout { border: 2px solid var(--d-edge); border-left-width: 6px; border-left-color: var(--d-accent); }
.d-demo { border-radius: 3px; background: repeating-conic-gradient(var(--d-accent-soft) 0 25%, transparent 0 50%) 0 0 / 12px 12px; }
.d-demo .w-ico { color: currentColor; }
.d-nav a.on { box-shadow: inset 4px 0 0 var(--d-accent); }
a { font-weight: 600; }
.d-defs dt, details summary, .d-table td:first-child { font-weight: 600; }

/* --- Mars: rounded, soft, no pixel shadows (overrides the town look above) ---------------- */
body { background: radial-gradient(120% 40% at 50% 0%, rgba(194, 71, 27, 0.12), transparent 60%), var(--d-bg); }
h1, h2, h3, h4, .d-brand b { letter-spacing: -0.02em; font-weight: 700; }
.d-mark { image-rendering: auto; border-radius: 9px; }
.d-top { border-bottom: 1px solid var(--d-line); backdrop-filter: blur(10px); background: color-mix(in srgb, var(--d-bg) 85%, transparent); }
.d-back, .d-menu { border: 0; box-shadow: none; border-radius: 999px; }
.d-back { background: linear-gradient(135deg, #ffa25a, #ff6a2b); color: #2a0f05; }
.d-figure img, .d-stats div, .d-steps li, .d-card, .d-table-wrap, details, .d-callout { border-radius: 16px; border: 1px solid var(--d-line); }
.d-figure img { border-radius: 18px; }
.d-callout { border-left: 4px solid var(--d-accent); }
.d-steps li::before { border-radius: 50%; background: linear-gradient(135deg, #ffa25a, #ff6a2b); color: #2a0f05; }
.d-nav a { border-radius: 10px; }
.d-demo { border-radius: 16px; }
.d-stats b { color: var(--d-accent); }
.d-bots { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; margin: 14px 0; }
.d-bots span { display: block; aspect-ratio: 120 / 174; padding: 6px; border-radius: 14px; background: var(--d-paper); border: 1px solid var(--d-line); }
.d-bots svg { width: 100%; height: 100%; }
pre.d-code { margin: 10px 0 14px; padding: 14px 16px; border-radius: 14px; background: #160a06; color: #ffd9c2; font: 13px/1.55 ui-monospace, Consolas, monospace; overflow-x: auto; white-space: pre; }
.d-camps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 12px 0; }
.d-camps div { padding: 12px 14px; border-radius: 14px; background: var(--d-paper); border: 1px solid var(--d-line); border-top: 4px solid var(--c); }
.d-camps b { display: block; font: 700 16px var(--w-ui); }
.d-camps small { color: var(--d-soft); }
@media (max-width: 900px) { .d-camps { grid-template-columns: 1fr 1fr; } }
