/* ==========================================================================
   games — landing factory dashboard
   Dark by default, a genuine light variant, zero external requests, no @import.
   Loaded by tools/dashboard.php from /assets/dashboard.css. The page also inlines
   a critical subset (lib/dashboard.php::dashboard_critical_css) so it stays
   readable if this file ever 404s — everything here is an enhancement of that.
   ========================================================================== */

:root {
  /* palette */
  --bg:          #0e1117;
  --bg-soft:     #11151f;
  --surface:     #171b26;
  --surface-2:   #1d2230;
  --surface-3:   #232a3a;
  --line:        #262c3b;
  --line-soft:   #1f2431;
  --text:        #e8ecf5;
  --muted:       #9aa5bb;
  --dim:         #6b7689;
  --accent:      #4f7cff;
  --accent-text: #b9ccff;
  --accent-soft: rgba(79, 124, 255, .15);
  --highlight:   #ffb545;
  --highlight-soft: rgba(255, 181, 69, .14);
  --ok:          #3ddc84;
  --ok-soft:     rgba(61, 220, 132, .14);
  --warn:        #ffb545;
  --warn-soft:   rgba(255, 181, 69, .14);
  --bad:         #ff6b6b;
  --bad-soft:    rgba(255, 107, 107, .14);
  --pulse:       rgba(61, 220, 132, .45);

  /* shape */
  --radius:      14px;
  --radius-sm:   8px;
  --radius-pill: 999px;
  --shadow:      0 1px 2px rgba(0, 0, 0, .40), 0 10px 28px rgba(0, 0, 0, .26);
  --shadow-lift: 0 2px 4px rgba(0, 0, 0, .40), 0 18px 40px rgba(0, 0, 0, .34);
  --ring:        var(--accent);

  /* type */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
          Arial, "Noto Sans", "Liberation Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
          "Liberation Mono", "Courier New", monospace;

  color-scheme: dark light;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg:          #f4f6fb;
    --bg-soft:     #eef1f8;
    --surface:     #ffffff;
    --surface-2:   #f3f5fa;
    --surface-3:   #e8ecf6;
    --line:        #dde2ee;
    --line-soft:   #e7ebf4;
    --text:        #151a24;
    --muted:       #56607a;
    --dim:         #737e96;
    --accent:      #2b56d6;
    --accent-text: #21409c;
    --accent-soft: rgba(43, 86, 214, .10);
    --highlight:   #a8650a;
    --highlight-soft: rgba(168, 101, 10, .12);
    --ok:          #128a4e;
    --ok-soft:     rgba(18, 138, 78, .12);
    --warn:        #a8650a;
    --warn-soft:   rgba(168, 101, 10, .12);
    --bad:         #c4302b;
    --bad-soft:    rgba(196, 48, 43, .12);
    --pulse:       rgba(18, 138, 78, .38);
    --shadow:      0 1px 2px rgba(20, 28, 48, .07), 0 8px 22px rgba(20, 28, 48, .07);
    --shadow-lift: 0 2px 6px rgba(20, 28, 48, .10), 0 16px 36px rgba(20, 28, 48, .12);
  }
}

/* --------------------------------------------------------------- base ---- */

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 { line-height: 1.25; }

a {
  color: var(--accent);
  text-decoration-color: color-mix(in srgb, var(--accent) 42%, transparent);
  text-underline-offset: 3px;
}
a:hover { color: var(--text); text-decoration-color: currentColor; }

code, pre, .mono { font-family: var(--mono); font-size: .92em; }

pre {
  margin: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.wrap {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px;
}

.dim { color: var(--dim); }
.sep { color: var(--line); margin: 0 .35em; }

:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 3px;
  border-radius: 4px;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 20;
}
.skip:focus {
  left: 12px;
  top: 12px;
  padding: 8px 14px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  text-decoration: none;
}

/* ------------------------------------------------------------- header ---- */

.top {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);                                    /* fallback */
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 20px 0 14px;
}

.top-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 20px;
}

.brand {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: .2px;
}
.brand-dim { color: var(--dim); font-weight: 500; }

.totals {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0 2px;
}
.totals strong { color: var(--text); font-variant-numeric: tabular-nums; }
.totals .stat + .sep { margin: 0 .45em; }

#js-running { color: var(--ok); }

.root-host {
  font-family: var(--mono);
  font-size: 12.5px;
  text-decoration: none;
  border-bottom: 1px dashed var(--accent);                       /* fallback */
  border-bottom-color: color-mix(in srgb, var(--accent) 50%, transparent);
}
.root-host:hover { border-bottom-style: solid; }

/* --------------------------------------------------------- cheat sheet ---- */

.cheat {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.cheat > summary {
  cursor: pointer;
  list-style: none;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .10em;
  text-transform: uppercase;
  color: var(--muted);
  user-select: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.cheat > summary::-webkit-details-marker { display: none; }
.cheat > summary::before {
  content: "";
  width: 0; height: 0;
  border-left: 5px solid currentColor;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform .16s ease;
}
.cheat[open] > summary::before { transform: rotate(90deg); }
.cheat > summary:hover { color: var(--text); }

.cheat-list {
  margin: 0;
  padding: 4px 12px 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 2px 24px;
  font-size: 12.5px;
}
.cheat-list dt {
  min-width: 0;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}
.cheat-list dt::-webkit-scrollbar { display: none; }
.cheat-list dt code { color: var(--accent-text); }
.cheat-list dd {
  margin: 0 0 6px;
  color: var(--dim);
}

@media (min-width: 760px) {
  .cheat-list {
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
  }
  .cheat-list dt { grid-column: auto; }
}

/* ---------------------------------------------------------------- grid ---- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  padding: 24px 0 8px;
  align-items: start;
}

/* ---------------------------------------------------------------- card ---- */

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 16px 16px;
  box-shadow: var(--shadow);
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
  overflow: hidden;
}
.card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--line);
  transition: background .16s ease;
}
.card.status-draft::before    { background: var(--dim); }
.card.status-dev::before      { background: var(--accent); }
.card.status-ready::before    { background: var(--ok); }
.card.status-exported::before { background: var(--highlight); }

.card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  box-shadow: var(--shadow-lift);
}
.card:focus-within {
  border-color: color-mix(in srgb, var(--accent) 60%, var(--line));
}

.card-top {
  display: flex;
  align-items: center;
  gap: 9px;
}

.card-title {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-slug {
  margin: 2px 0 0 18px;
  font-size: 12px;
}
.card-slug code {
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  padding: 1px 6px;
}

.card-url {
  display: block;
  margin: 12px 0 0;
  padding: 9px 11px;
  background: var(--accent-soft);
  border: 1px solid var(--line);                                 /* fallback */
  border-color: color-mix(in srgb, var(--accent) 28%, transparent);
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
  color: var(--accent-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: background .16s ease, border-color .16s ease, color .16s ease;
}
.card-url:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.card-url .scheme { opacity: .55; }

/* ----------------------------------------------------------- meta rows ---- */

.meta {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 5px 12px;
  margin: 13px 0 0;
  font-size: 12.5px;
  align-items: baseline;
}
.meta dt {
  color: var(--dim);
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
  white-space: nowrap;
}
.meta dd {
  margin: 0;
  min-width: 0;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
}
.meta dd code {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.meta time { color: var(--muted); }

/* ------------------------------------------------------- running state ---- */

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  flex: none;
  border-radius: 50%;
  background: #4a5266;
  box-shadow: 0 0 0 0 transparent;
}
.dot.is-running {
  background: var(--ok);
  animation: dot-pulse 2.4s cubic-bezier(.4, 0, .2, 1) infinite;
}

@media (prefers-color-scheme: light) {
  .dot { background: #b3bccd; }
}

@keyframes dot-pulse {
  0%   { box-shadow: 0 0 0 0 var(--pulse); }
  70%  { box-shadow: 0 0 0 7px rgba(61, 220, 132, 0); }
  100% { box-shadow: 0 0 0 0 rgba(61, 220, 132, 0); }
}

.card.is-running [data-live-label] { color: var(--ok); font-weight: 600; }

/* -------------------------------------------------------------- badges ---- */

.badge {
  display: inline-block;
  flex: none;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: .02em;
  white-space: nowrap;
}
.badge-draft {
  color: var(--muted);
  border-color: var(--line);
  background: var(--surface-2);
}
.badge-dev {
  color: var(--accent-text);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  background: var(--accent-soft);
}
.badge-ready {
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 45%, transparent);
  background: var(--ok-soft);
}
.badge-exported {
  color: var(--highlight);
  border-color: color-mix(in srgb, var(--highlight) 45%, transparent);
  background: var(--highlight-soft);
}
.badge-other { color: var(--dim); }

.badge.score { font-variant-numeric: tabular-nums; }
.score-good {
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 45%, transparent);
  background: var(--ok-soft);
}
.score-ok {
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 45%, transparent);
  background: var(--warn-soft);
}
.score-bad {
  color: var(--bad);
  border-color: color-mix(in srgb, var(--bad) 45%, transparent);
  background: var(--bad-soft);
}

/* --------------------------------------------------------------- chips ---- */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0 0;
}
.chip {
  display: inline-block;
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--dim);
  font-family: var(--mono);
  font-size: 11px;
  white-space: nowrap;
}
.chip-dist {
  color: var(--accent-text);
  border-color: color-mix(in srgb, var(--accent) 32%, transparent);
}
.chip-warn {
  color: var(--bad);
  border-color: color-mix(in srgb, var(--bad) 40%, transparent);
  background: var(--bad-soft);
}
.chip-port { color: var(--muted); }

/* --------------------------------------------------------- empty state ---- */

.empty {
  max-width: 620px;
  margin: 0 auto;
  padding: 72px 0 56px;
  text-align: center;
}
.empty h2 {
  margin: 0 0 8px;
  font-size: 22px;
}
.empty p { margin: 0 0 16px; }
.empty .cmd { margin: 0 0 18px; }

.cmd {
  display: block;
  padding: 13px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  text-align: left;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  box-shadow: var(--shadow);
}
.cmd code { color: inherit; font-size: 13px; }

/* ---------------------------------------------------------- error page ---- */

.page-error {
  max-width: 640px;
  padding-top: 84px;
  padding-bottom: 64px;
  text-align: center;
}
.error-code {
  margin: 0;
  font-family: var(--mono);
  font-size: 56px;
  font-weight: 700;
  line-height: 1;
  color: var(--accent);
  opacity: .85;
}
.page-error h1 { margin: 10px 0 6px; font-size: 22px; }
.page-error .detail {
  margin: 18px 0;
  text-align: left;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
  color: var(--muted);
  border-left-color: var(--bad);
}

.btn {
  display: inline-block;
  margin-top: 18px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);                                 /* fallback */
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  transition: background .16s ease, color .16s ease;
}
.btn:hover { background: var(--accent); color: #fff; }

/* -------------------------------------------------------------- footer ---- */

.foot {
  padding-top: 20px;
  padding-bottom: 36px;
  color: var(--dim);
  font-size: 12px;
  border-top: 1px solid var(--line-soft);
  margin-top: 24px;
}
.foot p { margin: 0; }
.foot code { color: var(--muted); }

/* ------------------------------------------------------------ responsive -- */

@media (max-width: 560px) {
  .wrap { padding: 0 14px; }
  .top { position: static; padding-top: 16px; }
  .top-row { align-items: flex-start; flex-direction: column; }
  .grid { grid-template-columns: 1fr; gap: 12px; padding-top: 18px; }
  .cheat-list { grid-template-columns: 1fr; }
  .empty { padding-top: 44px; }
  .error-code { font-size: 44px; }
}

/* -------------------------------------------------------- reduced motion -- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .dot.is-running {
    animation: none !important;
    box-shadow: 0 0 0 3px rgba(61, 220, 132, .24);
  }
  .card:hover { transform: none; }
}
