/* Hover glossary — Your Bible Life
   Tokens are defined on :root so the site's own palette can override them.
   Light is the base; dark is a token swap, never a separate rule set. */

:root {
  --gloss-ink: #16181c;
  --gloss-ink-soft: #4e545e;
  --gloss-ink-faint: #7c838e;
  --gloss-surface: #ffffff;
  --gloss-rule: #d9dbd8;
  --gloss-mark: #2b4b7d; /* lexical — the annotator's blue pencil */
  --gloss-mark-bg: rgba(43, 75, 125, 0.08);
  --gloss-background-mark: #2f6f66; /* background/cultural entries — verdigris */
  --gloss-background-mark-bg: rgba(47, 111, 102, 0.09);
  --gloss-flag: #a32e22; /* contested — rubric red, reserved for dispute alone */
  --gloss-shadow: 0 1px 2px rgba(22, 24, 28, 0.06), 0 14px 30px rgba(22, 24, 28, 0.12);
  --gloss-serif: Literata, "Iowan Old Style", Charter, Georgia, serif;
  --gloss-sans: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Helvetica, sans-serif;
  --gloss-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

:root:not([data-theme="light"]) {
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --gloss-ink: #e6e8ea;
    --gloss-ink-soft: #a7aeb8;
    --gloss-ink-faint: #79808b;
    --gloss-surface: #1e2126;
    --gloss-rule: #343941;
    --gloss-mark: #8fb4e6;
    --gloss-mark-bg: rgba(143, 180, 230, 0.14);
    --gloss-background-mark: #6fb7ab;
    --gloss-background-mark-bg: rgba(111, 183, 171, 0.14);
    --gloss-flag: #ee8a7a;
    --gloss-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px rgba(0, 0, 0, 0.5);
  }
}

:root[data-theme="dark"] {
  --gloss-ink: #e6e8ea;
  --gloss-ink-soft: #a7aeb8;
  --gloss-ink-faint: #79808b;
  --gloss-surface: #1e2126;
  --gloss-rule: #343941;
  --gloss-mark: #8fb4e6;
  --gloss-mark-bg: rgba(143, 180, 230, 0.14);
  --gloss-background-mark: #6fb7ab;
  --gloss-background-mark-bg: rgba(111, 183, 171, 0.14);
  --gloss-flag: #ee8a7a;
  --gloss-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px rgba(0, 0, 0, 0.5);
}

/* ---- the mark in the prose ------------------------------------------- */
/* A real button: it takes Tab, Enter and Space, and it shows a focus ring.
   The underline is dotted and thin enough to read past — the reader should
   notice it when they need it and not before. */

.gloss {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0 0.06em;
  margin: 0 -0.06em;
  cursor: help;
  border-radius: 2px;
  text-decoration: underline dotted var(--gloss-mark);
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1px;
  transition: background-color 120ms ease;
}

.gloss[data-type="background"] {
  text-decoration-color: var(--gloss-background-mark);
  text-decoration-style: dashed;
}

.gloss:hover,
.gloss[aria-expanded="true"] {
  background: var(--gloss-mark-bg);
}

.gloss[data-type="background"]:hover,
.gloss[data-type="background"][aria-expanded="true"] {
  background: var(--gloss-background-mark-bg);
}

.gloss:focus-visible {
  outline: 2px solid var(--gloss-mark);
  outline-offset: 2px;
  background: var(--gloss-mark-bg);
}

/* ---- the popover ------------------------------------------------------ */

#gloss-popover {
  position: fixed;
  z-index: 9999;
  inset: auto;
  width: min(22rem, calc(100vw - 2rem));
  /* Tall enough that the source-and-date line is visible without scrolling on
     all but the longest entries — that line is the point of the design. */
  max-height: min(30rem, 80vh);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0.95rem 1.05rem 0.85rem;
  background: var(--gloss-surface);
  color: var(--gloss-ink);
  border: 1px solid var(--gloss-rule);
  border-radius: 10px;
  box-shadow: var(--gloss-shadow);
  font-family: var(--gloss-sans);
  font-size: 0.875rem;
  line-height: 1.5;
  opacity: 0;
  transform: translateY(-3px);
  transition: opacity 110ms ease, transform 110ms ease;
}

#gloss-popover[hidden] {
  display: none !important;
}

#gloss-popover.is-open {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  #gloss-popover,
  .gloss {
    transition: none;
  }
  #gloss-popover {
    transform: none;
  }
}

/* Under 480px the popover stops chasing the word and docks to the bottom,
   where a thumb can reach it. */
@media (max-width: 479px) {
  #gloss-popover {
    left: 0.75rem;
    right: 0.75rem;
    bottom: 0.75rem;
    top: auto !important;
    width: auto;
    max-height: 60vh;
    transform: translateY(6px);
  }
  #gloss-popover.is-open {
    transform: none;
  }
}

.gloss-head {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.gloss-term {
  font-family: var(--gloss-serif);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.gloss-kind {
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--gloss-ink-faint);
  border: 1px solid var(--gloss-rule);
  border-radius: 999px;
  padding: 0.1rem 0.42rem;
}

.gloss-plain {
  font-family: var(--gloss-serif);
  font-size: 0.95rem;
  line-height: 1.55;
  margin: 0 0 0.6rem;
}

.gloss-here {
  display: block;
  font-family: var(--gloss-sans);
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--gloss-mark);
  margin-bottom: 0.2rem;
}

.gloss-misread {
  margin: 0 0 0.6rem;
  color: var(--gloss-ink-soft);
  font-size: 0.8125rem;
  line-height: 1.55;
}

.gloss-disputed {
  margin: 0 0 0.6rem;
  padding-left: 0.65rem;
  border-left: 2px solid var(--gloss-flag);
  color: var(--gloss-ink-soft);
  font-size: 0.8125rem;
  line-height: 1.55;
}

.gloss-disputed b {
  display: block;
  color: var(--gloss-flag);
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-weight: 600;
  margin-bottom: 0.15rem;
}

.gloss-refs {
  font-family: var(--gloss-mono);
  font-size: 0.6875rem;
  color: var(--gloss-ink-faint);
  margin: 0 0 0.6rem;
}

/* The rigour, one click away rather than in the reader's face. */
.gloss-detail {
  border-top: 1px solid var(--gloss-rule);
  padding-top: 0.5rem;
}

.gloss-detail > summary {
  cursor: pointer;
  list-style: none;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gloss-ink-faint);
}

.gloss-detail > summary::-webkit-details-marker { display: none; }

.gloss-detail > summary::before {
  content: "\203a";
  display: inline-block;
  margin-right: 0.35rem;
  transition: transform 120ms ease;
}

.gloss-detail[open] > summary::before { transform: rotate(90deg); }

.gloss-detail > summary:hover { color: var(--gloss-ink-soft); }

.gloss-detail > summary:focus-visible {
  outline: 2px solid var(--gloss-mark);
  outline-offset: 2px;
  border-radius: 3px;
}

.gloss-lexeme { margin-top: 0.55rem; }

.gloss-lemma {
  font-family: var(--gloss-serif);
  font-size: 0.9375rem;
  color: var(--gloss-ink);
}

.gloss-translit { font-style: italic; }

.gloss-gloss {
  font-size: 0.6875rem;
  line-height: 1.45;
  color: var(--gloss-ink-faint);
}

.gloss-cite {
  font-size: 0.6875rem;
  line-height: 1.45;
  color: var(--gloss-ink-faint);
  margin: 0.15rem 0 0;
}

.gloss-cite code {
  font-family: var(--gloss-mono);
  font-size: 0.6875rem;
}

.gloss-scholarship {
  margin: 0.55rem 0 0;
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--gloss-ink-soft);
}

.gloss-cite a,
.gloss-more { color: var(--gloss-mark); }

.gloss-more {
  display: inline-block;
  margin-top: 0.7rem;
  font-size: 0.75rem;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}

@media (prefers-reduced-motion: reduce) {
  .gloss-detail > summary::before { transition: none; }
}

.gloss-dismiss {
  position: absolute;
  top: 0.45rem;
  right: 0.5rem;
  border: 0;
  background: none;
  color: var(--gloss-ink-faint);
  font-size: 1.05rem;
  line-height: 1;
  padding: 0.25rem 0.35rem;
  cursor: pointer;
  border-radius: 4px;
}

.gloss-dismiss:hover {
  color: var(--gloss-ink);
}

.gloss-dismiss:focus-visible {
  outline: 2px solid var(--gloss-mark);
  outline-offset: 1px;
}
