/* Go: a board and a chat beside it (below it on narrow screens), under the sites' thin top bar. */

:root {
  --bg: #fefefc;
  --bg-soft: #f5f4ef;
  --ink: #1f1d1a;
  --ink-soft: #57524a;
  --ink-faint: #8a8478;
  --rule: #e3ded3;
  --accent: #2f5d8a;
  --draft: #b0471f;
  /* the board */
  --wood: #e4c184;
  --wood-edge: #c9a061;
  --grid: #3d2f1b;
  --coord: #6e5532;
  --shadow: rgba(40, 25, 5, .3);
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --gutter: 16px;
  color-scheme: light;
}

/* Dark colours: when the toggle says dark, or the device prefers dark and the toggle hasn't said light. */
:root[data-theme="dark"] {
  --bg: #171614;
  --bg-soft: #22201d;
  --ink: #ece8e1;
  --ink-soft: #b9b2a6;
  --ink-faint: #8a8478;
  --rule: #34312c;
  --accent: #8fb6dd;
  --draft: #e98a62;
  --wood: #b48d55;
  --wood-edge: #8d6b3b;
  --grid: #2b200f;
  --coord: #3f2f17;
  --shadow: rgba(0, 0, 0, .45);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171614;
    --bg-soft: #22201d;
    --ink: #ece8e1;
    --ink-soft: #b9b2a6;
    --ink-faint: #8a8478;
    --rule: #34312c;
    --accent: #8fb6dd;
    --draft: #e98a62;
    --wood: #b48d55;
    --wood-edge: #8d6b3b;
    --grid: #2b200f;
    --coord: #3f2f17;
    --shadow: rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--sans); }
a { color: var(--accent); text-underline-offset: 2px; }
button, select { font: inherit; color: inherit; }

/* ---------------------------------------------------------------- top bar (as on the sites) */

.masthead {
  display: flex; align-items: center; gap: 12px;
  max-width: 1240px; margin: 0 auto; padding: 14px var(--gutter);
  font: 500 14px/1.2 var(--sans);
}
.masthead .brand { color: var(--ink); text-decoration: none; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; font-size: 13px; }
.masthead .about { margin: 0; font-size: 12px; color: var(--ink-faint); }
.masthead nav { margin-left: auto; display: flex; }
.theme-toggle { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; background: none; color: var(--ink-soft); cursor: pointer; border-radius: 6px; }
.theme-toggle:hover { color: var(--ink); background: var(--bg-soft); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .sun, :root[data-theme="dark"] .theme-toggle .moon { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: block; }

/* ---------------------------------------------------------------- layout */

.go {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(18rem, 24rem); gap: 28px; align-items: start;
  max-width: 1240px; margin: 0 auto; padding: 0 var(--gutter) 32px;
}
@media (max-width: 860px) { .go { grid-template-columns: minmax(0, 1fr); gap: 20px; } }

/* ---------------------------------------------------------------- the board */

.play { display: flex; flex-direction: column; align-items: center; gap: 10px; min-width: 0; }
.status { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin: 0; min-height: 1.5em; color: var(--ink-soft); }
.status .turn { color: var(--ink); font-weight: 500; }
.status .caps { color: var(--ink-faint); font-size: 13px; }
.board-wrap { width: min(100%, calc(100vh - 170px), 820px); min-width: 260px; aspect-ratio: 1; }
.board { display: block; width: 100%; height: 100%; filter: drop-shadow(0 2px 6px var(--shadow)); touch-action: manipulation; }
.board.playable { cursor: pointer; }
.board .wood { fill: var(--wood); stroke: var(--wood-edge); stroke-width: 1.5; }
.board .grid { stroke: var(--grid); stroke-width: 1; opacity: .8; }
.board .edge { fill: none; stroke: var(--grid); stroke-width: 1.6; }
.board .star { fill: var(--grid); }
.board .coord { fill: var(--coord); font: 500 13px var(--sans); text-anchor: middle; dominant-baseline: central; user-select: none; }
.board .shadow { fill: var(--shadow); }
.board .stone.w { stroke: rgba(0, 0, 0, .18); stroke-width: .8; }
.board .last { fill: none; stroke-width: 2.2; }
.board .last.on-b { stroke: #f1ede4; }
.board .last.on-w { stroke: #2a2a2a; }
.board .ghost { opacity: .45; pointer-events: none; }
.board .ghost.b { fill: #1a1a1a; }
.board .ghost.w { fill: #fbfaf6; }

.controls { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; font-size: 14px; color: var(--ink-soft); }
.controls label { display: flex; align-items: center; gap: 6px; }
.controls button, .controls select {
  padding: 5px 12px; border: 1px solid var(--rule); border-radius: 6px; background: var(--bg); cursor: pointer;
}
.controls button:hover:not(:disabled), .controls select:hover:not(:disabled) { border-color: var(--ink-faint); }
.controls :disabled { opacity: .45; cursor: default; }

/* waiting for the other player, or for Hobbes: a small spinner */
.spinner {
  display: inline-block; width: .85em; height: .85em; vertical-align: -.1em;
  border: 1.5px solid var(--ink-faint); border-right-color: transparent; border-radius: 50%;
  animation: spin .9s linear infinite;
}
.spinner[hidden] { display: none; }
@keyframes spin { to { transform: rotate(1turn); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

/* ---------------------------------------------------------------- the chat */

.talk {
  display: flex; flex-direction: column; min-width: 0;
  height: min(calc(100vh - 90px), 900px); position: sticky; top: 12px;
  border: 1px solid var(--rule); border-radius: 8px; background: var(--bg-soft);
}
@media (max-width: 860px) { .talk { height: auto; position: static; } .lines { max-height: 50vh; min-height: 8rem; } }
.lines { flex: 1; overflow-y: auto; padding: 12px 14px; color: var(--ink-soft); overscroll-behavior: contain; }
.lines p { margin: 0 0 .5em; overflow-wrap: anywhere; }
.lines .who { color: var(--ink-faint); font-size: 13px; }
.lines .who::after { content: ":"; }
.lines .you, .lines .them { color: var(--ink); white-space: pre-wrap; }
.lines .host { color: var(--ink); }
.lines .host + .host { margin-top: -.25em; }
.lines .note { font-size: 13px; color: var(--ink-faint); }
.lines .error { color: var(--draft); }
.lines .move { font-size: 13px; color: var(--ink-soft); }
.lines .move .stone { display: inline-block; width: .9em; height: .9em; margin-right: .4em; vertical-align: -.12em; border-radius: 50%; }
.lines .move .stone.b { background: radial-gradient(circle at 35% 30%, #6b6b6b, #111 60%); }
.lines .move .stone.w { background: radial-gradient(circle at 35% 30%, #fff, #cfc8ba); box-shadow: inset 0 0 0 .5px rgba(0, 0, 0, .3); }
.lines .aside { color: var(--ink-faint); }
.lines .typing span:last-child::after { content: "▍"; color: var(--ink-faint); }
.lines a { color: inherit; }

.form { padding: 8px 14px; border-top: 1px solid var(--rule); }
.form textarea {
  display: block; width: 100%; max-height: 30vh; padding: 6px 0; border: 0; border-bottom: 1px solid var(--ink-faint);
  background: transparent; color: var(--ink); font: 15px/22px var(--sans); resize: none; overflow-y: auto;
}
.form textarea:focus { outline: none; border-bottom-color: var(--ink-soft); }

.options {
  display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: baseline;
  padding: 0 14px 10px; font-size: 13px; color: var(--ink-faint);
}
.options[hidden] { display: none; }
.options button {
  padding: 0; border: 0; background: none; color: inherit; cursor: pointer;
  text-decoration: underline; text-decoration-color: var(--ink-faint); text-underline-offset: 3px;
}
.options button[aria-pressed="true"], .options button[data-take] { color: var(--ink-soft); }
.options button:hover { color: var(--ink); }
