/*
 * Workspace layout (WP04 T020; FR-005, NFR-004, contracts/workspace-layout.md).
 * The header and footer are shell.css's, the landing page landing.css's.
 *
 * Regions of .layout (app.js), in DOM order:
 *   .toolbar             the 'This game' actions (Save, Export, Share)
 *   .workspace-board     the board, its controls (<board-controls>) and the
 *                        status line
 *   .workspace-analysis  the analysis bar (depth settings), the move details
 *                        directly under it, then the evaluation graph
 *   .workspace-moves     the move list
 *
 * Grid areas
 *   >= 1100 px     toolbar over  board | analysis | moves   (the move list
 *                  sticks beside the board and scrolls inside its column)
 *   720-1099 px    toolbar over  board | analysis,  moves full width below
 *   < 720 px       one column: toolbar, board (with its controls), moves,
 *                  analysis
 * No horizontal scroll from 360 to 1920 px: every track can shrink to 0
 * (minmax(0, ...)) and nothing inside has a fixed width wider than a phone.
 */

.app {
  width: 100%;
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: var(--space-4);
  min-width: 0;
}

.app__loading {
  padding: var(--space-6) 0;
  color: var(--color-text-muted);
  text-align: center;
}

/* The disclaimer of the static loading state in index.html (before boot.js
   replaces it with the shell, whose footer carries it from then on). */
.app__loading-notice {
  color: var(--color-text-muted);
  text-align: center;
}

.layout {
  /* The visually hidden h1 is absolutely positioned: it takes no grid cell. */
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "toolbar"
    "board"
    "moves"
    "analysis";
  gap: var(--space-3);
  align-items: start;
}

.toolbar {
  grid-area: toolbar;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.workspace-board {
  grid-area: board;
  display: grid;
  justify-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.workspace-board > monolith-status-line {
  width: min(100%, 560px);
}

.workspace-analysis {
  grid-area: analysis;
  min-width: 0;
  overflow-wrap: anywhere;
}

.workspace-moves {
  grid-area: moves;
  min-width: 0;
  overflow-wrap: anywhere;
}

/* Anything interactive in the app is at least a 44 px touch target. */
.toolbar > *,
.layout button,
.layout [role="button"],
.layout [role="option"] {
  min-height: var(--touch-target);
}

@media (min-width: 720px) {
  .layout {
    grid-template-columns: minmax(0, 1fr) minmax(18rem, var(--side-panel-width));
    grid-template-areas:
      "toolbar toolbar"
      "board   analysis"
      "moves   moves";
    gap: var(--space-4);
  }
}

@media (min-width: 1100px) {
  .layout {
    /* Board up to 470 px, the moves 16-21.5rem (an annotated move needs about
       300 px), the analysis (details) the rest and at least 20rem: about
       320 px at 1100, about 400 at 1280. */
    grid-template-columns: minmax(0, 470px) minmax(20rem, 1fr) minmax(16rem, 21.5rem);
    grid-template-areas:
      "toolbar toolbar  toolbar"
      "board   analysis moves";
  }

  /* The whole list stays reachable next to the board: the column sticks
     and the list scrolls inside it. */
  .workspace-moves {
    position: sticky;
    top: var(--space-4);
    padding-inline: var(--space-3);
    --move-list-max-height: max(16rem, calc(100vh - 10rem));
  }
}

@media (max-width: 719.98px) {
  .app {
    padding: var(--space-2);
  }

  .notice {
    margin: var(--space-4) 0;
    padding: var(--space-4);
  }
}

/* Banners above the screens: update ready, a change in another tab. */
.app-banner__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.app-banner__actions button {
  min-height: var(--touch-target);
}

.app-banner:empty {
  display: none;
}

.app-banner__item {
  margin: 0 0 var(--space-4);
}

[hidden] {
  display: none !important;
}
