/* filename: css/mini_board.css
   오프닝 자료 탐색기 / K-데이터베이스 공통: 왼쪽 작은 체스판 + 오른쪽 넓은 기능 영역 */

.tool-main {
  max-width: 1240px;
  justify-content: flex-start;
  align-items: stretch;
}

.tool-layout {
  --mb-max: min(440px, calc(100vh - 250px));
  display: grid;
  grid-template-columns: minmax(0, var(--mb-max)) minmax(0, 1fr);
  gap: 22px;
  width: 100%;
  align-items: start;
}

.tool-board-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  position: sticky;
  top: 76px;
}

.tool-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.tool-card {
  background: var(--card-bg);
  border: 1px solid var(--border-purple);
  border-radius: 16px;
  padding: 16px;
}

.tool-card-title {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--accent-gold);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* ---------- 체스판 ---------- */
.mb-wrap {
  position: relative;
  width: 100%;
  min-width: 240px;
  aspect-ratio: 1 / 1;
}

.mb-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: 100%;
  height: 100%;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

.mb-board.can-move {
  cursor: pointer;
}

.mb-sq { position: relative; }
.mb-sq.light { background: var(--sq-light, #f0d9b5); }
.mb-sq.dark { background: var(--sq-dark, #b58863); }
.mb-sq.last::before,
.mb-sq.selected::before {
  content: "";
  position: absolute;
  inset: 0;
}
.mb-sq.last::before { background: rgba(155, 199, 0, 0.41); }
.mb-sq.selected::before { background: rgba(20, 85, 30, 0.5); }
.mb-sq.check {
  background-image: radial-gradient(ellipse at center, rgba(255, 0, 0, 1) 0%, rgba(231, 0, 0, 1) 25%, rgba(169, 0, 0, 0) 89%, rgba(158, 0, 0, 0) 100%);
}

.mb-piece {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}
.mb-piece.dragging { opacity: 0.3; }

.mb-dest {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 28%;
  height: 28%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(20, 85, 30, 0.5);
  z-index: 3;
  pointer-events: none;
}
.mb-dest.capture {
  width: 100%;
  height: 100%;
  background: radial-gradient(circle closest-side, transparent 0%, transparent 76%, rgba(20, 85, 30, 0.5) 78%);
}

.mb-coord {
  position: absolute;
  font-size: 0.62rem;
  font-weight: 800;
  z-index: 1;
  pointer-events: none;
}
.mb-coord.file { right: 4%; bottom: 2%; }
.mb-coord.rank { left: 4%; top: 2%; }
.mb-sq.light .mb-coord { color: var(--sq-dark, #b58863); }
.mb-sq.dark .mb-coord { color: var(--sq-light, #f0d9b5); }
@media (max-width: 640px) { .mb-coord { font-size: 0.72rem; } }   /* 휴대폰: 좌표 글자 키우기 */

.mb-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 3000;
  transform: translate(-50%, -50%);
}

.mb-promo {
  position: absolute;
  inset: 0;
  background: rgba(11, 9, 18, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  border-radius: 6px;
}
.mb-promo-box {
  display: flex;
  gap: 6px;
  background: var(--card-bg);
  border: 1px solid var(--accent-gold);
  border-radius: 12px;
  padding: 8px;
}
.mb-promo-box button {
  width: 56px;
  height: 56px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-purple);
  border-radius: 8px;
  cursor: pointer;
  padding: 3px;
}
.mb-promo-box img { width: 100%; height: 100%; }

/* 이동 버튼 */
.mb-nav {
  display: flex;
  gap: 5px;
}
.mb-nav button {
  flex: 1;
  padding: 7px 0;
  background: var(--card-bg);
  border: 1px solid var(--border-purple);
  border-radius: 8px;
  color: var(--text-main);
  font-size: 0.85rem;
  font-weight: 900;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.mb-nav button:hover { border-color: var(--accent-gold); color: var(--accent-gold); }

/* 판 아래 작은 기보 */
.mb-moves {
  max-height: 84px;
  overflow-y: auto;
  position: relative;
  background: var(--card-bg);
  border: 1px solid var(--border-purple);
  border-radius: 10px;
  padding: 7px 9px;
  font-size: 0.8rem;
  line-height: 1.75;
  color: var(--text-soft);
}
/* 수 사이에 공백 글자가 없어도 줄이 바뀌도록 inline-block */
.mb-moves .mb-no,
.mb-moves .mb-mv {
  display: inline-block;
}

.mb-moves .mb-no {
  color: var(--text-muted);
  margin-right: 3px;
}
.mb-moves .mb-mv {
  cursor: pointer;
  padding: 1px 3px;
  margin-right: 4px;
  border-radius: 4px;
  font-weight: 700;
}
.mb-moves .mb-mv:hover { background: rgba(255, 255, 255, 0.1); }
.mb-moves .mb-mv.active { background: var(--accent-gold); color: var(--on-accent); }
.mb-moves .mb-empty { color: var(--text-muted); }

/* ---------- 공통 버튼 / 입력 / 창 ---------- */
.tool-btn {
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--border-purple);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  font-size: 0.85rem;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.tool-btn:hover { border-color: var(--accent-gold); color: var(--accent-gold); }
.tool-btn.primary { background: var(--accent-gold); border-color: var(--accent-gold); color: var(--on-accent); }
.tool-btn.primary:hover { opacity: 0.9; color: var(--on-accent); }
.tool-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.tool-input,
.tool-select,
.tool-textarea {
  width: 100%;
  background: var(--bg-dark);
  border: 1px solid var(--border-purple);
  border-radius: 10px;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.88rem;
  padding: 9px 11px;
  outline: none;
}
.tool-input:focus,
.tool-select:focus,
.tool-textarea:focus { border-color: var(--accent-gold); }
.tool-input:disabled { opacity: 0.4; }
.tool-textarea { resize: vertical; min-height: 120px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.8rem; }

.tool-modal {
  position: fixed;
  inset: 0;
  z-index: 2500;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(11, 9, 18, 0.85);
  backdrop-filter: blur(6px);
}
.tool-modal.active { display: flex; }
.tool-modal-box {
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  background: var(--card-bg);
  border: 1px solid var(--border-purple);
  border-radius: 20px;
  padding: 24px 22px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.8);
}
.tool-modal-box h3 {
  font-size: 1.15rem;
  font-weight: 900;
  margin-bottom: 16px;
}
.tool-field { margin-bottom: 14px; }
.tool-field > label,
.tool-field > .tool-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.tool-field .req { color: #ff6b6b; margin-left: 2px; }
.tool-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tool-choices label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  border: 1px solid var(--border-purple);
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}
.tool-choices input { accent-color: var(--accent-gold); }
.tool-choices label:has(input:checked) { border-color: var(--accent-gold); color: var(--accent-gold); }
.tool-choices.column { flex-direction: column; }
.tool-choices.column label { border-radius: 10px; }
.tool-modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 18px;
}
.tool-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 5px;
  line-height: 1.5;
}
.tool-error {
  color: #ff6b6b;
  font-size: 0.8rem;
  font-weight: 700;
  min-height: 1em;
  margin-top: 8px;
}

@media (max-width: 860px) {
  .tool-layout {
    grid-template-columns: 1fr;
    --mb-max: 440px;
  }
  .tool-board-col {
    position: static;
    max-width: 440px;
    width: 100%;
    margin: 0 auto;
  }
}

/* 오프닝 탐색기: 체스판 크기 조절 손잡이 (체스판 열 오른쪽 가장자리) */
.op-resize { position: absolute; top: 0; bottom: 0; right: -14px; width: 10px; cursor: col-resize; z-index: 5; touch-action: none; }
.op-resize::after { content: ""; position: absolute; top: 0; bottom: 0; left: 4px; width: 2px; border-radius: 2px; background: transparent; }
.op-resize:hover::after, .op-resize.dragging::after { background: var(--accent-gold); }
body.op-resizing { cursor: col-resize; user-select: none; }
@media (max-width: 760px) { .op-resize { display: none; } }
