/* The Card Workshop (js/workshop.js): its own page (workshop.html) or a full-window layer
   over the game (F4). Everything is scoped under .ws so it never touches the game's page. */

.ws {
  --bg: #07081a; --panel: #10142c; --panel2: #161c3a; --line: #2c3658;
  --text: #e8ecff; --dim: #9aa4c8; --accent: #8fb0ff; --gold: #ffd27a; --green: #7aff9a; --red: #ff7080;
  position: fixed; inset: 0; z-index: 50;
  display: grid; grid-template-rows: auto 1fr;
  background: var(--bg); color: var(--text); font: 14px/1.4 system-ui, 'Segoe UI', sans-serif;
}
.ws * { box-sizing: border-box; }
.ws .pixel { font-weight: 600; letter-spacing: 0.3px; } /* headings and tabs: normal text, just bolder (only the cards and sprites are pixel art) */
.ws button, .ws select, .ws input, .ws textarea { font: inherit; color: var(--text); }
.ws button { background: #1e2850; border: 1px solid var(--accent); border-radius: 6px; padding: 5px 12px; cursor: pointer; }
.ws button:hover { background: #2a3a68; }
.ws button:disabled { opacity: 0.4; cursor: default; }
.ws button.quiet { border-color: var(--line); color: var(--dim); }
.ws button.danger { border-color: #a04a5a; color: #ffb0bc; }
.ws button.save { background: #1f4a2c; border-color: var(--green); color: #d8ffe2; }
.ws button.save:hover { background: #2a6a3c; }

.ws header { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.ws header h1 { margin: 0; font-size: 26px; color: var(--gold); font-weight: normal; }
.ws .tabs { display: flex; gap: 6px; }
.ws .tabs button { border-color: var(--line); }
.ws .tabs button.on { background: #2a5a3a; border-color: var(--green); color: #bfffd0; }
.ws .status { margin-left: auto; color: var(--dim); font-size: 13px; text-align: right; }
.ws .status b { color: var(--gold); }
.ws .status b.ok { color: var(--green); }

.ws main { display: grid; grid-template-columns: 1fr 400px; min-height: 0; }
.ws .list { overflow: auto; padding: 12px 16px 40px; }
.ws .editor { overflow-y: auto; background: var(--panel); border-left: 1px solid var(--line); padding: 14px 16px 40px; }

.ws .toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.ws .toolbar input[type=search] { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; width: 180px; }
.ws .chip { border: 1px solid var(--line); background: var(--panel2); border-radius: 12px; padding: 3px 10px; font-size: 12px; cursor: pointer; color: var(--dim); }
.ws .chip.on { border-color: var(--accent); color: var(--text); background: #1e2850; }
.ws label.check { color: var(--dim); font-size: 13px; display: flex; gap: 5px; align-items: center; }

.ws .pile { border: 1px dashed transparent; border-radius: 10px; padding: 6px 8px 10px; margin-bottom: 14px; background: rgba(16, 20, 44, 0.5); }
.ws .pile.drop { border-color: var(--green); background: rgba(40, 90, 58, 0.25); }
.ws .pile h2 { margin: 2px 0; font-size: 18px; font-weight: normal; color: var(--accent); }
.ws .pile .hint { color: var(--dim); font-size: 12px; margin-bottom: 6px; }
.ws .tiles { display: flex; flex-wrap: wrap; gap: 8px; min-height: 70px; }
.ws .tile { position: relative; border-radius: 8px; padding: 2px; cursor: pointer; border: 2px solid transparent; }
.ws .tile.sel { border-color: var(--gold); }
.ws .tile canvas { display: block; }
.ws .tile .edited { position: absolute; top: -4px; right: -4px; background: var(--gold); color: #000; font-size: 10px; border-radius: 8px; padding: 0 5px; }
.ws .tile .count { display: flex; gap: 4px; align-items: center; justify-content: center; margin-top: 3px; }
.ws .tile .count button { padding: 0 6px; font-size: 12px; line-height: 16px; border-radius: 8px; }
.ws .tile .count span { font-weight: bold; min-width: 18px; text-align: center; }

.ws .editor h2 { margin: 0 0 4px; font-size: 22px; font-weight: normal; color: var(--gold); }
.ws .editor h3 { margin: 18px 0 6px; font-size: 15px; font-weight: normal; color: var(--accent); border-bottom: 1px solid var(--line); padding-bottom: 3px; }
.ws .previews { display: flex; gap: 10px; justify-content: center; margin: 8px 0; }
.ws .previews div { text-align: center; color: var(--dim); font-size: 12px; }
.ws table.fields { width: 100%; border-collapse: collapse; }
.ws table.fields th { text-align: left; color: var(--dim); font-weight: normal; font-size: 12px; padding: 2px 4px; }
.ws table.fields td { padding: 2px 4px; }
.ws table.fields td:first-child { color: var(--dim); width: 38%; }
.ws table.fields input, .ws table.fields select, .ws .row input, .ws .row select { width: 100%; background: var(--panel2); border: 1px solid var(--line); border-radius: 5px; padding: 3px 6px; }
.ws .changed { border-color: var(--gold) !important; box-shadow: 0 0 0 1px var(--gold) inset; }
.ws .row { display: grid; grid-template-columns: 38% 1fr; gap: 6px; align-items: center; margin: 4px 0; }
.ws .row > span { color: var(--dim); }
.ws textarea { width: 100%; min-height: 64px; background: var(--panel2); border: 1px solid var(--line); border-radius: 5px; padding: 6px; resize: vertical; }
.ws .small { color: var(--dim); font-size: 12px; }
.ws .keys { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0; }
.ws .keys code { background: var(--panel2); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; cursor: pointer; font-size: 12px; }
.ws .empty { color: var(--dim); text-align: center; margin-top: 80px; }

.ws table.installs { border-collapse: collapse; width: 100%; }
.ws table.installs th { color: var(--dim); font-weight: normal; font-size: 12px; text-align: left; padding: 4px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); }
.ws table.installs td { padding: 4px 3px; border-bottom: 1px solid #1a2040; vertical-align: middle; }
.ws table.installs tr.sel td { background: rgba(255, 210, 122, 0.08); }
.ws table.installs input, .ws table.installs select { width: 42px; background: var(--panel2); border: 1px solid var(--line); border-radius: 4px; padding: 2px 4px; }
.ws table.installs select { width: 72px; padding: 2px 1px; }
.ws table.installs .name { cursor: pointer; color: var(--text); white-space: nowrap; }
.ws table.installs .sub { color: var(--dim); font-size: 11px; }
.ws .pair { display: flex; gap: 3px; }

.ws .modal { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.7); display: none; align-items: center; justify-content: center; }
.ws .modal.open { display: flex; }
.ws .modal .box { background: var(--panel); border: 1px solid var(--accent); border-radius: 10px; padding: 16px; width: min(720px, 92vw); }
.ws .modal textarea { min-height: 320px; font: 12px/1.4 Consolas, monospace; }
.ws .modal .buttons { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }

/* TABLE tab */
.ws table.cards td { vertical-align: top; padding-top: 6px; }
.ws table.cards select { width: 96px; }
.ws .swatch { display: inline-block; width: 6px; height: 30px; border-radius: 3px; }
.ws .nums { display: flex; flex-wrap: wrap; gap: 4px 12px; max-width: 420px; }
.ws .num { display: flex; align-items: center; gap: 3px; }
.ws .num em { font-style: normal; color: var(--dim); font-size: 12px; min-width: 52px; }
.ws .words { color: var(--dim); font-size: 12px; max-width: 280px; }
.ws .stale { background: rgba(255, 179, 71, 0.12); border: 1px solid #b07a2a; color: #ffd27a; border-radius: 6px; padding: 6px 8px; margin: 6px 0; font-size: 12px; }
.ws .warn { color: #ffb347; }
.ws table.installs td:last-child input { width: 52px; } /* shop price: room for 3 digits */
.ws .textHead { display: flex; justify-content: space-between; align-items: center; margin: 8px 0 3px; }
.ws textarea.auto { color: var(--dim); opacity: 0.6; cursor: not-allowed; }

/* PIXEL tab (js/pixelpaint.js) */
.ws .ptools button { padding: 4px 9px; font-size: 13px; }
.ws button.onq { background: #2a5a3a; border-color: var(--green); color: #d8ffe2; }
.ws .sep { width: 1px; align-self: stretch; background: var(--line); margin: 0 4px; }
.ws .pwrap { display: inline-block; padding: 8px; background: #0b0d20; border: 1px solid var(--line); border-radius: 8px; }
.ws .pcanvas { display: block; cursor: crosshair; image-rendering: pixelated; touch-action: none; }
.ws .pframes { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.ws .pframe { border: 2px solid var(--line); border-radius: 6px; padding: 3px; background: #0b0d20; cursor: pointer; text-align: center; font-size: 11px; color: var(--dim); }
.ws .pframe.on { border-color: var(--gold); }
.ws .pframe canvas { display: block; image-rendering: pixelated; }
.ws .pbuttons { display: flex; gap: 8px; margin: 8px 0; }
.ws .library { display: flex; flex-direction: column; gap: 4px; }
.ws .libItem { display: grid; grid-template-columns: 40px 1fr auto; gap: 8px; align-items: center; padding: 3px 6px; border-radius: 6px; cursor: pointer; }
.ws .libItem:hover, .ws .libItem.on { background: var(--panel2); }
.ws .libItem em { color: var(--green); font-style: normal; font-size: 12px; }
.ws .libThumb { width: 40px; height: 32px; display: flex; align-items: center; justify-content: center; background: #0b0d20; border-radius: 4px; }
.ws .libThumb canvas { max-width: 36px; max-height: 28px; image-rendering: pixelated; transform: scale(2); }
.ws .colourRow { display: flex; gap: 8px; align-items: center; }
.ws .colourRow input[type=color] { width: 44px; height: 30px; padding: 0; border: 1px solid var(--line); background: none; }
.ws .bigSwatch { width: 30px; height: 30px; border-radius: 6px; border: 2px solid var(--text); }
.ws .swatches { display: flex; flex-wrap: wrap; gap: 3px; margin: 4px 0 8px; }
.ws .swatchBtn { width: 18px; height: 18px; border-radius: 3px; border: 1px solid rgba(255, 255, 255, 0.15); cursor: pointer; }
.ws .swatchBtn.on { outline: 2px solid var(--gold); outline-offset: 1px; }
.ws .previews canvas { display: block; image-rendering: pixelated; border: 1px solid var(--line); border-radius: 4px; margin: 0 auto 3px; }
.ws .uses { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--dim); }
.ws .uses b { color: var(--text); font-weight: 600; }
.ws .uses button { margin-left: 6px; padding: 0 6px; }
.ws .pframes input { background: var(--panel2); border: 1px solid var(--line); border-radius: 4px; padding: 2px 4px; margin: 0 4px; }

/* SOUNDS tab */
.ws table.sounds td { vertical-align: middle; }
.ws table.sounds .sub { max-width: 230px; }
.ws .variants { display: flex; flex-wrap: wrap; gap: 4px; }
.ws .variant { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.ws .variant button { border: 0; border-radius: 0; padding: 3px 7px; font-size: 12px; }
.ws .variant .play { color: var(--gold); border-right: 1px solid var(--line); }
.ws .variant.on { border-color: var(--green); }
.ws .variant.on .pick { background: #2a5a3a; color: #d8ffe2; }
.ws table.sounds td input.note { width: 100%; margin-top: 5px; padding: 3px 8px; } /* (beats the shop-price rule) */
.ws table.sounds tr.groupRow td { padding: 14px 4px 4px; color: var(--accent); font-weight: 600; font-size: 15px; border-bottom: 1px solid var(--line); }
.ws table.sounds tr.groupRow { cursor: pointer; }
.ws table.sounds tr.groupRow:hover td { color: var(--text); }
.ws table.sounds .groupCount { color: var(--dim); font-weight: normal; font-size: 12px; }
