/* Card Image Editor — admin tool chrome. Loads AFTER the game's styles.css,
   so these rules win on equal specificity. Reuses the neon theme vars. */

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #06060c;
  color: var(--text, #e8ecf6);
  font-family: 'Rajdhani', system-ui, sans-serif;
}
/* Column layout: fixed header + set-meta bars, then the content area fills the rest and
   scrolls internally. Avoids hard-coding chrome heights (which buried the last cards). */
body { display: flex; flex-direction: column; }

.bar {
  display: flex; align-items: center; gap: 18px;
  padding: 10px 18px; flex: 0 0 auto;
  border-bottom: 1px solid rgba(0, 240, 255, .18);
  background: linear-gradient(180deg, rgba(0, 240, 255, .06), transparent);
}
.bar h1 {
  font-family: 'Orbitron', sans-serif; font-size: 16px; letter-spacing: 3px;
  margin: 0; color: #00f0ff; text-shadow: 0 0 12px rgba(0, 240, 255, .5);
}
.bar-stats { display: flex; gap: 14px; font-size: 13px; opacity: .85; }
.bar-stats b { color: #fff; }
.bar-actions { margin-left: auto; display: flex; gap: 14px; align-items: center; }
.setpick { font-size: 11px; letter-spacing: 1.5px; color: #7d8aa5; display: flex; flex-direction: column; gap: 3px; }
/* Header set-picker: label sits BEFORE the combo box, not above it. */
.bar-actions .setpick { flex-direction: row; align-items: center; gap: 8px; }
.setpick select {
  font: inherit; font-size: 14px; letter-spacing: .5px; padding: 5px 8px;
  background: #10121c; color: #e8ecf6; border: 1px solid rgba(0, 240, 255, .3); border-radius: 6px;
}

.layout { display: flex; flex: 1 1 auto; min-height: 0; }

/* ---- film strip ---- */
.strip {
  width: 190px; flex: 0 0 190px; overflow-y: auto; overflow-x: hidden;
  border-right: 1px solid rgba(255, 255, 255, .08); padding: 8px;
  display: flex; flex-direction: column; gap: 6px;
}
.thumb {
  display: flex; align-items: center; gap: 8px; padding: 5px 7px; border-radius: 7px;
  cursor: pointer; border: 1px solid transparent; background: rgba(255, 255, 255, .02);
  text-align: left; color: inherit; font: inherit; width: 100%;
}
.thumb:hover { background: rgba(0, 240, 255, .08); }
.thumb.active { border-color: #00f0ff; background: rgba(0, 240, 255, .12); }
.thumb img { width: 42px; height: 42px; object-fit: cover; border-radius: 4px; flex: 0 0 42px; background: #000; }
.thumb .tn { flex: 1; min-width: 0; }
.thumb .tn b { display: block; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumb .tn small { font-size: 10px; opacity: .6; }
.thumb .dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 9px; background: #3a3f52; }
.thumb .dot.ok { background: #29e08a; box-shadow: 0 0 6px #29e08a; }
.thumb .dot.ko { background: #ff4d6d; box-shadow: 0 0 6px #ff4d6d; }
.thumb .crop-flag { font-size: 11px; color: #ffcf3f; }

/* ---- editor ---- */
.editor { flex: 1; display: flex; flex-direction: column; padding: 14px 20px; min-width: 0; overflow-y: auto; }
.editor-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.editor-title { display: flex; align-items: center; gap: 12px; }
.editor-title #cur-name { font-family: 'Orbitron', sans-serif; font-size: 18px; letter-spacing: 1px; }
.pill { font-size: 11px; letter-spacing: 1px; padding: 2px 9px; border-radius: 20px; text-transform: uppercase;
  border: 1px solid currentColor; }
.pill.dim { color: #7d8aa5; }
.editor-nav { display: flex; gap: 8px; }

.stage { display: flex; gap: 28px; align-items: flex-start; }

.cropwrap { display: flex; flex-direction: column; gap: 8px; }
.cropwin {
  position: relative; overflow: hidden; background: #000; cursor: grab;
  border: 1px solid rgba(0, 240, 255, .35); box-shadow: 0 0 24px rgba(0, 240, 255, .12);
  height: 460px; /* width set by JS from the measured card art ratio */
  touch-action: none; user-select: none;
}
.cropwin:active { cursor: grabbing; }
.cropwin img { position: absolute; top: 0; left: 0; transform-origin: 0 0; will-change: transform; -webkit-user-drag: none; }
.crop-guides { position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(rgba(255, 255, 255, .18) 1px, transparent 1px) 0 33.33% / 100% 33.34%,
    linear-gradient(90deg, rgba(255, 255, 255, .18) 1px, transparent 1px) 33.33% 0 / 33.34% 100%;
  opacity: 0; transition: opacity .15s; }
.cropwin:hover .crop-guides, .cropwin.dragging .crop-guides { opacity: 1; }
.hint { font-size: 11px; color: #7d8aa5; margin: 0; text-align: center; max-width: 320px; }

.preview { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.preview-label { font-size: 11px; letter-spacing: 2px; color: #7d8aa5; }
#card-mount { width: 250px; }
#card-mount .cards-grid { display: block; }
#card-mount .pcard { width: 250px; flex: none; }

/* ---- controls ---- */
.controls { display: flex; flex-wrap: wrap; gap: 24px; margin-top: 18px; align-items: center; }
.ctl-group { display: flex; gap: 10px; align-items: center; }
.btn {
  font: inherit; font-size: 14px; letter-spacing: .5px; font-weight: 700;
  padding: 9px 16px; border-radius: 8px; cursor: pointer; border: 1px solid rgba(255, 255, 255, .18);
  background: #14161f; color: #e8ecf6; transition: all .12s;
}
.btn:hover { transform: translateY(-1px); }
.btn.ghost { background: transparent; }
.btn.ok { border-color: #29e08a; color: #29e08a; }
.btn.ok.active { background: #29e08a; color: #04120a; box-shadow: 0 0 16px rgba(41, 224, 138, .5); }
.btn.ko { border-color: #ff4d6d; color: #ff4d6d; }
.btn.ko.active { background: #ff4d6d; color: #1a0308; box-shadow: 0 0 16px rgba(255, 77, 109, .5); }
.btn.save { border-color: #ffcf3f; color: #ffcf3f; }
.btn.save:hover { background: #ffcf3f; color: #1a1405; }
.ghost { font: inherit; font-size: 13px; padding: 8px 12px; border-radius: 7px; cursor: pointer;
  background: transparent; color: #cfd6e6; border: 1px solid rgba(255, 255, 255, .18); }
.ghost:hover { border-color: #00f0ff; color: #00f0ff; }
.ghost:disabled { opacity: .35; cursor: not-allowed; }
.ghost:disabled:hover { border-color: rgba(255, 255, 255, .18); color: #cfd6e6; }
.zoom { display: flex; align-items: center; gap: 8px; font-size: 11px; letter-spacing: 1.5px; color: #7d8aa5; }
.zoom input { width: 160px; accent-color: #00f0ff; }

/* note field — highlighted when the card is marked broken */
.note-group { flex: 1 1 100%; }
.notefield { display: flex; flex-direction: column; gap: 4px; font-size: 11px; letter-spacing: 1.5px; color: #7d8aa5; width: 100%; }
.notefield textarea {
  font: inherit; font-size: 14px; letter-spacing: .3px; line-height: 1.35; resize: vertical;
  padding: 8px 10px; border-radius: 8px; background: #10121c; color: #e8ecf6;
  border: 1px solid rgba(255, 255, 255, .18); width: 100%; min-height: 40px;
}
.notefield textarea:focus { outline: none; border-color: #00f0ff; }
.note-group.broken .notefield { color: #ff4d6d; }
.note-group.broken .notefield textarea { border-color: rgba(255, 77, 109, .55); background: rgba(255, 77, 109, .06); }
.notefield textarea::placeholder { color: #4b5268; }

.statusline { margin-top: 14px; font-size: 12.5px; color: #7d8aa5; min-height: 18px; }
.statusline b { color: #cfd6e6; }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #10121c; border: 1px solid rgba(0, 240, 255, .4); color: #e8ecf6;
  padding: 10px 18px; border-radius: 9px; font-size: 14px; opacity: 0; pointer-events: none;
  transition: all .2s; box-shadow: 0 6px 30px rgba(0, 0, 0, .6); z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: #ff4d6d; }

/* ---- export completeness modal ---- */
.modal-backdrop { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center;
  justify-content: center; padding: 20px; background: rgba(3, 4, 10, .72); backdrop-filter: blur(4px); }
.modal-backdrop[hidden] { display: none; }
.modal { width: 100%; max-width: 460px; max-height: 84vh; display: flex; flex-direction: column;
  background: #10121c; border: 1px solid rgba(255, 207, 63, .5); border-radius: 12px;
  box-shadow: 0 12px 44px rgba(0, 0, 0, .7); padding: 20px; }
.modal h2 { font-size: 16px; margin: 0 0 10px; color: #ffcf3f; }
.warn-body { overflow: auto; font-size: 13.5px; line-height: 1.5; color: #cfd6e6; }
.warn-body p { margin: 0 0 12px; }
.warn-section { margin-bottom: 14px; }
.warn-section h3 { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: #8b93a7;
  margin: 0 0 6px; }
.warn-section ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 5px; }
.warn-section li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; }
.warn-card-link { color: #00f0ff; text-decoration: none; font-weight: 700; cursor: pointer;
  border-bottom: 1px dashed rgba(0, 240, 255, .5); }
.warn-card-link:hover { color: #7df3ff; border-bottom-color: #7df3ff; }
.warn-missing { color: #ff8098; font-size: 12px; }
.warn-global { color: #ff8098; font-weight: 700; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

/* ============================================================
   Productionized editor additions (CRUD, upload/crop, import/export)
   ============================================================ */
.hidden { display: none !important; }

/* env badge in the title bar */
.env { font-family: 'Rajdhani', sans-serif; font-size: 10px; letter-spacing: 1.5px; font-weight: 700;
  padding: 2px 7px; border-radius: 5px; vertical-align: middle; margin-left: 6px;
  border: 1px solid rgba(255,255,255,.25); color: #9fb0c8; }
.env.local { color: #29e08a; border-color: #29e08a; text-shadow: 0 0 8px rgba(41,224,138,.5); }
.env.static { color: #00f0ff; border-color: rgba(0,240,255,.5); }
/* When not running under the local Node server, hide disk-only controls. */
body:not(.is-local) .local-only { display: none !important; }
.ghost.danger { border-color: rgba(255,77,109,.4); color: #ff8098; }
.ghost.danger:hover { border-color: #ff4d6d; color: #ff4d6d; }

/* set-level meta bar */
.setmeta { display: flex; gap: 16px; align-items: flex-end; padding: 8px 18px; flex: 0 0 auto;
  border-bottom: 1px solid rgba(255,255,255,.07); background: rgba(255,255,255,.015); flex-wrap: wrap; }
.setmeta .field { flex: 0 0 auto; }
.setmeta .field input { width: 200px; }
.setmeta .field.short input { width: 60px; }
.setmeta-uid { margin-left: auto; font-size: 10.5px; color: #5c667e; letter-spacing: .5px;
  font-family: 'Rajdhani', monospace; align-self: center; }

/* generic labelled field (set meta + card fields) */
.field { display: flex; flex-direction: column; gap: 4px; font-size: 10.5px; letter-spacing: 1.4px; color: #7d8aa5; }
.field input, .field textarea, .field select {
  font: inherit; font-size: 14px; letter-spacing: .3px; padding: 7px 9px; border-radius: 7px;
  background: #10121c; color: #e8ecf6; border: 1px solid rgba(255,255,255,.16); }
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: #00f0ff; }
.field textarea { resize: vertical; line-height: 1.35; min-height: 42px; }

/* left column: add-card button above the strip */
.strip-wrap { width: 210px; flex: 0 0 210px; display: flex; flex-direction: column;
  border-right: 1px solid rgba(255,255,255,.08); min-height: 0; }
.strip-wrap .strip { width: auto; flex: 1 1 auto; border-right: none; }
.btn.add { margin: 8px; }
.strip-filter { margin: 0 8px 6px; }
.strip-filter select { width: 100%; }

/* the stage becomes 3 columns: crop | preview | fields */
.stage { flex-wrap: wrap; }
.fields { display: flex; flex-direction: column; gap: 12px; flex: 1 1 280px; min-width: 240px; max-width: 420px; }
.fields .field input, .fields .field textarea, .fields .field select { width: 100%; }

/* crop action row under the crop window */
.crop-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 4px; max-width: 360px; }
.crop-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #4b5268; font-size: 13px; letter-spacing: 1px; text-align: center; padding: 0 20px; pointer-events: none; }
.cropwin.has-img .crop-empty { display: none; }
.btn.add { border-color: #00f0ff; color: #00f0ff; }
.btn.add:hover { background: rgba(0,240,255,.12); }
.thumb-noimg { width: 42px; height: 42px; border-radius: 4px; flex: 0 0 42px; background: #181c28;
  display: flex; align-items: center; justify-content: center; color: #4b5268; font-size: 18px; }
