/**
 * Styles for the shared StatGlossary explain button and its popover.
 * Pair with shared/js/stat_glossary.js.
 *
 * The button deliberately looks like a quiet question mark rather than a call to
 * action: it sits beside a number the student is already reading, and should not
 * compete with it.
 */

.stat-explain-wrap {
  position: relative;
  display: inline-block;
}

.stat-explain {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3em;
  margin-left: 0.35em;
  padding: 0.1em 0.55em;
  min-height: 1.6em;
  font: inherit;
  /* These four must come AFTER `font: inherit`, and text-transform and
     letter-spacing are not in the font shorthand at all, so they inherit
     separately. Without them the button turns bold and UPPERCASE inside a table
     header, which is exactly where the house standard puts one. */
  font-size: 0.82em;
  font-weight: 500;
  font-style: normal;
  letter-spacing: normal;
  text-transform: none;
  line-height: 1.4;
  white-space: nowrap;
  color: var(--app-accent-dark, #1a5fb4);
  background: transparent;
  border: 1px solid var(--app-border, #d6dfea);
  border-radius: 999px;
  cursor: pointer;
  vertical-align: baseline;
}

.stat-explain:hover {
  background: #eef4fc;
  border-color: var(--app-accent, #2a7de1);
}

.stat-explain:focus-visible {
  outline: 2px solid var(--app-accent, #2a7de1);
  outline-offset: 2px;
}

.stat-explain[aria-expanded='true'] {
  background: #eef4fc;
  border-color: var(--app-accent, #2a7de1);
}

.stat-explain-popover {
  position: absolute;
  z-index: 97000; /* above page chrome, below ModelProgress (97900) and dialogs */
  top: calc(100% + 0.4em);
  left: 0;
  width: min(30rem, calc(100vw - 2rem));
  max-height: 60vh;
  overflow-y: auto;
  padding: 0.9rem 1rem 0.75rem;
  /* The popover lives inside whatever element the button was placed in, so it
     inherits that element's text styling. In a table header that means bold,
     uppercase and letter-spaced body copy. */
  font-size: 1rem;
  font-weight: 400;
  font-style: normal;
  letter-spacing: normal;
  text-transform: none;
  white-space: normal;
  line-height: 1.5;
  text-align: left;
  color: var(--app-text, #1f2a37);
  background: var(--app-card-bg, #ffffff);
  border: 1px solid var(--app-border, #d6dfea);
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(31, 42, 55, 0.18);
}

.stat-explain-popover[hidden] {
  display: none;
}

.stat-explain-popover__formal {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.stat-explain-popover__aka {
  margin: 0.15rem 0 0;
  font-size: 0.82rem;
  color: var(--app-muted, #5f6b7a);
}

.stat-explain-popover__heading {
  margin: 0.8rem 0 0.2rem;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--app-muted, #5f6b7a);
}

.stat-explain-popover__body {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
}

.stat-explain-popover__technical {
  margin-top: 0.85rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--app-border, #d6dfea);
}

.stat-explain-popover__technical > summary {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--app-accent-dark, #1a5fb4);
  cursor: pointer;
}

.stat-explain-popover__technical > summary:focus-visible {
  outline: 2px solid var(--app-accent, #2a7de1);
  outline-offset: 2px;
}

.stat-explain-popover__technical .stat-explain-popover__body {
  margin-top: 0.4rem;
  font-size: 0.86rem;
  color: var(--app-muted, #5f6b7a);
}

.stat-explain-popover__textbook {
  display: inline-block;
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--app-accent-dark, #1a5fb4);
}

.stat-explain-popover__close {
  display: block;
  margin: 0.85rem 0 0 auto;
  padding: 0.25rem 0.75rem;
  font: inherit;
  font-size: 0.82rem;
  color: var(--app-muted, #5f6b7a);
  background: transparent;
  border: 1px solid var(--app-border, #d6dfea);
  border-radius: 6px;
  cursor: pointer;
}

.stat-explain-popover__close:hover {
  color: var(--app-text, #1f2a37);
  border-color: var(--app-accent, #2a7de1);
}

.stat-explain-popover__close:focus-visible {
  outline: 2px solid var(--app-accent, #2a7de1);
  outline-offset: 2px;
}

/* Near the right edge a left-anchored popover would run off screen. */
@media (max-width: 40rem) {
  .stat-explain-popover {
    left: auto;
    right: 0;
  }
}

@media print {
  .stat-explain,
  .stat-explain-popover {
    display: none !important;
  }
}
