/* Moved out of app.css as it was, rule for rule and in the same order (#547), so the picker can
   choose this file's specs: Narrow screens' menus and dialogs, then screen-reader-only text and the hold-Back ring (the last
   rules of app.css).
   index.html loads it right after tessellate-hud.css, where these rules stood. */

/* ------------------------------------------------------------ narrow screens (#70, #72)
   Less than 36 lines of text wide (data-fit='narrow', js/layout.ts: a phone, a small tablet, a
   split window, or 200 % text on a TV), the menus and dialogs must fit the width: labels go
   above their buttons, chips wrap, panels and dialogs use the whole width, and headings get
   smaller. The text size setting is kept as chosen; only the layout gives way. */
:root[data-fit='narrow'] .menu {
  gap: 0.6em;
  padding: 2.4em 0.5em 1.6em;
}

:root[data-fit='narrow'] .menu h1 {
  font-size: 2.2em;
}

:root[data-fit='narrow'] .menu h2 {
  font-size: 1.4em;
}

:root[data-fit='narrow'] .menu.wide .columns,
:root[data-fit='narrow'] .panel {
  width: 100%;
}

:root[data-fit='narrow'] .panel {
  padding: 0.5em 0.7em;
}

:root[data-fit='narrow'] .row {
  gap: 0.4em;
}

:root[data-fit='narrow'] .row-note,
:root[data-fit='narrow'] .sg-map-about {
  padding-inline-start: 0;
}

:root[data-fit='narrow'] .row > .label {
  flex: 1 1 100%;
  min-width: 0;
}

:root[data-fit='narrow'] .chip {
  flex-wrap: wrap;
  max-width: 100%;
  text-align: start;
}

:root[data-fit='narrow'] .big {
  gap: 0.5em;
  padding: 0.6em 0.8em;
  font-size: 1.05em;
}

:root[data-fit='narrow'] .actions {
  gap: 0.5em;
}

:root[data-fit='narrow'] .btn {
  padding: 0.55em 1em;
}

:root[data-fit='narrow'] .pg-dialog {
  min-width: 0;
  width: 94vw;
  max-width: 94vw;
  max-height: 92vh;
  overflow-y: auto;
  padding: 1em 0.9em;
  /* Opaque: on a small screen the HUD behind would show through the text. */
  background: var(--bg);
}

:root[data-fit='narrow'] .pg-dialog h2 {
  font-size: 1.4em;
}

:root[data-fit='narrow'] .lobby-body {
  flex-direction: column;
  align-items: center;
  gap: 0.6em;
}

:root[data-fit='narrow'] .lobby-qr .qr {
  width: 8em;
  height: 8em;
}

:root[data-fit='narrow'] .lobby-link b {
  word-break: break-all;
}

:root[data-fit='narrow'] .pg-table {
  font-size: max(var(--fs-small), 0.85em);
}

/* Headings and names break between words, never inside one ("Plac/e", "Pyra/mid" at 320 px,
   #322): a table wider than the screen scrolls in its box (.results-table, .tstand-box). */
:root[data-fit='narrow'] .pg-table th,
:root[data-fit='narrow'] .pg-table td {
  padding-inline-start: 0.2em;
  padding-inline-end: 0.2em;
}

:root[data-fit='narrow'] .lobby-cover {
  width: auto;
  min-height: 0;
  align-self: stretch;
}

:root[data-fit='narrow'] .lobby-code-row {
  justify-content: center;
}

:root[data-fit='narrow'] .lobby-code {
  font-size: 2.4em;
}

/* ------------------------------------------------------------ screen readers only */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* "Describe the board" (#70): unseen until it has the focus (Tab, or a screen reader moving to
   it), then a small HUD pill top left; the I key does the same while playing. */
.board-describe:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.board-describe:focus {
  position: fixed;
  inset-inline-start: calc(var(--sa-s) + 12px);
  top: calc(var(--sa-t, 0px) + 12px);
  z-index: 30;
  padding: 0.45em 0.9em;
  border-radius: 0.9em;
  background: var(--ui);
  border: 2px solid var(--ui-text);
  color: var(--ui-text);
  font: inherit;
  font-weight: 800;
  white-space: nowrap;
  max-width: calc(100vw - var(--sa-l, 0px) - var(--sa-r, 0px) - 24px);
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: auto;
}

/* No keyboard on a touch screen: no I key on the pill; small phones get the small text size. */
@media (pointer: coarse) {
  .board-describe kbd {
    display: none;
  }
}

@media (max-width: 599px) and (orientation: portrait) {
  .board-describe:focus {
    font-size: var(--fs-small);
  }
}

/* ------------------------------------------------------------ hold Back to leave (#72 should 23) */

/* The ring fills with --hold (0…1, set by C# each frame while Ⓑ, Esc or a phone's Ⓑ is held). */
.hold-ring {
  position: fixed;
  left: 50%;
  /* Low on the screen, over the match's hint bar (none on the pause menu: Quit fills there). */
  bottom: calc(3vh + var(--safe-bottom, 0px));
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 0.7em;
  max-width: min(92vw, 34em);
  padding-block: 0.6em;
  padding-inline: 0.6em 1.1em;
  border-radius: 2.4em;
  background: var(--ui);
  border: 2px solid var(--ui-line);
  box-shadow: 0 0.4em 1.6em var(--shadow);
  transform: translateX(-50%);
  pointer-events: none;
  animation: hold-ring-in 0.15s ease-out both;
}

/* A game's first play: its code is on its way (#174; js/games.ts). Shown only when it takes a
   moment (App.GameLoad.cs), high on the screen, clear of the hold ring and the hint bar. */
.loading-line {
  position: fixed;
  left: 50%;
  top: calc(2.5vh + var(--safe-top, 0px));
  z-index: 60;
  max-width: min(92vw, 30em);
  padding: 0.5em 1.1em;
  border-radius: 2em;
  background: var(--ui);
  color: var(--ui-text);
  font-size: max(var(--fs-small), 0.95em);
  font-weight: 700;
  transform: translateX(-50%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.loading-line.shown {
  opacity: 1;
}

.hold-ring-dial {
  position: relative;
  flex: none;
  width: 3.2em;
  height: 3.2em;
}

.hold-ring-dial svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.hold-ring-dial circle {
  fill: none;
  stroke-width: 5;
}

.hold-ring-track {
  stroke: var(--ui-key);
}

.hold-ring-fill {
  stroke: var(--warn);
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: calc(1 - var(--hold, 0));
}

.hold-ring-glyph {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.hold-ring-glyph .pb,
.hold-ring-glyph kbd {
  margin: 0;
}

.hold-ring-text {
  font-weight: 800;
}

@keyframes hold-ring-in {
  from {
    opacity: 0;
    transform: translateX(-50%) scale(0.85);
  }
}

/* A phone or small screen on its side: the waiting room's buttons fill the bottom, so the ring
   docks at the top (on the pause menu the Quit button fills instead of the ring). */
@media (max-height: 500px) {
  .hold-ring {
    top: calc(2vh + var(--safe-top, 0px));
    bottom: auto;
  }
}

.reduced-motion .hold-ring {
  animation: none;
}

.high-contrast .hold-ring {
  background: var(--bg);
  border-color: var(--ui-text);
}

/* Team membership remains readable without colour, beside every shape. */
.board-team {
  position: absolute;
  display: inline-grid;
  place-items: center;
  inline-size: 1.4em;
  block-size: 1.4em;
  border: 0.1em solid var(--ui-text);
  border-radius: 50%;
  background: var(--ui-card);
  color: var(--ui-text);
  font-size: var(--fs-small);
  font-weight: 900;
  line-height: 1;
  pointer-events: none;
}
.sg-label > .board-team {
  position: static;
  margin-inline-start: 0.3em;
}
