/* ==========================================================================
   REFRACT — Cold-Press Watercolor Glossary Popover (glossary.css)
   CSP-safe: zero external fonts, zero CDN assets, zero data-URI images,
   zero inline style attributes or JS element.style.* positioning.
   Matches the paper, Sumi ink, cerulean, and seafoam tokens of refract-site.
   ========================================================================== */

:root {
  --rg-paper: #FFFDF9;
  --rg-paper-glass: rgba(255, 253, 249, 0.96);
  --rg-tint: #F4F9FB;
  --rg-ink: #162032;
  --rg-slate: #334155;
  --rg-muted: #3E5065;
  --rg-cerulean: #075985;
  --rg-seafoam: #0D645D;
  --rg-cerulean-soft: rgba(2, 132, 199, 0.12);
  --rg-seafoam-soft: rgba(13, 148, 136, 0.12);
  --rg-border: rgba(2, 132, 199, 0.34);
  --rg-hairline: rgba(22, 32, 50, 0.10);
  --rg-shadow:
    0 18px 40px -14px rgba(22, 32, 50, 0.18),
    0 6px 16px -4px rgba(2, 132, 199, 0.12),
    0 1px 3px rgba(22, 32, 50, 0.06);
  --rg-sans: "Plus Jakarta Sans", "Avenir Next", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --rg-serif: Georgia, "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, serif;
  --rg-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

/* Inline trigger styling for [data-glossary] elements */
[data-glossary] {
  position: relative;
  display: inline;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-decoration-color: rgba(2, 132, 199, 0.62);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
  border-radius: 4px;
  padding: 0 2px;
  margin: 0 -2px;
  cursor: help;
  transition:
    background-color 160ms cubic-bezier(0.22, 1, 0.36, 1),
    text-decoration-color 160ms cubic-bezier(0.22, 1, 0.36, 1),
    color 160ms cubic-bezier(0.22, 1, 0.36, 1);
}

[data-glossary]:hover,
[data-glossary][data-glossary-open="true"] {
  background: linear-gradient(120deg, var(--rg-cerulean-soft), var(--rg-seafoam-soft));
  text-decoration-style: solid;
  text-decoration-color: var(--rg-seafoam);
}

[data-glossary][data-glossary-open="true"] {
  anchor-name: --rg-trigger;
}

[data-glossary]:focus-visible {
  outline: 2px solid var(--rg-cerulean);
  outline-offset: 2px;
  background: var(--rg-cerulean-soft);
}

.rg-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: rgba(22, 32, 50, 0.14);
}

.rg-backdrop[hidden] {
  display: none;
}

/* Floating Cold-Press Watercolor Popover Dialog */
.rg-popover[hidden] {
  display: none;
}

.rg-popover {
  position: fixed;
  inset: auto;
  position-anchor: --rg-trigger;
  position-area: block-end span-all;
  justify-self: anchor-center;
  position-try-fallbacks: flip-block;
  margin: 10px 12px;
  z-index: 9999;
  width: min(360px, calc(100vw - 24px));
  max-width: min(360px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  padding: 16px 17px 14px;
  border-radius: 16px;
  background: var(--rg-paper);
  background-image:
    radial-gradient(ellipse 85% 55% at 8% 0%, rgba(14, 165, 233, 0.09), transparent 65%),
    radial-gradient(ellipse 70% 50% at 96% 100%, rgba(20, 184, 166, 0.10), transparent 65%),
    linear-gradient(180deg, var(--rg-paper-glass) 0%, #FAF7F0 100%);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1.5px solid var(--rg-border);
  box-shadow: var(--rg-shadow);
  color: var(--rg-ink);
  font-family: var(--rg-sans);
  font-size: 14.5px;
  line-height: 1.52;
  text-align: left;
  pointer-events: auto;
  opacity: 0;
  visibility: hidden;
  transform: translate3d(0, 6px, 0);
  transition:
    opacity 170ms cubic-bezier(0.22, 1, 0.36, 1),
    transform 170ms cubic-bezier(0.22, 1, 0.36, 1),
    visibility 170ms step-end;
}

.rg-popover.rg-popover--centered {
  position-anchor: auto;
  position-area: none;
  top: 50%;
  left: 50%;
  margin: 0;
  transform: translate3d(-50%, -50%, 0);
}

.rg-popover::before {
  content: "";
  position: absolute;
  top: 0;
  left: 16px;
  right: 16px;
  height: 3px;
  border-radius: 0 0 999px 999px;
  background: linear-gradient(90deg, var(--rg-cerulean), var(--rg-seafoam));
  opacity: 0.85;
}

.rg-popover.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translate3d(0, 0, 0);
  transition:
    opacity 170ms cubic-bezier(0.22, 1, 0.36, 1),
    transform 170ms cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0ms step-start;
}

.rg-popover.is-visible.rg-popover--centered {
  transform: translate3d(-50%, -50%, 0);
}

/* Header: Kicker + Close button (for touch/click) */
.rg-popover-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
}

.rg-popover-kicker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--rg-seafoam);
}

.rg-popover-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--rg-cerulean), var(--rg-seafoam));
  flex: none;
}

.rg-popover-close {
  appearance: none;
  border: 1px solid var(--rg-hairline);
  background: rgba(255, 255, 255, 0.85);
  color: var(--rg-slate);
  border-radius: 999px;
  width: 28px;
  height: 28px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease;
}

.rg-popover-close:hover {
  background: var(--rg-cerulean-soft);
  border-color: var(--rg-border);
  color: var(--rg-ink);
}

.rg-popover-close:focus-visible {
  outline: 2px solid var(--rg-cerulean);
  outline-offset: 1px;
}

/* Plain-English Headline */
.rg-popover-title {
  margin: 0 0 6px;
  font-family: var(--rg-serif);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--rg-ink);
}

/* 1-2 Sentence Zero-Jargon Explanation */
.rg-popover-body {
  margin: 0 0 10px;
  font-size: 14.5px;
  line-height: 1.52;
  color: var(--rg-ink);
}

/* Concrete Everyday Analogy / Example */
.rg-popover-analogy {
  margin: 0 0 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.07), rgba(20, 184, 166, 0.09));
  border: 1px solid rgba(13, 148, 136, 0.22);
  font-size: 0.90625rem;
  line-height: 1.48;
  color: var(--rg-slate);
}

.rg-popover-analogy-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--rg-cerulean);
  margin-bottom: 2px;
}

/* Subtle "Under the hood" Footer for Stats Nerds */
.rg-popover-hood {
  margin: 0;
  padding-top: 8px;
  border-top: 1px dashed var(--rg-hairline);
  font-size: 0.90625rem;
  line-height: 1.45;
  color: var(--rg-muted);
}

.rg-popover-hood-label {
  font-family: var(--rg-mono);
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--rg-slate);
  margin-right: 5px;
}

/* Caret pointer hidden when CSS Anchor Positioning handles viewport clamping/flipping */
.rg-popover-arrow {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  [data-glossary],
  .rg-popover {
    transition: none;
  }
}

/* Round 10b: WCAG AA eyebrow override (7.58:1 on wash) */
.eyebrow, .hero-top .eyebrow, .hero .eyebrow, .brand-wrap .eyebrow, .rn-hero .eyebrow { color: #475569 !important; }
