/* Travel catalogue, itinerary, service and traveller-story photographs.
   Load after media-rich.css and calm-system.css. Homepage, Care, tools and
   destination/information pages are deliberately outside these selectors.

   Verified conflicts addressed here:
   - Legacy 4:3 cover boxes around 3:2 media derivatives left a blank strip.
   - Legacy service actions in column 2 created an implicit second column.
   - Global story-photo width/height caps also shrank landscape/hotel photos.
   - Mixed portrait/landscape review photos produced uneven gallery rows.
   <picture> support keeps the same frame contract if responsive wrappers are
   emitted later; the currently checked travel pages use direct <img> tags. */

/* A single cover frame owns the ratio; its image always fills that frame. */
body.ltc-calm.mr-photo-catalog .store-card-image {
  display: block;
  width: 100%;
  min-width: 0;
  aspect-ratio: 3 / 2 !important;
  margin: 0;
  padding: 0 !important;
  overflow: hidden;
  border: 0 !important;
  border-radius: 20px !important;
  background: #f5f5f7;
  line-height: 0;
  box-shadow: none !important;
  transform: none !important;
}

body.ltc-calm.mr-photo-catalog .store-card-image > :is(img, picture),
body.ltc-calm.mr-photo-catalog .store-card-image > picture > img {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  max-height: none !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: inherit !important;
  aspect-ratio: auto !important;
  object-fit: cover !important;
  transform: none !important;
}

/* Compact service directory: image + copy, then an unambiguous action row.
   Reset every item's placement so the old grid-column:2 cannot create a
   hidden extra column or displace the feedback area. */
body.ltc-calm.mr-photo-catalog .jd-service-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: stretch;
}

body.ltc-calm.mr-photo-catalog .jd-service-card:has(> .mr-service-cover) {
  display: grid !important;
  grid-template-columns: 112px minmax(0, 1fr) !important;
  grid-template-rows: minmax(112px, 1fr) auto;
  gap: 16px 18px !important;
  width: 100%;
  min-width: 0;
  padding: 20px !important;
  box-sizing: border-box;
  align-items: start;
  border-radius: 20px !important;
  overflow: hidden;
}

body.ltc-calm.mr-photo-catalog .jd-service-card > .mr-service-cover {
  grid-column: 1 !important;
  grid-row: 1 !important;
  width: 112px !important;
  height: 112px !important;
  aspect-ratio: 1 !important;
  margin: 0 !important;
  border-radius: 16px !important;
}

body.ltc-calm.mr-photo-catalog .jd-service-card:has(> .mr-service-cover) > .jd-service-icon {
  display: none;
}

body.ltc-calm.mr-photo-catalog .jd-service-card:has(> .mr-service-cover) > div:not(.jd-service-actions) {
  grid-column: 2 !important;
  grid-row: 1 !important;
  min-width: 0;
  padding: 0 !important;
}

body.ltc-calm.mr-photo-catalog .jd-service-card:has(> .mr-service-cover) h3 {
  margin: 0 0 8px;
  font-size: 20px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

body.ltc-calm.mr-photo-catalog .jd-service-card:has(> .mr-service-cover) > div:not(.jd-service-actions) > p {
  margin: 0;
  font-size: 15px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

body.ltc-calm.mr-photo-catalog .jd-service-card:has(> .mr-service-cover) > .jd-service-actions {
  grid-column: 1 / -1 !important;
  grid-row: 2 !important;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 14px;
  min-width: 0;
  margin: 0 !important;
  padding: 12px 0 0 !important;
  border-top: 1px solid #e5e5e7;
}

body.ltc-calm.mr-photo-catalog .jd-service-card > [data-choice-feedback] {
  grid-column: 1 / -1 !important;
  grid-row: 3 !important;
  min-width: 0;
  margin: 0;
  padding: 0 !important;
}

body.ltc-calm.mr-photo-catalog .jd-service-card > [data-choice-feedback]:empty {
  display: none;
}

/* Existing comparison and short-tour frames already define the correct
   ratio. Retain it, and make direct/responsive images use the whole slot. */
body.ltc-calm[data-page="selection"] .ed-compare-photo,
.calm-hub .calm-tour-image {
  min-width: 0;
  overflow: hidden;
  border-radius: 20px;
  line-height: 0;
  background: #f5f5f7;
}

body.ltc-calm[data-page="selection"] .ed-compare-photo > :is(img, picture),
body.ltc-calm[data-page="selection"] .ed-compare-photo > picture > img,
.calm-hub .calm-tour-image > :is(img, picture),
.calm-hub .calm-tour-image > picture > img {
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  aspect-ratio: auto;
  object-fit: cover;
}

body.ltc-calm[data-page="selection"] .ed-compare-photo > span {
  line-height: 1.5;
}

/* Removing the image's intrinsic grid contribution prevents a tall source
   from forcing a 740px row even when its column is much narrower. Multi-day
   covers also respect the 1024px originals used by several approved routes. */
body.ltc-calm.catalog-notebook .jd-detail-intro > .ltc-cover {
  width: 100%;
  height: auto;
  max-width: 960px;
  min-height: 0;
  aspect-ratio: 3 / 2;
  grid-template-rows: minmax(0, 1fr);
  align-self: center;
  justify-self: center;
}

body.ltc-calm.catalog-notebook .jd-multi .jd-detail-intro > .ltc-cover {
  width: min(100%, 960px);
  margin: 26px auto 36px !important;
  aspect-ratio: 16 / 9;
}

body.ltc-calm.catalog-notebook .jd-short .jd-detail-intro > .ltc-cover {
  max-width: 640px;
}

body.ltc-calm.catalog-notebook .ltc-cover:not(.ltc-pair):is(:has(img[src*="huangshizhai-cableway"]), :has(source[srcset*="huangshizhai-cableway"])) {
  width: min(100%, 480px) !important;
  max-width: 480px !important;
  aspect-ratio: 4 / 3;
}

body.ltc-calm.catalog-notebook .ltc-cover.ltc-pair:has(> .ltc-cover-frame:first-child img[src*="huangshizhai-cableway"]) {
  width: min(100%, 700px) !important;
  max-width: 700px !important;
}

body.ltc-calm.catalog-notebook .ltc-cover-standalone {
  width: min(100%, 880px) !important;
  height: auto;
  min-height: 0;
  aspect-ratio: 16 / 9;
  grid-template-rows: minmax(0, 1fr);
  margin: 24px auto 32px !important;
}

body.ltc-calm.catalog-notebook .ltc-cover-frame {
  position: relative;
  min-width: 0;
  min-height: 0;
}

body.ltc-calm.catalog-notebook .ltc-cover-frame > :is(img, picture),
body.ltc-calm.catalog-notebook .ltc-cover-frame > picture > img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  max-height: none;
  margin: 0;
  aspect-ratio: auto;
  object-fit: cover;
  border-radius: inherit;
}

body.ltc-calm.catalog-notebook .jd-step-copy > a:has(> .jd-step-photo),
body.ltc-calm.catalog-notebook .jd-step-copy > a:has(> picture > .jd-step-photo) {
  display: block;
  margin-top: 18px;
  overflow: hidden;
  border-radius: 20px;
  line-height: 0;
}

body.ltc-calm.catalog-notebook .jd-step-copy > a > .jd-step-photo,
body.ltc-calm.catalog-notebook .jd-step-copy > a > picture,
body.ltc-calm.catalog-notebook .jd-step-copy > a > picture > .jd-step-photo {
  display: block;
  width: 100%;
  height: auto;
  margin-top: 0;
  border-radius: inherit;
}

/* Scenic itinerary photographs can use the available reading width; guest
   records keep the smaller, secondary presentation selected for the site.
   The 4-night itinerary uses main > section.day without .route-detail. */
body.ltc-calm:is(.route-detail, :has(> main > section.day)) .story-photo:not(:has(img[src*="guest-"])) {
  width: min(calc(100% - 52px), 900px);
  max-width: none !important;
  margin: 24px auto !important;
}

body.ltc-calm:is(.route-detail, :has(> main > section.day)) .photopair {
  gap: 20px;
  align-items: start;
}

body.ltc-calm:is(.route-detail, :has(> main > section.day)) :is(.photopair, .arrival-pair, .photo-note-pair, .coffee-editorial) > figure.story-photo {
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
}

body.ltc-calm:is(.route-detail, :has(> main > section.day), .service-page:not(.service-inquiry)) .story-photo > :is(.photo, .mr-scene-photo) {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0 !important;
  overflow: hidden;
  border: 0 !important;
  border-radius: 20px;
  background: #f5f5f7;
  line-height: 0;
  box-shadow: none !important;
}

body.ltc-calm:is(.route-detail, :has(> main > section.day)) .story-photo:not(:has(img[src*="guest-"])) .photo,
body.ltc-calm.service-page:not(.service-inquiry) .story-photo .photo {
  aspect-ratio: 3 / 2;
}

body.ltc-calm:is(.route-detail, :has(> main > section.day)) .story-photo:not(:has(img[src*="guest-"])) .photo > :is(img, picture),
body.ltc-calm:is(.route-detail, :has(> main > section.day)) .story-photo:not(:has(img[src*="guest-"])) .photo > picture > img,
body.ltc-calm.service-page:not(.service-inquiry) .story-photo .photo > :is(img, picture),
body.ltc-calm.service-page:not(.service-inquiry) .story-photo .photo > picture > img {
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-height: none !important;
  margin: 0;
  border: 0 !important;
  box-shadow: none !important;
  aspect-ratio: auto !important;
  object-fit: cover !important;
}

body.ltc-calm:is(.route-detail, :has(> main > section.day)) .story-photo:has(img[src*="bailong"]) .photo {
  width: min(100%, 500px);
  margin-inline: auto;
  aspect-ratio: 4 / 5;
}

body.ltc-calm:is(.route-detail, :has(> main > section.day), .service-page:not(.service-inquiry)) .story-photo:has(img[src*="guest-"]) :is(.photo, .mr-scene-photo) {
  aspect-ratio: 3 / 2;
}

body.ltc-calm:is(.route-detail, :has(> main > section.day), .service-page:not(.service-inquiry)) .story-photo:has(img[src*="guest-"]) :is(.photo, .mr-scene-photo) > :is(img, picture),
body.ltc-calm:is(.route-detail, :has(> main > section.day), .service-page:not(.service-inquiry)) .story-photo:has(img[src*="guest-"]) :is(.photo, .mr-scene-photo) > picture > img {
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-height: none !important;
  margin: 0;
  border: 0 !important;
  box-shadow: none !important;
  aspect-ratio: auto !important;
  object-fit: cover !important;
  object-position: 50% 42%;
}

body.ltc-calm:is(.route-detail, :has(> main > section.day), .service-page:not(.service-inquiry)) .story-photo figcaption {
  padding-top: 14px;
  line-height: 1.65;
}

body.ltc-calm.service-page:not(.service-inquiry) .service-reference > :is(img, picture) {
  display: block;
  width: 100% !important;
  height: auto !important;
  max-height: none !important;
  margin: 0;
  border: 0 !important;
  border-radius: 20px;
  aspect-ratio: 3 / 2;
  object-fit: cover;
}

body.ltc-calm.service-page:not(.service-inquiry) .service-reference > picture > img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Hotel summaries contain a caption below the photo: size only the picture,
   not the summary. Expanded rails show two complete reference photos. */
body.ltc-calm:is(.route-detail, :has(> main > section.day)) .hotel-album > summary > :is(img, picture) {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  object-fit: cover;
  border-radius: 20px;
}

body.ltc-calm:is(.route-detail, :has(> main > section.day)) .hotel-album > summary > picture > img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

body.ltc-calm:is(.route-detail, :has(> main > section.day)) .media-rail {
  gap: 20px;
  align-items: start;
  padding-block: 16px 8px;
}

body.ltc-calm:is(.route-detail, :has(> main > section.day)) .media-rail > figure.story-photo {
  flex: 0 0 calc((100% - 20px) / 2);
  width: auto;
  max-width: none !important;
  margin: 0 !important;
}

body.ltc-calm:is(.route-detail, :has(> main > section.day)) .media-rail .photo > img,
body.ltc-calm:is(.route-detail, :has(> main > section.day)) .media-rail .photo > picture > img {
  object-fit: cover !important;
}

/* The source is a 788 x 1050 portrait, so keep a matching portrait frame
   and a smaller reading width instead of enlarging it into a wide scene. */
body.ltc-calm:is(.route-detail, :has(> main > section.day)) figure.story-photo:has(img[src*="/cave-08-"]) {
  width: min(calc(100% - 40px), 600px) !important;
  max-width: 600px !important;
}

body.ltc-calm:is(.route-detail, :has(> main > section.day)) figure.story-photo:has(img[src*="/cave-08-"]) > .photo {
  aspect-ratio: 788 / 1050 !important;
}

/* photo-gallery.js replaces the static meal record after load. Its generated
   .gallery-slide button needs the same zero-padding photo frame contract;
   the old notebook style otherwise inserts seven white pixels per side. */
body.ltc-calm:is(.route-detail, :has(> main > section.day)) .photo-gallery .gallery-track {
  gap: 20px;
}

body.ltc-calm:is(.route-detail, :has(> main > section.day)) .photo-gallery .gallery-slide {
  min-width: 0;
  margin: 0;
}

body.ltc-calm:is(.route-detail, :has(> main > section.day)) .photo-gallery .gallery-slide > button {
  display: block;
  width: 100%;
  min-height: 0;
  aspect-ratio: 3 / 2;
  margin: 0;
  padding: 0 !important;
  overflow: hidden !important;
  border: 0 !important;
  border-radius: 20px !important;
  background: #f5f5f7;
  line-height: 0;
  box-shadow: none !important;
  transform: none !important;
}

body.ltc-calm:is(.route-detail, :has(> main > section.day)) .photo-gallery .gallery-slide > button > :is(img, picture),
body.ltc-calm:is(.route-detail, :has(> main > section.day)) .photo-gallery .gallery-slide > button > picture > img {
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-height: none !important;
  margin: 0;
  padding: 0 !important;
  border: 0 !important;
  border-radius: inherit;
  aspect-ratio: auto !important;
  object-fit: cover !important;
  box-shadow: none !important;
}

/* Equal review thumbnail slots remove uneven rows. The original-photo links
   remain intact, and the original full-size image is not modified. */
.review-entry .gallery {
  gap: 20px;
  align-items: start;
}

.review-entry .gallery figure {
  min-width: 0;
  margin: 0;
}

.review-entry .gallery figure > a {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  border-radius: 20px;
  background: #f5f5f7;
  line-height: 0;
}

.review-entry .gallery figure > a > :is(img, picture),
.review-entry .gallery figure > a > picture > img {
  display: block;
  width: 100%;
  height: 100%;
  max-height: none;
  margin: 0;
  aspect-ratio: auto;
  object-fit: cover;
  border-radius: inherit;
}

.review-entry .gallery figcaption {
  margin-top: 10px;
  line-height: 1.6;
}

/* Reference images that need to be read rather than cropped retain their
   full content. Full-size photo/document dialogs are outside every rule. */
body.ltc-calm:is(.catalog-notebook, .route-detail, :has(> main > section.day), .service-page:not(.service-inquiry)) :is(.ltc-cover-frame, .photo, .gallery-slide > button) img:is([src*="qrcode"], [src*="qr-code"], [alt*="QR"], [alt*="二维码"], [alt*="사업자등록"], [alt*="영수증"], [alt*="예약 확인서"], [alt*="营业执照"], [alt*="票据"], [alt*="收据"]),
.review-entry .gallery img:is([src*="qrcode"], [src*="qr-code"], [alt*="QR"], [alt*="二维码"], [alt*="사업자등록"], [alt*="영수증"], [alt*="예약 확인서"], [alt*="营业执照"], [alt*="票据"], [alt*="收据"]) {
  object-fit: contain !important;
}

@media (max-width: 760px) {
  body.ltc-calm.mr-photo-catalog .jd-service-list {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }

  body.ltc-calm:is(.route-detail, :has(> main > section.day)) .story-photo:not(:has(img[src*="guest-"])) {
    width: calc(100% - 40px);
    margin-block: 20px !important;
  }

  body.ltc-calm:is(.route-detail, :has(> main > section.day)) .photopair,
  body.ltc-calm:is(.route-detail, :has(> main > section.day)) .media-rail,
  .review-entry .gallery {
    gap: 16px;
  }

  body.ltc-calm:is(.route-detail, :has(> main > section.day)) .media-rail > figure.story-photo {
    flex-basis: 88%;
  }
}

@media (max-width: 650px) {
  body.ltc-calm.mr-photo-catalog .jd-service-card:has(> .mr-service-cover) {
    grid-template-columns: 88px minmax(0, 1fr) !important;
    grid-template-rows: minmax(88px, 1fr) auto;
    gap: 14px 16px !important;
    padding: 18px !important;
  }

  body.ltc-calm.mr-photo-catalog .jd-service-card > .mr-service-cover {
    width: 88px !important;
    height: 88px !important;
    border-radius: 14px !important;
  }

  body.ltc-calm.mr-photo-catalog .jd-service-card:has(> .mr-service-cover) h3 {
    font-size: 19px;
  }
}
