/* A continuous display keeps the document's ordinary reading and focus order. */
.duo-reader {
  display: contents;
}

/* On a short phone display keep the identity, controls and first lines in view. */
@media screen and (max-height: 40rem) and (max-width: 40rem) {
  .site-header .masthead {
    padding-block: .875rem;
  }

  .hero, .content-page {
    padding-top: 1.25rem;
  }

  .hero .eyebrow, .content-page .eyebrow {
    margin-bottom: .55rem;
  }
}

@media screen and (max-height: 28rem) and (min-width: 35rem) and (max-width: 45rem) {
  .hero, .english-hero {
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
    gap: 1.5rem;
    align-items: start;
  }

  .name-en {
    font-size: clamp(3rem, 9vw, 4rem);
  }

  .hero .name-cn {
    margin-bottom: .5rem;
  }

  .hero-portrait img, .english-hero img {
    aspect-ratio: 4/5;
  }
}

/* The coordinates come from the browser; the crease can have zero or non-zero width. */
@media screen and (horizontal-viewport-segments: 2),
       screen and (vertical-viewport-segments: 2) {
  body {
    display: grid;
    grid-template-areas: "navigation" "reader";
    height: 100vh;
    height: 100dvh;
    margin: 0;
  }

  body > header, .duo-reader {
    min-width: 0;
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
  }

  body > header {
    grid-area: navigation;
    align-self: stretch;
  }

  .duo-reader {
    grid-area: reader;
    display: block;
    container: duo-reader / inline-size;
  }

  .skip-link:focus {
    position: fixed;
    z-index: 5;
  }

  .utility-bar nav {
    padding-inline: 1.25rem;
    flex-wrap: wrap;
  }

  .utility-bar nav a {
    white-space: normal;
  }

  .profile-navigation .section-links {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem 1rem;
    overflow: visible;
  }

  .site-header .masthead {
    width: calc(100% - 2.5rem);
    padding-block: 1rem;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: .75rem;
  }

  .privacy-header {
    align-content: start;
    align-items: start;
  }

  .site-header .masthead p {
    font-size: 1rem;
    overflow-wrap: anywhere;
  }
}

@media screen and (horizontal-viewport-segments: 2) {
  body {
    grid-template-areas: "navigation . reader";
    grid-template-columns:
      env(viewport-segment-width 0 0)
      max(0px, calc(env(viewport-segment-left 1 0) - env(viewport-segment-right 0 0)))
      env(viewport-segment-width 1 0);
    grid-template-rows: minmax(0, 1fr);
  }

  /* CSS grid starts at the right in RTL; segment indices always start at the left. */
  html[dir="rtl"] body {
    grid-template-columns:
      env(viewport-segment-width 1 0)
      max(0px, calc(env(viewport-segment-left 1 0) - env(viewport-segment-right 0 0)))
      env(viewport-segment-width 0 0);
  }
}

@media screen and (vertical-viewport-segments: 2) {
  body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "navigation" "." "reader";
    grid-template-rows:
      env(viewport-segment-height 0 0)
      max(0px, calc(env(viewport-segment-top 0 1) - env(viewport-segment-bottom 0 0)))
      minmax(0, 1fr);
  }
}

@container duo-reader (max-width: 45rem) {
  .page-width {
    width: calc(100% - 2.5rem);
  }

  .hero, .english-hero, .technical-grid, .technical-notes, .career-grid,
  .work-directory, .biography, .connect, .account-list {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1.5rem;
  }

  .hero, .content-page {
    padding-top: 1.5rem;
  }

  .hero h1 {
    letter-spacing: -.045em;
  }

  .name-en {
    font-size: clamp(3rem, 14cqi, 5rem);
  }

  .name-en br {
    display: none;
  }

  .content-page h1 {
    font-size: clamp(2rem, 7cqi, 2.75rem);
    overflow-wrap: anywhere;
  }

  .work-article p, .english-copy p {
    font-size: 1.0625rem;
  }

  .footer {
    flex-wrap: wrap;
  }
}
