/* explainer.css
   Floating "What is this?" trigger plus the explanation dialog. Uses the
   shared design tokens; AA contrast on the dark theme. The trigger sits
   bottom-right, clear of #stage, so visual goldens are unaffected. */

/* Frosted pill, light text, accent dot. Matches the back button so
   the chrome reads as one system; no more black-on-gold. */
.explainer-fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9000;
  display: flex;
  align-items: center;
  gap: 8px;
  font: 500 0.8125rem/1 "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  letter-spacing: -0.005em;
  color: #c7cedd;
  background: rgba(12, 15, 26, 0.85);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 9px 16px 9px 13px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  transition: color 120ms ease, border-color 120ms ease, background 120ms ease;
}
.explainer-fab::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4f7ef7;
  box-shadow: 0 0 7px rgba(79, 126, 247, 0.8);
  flex: none;
}
.explainer-fab:hover {
  color: #e8eaf0;
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(20, 23, 40, 0.9);
}
.explainer-fab:focus-visible { outline: 2px solid #4f7ef7; outline-offset: 2px; }

.explainer-dialog {
  /* Explicit high-contrast colours, NOT page tokens: --fg resolves to a
     dark value on some playground themes and made the body unreadable. */
  border: 1px solid #2f3440;
  background: #14161c;
  color: #eef0f4;
  max-width: 720px;
  width: calc(100vw - 32px);
  border-radius: 12px;
  padding: 0;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.6);
  /* No max-height here: the dialog wraps the body exactly. The body
     alone carries the height cap and the scrollbar; capping both gave
     two scrollbars. overflow:hidden keeps the border-radius clean. */
  overflow: hidden;
}
.explainer-dialog::backdrop { background: rgba(2, 4, 8, 0.66); }

.explainer-body {
  padding: 22px 26px 28px;
  overflow-y: auto;
  max-height: 86vh;
  font-size: 15px;
  line-height: 1.62;
  color: #eef0f4;
}
.explainer-body h2 {
  margin: 0 32px 6px 0;
  font-size: 19px;
  color: #ffffff;
}
.explainer-body h3 {
  margin: 20px 0 6px;
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #ffd166;
}
.explainer-body h4 {
  margin: 18px 0 4px;
  font-size: 15.5px;
  color: #ffe49a;
}
.explainer-body h5 {
  margin: 14px 0 4px;
  font-size: 14px;
  color: #cfd3da;
}
.explainer-body p { margin: 8px 0; color: #eef0f4; }
.explainer-body p.eq { overflow-x: auto; text-align: center; margin: 12px 0; }
.explainer-body ul, .explainer-body ol { margin: 8px 0; padding-left: 22px; }
.explainer-body li { margin: 4px 0; }
.explainer-main { margin-top: 6px; }
.explainer-more {
  margin-top: 18px;
  border-top: 1px solid #2f3440;
  padding-top: 10px;
}
.explainer-more > summary {
  cursor: pointer;
  font: 600 12px/1.4 var(--font-mono, ui-monospace, monospace);
  letter-spacing: 0.04em;
  color: #9aa0a6;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.explainer-more > summary::-webkit-details-marker { display: none; }
/* Section 13: a chevron that rotates 180deg on open (CSS, 200ms). */
.explainer-more > summary::before {
  content: "\25be";
  display: inline-block;
  transition: transform 200ms ease;
  color: #6b7fa3;
}
.explainer-more[open] > summary::before { transform: rotate(180deg); }
.explainer-more > summary:hover { color: #eef0f4; }
.explainer-more[open] > summary { margin-bottom: 8px; }
/* Section 13: smooth disclosure of the hint body. */
.explainer-more-body {
  overflow: hidden;
  max-height: 0;
  transition: max-height 250ms ease;
}
.explainer-more[open] .explainer-more-body { max-height: 1400px; }
.explainer-body code {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.92em;
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 5px;
  border-radius: 4px;
}
.explainer-body pre {
  background: rgba(255, 255, 255, 0.05);
  padding: 10px 12px;
  border-radius: 6px;
  overflow-x: auto;
}
.explainer-close {
  position: absolute;
  top: 14px;
  right: 16px;
  font: 600 11px/1 var(--font-mono, ui-monospace, monospace);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--fg-muted, #9aa0a6);
  background: transparent;
  border: 1px solid var(--border, #2a2e37);
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
}
.explainer-close:hover { color: var(--fg, #e8e8ea); }

@media (prefers-reduced-motion: no-preference) {
  .explainer-dialog[open] { animation: explainer-in 0.16s ease-out; }
}
@keyframes explainer-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
