/* ── Coin Viewer (lightbox) ────────────────────────────────────────────── */

.lic-viewer {
  position: fixed;
  inset: 0;
  /* dvh tracks the viewport as mobile browser chrome shows/hides; plain vh
     resolves against the *large* viewport, which hides the footer controls
     behind the toolbar. vh first as the fallback for older browsers. */
  height: 100vh;
  height: 100dvh;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
}
.lic-viewer[hidden] { display: none; }

.lic-viewer-overlay {
  position: absolute;
  inset: 0;
  background: rgba(14, 12, 9, 0.90);
  cursor: pointer;
}

.lic-viewer-panel {
  position: relative;
  background: var(--deep, #1A1610);
  border: 1px solid var(--rule, #3D2B1A);
  border-radius: 3px;
  width: 100%;
  max-width: 840px;
  max-height: 90vh;
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 72px rgba(0, 0, 0, 0.7);
}

/* ── Header ── */
.lic-viewer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid var(--rule, #3D2B1A);
  flex-shrink: 0;
}
.lic-viewer-header-text { flex: 1; min-width: 0; }

.lic-viewer-name {
  font-family: 'IM Fell English', Georgia, serif;
  font-style: italic;
  font-size: 1.05rem;
  color: var(--parchment, #F2EBD9);
  line-height: 1.35;
  margin-bottom: 0.2rem;
  text-wrap: balance;
}
.lic-viewer-identity {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.05em;
}

.lic-viewer-close {
  background: none;
  /* --rule is 1.34:1 here — the ring was effectively not drawn. --edge is
     3.43:1: too weak for text, over the 3:1 a control's boundary needs. */
  border: 1px solid var(--edge, #7A6A50);
  color: var(--muted);
  border-radius: 50%;
  /* 44px. Was 1.9rem — 30px, under the minimum touch target. */
  width: 2.75rem;
  height: 2.75rem;
  cursor: pointer;
  flex-shrink: 0;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, border-color 0.15s;
  margin-top: 0.1rem;
}
.lic-viewer-close:hover,
.lic-viewer-close:focus-visible {
  color: var(--gold, #C9A84C);
  border-color: var(--gold-dim, #8A6F2E);
  outline: none;
}

/* ── 2D / 3D Tabs ── */
.lic-viewer-tabs {
  display: flex;
  border-bottom: 1px solid var(--rule, #3D2B1A);
  padding: 0 1.5rem;
  flex-shrink: 0;
}
.lic-viewer-tabs[hidden] { display: none; }

.lic-viewer-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  /* The idle tab is the only signpost that a 3D view exists at all, so it has
     to be readable. --muted now carries an AA-safe value site-wide. */
  color: var(--muted);
  font-family: 'Cinzel', Georgia, serif;
  /* was 0.58rem — 9.3px, small for a control anyone has to find. 0.72rem
     matches .lic-viewer-identity, so this borrows a size the panel already uses. */
  font-size: 0.72rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  /* ~44px tall, a real touch target; the old 30px was awkward on a phone.
     Padding gets there at 57.8px once Cinzel loads, but the fallback line box
     lands at 42.3px, so state the floor rather than depend on the webfont. */
  padding: 0.85rem 1.15rem 0.7rem;
  min-height: 44px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background-color 0.15s;
  margin-bottom: -1px;
  border-radius: 2px 2px 0 0;
}
/* A wash on hover so the row reads as something you can press, not a caption. */
.lic-viewer-tab:hover {
  color: var(--cream, #EDE3CC);
  background: rgba(201, 168, 76, 0.07);
}
/* .lic-viewer-close already shows focus; the tabs did not. */
.lic-viewer-tab:focus-visible {
  outline: 2px solid var(--gold, #C9A84C);
  outline-offset: -3px;
  color: var(--cream, #EDE3CC);
}
.lic-viewer-tab.active {
  color: var(--gold, #C9A84C);
  border-bottom-color: var(--gold, #C9A84C);
}

/* ── Content area ── */
.lic-viewer-content {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* 2D: side-by-side obverse + reverse */
.lic-viewer-2d {
  display: flex;
  gap: 1.5rem;
  padding: 1.5rem;
  height: 100%;
  align-items: flex-start;
  overflow-y: auto;
}
.lic-viewer-2d[hidden] { display: none; }

.lic-viewer-obverse,
.lic-viewer-reverse {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}
.lic-viewer-reverse[hidden] { display: none; }

/* When reverse is hidden, center the obverse */
.lic-viewer-2d:has(.lic-viewer-reverse[hidden]) .lic-viewer-obverse {
  max-width: 360px;
  margin: 0 auto;
  flex: unset;
}

.lic-viewer-img {
  width: 100%;
  height: auto;
  max-height: 420px;
  object-fit: contain;
  border-radius: 3px;
  border: 1px solid var(--rule, #3D2B1A);
  display: block;
  background: var(--black, #0E0C09);
}

.lic-viewer-side-label {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold-label);
}

.lic-viewer-cap {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
  font-style: italic;
}

/* 3D: fill the content area */
.lic-viewer-3d {
  width: 100%;
  height: 420px;
  min-height: 420px;
}
.lic-viewer-3d[hidden] { display: none; }

/* ── Footer ── */
.lic-viewer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 1.5rem;
  border-top: 1px solid var(--rule, #3D2B1A);
  flex-shrink: 0;
}

.lic-viewer-prev,
.lic-viewer-next {
  background: none;
  border: 1px solid var(--edge, #7A6A50);   /* was --rule, 1.34:1 */
  color: var(--muted);
  font-family: 'Cinzel', Georgia, serif;
  /* was 0.58rem — 9.28px, the smallest thing in the panel and one of the two
     controls you actually need to move through a display. */
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.5rem 1.15rem;
  /* min-height rather than padding arithmetic: 44px regardless of how the
     Cinzel line box resolves. */
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background-color 0.15s;
}
.lic-viewer-prev:hover,
.lic-viewer-next:hover {
  color: var(--gold, #C9A84C);
  border-color: var(--gold-dim, #8A6F2E);
  background: rgba(201, 168, 76, 0.07);
}
.lic-viewer-prev:focus-visible,
.lic-viewer-next:focus-visible {
  outline: 2px solid var(--gold, #C9A84C);
  outline-offset: 2px;
  color: var(--cream, #EDE3CC);
}
.lic-viewer-prev[hidden],
.lic-viewer-next[hidden] { visibility: hidden; }

.lic-viewer-count {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.04em;
}

/* ── Zoom trigger on coin images ── */
[data-cv-set] {
  cursor: zoom-in;
}
[data-cv-set]:focus-visible {
  outline: 1px solid var(--gold-dim, #8A6F2E);
  outline-offset: 2px;
}

/* Mobile: stack obverse / reverse vertically */
@media (max-width: 600px) {
  .lic-viewer { padding: 0.5rem; }

  .lic-viewer-panel { max-height: 96vh; max-height: 90dvh; }

  .lic-viewer-2d {
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
  }

  .lic-viewer-obverse,
  .lic-viewer-reverse {
    width: 100%;
    max-width: 280px;
  }

  .lic-viewer-img { max-height: 260px; }

  .lic-viewer-header { padding: 1rem 1rem 0.75rem; }
  .lic-viewer-footer { padding: 0.85rem 1rem; }
  .lic-viewer-2d    { padding: 1rem; }
}
