@import url('../vendor/cm-chessboard/assets/chessboard.css');

/* Ymmude Chess UI — paired with the A0 site theme.
 * --a0-* variables switch with body.a0-light, so links and controls stay readable. */

.ymmudechess {
  --chess-link: var(--a0-cyan);
  --chess-accent: var(--a0-purple);
  --chess-text: var(--a0-text);
  --chess-dim: var(--a0-text-dim);
  --chess-surface: var(--a0-surface);
  --chess-border: var(--a0-border);
  --chess-hover: color-mix(in srgb, var(--a0-purple) 12%, transparent);
  color: var(--chess-text);
  max-width: 1100px;
  margin: 0 auto;
  font-size: 15px;
}

.ymmudechess a { color: var(--chess-link); text-decoration: underline; }
.ymmudechess a:hover { filter: brightness(1.2); }
.ymmudechess h2, .ymmudechess h3 { margin: .2em 0 .75em; letter-spacing: .02em; }
.ymmudechess h2 { font-size: 1.9rem; }
.ymmudechess-mono, .ymm-clock { font-variant-numeric: tabular-nums; }

/* Inline setup cards on the dashboard */
.ymmudechess-card {
  background: var(--chess-surface);
  color: var(--chess-text);
  border: 1px solid var(--chess-border);
  border-radius: 14px;
  padding: 1.15rem;
  margin-bottom: 1rem;
  box-shadow: 0 8px 28px rgba(0,0,0,.08);
}
.ymmudechess-form {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: .7rem;
}
.ymmudechess-form label { margin: 0 0 .4rem; font-weight: 600; color: var(--chess-dim); }
.ymmudechess-form select,
.ymmudechess-form input {
  flex: 1 1 150px;
  min-width: 0;
  padding: .6rem .75rem;
  color: var(--chess-text);
  background: var(--a0-bg-2);
  border: 1px solid var(--chess-border);
  border-radius: 9px;
}
.ymmudechess-form select:focus,
.ymmudechess-form input:focus { outline: 2px solid var(--a0-border-hi); }
.ymmudechess-hint { color: var(--chess-dim); font-size: .9rem; margin: .6rem 0 0; }

.ymmudechess-btn,
.ymmudechess-btn:link,
.ymmudechess-btn:visited {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .6rem 1rem;
  border: 1px solid transparent;
  border-radius: 9px;
  background: var(--chess-accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.ymmudechess-btn:hover,
.ymmudechess-btn:focus {
  filter: brightness(1.12);
  color: #fff;
  text-decoration: none;
  transform: translateY(-1px);
}
.ymmudechess-btn.secondary {
  background: var(--a0-bg-2);
  color: var(--chess-text);
  border-color: var(--chess-border);
}
.ymmudechess-btn.secondary:hover { color: var(--a0-cyan); background: var(--chess-hover); }

/* Board frame and play layout */
.ymmudechess-board-layout { display: flex; gap: 2rem; align-items: flex-start; justify-content: center; }
.ymmudechess-board-column { flex: 1 1 620px; min-width: 0; max-width: 640px; }
.ymmudechess-board {
  position: relative;
  border-radius: 16px;
  padding: 10px;
  background: linear-gradient(145deg, #292536, #171521);
  border: 1px solid rgba(180,160,110,.38);
  box-shadow: 0 16px 44px rgba(0,0,0,.2), inset 0 1px 2px rgba(255,255,255,.06);
}
.ymmudechess-board cm-chessboard,
.ymmudechess-board .cm-chessboard { display: block; width: 100%; aspect-ratio: 1; border-radius: 8px; overflow: hidden; }
.ymmudechess-board-wrap {
  box-sizing: border-box; max-width: 640px; margin: 0 auto 1.25rem; border-radius: 15px; padding: 10px;
  background: linear-gradient(145deg, #292536, #171521);
  border: 1px solid rgba(180,160,110,.38);
  box-shadow: 0 16px 44px rgba(0,0,0,.2), inset 0 1px 2px rgba(255,255,255,.06);
}
.ymmudechess-board-wrap cm-chessboard,
.ymmudechess-board-wrap .cm-chessboard { width: 100%; aspect-ratio: 1; border-radius: 12px; overflow: hidden; }
.ymm-playerbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: .7rem 1rem;
  margin: 6px auto;
  max-width: 640px;
  border-radius: 13px;
  background: var(--chess-surface);
  border: 1px solid var(--chess-border);
}
.ymm-playerbar.top { margin-bottom: 4px; }
.ymm-playerbar.bottom { margin-top: 4px; }
.ymm-pname { font-weight: 700; font-size: 1.05rem; color: var(--chess-text); display: flex; align-items: center; gap: 8px; }
.ymm-pname::before { content: ''; display: inline-block; width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--chess-dim); }
.ymm-playerbar.top .ymm-pname::before { background: #24222d; }
.ymm-playerbar.bottom .ymm-pname::before { background: #f0ead7; }
.ymm-clock { padding: 5px 13px; border-radius: 8px; background: var(--a0-bg-2); font-size: 1.25rem; font-weight: 700; font-family: ui-monospace,monospace; color: var(--chess-text); border: 1px solid var(--chess-border); }
.ymm-clock.active { outline: 2px solid var(--a0-green); color: var(--a0-green); }
.ymmudechess-status { text-align: center; font-size: 1.08rem; font-weight: 600; margin: 0 0 1rem; min-height: 1.5em; color: var(--chess-text); }
.ymmudechess-status[data-status="finished"] { color: var(--a0-green); }
.ymmudechess-toolbar { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; margin: 1rem 0; }

/* Compact move log and chat match the site panel palette */
.ymmudechess-moves, .ymm-chat {
  background: var(--chess-surface);
  border: 1px solid var(--chess-border);
  border-radius: 14px;
  color: var(--chess-text);
  overflow: hidden;
}
.ymmudechess-moves { max-height: 380px; overflow: auto; padding: 1rem; }
.ymm-chat { width: 320px; align-self: stretch; display: flex; flex-direction: column; }
.ymm-chat-head { padding: 1rem 1.15rem; border-bottom: 1px solid var(--chess-border); background: var(--a0-bg-2); }
.ymm-chat-title { font-weight: 700; color: var(--a0-cyan); }
.ymm-chat-log { flex: 1; min-height: 220px; max-height: 430px; overflow-y: auto; padding: 1rem; background: var(--chess-surface); }
.ymm-chat-date { text-align: center; color: var(--chess-dim); font-size: .72rem; margin: .6rem 0; }
.ymm-chat-msg { max-width: 88%; padding: .6rem .8rem; margin: 0 0 .65rem; border-radius: 10px; background: var(--a0-bg-2); border: 1px solid var(--chess-border); word-wrap: break-word; overflow-wrap: anywhere; }
.ymm-chat-msg.mine { margin-left: auto; border-color: color-mix(in srgb, var(--a0-purple) 55%, transparent); background: color-mix(in srgb, var(--a0-purple) 12%, transparent); }
.ymm-chat-who { display: flex; align-items: center; gap: .4rem; font-weight: 700; font-size: .78rem; color: var(--chess-dim); margin-bottom: .25rem; }
.ymm-chat-who time { margin-left: auto; font-weight: 400; }
.ymm-chat-swatch { width: 9px; height: 9px; border: 1px solid var(--chess-dim); border-radius: 2px; }
.ymm-chat-swatch-white { background: #f0ead7; }
.ymm-chat-swatch-black { background: #24222d; }
.ymm-chat-text { white-space: pre-wrap; }
.ymm-chat-form { display: flex; gap: .4rem; padding: .75rem; border-top: 1px solid var(--chess-border); }
.ymm-chat-form input { flex: 1; min-width: 0; background: var(--a0-bg-2); color: var(--chess-text); border: 1px solid var(--chess-border); border-radius: 8px; padding: .6rem .7rem; }
.ymm-chat-form input:disabled { opacity: .55; }
.ymm-chat-form button { padding: .6rem .8rem; }
.ymm-chat-notice { color: var(--chess-dim); font-size: .8rem; padding: 0 .9rem .8rem; }
.ymm-chat-error { display: none; color: #f87171; padding: .2rem .9rem .7rem; font-size: .8rem; }
.ymm-chat-error:empty { display: none; }
.ymm-chat-empty { color: var(--chess-dim); text-align: center; padding: 2rem .5rem; }

/* Dashboard tables */
.ymmudechess-games-list { background: var(--chess-surface); border: 1px solid var(--chess-border); border-radius: 14px; padding: 1.15rem; }
.ymmudechess-games-list table, .ymmudechess-leaderboard table { width: 100%; border-collapse: collapse; }
.ymmudechess-games-list th, .ymmudechess-games-list td,
.ymmudechess-leaderboard th, .ymmudechess-leaderboard td { text-align: left; padding: .65rem .75rem; border-bottom: 1px solid var(--chess-border); }
.ymmudechess-games-list th, .ymmudechess-leaderboard th { color: var(--chess-dim); font-size: .78rem; text-transform: uppercase; letter-spacing: .07em; }
.ymmudechess-games-list tbody tr:hover, .ymmudechess-leaderboard tbody tr:hover { background: var(--chess-hover); }
.ymmudechess-games-list .ymmudechess-btn { padding: .35rem .7rem; font-weight: 600; font-size: .84rem; }
.ymmudechess-badge { display: inline-block; padding: .2rem .65rem; border-radius: 999px; font-size: .76rem; font-weight: 600; background: color-mix(in srgb, var(--a0-purple) 14%, transparent); color: var(--a0-cyan); }
.ymm-games-tabs { display: flex; gap: .5rem; margin: 0 0 1rem; flex-wrap: wrap; }
.ymm-games-tab { appearance: none; border: 1px solid var(--chess-border); background: var(--a0-bg-2); color: var(--chess-text); padding: .5rem 1.05rem; border-radius: 999px; font-size: .9rem; cursor: pointer; }
.ymm-games-tab:hover { border-color: var(--a0-border-hi); color: var(--a0-cyan); }
.ymm-games-tab.is-active { background: var(--chess-accent); border-color: var(--chess-accent); color: #fff; }

/* Explicit light palette: the template does not redefine all --a0 variables. */
body.a0-light .ymmudechess {
  --chess-link: #075985;
  --chess-accent: #5b3fc4;
  --chess-text: #1a1a2e;
  --chess-dim: #55556a;
  --chess-surface: rgba(255, 255, 255, .82);
  --a0-bg-2: #e4e4ef;
  --chess-border: rgba(99, 102, 241, .24);
  --chess-hover: rgba(99, 102, 241, .09);
  color: var(--chess-text);
}
body.a0-light .ymmudechess a:not(.ymmudechess-btn),
.ymmudechess a:not(.ymmudechess-btn) { color: var(--chess-link); }
.a0-main-content .ymmudechess a.ymmudechess-btn,
.ymmudechess .ymmudechess-btn,
.ymmudechess .ymmudechess-btn:link,
.ymmudechess .ymmudechess-btn:visited {
  color: #fff;
  text-decoration: none;
}
body.a0-light .ymmudechess .ymmudechess-btn.secondary,
.a0-main-content body.a0-light .ymmudechess a.ymmudechess-btn.secondary {
  color: #1a1a2e;
}
.ymmudechess .ymm-games-tab:not(.is-active) { color: var(--chess-text); }
.ymmudechess .ymm-games-tab.is-active { color: #fff; }

/* Light scheme adjustments for board frame only; all text uses foreground vars. */
body.a0-light .ymmudechess-board, body.a0-light .ymmudechess-board-wrap {
  background: linear-gradient(145deg, #fdfcf8, #ded8c6);
  border-color: rgba(120,100,60,.4);
  box-shadow: 0 12px 32px rgba(50,45,30,.12), inset 0 1px 2px rgba(255,255,255,.8);
}
body.a0-light .ymmudechess-card,
body.a0-light .ymmudechess-games-list { box-shadow: 0 6px 18px rgba(35,35,60,.05); }
.color-mix-fallback .ymmudechess-btn { background: #7c5cff; }
@media (max-width:1199px) {
  .ymmudechess-board-layout { flex-direction: column; align-items: center; }
  .ymm-chat { width: 100%; max-width: 640px; }
}
@media (max-width:600px) {
  .ymmudechess { font-size: 14px; }
  .ymmudechess-board { padding: 5px; border-radius: 10px; }
  .ymm-playerbar { padding: .5rem .65rem; }
  .ymm-pname { font-size: .92rem; }
  .ymm-clock { font-size: 1.05rem; padding: 4px 8px; }
  .ymmudechess-games-list { padding: .75rem; overflow-x: auto; }
  .ymmudechess-form { flex-direction: column; align-items: stretch; }
}

body.a0-light .ymmudechess .ymm-chat-title { color: #075985; }
body.a0-light .ymmudechess .ymm-chat-head { background: #e4e4ef; }
