/* editor.css — komponenty warsztatu figur i gier.
   UZUPEŁNIA /css/style.css — używa tych samych tokenów HSL var(--...). */

/* ── zakładki ── */
.ed-tabs { display: flex; gap: 6px; padding: 2px 0 0; }
.ed-tab {
  background: transparent; color: hsl(var(--ink-dim));
  border: 1px solid hsl(var(--line)); border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 10px 20px; font-family: var(--font-display); font-size: 15px; letter-spacing: .04em;
  cursor: pointer; transform: translateY(1px);
}
.ed-tab:hover { color: hsl(var(--ink)); border-color: hsl(var(--brass-dim)); }
.ed-tab.active {
  color: hsl(var(--brass)); background: hsl(var(--bg-raise));
  border-color: hsl(var(--line)); border-bottom: 1px solid hsl(var(--bg-raise));
}

.ed-panel { margin: 30px 0; }

/* ── powiadomienie o zapleczu ── */
.server-notice {
  max-width: 1180px; margin: 14px auto 0; padding: 0 20px;
}
.server-notice > .inner {
  background: hsl(var(--wine) / .12); border: 1px solid hsl(var(--wine) / .5);
  color: hsl(355 60% 78%); border-radius: var(--radius); padding: 10px 16px; font-size: 14px;
}

/* ═══════════ FIGURY ═══════════ */

/* lista figur */
.piece-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px;
  margin-bottom: 18px;
}
.piece-list .empty { grid-column: 1/-1; color: hsl(var(--ink-dim)); font-style: italic; padding: 18px 4px; }
.piece-card {
  position: relative; display: flex; flex-direction: column;
  background: hsl(var(--bg-raise)); border: 1px solid hsl(var(--line)); border-radius: var(--radius);
  overflow: hidden; transition: border-color .14s, transform .14s;
}
.piece-card:hover { border-color: hsl(var(--brass-dim)); transform: translateY(-2px); }
.piece-card.selected { border-color: hsl(var(--brass)); box-shadow: 0 0 0 1px hsl(var(--brass) / .5); }
.piece-card .pc-thumb {
  aspect-ratio: 1; background: hsl(var(--bg-raise2)); display: flex; align-items: center; justify-content: center;
  position: relative;
}
.piece-card .pc-thumb img { width: 100%; height: 100%; object-fit: contain; }
.piece-card .pc-silhouette { font-size: 54px; color: hsl(var(--ink-dim) / .5); position: relative; }
.piece-card .pc-silhouette .q {
  position: absolute; right: -6px; bottom: 2px; font-size: 20px; color: hsl(var(--brass-dim));
  font-family: var(--font-display);
}
.piece-card .pc-body { padding: 8px 10px 10px; }
.piece-card .pc-name { font-family: var(--font-display); font-size: 14.5px; }
.piece-card .pc-meta { color: hsl(var(--ink-dim)); font-size: 12px; margin-top: 2px; }
.piece-card .pc-badges { display: flex; gap: 5px; margin-top: 7px; }
.piece-card .pc-actions { display: flex; gap: 6px; padding: 0 10px 10px; }
.piece-card .pc-actions .btn { flex: 1; }

.badge {
  font-size: 10.5px; padding: 2px 7px; border-radius: 999px; letter-spacing: .04em;
  border: 1px solid hsl(var(--line)); color: hsl(var(--ink-dim));
}
.badge.ready { color: hsl(140 45% 68%); border-color: hsl(140 35% 40%); background: hsl(140 40% 30% / .18); }
.badge.generating { color: hsl(var(--brass)); border-color: hsl(var(--brass-dim)); background: hsl(var(--brass) / .12); }

/* edytor figury: dwie kolumny */
.piece-editor {
  display: grid; grid-template-columns: minmax(280px, 1fr) auto; gap: 26px; padding: 22px;
  align-items: start;
}
.pe-form h3, .pe-designer h3, .ge-form h3 { color: hsl(var(--brass)); font-size: 17px; margin: 0 0 14px; }
.field-row { display: flex; gap: 14px; }
.field-row .field { margin: 12px 0; }
.field-abbrev { width: 110px; flex: none; }
.field-value { flex: 1; }
.field input[type=range] { accent-color: hsl(var(--brass)); width: 100%; padding: 0; }
.field-check label { display: flex; align-items: center; gap: 8px; color: hsl(var(--ink)); cursor: pointer; }
.field-check input { width: auto; accent-color: hsl(var(--brass)); }
#pf-abbrev { text-transform: uppercase; text-align: center; font-weight: 700; }

.pe-actions { display: flex; gap: 10px; margin: 8px 0 4px; }

/* generacja grafiki */
.pe-gen {
  display: flex; gap: 14px; margin-top: 18px; padding-top: 16px;
  border-top: 1px solid hsl(var(--line)); align-items: center;
}
.gen-slot {
  width: 108px; height: 108px; flex: none; border-radius: var(--radius);
  background: hsl(var(--bg-raise2)); border: 1px solid hsl(var(--line));
  display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative;
}
.gen-slot img { width: 100%; height: 100%; object-fit: contain; }
.gen-silhouette { font-size: 54px; color: hsl(var(--ink-dim) / .45); position: relative; }
.gen-silhouette .gen-q {
  position: absolute; right: -8px; bottom: 4px; font-size: 22px; color: hsl(var(--brass-dim));
  font-family: var(--font-display);
}
.gen-side { flex: 1; min-width: 0; }
.gen-buttons { display: flex; flex-direction: column; gap: 8px; }
.gen-status { color: hsl(var(--ink-dim)); font-size: 13px; margin-top: 10px; line-height: 1.45; }
.gen-status.err { color: hsl(355 70% 74%); }
.gen-status.busy { color: hsl(var(--brass)); }

.spinner {
  display: inline-block; width: 15px; height: 15px; vertical-align: -3px; margin-right: 7px;
  border: 2px solid hsl(var(--brass) / .3); border-top-color: hsl(var(--brass));
  border-radius: 50%; animation: spin .8s linear infinite;
}
.gen-slot .spinner { width: 34px; height: 34px; border-width: 3px; margin: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── projektant ruchów ── */
.pe-designer { min-width: 0; }
.md-modes { max-width: 340px; }
.md-help { color: hsl(var(--ink-dim)); font-size: 12.5px; margin: 8px 0 12px; min-height: 16px; }

.md-grid {
  --n: 11;
  display: grid; grid-template-columns: repeat(var(--n), 1fr);
  width: min(352px, 78vw); aspect-ratio: 1; gap: 2px;
  background: hsl(var(--line)); border: 1px solid hsl(var(--line)); border-radius: 6px; padding: 2px;
}
.md-cell {
  position: relative; aspect-ratio: 1; cursor: pointer; border-radius: 2px;
  background: hsl(var(--bg-raise2));
  display: flex; align-items: center; justify-content: center;
  transition: background .1s;
}
.md-cell.alt { background: hsl(158 12% 15%); }
.md-cell:hover { outline: 1px solid hsl(var(--brass-dim)); outline-offset: -1px; }
.md-cell.ride { background: hsl(var(--felt)); }
.md-cell.leap { background: hsl(var(--brass) / .30); }
.md-cell.leap::after {
  content: ''; width: 42%; height: 42%; border-radius: 50%;
  background: hsl(var(--brass)); box-shadow: 0 0 6px hsl(var(--brass) / .7);
}
.md-cell.center {
  background: hsl(var(--bg-raise)); cursor: default; outline: 1px solid hsl(var(--brass));
  outline-offset: -1px; color: hsl(var(--brass)); font-size: 15px; font-weight: 700;
}
.md-cell.center:hover { outline: 1px solid hsl(var(--brass)); }
.md-cell.center .cc-glyph { font-family: var(--font-display); }

.md-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; margin-top: 14px; max-width: 360px; }
.md-controls .field { margin: 0; }
.md-controls .field:last-child { grid-column: 1/-1; }
.md-tools { display: flex; gap: 8px; margin-top: 12px; }
.md-preview {
  margin-top: 14px; padding: 10px 14px; border-radius: 8px; max-width: 360px;
  background: hsl(var(--bg-raise2)); border: 1px solid hsl(var(--line));
  color: hsl(var(--ink)); font-size: 13.5px; line-height: 1.5;
}
.md-preview .lbl { color: hsl(var(--ink-dim)); }

/* ═══════════ GRY ═══════════ */
.game-editor {
  display: grid; grid-template-columns: minmax(280px, 380px) 1fr; gap: 26px; padding: 22px;
  align-items: start;
}
.ge-form .field { margin: 12px 0; }

.palette {
  margin: 16px 0 4px; padding: 14px; border: 1px solid hsl(var(--line)); border-radius: var(--radius);
  background: hsl(var(--bg-raise2) / .5);
}
.pal-head { font-family: var(--font-display); color: hsl(var(--brass)); font-size: 14px; margin-bottom: 10px; letter-spacing: .04em; }
.pal-side { margin-bottom: 12px; }
.pal-pieces { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 6px; }
.pal-piece {
  aspect-ratio: 1; border: 1px solid hsl(var(--line)); border-radius: 8px; cursor: pointer;
  background: hsl(var(--bg-raise)); display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden; transition: border-color .12s, transform .1s;
}
.pal-piece:hover { border-color: hsl(var(--brass-dim)); }
.pal-piece.active { border-color: hsl(var(--brass)); box-shadow: 0 0 0 1px hsl(var(--brass) / .6) inset; }
.pal-piece .pg { font-size: 26px; line-height: 1; }
.pal-piece img { width: 84%; height: 84%; object-fit: contain; }
.pal-piece .pg.w { color: hsl(42 42% 90%); text-shadow: 0 1px 1px hsl(160 30% 4% / .8), 0 0 1px hsl(160 20% 6%); }
.pal-piece .pg.b { color: hsl(160 14% 10%); text-shadow: 0 1px 0 hsl(42 20% 55% / .5); }
.pal-piece .pg.custom { font-family: var(--font-display); font-size: 20px; font-weight: 700; }
.pal-piece .pg.custom.w { color: hsl(42 42% 88%); }
.pal-piece .pg.custom.b { color: hsl(160 14% 12%); }
.pal-tools { display: flex; gap: 8px; margin-top: 10px; }
.pal-tool.active { border-color: hsl(var(--brass)); color: hsl(var(--brass)); }
.pal-current { color: hsl(var(--ink-dim)); font-size: 12.5px; margin-top: 10px; min-height: 16px; }

.ge-valid { margin: 12px 0; font-size: 13.5px; display: flex; flex-direction: column; gap: 3px; }
.ge-valid .ok { color: hsl(140 45% 68%); }
.ge-valid .err { color: hsl(355 70% 74%); }
.ge-result {
  margin-top: 14px; padding: 12px 14px; border-radius: 8px;
  background: hsl(140 40% 26% / .18); border: 1px solid hsl(140 35% 40%); color: hsl(var(--ink));
  font-size: 14px;
}
.ge-result a.btn { margin-top: 8px; }

/* malarz planszy */
.ge-board-wrap { min-width: 0; }
.bp-coords-note { color: hsl(var(--ink-dim)); font-size: 12px; margin-bottom: 8px; text-align: center; letter-spacing: .04em; }
.board-paint {
  --w: 8; --h: 8;
  display: grid; grid-template-columns: repeat(var(--w), 1fr);
  width: min(560px, 100%); margin: 0 auto; aspect-ratio: var(--w) / var(--h);
  border: 2px solid hsl(var(--brass-dim)); border-radius: 6px; overflow: hidden;
  box-shadow: var(--shadow);
}
.bp-cell {
  position: relative; aspect-ratio: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  user-select: none;
}
.bp-cell.light { background: hsl(42 30% 78%); }
.bp-cell.dark { background: hsl(158 26% 30%); }
.bp-cell:hover::before {
  content: ''; position: absolute; inset: 0; background: hsl(var(--brass) / .28);
}
.bp-cell.hole {
  background:
    repeating-linear-gradient(45deg, hsl(160 20% 6%), hsl(160 20% 6%) 5px, hsl(160 16% 9%) 5px, hsl(160 16% 9%) 10px);
  cursor: crosshair;
}
.bp-cell .glyph { font-size: clamp(15px, 4.4vw, 34px); line-height: 1; pointer-events: none; }
.bp-cell .glyph.w { color: hsl(42 46% 94%); text-shadow: 0 1px 1px hsl(160 40% 4% / .7), 0 0 2px hsl(160 30% 8% / .8); }
.bp-cell .glyph.b { color: hsl(160 16% 9%); text-shadow: 0 1px 0 hsl(42 30% 70% / .35); }
.bp-cell .cust {
  width: 84%; height: 84%; display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.bp-cell .cust img { width: 100%; height: 100%; object-fit: contain; }
.bp-cell .cust .cletter {
  width: 74%; aspect-ratio: 1; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700; font-size: clamp(11px, 3vw, 20px);
  border: 2px solid currentColor;
}
.bp-cell .cust .cletter.w { color: hsl(42 46% 92%); background: hsl(160 30% 10% / .35); }
.bp-cell .cust .cletter.b { color: hsl(160 18% 10%); background: hsl(42 30% 78% / .5); }

/* ── mobile ── */
@media (max-width: 900px) {
  .piece-editor, .game-editor { grid-template-columns: 1fr; }
  .pe-gen { flex-wrap: wrap; }
  .md-grid { width: min(352px, 90vw); }
}
@media (max-width: 560px) {
  .site-bar h1 { font-size: 21px; }
  .ed-tab { padding: 9px 13px; font-size: 13.5px; }
  .field-row { flex-wrap: wrap; }
  .field-abbrev { width: 100%; }
  .md-controls { grid-template-columns: 1fr; }
  .md-grid { width: min(340px, 92vw); }
  .board-paint { width: 100%; }
  .pe-gen { gap: 12px; }
}
@media (max-width: 400px) {
  .piece-list { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
}
