/* =========================================================================
   Global — #tptdental gallery section
   ========================================================================= */

.hp-gallery {
  padding: 72px 0;
}

.hp-gallery .container {
  max-width: 1276px;
}

/* Desktop: section fit full viewport, noi dung canh giua */
@media screen and (min-width: 1025px) {
  .hp-gallery {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-sizing: border-box;
  }

  body.admin-bar .hp-gallery {
    min-height: calc(100vh - 32px);
    min-height: calc(100dvh - 32px);
  }
}
.hp-gallery__title {
  margin-bottom: 20px;
  color: #293948;
  font-family: var(--font-hn);
  font-weight: 700;
  font-size: 30px;
  line-height: 136%;
  letter-spacing: 0.01em;

}

/* --- Desktop: 3 columns, each with a big image + row of 2 smalls ---------- */
.hp-gallery__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.hp-gallery__col {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hp-gallery__row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.hp-gallery__item {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: 20px;
  background: #F5F5F5;
  text-decoration: none;
  /* Button reset (item co the render la <button>) */
  border: 0;
  padding: 0;
  margin: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
  width: 100%;
}

button.hp-gallery__item {
  appearance: none;
  -webkit-appearance: none;
}

div.hp-gallery__item {
  cursor: default;
}

/* Ti le 4:5 (portrait) cho ca big lan small */
.hp-gallery__item {
  aspect-ratio: 4 / 5;
  height: auto;
}

.hp-gallery__item--big,
.hp-gallery__item--small {
  height: auto;
  max-height: none;
}

.hp-gallery__img,
.hp-gallery__video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.hp-gallery__video {
  background: #000;
}

a.hp-gallery__item:hover .hp-gallery__img,
a.hp-gallery__item:focus .hp-gallery__img,
button.hp-gallery__item:hover .hp-gallery__img,
button.hp-gallery__item:focus .hp-gallery__img,
a.hp-gallery__item:hover .hp-gallery__video,
button.hp-gallery__item:hover .hp-gallery__video {
  transform: scale(1.04);
}

/* Play icon overlay cho YouTube-only tile */
.hp-gallery__play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  pointer-events: none;
  transition: transform 0.25s ease;
}

.hp-gallery__item:hover .hp-gallery__play {
  transform: translate(-50%, -50%) scale(1.08);
}

.hp-gallery__play svg {
  width: 100%;
  height: 100%;
}

.hp-gallery__icon {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 2;
  width: 20px;
  height: 20px;
  object-fit: contain;
}

/* --- Hidden columns (before "Xem thêm" clicked) --------------------------- */
.hp-gallery__col--hidden {
  display: none;
}

/* --- Xem them / View all buttons ------------------------------------------ */
.hp-gallery__more-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin-top: 20px;
}

.hp-gallery__more {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  border: 1px solid #293948;
  border-radius: 40px;
  background: transparent;
  color: #293948;
  font-family: var(--font-hn);
  font-weight: 500;
  font-size: 16px;
  line-height: 150%;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}

.hp-gallery__more[hidden] {
  display: none !important;
}

.hp-gallery__more:hover,
.hp-gallery__more:focus {
  background: #D85401;
  border-color: #D85401;
  color: #FFFFFF;
}

.hp-gallery__more svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  transition: transform 0.25s ease;
}

.hp-gallery__view-all {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  border: 1px solid #293948;
  border-radius: 40px;
  background: transparent;
  color: #293948;
  font-family: var(--font-hn);
  font-weight: 500;
  font-size: 16px;
  line-height: 150%;
  letter-spacing: 0.02em;
  text-decoration: none;
  transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}

.hp-gallery__view-all[hidden] {
  display: none !important;
}

.hp-gallery__view-all:hover,
.hp-gallery__view-all:focus {
  background: #D85401;
  border-color: #D85401;
  color: #FFFFFF;
}

.hp-gallery__view-all svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* --- Tablet: keep 3-column layout, aspect-ratio tu dieu chinh ------------ */

@media screen and (max-width: 900px) {
  .hp-gallery {
    padding: 0 0 64px 0;
  }
}

/* --- Mobile: horizontal drag carousel (no next/prev buttons) -------------- */
@media screen and (max-width: 767px) {
  .hp-gallery {
    padding: 0 0 48px 0;
  }

  /* Let the carousel bleed edge-to-edge on mobile: neutralize the container's
     side padding just for the gallery, then reintroduce it inside so the title
     and first slide stay aligned with the rest of the page. */
  .hp-gallery > .container {
    padding-left: 0;
    padding-right: 0;
    max-width: none;
  }

  .hp-gallery__title {
    margin: 0 15px 24px;
    font-size: 24px;
  }

  .hp-gallery__grid {
    display: flex;
    grid-template-columns: none;
    gap: 12px;
    padding: 0 15px 12px 15px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scroll-padding-left: 15px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .hp-gallery__grid::-webkit-scrollbar {
    display: none;
  }

  .hp-gallery__col {
    flex: 0 0 78%;
    scroll-snap-align: start;
  }

  .hp-gallery__icon {
    right: 12px;
    bottom: 12px;
    width: 20px;
    height: 20px;
  }
}

/* =========================================================================
   Popup — 2-column: media LEFT + WYSIWYG content RIGHT
   ========================================================================= */
.hp-gallery__popup[hidden] {
  display: none !important;
}

.hp-gallery__popup {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
}

.hp-gallery__popup-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 28, 40, 0.72);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.hp-gallery__popup-box {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 960px;
  max-height: 82vh;
  background: transparent;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.35);
}

.hp-gallery__popup-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  color: #293948;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.hp-gallery__popup-close:hover {
  background: #FFFFFF;
}

.hp-gallery__popup-close svg {
  display: block;
}

.hp-gallery__popup-body {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  height: 82vh;
  max-height: 640px;
  background: #FFFFFF;
  border-radius: 16px;
  overflow: hidden;
}

/* --- Left: media (video / image) ---------------------------------------- */
.hp-gallery__popup-media {
  position: relative;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.hp-gallery__popup-media iframe,
.hp-gallery__popup-media video,
.hp-gallery__popup-media img {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  object-fit: contain;
}

/* --- Right: WYSIWYG content panel --------------------------------------- */
.hp-gallery__popup-side {
  padding: 28px 28px 28px 28px;
  overflow-y: auto;
  background: #FFFFFF;
  color: #293948;
  font-family: var(--font-hn);
  font-size: 14px;
  line-height: 1.55;
  letter-spacing: 0.01em;
}

.hp-gallery__popup-side > *:first-child { margin-top: 0; }
.hp-gallery__popup-side > *:last-child  { margin-bottom: 0; }

.hp-gallery__popup-side h1,
.hp-gallery__popup-side h2 {
  margin: 0 0 12px;
  color: #293948;
  font-weight: 700;
  font-size: 20px;
  line-height: 1.35;
}

.hp-gallery__popup-side h3 {
  margin: 16px 0 8px;
  font-weight: 700;
  font-size: 17px;
  line-height: 1.4;
}

.hp-gallery__popup-side h4,
.hp-gallery__popup-side h5,
.hp-gallery__popup-side h6 {
  margin: 14px 0 6px;
  font-weight: 600;
  font-size: 15px;
  line-height: 1.4;
}

.hp-gallery__popup-side p {
  margin: 0 0 12px;
}

.hp-gallery__popup-side a {
  color: #D85401;
  text-decoration: underline;
}

.hp-gallery__popup-side ul,
.hp-gallery__popup-side ol {
  margin: 0 0 12px;
  padding-left: 20px;
}

.hp-gallery__popup-side li {
  margin: 0 0 4px;
}

.hp-gallery__popup-side img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 12px 0;
  border-radius: 8px;
}

.hp-gallery__popup-side blockquote {
  margin: 12px 0;
  padding: 8px 14px;
  border-left: 3px solid #D85401;
  color: #465E75;
  font-style: italic;
}

/* Body scroll lock khi popup mo */
html.hp-gallery-locked,
html.hp-gallery-locked body {
  overflow: hidden;
}

/* --- Popup responsive --------------------------------------------------- */
@media screen and (max-width: 900px) {
  .hp-gallery__popup {
    padding: 16px;
  }
  .hp-gallery__popup-box {
    max-height: 88vh;
  }
  .hp-gallery__popup-body {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    height: auto;
    max-height: 88vh;
  }
  .hp-gallery__popup-media {
    aspect-ratio: 16 / 9;
    max-height: 45vh;
  }
  .hp-gallery__popup-side {
    padding: 20px;
    font-size: 13.5px;
    max-height: 43vh;
  }
  .hp-gallery__popup-side h1,
  .hp-gallery__popup-side h2 { font-size: 18px; }
  .hp-gallery__popup-side h3 { font-size: 16px; }
}

@media screen and (max-width: 480px) {
  .hp-gallery__popup { padding: 10px; }
  .hp-gallery__popup-side { padding: 16px; }
}
