/**
 * Kymi Games - Korean Janggi Stylesheet (assets/css/games/janggi.css)
 *
 * Scoped strictly to .janggi-wrapper and janggi components.
 * Adheres 100% to Kymi Design System (DESIGN_SYSTEM.md, tokens.css, common.css).
 */

.janggi-wrapper {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

/* Breadcrumbs */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 16px;
}

.breadcrumbs a {
  color: var(--muted);
  text-decoration: none;
}

.breadcrumbs a:hover {
  color: var(--blue);
  text-decoration: underline;
}

/* Header Bar */
.janggi-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
}

.janggi-title-group h1 {
  font-size: 28px;
  font-weight: 800;
  color: var(--ink-heading);
  letter-spacing: -0.03em;
  margin: 6px 0 0;
}

.janggi-meta-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--blue-dark);
  background: var(--blue-light);
  padding: 4px 10px;
  border-radius: var(--radius-full);
}

.lang-switch-pill {
  display: inline-flex;
  background: var(--surface-alt);
  padding: 4px;
  border-radius: var(--radius-full);
  gap: 2px;
  border: 1px solid var(--line);
}

.lang-switch-pill a {
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  transition: all 0.15s ease;
}

.lang-switch-pill a.active {
  background: var(--paper);
  color: var(--ink-heading);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

/* Main 2-Column Grid */
.janggi-main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.95fr);
  gap: 28px;
  align-items: start;
}

@media (max-width: 960px) {
  .janggi-main-grid {
    grid-template-columns: 1fr;
  }
}

/* Left Column: Board Card */
.janggi-board-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Top Dashboard Bar */
.janggi-dashboard-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--wash);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  gap: 12px;
}

.player-profile-badge {
  display: flex;
  align-items: center;
  gap: 10px;
}

.token-indicator {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.token-indicator.cho {
  background: #fef3c7;
  color: #15803d;
  border: 2px solid #15803d;
}

.token-indicator.han {
  background: #ffedd5;
  color: #b91c1c;
  border: 2px solid #b91c1c;
}

.player-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}

.player-score {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}

.player-timer {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-heading);
}

.game-status-pill {
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
}

.game-status-pill.your-turn {
  background: var(--mint);
  color: var(--mint-dark);
}

.game-status-pill.opp-turn {
  background: var(--surface-alt);
  color: var(--muted);
}

.game-status-pill.ai-turn {
  background: var(--blue-light);
  color: var(--blue-dark);
  animation: pulseAi 1.5s infinite;
}

.game-status-pill.check-alert {
  background: #fee2e2;
  color: #b91c1c;
  animation: pulseCheck 1s infinite;
}

.game-status-pill.game-over {
  background: #fef08a;
  color: #854d0e;
}

@keyframes pulseAi {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

@keyframes pulseCheck {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

/* Board Mount Point */
.game-interaction-area {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #d4a359;
  border-radius: var(--radius-md);
  padding: 12px;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.15);
}

.janggi-board-svg {
  width: 100%;
  max-width: 600px;
  height: auto;
  aspect-ratio: 9 / 10;
  display: block;
  user-select: none;
}

/* SVG Elements Styling */
.board-wood-bg {
  fill: #e5b875;
}

.board-outer-border {
  fill: none;
  stroke: #7c441b;
  stroke-width: 3;
}

.board-grid-line {
  stroke: #663914;
  stroke-width: 1.6;
}

.board-palace-line {
  stroke: #663914;
  stroke-width: 1.8;
}

/* Pieces */
.janggi-piece-group {
  cursor: pointer;
  transition: transform 0.15s ease;
}

.janggi-piece-group:hover {
  transform: translateY(-2px);
}

.piece-shadow {
  fill: rgba(0, 0, 0, 0.22);
}

.token-cho {
  fill: #fffbeb;
  stroke: #166534;
  stroke-width: 2.2;
}

.token-han {
  fill: #fff7ed;
  stroke: #991b1b;
  stroke-width: 2.2;
}

.piece-inner-ring {
  fill: none;
  stroke: rgba(0, 0, 0, 0.12);
  stroke-width: 1;
}

.piece-hanja {
  font-family: 'Noto Serif KR', 'Batang', serif;
  font-size: 26px;
  font-weight: 800;
  pointer-events: none;
}

.hanja-cho {
  fill: #15803d;
}

.hanja-han {
  fill: #b91c1c;
}

.piece-accessibility-code {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 800;
  pointer-events: none;
}

.code-cho {
  fill: #166534;
}

.code-han {
  fill: #991b1b;
}

/* Touch Intersections */
.touch-intersection-target {
  fill: transparent;
  cursor: pointer;
  outline: none;
}

.touch-intersection-target:focus-visible {
  stroke: var(--blue);
  stroke-width: 2;
  stroke-dasharray: 4;
}

/* Highlights */
.last-move-origin {
  fill: none;
  stroke: #d97706;
  stroke-width: 2.5;
  stroke-dasharray: 5, 3;
}

.last-move-dest {
  fill: none;
  stroke: #d97706;
  stroke-width: 3;
}

.selected-piece-ring {
  fill: none;
  stroke: var(--blue);
  stroke-width: 3.5;
  stroke-dasharray: 6, 3;
  animation: rotateSel 8s linear infinite;
}

@keyframes rotateSel {
  100% { stroke-dashoffset: -100; }
}

.assist-move-dot {
  fill: #10b981;
  opacity: 0.85;
}

.assist-capture-ring {
  fill: none;
  stroke: #ef4444;
  stroke-width: 3;
  stroke-dasharray: 4, 3;
}

.check-warning-pulse {
  fill: none;
  stroke: #ef4444;
  stroke-width: 4;
  animation: pulseCheckRing 1.2s infinite;
}

@keyframes pulseCheckRing {
  0% { transform: scale(0.95); opacity: 0.9; }
  50% { transform: scale(1.15); opacity: 0.4; }
  100% { transform: scale(0.95); opacity: 0.9; }
}

/* Action Buttons Bar */
.janggi-actions-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn-game-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-game-action:hover:not(:disabled) {
  background: var(--surface-alt);
  border-color: var(--line-strong);
}

.btn-game-action.primary {
  background: var(--blue);
  border-color: var(--blue);
  color: white;
}

.btn-game-action.primary:hover:not(:disabled) {
  background: var(--blue-dark);
}

.btn-game-action.danger {
  color: #b91c1c;
}

.btn-game-action.danger:hover:not(:disabled) {
  background: #fee2e2;
  border-color: #fca5a5;
}

/* Right Column: Side Panel */
.janggi-side-panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}

.side-tabs-nav {
  display: flex;
  border-bottom: 1px solid var(--line);
  gap: 4px;
  overflow-x: auto;
  margin-bottom: 20px;
}

.side-tab-btn {
  padding: 10px 14px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.side-tab-btn:hover {
  color: var(--ink);
}

.side-tab-btn.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

.side-tab-content h3 {
  font-size: 16px;
  font-weight: 800;
  color: var(--ink-heading);
  margin: 0 0 16px;
}

/* Control Groups */
.control-field-group {
  margin-bottom: 16px;
}

.control-field-group label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.segmented-control {
  display: flex;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 2px;
}

.segmented-control button {
  flex: 1;
  padding: 6px 10px;
  border: none;
  background: none;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
}

.segmented-control button.active {
  background: var(--paper);
  color: var(--ink-heading);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
}

.switch-toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider-round {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--line-strong);
  transition: 0.3s;
  border-radius: 24px;
}

.slider-round:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
}

input:checked + .slider-round {
  background-color: var(--blue);
}

input:checked + .slider-round:before {
  transform: translateX(20px);
}

/* Online notices */
.janggi-online-notice {
  font-size: 13px;
  color: var(--muted);
  background: var(--blue-light);
  border: 1px solid #c7d9fc;
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 16px;
  line-height: 1.5;
}

/* Rules Guide Section */
.rules-accordion {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rules-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px;
  background: var(--wash);
}

.rules-item h4 {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-heading);
  margin: 0 0 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.rules-item p {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
  line-height: 1.5;
}

/* Fix 6-tab bar clipping/overlap: clean 3x2 grid */
.side-tabs-nav{display:grid!important;grid-template-columns:repeat(3,minmax(0,1fr))!important;gap:6px!important;overflow:visible!important;padding:6px!important;}
.side-tab-btn{width:100%!important;white-space:nowrap!important;overflow:hidden!important;text-overflow:ellipsis!important;padding:8px 6px!important;font-size:12.5px!important;text-align:center!important;justify-content:center!important;}
