/*
  WEBHOOK DEMO (learn/demos/live-webhooks.md, js/webhooks.js)
  The senders on the left, the back office's inbox on the right, the polling count under
  them and the raw delivery under "Behind the scenes". Checkboxes reuse dg-check from
  diagrams.css, which the page also loads. States are is-ok (green), is-bad (red),
  is-warn (sand) and is-muted.
*/

.wh-app {
  display: grid;
  gap: 2rem;
  padding: clamp(1.25rem, 3vw, 2rem);
}
@media (min-width: 900px) {
  .wh-app { grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); align-items: start; gap: 2.5rem; }
}
.wh-side { min-width: 0; }
.wh-help { margin: 0.6rem 0 1rem; font-size: 0.9rem; color: var(--muted); }
.wh-noscript { margin: 0; font-size: 0.9rem; color: var(--muted); }

/* ---- The senders ---- */
.wh-events { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
@media (min-width: 520px) { .wh-events { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.wh-fire {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  height: 100%;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--image-border-color);
  border-radius: 12px;
  background: var(--card-solid);
  color: var(--font-color);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.wh-fire:hover:not(:disabled) { border-color: var(--primary-color); transform: translateY(-2px); }
.wh-fire:active:not(:disabled) { transform: translateY(0); }
.wh-fire:disabled { opacity: 0.55; cursor: wait; }
.wh-fire > i {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 10px;
  background: var(--navy);
  color: #fff;
}
.wh-fire b { display: block; color: var(--title-color); font-weight: 800; line-height: 1.25; }
.wh-fire small { display: block; margin-top: 0.15rem; font-size: 0.75rem; color: var(--muted); }
.wh-fire code { overflow-wrap: anywhere; }

.wh-wrong, .wh-subs { margin: 1.5rem 0 0; padding: 0; min-width: 0; border: 0; }
.wh-subs { margin-top: 1rem; }
.wh-subs code { font-size: 0.8rem; }

.wh-log-head {
  margin: 1.5rem 0 0.5rem;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.wh-log { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; font-size: 0.85rem; }
.wh-log li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.6rem;
  padding: 0.5rem 0.7rem;
  border-left: 4px solid var(--image-border-color);
  border-radius: 10px;
  background: var(--card-solid);
}
.wh-log time { color: var(--muted); font-variant-numeric: tabular-nums; }
.wh-log .is-ok { border-left-color: var(--primary-color); }
.wh-log .is-bad { border-left-color: var(--red); }
.wh-log .is-warn { border-left-color: var(--sand); }
.wh-log li.wh-empty, .wh-inbox li.wh-empty { display: block; border-left-color: transparent; color: var(--muted); }

/* ---- The back office ---- */
.wh-address {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.75rem;
  padding: 0.8rem 0.9rem;
  border-radius: 12px;
  background: var(--navy);
  color: #fff;
}
.wh-address-label { width: 100%; font-size: 0.7rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: rgb(255 255 255 / 0.7); }
.wh-address code { color: #fff; font-size: 0.85rem; overflow-wrap: anywhere; }
.wh-mode {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  background: rgb(255 255 255 / 0.12);
  font-size: 0.75rem;
  font-weight: 700;
}
.wh-mode::before { content: ""; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: rgb(255 255 255 / 0.5); }
.wh-mode.is-live::before { background: var(--primary-color); }
.wh-mode.is-simulated::before { background: var(--sand); }

.wh-inbox { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.6rem; }
.wh-item {
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--image-border-color);
  border-left: 4px solid var(--primary-color);
  border-radius: 12px;
  background: var(--card-solid);
}
.wh-item.is-bad { border-left-color: var(--red); }
.wh-item.is-warn { border-left-color: var(--sand); }
.wh-item.is-muted { border-left-color: var(--image-border-color); }
.wh-item-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.6rem; margin: 0; }
.wh-item-head i { color: var(--text-link); }
.wh-item-head b { color: var(--title-color); font-weight: 800; }
.wh-item-head time { margin-left: auto; font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.wh-pill {
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  background: var(--primary-color);
  color: var(--on-accent);
  font-size: 0.7rem;
  font-weight: 800;
}
.is-bad > .wh-item-head .wh-pill { background: var(--red); color: #fff; }
.is-warn > .wh-item-head .wh-pill { background: var(--sand); color: var(--on-accent); }
.is-muted > .wh-item-head .wh-pill { background: var(--image-border-color); color: var(--title-color); }
.wh-item-meta { margin: 0.3rem 0 0; font-size: 0.75rem; color: var(--muted); overflow-wrap: anywhere; }
.wh-did { margin: 0.5rem 0 0; padding-left: 1.1rem; font-size: 0.875rem; }
.wh-did li + li { margin-top: 0.15rem; }
@media (prefers-reduced-motion: no-preference) {
  .wh-item, .wh-log li { animation: wh-in 0.35s ease both; }
}
@keyframes wh-in { from { opacity: 0; transform: translateY(-6px); } }

/* ---- Asking versus being told ---- */
.wh-poll {
  display: grid;
  gap: 0.75rem;
  margin-top: 1.5rem;
}
@media (min-width: 640px) { .wh-poll { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.wh-poll[hidden] { display: none; }
.wh-poll p {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin: 0;
  padding: 0.9rem 1.1rem;
  border: 1px solid var(--image-border-color);
  border-radius: 16px;
  background: var(--card);
  font-size: 0.9rem;
}
.wh-poll b { min-width: 2.5ch; color: var(--error); font-size: 2rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.wh-poll p + p b { color: var(--text-link); }

/* ---- From another device, and behind the scenes ---- */
.wh-share { margin: 0.9rem 0 0; }
.wh-share code { color: var(--title-color); font-size: 0.85rem; overflow-wrap: anywhere; }
.wh-joined { margin: 0.9rem 0 0; font-size: 0.875rem; color: var(--muted); }
.wh-code {
  margin: 0.9rem 0 0;
  max-height: 360px;
  overflow: auto;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--image-border-color);
  border-radius: 12px;
  background: var(--card-solid);
  color: var(--title-color);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.wh-steps, .wh-checks { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: 0.5rem; font-size: 0.875rem; }
.wh-steps li, .wh-checks li { display: flex; gap: 0.6rem; }
.wh-steps i, .wh-checks i { margin-top: 0.2rem; color: var(--text-link); }
.wh-checks .is-bad i { color: var(--error); }
.wh-checks code { overflow-wrap: anywhere; }
.wh-relay-note {
  display: flex;
  gap: 0.75rem;
  margin: 1.5rem 0 0;
  padding: 1rem 1.1rem;
  border-radius: 14px;
  background: var(--card);
  border: 1px dashed var(--image-border-color);
  font-size: 0.9rem;
  color: var(--muted);
}
.wh-relay-note i { margin-top: 0.2rem; color: var(--text-link); }
