/* Game review and KIF import (Steps 21 and 18).
 *
 * One stylesheet for two pages because they are the same page: a board, a
 * move list beside it, and something along the top. Splitting them would mean
 * two copies of the replay layout drifting apart.
 *
 * Colours are the site's own tokens, with one addition: the eval graph's
 * diverging pair, chosen against the paper surface and validated for the
 * lightness band, chroma floor, colour-vision separation and contrast rather
 * than picked by eye. They are here rather than only in the JavaScript so the
 * legend swatches and the graph cannot drift.
 */

:root {
  --eval-sente: #1C7FBE;
  --eval-gote: #BE4A34;

  /* Judgment colours. Reserved: they are a status palette, never reused as
     "another series". Every place they appear also carries the word or the
     ?!/?/?? mark, so nothing is encoded by colour alone. */
  --judge-inaccuracy: #B8860B;
  --judge-mistake: #C0642A;
  --judge-blunder: #A3382A;
}

.review-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 20px;
  align-items: start;
}

@media (max-width: 900px) {
  .review-page {
    grid-template-columns: minmax(0, 1fr);
  }
}

.review-board {
  min-width: 0;
}

/* The board needs a definite height, and this is the whole reason why.
 *
 * In the landscape layout `board.js._sizeBoard` measures `.sb-root` and makes
 * the board the smaller of that HEIGHT and the width the komadai leave over.
 * On the play page that height is definite: the page is a flex column filling
 * the viewport, so `height: 100%` has something to resolve against. The
 * review and import pages put the board in an ordinary `<main>` with auto
 * height, where `height: 100%` resolves against nothing — the measurement
 * comes back as whatever the komadai happen to be tall, and the board is
 * drawn at a size that does not match its box. That is the clipped board.
 *
 * A `max-height` does not fix it: it caps the box without ever giving the
 * measurement a number to read.
 *
 * Portrait keeps `auto`, because board.css sizes from the WIDTH there and a
 * fixed height would leave a slab of empty paper under the board.
 */
#review-board-root {
  height: clamp(240px, 68vh, 760px);
}

@media (orientation: portrait) {
  #review-board-root {
    height: auto;
  }
}

.review-side {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

/* ---- the graph -------------------------------------------------------- */

.evalgraph {
  position: relative;
  width: 100%;
  border: 1px solid var(--paper-edge, #D8C48C);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.55);
}

.evalgraph__svg {
  display: block;
  width: 100%;
}

.evalgraph__surface {
  cursor: pointer;
}

.evalgraph__tip {
  position: absolute;
  top: 6px;
  z-index: 3;
  min-width: 140px;
  max-width: 220px;
  padding: 6px 8px;
  border: 1px solid var(--paper-edge, #D8C48C);
  border-radius: 4px;
  background: var(--paper, #F2E8D2);
  box-shadow: 0 6px 18px -8px rgba(43, 30, 15, 0.5);
  font-size: 0.82rem;
  line-height: 1.35;
  pointer-events: none;
}

.evalgraph-key {
  display: flex;
  gap: 16px;
  margin: 6px 2px 0;
  font-size: 0.78rem;
  color: var(--ink-soft, #5C5040);
}

.evalgraph-key span::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 5px;
  border-radius: 2px;
  vertical-align: -1px;
}

.evalgraph-key .is-sente::before { background: var(--eval-sente); }
.evalgraph-key .is-gote::before { background: var(--eval-gote); }

/* ---- summary ---------------------------------------------------------- */

.review-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.review-summary__side {
  padding: 10px 12px;
  border: 1px solid var(--paper-edge, #D8C48C);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.55);
}

.review-summary__who {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft, #5C5040);
}

.review-summary__accuracy {
  font-size: 1.6rem;
  font-variant-numeric: tabular-nums;
}

.review-summary__counts {
  font-size: 0.8rem;
  color: var(--ink-soft, #5C5040);
}

.review-status {
  padding: 10px 12px;
  border: 1px solid var(--paper-edge, #D8C48C);
  border-left: 4px solid var(--indigo, #2C4A63);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.55);
  font-size: 0.88rem;
}

.review-status--error {
  border-left-color: var(--judge-blunder);
}

/* ---- move list -------------------------------------------------------- */
/*
 * The move list is also the review's TABLE VIEW: every judged move is here in
 * words, with its mark, in order. Anything the graph shows can be read here
 * without seeing the graph at all.
 */

.review-side .movelist {
  max-height: 46vh;
  overflow-y: auto;
  border: 1px solid var(--paper-edge, #D8C48C);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.55);
  font-variant-numeric: tabular-nums;
  font-size: 0.88rem;
}

.movelist__side {
  margin-right: 4px;
  opacity: 0.65;
}

.movelist__mark {
  margin-left: 4px;
  font-weight: 700;
}

.judgment--inaccuracy .movelist__mark { color: var(--judge-inaccuracy); }
.judgment--mistake .movelist__mark { color: var(--judge-mistake); }
.judgment--blunder .movelist__mark { color: var(--judge-blunder); }

/* ---- controls --------------------------------------------------------- */

.replay-controls {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.replay-controls button {
  padding: 6px 10px;
  border: 1px solid var(--paper-edge, #D8C48C);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.6);
  font: inherit;
  cursor: pointer;
}

.replay-controls button:hover,
.replay-controls button:focus-visible {
  background: rgba(44, 74, 99, 0.12);
}

.review-note {
  padding: 8px 10px;
  border-radius: 4px;
  background: rgba(44, 74, 99, 0.1);
  font-size: 0.86rem;
  min-height: 2.4em;
}

.review-note strong { font-weight: 700; }

.suggestion-hint {
  color: var(--ink-soft, #5C5040);
  font-size: 0.92em;
}

/* The key for the two tints on the board.
 *
 * The swatches are the COMPOSITED colours — what the translucent tints
 * actually become over the board's #E8C88A — rather than the tints
 * themselves, which on paper would be two barely-there washes that look
 * nothing like the squares they describe.
 *
 * It appears only while a suggestion is on the board, and the words carry the
 * meaning on their own: green against red is the one pair a red-green
 * colour-blind viewer cannot separate, so neither this key nor the board
 * leans on hue alone. */
.suggestion-key {
  display: flex;
  gap: 14px;
  margin: 2px;
  font-size: 0.78rem;
  color: var(--ink-soft, #5C5040);
}

.suggestion-key span::before {
  content: "";
  display: inline-block;
  width: 11px;
  height: 11px;
  margin-right: 5px;
  border-radius: 2px;
  vertical-align: -1px;
}

.suggestion-key .is-played::before {
  background: #D39D6D;
}

.suggestion-key .is-suggest::before {
  background: #36803F;
  /* The same non-colour cue the destination square carries on the board. */
  box-shadow: inset 0 0 0 1.5px rgba(18, 90, 40, 0.95);
}

#toggle-suggestion[aria-pressed="true"] {
  border-color: #36803F;
  box-shadow: inset 0 0 0 1px #36803F;
}

/* ---- import page ------------------------------------------------------ */

.kif-drop {
  padding: 16px;
  border: 2px dashed var(--paper-edge, #D8C48C);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.4);
}

.kif-drop.is-over {
  border-color: var(--indigo, #2C4A63);
  background: rgba(44, 74, 99, 0.08);
}

.kif-drop textarea {
  width: 100%;
  min-height: 120px;
  margin-top: 10px;
  padding: 8px;
  border: 1px solid var(--paper-edge, #D8C48C);
  border-radius: 4px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.8rem;
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink, #2A2118);
}

.kif-error {
  color: var(--judge-blunder);
  font-size: 0.88rem;
}

.kif-meta {
  font-size: 0.88rem;
  color: var(--ink-soft, #5C5040);
}

.export-links {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.86rem;
}

/* ---- openings and castles ---------------------------------------------- */
/*
 * Part of the review (unlocked with it). Two cards side by side, the same
 * shape as the accuracy summary above so the eye reads them as one pair of
 * columns: Sente on the left, Gote on the right, all the way down.
 */

.review-strategy__title {
  font-family: 'Shippori Mincho', serif;
  font-size: 1.05rem;
  margin: 0 0 2px;
}

.review-strategy__game {
  margin: 0 0 8px;
  font-size: 0.92rem;
  color: var(--ink-soft, #5C5040);
}

.review-strategy__sides {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 420px) {
  .review-strategy__sides {
    grid-template-columns: minmax(0, 1fr);
  }
}

.review-strategy__side {
  padding: 10px 12px;
  border: 1px solid var(--paper-edge, #D8C48C);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.55);
  min-width: 0;
}

.review-strategy__side--sente { border-top: 3px solid var(--eval-sente); }
.review-strategy__side--gote { border-top: 3px solid var(--eval-gote); }

.review-strategy__side dl {
  margin: 6px 0 0;
  font-size: 0.82rem;
  line-height: 1.4;
}

.review-strategy__side dt {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft, #5C5040);
  margin-top: 6px;
}

.review-strategy__side dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.review-strategy .jp {
  font-family: 'Noto Serif JP', 'Zen Old Mincho', serif;
  color: var(--ink-soft, #5C5040);
  font-size: 0.9em;
}

.review-strategy .is-broken {
  color: var(--judge-blunder);
}

.review-strategy__notes {
  margin: 10px 0 0;
  padding-left: 1.1em;
  font-size: 0.85rem;
  line-height: 1.5;
}

.review-strategy__notes li + li {
  margin-top: 4px;
}

.linklike {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--indigo, #2C4A63);
  cursor: pointer;
  text-decoration: underline dotted;
}

.linklike:hover,
.linklike:focus-visible {
  text-decoration: underline;
}
