/* Blindfold Chess Trainer. Mobile first; two columns from 768px.
 *
 * Colors (protan safe: blues, amber and neutrals, nothing that leans on
 * red against green):
 *   #F5F6F8 page gray, #FFFFFF panel white, #D0D7DE border gray,
 *   #1F2328 ink, #57606A muted gray,
 *   #0072B2 blue (actions, focus), #005A8C deep blue (pressed),
 *   #DCE6EE pale steel (light squares), #7B9BB5 steel blue (dark squares),
 *   #FFB000 amber (listening, notices), #FFF4D6 pale amber,
 *   #7E2954 dark magenta (errors, always with words). */

:root {
  --page: #f5f6f8;
  --panel: #ffffff;
  --border: #d0d7de;
  --ink: #1f2328;
  --muted: #57606a;
  --blue: #0072b2;
  --blue-deep: #005a8c;
  --square-light: #dce6ee;
  --square-dark: #7b9bb5;
  --amber: #ffb000;
  --amber-pale: #fff4d6;
  --error: #7e2954;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
}

a {
  color: var(--blue);
}

:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Page. */

.page-header {
  max-width: 1000px;
  margin: 0 auto;
  padding: 16px 16px 0;
}

.page-title {
  margin: 0;
  font-size: 1.5rem;
}

.page-tagline {
  margin: 4px 0 0;
  color: var(--muted);
}

.layout {
  max-width: 1000px;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  gap: 16px;
}

.panel {
  min-width: 0;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.panel-title {
  margin: 0;
  font-size: 1.25rem;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.muted {
  color: var(--muted);
}

.instructions {
  margin: 0;
  font-weight: 600;
}

.info p {
  margin: 0 0 16px;
}

.info p:last-child {
  margin-bottom: 0;
}

.credit {
  color: var(--muted);
  font-size: 0.875rem;
}

/* Controls. */

.btn {
  min-height: 44px;
  padding: 8px 16px;
  border: 2px solid var(--blue);
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary {
  background: var(--blue);
  color: #ffffff;
}

.btn-primary:hover,
.btn-primary:active {
  background: var(--blue-deep);
  border-color: var(--blue-deep);
}

.btn-secondary {
  background: var(--panel);
  color: var(--blue);
}

.btn-secondary:hover,
.btn-secondary:active {
  background: var(--square-light);
}

.text-field {
  min-height: 44px;
  padding: 8px 12px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font: inherit;
  color: var(--ink);
  background: var(--panel);
}

.move-field {
  width: 8em;
  font-size: 1.25rem;
}

.fen-field {
  flex: 1 1 16em;
  min-width: 0;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.875rem;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
}

.check input {
  width: 20px;
  height: 20px;
}

.error {
  margin: 0;
  min-height: 1.5em;
  color: var(--error);
  font-weight: 700;
}

.error:empty {
  min-height: 0;
}

.notice {
  margin: 0;
  padding: 8px 16px;
  background: var(--amber-pale);
  border-left: 4px solid var(--amber);
}

/* Board. */

.board {
  container-type: inline-size;
  width: min(100%, 480px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  aspect-ratio: 1;
  border: 2px solid var(--ink);
  user-select: none;
}

.square {
  position: relative;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.square-light {
  background: var(--square-light);
}

.square-dark {
  background: var(--square-dark);
}

.piece {
  font-size: 10cqi;
  line-height: 1;
  font-family: "Noto Sans Symbols 2", "Segoe UI Symbol", "Apple Symbols",
    "DejaVu Sans", sans-serif;
}

.piece-white {
  color: #ffffff;
  -webkit-text-stroke: 1.5px var(--ink);
  paint-order: stroke fill;
}

.piece-black {
  color: #111111;
}

.coord {
  position: absolute;
  font-size: 2.5cqi;
  font-weight: 700;
  line-height: 1;
}

.coord-rank {
  top: 4px;
  left: 4px;
}

.coord-file {
  right: 4px;
  bottom: 4px;
}

.square-light .coord {
  color: #2e4a62;
}

.square-dark .coord {
  color: #ffffff;
}

.status {
  margin: 16px 0 0;
  font-size: 1.125rem;
  font-weight: 600;
  text-align: center;
}

/* Speech input. */

.mic {
  position: relative;
  width: 160px;
  height: 160px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 2px solid var(--blue);
  border-radius: 50%;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.mic:hover {
  background: var(--square-light);
}

.mic:disabled {
  border-color: var(--border);
  background: var(--page);
  color: var(--muted);
  cursor: not-allowed;
}

.mic.mic-active {
  background: var(--amber);
  border-color: var(--ink);
}

.mic-state {
  font-weight: 600;
}

.mic-icon {
  width: 56px;
  height: 56px;
  pointer-events: none;
}

.speech-info {
  margin: 0;
  min-height: 1.5em;
  font-size: 1.125rem;
  text-align: center;
}

.speech-heard {
  margin: 0;
  min-height: 1.5em;
  color: var(--muted);
  text-align: center;
  overflow-wrap: anywhere;
}

/* Advanced. */

.advanced {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: flex-start;
}

.advanced > .stack {
  align-self: stretch;
}

.fen {
  gap: 8px;
}

.fen-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.fen-text {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.875rem;
  overflow-wrap: anywhere;
}

/* Ending. */

.ending {
  width: min(100% - 32px, 400px);
  padding: 24px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  text-align: center;
}

.ending::backdrop {
  background: rgba(31, 35, 40, 0.6);
}

.ending-title {
  margin: 0 0 8px;
  font-size: 1.5rem;
}

.ending-detail {
  margin: 0 0 24px;
  color: var(--muted);
}

.ending .row {
  justify-content: center;
}

@media (min-width: 768px) {
  .layout {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: start;
  }

  .info,
  .advanced {
    grid-column: 1 / -1;
  }

  .page-title {
    font-size: 2rem;
  }
}
