/* Language V1 only: language state and navigation switch. */
body.language-zh.gallery-page .masthead-copy-zh {
  margin-top: 0;
}

/* Derive the cover offset from the active body leading instead of fixed breakpoint values. */
body.gallery-page {
  --gallery-body-size: 14px;
  --gallery-body-leading: 1.8;
  --gallery-cover-offset: calc(var(--gallery-body-size) * var(--gallery-body-leading) * 1.5);
}

body.language-zh.gallery-page {
  --gallery-body-leading: 2.16;
}

/* Align the visible first-line glyphs across every case-intro grid. */
body.case-page {
  --case-intro-optical-offset: 0.28125em;
}

body.language-zh.case-page .case-intro-title-latin {
  --case-intro-optical-offset: 0.4375em;
}

body.language-zh.case-page .case-intro-title-zh {
  --case-intro-optical-offset: 0.28125em;
}

/* Normalize legacy Adobe language attributes before applying the optical alignment. */
body.language-zh.case-page #project-modules .case-intro-title [lang^="zh"],
body.language-zh.case-page #project-modules .case-intro-title [lang^="zh"] * {
  font-size: 18px !important;
  line-height: 1.55 !important;
}

body.language-zh.case-page #project-modules .case-intro-copy,
body.language-zh.case-page #project-modules .case-intro-copy * {
  line-height: 2.16 !important;
}

/* Own the case-intro columns independently of Adobe's flex gutters and 800px text cap. */
body.case-page #project-modules .case-intro-row {
  align-items: start;
  column-gap: 24px;
  display: grid;
  grid-template-columns:
    minmax(0, var(--case-intro-title-track, 51fr))
    minmax(0, var(--case-intro-copy-track, 149fr));
}

body.case-page #project-modules .case-intro-row > .tree-child-wrapper {
  border-left: 0 !important;
  border-right: 0 !important;
  min-width: 0;
}

body.case-page #project-modules .case-intro-row :is(.case-intro-title, .case-intro-copy) {
  box-sizing: border-box;
  margin-left: 0 !important;
  margin-right: 0 !important;
  max-width: none !important;
  width: 100% !important;
}

@media (min-width: 541px) {
  body.case-page #project-modules .case-intro-title {
    transform: translateY(var(--case-intro-optical-offset));
  }
}

@media (max-width: 540px) {
  body.case-page #project-modules .case-intro-row {
    column-gap: 0;
    display: block;
  }
}

body.gallery-page .masthead {
  padding-bottom: var(--gallery-cover-offset) !important;
}

body.gallery-page .masthead-buttons {
  padding-top: 0 !important;
}

body.site-typography .language-switch a:not(.active) {
  opacity: 0.5;
}

body.site-typography .language-switch a.active {
  opacity: 1;
}

body.site-typography .responsive-nav .nav-container .language-switch {
  margin-top: 2em;
}

@media (min-width: 933px) {
  body.site-typography .site-header > .nav-container {
    left: auto;
    width: max-content;
  }

  /* Only the visible logo remains clickable; its centered layout wrapper cannot cover nav links. */
  body.site-typography .site-header .logo-wrap {
    pointer-events: none;
  }

  body.site-typography .site-header .logo-wrap .image-link {
    pointer-events: auto;
  }
}

@media (min-width: 933px) and (max-width: 1000px) {
  body.site-typography .site-header .nav-container,
  body.site-typography .site-header .nav-container * {
    font-size: 14px !important;
  }
}

/* The cover grid uses internal gaps only, so its outer edges stay aligned to the page grid. */
body.site-typography .project-covers {
  display: grid !important;
  gap: 8px !important;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

body.site-typography .project-covers > .project-cover {
  clear: none !important;
  float: none !important;
  margin: 0 !important;
  width: 100% !important;
}

body.site-typography .project-covers > .project-cover .cover-content-container {
  margin: 0 !important;
}

@media (max-width: 932px) {
  body.site-typography .project-covers {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 540px) {
  body.site-typography .project-covers {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Use the existing mobile navigation whenever the logo's measured protection zone cannot fit. */
body.language-nav-compact .site-header > .nav-container {
  display: none;
}

body.language-nav-compact .hamburger-click-area {
  display: block;
}

body.language-nav-compact .hamburger i {
  background-color: #282828;
}

body.language-nav-compact .responsive-nav {
  align-items: center;
  background-color: #ffffff;
  bottom: 0;
  box-sizing: border-box;
  display: grid;
  height: 100%;
  justify-items: center;
  left: 0;
  overflow: auto;
  padding: 50px 5% 0;
  position: fixed;
  right: 0;
  text-align: center;
  top: 0;
  transition: visibility 0s ease 0.2s, opacity 0.2s ease 0s;
  z-index: 99999;
}

body.language-nav-compact .responsive-nav nav {
  float: none !important;
  left: auto !important;
  margin: 0 !important;
  max-width: 100% !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  position: static !important;
  right: auto !important;
  text-align: center !important;
  transform: none !important;
  width: 100% !important;
}

body.language-nav-compact .responsive-nav.has-social nav {
  padding-bottom: 80px;
}

body.language-nav-compact .responsive-nav .nav-container {
  width: 100% !important;
}

body.language-nav-compact .responsive-nav .nav-container > * {
  box-sizing: border-box;
  float: none !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  text-align: center !important;
  width: 100%;
}

body.language-nav-compact .responsive-nav :is(.page-title, .project-title, .link-title, .gallery-title) {
  display: block;
  padding: 0 0 30px;
  text-align: center;
}

body.language-nav-compact .responsive-nav :is(.page-title, .project-title, .link-title, .gallery-title) a {
  font-size: 22px;
  line-height: 32px;
}

body.language-nav-compact .close-responsive-click-area {
  cursor: pointer;
  padding: 50px 6%;
  position: fixed;
  right: 0;
  top: 0;
}

body.language-nav-compact .close-responsive-button {
  height: 20px;
  position: fixed;
  right: 5%;
  top: 40px;
  width: 20px;
}

body.language-nav-compact .close-responsive-button::before,
body.language-nav-compact .close-responsive-button::after {
  background-color: #282828;
  content: "";
  display: block;
  height: 20px;
  left: 50%;
  position: absolute;
  width: 2px;
}

body.language-nav-compact .close-responsive-button::before {
  transform: rotate(45deg);
}

body.language-nav-compact .close-responsive-button::after {
  transform: rotate(-45deg);
}

body.language-nav-compact.show-responsive-nav {
  overflow: hidden;
}

body.language-nav-compact.show-responsive-nav .responsive-nav {
  opacity: 1;
  transition: visibility 0s ease 0s, opacity 0.2s ease 0s;
  visibility: visible;
}

body.language-nav-compact.show-responsive-nav .responsive-nav nav {
  display: block;
}

body.language-nav-compact.show-responsive-nav :is(.site-header, .site-container) {
  display: none;
}

/* The open overlay owns its viewport alignment, independent of breakpoint timing. */
body.show-responsive-nav .responsive-nav {
  box-sizing: border-box;
  left: 0 !important;
  right: 0 !important;
  width: 100vw !important;
}

body.show-responsive-nav .responsive-nav nav.nav-container {
  box-sizing: border-box;
  display: grid !important;
  float: none !important;
  justify-items: center !important;
  left: 0 !important;
  margin-left: auto !important;
  margin-right: auto !important;
  max-width: 100% !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  position: static !important;
  right: 0 !important;
  text-align: center !important;
  transform: none !important;
  width: 100% !important;
}

body.show-responsive-nav .responsive-nav nav.nav-container > * {
  box-sizing: border-box;
  float: none !important;
  justify-self: center !important;
  margin-left: auto !important;
  margin-right: auto !important;
  max-width: 100% !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  text-align: center !important;
  width: max-content !important;
}
