/* ============================================================
   OBExplain — self-documenting legend. Pairs with js/ob-explain.js.
   Self-scoped: everything is .obx*, plus two body-level flags
   (.obx-on, .obx-focusing) and one data attribute the control
   stamps on host elements (data-obx-s).

   NOTHING here applies until <body class="obx-on">, so a page that
   never turns it on pays zero.
   ============================================================ */

.obx-tip, .obx-panel {
  --obx-acc: var(--acc, #0F9E8E);
  --obx-crit: #C8472F;
  --obx-warn: #B7791F;
  --obx-ink: var(--ob-ink, #101720);
  --obx-muted: var(--ob-muted, #6A7482);
  --obx-faint: var(--ob-faint, #9AA3AF);
  --obx-line: var(--ob-line, #E6E9EE);
  --obx-line-soft: var(--ob-line-soft, #F0F2F5);
  font-family: inherit;
}

/* ---------- the ring ----------
   Colour = consequence, not "there is a note here". One flat colour told a worker that fifteen
   things were explainable but not which two could get them in trouble. */
[data-x] { --obx-c: #0F9E8E; --obx-a: 13%; }
[data-x][data-obx-s="crit"] { --obx-c: #C8472F; --obx-a: 15%; }
[data-x][data-obx-s="warn"] { --obx-c: #B7791F; --obx-a: 15%; }

body.obx-on [data-x] { position: relative; cursor: help; }
body.obx-on [data-x]::after {
  content: ""; position: absolute; inset: -3px; border-radius: 9px; pointer-events: none; z-index: 3;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--obx-c) 62%, transparent),
              0 0 0 6px color-mix(in srgb, var(--obx-c) var(--obx-a), transparent);
  animation: obx-pop .45s ease-out both;
}
/* Critical gets two extra beats so the eye lands there first — then it STOPS. A board that keeps
   pulsing is unusable, and it is the first thing anyone over-does. */
body.obx-on [data-x][data-obx-s="crit"]::after {
  animation: obx-pop .45s ease-out both, obx-beat 1.15s ease-in-out .45s 2;
}
@keyframes obx-pop { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } }
@keyframes obx-beat {
  0%, 100% { box-shadow: 0 0 0 2px color-mix(in srgb, var(--obx-c) 62%, transparent),
                         0 0 0 6px color-mix(in srgb, var(--obx-c) 15%, transparent); }
  50%      { box-shadow: 0 0 0 2px var(--obx-c),
                         0 0 0 9px color-mix(in srgb, var(--obx-c) 26%, transparent); }
}
body.obx-on [data-x]:hover::after {
  animation: none;
  box-shadow: 0 0 0 2px var(--obx-c), 0 0 0 7px color-mix(in srgb, var(--obx-c) 24%, transparent);
}

@media (prefers-reduced-motion: reduce) {
  body.obx-on [data-x]::after,
  body.obx-on [data-x][data-obx-s="crit"]::after { animation: none; }
}

/* Isolate one kind while a legend row is hovered. */
body.obx-on.obx-focusing [data-x]:not(.obx-match)::after { box-shadow: none; }
body.obx-on.obx-focusing [data-x]:not(.obx-match) { opacity: .4; }

/* ---------- tooltip ---------- */
.obx-tip {
  position: fixed; z-index: 2147482600; max-width: 272px; background: #101720; color: #fff;
  border-radius: 10px; padding: 9px 11px; border-left: 3px solid transparent;
  box-shadow: 0 12px 30px -8px rgba(16, 24, 40, .5);
  pointer-events: none; opacity: 0; transform: translateY(4px);
  transition: opacity .12s, transform .12s;
}
.obx-tip.show { opacity: 1; transform: none; }
.obx-tip[data-obx-s="crit"] { border-left-color: #E4705C; }
.obx-tip[data-obx-s="warn"] { border-left-color: #D9A441; }
.obx-tip .t { font-size: 12px; font-weight: 700; margin-bottom: 3px; display: flex; align-items: center; gap: 6px; }
.obx-tip .d { font-size: 11.5px; line-height: 1.5; color: #CBD3DE; }
.obx-tip .tag {
  margin-left: auto; font-size: 9px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  padding: 2px 6px; border-radius: 5px; background: rgba(255, 255, 255, .13); color: #fff;
}
.obx-tip[data-obx-s="crit"] .tag { background: rgba(228, 112, 92, .25); color: #FFC7BC; }
.obx-tip[data-obx-s="warn"] .tag { background: rgba(217, 164, 65, .22); color: #F5D79B; }

/* ---------- panel ---------- */
.obx-panel {
  position: fixed; right: 18px; bottom: 18px; width: 308px; max-height: 76vh; z-index: 2147482500;
  background: #fff; border: 1px solid var(--obx-line); border-radius: 15px; overflow: hidden;
  box-shadow: 0 18px 44px -12px rgba(17, 19, 34, .26), 0 5px 14px -6px rgba(17, 19, 34, .10);
  display: flex; flex-direction: column; color: var(--obx-ink);
  transform: translateY(12px) scale(.98); opacity: 0; pointer-events: none;
  transition: all .16s cubic-bezier(.2, .8, .3, 1);
}
body.obx-on .obx-panel { transform: none; opacity: 1; pointer-events: auto; }

.obx-ph { display: flex; align-items: center; gap: 8px; padding: 12px 13px; border-bottom: 1px solid var(--obx-line-soft); }
.obx-ph .bi { color: var(--obx-acc); }
.obx-ph .ti { font-size: 12.5px; font-weight: 700; flex: 1; }
.obx-ph .x {
  width: 24px; height: 24px; border: 0; background: transparent; border-radius: 7px; cursor: pointer;
  color: var(--obx-faint); display: inline-flex; align-items: center; justify-content: center; font-size: 11px;
}
.obx-ph .x:hover { background: var(--obx-line-soft); color: var(--obx-ink); }

.obx-pb { overflow-y: auto; padding: 6px; }
.obx-grp {
  font-size: 9.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  color: var(--obx-faint); padding: 9px 8px 5px;
}
.obx-grp.crit { color: var(--obx-crit); }
.obx-grp.crit::before {
  content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--obx-crit); margin-right: 6px; vertical-align: middle;
}

.obx-row {
  --obx-c: #0F9E8E;
  display: flex; align-items: flex-start; gap: 10px; padding: 7px 8px; border-radius: 9px;
  cursor: pointer; transition: background .12s; border-left: 3px solid transparent;
}
.obx-row[data-obx-s="crit"] { --obx-c: #C8472F; border-left-color: color-mix(in srgb, var(--obx-c) 55%, #fff); }
.obx-row[data-obx-s="warn"] { --obx-c: #B7791F; border-left-color: color-mix(in srgb, var(--obx-c) 45%, #fff); }
.obx-row:hover, .obx-row.act { background: color-mix(in srgb, var(--obx-c) 9%, #fff); border-left-color: var(--obx-c); }
.obx-row .ky { flex: none; width: 22px; display: flex; justify-content: center; padding-top: 2px; }
.obx-row .tx { min-width: 0; }
.obx-row .nm { font-size: 12px; font-weight: 650; line-height: 1.3; }
.obx-row .ds { font-size: 11px; color: var(--obx-muted); line-height: 1.45; margin-top: 2px; }
.obx-row .n {
  margin-left: auto; font-size: 10px; color: var(--obx-faint); padding-top: 2px;
  font-family: var(--mono, "JetBrains Mono", monospace);
}

.obx-pf { padding: 9px 13px; border-top: 1px solid var(--obx-line-soft); font-size: 11px; color: var(--obx-faint); }
.obx-pf .k { display: inline-flex; align-items: center; gap: 5px; margin-right: 9px; }
.obx-pf .k .d { width: 7px; height: 7px; border-radius: 50%; background: var(--obx-acc); display: inline-block; }
.obx-pf .k .d.crit { background: var(--obx-crit); }
.obx-pf .k .d.warn { background: var(--obx-warn); }
.obx-pf .hint { margin-top: 5px; }

/* ---------- swatches ---------- */
.obx-sw-dot  { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.obx-sw-bar  { width: 14px; height: 10px; border-radius: 3px; display: inline-block; }
.obx-sw-edge { width: 4px; height: 16px; border-radius: 2px; display: inline-block; }

/* ---------- the toggle button (host-styled, this is just the "on" state) ---------- */
.obx-btn.on { background: var(--acc, #0F9E8E); border-color: var(--acc, #0F9E8E); color: #fff; }
.obx-btn.on:hover { color: #fff; }

@media (max-width: 640px) {
  .obx-panel { right: 10px; left: 10px; width: auto; bottom: 10px; max-height: 62vh; }
}
