/* An inline phrase moves with its neighbours as one unit. If the phrase alone
   exceeds the available measure, it can still be read at full text size. */
.wrap-unit {
  display: inline-block;
  inline-size: max-content;
  max-inline-size: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  vertical-align: baseline;
  text-indent: 0;
}

/* The name and the areas of work can take separate rows at large text sizes. */
.masthead.page-width {
  flex-wrap: wrap;
  column-gap: 1rem;
  row-gap: .4em;
}
.masthead .wordmark {
  max-inline-size: 100%;
}
.masthead.page-width p.masthead-topics {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: .12em .55em;
  flex: 0 1 auto;
  min-inline-size: 0;
  max-inline-size: 100%;
  margin-inline-start: auto;
  text-align: end;
  word-break: normal;
  overflow-wrap: anywhere;
}
.masthead-topics .masthead-topic {
  display: inline-block;
  flex: none;
  inline-size: max-content;
  max-inline-size: 100%;
  white-space: normal;
}
@media (max-width: 48rem) {
  .masthead.page-width p.masthead-topics {
    column-gap: 1em;
  }
  .masthead-topics .topic-separator {
    display: none;
  }
}
@media (max-width: 600px) {
  html:lang(zh-CN) .masthead.page-width p.masthead-topics {
    font-size: max(.75rem, 10px);
  }
}
@supports (font: -apple-system-caption1) {
  @media (pointer: coarse) and (max-width: 600px) {
    html:lang(zh-CN) .masthead.page-width p.masthead-topics {
      font: -apple-system-caption1;
      font-family: var(--sans);
      line-height: 1.6;
    }
  }
}

/* Each traditional Mongolian topic starts its own top-to-bottom measure.
   Columns run left to right and a long item can continue on the next column. */
html[lang="mn-Mong-CN"] .masthead.page-width p.masthead-topics {
  display: flex;
  align-items: flex-start;
  writing-mode: horizontal-tb;
  max-width: 100%;
  max-height: none;
  text-align: start;
}
html[lang="mn-Mong-CN"] .masthead-topics .masthead-topic {
  display: block;
  writing-mode: vertical-lr;
  text-orientation: mixed;
  inline-size: max-content;
  max-inline-size: min(28rem, 70vh);
  max-block-size: 100%;
}
html[lang="mn-Mong-CN"] .masthead-topics .topic-separator {
  display: none;
}
html[lang="mn-Mong-CN"] .privacy-date {
  max-width: 100%;
  height: max-content;
  max-height: min(30rem, 70vh);
  overflow: auto;
}
html[lang="mn-Mong-CN"] .privacy-article .privacy-date {
  margin: .7rem 0 1.3rem;
}
html[lang="mn-Mong-CN"] .policy-versions li a {
  min-width: 0;
  max-width: 100%;
  max-height: min(30rem, 70vh);
  overflow: auto;
}

/* Let the date, event, and source share the viewport when readers enlarge type. */
.archive-catalog .event-index li > * {
  min-width: 0;
}
.archive-catalog .event-index li p a,
.archive-catalog details time {
  white-space: normal;
}

/* Compounds follow the language's hyphenation rules before breaking midword. */
:lang(de) :is(.english-profile, .privacy-header, .privacy-article) {
  hyphens: auto;
  overflow-wrap: anywhere;
}
.privacy-header .policy-nav {
  min-width: 0;
  max-width: 100%;
}

@media (max-width: 720px) {
  .hero, .english-hero {
    grid-template-columns: minmax(0, 1fr);
  }
  .hero .name-en {
    overflow-wrap: anywhere;
  }
  .carousel-controls {
    flex-wrap: wrap;
  }
  .carousel-controls .arrow-button {
    width: max(42px, 1.4em);
    height: max(42px, 1.4em);
    padding: 0;
  }
}

@media (max-width: 580px) {
  .site-header:has(.header-meta) {
    flex-wrap: wrap;
    height: auto;
    min-height: 66px;
    row-gap: 4px;
  }
  .infobox table {
    width: 100%;
    overflow-wrap: anywhere;
  }
}
@media (max-width: 720px) {
  .hero .handle {
    max-width: 100%;
    overflow-wrap: anywhere;
  }
  :lang(en) .article-body :is(h2, h3) {
    hyphens: auto;
    overflow-wrap: anywhere;
  }
}
html[lang="mn-Mong-CN"] .case-figures figcaption {
  writing-mode: horizontal-tb;
}
@media (max-width: 620px) {
  /* Keep the version/date/source columns as a native table. */
  .archive-catalog table,
  .copy table.timeline {
    table-layout: fixed;
    overflow-wrap: anywhere;
  }
  .archive-catalog thead th:first-child {
    width: 3.9em;
  }
  .work-caption h3 span[lang] {
    display: inline-block;
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
  }
}

.technical-feature .section-line {
  flex-wrap: wrap;
}
.directory-card h3:where(:lang(es), :lang(fr)) {
  hyphens: auto;
  overflow-wrap: anywhere;
}

/* The encyclopedia's reading column also shrinks beside its contents panel.
   A viewport breakpoint alone misses this when the base font grows. */
.sheet .copy {
  container-type: inline-size;
}
@container (max-width: 34rem) {
  .copy :is(.baidu-facts, .infobox) {
    float: none;
    width: 100%;
    margin: 0 0 1rem;
  }
}
.copy :is(.baidu-facts, .infobox) table {
  table-layout: fixed;
  overflow-wrap: anywhere;
}
.copy :is(.baidu-facts, .infobox) th {
  width: 35%;
}
@media (min-width: 851px) {
  .wrap:has(> .toc) {
    grid-template-columns: minmax(0, min(14rem, 24%)) minmax(0, 1fr);
  }
}
.copy :is(.table-wrap, .works-scroll, .table-scroll) {
  max-width: 100%;
  overflow-x: auto;
}

/* A caption needs room for a full word even when the photo grid fits two photos. */
:lang(en) .photo-gallery figcaption {
  hyphens: auto;
  overflow-wrap: anywhere;
}
@media (max-width: 580px) {
  .article-body > .infobox {
    float: none;
    width: 100%;
    max-width: 100%;
    margin-inline: 0;
  }
}

/* Four-character field names plus both cell insets. */
.copy .baidu-facts th {
  width: max(42%, calc(4em + 1.25rem + 2px));
}
.copy .baidu-facts { container: biographical-facts / inline-size; }
@container biographical-facts (max-width: 15rem) {
  .baidu-facts table, .baidu-facts tbody { display: block; }
  .baidu-facts tr { display: grid; grid-template-columns: minmax(0, 1fr); }
  .copy .baidu-facts th, .copy .baidu-facts td { width: auto; text-align: start; }
  .copy .baidu-facts th { border-bottom: 0; }
}
