/**
 * Hydra Tools — image thumb, detail hero, lightbox (mobile-first).
 */

/* List thumb — 48px beside card body */
#hydraToolsShell .hti-thumb-btn {
  display: block;
  flex-shrink: 0;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  border-radius: 10px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

#hydraToolsShell .hti-thumb-fallback,
#hydraToolsShell .hti-detail-hero__fallback {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  background: linear-gradient(145deg, #f1f5f9 0%, #e2e8f0 100%);
  flex-shrink: 0;
}

/* Detail hero in drawer/modal */
#hydraToolsShell .hti-detail-hero {
  margin: 0 0 12px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

#hydraToolsShell .hti-detail-hero__btn {
  display: block;
  width: 100%;
  max-width: 200px;
  margin: 0 auto;
  padding: 0;
  border: 0;
  background: transparent;
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
}

#hydraToolsShell .hti-detail-hero__img {
  display: block;
  width: 100%;
  max-height: 130px;
  object-fit: contain;
  background: #f8fafc;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.2);
}

#hydraToolsShell .hti-detail-hero--empty .hti-detail-hero__fallback {
  width: 100%;
  max-width: 120px;
  height: 72px;
  margin: 0 auto;
  border-radius: 14px;
}

/* Hit library list — thumb + text row */
#hydraToolsShell .ht-list-item--has-thumb {
  display: grid !important;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  text-align: left;
}

#hydraToolsShell .ht-list-item--has-thumb .hti-thumb-btn {
  grid-row: 1 / span 3;
}

#hydraToolsShell .ht-list-item--has-thumb .ht-list-item__body {
  min-width: 0;
}

/* Lightbox — full viewport, pinch allowed */
.hti-img-lightbox {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-toast, 12000) + 80);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(12px, env(safe-area-inset-top, 0px)) 12px max(12px, env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;
  background: rgba(15, 23, 42, 0.88);
  isolation: isolate;
  touch-action: manipulation;
}

.hti-img-lightbox.hidden {
  display: none !important;
  pointer-events: none !important;
}

.hti-img-lightbox__backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
}

.hti-img-lightbox__x {
  position: fixed;
  top: max(12px, env(safe-area-inset-top, 0px));
  right: max(12px, env(safe-area-inset-right, 0px));
  z-index: 3;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.78);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  pointer-events: auto;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.hti-img-lightbox__img {
  position: relative;
  z-index: 1;
  max-width: min(100%, 420px);
  max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 56px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 12px;
  pointer-events: auto;
  touch-action: pinch-zoom pan-x pan-y;
}

html.hti-lightbox-open,
body.hti-lightbox-open {
  overflow: hidden;
}

/* Form image preview row */
#hydraToolsShell .hti-form-image-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}

#hydraToolsShell .hti-form-image-preview {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  object-fit: cover;
  background: #f8fafc;
  border: 1px solid rgba(148, 163, 184, 0.25);
  flex-shrink: 0;
}

#hydraToolsShell .hti-form-image-preview--empty {
  background: linear-gradient(145deg, #f1f5f9 0%, #e2e8f0 100%);
}

@media (max-width: 430px) {
  #hydraToolsShell .hti-detail-hero__img {
    max-height: 120px;
  }

  #hydraToolsShell .hti-detail-hero__btn {
    max-width: 140px;
  }
}
