/*
 * Sober and dark, in the colours of the mod: the blue of the left band of every intro, the
 * near-black of their backdrop. Nothing here is borrowed from Cobblemon's own assets.
 */

:root {
  --bg: #0b0e17;
  --panel: #141926;
  --panel-2: #1a2032;
  --line: #242c42;
  --line-soft: #1d2438;
  --text: #dce3f2;
  --muted: #8a97be;
  --blue: #2f6fbf;
  --blue-bright: #4c8bf5;
  --red: #bf3a3a;
  --amber: #d9a441;
  --cream: #fff0c0;
  --radius: 10px;
  color-scheme: dark;
}

.category-picker { display: flex; flex-direction: column; gap: 4px; }
.category-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 16px; margin-top: 20px; }
.category-card { background: var(--panel); border: 1px solid var(--line); border-top: 3px solid var(--blue-bright); border-radius: var(--radius); padding: 18px; min-width: 0; }
.category-card h3 { font-size: 18px; overflow-wrap: anywhere; }
.category-members { display: grid; gap: 8px; margin-top: 16px; }
.category-member { display: flex; flex-direction: column; gap: 4px; text-align: left; padding: 12px; background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; cursor: pointer; overflow-wrap: anywhere; }
.category-member:hover, .category-member:focus-visible { border-color: var(--blue-bright); }

* { box-sizing: border-box; }
/* A row the stage hides is `display: flex` from .row, which outranks the default. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1, h2, h3, h4 { margin: 0 0 6px; font-weight: 600; line-height: 1.25; }
h1 { font-size: 17px; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
h3 { font-size: 14px; }
p { margin: 0 0 8px; }
a { color: var(--blue-bright); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.error-text { color: #ff9a9a; }

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

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 20px;
  background: linear-gradient(180deg, #121828, #0d1120);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}

.brand { display: flex; align-items: center; gap: 14px; }

/* The mod's own logo, drawn pixel for pixel - it is pixel art, and smoothing muddies it. */
.brand-logo { display: block; line-height: 0; }
.brand-logo img {
  width: auto; height: 40px;
  image-rendering: pixelated;
  border-radius: 4px;
}
.brand-logo:hover img { filter: brightness(1.12); }

.top-links { display: flex; align-items: center; gap: 16px; font-size: 13px; }

.lang { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.lang-btn {
  background: transparent; border: 0; color: var(--muted);
  padding: 5px 10px; font: inherit; font-size: 12px; cursor: pointer;
}
.lang-btn.on { background: var(--blue); color: #fff; }

/* ---- shell -------------------------------------------------------------- */

.shell {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
  align-items: start;
}

.side { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 90px; }

.side-block {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.side-block > .btn { margin-bottom: 8px; }

.work { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

.editor {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: 420px;
}

/* ---- file list ---------------------------------------------------------- */

.files { display: flex; flex-direction: column; gap: 2px; margin-top: 10px; }

.files-head {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); margin: 10px 0 2px;
}

.file {
  display: flex; align-items: center; gap: 4px;
  width: 100%; text-align: left;
  background: transparent; border: 1px solid transparent; border-radius: 7px;
  color: var(--text); font: inherit; font-size: 13px;
  padding: 6px 8px; cursor: pointer;
}
.file:hover { background: var(--panel-2); }
.file-on { background: var(--panel-2); border-color: var(--blue); }
.file-folder { color: var(--muted); }
.file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.dot {
  margin-left: auto;
  min-width: 18px; height: 18px; padding: 0 5px;
  display: inline-grid; place-items: center;
  border-radius: 9px; font-size: 11px; font-weight: 600;
}
.dot-error { background: var(--red); color: #fff; }
.dot-warn { background: var(--amber); color: #241a06; }

/* ---- editor head -------------------------------------------------------- */

.editor-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.editor-id { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1 1 240px; }
.editor-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.editor-ref {
  max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
@media (max-width: 1000px) { .editor-ref { display: none; } }

.badge {
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  padding: 3px 8px; border-radius: 20px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
}
.badge-trainer { border-color: var(--blue); color: #9fc2ff; }
.badge-intro { border-color: var(--red); color: #ff9f9f; }
.badge-category { border-color: var(--amber); color: #f0cf8d; }
.badge-advancement { border-color: #5a8f63; color: #a5d8ad; }

.input-path { max-width: 320px; font-family: ui-monospace, Menlo, Consolas, monospace; }
/* The category menu sits in the header beside the path, and must not crowd it out. */
.editor-id .input-menu { flex: 0 1 auto; width: auto; max-width: 200px; }

/* ---- tabs --------------------------------------------------------------- */

.tabs { display: flex; gap: 4px; padding: 10px 16px 0; border-bottom: 1px solid var(--line); }

.tab {
  background: transparent; border: 1px solid transparent; border-bottom: none;
  border-radius: 8px 8px 0 0;
  color: var(--muted); font: inherit; font-size: 13px;
  padding: 7px 14px; cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab-on { background: var(--panel-2); border-color: var(--line); color: var(--text); }

.editor-body { padding: 16px; }

.columns { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 18px; }
.columns-intro { grid-template-columns: minmax(0, 1fr) minmax(360px, 46%); }
.column { min-width: 0; }
.column-preview, .column-side { position: sticky; top: 102px; align-self: start; }

/* ---- fields ------------------------------------------------------------- */

.fields { display: flex; flex-direction: column; gap: 12px; }

.field { display: block; }
.field-head { display: flex; align-items: center; gap: 6px; }
.field-label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field-hint { font-size: 11.5px; color: var(--muted); margin: 4px 0 0; }

.field-doc {
  width: 15px; height: 15px; border-radius: 50%;
  display: inline-grid; place-items: center;
  border: 1px solid var(--line); color: var(--muted);
  font-size: 10px; margin-bottom: 4px; text-decoration: none;
}
.field-doc:hover { border-color: var(--blue); color: var(--blue-bright); text-decoration: none; }

.input {
  width: 100%;
  background: #0f1422;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  font: inherit;
  padding: 7px 9px;
}
.input:focus { outline: none; border-color: var(--blue); }
.input:disabled { opacity: .45; }
textarea.input { resize: vertical; }
.input-num { width: 100px; }
.input-hex { width: 110px; font-family: ui-monospace, Menlo, Consolas, monospace; }
.input-color { width: 34px; height: 34px; padding: 0; border: 1px solid var(--line); border-radius: 7px; background: #0f1422; }

.row { display: flex; align-items: center; gap: 8px; }
.row-wrap { flex-wrap: wrap; }
.row-end { justify-content: flex-end; }

.mini { display: flex; align-items: center; gap: 6px; }
.mini-label { font-size: 11px; color: var(--muted); min-width: 30px; }

.area { display: flex; flex-direction: column; gap: 6px; }

.switch { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-mark {
  width: 34px; height: 19px; border-radius: 19px;
  background: #0f1422; border: 1px solid var(--line); position: relative; transition: .15s;
}
.switch-mark::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 13px; height: 13px; border-radius: 50%; background: var(--muted); transition: .15s;
}
.switch input:checked + .switch-mark { background: rgba(47, 111, 191, .35); border-color: var(--blue); }
.switch input:checked + .switch-mark::after { left: 17px; background: var(--blue-bright); }
.switch-text { font-size: 12px; color: var(--muted); }
.switch-inline { white-space: nowrap; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); border-radius: 20px; padding: 4px 11px;
  font-size: 12.5px; cursor: pointer;
}
.tag:has(input:checked) { border-color: var(--blue); background: rgba(47, 111, 191, .18); }

.list { display: flex; flex-direction: column; gap: 8px; }

.group {
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  background: #111624;
  padding: 0 12px 12px;
}
.group[open] { padding-bottom: 14px; }
.group-head { cursor: pointer; padding: 10px 0; display: flex; align-items: center; gap: 8px; }
.group-title { font-size: 13px; font-weight: 600; }
.group-hint { margin-top: -4px; margin-bottom: 10px; }
summary::-webkit-details-marker { display: none; }
summary { list-style: none; }
.group-head::before, .card-head.summary-mark::before { content: '▸'; color: var(--muted); font-size: 11px; }
.group[open] > .group-head::before { content: '▾'; }

/* ---- cards -------------------------------------------------------------- */

.card {
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  background: #111624;
  padding: 10px 12px;
  margin-bottom: 10px;
}
.card-inline { margin-bottom: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.card-title { font-size: 12.5px; color: var(--muted); }
.layer > .card-head { cursor: pointer; margin-bottom: 0; }
.layer[open] > .card-head { margin-bottom: 10px; }

.side-card {
  border: 1px solid var(--line-soft); border-radius: 9px; background: #111624;
  padding: 12px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start;
  margin-bottom: 12px;
}
.chip {
  font-size: 12px; padding: 2px 8px; border-radius: 14px;
  background: var(--panel-2); border: 1px solid var(--line);
}

/* ---- buttons ------------------------------------------------------------ */

.btn {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  padding: 7px 12px;
  cursor: pointer;
}
.btn:hover { border-color: var(--blue); }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-bright); }
.btn-ghost { background: transparent; }
.btn-small { padding: 5px 10px; font-size: 12.5px; }
.btn-mini { padding: 2px 7px; font-size: 12px; line-height: 1.2; }
.btn-wide { width: 100%; }
.btn-danger:hover { border-color: var(--red); color: #ff9f9f; }

.add-row { margin-bottom: 8px; }

/* ---- team, json --------------------------------------------------------- */

.team-area { font-size: 12.5px; line-height: 1.45; }
.json-area { width: 100%; height: 60vh; font-size: 12.5px; line-height: 1.5; }
.json { display: flex; flex-direction: column; gap: 10px; }

.skin-card {
  border: 1px solid var(--line-soft); border-radius: 9px; background: #0f1422;
  padding: 12px; display: flex; flex-direction: column; align-items: center; gap: 6px;
  margin-bottom: 12px;
}
.skin-card.drop { border-color: var(--blue); }
.skin-canvas { image-rendering: pixelated; }

/* ---- preview ------------------------------------------------------------ */

.preview { display: flex; flex-direction: column; gap: 8px; }

.preview-canvas {
  width: 100%; height: auto; aspect-ratio: 16 / 9;
  background: #05060d;
  border: 1px solid var(--line);
  border-radius: 9px;
  image-rendering: pixelated;
}

.preview-bar { display: flex; align-items: center; gap: 8px; }
.preview-skins { gap: 12px; }
.preview-skins .input { min-width: 0; }
.slider { flex: 1; accent-color: var(--blue-bright); }

/* ---- the stage ---------------------------------------------------------- */

/*
 * Two canvases, stacked. The scene keeps `image-rendering: pixelated` because it is the game's
 * own 640 x 360 blown up; the overlay on top is drawn at twice that and smoothed, so a
 * selection box is a hairline rather than four fat pixels.
 */
/*
 * The frame is on the holder, not on the scene canvas. `inset: 0` puts the overlay on the
 * padding box, and so does a canvas at `width: 100%`: the two agree to the pixel only if
 * neither carries a border of its own - one pixel of disagreement is one pixel of drift
 * between what is drawn and what is grabbed.
 */
.stage {
  position: relative; line-height: 0;
  border: 1px solid var(--line); border-radius: 9px; overflow: hidden;
}
.stage .preview-canvas { display: block; border: none; border-radius: 0; }

.stage-overlay {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  touch-action: none;
}
.stage-overlay:focus-visible { outline: 2px solid var(--blue-bright); outline-offset: 2px; }
/* The animation is watched, not edited: nothing under the pointer pretends otherwise. */
.stage-play .stage-overlay { cursor: default; }

.stage-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.stage-toggles { gap: 12px; }
.stage-toggles .check { border: none; padding: 0; font-size: 12px; color: var(--muted); }
.stage-hint { margin: 0; }
.stage-clock { min-width: 26px; text-align: right; }
.stage-skins { display: flex; flex-direction: column; gap: 4px; }
.stage-skins p { margin: 0; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg-btn {
  background: transparent; border: none; border-right: 1px solid var(--line);
  color: var(--muted); font: inherit; font-size: 12.5px;
  padding: 5px 12px; cursor: pointer;
}
.seg-btn:last-child { border-right: none; }
.seg-btn:hover { color: var(--text); }
.seg-on { background: var(--panel-2); color: var(--text); }

/* The nine anchors as they sit on the screen, so the pad is a picture of the answer. */
.pad { display: grid; grid-template-columns: repeat(3, 22px); gap: 3px; }
.pad-dot {
  height: 22px; border: 1px solid var(--line); border-radius: 5px;
  background: #0f1422; cursor: pointer; padding: 0;
}
.pad-dot::after {
  content: ''; display: block; width: 4px; height: 4px; margin: auto;
  border-radius: 50%; background: var(--muted);
}
.pad-dot:hover { border-color: var(--blue); }
.pad-on { border-color: var(--blue-bright); background: #16233c; }
.pad-on::after { background: var(--blue-bright); }

/* ---- layer cards -------------------------------------------------------- */

/*
 * The cards scroll here, not on the page: the stage and the timeline are sticky beside them,
 * and the point of that is defeated the moment choosing a layer scrolls the document.
 * `overscroll-behavior` stops a flick at either end from carrying on into the page.
 */
.layer-list {
  max-height: calc(100vh - 300px); min-height: 220px;
  overflow-y: auto; overscroll-behavior: contain;
  padding-right: 4px;
}

.layer-on { border-color: var(--blue); box-shadow: 0 0 0 1px rgba(76, 139, 245, 0.35); }
.layer-at { font-size: 11.5px; margin-left: auto; }
.layer > .card-head .row { flex: none; }
.layer-body { display: flex; flex-direction: column; gap: 10px; }
.layer-part {
  margin: 4px 0 0; font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .07em;
  border-top: 1px solid var(--line-soft); padding-top: 8px;
}
.layer-body > .layer-part:first-child { border-top: none; padding-top: 0; }

/* ---- the timeline ------------------------------------------------------- */

.timeline {
  border: 1px solid var(--line-soft); border-radius: 9px; background: #111624;
  padding: 10px 12px; margin-top: 12px;
}
.timeline-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.timeline-head h4 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.timeline-body { display: flex; flex-direction: column; gap: 3px; max-height: 200px; overflow-y: auto; }

.timeline-row { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 8px; align-items: center; }
.timeline-name {
  background: transparent; border: none; padding: 2px 0; text-align: left;
  color: var(--muted); font: inherit; font-size: 11.5px; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.timeline-name:hover { color: var(--text); }
.timeline-on .timeline-name { color: var(--text); }
.timeline-off { opacity: .45; }

.timeline-track {
  position: relative; height: 16px;
  background: #0f1422; border: 1px solid var(--line); border-radius: 5px;
  touch-action: none;
}
.timeline-ruler .timeline-track { height: 12px; cursor: pointer; background: #0c1120; }
.timeline-mark { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--line); }

.timeline-bar {
  position: absolute; top: 1px; bottom: 1px; min-width: 6px;
  background: rgba(47, 111, 191, 0.55); border: 1px solid var(--blue);
  border-radius: 4px; cursor: grab; touch-action: none;
}
.timeline-bar:active { cursor: grabbing; }
.timeline-on .timeline-bar { background: rgba(76, 139, 245, 0.7); border-color: var(--blue-bright); }
.timeline-grip {
  position: absolute; top: -1px; bottom: -1px; right: -3px; width: 7px;
  cursor: ew-resize; border-radius: 0 4px 4px 0;
}
.timeline-grip:hover { background: var(--blue-bright); }

.timeline-body { position: relative; }
.timeline-sweep { position: absolute; left: 128px; right: 0; top: 0; bottom: 0; pointer-events: none; }
.timeline-playhead {
  position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px;
  background: var(--amber); opacity: .8;
}

/* ---- assets and translations -------------------------------------------- */

.assets-block {
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  background: #111624;
  padding: 12px;
  margin-bottom: 12px;
}
.assets-block .card-head { margin-bottom: 4px; }

.asset {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0; border-top: 1px solid var(--line-soft);
}
.asset .input-path { max-width: 180px; }
.asset .input { max-width: 240px; }

.asset-ref {
  background: #0f1422; border: 1px solid var(--line); border-radius: 6px;
  color: var(--muted); font-size: 11.5px; padding: 4px 8px; cursor: pointer;
  max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.asset-ref:hover { border-color: var(--blue); color: var(--blue-bright); }

.asset-thumb {
  width: 48px; height: 48px; image-rendering: pixelated;
  background: #0f1422; border: 1px solid var(--line); border-radius: 6px;
}

/* The menu of what the pack holds, the field, and the button that fills it - one line. */
.row-pick { gap: 6px; }
.row-pick .input { flex: 1; min-width: 0; }
.row-pick .btn { flex: none; }
.row-pick .input-menu { flex: 0 1 auto; width: auto; max-width: 45%; }
.row-pick .input-menu:disabled { opacity: .5; }

/* It is a button, so it answers a click as well as a drag - and looks the same either way. */
.drop-zone {
  display: block; width: 100%;
  margin-top: 10px; padding: 12px; text-align: center;
  background: transparent;
  border: 1px dashed var(--line); border-radius: 8px;
  color: var(--muted); font: inherit; font-size: 12px;
  cursor: pointer;
}
.drop-zone:hover { border-color: var(--blue); color: var(--blue-bright); }
.drop-zone.drop { border-color: var(--blue); color: var(--blue-bright); }

.dot-quiet { background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }

.lang-table { display: flex; flex-direction: column; margin-top: 12px; }

.lang-row {
  display: grid;
  grid-template-columns: minmax(160px, 260px) repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px; align-items: center;
  padding: 5px 0; border-top: 1px solid var(--line-soft);
}
.lang-head { border-top: none; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .07em; }
.lang-key { overflow: hidden; text-overflow: ellipsis; }

/* ---- checks ------------------------------------------------------------- */

.checks {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
  max-height: 34vh;
  overflow: auto;
}

.checks-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }

.check {
  display: flex; gap: 8px; align-items: flex-start;
  padding: 6px 0; border-top: 1px solid var(--line-soft); font-size: 13px;
}
.check-mark {
  flex: none; width: 18px; height: 18px; border-radius: 50%;
  display: grid; place-items: center; font-size: 11px; font-weight: 700; margin-top: 1px;
}
.check-error .check-mark { background: var(--red); color: #fff; }
.check-warn .check-mark { background: var(--amber); color: #241a06; }
.check-info .check-mark { background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }

.empty { padding: 60px 20px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.empty .row { justify-content: center; }

@media (max-width: 1100px) {
  .columns, .columns-intro { grid-template-columns: minmax(0, 1fr); }
  .column-preview, .column-side { position: static; }
}

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; }
}
