/* OBSCURA OS - live editing (live-ui.js, live-docs.js, live-sheets.js).
 *
 * The dialog takes the look of the application it opens in (Docs' or
 * Sheets' own dialog classes); this adds only what it holds: the codes, the
 * phrase, the people. Each person's colour is one of the five chart
 * colours, which every colourway sets for light and dark. */

/* ---- the button in the title bar ---- */
.lv-btn { position: relative; }
.lv-btn[data-live="live"]::after,
.lv-btn[data-live="dropped"]::after,
.lv-btn[data-live="waiting"]::after {
  content: ""; position: absolute; top: 3px; right: 3px; width: 6px; height: 6px; border-radius: 50%;
  background: var(--good);
}
.lv-btn[data-live="dropped"]::after { background: var(--warn); }
.lv-btn[data-live="waiting"]::after { background: currentColor; }

/* Sheets' title bar has no pill of its own: this is Docs' pill in Sheets'
   bar, white on its colour. */
.sh-live {
  flex: none; display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; margin-left: 6px;
  border: 1px solid color-mix(in srgb, currentColor 45%, transparent); border-radius: var(--radius-md);
  background: none; color: inherit; font: inherit; font-size: var(--text-xs); cursor: pointer;
}
.sh-live:hover { background: color-mix(in srgb, currentColor 16%, transparent); }
.sh-live:focus-visible { outline: 2px solid currentColor; outline-offset: -2px; }
.sh-live svg, .lv-btn svg { width: 16px; height: 16px; flex: none; }
/* On a phone Sheets' bar is one row that scrolls sideways (app-chrome.css):
   the name, Undo and Redo first, then the rest, this among them. */
@media (max-width: 760px) {
  body.sheets-app .sh-titlebar .sh-live { order: 3; margin-left: 0; padding: 0; width: 36px; justify-content: center; border-color: transparent; }
  .sh-live span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
@media (pointer: coarse) {
  .sh-live { min-height: 44px; min-width: 44px; }
}

/* ---- the dialog ---- */
dialog.lv-dlg { width: min(520px, calc(100vw - 24px)); }
.lv-body { display: flex; flex-direction: column; gap: 12px; overflow: auto; }
.lv-body p { margin: 0; }
.lv-lead { color: var(--ink-mid); max-width: 60ch; }
.lv-field { display: flex; flex-direction: column; gap: 4px; }
.lv-field span, .lv-step, .lv-code label {
  font-size: var(--text-2xs); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-soft);
}
.lv-field input, .lv-input, .lv-text {
  width: 100%; box-sizing: border-box; min-height: 32px; padding: 5px 8px;
  border: 1px solid var(--rule-strong); border-radius: var(--radius-sm); background: var(--paper); color: var(--ink);
  font: var(--text-xs) var(--font-ui);
}
.lv-text { font-family: var(--font-mono); font-size: var(--text-2xs); line-height: 1.35; resize: vertical; word-break: break-all; }
.lv-text[readonly] { background: var(--paper-inset); }
.lv-field input:focus-visible, .lv-input:focus-visible, .lv-text:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.lv-acts { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.lv-main { padding-top: 2px; }
.lv-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.lv-steps > li { display: flex; flex-direction: column; gap: 6px; }
.lv-code { display: flex; flex-direction: column; gap: 6px; }
.lv-phrase {
  display: inline-block; align-self: flex-start; padding: 6px 10px; border: 1px solid var(--rule-strong); border-radius: var(--radius-sm);
  background: var(--paper-inset); font: 600 var(--text-md) var(--font-mono); letter-spacing: 0.04em; user-select: all;
}
.lv-qr { align-self: flex-start; width: min(280px, 100%); height: auto; image-rendering: pixelated; border: 1px solid var(--rule); border-radius: var(--radius-sm); }
.lv-video { width: 100%; max-height: 240px; background: var(--paper-inset); border: 1px solid var(--rule); border-radius: var(--radius-sm); }
.lv-status { color: var(--ink-mid); }
.lv-status[data-state="live"] { color: var(--good); }
.lv-status[data-state="dropped"] { color: var(--warn); }
.lv-error, .lv-refused { color: var(--danger); }
.lv-people { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.lv-people li { display: flex; align-items: center; gap: 8px; min-height: 28px; padding: 2px 0; border-bottom: 1px solid var(--rule); }
.lv-swatch { flex: none; width: 12px; height: 12px; border-radius: var(--radius-sm); }
.lv-who { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lv-tag { font-size: var(--text-2xs); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-soft); }
.lv-how { border-top: 1px solid var(--rule); padding-top: 8px; color: var(--ink-mid); }
.lv-how summary { cursor: pointer; padding: 4px 0; color: var(--ink); }
.lv-how ul { margin: 6px 0 8px; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.lv-check { display: flex; align-items: center; gap: 8px; min-height: 28px; color: var(--ink); }
@media (pointer: coarse) {
  .lv-dlg button, .lv-field input, .lv-input, .lv-how summary, .lv-check { min-height: 44px; }
}

/* ---- the others' carets and selections ---- */
.lv-carets { position: fixed; inset: 0; pointer-events: none; z-index: 40; overflow: hidden; }
.lv-caret { position: absolute; width: 2px; margin-left: -1px; background: var(--lv-c); }
.lv-sel { position: absolute; background: color-mix(in srgb, var(--lv-c) 24%, transparent); }
.lv-name {
  position: absolute; left: -1px; bottom: 100%; padding: 0 4px; border-radius: var(--radius-sm) var(--radius-sm) var(--radius-sm) 0;
  background: var(--lv-c); color: var(--on-accent); font: 600 var(--text-2xs)/1.35 var(--font-ui); white-space: nowrap;
}
/* In Sheets, a box round the cell each person is on, in the grid's own
   scrolling space so it moves with the cells. */
.lv-cells { position: absolute; left: 0; top: 0; width: 0; height: 0; pointer-events: none; z-index: 6; }
.lv-cell { position: absolute; box-sizing: border-box; border: 2px solid var(--lv-c); }
.lv-range { position: absolute; background: color-mix(in srgb, var(--lv-c) 14%, transparent); }
.lv-cell .lv-name { left: -2px; bottom: calc(100% + 0px); }
