/* /demos/crdt-lab page chrome (PF-S421).
 *
 * Loaded only by this page, through Tags.PageCSS; the ?v= in PageCSSHref is the
 * whole cache-busting story. Colors come from the shared sheet's custom
 * properties (--ink, --ink-muted, --hairline, --surface, --surface-alt,
 * --accent), which css.css redeclares under both the system dark preference and
 * the explicit theme toggle — so this page follows both without a palette of
 * its own. The two status colors are the one exception, declared here with the
 * same three-way discipline.
 */

.crdt-stage {
  --crdt-ok: #1a7f37;
  --crdt-warn: #9a6700;
  margin: 1.5rem 0 2.5rem;
}

@media (prefers-color-scheme: dark) {
  .crdt-stage {
    --crdt-ok: #3fb950;
    --crdt-warn: #d29922;
  }
}

[data-theme="dark"] .crdt-stage {
  --crdt-ok: #3fb950;
  --crdt-warn: #d29922;
}

[data-theme="light"] .crdt-stage {
  --crdt-ok: #1a7f37;
  --crdt-warn: #9a6700;
}

.crdt-stage__label {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  border-left: 4px solid var(--accent);
  border-radius: 0 6px 6px 0;
  background: var(--surface-alt);
  color: var(--ink);
  font-size: 0.9rem;
}

.crdt-status {
  color: var(--ink-muted);
  font-size: 0.9rem;
  min-height: 1.4em;
}

.crdt-stage h2 {
  font-size: 1.15rem;
  margin: 1.25rem 0 0.5rem;
}

.crdt-presets__buttons,
.crdt-controls__row,
.crdt-replica__ops {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.crdt-controls__row {
  margin-bottom: 0.6rem;
}

.crdt-preset[aria-pressed="true"],
.crdt-online[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.crdt-online[aria-pressed="false"] {
  border-color: var(--crdt-warn);
  color: var(--crdt-warn);
}

.crdt-presets__shows,
.crdt-presets__next {
  margin: 0.6rem 0 0;
  color: var(--ink);
}

.crdt-check {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
}

.crdt-verdict {
  margin: 1rem 0 0.5rem;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  color: var(--ink);
  font-weight: 600;
}

.crdt-verdict.is-converged {
  border-color: var(--crdt-ok);
  color: var(--crdt-ok);
}

.crdt-expected {
  color: var(--ink);
}

.crdt-replicas {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}

@media (max-width: 860px) {
  .crdt-replicas {
    grid-template-columns: minmax(0, 1fr);
  }
}

.crdt-replica {
  padding: 0.75rem;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  min-width: 0;
}

.crdt-replica.is-offline {
  border-style: dashed;
  background: var(--surface-alt);
}

.crdt-replica__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.crdt-replica__head h3 {
  font-size: 1rem;
  margin: 0;
}

.crdt-replica p {
  margin: 0.35rem 0;
  overflow-wrap: anywhere;
}

.crdt-k {
  display: inline-block;
  min-width: 3.5rem;
  color: var(--ink-muted);
  font-size: 0.85rem;
}

.crdt-replica__ops {
  margin-top: 0.5rem;
}

.crdt-replica__ops input[type="text"] {
  flex: 1 1 8rem;
  min-width: 0;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--hairline);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
}

.crdt-valueops,
.crdt-textops {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  width: 100%;
}

.crdt-stats {
  color: var(--ink-muted);
  font-size: 0.9rem;
}

/* The scroll lives on the wrapper, which the template makes a focusable,
 * named region: a scroll container a keyboard cannot reach hides content from
 * everyone who does not use a mouse. The list inside keeps its list semantics. */
.crdt-queue-scroll {
  max-height: 16rem;
  overflow-y: auto;
}

.crdt-queue {
  margin: 0;
  padding-left: 1.25rem;
  font-size: 0.85rem;
  color: var(--ink);
}

.crdt-queue li {
  margin: 0.3rem 0;
}

.crdt-queue li.is-duplicate .crdt-msg__route {
  color: var(--crdt-warn);
}

/* Payloads WRAP rather than scroll sideways, so each one is not a scroll
 * container of its own. */
.crdt-queue code {
  display: block;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  color: var(--ink-muted);
}

.crdt-queue__empty {
  list-style: none;
  color: var(--ink-muted);
}

.crdt-types dt {
  margin-top: 0.75rem;
}
