/* tool-meta.css — single floating Help button + accessible modal containing
   how-to-use, formulas, assumptions, references, data provenance, related
   tools, and author info. All content lives inside the modal so we never
   inject content into the host tool's flex/grid layout. */

/* ---------- Help button (FAB, single, bottom-right) ---------- */
.tool-help-btn {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--surface2, rgba(255,255,255,0.1));
  background: var(--surface, rgba(255,255,255,0.06));
  color: var(--text, #f0f0f2);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  z-index: 950;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
  transition: transform 120ms, background 120ms;
  font-family: inherit;
}
.tool-help-btn:hover,
.tool-help-btn:focus-visible {
  background: var(--accent, #818cf8);
  color: var(--bg, #060608);
  transform: translateY(-1px);
  outline: none;
}

/* ---------- Modal ---------- */
.tool-help-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1.5rem;
}
.tool-help-modal.is-open { display: flex; }

.tool-help-panel {
  background: var(--bg, #060608);
  color: var(--text, #f0f0f2);
  border: 1px solid var(--surface2, rgba(255,255,255,0.1));
  border-radius: var(--radius, 8px);
  max-width: 640px;
  max-height: 80vh;
  overflow-y: auto;
  padding: 1.5rem;
  width: 100%;
  box-sizing: border-box;
  font-size: 0.92rem;
  line-height: 1.55;
  font-family: inherit;
}
.tool-help-panel h2 {
  margin: 0 0 1rem;
  font-size: 1.2rem;
  font-weight: 600;
}
.tool-help-panel h3 {
  margin: 1.2rem 0 0.4rem;
  font-size: 0.95rem;
  color: var(--accent, #818cf8);
  font-weight: 600;
}
.tool-help-panel p { margin: 0.4rem 0; }
.tool-help-panel ul { margin: 0.4rem 0 0.4rem 1.2rem; }
.tool-help-panel li { margin: 0.2rem 0; }

.tool-help-close {
  float: right;
  background: transparent;
  border: 1px solid var(--surface2, rgba(255,255,255,0.1));
  color: var(--muted, #6e6e80);
  border-radius: 4px;
  padding: 0.3rem 0.7rem;
  cursor: pointer;
  font-size: 0.85rem;
  min-height: 36px;
  font-family: inherit;
}
.tool-help-close:hover,
.tool-help-close:focus-visible {
  color: var(--text, #f0f0f2);
  border-color: var(--accent, #818cf8);
  outline: none;
}

/* ---------- Inline elements rendered inside the modal ---------- */
.tool-meta-formula {
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--surface2, rgba(255,255,255,0.07));
  padding: 0.4rem 0.6rem;
  border-radius: 4px;
  margin: 0.25rem 0;
  font-size: 0.88rem;
  white-space: pre-wrap;
}
.tool-meta-cite {
  color: var(--accent, #818cf8);
  text-decoration: none;
}
.tool-meta-cite:hover { text-decoration: underline; }

.tool-meta-author {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.2rem;
  margin-top: 1rem;
  padding-top: 0.8rem;
  border-top: 1px dashed var(--surface2, rgba(255,255,255,0.08));
  color: var(--muted, #6e6e80);
  font-size: 0.85rem;
}
.tool-meta-author a {
  color: var(--accent, #818cf8);
  text-decoration: none;
}
.tool-meta-author a:hover { text-decoration: underline; }

.tool-related-list {
  display: grid;
  gap: 0.5rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin: 0.25rem 0;
}
.tool-related-list a {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0.6rem 0.8rem;
  background: var(--surface2, rgba(255,255,255,0.06));
  border-radius: 6px;
  color: var(--text, #f0f0f2);
  text-decoration: none;
  font-size: 0.9rem;
  min-height: 44px;
  transition: background 120ms, color 120ms;
}
.tool-related-list a:hover,
.tool-related-list a:focus-visible {
  background: var(--accent, #818cf8);
  color: var(--bg, #060608);
  outline: none;
}
.tool-related-list a .tool-related-blurb {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.78rem;
  color: var(--muted, #6e6e80);
}
.tool-related-list a:hover .tool-related-blurb,
.tool-related-list a:focus-visible .tool-related-blurb {
  color: var(--bg, #060608);
}

/* ---------- Mobile ---------- */
@media (max-width: 768px) {
  .tool-help-btn { bottom: 0.85rem; right: 0.85rem; width: 44px; height: 44px; }
  .tool-help-panel { padding: 1.1rem; max-height: 88vh; }
}
