/*
  Shared detail view (/assets/js/detail-view.js). Plain by default; theme it with these
  variables on :root or body (the panel is appended to <body>):
    --detail-bg           panel background           (#faf9f6)
    --detail-fg           text                       (#1d1d1b)
    --detail-muted        secondary text             (#6b6b66)
    --detail-line         borders                    (rgba(0,0,0,.12))
    --detail-stage-bg     behind the image           (#efede8)
    --detail-accent       focus ring, current thumb  (currentColor)
    --detail-font         panel font                 (inherit)
    --detail-info-width   info panel width (wide)    (360px)
  Info panel content is the page's own; style it under .ehq-detail__info.
*/
.ehq-detail {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  background: var(--detail-bg, #faf9f6);
  color: var(--detail-fg, #1d1d1b);
  font-family: var(--detail-font, inherit);
  opacity: 0;
  transition: opacity .25s ease;
}
.ehq-detail[hidden] { display: none; }
.ehq-detail.is-open { opacity: 1; }

/* Top bar: previous · count · next · close */
.ehq-detail__bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px max(12px, 2vw);
  border-bottom: 1px solid var(--detail-line, rgba(0, 0, 0, .12));
}
.ehq-detail__count { min-width: 5em; text-align: center; color: var(--detail-muted, #6b6b66); font-size: .92em; }
.ehq-detail__btn,
.ehq-detail__step {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--detail-line, rgba(0, 0, 0, .12));
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.ehq-detail__btn[hidden] { display: none; }
.ehq-detail__btn:hover,
.ehq-detail__step:hover { border-color: currentColor; }
.ehq-detail__close { margin-left: auto; width: 40px; padding: 0; justify-content: center; }
.ehq-detail svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ehq-detail button:focus-visible,
.ehq-detail a:focus-visible { outline: 2px solid var(--detail-accent, currentColor); outline-offset: 2px; }

/* Body: stage left, info right; stacked on narrow screens */
.ehq-detail__body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--detail-info-width, 360px);
}
.ehq-detail__stage {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--detail-stage-bg, #efede8);
}
.ehq-detail__frame {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  touch-action: pan-y;
}
.ehq-detail__img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  opacity: 0;
  transition: opacity .25s ease;
}
.ehq-detail__img.is-loaded { opacity: 1; }
.ehq-detail__video { width: 100%; max-width: 960px; aspect-ratio: 16 / 9; height: auto; border: 0; }
.ehq-detail__noimg { color: var(--detail-muted, #6b6b66); }

.ehq-detail__media-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px 16px;
  justify-content: center;
}
.ehq-detail__media-nav[hidden] { display: none; }
.ehq-detail__step { width: 40px; padding: 0; justify-content: center; flex: none; }
.ehq-detail__thumbs { display: flex; gap: 6px; overflow-x: auto; padding: 4px; scrollbar-width: none; }
.ehq-detail__thumb {
  position: relative;
  flex: none;
  width: 52px;
  height: 52px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 4px;
  background: none;
  cursor: pointer;
  opacity: .65;
}
.ehq-detail__thumb img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 2px; }
.ehq-detail__thumb[aria-current="true"] { border-color: var(--detail-accent, currentColor); opacity: 1; }
.ehq-detail__thumb:hover { opacity: 1; }
.ehq-detail__thumb.is-video::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 0;
  height: 0;
  border-left: 14px solid #fff;
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
  filter: drop-shadow(0 0 2px rgba(0, 0, 0, .6));
}

.ehq-detail__info {
  overflow-y: auto;
  padding: 28px 28px 40px;
  border-left: 1px solid var(--detail-line, rgba(0, 0, 0, .12));
  line-height: 1.55;
}

@media (max-width: 800px) {
  .ehq-detail__body { display: block; overflow-y: auto; }
  .ehq-detail__stage { min-height: 0; }
  .ehq-detail__frame { height: min(62vh, 560px); padding: 16px; }
  .ehq-detail__info { overflow: visible; border-left: 0; border-top: 1px solid var(--detail-line, rgba(0, 0, 0, .12)); padding: 20px 16px 40px; }
}
@media (max-width: 480px) {
  .ehq-detail__btn span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .ehq-detail__btn { width: 40px; padding: 0; justify-content: center; }
}
@media (prefers-reduced-motion: reduce) {
  .ehq-detail, .ehq-detail__img { transition: none; }
}
