/* ============================================================
   diag4free — Glossar

   Zwei Sorten Mensch lesen denselben Text. Für den Profi ist jede
   Erklärung, die er nicht angefordert hat, Ablenkung — also darf
   der ausgezeichnete Begriff im Fließtext nicht wie ein Knopf
   aussehen. Eine gepunktete Unterlinie in der Textfarbe reicht:
   Wer sie sucht, findet sie; wer sie nicht braucht, liest darüber
   hinweg.

   Alle Farben kommen aus den Variablen von style.css. Damit
   stimmen Light und Dark ohne eine zweite Pflegestelle.
   ============================================================ */

/* ---------- Der Begriff im Text ---------- */

.gl-term {
  /* Ein Knopf, der wie Text aussieht: Schrift, Farbe und Gewicht
     kommen unverändert von der Umgebung. */
  display: inline;
  padding: 0;
  margin: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  text-align: inherit;
  line-height: inherit;
  cursor: help;

  /* Die einzige Auszeichnung. `currentColor` mit reduzierter
     Deckkraft, damit die Linie im Dark Mode nicht härter wirkt als
     im Light Mode. */
  text-decoration: underline dotted
    color-mix(in oklab, currentColor 45%, transparent);
  text-underline-offset: 0.22em;
  text-decoration-thickness: 1px;

  /* Abkürzungen dürfen nicht mitten in der Zeile brechen. */
  white-space: nowrap;
}

.gl-term:hover,
.gl-term:focus-visible {
  color: var(--color-primary);
  text-decoration-color: var(--color-primary);
}

.gl-term:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Beim Drucken ist nichts anklickbar. Dann ist die Linie nur noch
   Rauschen und verschwindet. */
@media print {
  .gl-term { text-decoration: none; color: inherit; }
  .gl-overlay { display: none; }
}

/* ---------- Die Einblendung ---------- */

.gl-overlay {
  position: fixed;
  inset: 0;
  /* Über Drawer (110) und Sidebar (200) — ein Begriff wird auch
     aus einem offenen Dokument heraus angeklickt. */
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}

.gl-overlay[hidden] { display: none; }

.gl-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 20, 40, 0.5);
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 160ms ease;
}

.gl-dialog {
  position: relative;
  width: min(520px, 100%);
  max-height: min(80dvh, 640px);
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  /* Nur verschieben, nicht skalieren. Ein `scale` unter 1 macht jedes
     Berührziel für die Dauer der Animation kleiner als 44 px — und
     genau in diesem Moment tippt jemand darauf. */
  transform: translateY(8px);
  transition:
    opacity 160ms cubic-bezier(0.2, 0.8, 0.2, 1),
    transform 160ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.gl-dialog:focus { outline: none; }

.gl-overlay.gl-offen .gl-backdrop { opacity: 1; }
.gl-overlay.gl-offen .gl-dialog {
  opacity: 1;
  transform: translateY(0);
}

/* ---------- Kopf ---------- */

.gl-head {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-4) var(--space-3);
  border-bottom: 1px solid var(--color-divider);
}

.gl-head-text { min-width: 0; flex: 1; }

.gl-titel {
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: 0.01em;
  overflow-wrap: anywhere;
}

.gl-lang {
  margin-top: var(--space-1);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.gl-lang[hidden] { display: none; }

.gl-close {
  flex: none;
  /* Berührziel — UI-Konzept: Ziele ≥ 44 px. */
  width: 44px;
  height: 44px;
  margin: calc(var(--space-2) * -1) calc(var(--space-2) * -1) 0 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
}

.gl-close:hover {
  background: var(--color-surface-offset);
  color: var(--color-text);
}

/* ---------- Rumpf ---------- */

.gl-body {
  padding: var(--space-4);
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* Der Satz, der ohne Vorwissen trägt. Er steht zuerst und deutlich. */
.gl-kurz {
  font-size: var(--text-md);
  font-weight: 500;
  line-height: 1.45;
}

.gl-text {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* Das wichtigste Feld: nicht was es heißt, sondern warum es hier
   steht. Deshalb bekommt es als einziges eine Fläche. */
.gl-warum {
  padding: var(--space-3);
  border-left: 3px solid var(--color-primary);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  background: var(--color-primary-tint-2);
}

.gl-warum h3,
.gl-siehe h3,
.gl-docs h3 {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}

.gl-warum h3 { color: var(--color-primary); }
.gl-warum p { font-size: var(--text-sm); }

.gl-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.gl-chip {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  background: var(--color-surface-2);
  color: var(--color-text);
  font-size: var(--text-sm);
  font-weight: 500;
}

.gl-chip:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-tint);
  color: var(--color-primary);
}

/* Doc-IDs sind Kennungen, keine Prosa — deshalb dieselbe Schrift
   wie überall sonst im Projekt für Kennungen. */
.gl-chip-doc {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.02em;
}

/* Ein Begriff im Overlay soll nicht doppelt ausgezeichnet sein:
   die Chips tragen die Auszeichnung schon in ihrer Form. */
.gl-chip.gl-term { text-decoration: none; white-space: nowrap; }

/* ---------- Fuß ---------- */

.gl-foot {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--color-divider);
  display: flex;
  justify-content: flex-end;
}

.gl-btn {
  min-height: 44px;
  padding: 0 var(--space-5);
  border-radius: var(--radius-md);
  background: var(--color-primary);
  color: var(--color-on-primary);
  font-size: var(--text-sm);
  font-weight: 600;
}

.gl-btn:hover { background: var(--color-primary-hover); }
.gl-btn:active { background: var(--color-primary-active); }

/* ---------- Schmale Geräte ---------- */

/* Auf dem Phone kommt die Erklärung von unten. Das ist der Griff,
   der mit dem Daumen erreichbar bleibt. */
@media (max-width: 560px) {
  .gl-overlay {
    align-items: flex-end;
    padding: 0;
  }
  .gl-dialog {
    width: 100%;
    max-height: 85dvh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    transform: translateY(16px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .gl-overlay.gl-offen .gl-dialog { transform: translateY(0); }
}

/* Mit Finger bedient wird die Unterlinie etwas deutlicher — ein
   Fingertipp trifft nicht so genau wie ein Mauszeiger. */
@media (pointer: coarse) {
  .gl-term {
    text-decoration-color: color-mix(in oklab, currentColor 60%, transparent);
  }
}

@media (prefers-reduced-motion: reduce) {
  .gl-dialog,
  .gl-backdrop { transition: none; }
  .gl-dialog { transform: none; }
}
