/* App shell for the Go board.
 *
 * Two hard requirements drive every number here:
 *   1. the board is a square sized to fit the space *left over* after the page
 *      chrome, so it never pushes a scrollbar onto the screen;
 *   2. the board sits on the left and every control sits to its right — nothing
 *      above or below it that you have to scroll to reach.
 *
 * The right column therefore scrolls internally if a future control needs more
 * room, while the board itself never moves.
 */

.tool-page-app .tool-panel-wrap {
  max-width: none;
  margin-bottom: 1.5rem;
}

/* ---- page chrome: as thin as possible while keeping the h1 ---- */
body.page-app main {
  max-width: 96rem;
  padding-top: 0;
}
body.page-app .site-nav {
  padding-top: 0.4rem;
  padding-bottom: 0.4rem;
}
.tool-page-app .tool-hero-compact {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin: 0 0 0.35rem;
}
.tool-page-app .tool-hero-compact h1 {
  font-size: clamp(1rem, 0.85rem + 0.7vw, 1.3rem);
  margin: 0;
}
.tool-page-app .tool-hero-compact .tagline {
  font-size: 0.82rem;
  margin: 0;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 46ch;
}
.tool-page-app .tool-hero-compact .meta-row {
  display: none;
}

/* ---- two panes, one screen ---- */
.go-app {
  display: grid;
  gap: 0.9rem;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
}

/* Mid-width windows: a narrower control column keeps the board respectable. */
@media (min-width: 760px) and (max-width: 1080px) {
  .go-app {
    --chrome: 6.2rem;
    grid-template-columns: minmax(0, 1fr) 17rem;
    height: calc(100dvh - var(--chrome));
  }
  #go-ai-board {
    width: min(calc(100dvh - 12rem), calc(100vw - 20rem), 100%);
  }
}

@media (min-width: 760px) {
  /* Height budget: nav (≈2.2rem) + one-line heading (≈1.6rem) + margins.
     Everything the board and the controls need must fit inside this. */
  .go-app {
    --chrome: 6.2rem;
    grid-template-columns: minmax(0, 1fr) 20rem;
    height: calc(100dvh - var(--chrome));
    align-items: stretch;
  }
  .go-side-pane {
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-right: 0.15rem;
  }
}

.go-board-pane {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
}

/* The board: the smaller of (available height) and (available width). Both
   operands are explicit so the square can never overflow its cell. */
#go-ai-board {
  /* Leave real air above and below the board: it should sit comfortably inside
     the screen, not touch the edges. */
  width: min(calc(100dvh - 12rem), calc(100vw - 24rem), 100%);
  height: auto;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  box-shadow: var(--shadow);
  touch-action: manipulation;
  cursor: pointer;
  background: #e8c48c;
}

/* ---- right column ---- */
.go-side-pane {
  display: grid;
  gap: 0.55rem;
  align-content: start;
  min-width: 0;
  min-height: 0;
}
.go-status {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.35;
  color: var(--ink-2);
  min-height: 2.2em;
}
.go-block {
  display: grid;
  gap: 0.45rem;
}
.go-block .field {
  gap: 0.2rem;
}
.go-block .field-label {
  font-size: 0.78rem;
}
.go-block .field-hint {
  font-size: 0.72rem;
}
.go-block .chip {
  font-size: 0.76rem;
  padding: 0.22rem 0.55rem;
}
.go-actions,
.go-analysis-actions {
  gap: 0.3rem;
}
.go-actions .btn,
.go-analysis-actions .btn {
  font-size: 0.78rem;
  padding: 0.28rem 0.55rem;
}
.go-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.35rem;
}
.go-stats .stat {
  padding: 0.35rem 0.45rem;
}
.go-stats .stat-label {
  font-size: 0.66rem;
}
.go-stats .stat-value {
  font-size: 0.92rem;
}
.go-analysis-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem;
}
.go-analysis-stats .stat {
  padding: 0.35rem 0.45rem;
}
.go-analysis-stats .stat-label {
  font-size: 0.64rem;
}
.go-analysis-stats .stat-value {
  font-size: 0.9rem;
}
.go-analysis-stats .stat-sub {
  font-size: 0.68rem;
}
.go-note {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--ink-3);
}
.go-footnote {
  margin: 0.2rem 0 0;
  font-size: 0.68rem;
  color: var(--ink-3);
  border-top: 1px solid var(--line);
  padding-top: 0.4rem;
}
.go-details summary {
  cursor: pointer;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--ink-2);
  padding: 0.2rem 0;
}
.go-details .table-wrap {
  margin-top: 0.3rem;
  max-height: 10rem;
  overflow: auto;
}
.go-details .table th,
.go-details .table td {
  padding: 0.25rem 0.4rem;
  font-size: 0.74rem;
}

/* ---- phone: board on top, controls underneath ---- */
@media (max-width: 759px) {
  #go-ai-board {
    width: min(100%, calc(100dvh - 12rem));
  }
  .go-side-pane {
    overflow: visible;
  }
  /* The heading and tagline are the only thing between the nav and the board on
     a phone, so they get clamped hard: the board and the six game buttons have to
     share an 800px screen. */
  .tool-page-app .tool-hero-compact {
    padding-top: 0.1rem;
  }
  .tool-page-app .tool-hero-compact h1 {
    font-size: 0.95rem;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .tool-page-app .tool-hero-compact .tagline {
    display: none;
  }
  .tool-page-app .tool-panel-wrap {
    margin-top: 0.2rem;
  }
  .go-status {
    min-height: 0;
  }
}

/* ---- engine block: the two buttons are always visible ---- */
.go-analysis-block {
  display: grid;
  gap: 0.3rem;
  border-top: 1px solid var(--line);
  padding-top: 0.5rem;
}
.go-analysis-block .field-label {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-3);
}
.go-analysis-block > * + * {
  margin-top: 0.15rem;
}
@media (max-width: 759px) {
  .go-footnote {
    display: none; /* the same note lives in the page FAQ */
  }
  .go-block .field-hint {
    display: none;
  }
}

/* ---- game record: import / export ---- */
.go-io {
  display: grid;
  gap: 0.3rem;
  border-top: 1px solid var(--line);
  padding-top: 0.5rem;
}
.go-io .field-label {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-3);
}
.go-io-actions {
  gap: 0.3rem;
}
.go-io-actions .btn,
.go-file-label {
  font-size: 0.76rem;
  padding: 0.26rem 0.5rem;
}
.go-file-label {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}
.go-sgf {
  min-height: 3.4rem;
  font-size: 0.72rem;
  line-height: 1.35;
  padding: 0.35rem 0.45rem;
  resize: vertical;
}
