/* ============================================================================
   Map Blueprint — shared design system  (pixel terminal / neon-green on black)
   ONE source of truth for tokens + base controls. Linked by index/dashboard/
   login/settings.html. Editor-only layout stays in style.css.
   White-label config.json still overrides --accent / --accent-dim at runtime;
   the rest of the accent family is derived with color-mix() so it follows.
   ========================================================================= */

/* ---- fonts (bundled locally — no external requests, offline-safe) ---- */
@font-face {
  font-family: "Pixelify Sans"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("assets/fonts/pixelify-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Pixelify Sans"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("assets/fonts/pixelify-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Space Mono"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("assets/fonts/spacemono-400-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Space Mono"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("assets/fonts/spacemono-400-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Space Mono"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("assets/fonts/spacemono-700-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Space Mono"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("assets/fonts/spacemono-700-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---- tokens ---- */
:root {
  /* surfaces — nested darkness = depth (no soft shadows anywhere) */
  --bg:        #0a0a0a;
  --bg-alt:    #0c110e;
  --panel:     #101410;   /* cards / panels / toolbar */
  --panel-2:   #171a17;   /* buttons / inputs / tab surface */
  --panel-ink: #0c0f0c;   /* inset wells (inputs, canvas overlays) */
  --line:      #2a302a;   /* 1px structural border */
  --canvas-bg: #0d0d0d;

  /* text */
  --text:       #d6e0d0;
  --body-green: #bff59a;  /* AA-safe green-on-black copy */
  --muted:      #8a988a;

  /* the single neon accent — white-label overrides --accent / --accent-dim,
     the rest derive from --accent so a custom accent recolours the whole set */
  --accent:        #7be23a;
  --accent-dim:    #223018;                                       /* selected fill tint */
  --accent-2:      color-mix(in srgb, var(--accent) 70%, #fff);   /* bright peak */
  --accent-border: color-mix(in srgb, var(--accent) 62%, #000);   /* ~#52971f */
  --ink-on-green:  #04110a;                                       /* text on green fill */

  /* state colours (unify the old ad-hoc reds / ambers) */
  --danger: #f2593b;
  --ok:     #7be23a;
  --warn:   #d8a64a;

  /* pixel depth — hard, zero-blur black offset ONLY */
  --shadow-pixel:    3px 3px 0 rgba(0, 0, 0, .5);
  --shadow-pixel-lg: 5px 5px 0 rgba(0, 0, 0, .5);
  --glow:            0 0 16px rgba(123, 226, 58, .42);

  /* sharp corners + two border weights only */
  --radius:   0;
  --bd:       1px;
  --bd-thick: 2px;

  --font-display: "Pixelify Sans", system-ui, sans-serif;
  --font-mono:    "Space Mono", ui-monospace, Consolas, monospace;
  --font-body:    system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
/* Pixelify Sans has no CJK glyphs — swap display face for Chinese */
html[lang="zh"] { --font-display: system-ui, "Microsoft YaHei", "Noto Sans CJK SC", sans-serif; }

/* ---- base ---- */
* { box-sizing: border-box; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
}
h1, h2, h3, legend, .brand-sub, .app-title {
  font-family: var(--font-display);
  letter-spacing: .5px;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); }
::selection { background: var(--accent); color: var(--ink-on-green); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- scrollbars (square, dim-green) ---- */
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line); border-radius: 0;
  border: 2px solid transparent; background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--accent-border); background-clip: padding-box; }
::-webkit-scrollbar-corner { background: transparent; }

/* ============================================================================
   Buttons — chunky pixel: black fill / green text, invert on hover, press down.
   Applies to <button>, .btn and links styled as buttons. Ghost = quieter.
   ========================================================================= */
button, .btn,
input[type="submit"], input[type="button"] {
  display: inline-block;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: .4px;
  font-size: 14px;
  line-height: 1.2;
  padding: 9px 15px;
  background: var(--panel-2);
  color: var(--accent);
  border: var(--bd-thick) solid var(--accent-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pixel);
  cursor: pointer;
  text-decoration: none;
  transition: transform .1s steps(2, end), box-shadow .12s ease, background .12s ease, color .12s ease, border-color .12s ease;
}
button:hover, .btn:hover,
input[type="submit"]:hover, input[type="button"]:hover {
  background: var(--accent);
  color: var(--ink-on-green);
  border-color: var(--accent);
  transform: translate(-2px, -2px);
  box-shadow: var(--shadow-pixel-lg), var(--glow);
}
button:active, .btn:active,
input[type="submit"]:active, input[type="button"]:active {
  transform: translate(2px, 2px);
  box-shadow: none;
}
button:disabled, .btn:disabled, button[disabled] {
  opacity: .45; cursor: default;
  transform: none; box-shadow: var(--shadow-pixel);
  background: var(--panel-2); color: var(--muted); border-color: var(--line);
}

/* ghost / secondary — dim line border, muted text until hover */
.btn-ghost, button.ghost, .btn.ghost {
  background: transparent; border-color: var(--line); color: var(--muted); box-shadow: none;
}
.btn-ghost:hover, button.ghost:hover, .btn.ghost:hover {
  background: var(--panel-2); border-color: var(--accent); color: var(--accent);
  box-shadow: var(--shadow-pixel), var(--glow);
}

/* destructive — reserve the single danger red */
.btn-danger, button.danger, .btn.danger, .danger-btn {
  color: var(--danger); border-color: color-mix(in srgb, var(--danger) 62%, #000);
}
.btn-danger:hover, button.danger:hover, .btn.danger:hover, .danger-btn:hover {
  background: var(--danger); color: #120503; border-color: var(--danger);
  box-shadow: var(--shadow-pixel-lg), 0 0 16px rgba(242, 89, 59, .45);
}

.btn-block { display: block; width: 100%; text-align: center; }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-lg { padding: 12px 22px; font-size: 16px; }

/* ============================================================================
   Inputs / selects — inset well, 1px line, green focus. Squared.
   ========================================================================= */
input[type="text"], input[type="password"], input[type="number"],
input[type="search"], input[type="email"], textarea {
  font-family: var(--font-body);
  font-size: 14px;
  padding: 9px 11px;
  background: var(--panel-ink);
  color: var(--text);
  border: var(--bd) solid var(--line);
  border-radius: var(--radius);
  outline: none;
}
input::placeholder, textarea::placeholder { color: var(--muted); }
input[type="text"]:focus, input[type="password"]:focus, input[type="number"]:focus,
input[type="search"]:focus, input[type="email"]:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: var(--glow);
}
input:disabled, textarea:disabled { opacity: .5; cursor: not-allowed; }

/* native select (the .lang-switch keeps its own chevron rule in each page) */
select {
  font-family: var(--font-body);
  background: var(--panel-2); color: var(--text);
  border: var(--bd) solid var(--line); border-radius: var(--radius);
  padding: 8px 10px; cursor: pointer; outline: none;
}
select:focus { border-color: var(--accent); box-shadow: var(--glow); }

/* colour picker swatch */
input[type="color"] {
  border: var(--bd) solid var(--line); border-radius: var(--radius);
  background: var(--panel-ink); padding: 2px; cursor: pointer;
}

/* ---- pixel checkbox ---- */
input[type="checkbox"] {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; margin: 0;
  background: var(--panel-ink);
  border: var(--bd) solid var(--line); border-radius: 0;
  cursor: pointer; position: relative; flex: 0 0 auto;
}
input[type="checkbox"]:hover { border-color: var(--accent-border); }
input[type="checkbox"]:checked { background: var(--accent); border-color: var(--accent); }
input[type="checkbox"]:checked::after {
  content: ""; position: absolute; inset: 3px;
  /* pixel tick, dark ink on green */
  background: var(--ink-on-green);
  clip-path: polygon(0 55%, 30% 55%, 30% 80%, 55% 80%, 55% 55%, 80% 55%, 80% 30%, 100% 30%, 100% 100%, 0 100%);
}
input[type="checkbox"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- pixel range slider ---- */
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  height: 18px; background: transparent; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px; background: var(--line); border: var(--bd) solid var(--panel-ink); border-radius: 0;
}
input[type="range"]::-moz-range-track {
  height: 4px; background: var(--line); border: var(--bd) solid var(--panel-ink); border-radius: 0;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 12px; height: 14px; margin-top: -6px;
  background: var(--accent); border: none; border-radius: 0;
  box-shadow: var(--shadow-pixel);
}
input[type="range"]::-moz-range-thumb {
  width: 12px; height: 14px;
  background: var(--accent); border: none; border-radius: 0;
  box-shadow: var(--shadow-pixel);
}

/* ============================================================================
   Surfaces
   ========================================================================= */
.panel, .card, fieldset {
  background: var(--panel);
  border: var(--bd) solid var(--line);
  border-radius: var(--radius);
}
.card {
  box-shadow: var(--shadow-pixel);
  transition: transform .1s steps(2, end), box-shadow .15s ease, border-color .12s ease;
}
.card:hover {
  transform: translate(-2px, -2px);
  box-shadow: var(--shadow-pixel-lg), var(--glow);
  border-color: var(--accent);
}

/* section eyebrow / label — uppercase pixel tracking */
.eyebrow, .section-label {
  font-family: var(--font-display);
  text-transform: uppercase; letter-spacing: 2px;
  font-size: 11px; font-weight: 700; color: var(--accent);
}

/* pixel icon glyph (inline SVG uses currentColor) */
.mb-ico { display: inline-flex; width: 1em; height: 1em; line-height: 0; vertical-align: -0.12em; }
.mb-ico svg { width: 100%; height: 100%; display: block; image-rendering: pixelated; }

/* state text */
.ok  { color: var(--ok); }
.err { color: var(--danger); }
.warn { color: var(--warn); }
