/*
  The app's frame (ADR 0294 decision 8): one navigation for every page. From 840 px a left
  sidebar; below it a bottom bar of at most five places, 56 px plus the safe-area inset. A
  focused mode (the labelling stream, Guided) hides both and shows a slim bar with the way back.
  Cmd/Ctrl-K opens the go-to palette everywhere. Tokens come from tokens.css.
*/

html {
  scroll-padding-top: var(--s4);
}

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

.uv-skip {
  position: absolute;
  left: -9999px;
  top: var(--s2);
  z-index: 100;
  padding: var(--s2) var(--s3);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  text-decoration: none;
}

.uv-skip:focus {
  left: var(--s2);
}

.uv-icon {
  width: 20px;
  height: 20px;
  flex: none;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* -- the navigation ---------------------------------------------------------------------- */

.uv-nav[hidden],
.uv-top[hidden] {
  display: none !important;
}

.uv-nav {
  position: fixed;
  z-index: 30;
  display: flex;
  font-family: var(--font-body);
}

.uv-brand {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--s2);
  color: var(--text);
  text-decoration: none;
  font-weight: 650;
  font-size: 15px;
  letter-spacing: 0.01em;
}

.uv-mark {
  width: 22px;
  height: 22px;
  flex: none;
}

.uv-items {
  display: flex;
  margin: 0;
  padding: 0;
  list-style: none;
}

.uv-item {
  display: flex;
  align-items: center;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: var(--t-body);
  font-weight: 500;
  border-radius: var(--radius);
}

.uv-item:hover {
  color: var(--text);
}

.uv-item[aria-current="page"] {
  color: var(--text);
}

.uv-count {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--waiting);
  color: var(--waiting-ink);
  font-size: var(--t-meta);
  font-weight: 600;
  line-height: 20px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.uv-kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1;
  padding: 3px 5px;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-tertiary);
}

.uv-foot {
  display: flex;
  flex-direction: column;
  gap: var(--s1);
}

.uv-search,
.uv-account {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: var(--row);
  padding: 0 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: none;
  color: var(--text-secondary);
  font: inherit;
  font-size: var(--t-body);
  cursor: pointer;
  text-align: left;
  text-decoration: none;
}

.uv-account {
  border-color: transparent;
}

.uv-search:hover,
.uv-account:hover {
  color: var(--text);
  background: var(--raised);
}

.uv-search .uv-kbd {
  margin-left: auto;
}

.uv-avatar {
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: 50%;
  background: var(--raised);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.uv-account-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Wide: the sidebar. */
@media (min-width: 840px) {
  body.uv-has-nav {
    padding-left: var(--sidebar-w);
  }

  .uv-nav {
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    flex-direction: column;
    gap: var(--s1);
    padding: var(--s4) var(--s3);
    background: var(--surface);
    border-right: 1px solid var(--border);
    overflow-y: auto;
  }

  .uv-brand {
    padding: 2px 10px var(--s4);
  }

  .uv-items {
    flex-direction: column;
    gap: 2px;
  }

  .uv-item {
    flex-direction: row;
    gap: 10px;
    height: var(--row);
    padding: 0 10px;
  }

  .uv-item:hover,
  .uv-item[aria-current="page"] {
    background: var(--raised);
  }

  .uv-item .uv-count {
    margin-left: auto;
  }

  .uv-foot {
    margin-top: auto;
    padding-top: var(--s4);
  }

  .uv-top {
    display: none;
  }
}

/* Narrow: a title bar with the page's title and search, and under it the places with their
   labels (owner, 2026-10-27: "Category nav labels should be at the top"; ADR 0305). */
@media (max-width: 839.98px) {
  :root {
    --uv-top-h: 52px;
    --uv-nav-h: var(--touch);
    --uv-head: calc(var(--uv-top-h) + var(--uv-nav-h));
  }

  html {
    scroll-padding-top: calc(var(--uv-head) + var(--s4));
  }

  .uv-nav {
    position: sticky;
    top: var(--uv-top-h);
    z-index: 24;
    height: var(--uv-nav-h);
    padding: 0 max(var(--s2), env(safe-area-inset-right)) 0 max(var(--s2), env(safe-area-inset-left));
    flex-direction: row;
    background: var(--nav-bg);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
  }

  .uv-nav .uv-brand,
  .uv-nav .uv-foot {
    display: none;
  }

  .uv-items {
    flex: 1;
    flex-direction: row;
    align-items: center;
    gap: 2px;
  }

  .uv-items > li {
    flex: 1;
    display: flex;
    min-width: 0;
  }

  .uv-item {
    flex: 1;
    flex-direction: row;
    justify-content: center;
    gap: 5px;
    height: 34px;
    min-height: 0;
    padding: 0 6px;
    border-radius: 17px;
    font-size: var(--t-meta);
    font-weight: 500;
    position: relative;
    white-space: nowrap;
  }

  .uv-item .uv-icon-wrap {
    display: flex;
    align-items: center;
  }

  .uv-item .uv-icon-wrap .uv-icon {
    width: 16px;
    height: 16px;
  }

  /* The current place: a soft pill behind it. */
  .uv-item[aria-current="page"] {
    background: var(--raised);
    color: var(--text);
  }

  .uv-item .uv-count {
    position: absolute;
    top: -2px;
    right: 2px;
    min-width: 16px;
    height: 16px;
    line-height: 16px;
    font-size: 10px;
  }

  .uv-top {
    position: sticky;
    top: 0;
    z-index: 25;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: var(--s2);
    height: var(--uv-top-h);
    padding: 0 max(var(--s4), env(safe-area-inset-right)) 0 max(var(--s4), env(safe-area-inset-left));
    background: var(--nav-bg);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
  }

  .uv-top .uv-mark {
    width: 20px;
    height: 20px;
  }

  .uv-top-title {
    flex: 1;
    min-width: 0;
    font-size: var(--t-head);
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* A page's own sticky bar sits under the shell's two. */
  body.uv-has-nav .ui-bar {
    top: var(--uv-head);
  }
}

/* Too narrow for an icon and a label in each place: the labels alone. */
@media (max-width: 379.98px) {
  .uv-item .uv-icon-wrap {
    display: none;
  }
}

.uv-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--touch);
  height: var(--touch);
  margin-right: calc(-1 * var(--s2));
  border: 0;
  border-radius: var(--radius);
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
}

.uv-icon-btn:hover {
  color: var(--text);
}

/* -- a game's tabs (Overview, Setup, Players, Stats, Data, Tools), on the app's pages and on the
   console pages that belong to a game (ADR 0305) ------------------------------------------- */

.tabs {
  display: flex;
  flex-direction: row;
  gap: var(--s1);
  margin: 0 0 var(--s4);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

/* A strip that scrolls fades at its end instead of showing a scrollbar. */
@media (max-width: 839.98px) {
  .tabs {
    mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
  }
}

.tab {
  padding: var(--s2) var(--s3);
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}

.tab:hover {
  color: var(--text);
}

.tab[aria-current="page"] {
  color: var(--text);
  border-bottom-color: var(--text);
}

.uv-game-head {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: var(--s5) var(--s5) 0;
}

.uv-game-head .uv-game-title {
  font-size: var(--t-title);
  font-weight: 650;
  letter-spacing: -0.01em;
  margin: 0 0 var(--s4);
}

/* On a phone the title bar already names the game. */
@media (max-width: 839.98px) {
  .uv-game-head {
    padding: var(--s3) var(--s4) 0;
  }

  .uv-game-head .uv-game-title {
    display: none;
  }
}

/* A console page in the shell: the shell's nav and the game's tabs replace its own close button,
   and its bar is the page's header, in the content column like the app's page titles. */
html[data-shell] #back,
html[data-shell] .ui-bar > a.ui-icon[href="/"],
html[data-shell] .top > a.back {
  display: none;
}

html[data-shell] .ui-bar {
  position: static;
  max-width: 820px;
  margin: 0 auto;
  padding: var(--s5) var(--s5) var(--s3);
  background: none;
  border: 0;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

html[data-shell] .ui-bar .ui-head {
  font-size: var(--t-title);
  font-weight: 650;
  letter-spacing: -0.01em;
}

html[data-game] .uv-game-head + .ui-bar,
html[data-game] .uv-game-head + .help {
  padding-top: 0;
}

/* The naming page fills the screen under the shell's bars and the game's tabs. */
html[data-shell] body:has(> #app.app) {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

html[data-shell] body:has(> #app.app) > #app.app {
  flex: 1;
  min-height: 0;
  height: auto;
}

@media (max-width: 839.98px) {
  html[data-shell] .ui-bar {
    padding: var(--s3) var(--s4) var(--s2);
  }

  html[data-shell] .ui-bar .ui-head {
    font-size: var(--t-head);
  }
}

/* On a phone the title bar names the page, as on the app's own pages. */
@media (max-width: 600px) {
  html[data-shell] .ui-bar .ui-head {
    display: none;
  }
}

/* -- focused mode: the labelling stream, Guided ---------------------------------------- */

body.uv-focused {
  padding: 0;
}

body.uv-focused .uv-nav,
body.uv-focused .uv-top {
  display: none;
}

.uv-focusbar {
  position: sticky;
  top: 0;
  z-index: 25;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--s2);
  min-height: 48px;
  padding: 0 max(var(--s4), env(safe-area-inset-right)) 0 max(var(--s3), env(safe-area-inset-left));
  background: var(--nav-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

body:not(.uv-focused) .uv-focusbar {
  display: none;
}

.uv-back {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: var(--s1);
  min-height: var(--touch);
  padding: 0 var(--s2) 0 var(--s1);
  border-radius: var(--radius);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: var(--t-body);
  font-weight: 500;
}

.uv-back:hover {
  color: var(--text);
  background: var(--raised);
}

.uv-focus-title {
  flex: 1;
  min-width: 0;
  font-size: var(--t-body);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.uv-focus-actions {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--s2);
}

/* -- the go-to palette ------------------------------------------------------------------- */

.uv-palette {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12vh var(--s4) var(--s4);
  background: rgba(0, 0, 0, 0.45);
}

.uv-palette[hidden] {
  display: none;
}

.uv-palette-box {
  width: min(560px, 100%);
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}

.uv-palette-input {
  height: 52px;
  padding: 0 var(--s4);
  border: 0;
  border-bottom: 1px solid var(--border);
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 16px;
  outline: none;
}

.uv-palette-list {
  margin: 0;
  padding: var(--s2);
  list-style: none;
  overflow-y: auto;
}

.uv-palette-group {
  padding: var(--s2) 10px var(--s1);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.uv-palette-option {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 0 10px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  cursor: pointer;
}

.uv-palette-option[aria-selected="true"] {
  background: var(--raised);
  color: var(--text);
}

.uv-palette-option .uv-hint {
  margin-left: auto;
  font-size: var(--t-meta);
  color: var(--text-tertiary);
}

.uv-palette-empty {
  padding: var(--s4);
  color: var(--text-tertiary);
}

@media (max-width: 839.98px) {
  .uv-palette {
    padding: env(safe-area-inset-top) 0 0;
    align-items: stretch;
  }

  .uv-palette-box {
    width: 100%;
    max-height: 80vh;
    border-radius: 0 0 var(--radius-l) var(--radius-l);
    border-top: 0;
  }
}

/* A console view drawn in the shell (ADR 0299): the shell's bars stand in for its header. */
html[data-console-hash] #shell > header {
  display: none;
}

/* -- waiting (ADR 0294): every request shows within 100 ms ------------------------------- */

/* A thin bar across the top while anything the page asked for is on its way. */
.uv-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 60;
  height: 3px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--quick);
}

.uv-progress.on {
  opacity: 1;
}

.uv-progress::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 40%;
  background: var(--action);
  animation: uv-progress 1.1s ease-in-out infinite;
}

@keyframes uv-progress {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(250%);
  }
}

/* What the wait is, once it is longer than a moment. */
.uv-slow {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + var(--s4));
  z-index: 60;
  transform: translateX(-50%);
  max-width: min(92vw, 520px);
  padding: var(--s2) var(--s4);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  background: var(--raised);
  color: var(--text);
  font-size: var(--t-body);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}

.uv-slow.stuck {
  border-color: var(--waiting);
}

/* A picture area whose next picture is on its way. */
.uv-busy-area {
  position: relative;
}

.uv-busy-area::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 5;
  width: 36px;
  height: 36px;
  margin: -18px 0 0 -18px;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: var(--action);
  border-radius: 50%;
  animation: uv-spin 0.8s linear infinite;
  pointer-events: none;
}

@keyframes uv-spin {
  to {
    transform: rotate(360deg);
  }
}

/* The button whose answer is on its way. */
.uv-pending {
  opacity: 0.6;
  cursor: progress;
}

@media (prefers-reduced-motion: reduce) {
  .uv-progress::before {
    width: 100%;
    animation: none;
    opacity: 0.6;
  }

  .uv-busy-area::after {
    animation: none;
    border-color: var(--action);
  }
}

/* -- status (owner, 2026-10-26): one set app-wide, each a colour, an icon and a word ------- */

.uv-status {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 9px 0 7px;
  border-radius: 11px;
  font-size: var(--t-meta);
  font-weight: 600;
  white-space: nowrap;
}

.uv-status-icon {
  font-size: 11px;
  line-height: 1;
}

.uv-status.you {
  background: var(--you);
  color: var(--you-ink);
}

.uv-status.queued {
  background: var(--waiting);
  color: var(--waiting-ink);
}

.uv-status.running {
  background: var(--running);
  color: var(--running-ink);
}

.uv-status.done {
  background: var(--done);
  color: var(--mint-ink);
}

.uv-status.idle {
  background: transparent;
  color: var(--text-secondary);
  box-shadow: inset 0 0 0 1px var(--border);
}

.uv-status.failed {
  background: var(--failed);
  color: var(--failed-ink);
}

.uv-status.running .uv-status-icon {
  width: 9px;
  height: 9px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  font-size: 0;
  animation: uv-spin 0.9s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
  .uv-status.running .uv-status-icon {
    animation: none;
  }
}

/* -- the next thing waiting on the owner, once a page's ask is answered (owner, 2026-10-27) -- */

.uv-next {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--s1) var(--s3);
  margin: var(--s3) var(--s4);
  padding: var(--s3) var(--s4);
  border-radius: var(--radius);
  background: var(--you);
  color: var(--you-ink);
  font-size: var(--t-body);
}

.uv-next-word {
  font-weight: 600;
}

.uv-next-link {
  color: inherit;
  font-weight: 600;
  text-decoration: underline;
  overflow-wrap: anywhere;
}

.uv-next-link::after {
  content: " →";
}

/* The slow line's Try again: the app's button, on pages without app.css too. */
.uv-slow button {
  margin-left: var(--s2);
  padding: var(--s1) var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
