/* =============================================================
   Barrierefreie <dialog>-Lightbox
   Zwei Blöcke:
     1) KOMPONENTE  – die wiederverwendbare Lightbox (.lb …)
     2) DEMO-SEITE  – nur das Drumherum dieser Beispielseite
   Der Komponentenblock ist komplett eigenständig und lässt sich
   1:1 in ein TYPO3-/WordPress-Sitepackage übernehmen.
   ============================================================= */

/* -----------------------------------------------------------------
   Design-Tokens
   ----------------------------------------------------------------- */
:root {
  --paper:    #eceef1;
  --paper-2:  #ffffff;
  --ink:      #16181d;
  --muted:    #5b616b;
  --line:     #d3d7dd;
  --accent:   #0f766e;   /* tiefes Teal */
  --accent-d: #0b5750;
  --focus:    #f2b705;   /* warmer Fokusring, hoher Kontrast auf hell + dunkel */

  --lb-bg:    rgb(11 14 20 / 0.94);
  --lb-fg:    #f4f6f8;
  --lb-ctrl:  rgb(255 255 255 / 0.10);
  --lb-ctrl-h:rgb(255 255 255 / 0.22);

  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --radius: 14px;
  --ease:   cubic-bezier(0.16, 1, 0.3, 1);
}

/* Screenreader-only – für die Live-Region */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* =================================================================
   1) KOMPONENTE — Lightbox
   ================================================================= */

/* Der Dialog füllt den Viewport; Hintergrund/Focus-Trap/ESC
   übernimmt showModal() nativ. */
.lb {
  width: 100%;
  height: 100%;
  max-width: 100vw;
  max-height: 100dvh;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--lb-fg);
  overflow: hidden;
}

.lb::backdrop {
  background: var(--lb-bg);
  backdrop-filter: blur(6px);
}

/* Bühne: zentriert das Bild, lässt Rand als Klickfläche zum Schließen */
.lb__stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: clamp(0.75rem, 3vw, 3rem);
  /* Klicks auf die Bühne (nicht auf Figur/Buttons) schließen -> JS */
}

.lb__figure {
  position: relative;
  margin: 0;
  max-width: min(1200px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
}

.lb__img {
  display: block;
  max-width: 100%;
  max-height: calc(100dvh - 7rem);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 6px;
  background: rgb(255 255 255 / 0.04);
  box-shadow: 0 24px 60px rgb(0 0 0 / 0.5);
}

.lb__caption {
  max-width: 62ch;
  margin: 0;
  text-align: center;
  font: 400 0.95rem/1.5 var(--font-sans);
  color: rgb(244 246 248 / 0.86);
  text-wrap: pretty;
}

/* Fade-Übergang zwischen den Bildern – nur aktiv, wenn die Instanz
   mit smoothFade:true läuft (Klasse .lb--smooth wird per JS gesetzt).
   Hinweis: smoothFade:true respektiert prefers-reduced-motion NICHT
   (bewusste Design-Entscheidung -> "ggf. nicht barrierefrei").
   Für strikte BFSG-Konformität smoothFade:false verwenden. */
.lb.lb--smooth .lb__img,
.lb.lb--smooth .lb__caption { transition: opacity 0.24s var(--ease); }

.lb.lb--smooth .lb__figure.is-changing .lb__img,
.lb.lb--smooth .lb__figure.is-changing .lb__caption { opacity: 0; }

/* Lade-Indikator */
.lb__spinner {
  position: absolute;
  top: 50%; left: 50%;
  width: 40px; height: 40px;
  margin: -20px 0 0 -20px;
  border: 3px solid rgb(255 255 255 / 0.25);
  border-top-color: var(--lb-fg);
  border-radius: 50%;
  opacity: 0;
  animation: lb-spin 0.8s linear infinite;
}
.lb.is-loading .lb__spinner { opacity: 1; }

@keyframes lb-spin { to { transform: rotate(360deg); } }

/* Steuer-Buttons */
.lb__btn {
  position: absolute;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--lb-ctrl);
  color: var(--lb-fg);
  cursor: pointer;
  transition: background 0.18s var(--ease), transform 0.18s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.lb__btn:hover { background: var(--lb-ctrl-h); }
.lb__btn:active { transform: scale(0.94); }
.lb__btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; }

.lb__btn--close { top: 14px; right: 14px; }
.lb__btn--prev  { left: 14px;  top: 50%; transform: translateY(-50%); }
.lb__btn--next  { right: 14px; top: 50%; transform: translateY(-50%); }
.lb__btn--prev:active,
.lb__btn--next:active { transform: translateY(-50%) scale(0.94); }

.lb__btn:disabled { opacity: 0.3; cursor: default; }

/* Zähler als Instrumenten-Anzeige (mono, tabellarisch) */
.lb__counter {
  position: absolute;
  top: 18px;
  left: 18px;
  z-index: 2;
  margin: 0;
  font: 600 0.9rem/1 var(--font-mono);
  letter-spacing: 0.08em;
  color: rgb(244 246 248 / 0.72);
  font-variant-numeric: tabular-nums;
}

/* Sichtbarer Fokus – auf dunklem Grund */
.lb__btn:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

/* Öffnen-Animation (fällt ohne @starting-style / bei reduced motion sauber weg) */
@media (prefers-reduced-motion: no-preference) {
  .lb[open] { animation: lb-in 0.28s var(--ease); }
  .lb[open]::backdrop { animation: lb-fade 0.28s var(--ease); }
  @keyframes lb-in   { from { opacity: 0; transform: scale(0.98); } }
  @keyframes lb-fade { from { opacity: 0; } }
}

/* =================================================================
   2) DEMO-SEITE
   ================================================================= */
* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1080px; margin-inline: auto; padding-inline: clamp(1.25rem, 4vw, 3rem); }

.masthead { padding-block: clamp(3rem, 8vw, 6rem) 2.5rem; }
.eyebrow {
  font: 600 0.78rem/1 var(--font-mono);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 1.1rem;
}
.masthead h1 {
  margin: 0;
  font-size: clamp(2.3rem, 6vw, 3.8rem);
  line-height: 1.02;
  letter-spacing: -0.03em;
  font-weight: 800;
}
.masthead p {
  max-width: 60ch;
  margin: 1.1rem 0 0;
  font-size: 1.08rem;
  color: var(--muted);
  text-wrap: pretty;
}

/* Feature-Zeile */
.specs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.8rem;
  padding: 0;
  list-style: none;
}
.specs li {
  font: 500 0.82rem/1 var(--font-mono);
  letter-spacing: 0.02em;
  padding: 0.5rem 0.7rem;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #2c313a;
}

.section-label {
  display: flex;
  align-items: baseline;
  gap: 0.8rem;
  margin: 3rem 0 1.2rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--line);
}
.section-label h2 { margin: 0; font-size: 1.25rem; letter-spacing: -0.01em; }
.section-label span {
  font: 600 0.78rem/1 var(--font-mono);
  color: var(--muted);
  letter-spacing: 0.08em;
}

/* Galerie-Raster */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 0.9rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.gallery__link {
  display: block;
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--paper-2);
  border: 1px solid var(--line);
  aspect-ratio: 3 / 2;
  outline-offset: 3px;
}
.gallery__link:focus-visible { outline: 3px solid var(--focus); }

.gallery__link img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s var(--ease), filter 0.3s var(--ease);
}
.gallery__link::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgb(11 14 20 / 0.28), transparent 45%);
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}

@media (prefers-reduced-motion: no-preference) {
  .gallery__link:hover img { transform: scale(1.05); }
}
.gallery__link:hover::after,
.gallery__link:focus-visible::after { opacity: 1; }

/* kleine Lupe rechts unten als Affordance */
.gallery__link .zoom {
  position: absolute;
  right: 10px; bottom: 10px;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgb(11 14 20 / 0.55);
  color: #fff;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
}
.gallery__link .zoom svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; }
.gallery__link:hover .zoom,
.gallery__link:focus-visible .zoom { opacity: 1; transform: translateY(0); }

.note {
  margin: 2.6rem 0 0;
  padding: 1.1rem 1.2rem;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  font-size: 0.95rem;
  color: #2c313a;
}
.note code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: #e2e6ea;
  padding: 0.1em 0.4em;
  border-radius: 4px;
}

kbd {
  font: 600 0.8em/1 var(--font-mono);
  padding: 0.2em 0.5em;
  background: #fff;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  color: #2c313a;
}

/* Einbindungs-Codeblock */
.code {
  margin: 1rem 0 0;
  padding: 1.1rem 1.25rem;
  background: #14171d;
  color: #e7ebf0;
  border-radius: 10px;
  overflow-x: auto;
  font: 500 0.85rem/1.65 var(--font-mono);
  tab-size: 2;
}
.code .t { color: #7fb2ff; }   /* Tag / Bezeichner */
.code .a { color: #f2b705; }   /* Attribut / Key   */
.code .s { color: #8fd39a; }   /* String / Wert    */
.code .c { color: #6b7280; }   /* Kommentar        */

.footer {
  margin-top: 4rem;
  padding: 2rem 0 3rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.88rem;
}

/* Scroll-Lock, wenn Lightbox offen ist */
html.lb-open, html.lb-open body { overflow: hidden; }
