/**
 * @file
 * APU chart lightbox — styles for the trigger button and dialog.
 *
 * Targets: figure.chart-wide containing chart images.
 * Tokens inherited from apu-style.css :root variables.
 */

/* ──────────────────────────────────────────────
   Trigger button (wraps the chart image)
   ────────────────────────────────────────────── */
.chart-lightbox__trigger {
  display: block;
  width: 100%;
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  cursor: zoom-in;
  position: relative;
  line-height: 0;
}

.chart-lightbox__trigger img {
  width: 100%;
  height: auto;
  display: block;
}

.chart-lightbox__trigger:focus-visible {
  outline: 3px solid var(--fg-gold-dark);
  outline-offset: 2px;
}

/* Enlarge icon — mobile only.
   \u2922 (⤢) is the standard expand/maximize glyph used in
   data-journalism interfaces. Do not replace with arrow glyphs
   (↗ etc) — those imply "open in new window," a different action. */
.chart-lightbox__trigger::after {
  content: "\2922";
  position: absolute;
  bottom: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--fg-paper);
  border: 1px solid var(--fg-hairline);
  border-radius: 50%;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 18px;
  color: var(--fg-ink);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  pointer-events: none;
}

@media (min-width: 769px) {
  .chart-lightbox__trigger::after {
    display: none;
  }
}

/* ──────────────────────────────────────────────
   Lightbox dialog (native <dialog> element)
   ────────────────────────────────────────────── */
.chart-lightbox[open] {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: 100vw;
  max-height: 100vh;
  max-height: 100dvh;
  margin: 0;
  padding: 0;
  border: none;
  background: var(--fg-paper);
  color: var(--fg-ink);
  display: flex;
  flex-direction: column;
}

.chart-lightbox:not([open]) {
  display: none;
}

.chart-lightbox::backdrop {
  background: rgba(26, 26, 26, 0.9);
}

/* ──────────────────────────────────────────────
   Close button (stacks above zoomed image)
   48x48 exceeds WCAG 2.2 AA minimum (44x44) and is more
   visually balanced for desktop where surface area matters
   for discoverability rather than touch precision.
   ────────────────────────────────────────────── */
.chart-lightbox__close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 48px;
  height: 48px;
  padding: 0;
  background: var(--fg-paper);
  border: 1px solid var(--fg-hairline);
  border-radius: 50%;
  font-size: 30px;
  line-height: 1;
  color: var(--fg-ink);
  cursor: pointer;
  z-index: 9999;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.chart-lightbox__close:focus-visible {
  outline: 3px solid var(--fg-gold-dark);
  outline-offset: 2px;
}

/* ──────────────────────────────────────────────
   Stage (image viewport)
   FIX: align-items: flex-start anchors tall images to the top of
   the scroll container. Previously align-items: center vertically
   centered the image, pushing its top above the scrollable area
   so users could scroll DOWN but never reach the image's top edge.
   ────────────────────────────────────────────── */
.chart-lightbox__stage {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 16px 16px 24px;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: auto;
}

/* Roomier padding on large desktop monitors so the chart
   doesn't sit flush against viewport edges. */
@media (min-width: 1200px) {
  .chart-lightbox__stage {
    padding: 32px 32px 40px;
  }
}

.chart-lightbox__image {
  max-width: 100%;
  height: auto;
  margin: auto;
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;       /* prevent drag-start without breaking touch */
  -webkit-touch-callout: none;   /* suppress iOS long-press save/copy menu */
}

/* ──────────────────────────────────────────────
   Hint text — mobile vs desktop variants
   ────────────────────────────────────────────── */
.chart-lightbox__hint {
  flex: 0 0 auto;
  margin: 0;
  padding: 10px 16px;
  background: var(--fg-paper-aged);
  color: var(--fg-ink-muted);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 12px;
  text-align: center;
  border-top: 1px solid var(--fg-hairline);
}

.chart-lightbox__hint--mobile {
  display: inline;
}

.chart-lightbox__hint--desktop {
  display: none;
}

@media (min-width: 769px) {
  .chart-lightbox__hint--mobile {
    display: none;
  }
  .chart-lightbox__hint--desktop {
    display: inline;
  }
}

@media (prefers-reduced-motion: reduce) {
  .chart-lightbox__close,
  .chart-lightbox__trigger::after {
    transition: none;
  }
}
