/* AP Physics 1 study: glossary terms and popup. Uses the site.css tokens (--ink, --panel, --line, --accent,
   --link, --muted, --focus, --panel2, --radius, --shadow), so light / dark / the manual toggle all follow the site. */

/* ---------- terms in the text: a quiet dotted underline, reads like normal text ---------- */
.gl-term,
button.gl-term {
  all: unset;
  display: inline;
  position: relative;
  min-height: 0;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 3px;
  background: none;
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
  line-height: inherit;
  text-decoration: underline dotted;
  text-decoration-color: color-mix(in srgb, var(--accent, #1d4ed8) 70%, transparent);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  cursor: help;
  -webkit-tap-highlight-color: transparent;
}
/* bigger invisible tap target without moving the text */
.gl-term::after { content: ""; position: absolute; inset: -7px -2px; }
.gl-term:hover,
.gl-term.gl-open {
  color: var(--link, #1d4ed8);
  text-decoration-style: solid;
  background: color-mix(in srgb, var(--accent, #1d4ed8) 10%, transparent);
}
.gl-term:focus-visible { outline: 3px solid var(--focus, #f59e0b); outline-offset: 2px; }
@media (forced-colors: active) { .gl-term { text-decoration-color: LinkText; } }

/* ---------- popup card ---------- */
.gl-pop {
  position: absolute;
  z-index: 1100;
  box-sizing: border-box;
  width: max-content;
  max-width: min(300px, calc(100vw - 16px));
  padding: 12px 14px 10px;
  border: 1px solid var(--line, #d4dae4);
  border-radius: var(--radius, 12px);
  background: var(--panel, #fff);
  color: var(--ink, #111827);
  box-shadow: 0 6px 24px rgba(15, 23, 42, .18), 0 1px 3px rgba(15, 23, 42, .12);
  font: 15px/1.45 var(--font, system-ui, sans-serif);
  text-align: left;
  font-style: normal;
  font-weight: 400;
  animation: gl-in .14s ease-out;
}
.gl-pop[hidden] { display: none !important; }
.gl-pop:focus { outline: none; }
.gl-pop:focus-visible { outline: 3px solid var(--focus, #f59e0b); outline-offset: 2px; }
@keyframes gl-in { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

.gl-arrow {
  position: absolute;
  width: 12px; height: 12px;
  margin-left: -6px;
  background: inherit;
  border: inherit;
  transform: rotate(45deg);
}
.gl-pop.gl-below .gl-arrow { top: -7px; border-right: 0; border-bottom: 0; }
.gl-pop.gl-above .gl-arrow { bottom: -7px; border-left: 0; border-top: 0; }

.gl-pop .gl-close {
  all: unset;
  position: absolute; top: 4px; right: 4px;
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 8px;
  font-size: 22px; line-height: 1;
  color: var(--muted, #4b5563);
  cursor: pointer;
}
.gl-pop .gl-close:hover { background: var(--panel2, #eef2f8); color: var(--ink, #111827); }
.gl-pop .gl-close:focus-visible { outline: 3px solid var(--focus, #f59e0b); }

.gl-head { display: flex; align-items: center; gap: 10px; margin: 0 30px 6px 0; }
.gl-icon { flex: none; width: 32px; height: 32px; color: var(--accent, #1d4ed8); }
.gl-titles { display: flex; flex-direction: column; min-width: 0; }
.gl-term-name { font-size: 17px; line-height: 1.25; outline: none; }
.gl-meta { font-size: 13px; color: var(--muted, #4b5563); }
.gl-sym { font-family: var(--mono, ui-monospace, monospace); font-weight: 600; color: var(--ink, #111827); margin-right: 6px; }

.gl-pop p { margin: 6px 0 0; }
.gl-meaning { font-size: 15.5px; }
.gl-ex, .gl-hook, .gl-not, .gl-see { font-size: 14px; }
.gl-hook {
  padding: 5px 8px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--focus, #f59e0b) 16%, transparent);
}
.gl-not { color: var(--muted, #4b5563); }
.gl-pop b { font-weight: 700; }

.gl-chip,
.gl-pop button.gl-chip {
  all: unset;
  display: inline-block;
  margin: 2px 4px 2px 0;
  padding: 3px 10px;
  min-height: 0;
  border: 1px solid var(--line, #d4dae4);
  border-radius: 999px;
  background: var(--panel2, #eef2f8);
  color: var(--link, #1d4ed8);
  font-size: 13.5px;
  line-height: 1.6;
  cursor: pointer;
}
.gl-chip:hover { border-color: var(--accent, #1d4ed8); }
.gl-chip:focus-visible { outline: 3px solid var(--focus, #f59e0b); outline-offset: 1px; }

.gl-foot {
  display: flex; flex-wrap: wrap; gap: 4px 16px;
  margin-top: 8px !important;
  padding-top: 6px;
  border-top: 1px solid var(--line, #d4dae4);
  font-size: 13.5px;
}
.gl-foot:empty { display: none; }
.gl-foot a { color: var(--link, #1d4ed8); padding: 6px 0; text-underline-offset: 2px; }

/* ---------- phones: a bottom sheet ---------- */
.gl-pop.gl-sheet {
  position: fixed;
  left: 0 !important; right: 0; bottom: 0; top: auto !important;
  width: auto;
  max-width: none;
  max-height: 65vh;
  overflow-y: auto;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom, 0px));
  border-radius: 16px 16px 0 0;
  border-bottom: 0;
  font-size: 16px;
  box-shadow: 0 -6px 28px rgba(15, 23, 42, .25);
  animation: gl-up .18s ease-out;
}
.gl-pop.gl-sheet .gl-arrow { display: none; }
.gl-pop.gl-sheet .gl-close { width: 44px; height: 44px; top: 6px; right: 6px; }
.gl-pop.gl-sheet .gl-meaning { font-size: 17px; }
.gl-pop.gl-sheet :is(.gl-ex, .gl-hook, .gl-not, .gl-see) { font-size: 15.5px; }
.gl-pop.gl-sheet .gl-chip { padding: 6px 12px; font-size: 15px; }
.gl-pop.gl-sheet .gl-foot a { padding: 10px 0; font-size: 15px; }
@keyframes gl-up { from { transform: translateY(30px); opacity: .4; } to { transform: none; opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .gl-pop, .gl-pop.gl-sheet { animation: none; }
}
@media print {
  .gl-pop { display: none !important; }
  .gl-term { text-decoration: none; }
}
