/* Mod documentation, shared by both games - Supermarket Simulator and Megastore
   Simulator. This file used to say it was for the first one alone, from when the
   docs lived under /sms/; it dresses /docs/sms/ and /docs/mss/ alike now.

   Palette, fonts and easing come from the :root block of index.html, so the docs
   read as part of the site instead of an annex. */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg:        #000000;
  --bg2:       #0a0a0a;
  --bg3:       #111111;
  --bg4:       #1a1a1a;
  --border:    #1f1f1f;
  --border2:   #2a2a2a;
  --text:      #ffffff;
  --text2:     #a0a0a0;
  --text3:     #808080;
  --accent:    #3b82f6;
  --accent2:   #60a5fa;
  --accent-rgb: 59, 130, 246;
  --green:     #10b981;
  --amber:     #fbbf24;
  --red:       #ef4444;
  --violet:    #a78bfa;
  --mono:      'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans:      'Inter', system-ui, sans-serif;
  --ease:      cubic-bezier(0.4, 0, 0.2, 1);
  --nav-h:     60px;
  --shell-top: calc(var(--nav-h) + 2.25rem);
}

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--nav-h) + 20px); }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── NAVBAR ───────────────────────────────────────────────────────────── */
.docs-nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--nav-h);
  display: flex; align-items: center;
  gap: 1rem;
  padding: 0 1.25rem;
  background: rgba(0,0,0,0.82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.docs-nav-logo {
  font-family: var(--mono); font-size: .95rem; color: var(--accent);
  letter-spacing: .02em; white-space: nowrap;
}
.docs-nav-logo:hover { text-decoration: none; }
.docs-nav-logo span { color: var(--text2); }
.docs-nav-sep { color: var(--border2); }
.docs-nav-here { font-size: .85rem; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.docs-nav-right { margin-left: auto; display: flex; align-items: center; gap: 1.25rem; }
.docs-nav-right a { font-size: .82rem; color: var(--text2); }
.docs-nav-right a:hover { color: var(--text); text-decoration: none; }

.docs-burger {
  display: none; background: none; border: 1px solid var(--border2);
  border-radius: 6px; padding: .35rem .5rem; cursor: pointer; color: var(--text2);
}
.docs-burger svg { width: 18px; height: 18px; display: block; }

/* ── LAYOUT ───────────────────────────────────────────────────────────── */
.docs-shell {
  display: grid;
  grid-template-columns: 258px minmax(0, 1fr) 208px;
  gap: 2.5rem;
  max-width: 1340px;
  margin: 0 auto;
  padding: var(--shell-top) 1.75rem 5rem;
  align-items: start;
}

/* ── SIDEBAR ──────────────────────────────────────────────────────────── */
.docs-side {
  /* Exactly the shell's padding-top. If the sticky stop were higher than where the
     column starts, the rail would slide up on the first scroll and read as a jump. */
  position: sticky; top: var(--shell-top);
  max-height: calc(100vh - var(--nav-h) - 3rem);
  overflow-y: auto;
  padding-right: .5rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border2) transparent;
}
.docs-side::-webkit-scrollbar { width: 6px; }
.docs-side::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 99px; }
.docs-side::-webkit-scrollbar-track { background: transparent; }

.docs-side-group { margin-bottom: 1.25rem; }
.docs-side-group-name {
  font-size: .7rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text3); padding: 0 .75rem .45rem;
}
.docs-side-group-name.sub { font-size: .66rem; opacity: .8; padding-top: .35rem; }

/* One collapsible block per mod. Open by default only for the mod you are in,
   so the rail stays short no matter how many mods get documented. */
.docs-side-mod { margin-bottom: .35rem; }
.docs-side-mod-head { display: flex; align-items: center; gap: .25rem; }
.docs-side-mod-name {
  flex: 1; display: block; font-size: .9rem; font-weight: 600; color: var(--text2);
  padding: .38rem .75rem; border-radius: 6px; transition: color .15s var(--ease), background .15s var(--ease);
}
a.docs-side-mod-name:hover { color: var(--text); background: var(--bg2); text-decoration: none; }
a.docs-side-mod-name.on { color: var(--text); }
.docs-side-mod-name.muted { color: var(--text3); font-weight: 500; }
.docs-side-soon {
  font-size: .62rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text3); border: 1px solid var(--border2); border-radius: 99px;
  padding: .05rem .4rem; margin-right: .5rem;
}
.docs-side-chev {
  background: none; border: none; cursor: pointer; color: var(--text3);
  padding: .3rem; display: flex; border-radius: 5px;
  transition: color .15s var(--ease), transform .18s var(--ease);
}
.docs-side-chev:hover { color: var(--text); }
.docs-side-chev svg { width: 14px; height: 14px; }
.docs-side-mod[data-open="1"] .docs-side-chev { transform: rotate(90deg); }
.docs-side-mod[data-open="0"] .docs-side-mod-body { display: none; }
.docs-side-mod-body { padding-left: .5rem; border-left: 1px solid var(--border); margin: .25rem 0 1rem .75rem; }
.docs-side-mod-body .docs-side-group { margin-bottom: .8rem; }
.docs-side-mod-body .docs-side-group:last-child { margin-bottom: .2rem; }
.docs-side a {
  display: block;
  font-size: .855rem;
  color: var(--text2);
  padding: .34rem .75rem;
  border-left: 2px solid transparent;
  border-radius: 0 5px 5px 0;
  transition: color .15s var(--ease), background .15s var(--ease), border-color .15s var(--ease);
}
.docs-side a:hover { color: var(--text); background: var(--bg2); text-decoration: none; }
.docs-side a.active {
  color: var(--accent2);
  background: rgba(var(--accent-rgb), .08);
  border-left-color: var(--accent);
  font-weight: 600;
}

.docs-side-filter {
  width: 100%;
  background: var(--bg2); border: 1px solid var(--border2); border-radius: 7px;
  color: var(--text); font-family: var(--sans); font-size: .82rem;
  padding: .45rem .7rem; margin-bottom: 1.1rem; outline: none;
  transition: border-color .15s var(--ease);
}
.docs-side-filter:focus { border-color: var(--accent); }
.docs-side-filter::placeholder { color: var(--text3); }

/* ── ARTICLE ───────────────────────────────────────────────────────────── */
.docs-article { min-width: 0; padding-bottom: 1rem; }
.docs-eyebrow {
  font-family: var(--mono); font-size: .74rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--accent); margin-bottom: .5rem;
}
.docs-article h1 { font-size: 2.1rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; }
.docs-lead { font-size: 1.02rem; color: var(--text2); margin: .7rem 0 2.2rem; }

.docs-article h2 {
  font-size: 1.35rem; font-weight: 700; letter-spacing: -.01em;
  margin: 2.6rem 0 .9rem; padding-top: .3rem;
}
.docs-article h3 { font-size: 1.02rem; font-weight: 700; margin: 1.9rem 0 .6rem; }
.docs-article p { color: var(--text2); margin-bottom: 1rem; }
.docs-article strong { color: var(--text); font-weight: 600; }

.docs-article ul, .docs-article ol { color: var(--text2); margin: 0 0 1.1rem 1.15rem; }
.docs-article li { margin-bottom: .4rem; }
.docs-article li::marker { color: var(--text3); }

.docs-anchor {
  color: var(--text3); font-weight: 400; margin-left: .45rem;
  opacity: 0; transition: opacity .15s var(--ease);
}
h2:hover .docs-anchor, h3:hover .docs-anchor { opacity: 1; }
.docs-anchor:hover { color: var(--accent2); text-decoration: none; }

hr.docs-rule { border: 0; border-top: 1px solid var(--border); margin: 2.6rem 0; }

/* ── CODE BLOCKS ───────────────────────────────────────────────────────────── */

/* ================== THE CHIP IS NO LONGER OPT-IN ==================

   This used to be `code.inline` alone, which meant a bare <code> in a paragraph
   got NO styling at all - no mono, no background, no colour. Fifteen Mega UI
   pages were written that way, 142 occurrences of it.

   Direct-child selectors fix it without touching anything that already worked:

     p > code / li > code / dd > code   prose, which is where the chip is missed
     <td><code>                         does NOT match - a cell has no <p> inside,
                                        and it has its own rule further down
     <pre><code>                        does NOT match - the block sits under <pre>

   `code.inline` still applies, so pages that already mark the class do not move
   a pixel. */
code.inline,
p > code,
li > code,
dd > code {
  font-family: var(--mono); font-size: .84em;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 5px; padding: .1em .38em; color: var(--accent2);
}
.docs-code {
  position: relative;
  background: var(--bg2); border: 1px solid var(--border2);
  border-radius: 10px; margin: 0 0 1.4rem;
  overflow: hidden;
}
.docs-code-head {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding: .5rem .85rem; border-bottom: 1px solid var(--border);
  background: var(--bg3);
}
.docs-code-lang {
  font-family: var(--mono); font-size: .7rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--text3);
}
.docs-copy {
  background: transparent; border: none; cursor: pointer; color: var(--text3);
  padding: .2rem; border-radius: 4px; display: flex; transition: color .15s var(--ease);
}
.docs-copy:hover { color: var(--accent2); }
.docs-copy.copied { color: var(--green); }
.docs-copy svg { width: 14px; height: 14px; }
.docs-code pre {
  margin: 0; padding: .95rem 1.05rem; overflow-x: auto;
  font-family: var(--mono); font-size: .795rem; line-height: 1.72;
  color: #cbd5e1;
}
.docs-code pre::-webkit-scrollbar { height: 7px; }
.docs-code pre::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 99px; }

.tok-kw   { color: #c084fc; }
.tok-type { color: #7dd3fc; }
.tok-str  { color: #86efac; }
.tok-num  { color: var(--amber); }
.tok-com  { color: #64748b; font-style: italic; }
.tok-attr { color: #f9a8d4; }
.tok-tag  { color: #7dd3fc; }
.tok-aval { color: #86efac; }

/* ── TABLES ──────────────────────────────────────────────────────────── */
.docs-table-wrap { overflow-x: auto; margin-bottom: 1.5rem; border: 1px solid var(--border2); border-radius: 10px; }
table.docs-table { width: 100%; border-collapse: collapse; font-size: .855rem; }
table.docs-table th {
  text-align: left; font-weight: 600; color: var(--text);
  background: var(--bg3); padding: .6rem .85rem;
  border-bottom: 1px solid var(--border2); white-space: nowrap;
}
table.docs-table td {
  padding: .6rem .85rem; color: var(--text2);
  border-bottom: 1px solid var(--border); vertical-align: top;
}
table.docs-table tr:last-child td { border-bottom: none; }
table.docs-table code { font-family: var(--mono); font-size: .82em; color: var(--accent2); }
.req { color: var(--amber); font-family: var(--mono); font-size: .74rem; }

/* ── CALLOUTS ───────────────────────────────────────────────────────────── */
.docs-note {
  border: 1px solid var(--border2); border-left-width: 3px;
  border-radius: 8px; padding: .85rem 1.05rem; margin: 0 0 1.4rem;
  background: var(--bg2); font-size: .885rem; color: var(--text2);
}
.docs-note p:last-child { margin-bottom: 0; }
.docs-note-title { font-weight: 700; color: var(--text); font-size: .8rem; letter-spacing: .04em; text-transform: uppercase; margin-bottom: .35rem; }
.docs-note.info    { border-left-color: var(--accent); }
.docs-note.warn    { border-left-color: var(--amber); }
.docs-note.danger  { border-left-color: var(--red); }
.docs-note.ok      { border-left-color: var(--green); }
.docs-note.info   .docs-note-title { color: var(--accent2); }
.docs-note.warn   .docs-note-title { color: var(--amber); }
.docs-note.danger .docs-note-title { color: var(--red); }
.docs-note.ok     .docs-note-title { color: var(--green); }

/* ── CARDS ────────────────────────────────────────────────────────────── */
.docs-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1rem; margin-bottom: 1.6rem; }
.docs-card {
  display: block; background: var(--bg2); border: 1px solid var(--border2);
  border-radius: 10px; padding: 1rem 1.15rem;
  transition: border-color .18s var(--ease), transform .18s var(--ease);
}
a.docs-card:hover { border-color: var(--accent); transform: translateY(-2px); text-decoration: none; }
.docs-card-title { font-weight: 700; color: var(--text); margin-bottom: .3rem; font-size: .95rem; }
.docs-card-text { font-size: .84rem; color: var(--text2); line-height: 1.55; }

/* ── LANDING HERO ─────────────────────────────────────────────────────── */
.mod-hero {
  background: linear-gradient(160deg, rgba(var(--accent-rgb), .10), rgba(var(--accent-rgb), 0) 60%), var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 14px;
  padding: 1.6rem 1.75rem 1.75rem;
  margin-bottom: 2.4rem;
}
.mod-hero-tag {
  font-family: var(--mono); font-size: .72rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--accent); margin-bottom: .55rem;
}
.mod-hero-title { font-size: 1.45rem; font-weight: 700; letter-spacing: -.01em; }
.mod-hero-text { color: var(--text2); margin: .7rem 0 1.25rem; max-width: 62ch; }
.mod-hero-actions { display: flex; flex-wrap: wrap; gap: .6rem; }

/* ── TABLE OF CONTENTS ──────────────────────────────────────────────────────────── */
.docs-toc {
  /* Exactly the shell's padding-top. If the sticky stop were higher than where the
     column starts, the rail would slide up on the first scroll and read as a jump. */
  position: sticky; top: var(--shell-top);
  max-height: calc(100vh - var(--nav-h) - 3rem); overflow-y: auto;
  font-size: .8rem; scrollbar-width: thin; scrollbar-color: var(--border2) transparent;
}
.docs-toc::-webkit-scrollbar { width: 6px; }
.docs-toc::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 99px; }
.docs-toc-title {
  font-size: .68rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--text3); margin-bottom: .6rem; padding-left: .7rem;
}
.docs-toc a {
  display: block; color: var(--text3); padding: .22rem .7rem;
  border-left: 2px solid var(--border); line-height: 1.45;
  transition: color .15s var(--ease), border-color .15s var(--ease);
}
.docs-toc a:hover { color: var(--text2); text-decoration: none; }
.docs-toc a.h3 { padding-left: 1.35rem; font-size: .765rem; }
.docs-toc a.active { color: var(--accent2); border-left-color: var(--accent); }

/* ── PAGER ────────────────────────────────────────────────────────── */
.docs-pager { display: flex; gap: 1rem; margin-top: 3.2rem; }
.docs-pager a {
  flex: 1; background: var(--bg2); border: 1px solid var(--border2);
  border-radius: 10px; padding: .85rem 1.1rem;
  transition: border-color .18s var(--ease);
}
.docs-pager a:hover { border-color: var(--accent); text-decoration: none; }
.docs-pager .dir { display: block; font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--text3); margin-bottom: .2rem; }
.docs-pager .name { color: var(--text); font-weight: 600; font-size: .9rem; }
.docs-pager .next { text-align: right; }

/* ── TOOLS (generator / validator) ────────────────────────────────── */
.tool-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .9rem; margin-bottom: 1.2rem; }
.tool-field { display: flex; flex-direction: column; gap: .3rem; }
.tool-field label { font-size: .76rem; font-weight: 600; color: var(--text2); letter-spacing: .03em; }
.tool-field .hint { font-size: .72rem; color: var(--text3); }
.tool-field input, .tool-field select, .tool-field textarea {
  background: var(--bg2); border: 1px solid var(--border2); border-radius: 7px;
  color: var(--text); font-family: var(--sans); font-size: .85rem;
  padding: .45rem .65rem; outline: none; transition: border-color .15s var(--ease);
}
.tool-field textarea { font-family: var(--mono); font-size: .8rem; min-height: 150px; resize: vertical; line-height: 1.6; }
.tool-field input:focus, .tool-field select:focus, .tool-field textarea:focus { border-color: var(--accent); }
.tool-field input.bad, .tool-field textarea.bad { border-color: var(--red); }
.tool-row { display: flex; align-items: center; gap: .55rem; margin-bottom: .9rem; font-size: .85rem; color: var(--text2); }
.tool-count { font-family: var(--mono); font-size: .72rem; color: var(--text3); }
.tool-count.over { color: var(--red); }

.docs-tabs { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.docs-tab {
  background: var(--bg2); border: 1px solid var(--border2); border-radius: 7px;
  color: var(--text2); font-size: .8rem; font-weight: 600;
  padding: .35rem .8rem; cursor: pointer; transition: all .15s var(--ease);
}
.docs-tab:hover { color: var(--text); border-color: var(--text3); }
.docs-tab.on { background: rgba(var(--accent-rgb), .12); border-color: var(--accent); color: var(--accent2); }

.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  background: var(--accent); color: #fff; border: none; border-radius: 8px;
  font-family: var(--sans); font-size: .86rem; font-weight: 600;
  padding: .55rem 1.05rem; cursor: pointer; transition: background .15s var(--ease);
}
.btn:hover { background: var(--accent2); text-decoration: none; }
.btn.ghost { background: transparent; border: 1px solid var(--border2); color: var(--text2); }
.btn.ghost:hover { border-color: var(--text3); color: var(--text); background: transparent; }

.check-list { list-style: none; margin-left: 0; }
.check-list li { display: flex; gap: .55rem; align-items: flex-start; font-size: .865rem; margin-bottom: .45rem; }
.check-badge { font-family: var(--mono); font-size: .68rem; font-weight: 700; padding: .12rem .45rem; border-radius: 4px; flex-shrink: 0; margin-top: .15rem; }
.check-badge.err  { background: rgba(239,68,68,.15);  color: var(--red); }
.check-badge.warn { background: rgba(251,191,36,.15); color: var(--amber); }
.check-badge.ok   { background: rgba(16,185,129,.15); color: var(--green); }

/* ── BUILT-IN ICONS ──────────────────────────────────────────────────── */
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: .7rem; margin-bottom: 1.5rem; }
.icon-cell {
  background: var(--bg2); border: 1px solid var(--border2); border-radius: 9px;
  padding: .8rem .4rem .55rem; text-align: center;
}
/* These are white-with-alpha PNGs: the SAME files the mod draws in game. */
.icon-cell img { width: 26px; height: 26px; display: block; margin: 0 auto; opacity: .92; }
.icon-cell .name { display: block; font-family: var(--mono); font-size: .68rem; color: var(--text3); margin-top: .45rem; word-break: break-all; }

/* ── TAB DIAGRAM ────────────────────────────────────────────────── */
.tabs-demo { background: var(--bg2); border: 1px solid var(--border2); border-radius: 10px; padding: 1rem; margin-bottom: 1.5rem; overflow-x: auto; }
.tabs-demo-row { display: flex; gap: .4rem; align-items: center; min-width: 460px; }
.tabs-demo-row + .tabs-demo-row { margin-top: .5rem; padding-top: .5rem; border-top: 1px solid var(--border); }
.tabs-demo-chip {
  font-size: .78rem; font-weight: 600; padding: .32rem .85rem; border-radius: 6px;
  background: var(--bg4); color: var(--text2); border: 1px solid var(--border2); white-space: nowrap;
}
.tabs-demo-chip.on { background: var(--violet); color: #140e26; border-color: var(--violet); }
.tabs-demo-chip.sub-on { background: var(--violet); color: #140e26; border-color: var(--violet); }
.tabs-demo-arrow { color: var(--text3); font-size: 1.1rem; padding: 0 .2rem; }
.tabs-demo-x { margin-left: auto; color: var(--text3); font-size: .8rem; padding: .32rem .6rem; border: 1px solid var(--border2); border-radius: 6px; }
.tabs-demo-label { font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--text3); margin-bottom: .5rem; }

/* ── RESPONSIVE ───────────────────────────────────────────────────────── */
@media (max-width: 1180px) {
  .docs-shell { grid-template-columns: 240px minmax(0, 1fr); gap: 2rem; }
  .docs-toc { display: none; }
}
@media (max-width: 860px) {
  .docs-burger { display: block; }
  .docs-shell { grid-template-columns: minmax(0, 1fr); padding-top: calc(var(--nav-h) + 1.5rem); }
  .docs-side {
    position: fixed; top: var(--nav-h); left: 0; bottom: 0; width: 280px;
    background: var(--bg2); border-right: 1px solid var(--border2);
    padding: 1.25rem 1rem; max-height: none; z-index: 90;
    transform: translateX(-100%); transition: transform .25s var(--ease);
  }
  .docs-side.open { transform: translateX(0); }
  .docs-overlay {
    position: fixed; inset: var(--nav-h) 0 0 0; background: rgba(0,0,0,.6);
    z-index: 89; opacity: 0; pointer-events: none; transition: opacity .25s var(--ease);
  }
  .docs-overlay.on { opacity: 1; pointer-events: auto; }
  .docs-article h1 { font-size: 1.7rem; }
  .docs-nav-here { display: none; }
}
@media (max-width: 520px) {
  .docs-shell { padding-left: 1.1rem; padding-right: 1.1rem; }
  .docs-pager { flex-direction: column; }
  .docs-nav-right a.hide-sm { display: none; }
}
