/* PTJornada 城市導讀與景點內文。 */
body[data-city-format="city-places"][data-city-page] {
  --city-reading-width: 51rem;
  --city-gutter: clamp(1.3rem, 3vw, 2.75rem);
  --city-section-gap: clamp(2rem, 4vw, 3.5rem);
}

/* A city opens as a feature. Prose can continue down past the opening photograph. */
body[data-city-page="city"] .intro.editorial-hero {
  max-width: min(100%, 55rem);
  margin-inline: auto;
}
body[data-city-page="city"] .intro.editorial-hero .editorial-story {
  min-width: 0;
}
body[data-city-page="city"] .intro.editorial-hero .editorial-story p,
body[data-city-page="place"] .prose > p,
body[data-city-page="place"] .prose .culture-context p {
  font-size: clamp(1rem, .94rem + .2vw, 1.1rem);
  line-height: 1.85;
  color: var(--ptj-reading-ink, var(--cream));
}

/* The place photograph sits in the article's text flow. Short introductions
   can carry into the history below instead of leaving an empty side column. */
body[data-city-page="place"] main > article {
  display: flow-root;
  max-width: var(--city-reading-width);
  margin-inline: auto;
}
body[data-city-page="place"] .detail-top { display: block; margin: 0 0 1.35rem; }
body[data-city-page="place"] .detail-top h1.place-name { max-width: 21ch; line-height: 1.21; }
body[data-city-page="place"] .detail-top .lead {
  max-width: 41rem;
  margin: 1rem 0;
  font-size: clamp(1rem, .9rem + .34vw, 1.18rem);
  line-height: 1.8;
}
body[data-city-page="place"] .detail-layout {
  display: block;
  max-width: none;
  margin: 0;
  padding: 0;
  border: 0;
}
body[data-city-page="city"] .editorial-story p:not([data-ptj-text-wrap="preserve"]),
body[data-city-page="place"] .prose > p:not([data-ptj-text-wrap="preserve"]),
body[data-city-page="place"] .culture-context p:not([data-ptj-text-wrap="preserve"]) {
  white-space: normal;
  word-break: normal;
  line-break: strict;
  text-wrap: wrap;
  text-align: justify;
  text-align-last: start;
}
body[data-city-page="city"] .editorial-story p:not([data-ptj-text-wrap="preserve"]) [lang|="pt" i],
body[data-city-page="place"] .prose p:not([data-ptj-text-wrap="preserve"]) [lang|="pt" i] {
  display: inline;
  white-space: normal;
  -webkit-hyphens: auto;
  hyphens: auto;
  hyphenate-character: "-";
}
body[data-city-page="place"] .prose h2 { margin: 1.6rem 0 .8rem; }
body[data-city-page="place"] :is(.place-gallery,.visit-section,.sources,.page-end) { clear: both; }
/* The original gallery carries grid/spacing inline; override only that container. */
body[data-city-page="place"] .place-gallery[data-city-photo-pairs] {
  display: flex !important;
  flex-direction: column;
  gap: 1.2rem !important;
  margin: var(--city-section-gap) 0 !important;
}
body[data-city-page="place"] .city-photo-pair {
  display: grid;
  grid-template-columns: var(--city-photo-columns, 1fr);
  gap: 1.2rem;
  align-items: start;
}
body[data-city-page="place"] .city-photo-pair figure { margin: 0; min-width: 0; }
body[data-city-page="place"] .city-photo-pair img { width: 100%; height: auto; display: block; }
body[data-city-page="place"] .city-photo-pair:has(> figure:only-child) { max-width: 38rem; }
body[data-city-page="city"] .intro.editorial-hero .photo figcaption,
body[data-city-page="place"] main > article .photo figcaption {
  margin-top: .5rem;
  text-align: start;
  font-size: .84rem;
  line-height: 1.6;
}
@media (min-width: 760px) {
  /* Body copy fills the space next to a picture, then continues below its edge. */
  body[data-city-page="city"] .editorial-hero:not(:has([data-magazine-spread])) {
    --city-hero-size: 40%;
  }
  body[data-city-page="city"] .editorial-hero:has(> figure[data-photo-shape="portrait"]):not(:has([data-magazine-spread])) { --city-hero-size: 35%; }
  body[data-city-page="city"] .editorial-hero:has(> figure[data-photo-shape="landscape"]):not(:has([data-magazine-spread])) { --city-hero-size: 49%; }
  body[data-city-page="city"] .editorial-hero:has(> figure[data-photo-shape="panorama"]):not(:has([data-magazine-spread])) { --city-hero-size: 55%; }
  body[data-city-page="city"] .intro.editorial-hero:not(:has([data-magazine-spread])) {
    display: flow-root;
  }
  body[data-city-page="city"] .intro.editorial-hero:not(:has([data-magazine-spread])) > div:first-child {
    float: left;
    width: calc(100% - var(--city-hero-size) - var(--city-gutter));
  }
  body[data-city-page="city"] .intro.editorial-hero:not(:has([data-magazine-spread])) > figure.photo {
    float: right;
    width: var(--city-hero-size);
    margin: 0 0 1.35rem var(--city-gutter);
  }
  body[data-city-page="city"] .intro.editorial-hero:not(:has([data-magazine-spread])) > .editorial-story {
    display: block;
    clear: left;
  }
  body[data-city-page="city"] .city-visit-note[data-photo-shape="landscape"] > figure.photo {
    width: 49%;
  }
  body[data-city-page="place"] .detail-top { --place-hero-size: 38%; }
  body[data-city-page="place"] .detail-top:has(>figure[data-photo-shape="portrait"]) { --place-hero-size: 34%; }
  body[data-city-page="place"] .detail-top:has(>figure[data-photo-shape="landscape"]) { --place-hero-size: 48%; }
  body[data-city-page="place"] .detail-top:has(>figure) { display: contents; }
  body[data-city-page="place"] .detail-top:has(>figure) > div:first-child {
    float: left;
    width: calc(100% - var(--place-hero-size) - var(--city-gutter));
  }
  body[data-city-page="place"] .detail-top > figure.photo {
    float: right;
    width: var(--place-hero-size);
    margin: 0 0 1.4rem var(--city-gutter);
  }
  body[data-city-page="place"] .detail-top:has(> figure[data-photo-shape="panorama"]) { display: block; }
  body[data-city-page="place"] .detail-top:has(> figure[data-photo-shape="panorama"]) > div:first-child,
  body[data-city-page="place"] .detail-top > figure[data-photo-shape="panorama"] {
    float: none;
    width: 100%;
    margin-inline: 0;
  }
  body[data-city-page="place"] .detail-layout { clear: left; }
  /* In the confectioner's two portraits, let the table and pastries take the foreground. */
  body[data-city-page="place"] .city-photo-pair:has(img[src$="/am08-gallery-2.webp"]) {
    grid-template-columns: .9fr 1.1fr;
  }
}
@media (max-width:759px) {
  body[data-city-page="city"] .intro.editorial-hero { display: block; }
  body[data-city-page="city"] .intro.editorial-hero > div:first-child,
  body[data-city-page="city"] .intro.editorial-hero > figure.photo,
  body[data-city-page="city"] .city-visit-note > figure.photo {
    float: none;
    width: 100%;
    margin: 0 0 1.15rem;
  }
  body[data-city-page="place"] .detail-top figure { margin: 1rem 0 1.5rem; }
  body[data-city-page="place"] .city-photo-pair { grid-template-columns: 1fr; }
}

@media (min-width: 420px) and (max-width: 759px) {
  body[data-city-page="place"] .detail-top > figure[data-photo-shape="portrait"] { width: 88%; }
  body[data-city-page="city"] .intro.editorial-hero:not(:has([data-magazine-spread])) > figure[data-photo-shape="portrait"] { width: 88%; }
}
