/* sirucka.cz — image lightbox.
 *
 * Its own file for the same reason cookie-consent.css is: the two page shells load different
 * stylesheets (_Layout.cshtml loads site.css, Index.cshtml loads frontend.css) and the viewer is
 * identical on both, so duplicating it in each is how the two copies drift apart within a release.
 *
 * Every colour comes from tokens.css, which both stylesheets already pull in.
 *
 * The element is a native <dialog> opened with showModal(). That is what buys the focus trap, the
 * Esc key, the inert background and the top-layer stacking — none of which has to be written here,
 * and all of which a hand-rolled div would get subtly wrong. */

/* The affordance. Applied by lightbox.js, not by the markup, so an image is only ever advertised as
   clickable once the script that makes it clickable has actually run. */
[data-lightbox].is-zoomable {
  cursor: zoom-in;
}

[data-lightbox].is-zoomable:focus-visible {
  outline: 2px solid var(--accent-glow);
  outline-offset: 3px;
}

.lightbox {
  /* A <dialog> ships with a border, padding, a white background and auto margins. */
  border: 0;
  padding: 0;
  margin: auto;
  max-width: 100vw;
  max-height: 100vh;
  width: 100%;
  height: 100%;
  background: transparent;
  overflow: hidden;
}

.lightbox::backdrop {
  background: rgba(6, 10, 20, .88);
  backdrop-filter: blur(var(--blur-glass)) saturate(1.15);
  -webkit-backdrop-filter: blur(var(--blur-glass)) saturate(1.15);
}

.lightbox[open] {
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-figure {
  margin: 0;
  padding: clamp(16px, 4vw, 48px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  max-width: 100%;
  max-height: 100%;
  animation: lightbox-in .22s cubic-bezier(.2, .7, .3, 1) both;
}

.lightbox-img {
  display: block;
  max-width: 100%;
  /* Leaves room for the caption without letting a tall portrait push it off screen. */
  max-height: calc(100vh - 9rem);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-accent);
  box-shadow: var(--shadow-raised);
  background: var(--bg-secondary);
}

/* The 2400 variant is a real download. Dim the frame until it decodes rather than showing a
   half-painted image over a blurred page. */
.lightbox[data-loading="true"] .lightbox-img {
  opacity: .35;
}

.lightbox-caption {
  font-family: var(--font-mono);
  font-size: var(--fs-caption);
  letter-spacing: var(--tracking-wide);
  text-transform: lowercase;
  color: var(--text-tertiary);
  text-align: center;
  max-width: 62ch;
}

.lightbox-caption:empty {
  display: none;
}

.lightbox-close {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 1;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 1.25rem;
  line-height: 1;
  color: var(--text-secondary);
  background: var(--glass-fill);
  backdrop-filter: blur(var(--blur-glass));
  -webkit-backdrop-filter: blur(var(--blur-glass));
  border: 1px solid var(--border-default);
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition: color .2s ease, border-color .2s ease, background .2s ease;
}

.lightbox-close:hover,
.lightbox-close:focus-visible {
  color: var(--text-primary);
  border-color: var(--border-accent);
  background: var(--glass-fill-strong);
}

@keyframes lightbox-in {
  from { transform: scale(.97); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .lightbox-figure { animation: none; }
  .lightbox-close  { transition: none; }
}
