/* The ofp hub tool page: two step-through explanations (events and webhooks, the evidence log) above the
   page text. Scoped under .pa. The script sets classes per step; the motion itself is CSS. */

.pa {
  --t-bg:   #0d1126;
  --t-fg:   #d4dbe8;
  --t-dim:  #7d88a6;
  --t-key:  #8fb3ff;
  --t-str:  #a6e3c4;
  --t-num:  #f5b544;
  --t-ok:   #4ade80;
  --t-bad:  #f87171;
  --t-size: clamp(0.66rem, 1vw, 0.8rem);
}

/* ── Hero ── */
.pa-hero { padding: 4.5rem 0 3.5rem; border-bottom: 2px solid var(--teal); }
.pa-title {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: clamp(3rem, 7.5vw, 5.2rem);
  line-height: 1;
  letter-spacing: -0.04em;
  color: var(--heading);
}
.pa-title::after {
  content: "";
  display: inline-block;
  width: 0.45em; height: 0.08em; margin-left: 0.08em;
  background: var(--teal);
  animation: pa-cursor 1.1s steps(1) infinite;
}
@keyframes pa-cursor { 50% { opacity: 0; } }
.pa-lede { margin-top: 1.3rem; max-width: 60ch; font-size: clamp(1.05rem, 1.5vw, 1.2rem); line-height: 1.55; color: var(--fg); }
.pa-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.8rem; }

/* ── Sections ── */
.pa-section { padding: 4.5rem 0 0; }
.pa-h2 { font-size: clamp(1.45rem, 2.4vw, 1.9rem); font-weight: 700; line-height: 1.2; color: var(--heading); }
.pa-intro { margin-top: 0.8rem; max-width: 66ch; color: var(--fg-dim); }
.pa-note { margin-top: 1.6rem; max-width: 66ch; font-size: 0.92rem; color: var(--fg-muted); }
.pa-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: 2.5rem;
  margin-top: 2.2rem;
  align-items: start;
}
.pa-stage { position: sticky; top: calc(var(--nav-h) + 1.5rem); min-width: 0; }

/* ── Panel: the explaining text and the code under the diagram ── */
.pa-panel {
  margin-top: 1.2rem;
  padding: 0.9rem 1.1rem;
  min-height: 11.5rem;
  background: var(--t-bg);
  color: var(--t-fg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.pane { display: none; }
.pane.is-on { display: block; animation: pa-fade 0.35s ease; }
.pane-say { font-size: 0.92rem; line-height: 1.5; margin-bottom: 0.6rem; }
.pane-say[data-only] { display: none; }
.pane-say[data-only].is-on { display: block; }
.pane pre {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--t-size);
  line-height: 1.6;
  white-space: pre;
  overflow-x: auto;
  background: none;
  border: 0;
  padding: 0;
}
.c-k { color: var(--t-key); } .c-s { color: var(--t-str); } .c-n { color: var(--t-num); }
.c-ok { color: var(--t-ok); font-weight: 600; } .c-bad { color: var(--t-bad); font-weight: 600; } .c-dim { color: var(--t-dim); }
@keyframes pa-fade { from { opacity: 0; } to { opacity: 1; } }

/* ── Webhook pipeline ── */
.wh-pipe {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 2.2rem minmax(0, 1fr) 2.2rem minmax(0, 1fr) 2.2rem minmax(0, 1fr);
  align-items: center;
}
.wh-node {
  display: grid;
  gap: 0.15rem;
  padding: 0.75rem 0.6rem;
  text-align: center;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-dark);
  transition: border-color 0.25s, background 0.25s;
}
.wh-node b { font-size: 0.9rem; color: var(--heading); font-weight: 600; }
.wh-node small { font-size: 0.75rem; color: var(--fg-muted); }
.wh-node.is-on { border-color: var(--blue); background: var(--blue-opacity-subtle); }
.wh-node.is-bad { border-color: var(--red); background: color-mix(in srgb, var(--red) 12%, transparent); }
.wh-node.is-bad small { color: var(--red); font-weight: 600; }
.wh-node.is-good { border-color: var(--green); background: color-mix(in srgb, var(--green) 12%, transparent); }
.wh-node.is-good small { color: var(--green); font-weight: 600; }

.wh-link { position: relative; height: 2px; background: var(--border); }
.wh-link i {
  position: absolute; top: -4px; left: 0;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--sky);
  opacity: 0;
}
.wh-link.is-go i { animation: pa-travel 0.75s ease-in-out forwards; }
.wh-link.is-back i { animation: pa-travel-back 0.75s ease-in-out forwards; }
.wh-link.is-go, .wh-link.is-back { background: var(--blue); }
@keyframes pa-travel { from { left: 0; opacity: 1; } to { left: calc(100% - 10px); opacity: 1; } }
@keyframes pa-travel-back { from { left: calc(100% - 10px); opacity: 1; } to { left: 0; opacity: 1; } }

.wh-tries { list-style: none; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0.4rem; margin-top: 0.4rem; }
.wh-tries li {
  display: grid; justify-items: center; gap: 0.2rem;
  padding: 0.5rem 0.2rem;
  border: 1px solid #2a3560; border-radius: 6px;
  font-family: var(--font-mono); font-size: 0.75rem; color: var(--t-dim);
}
.wh-tries li b { font-size: 0.9rem; color: var(--t-fg); }
.wh-tries li.is-fail { border-color: var(--t-bad); color: var(--t-bad); }
.wh-tries li.is-wait { border-color: var(--t-num); color: var(--t-num); }
.wh-tries li.is-ok { border-color: var(--t-ok); color: var(--t-ok); }

/* ── Evidence chain ── */
.ev-chain { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1.1rem; }
.ev-link {
  position: relative;
  display: grid; gap: 0.2rem;
  padding: 0.7rem 0.7rem 0.6rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-dark);
  min-width: 0;
  transition: border-color 0.25s, background 0.25s, opacity 0.4s, transform 0.4s;
}
/* the chain between links */
.ev-link + .ev-link::before {
  content: ""; position: absolute; left: -1.1rem; top: 50%;
  width: 1.1rem; height: 2px; background: var(--border);
}
.ev-seq { font-family: var(--font-mono); font-size: 0.75rem; color: var(--fg-muted); }
.ev-link b { font-size: 0.8rem; font-weight: 600; color: var(--heading); }  /* breaks only at the <wbr> after "." and "_" */
.ev-link small { font-size: 0.75rem; color: var(--fg-dim); }
.ev-h { font-family: var(--font-mono); font-size: 0.72rem; color: var(--blue); }
.ev-new { opacity: 0; transform: translateX(12px); }
.ev-new.is-shown { opacity: 1; transform: none; }
.ev-link.is-seal { animation: pa-seal 0.5s ease forwards; animation-delay: calc(var(--i, 0) * 0.28s); }
.ev-link.is-bad { border-color: var(--red); background: color-mix(in srgb, var(--red) 10%, transparent); }
.ev-link.is-bad .ev-h { color: var(--red); }
.ev-link.is-redone .ev-h { color: var(--amber); }
@keyframes pa-seal { 50% { border-color: var(--blue); background: var(--blue-opacity-muted); } to { border-color: var(--blue); } }

.ev-anchor {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.4rem 1rem;
  margin-top: 1rem;
  padding: 0.6rem 0.8rem;
  border: 1.5px dashed var(--border-hover);
  border-radius: var(--radius-md);
  font-size: 0.82rem; color: var(--fg-dim);
  transition: border-color 0.25s, background 0.25s;
}
.ev-anchor code { font-family: var(--font-mono); color: var(--fg); }
.ev-anchor.is-bad { border-color: var(--red); border-style: solid; background: color-mix(in srgb, var(--red) 10%, transparent); }

/* ── Steps and controls (as on the ofp page) ── */
.pa-controls { display: flex; gap: 0.5rem; margin-top: 1rem; }
.pa-ctl {
  font: inherit; font-size: 0.85rem;
  padding: 0.4rem 1rem;
  color: var(--sky);
  background: var(--blue-opacity-subtle);
  border: 1px solid var(--blue-opacity-light);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.pa-ctl:hover { background: var(--blue-opacity-muted); }
.pa-ctl:disabled { opacity: 0.45; cursor: default; }
.pa-ctl:focus-visible, .pa-step:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.pa-steps { list-style: none; counter-reset: step; display: grid; gap: 0.35rem; }
.pa-steps li { counter-increment: step; }
.pa-step {
  display: grid; grid-template-columns: 2rem 1fr; column-gap: 0.75rem;
  width: 100%; padding: 0.7rem 0.8rem;
  text-align: left; font: inherit; color: var(--fg-dim);
  background: transparent; border: 0; border-left: 2px solid var(--border);
  cursor: pointer;
}
.pa-step::before { content: counter(step); grid-row: span 2; font-family: var(--font-mono); font-weight: 600; color: var(--fg-muted); }
.pa-step b { color: var(--fg); font-weight: 600; }
.pa-step span { font-size: 0.92rem; line-height: 1.55; }
.pa-step code { font-family: var(--font-mono); font-size: 0.85em; }
.pa-step:hover { background: var(--blue-opacity-faint); }
.pa-steps li.is-on .pa-step { border-left-color: var(--blue); background: var(--blue-opacity-subtle); }
.pa-steps li.is-on .pa-step::before { color: var(--blue); }
.pa-steps li.is-on .pa-step b { color: var(--heading); }

/* Without the script: the steps are a list and the stages are hidden. */
.pa:not(.has-js) .pa-stage { display: none; }
.pa:not(.has-js) .pa-grid { grid-template-columns: minmax(0, 1fr); }
.pa:not(.has-js) .pa-step { cursor: default; }

.pa-text { margin-top: 4rem; padding-top: 0.5rem; border-top: 2px solid var(--teal); }

/* ── Narrow screens ── */
@media (max-width: 960px) {
  .pa-grid { grid-template-columns: minmax(0, 1fr); }
  .pa-stage { position: static; }
}
@media (max-width: 700px) {
  .wh-pipe { grid-template-columns: minmax(0, 1fr); gap: 0; justify-items: center; }
  .wh-node { width: min(100%, 18rem); }
  .wh-link { width: 2px; height: 1.6rem; }
  .wh-link i { left: -4px; top: 0; }
  @keyframes pa-travel { from { top: 0; opacity: 1; } to { top: calc(100% - 10px); opacity: 1; } }
  @keyframes pa-travel-back { from { top: calc(100% - 10px); opacity: 1; } to { top: 0; opacity: 1; } }
  .ev-chain { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ev-link:nth-child(3)::before { display: none; }
  .wh-tries { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  .pa-title::after { animation: none; }
  .wh-link i { display: none; }
  .ev-link.is-seal { animation: none; border-color: var(--blue); }
  .pane.is-on { animation: none; }
  .ev-new, .ev-link, .wh-node { transition: none; }
}
