/* =========================
   KOREA GALLERY CSS (v2)
   Full replacement
   ========================= */

/* styles-v2.css has a global `* { height:100% }`.
   Neutralize ONLY inside this module. */
#korea-gallery-root,
#korea-gallery-root *{
  height: auto !important;
  min-height: 0 !important;
}

#korea-gallery-root{
  padding-bottom: 60px;
}

/* ---- Panel text ---- */
#korea-gallery-root .unit-details{
  margin: 0 auto 2%;
  max-width: 50%;
}

/* ---- Section header bar ---- */
#korea-gallery-root .sectionHeader{
  max-width: 975px;
  width: calc(100% - 40px);
  margin: 10px auto;
  padding: 10px;
  text-align: left;
  outline: 1px solid #fff;
}

/* =========================
   PATCH ROWS
   ========================= */

/* IMPORTANT:
   Don’t pin rows to min(975px,92vw) — that can easily end up < 924px depending
   on parent widths/padding and cause “lone last item” spills.
   Instead: fill parent, cap at 975, and keep padding predictable. */
#korea-gallery-root .patchButtonRow{
  max-width: 975px;
  width: calc(100% - 40px);
  margin: 0 auto 18px;
}

/* LAND section (first .sectionBlock): use GRID packing */
#korea-gallery-root .sectionBlock:nth-of-type(1) .patchButtonRow{
  display: grid;

  /* Each tile is a fixed track so packing stays consistent like v1.
     Auto-fit will create as many columns as can fit; it will only wrap when necessary. */
  grid-template-columns: repeat(auto-fit, 92px);

  justify-content: center;     /* cluster centered */
  align-content: start;

  column-gap: 5px;            /* tighter than your “spread out” version */
  row-gap: 12px;
}

/* NAVAL + AIR: centered cluster, NOT space-between */
#korea-gallery-root .sectionBlock:nth-of-type(n+2) .patchButtonRow{
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;

  gap: 12px;                   /* closer like v1 */
}

/* =========================
   PATCH BUTTONS
   ========================= */

#korea-gallery-root .patchButton{
  width: 100px;
  height: 125px;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;

  text-align: center;
  cursor: pointer;

  font-family: "Jost";
  color: #fff;

  transform: translateZ(0) scale(1);
  transform-origin: center;
  transition: transform 120ms ease, color 120ms ease;
}

#korea-gallery-root .patchButton:hover{
  color: #FFB719;
  transform: translateZ(0) scale(1.06);
}

/* Icon size (match v1 feel) */
#korea-gallery-root .patchButton > img:not(.patchArrow){
  width: 100px;
  height: 100px;
  object-fit: contain;
  display: block;
  margin: 0;
}

/* Label: reserve space so row height is stable */
#korea-gallery-root .patchLabel{
  display: block;
  margin-top: 10px;

  height: 18px;
  line-height: 18px;

  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;

  font-size: 14px;
}

/* Arrow: hidden unless active */
#korea-gallery-root .patchArrow{
  display: none !important;
  width: 22px !important;   /* v1-ish */
  height: auto !important;
  margin-top: 10px;
  opacity: 0.95;
}

/* Active: arrow replaces label */
#korea-gallery-root .patchButton.active{
  color: #FFB719;
}

#korea-gallery-root .patchButton.active .patchLabel{
  display: none !important;
}

#korea-gallery-root .patchButton.active .patchArrow{
  display: block !important;
}

/* =========================
   PANEL HOST + GALLERY
   ========================= */

#korea-gallery-root .rowPanelHost{
  width: 100%;
  text-align: center;
  margin-top: 18px;
  margin-bottom: 24px;
}

#korea-gallery-root .galleryPanel{
  display: none; /* toggled by JS */
  width: auto;
  margin: 0 auto 25px;
}

/* Panel title/desc */
#korea-gallery-root .unitTitle{
  font-size: 28px;
  margin: 25px;
  text-align: center;
  color: #FFB715;
}

#korea-gallery-root .unitDesc{
  text-align: justify;
}

/* Gallery grid */
#korea-gallery-root .gallery-container{
  width: 80%;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-block: 2%;
}

/* Object tiles */
#korea-gallery-root .gallery-item{
  max-width: 200px;
  border: 1px solid rgba(255,255,255,0);
  transform: translateZ(0) scale(1);
  transform-origin: center;
  transition: transform 120ms ease, border-color 120ms ease;
}

#korea-gallery-root .gallery-item:hover{
  transform: translateZ(0) scale(1.05);
  border-color: #fff;
}

#korea-gallery-root .gallery-item img{
  width: 95%;
  height: auto;
}

#korea-gallery-root .gallery-item a{
  background-color: transparent;
}

#korea-gallery-root .title{
  padding: 5px;
  text-align: center;
  color: #d2d2d2;
  font-family: "Jost";
  font-size: 14px;
}

#korea-gallery-root .desc{
  text-align: center;
  color: #A9A9A9;
  font-family: "Jost";
  font-size: 13px;
}

/* =========================
   RESPONSIVE
   ========================= */

/* Slightly smaller tiles when needed; still grid-packed */
@media (max-width: 1100px){
  #korea-gallery-root .sectionBlock:nth-of-type(1) .patchButtonRow{
    grid-template-columns: repeat(auto-fit, 84px);
    column-gap: 10px;
  }

  #korea-gallery-root .patchButton{
    width: 84px;
    height: 120px;
  }

  #korea-gallery-root .patchButton > img:not(.patchArrow){
    width: 78px;
    height: 78px;
  }
}

@media (max-width: 700px){
  #korea-gallery-root .sectionBlock:nth-of-type(1) .patchButtonRow{
    grid-template-columns: repeat(auto-fit, 78px);
    column-gap: 10px;
    row-gap: 18px;
  }

  #korea-gallery-root .patchButton{
    width: 78px;
    height: 114px;
  }

  #korea-gallery-root .patchLabel{
    font-size: 12px;
  }

  #korea-gallery-root .sectionBlock:nth-of-type(n+2) .patchButtonRow{
    gap: 18px; /* tighter on mobile */
  }
}
