/* =============================================================================
 * Marketing Engine — Glossary (styles)
 *
 * All selectors namespaced under .gloss-* to avoid collisions with the host
 * page's own CSS. Reads CSS variables from the host page when available so the
 * popover/modal themes itself to whatever page it's loaded on.
 *
 * Mission Metrics™ palette (brands/mission-metrics-solutions/brand.json):
 *   primary      #1EB980   Impact Green
 *   primaryDark  #17A06D
 *   dark         #0B2343   Deep Navy
 *   light        #F4F7FA   Cloud
 * Fonts: Inter, system-ui, sans-serif.
 *
 * If the host page defines --green / --navy / --cloud (studio.html does), those
 * win via the var() fallback chain.
 * =============================================================================
 */

:root {
  --gloss-accent: #1EB980;
  --gloss-accent-dark: #17A06D;
  --gloss-navy: #0B2343;
  --gloss-bg: #FFFFFF;
  --gloss-fg: #16233A;
  --gloss-muted: #6B7C93;
  --gloss-border: #E5E7EB;
  --gloss-border-soft: rgba(11, 35, 67, 0.06);
  --gloss-code-bg: #F4F7FA;
  --gloss-chip-bg: rgba(30, 185, 128, 0.10);
  --gloss-foot-bg: rgba(11, 35, 67, 0.02);
  --gloss-font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ───── Inline term + badge ────────────────────────────────────────────── */

.gloss-term {
  display: inline;
  font-weight: inherit;
}

.gloss-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin: 0 1px 0 3px;
  padding: 0;
  vertical-align: 1px;
  border: 1px solid currentColor;
  border-radius: 50%;
  background: transparent;
  color: var(--green, var(--gloss-accent));
  font: 700 10px/1 var(--gloss-font);
  cursor: pointer;
  opacity: 0.55;
  transition: all 0.15s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.gloss-badge:hover,
.gloss-badge:focus-visible {
  opacity: 1;
  background: var(--green, var(--gloss-accent));
  color: #fff;
  outline: none;
}
.gloss-badge:focus-visible {
  box-shadow: 0 0 0 2px rgba(30, 185, 128, 0.28);
}

/* ───── Popover (anchored to badge) ────────────────────────────────────── */

.gloss-popover {
  width: 360px;
  max-width: calc(100vw - 16px);
  max-height: min(480px, calc(100vh - 80px));
  overflow-y: auto;
  background: var(--gloss-bg);
  color: var(--gloss-fg);
  border: 1px solid var(--gloss-border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(11, 35, 67, 0.20),
              0 2px 8px rgba(11, 35, 67, 0.08);
  font: 13px/1.55 var(--gloss-font);
  z-index: 10000;
  animation: glossFadeIn 0.15s ease;
}
@keyframes glossFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Mobile bottom sheet */
.gloss-popover-mobile {
  position: fixed !important;
  left: 0 !important;
  right: 0 !important;
  top: auto !important;
  bottom: 0 !important;
  width: 100vw !important;
  max-width: 100vw;
  max-height: 80vh;
  border-radius: 14px 14px 0 0;
  border-bottom: 0;
  box-shadow: 0 -8px 32px rgba(11, 35, 67, 0.28);
  animation: glossSlideUp 0.2s ease;
}
@keyframes glossSlideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

/* Popover sections */
.gloss-pop-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--gloss-border);
  background: linear-gradient(135deg, rgba(30, 185, 128, 0.07), rgba(11, 35, 67, 0.03));
}
.gloss-pop-title {
  margin: 0;
  font: 700 14px/1.35 var(--gloss-font);
  color: var(--gloss-navy);
}
.gloss-pop-abbr {
  font-weight: 500;
  color: var(--gloss-muted);
  font-size: 12px;
}

.gloss-close,
.gloss-modal-close {
  flex: 0 0 auto;
  background: transparent;
  border: 0;
  font: 400 22px/1 var(--gloss-font);
  cursor: pointer;
  padding: 0 2px;
  color: var(--gloss-muted);
  margin: -4px -2px -4px 0;
}
.gloss-close:hover,
.gloss-modal-close:hover {
  color: var(--gloss-fg);
}

.gloss-pop-short {
  padding: 12px 14px;
  font-weight: 500;
  color: var(--gloss-fg);
}

.gloss-pop-section {
  padding: 10px 14px;
  border-top: 1px solid var(--gloss-border-soft);
}
.gloss-pop-label {
  font: 700 10px/1 var(--gloss-font);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--gloss-accent-dark);
  margin-bottom: 5px;
}
.gloss-pop-body {
  color: var(--gloss-fg);
  font-size: 13px;
  line-height: 1.55;
}

.gloss-pop-foot {
  padding: 12px 14px;
  border-top: 1px solid var(--gloss-border);
  text-align: right;
  background: var(--gloss-foot-bg);
}
.gloss-more {
  background: var(--gloss-accent);
  color: #fff;
  border: 0;
  padding: 7px 14px;
  border-radius: 8px;
  font: 700 12px/1 var(--gloss-font);
  cursor: pointer;
  transition: filter 0.15s ease;
}
.gloss-more:hover { filter: brightness(1.08); }
.gloss-more:active { filter: brightness(0.95); }

/* ───── Modal (full detail, centered) ──────────────────────────────────── */

.gloss-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 35, 67, 0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10001;
  padding: 16px;
  animation: glossFadeIn 0.18s ease;
}

.gloss-modal {
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--gloss-bg);
  color: var(--gloss-fg);
  border-radius: 16px;
  box-shadow: 0 24px 80px rgba(11, 35, 67, 0.38),
              0 4px 16px rgba(11, 35, 67, 0.14);
  font: 14px/1.6 var(--gloss-font);
}

.gloss-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  padding: 22px 24px 16px;
  border-bottom: 1px solid var(--gloss-border);
  background: linear-gradient(135deg, rgba(30, 185, 128, 0.08), rgba(11, 35, 67, 0.03));
  border-radius: 16px 16px 0 0;
}
.gloss-modal-title {
  margin: 0;
  font: 800 22px/1.25 var(--gloss-font);
  letter-spacing: -0.01em;
  color: var(--gloss-navy);
}
.gloss-modal-abbr {
  font-weight: 500;
  font-size: 17px;
  color: var(--gloss-muted);
}

.gloss-modal-body {
  padding: 18px 24px 24px;
}
.gloss-modal-short {
  margin: 0 0 18px;
  font-weight: 500;
  font-size: 15px;
  color: var(--gloss-fg);
}
.gloss-modal-section {
  margin: 18px 0;
}
.gloss-modal-section h4 {
  margin: 0 0 6px;
  font: 700 11px/1 var(--gloss-font);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--gloss-accent-dark);
}
.gloss-modal-section p,
.gloss-modal-section .gloss-modal-cat {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
}

.gloss-math {
  background: var(--gloss-code-bg);
  padding: 14px 16px;
  border-radius: 10px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  white-space: pre-wrap;
  margin: 0;
  border: 1px solid var(--gloss-border);
  color: var(--gloss-fg);
  overflow-x: auto;
}

.gloss-code {
  display: inline-block;
  background: var(--gloss-code-bg);
  padding: 4px 8px;
  border-radius: 6px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  border: 1px solid var(--gloss-border);
  color: var(--gloss-accent-dark);
  max-width: 100%;
  overflow-x: auto;
}

.gloss-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.gloss-chip {
  display: inline-block;
  background: var(--gloss-chip-bg);
  color: var(--gloss-accent-dark);
  padding: 5px 11px;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  user-select: none;
  transition: all 0.15s ease;
}
.gloss-chip:hover {
  background: var(--gloss-accent);
  color: #fff;
}

/* ───── Mobile tweaks ──────────────────────────────────────────────────── */

@media (max-width: 640px) {
  .gloss-modal {
    max-height: 95vh;
    border-radius: 12px;
  }
  .gloss-modal-head { padding: 16px 18px 12px; border-radius: 12px 12px 0 0; }
  .gloss-modal-body { padding: 14px 18px 20px; }
  .gloss-modal-title { font-size: 19px; }
  .gloss-modal-abbr  { font-size: 15px; }
}

/* ───── Dark surfaces ──────────────────────────────────────────────────────
   The Review Room's overlays sit on Deep Navy, and the OS may be in dark mode.
   Redefine only the tokens; every rule above reads them. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --gloss-bg: #0F2B4E;
    --gloss-fg: #DCE7F3;
    --gloss-muted: #93A9C4;
    --gloss-border: rgba(255, 255, 255, 0.12);
    --gloss-border-soft: rgba(255, 255, 255, 0.07);
    --gloss-code-bg: rgba(255, 255, 255, 0.06);
    --gloss-chip-bg: rgba(30, 185, 128, 0.18);
    --gloss-foot-bg: rgba(255, 255, 255, 0.03);
    --gloss-navy: #EAF3FF;
    --gloss-accent-dark: #7FE3BC;
  }
}
:root[data-theme="dark"] {
  --gloss-bg: #0F2B4E;
  --gloss-fg: #DCE7F3;
  --gloss-muted: #93A9C4;
  --gloss-border: rgba(255, 255, 255, 0.12);
  --gloss-border-soft: rgba(255, 255, 255, 0.07);
  --gloss-code-bg: rgba(255, 255, 255, 0.06);
  --gloss-chip-bg: rgba(30, 185, 128, 0.18);
  --gloss-foot-bg: rgba(255, 255, 255, 0.03);
  --gloss-navy: #EAF3FF;
  --gloss-accent-dark: #7FE3BC;
}
