/* Studios: live tiles grouped by game (studios/grid.js), the hover panel and the large view
   (studios/inspector.js) (NOTES.md §11: page head, media tiles, status). A tile is a card holding
   its picture on the stage colour; the picture keeps the Studio window's own aspect ratio. */

.studios {
  --tile-min: 300px;
}
.studios[data-density='s'] {
  --tile-min: 220px;
}
.studios[data-density='l'] {
  --tile-min: 440px;
}
.studios-tools {
  flex-wrap: nowrap;
}
.wall {
  display: grid;
  gap: 32px;
}
.group {
  display: grid;
  gap: 12px;
}
.group-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
}
.group-name {
  font-size: var(--fs-15);
  font-weight: 650;
}
.group-name:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}
.group-sp {
  flex: 1;
}
.group-facts {
  display: contents;
}
.group.is-vm-offline .tiles {
  opacity: 0.85;
}
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--tile-min)), 1fr));
  gap: 14px;
}
.tiles-empty {
  padding: 18px 0;
}

/* a tile: the picture inset 6 px (radius 14 - 6 = 8), then its label strip */
.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-radius: var(--r-4);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  outline: none;
  cursor: pointer;
  transition-property: box-shadow, scale;
  transition-duration: var(--t-med);
  transition-timing-function: var(--ease);
}
.tile:hover {
  box-shadow: var(--shadow-2);
}
.tile.is-live,
.tile:focus-visible {
  box-shadow: 0 0 0 2px var(--accent), var(--shadow-2);
}
.tile:active {
  scale: 0.99;
}
.screen {
  position: relative;
  aspect-ratio: 16 / 9;
  margin: 6px 6px 0;
  overflow: hidden;
  border-radius: 8px;
  background: var(--stage);
  isolation: isolate;
}
.screen .frame,
.sv-screen .frame {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.screen .frame:not([src]),
.sv-screen .frame:not([src]) {
  visibility: hidden;
}
.screen::after,
.sv-screen::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 3;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px var(--img-outline);
  pointer-events: none;
}
/* a state over the picture: why there is no live one (opening, offline, crashed, a dialog) */
.screen-state {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: none;
  place-content: center;
  justify-items: center;
  gap: 5px;
  padding: 12px;
  background: var(--stage);
  color: #cfccc3;
  text-align: center;
}
.screen-state.is-on {
  display: grid;
}
.screen-state .t1 {
  font-size: var(--fs-14);
  font-weight: 600;
}
.screen-state .t2 {
  max-width: 34ch;
  color: #9d9a91;
  font-size: var(--fs-12);
  text-wrap: balance;
}
.screen-state[data-kind='waiting'] {
  background:
    linear-gradient(180deg, transparent 0 46%, rgba(255, 255, 255, 0.05) 50%, transparent 54%) 0 0 / 100% 220% no-repeat,
    var(--stage);
  animation: sweep 2.6s linear infinite;
}
@keyframes sweep {
  from {
    background-position:
      0 100%,
      0 0;
  }
  to {
    background-position:
      0 0%,
      0 0;
  }
}
.screen-state[data-kind='crashed'],
.screen-state[data-kind='offline'] {
  background:
    repeating-linear-gradient(135deg, oklch(0.64 0.16 var(--hue-red) / 0.08) 0 8px, transparent 8px 16px),
    var(--stage);
}
.screen-state[data-kind='crashed'] .t1,
.screen-state[data-kind='offline'] .t1 {
  color: oklch(0.76 0.13 var(--hue-red));
}
.screen-state[data-kind='blocked'] .t1,
.screen-state[data-kind='nosignal'] .t1 {
  color: oklch(0.8 0.13 var(--hue-amber));
}
.caption {
  position: absolute;
  z-index: 2;
  bottom: 6px;
  left: 6px;
  max-width: calc(100% - 26px);
  padding: 3px 8px;
  overflow: hidden;
  border-radius: 6px;
  background: rgba(20, 20, 18, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #f4f2ec;
  font: 11px/1.3 var(--font-mono);
  white-space: nowrap;
  text-overflow: ellipsis;
  opacity: 0;
  translate: 0 3px;
  transition-property: opacity, translate;
  transition-duration: 280ms;
  transition-timing-function: var(--ease-out);
  pointer-events: none;
}
.caption.is-on {
  opacity: 1;
  translate: 0 0;
}
.stale,
.live-badge {
  position: absolute;
  z-index: 2;
  top: 6px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 20px;
  padding: 0 7px;
  border-radius: 6px;
  background: rgba(20, 20, 18, 0.72);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  opacity: 0;
  transition: opacity var(--t-med) var(--ease);
  pointer-events: none;
}
.stale {
  left: 6px;
  color: oklch(0.82 0.12 var(--hue-amber));
}
.stale.is-on {
  opacity: 1;
}
.live-badge {
  right: 16px;
  color: #f4f2ec;
}
.live-badge i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: oklch(0.7 0.16 var(--hue-red));
}
.tile.is-live .live-badge {
  opacity: 1;
}
.tile.is-offline .live-badge,
.tile.is-crashed .live-badge {
  opacity: 0;
}
/* the activity meter: tool calls in the last minute */
.tile-meter {
  position: absolute;
  z-index: 2;
  top: 6px;
  right: 5px;
  bottom: 6px;
  display: flex;
  flex-direction: column-reverse;
  gap: 2px;
  width: 6px;
  padding: 1px;
  border-radius: 3px;
  background: rgba(20, 20, 18, 0.6);
}
.tile-meter i {
  flex: 1;
  border-radius: 1px;
  background: rgba(255, 255, 255, 0.08);
  transition: background-color 250ms var(--ease);
}
.tile-meter i.on {
  background: oklch(0.74 0.14 var(--hue-blue));
}
.tile-meter i.on:nth-child(n + 9) {
  background: oklch(0.8 0.13 var(--hue-amber));
}
.tile.is-offline .tile-meter,
.tile.is-crashed .tile-meter {
  opacity: 0.35;
}
.umd {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 9px 12px 11px;
}
.umd-top {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  font-size: var(--fs-13);
  white-space: nowrap;
}
.umd-code {
  flex: none;
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 650;
}
.umd-branch {
  min-width: 0;
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 550;
  text-overflow: ellipsis;
}
.umd-owner {
  flex: none;
  margin-left: auto;
  color: var(--ink-3);
  font-size: var(--fs-12);
}
.umd-tc {
  flex: none;
  color: var(--ink-4);
  font-family: var(--font-mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.umd-todo {
  overflow: hidden;
  color: var(--ink-2);
  font-size: var(--fs-12);
  white-space: nowrap;
  text-overflow: ellipsis;
}
.umd-todo.is-muted {
  color: var(--ink-4);
}
/* the main Studio's mark: ink, like the label it is */
.tile-main {
  flex: none;
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 6px;
  border-radius: var(--r-1);
  background: var(--ink);
  color: var(--bg);
  font-size: 10.5px;
  font-weight: 650;
  line-height: 1;
}
.tile:not(.is-main) .tile-main,
.tile.is-main .umd-code {
  display: none;
}
.tile.is-main .umd-branch {
  font-family: var(--font-sans);
}
.studios.is-single .umd-code {
  display: none;
}
.studios.is-single .tile.is-main .umd-branch {
  font-family: var(--font-mono);
}

/* ---------------------------------------------------------------- the hover panel */
.hover-panel {
  position: fixed;
  z-index: 40;
  width: 420px;
  max-width: calc(100vw - 16px);
  max-height: calc(100vh - 16px);
  overflow: auto;
  border-radius: var(--r-5);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  opacity: 0;
  translate: 0 4px;
  transition-property: opacity, translate;
  transition-duration: 160ms;
  transition-timing-function: var(--ease-out);
  pointer-events: none;
}
.hover-panel.is-open {
  opacity: 1;
  translate: 0 0;
  pointer-events: auto;
}
.hover-panel .insp {
  padding: 16px;
}
.insp {
  display: grid;
  gap: 14px;
  min-width: 0;
}
.insp-head {
  display: grid;
  gap: 4px;
}
.insp-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: var(--fs-15);
  font-weight: 650;
}
.insp-code {
  color: var(--ink-3);
  font-size: var(--fs-12);
}
.insp-branch {
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: var(--fs-14);
  white-space: nowrap;
  text-overflow: ellipsis;
}
.insp-sub {
  color: var(--ink-3);
  font-size: var(--fs-12);
}
.insp-label {
  color: var(--ink-3);
  font-size: var(--fs-12);
  font-weight: 650;
}
/* what it does now: blue is "an agent is on it" */
.insp-now-wrap {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border-radius: var(--r-3);
  background: var(--surface-2);
  box-shadow: inset 3px 0 0 oklch(var(--tone-dot-l) var(--tone-dot-c) var(--hue-blue));
}
.insp-now {
  font-size: var(--fs-14);
  font-weight: 560;
  text-wrap: pretty;
}
.insp-now.is-muted {
  color: var(--ink-3);
  font-weight: 400;
}
.insp-sect {
  display: grid;
  gap: 6px;
  min-width: 0;
}
.insp-h {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.insp-count,
.insp-note {
  color: var(--ink-3);
  font-size: var(--fs-12);
}
.insp-note:empty {
  display: none;
}
.act-list {
  margin: 0;
  padding: 0;
  list-style: none;
}
.act {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 8px;
  align-items: baseline;
  padding: 2px 0;
  font: 12px/1.45 var(--font-mono);
}
.act-age {
  color: var(--ink-4);
  font-size: 11px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.act-text {
  overflow: hidden;
  color: var(--ink-3);
  white-space: nowrap;
  text-overflow: ellipsis;
}
.act-text b {
  color: var(--ink);
  font-weight: 600;
}
.act[data-kind='wsync'] .act-text b {
  color: oklch(var(--tone-ink-l) var(--tone-ink-c) var(--hue-blue));
}
.act[data-kind='todo'] .act-text b {
  color: oklch(var(--tone-ink-l) var(--tone-ink-c) var(--hue-amber));
}
.act[data-kind='seat'] .act-text b {
  color: oklch(var(--tone-ink-l) var(--tone-ink-c) var(--hue-red));
}
.act[data-kind='merge'] .act-text b,
.act[data-kind='publish'] .act-text b {
  color: oklch(var(--tone-ink-l) var(--tone-ink-c) var(--hue-green));
}
.insp-media {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}
.insp-thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: var(--stage);
  cursor: zoom-in;
  transition-property: box-shadow, scale;
  transition-duration: var(--t-fast);
  transition-timing-function: var(--ease);
}
.insp-thumb::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px var(--img-outline);
  pointer-events: none;
}
.insp-thumb:hover {
  box-shadow: 0 0 0 2px var(--accent);
}
.insp-thumb:active {
  scale: 0.96;
}
.insp-thumb img,
.insp-thumb video {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.insp-thumb-blank {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #9d9a91;
  font-size: 11px;
  font-weight: 650;
}
.insp-thumb-kind {
  position: absolute;
  bottom: 3px;
  left: 3px;
  z-index: 2;
  padding: 1px 4px;
  border-radius: 4px;
  background: rgba(20, 20, 18, 0.8);
  color: #fff;
  font-size: 10px;
  font-weight: 650;
}
.insp-thumb-origin {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 2;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: oklch(0.74 0.14 var(--hue-blue));
  box-shadow: 0 0 0 1.5px rgba(20, 20, 18, 0.8);
}
.insp-thumb-origin[data-origin='viewed'] {
  background: rgba(20, 20, 18, 0.6);
  box-shadow:
    inset 0 0 0 1.5px #fff,
    0 0 0 1px rgba(20, 20, 18, 0.6);
}

/* ---------------------------------------------------------------- the large view (#sheet) */
/* index.html's #sheet is a `.sheet`; the large view turns it into a full-screen backdrop holding
   one panel: the live picture and its facts, and what the agent is doing beside it. */
#sheet.studio-view {
  inset: 0;
  left: 0;
  width: auto;
  max-height: none;
  display: grid;
  place-items: center;
  padding: 16px;
  border-radius: 0;
  background: var(--scrim);
  box-shadow: none;
  translate: none;
  transition-property: opacity;
  transition-duration: 160ms;
}
#sheet.studio-view:not(.is-open) {
  opacity: 0;
  translate: none;
}
.sv-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  width: min(1680px, 100%);
  height: min(980px, calc(100dvh - 32px));
  overflow: hidden;
  border-radius: var(--r-5);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  scale: 0.985;
  transition: scale 200ms var(--ease-out);
}
#sheet.is-open .sv-card {
  scale: 1;
}
.sv-main {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  min-height: 0;
  padding: 14px 16px 16px;
}
.sv-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.sv-umd {
  display: flex;
  flex: 1 1 260px;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-size: var(--fs-17);
  font-weight: 650;
}
.sv-umd .umd-branch {
  font-size: var(--fs-15);
}
.sv-umd:has(.tile-main) .umd-branch {
  font-family: var(--font-serif);
  font-size: var(--fs-20);
  font-weight: 450;
}
.sv-umd .umd-owner {
  margin-left: 4px;
}
.sv-actions {
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
}
.sv-screen {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  border-radius: var(--r-4);
  background: var(--stage);
}
.sv-screen .live-badge {
  top: 10px;
  right: 10px;
  opacity: 1;
}
.sv-screen .screen-state .t1 {
  font-size: var(--fs-20);
}
.sv-screen .screen-state .t2 {
  font-size: var(--fs-13);
}
.sv-foot {
  display: flex;
  align-items: flex-end;
  gap: 16px;
}
.sv-facts {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  gap: 6px 22px;
  min-width: 0;
  margin: 0;
}
.sv-facts div {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.sv-facts div.is-wide {
  flex: 1 1 220px;
}
.sv-facts dt {
  color: var(--ink-3);
  font-size: var(--fs-12);
}
.sv-facts dd {
  margin: 0;
  overflow: hidden;
  color: var(--ink-2);
  font: 12px/1.3 var(--font-mono);
  white-space: nowrap;
  text-overflow: ellipsis;
}
.sv-nav {
  display: flex;
  flex: none;
  align-items: center;
  gap: 6px;
}
.sv-pos {
  min-width: 7ch;
  color: var(--ink-3);
  font-size: var(--fs-12);
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.sv-side {
  overflow: auto;
  padding: 16px;
  background: var(--surface-2);
  box-shadow: inset 1px 0 0 var(--line);
}
.sv-side .insp-title {
  display: none;
}
.sv-side .insp-now-wrap {
  background: var(--surface);
}
.sv-side .insp-media {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 1000px) {
  .sv-card {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
    height: calc(100dvh - 24px);
  }
  .sv-side {
    max-height: 40vh;
    box-shadow: inset 0 1px 0 var(--line);
  }
}
@media (max-width: 720px) {
  .studios {
    --tile-min: 260px;
  }
  .studios-hint {
    display: none;
  }
  #sheet.studio-view {
    top: 0;
    padding: 0;
    place-items: stretch;
    border-radius: 0;
  }
  /* one scrolling column: the picture and its facts, then what the agent is doing */
  .sv-card {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100dvh;
    border-radius: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .sv-main {
    flex: none;
    padding: 10px 12px 14px;
  }
  .sv-screen {
    flex: none;
    aspect-ratio: 16 / 9;
  }
  .sv-foot {
    flex-wrap: wrap;
  }
  .sv-actions .btn .lbl {
    display: none;
  }
  .sv-side {
    flex: none;
    max-height: none;
    overflow: visible;
  }
}
