/* Page shell */
.detail-header {
  background: #1b1a1a;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  color: #fff;
}

.detail-wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: clamp(14px, 3vw, 22px);
  display: grid;
  gap: 6px;
}

.back-link {
  color: #e5b567;
  text-decoration: none;
  font-weight: 700;
}

.back-link:hover {
  text-decoration: underline;
}

.detail-name {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 900;
}

.detail-region {
  opacity: .85;
}

.detail-main {
  color: #fff;
  padding: clamp(16px, 3vw, 32px);
}

.soldier-detail {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  gap: clamp(16px, 3vw, 28px);
}

/* Hero portrait + cards grid */
.detail-hero {
  aspect-ratio: 16 / 9;
  background: black;
  overflow: hidden;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .35);
}

.detail-hero img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.detail-hero .placeholder {
  display: grid;
  place-items: center;
  color: #ccc;
  height: 100%;
}

.detail-sections {
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(12px, 2.5vw, 20px);
}

@media (min-width: 900px) {
  .detail-sections {
    grid-template-columns: repeat(3, 1fr);
  }

  .card-longform {
    grid-column: 1 / -1;
  }
}

.card {
  background: #1f1e1e;
  border: 1px solid rgba(255, 255, 255, .06);
  padding: clamp(14px, 2.5vw, 20px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, .25);
}

.card h2 {
  font-size: clamp(1.15rem, 2.8vw, 1.35rem);
  margin-bottom: .6em;
}

/* Key-value layout */
.kvlist {
  display: grid;
  gap: 8px;
}

.kv {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, .03);
}

.kv dt {
  font-weight: 700;
  opacity: .95;
}

.kv dd {
  margin: 0;
  opacity: .9;
}

.longfield+.longfield {
  margin-top: 1rem;
}

.longfield h3 {
  font-size: 1rem;
  margin: 0 0 .4rem 0;
}

.longfield p {
  margin: 0;
  white-space: pre-wrap;
}

.muted {
  color: #cfcfcf;
  opacity: .7;
}

/* Gallery grid */
.gallery.card {
  max-width: 1200px;
  margin: 24px auto 0;
}

.photo-grid {
  /* Each tile will be between 140px and 220px wide; never bigger than 220px. */
  --tile: clamp(140px, 22vw, 220px);

  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(var(--tile), var(--tile)));
  gap: clamp(8px, 2vw, 14px);

  /* Center leftover space when there are few items (1 image won’t stretch full width). */
  justify-content: center;
}

.photo-tile {
  aspect-ratio: 1 / 1;
  width: var(--tile);
  /* explicit width matches the column track */
  max-width: var(--tile);
  /* belt & suspenders */
  border: 0;
  padding: 0;
  background: #2a2927;
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 2px 14px rgba(0, 0, 0, .25);
  transition: transform .16s ease, box-shadow .16s ease;
}

@media (min-width: 1100px) {

  /* If you want slightly larger caps on big screens, bump the max to 260px: */
  .photo-grid {
    --tile: clamp(150px, 18vw, 260px);
  }
}

.photo-tile:hover,
.photo-tile:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 10px 26px rgba(0, 0, 0, .35);
  outline: 2px solid #e5b567;
  outline-offset: 2px;
}

.photo-tile img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  /* show whole image inside the square */
  background: black;
}

/* Lightbox */
.lightbox[hidden] {
  display: none;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 30000;
  display: grid;
  place-items: center;
}

.lb-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .7);
}

.lb-stage {
  position: relative;
  width: min(94vw, 1200px);
  height: min(90vh, 90vh);
  background: #0f0f0f;
  border: 1px solid rgba(255, 255, 255, .1);
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .6);

  /* CHANGED: use flex to center canvas and keep controls at bottom */
  display: flex;
  flex-direction: column;
}

.lb-close {
  position: absolute;
  top: 8px;
  right: 8px;
  border: 0;
  padding: 8px 12px;
  background: rgba(255, 255, 255, .1);
  color: #fff;
  cursor: pointer;
  font-size: 1.4rem;
}

/* NEW: canvas area that centers the image and prevents cropping */
.lb-canvas {
  flex: 1;
  min-height: 0;
  /* allow flex child to shrink properly */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  /* small gutter so image never kisses edges */
  overflow: hidden;
  /* no scrollbars; image always contained */
  background: #0b0b0b;
}

/* CHANGED: intrinsic sizing — show entire image */
.lb-img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  /* <- ensures whole image fits */
  /* object-fit removed to avoid any crop behavior */
}

.lb-controls {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, .06);
}

.lb-prev,
.lb-next {
  border: 0;
  padding: 10px 14px;
  background: rgba(255, 255, 255, .1);
  color: #fff;
  cursor: pointer;
  font-size: 1.2rem;
}

.lb-counter {
  text-align: center;
  opacity: .85;
  color: white;
}