/* Shared CUHK strategic-plan prototype header and navigation. */

/* Desktop menu */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: #fff;
  overflow: visible;
  box-shadow: 0 4px 2px rgba(0, 0, 0, 0.25);
}

.header-inner {
  max-width: var(--max);
  margin: 0 auto;
  height: 100%;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 0 var(--content-pad);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(12px, 2vw, 30px);
}

.brand {
  display: flex;
  align-items: center;
  gap: clamp(12px, 2vw, 30px);
  min-width: 0;
  flex: 1 1 auto;
  overflow: visible;
}

.brand img {
  width: clamp(140px, 14vw, 200px);
  height: auto;
  max-height: 63px;
  object-fit: contain;
  display: block;
  flex-shrink: 0;
}

.brand-title {
  width: auto;
  max-width: none;
  min-width: max-content;
  flex: 0 0 auto;
  font-size: clamp(16px, 1.7vw, 24px);
  font-weight: var(--fw-medium);
  font-style: normal;
  line-height: normal;
  color: var(--cuhk-gold);
  white-space: nowrap;
  overflow: visible;
  text-overflow: clip;
}

.brand-title span {
  font-weight: var(--fw-light);
  color: var(--cuhk-gold);
}

.nav {
  display: flex;
  align-items: center;
  gap: clamp(14px, 2vw, 30px);
  flex: 0 0 auto;
  min-width: 0;
  max-width: 100%;
}

.nav-item {
  position: relative;
  padding-bottom: 48px;
  margin-bottom: -48px;
}

.nav-item-head {
  display: contents;
}

.nav-submenu-toggle {
  display: none;
}

.nav-link {
  font-size: clamp(16px, 1.4vw, 20px);
  font-weight: var(--fw-book);
  font-style: normal;
  line-height: normal;
  color: #000;
  padding: 0;
  display: inline-flex;
  align-items: center;
  height: 24px;
  white-space: nowrap;
  transition: color 0.2s;
}

.nav-link:hover,
.nav-item.open > .nav-link,
.nav-item.open > .nav-item-head > .nav-link {
  color: var(--purple-dynamic);
}

.nav-link.active {
  color: #000;
}

.dropdown {
  display: none;
  position: absolute;
  top: calc(100% - 38px);
  left: 0;
  width: 270px;
  background: transparent;
  border: 0;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
  padding: 0;
  z-index: 20;
}

.nav-item:nth-child(2) .dropdown {
  width: 301px;
}

.nav-item:nth-child(3) .dropdown {
  width: 230px;
}

.nav-item.open > .dropdown {
  display: block;
}

.dropdown.dropdown--portal {
  display: block !important;
  position: fixed !important;
  top: auto;
  left: auto;
  z-index: 10000;
  pointer-events: auto;
}

.dropdown a {
  display: block;
  height: 33px;
  padding: 0 13px;
  font-size: 16px;
  font-weight: var(--fw-book);
  line-height: 33px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid #e7e7e7;
  border-radius: 0;
  transition: background 0.15s, color 0.15s, border-radius 0.15s, font-weight 0.15s;
  white-space: nowrap;
}

.dropdown a .tiger-nav-letter {
  font-weight: 700;
  font-synthesis: weight;
  color: #000;
}

.dropdown a:hover .tiger-nav-letter,
body:has(.strategies.t) .dropdown a:is([href="talent.html"], [href="./prototype/talent.html"]) .tiger-nav-letter,
body:has(.strategies.i) .dropdown a:is([href="institutional.html"], [href="./prototype/institutional.html"]) .tiger-nav-letter,
body:has(.strategies.g) .dropdown a:is([href="global.html"], [href="./prototype/global.html"]) .tiger-nav-letter,
body:has(.strategies.e) .dropdown a:is([href="education.html"], [href="./prototype/education.html"]) .tiger-nav-letter,
body:has(.strategies.r) .dropdown a:is([href="research.html"], [href="./prototype/research.html"]) .tiger-nav-letter {
  color: #fff;
}

.dropdown a:last-child {
  border-bottom: none;
}

.dropdown a.nav-disabled,
.dropdown a[aria-disabled="true"] {
  pointer-events: none;
  cursor: default;
}

.dropdown a.nav-disabled:hover,
.dropdown a[aria-disabled="true"]:hover {
  background: rgba(255, 255, 255, 0.96);
  color: inherit;
  font-weight: var(--fw-book);
  border-radius: 0;
}

.dropdown a:hover {
  background: var(--cuhk-gold);
  color: #fff;
  font-weight: var(--fw-medium);
  border-bottom-right-radius: 10px;
}

.about-page .dropdown a[href="about.html"],
.vision-page .dropdown a[href="vision.html"],
.identity-page .dropdown a[href="identity.html"],
.priorities-page .dropdown a[href="priorities.html"] {
  background: var(--cuhk-gold);
  color: #fff;
  font-weight: var(--fw-medium);
  border-bottom-right-radius: 10px;
}

.tiger-page .dropdown a[href="tiger.html"],
body:has(.strategies.t) .dropdown a:is([href="talent.html"], [href="./prototype/talent.html"]),
body:has(.strategies.i) .dropdown a:is([href="institutional.html"], [href="./prototype/institutional.html"]),
body:has(.strategies.g) .dropdown a:is([href="global.html"], [href="./prototype/global.html"]),
body:has(.strategies.e) .dropdown a:is([href="education.html"], [href="./prototype/education.html"]),
body:has(.strategies.r) .dropdown a:is([href="research.html"], [href="./prototype/research.html"]) {
  background: var(--cuhk-gold);
  color: #fff;
  font-weight: var(--fw-medium);
  border-bottom-right-radius: 10px;
}

.lang {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.lang button,
.lang .lang-link {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  width: 30px;
  text-align: center;
  font-family: var(--font);
  font-weight: var(--fw-medium);
  font-style: normal;
  line-height: normal;
  color: #adadad;
  font-size: 18px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.lang button.active,
.lang .lang-link.active {
  color: var(--purple-dynamic);
  font-size: 20px;
}

.lang .sep {
  display: block;
  width: 1px;
  height: 21.5px;
  background: #adadad;
  flex-shrink: 0;
}

.menu-toggle {
  display: none;
  background: none;
  border: 1px solid #ddd;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: var(--fw-book);
  cursor: pointer;
  font-family: inherit;
  color: var(--purple-dynamic);
}

/* Tablet menu */
@media (min-width: 768px) and (max-width: 1279px) {
  :root {
    --header-h: 80px;
  }

  html {
    overflow-x: hidden;
  }

  body {
    width: 100%;
    max-width: 100%;
    padding-top: var(--header-h);
    overflow-x: hidden;
  }

  body > .site-header,
  body > main,
  body > .site-footer {
    width: 100%;
    max-width: 100%;
    zoom: 1;
  }

  .site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 120;
    box-shadow: 0 1px 0 rgba(0, 0, 0, .08);
  }

  .header-inner {
    position: relative;
    z-index: 121;
    padding-inline: clamp(24px, 4vw, 56px);
  }

  .brand {
    gap: 16px;
  }

  .brand img {
    width: clamp(126px, 18vw, 160px);
    height: auto;
  }

  .brand-title {
    min-width: 0;
    max-width: 260px;
    font-size: clamp(16px, 2vw, 20px);
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .menu-toggle {
    display: inline-flex;
    position: relative;
    align-items: center;
    justify-content: center;
    gap: 0;
    width: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    border: 1px solid #d7ccd9;
    border-radius: 22px;
    background: #fff;
    color: var(--purple-dynamic);
    font-size: 0;
    line-height: 1;
  }

  .menu-toggle::before {
    content: "";
    width: 18px;
    height: 14px;
    background:
      linear-gradient(currentColor 0 0) top / 100% 2px no-repeat,
      linear-gradient(currentColor 0 0) center / 100% 2px no-repeat,
      linear-gradient(currentColor 0 0) bottom / 100% 2px no-repeat;
  }

  .menu-toggle[aria-expanded="true"] {
    background: #f4edf5;
    border-color: #cab5ce;
    padding-left: 0;
  }

  .menu-toggle[aria-expanded="true"]::before {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 18px;
    height: 2px;
    background: currentColor;
    transform: translate(-50%, -50%) rotate(45deg);
  }

  .menu-toggle[aria-expanded="true"]::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 18px;
    height: 2px;
    background: currentColor;
    transform: translate(-50%, -50%) rotate(-45deg);
  }

  .nav {
    display: flex;
    position: fixed;
    top: var(--header-h);
    right: 0;
    left: auto;
    z-index: 115;
    width: min(420px, calc(100% - 48px));
    height: calc(100dvh - var(--header-h));
    max-height: calc(100dvh - var(--header-h));
    padding: 12px 28px max(28px, env(safe-area-inset-bottom));
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    overflow-x: hidden;
    overflow-y: auto;
    background: #fff;
    box-shadow: -12px 16px 32px rgba(24, 8, 30, .14);
    opacity: 0;
    visibility: hidden;
    transform: translate3d(24px, 0, 0);
    pointer-events: none;
    transition: opacity .22s ease, visibility .22s ease, transform .22s ease;
  }

  .nav.open {
    opacity: 1;
    visibility: visible;
    transform: translate3d(0, 0, 0);
    pointer-events: auto;
  }

  .nav-item {
    border-bottom: 1px solid #e8e3e9;
    padding-bottom: 0;
    margin-bottom: 0;
  }

  .nav-item-head {
    display: flex;
    align-items: stretch;
    gap: 4px;
  }

  .nav-link {
    width: 100%;
    height: auto;
    min-height: 56px;
    padding: 15px 0;
    justify-content: flex-start;
    font-size: 18px;
    line-height: 1.35;
    white-space: normal;
    flex: 1 1 auto;
  }

  .nav-submenu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 48px;
    min-height: 56px;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
  }

  .nav-submenu-toggle::after {
    content: "";
    width: 9px;
    height: 9px;
    margin-bottom: 4px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    transition: transform .2s ease, margin .2s ease;
  }

  .nav-item[data-dropdown].open > .nav-item-head > .nav-submenu-toggle::after {
    margin-top: 5px;
    margin-bottom: 0;
    transform: rotate(225deg);
  }

  .dropdown,
  .nav-item:nth-child(2) .dropdown,
  .nav-item:nth-child(3) .dropdown {
    position: static;
    width: 100%;
    min-width: 0;
    margin: 0 0 12px;
    padding: 4px 0;
    overflow: hidden;
    border: 0;
    border-radius: 8px;
    background: #f8f5f8;
    box-shadow: none;
  }

  .nav-item:hover:not(.open) > .dropdown,
  .nav-item:focus-within:not(.open) > .dropdown {
    display: none;
  }

  .nav-item.open > .dropdown {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
  }

  .dropdown a {
    height: auto;
    min-height: 44px;
    padding: 11px 16px;
    font-size: 15px;
    line-height: 1.4;
    white-space: normal;
  }

  .lang {
    min-height: 64px;
    padding-top: 4px;
    gap: 8px;
  }

  .lang button,
  .lang .lang-link {
    min-width: 40px;
    min-height: 40px;
    border-radius: 20px;
  }
}

/* Mobile menu */
@media (max-width: 767px) {
  body.menu-open {
    overflow: hidden;
    touch-action: none;
  }

  html.menu-open {
    overflow: hidden;
  }

  body.menu-open .site-header {
    position: fixed;
    inset: 0 0 auto;
    width: 100%;
    z-index: 120;
  }

  .site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 120;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
    overflow: visible;
  }

  body {
    padding-top: var(--header-h);
  }

  body::after {
    content: "";
    position: fixed;
    inset: var(--header-h) 0 0;
    z-index: 110;
    background: rgba(18, 8, 24, 0.42);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.25s ease, visibility 0.25s ease;
  }

  body.menu-open::after {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  .header-inner {
    position: relative;
    z-index: 121;
  }

  .brand img {
    width: 140px;
    height: 44px;
  }

  .brand-title {
    width: auto;
    font-size: 16px;
  }

  .brand {
    gap: 16px;
  }

  .nav {
    display: flex;
    position: fixed;
    top: var(--header-h);
    left: auto;
    right: 0;
    z-index: 115;
    width: min(420px, calc(100% - 48px));
    height: calc(100dvh - var(--header-h));
    max-height: calc(100dvh - var(--header-h));
    background: #fff;
    flex-direction: column;
    align-items: stretch;
    padding: 12px 28px max(28px, env(safe-area-inset-bottom));
    box-shadow: -12px 16px 32px rgba(24, 8, 30, 0.14);
    gap: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    opacity: 0;
    visibility: hidden;
    transform: translate3d(24px, 0, 0);
    pointer-events: none;
    transition:
      opacity 0.22s ease,
      visibility 0.22s ease,
      transform 0.22s ease;
  }

  body > .nav.nav--portal,
  .nav.nav--portal {
    z-index: 116;
  }

  .nav.open {
    opacity: 1;
    visibility: visible;
    transform: translate3d(0, 0, 0);
    pointer-events: auto;
  }

  .nav-item {
    border-bottom: 1px solid #e8e3e9;
    padding-bottom: 0;
    margin-bottom: 0;
  }

  .nav-item-head {
    display: flex;
    align-items: stretch;
    gap: 4px;
  }

  .nav-link {
    width: 100%;
    height: auto;
    min-height: 56px;
    padding: 15px 0;
    justify-content: flex-start;
    gap: 16px;
    font-size: 18px;
    line-height: 1.35;
    white-space: normal;
    flex: 1 1 auto;
  }

  .nav-item[data-dropdown] > .nav-item-head > .nav-link::after,
  .nav-item[data-dropdown] > .nav-link::after {
    display: none;
  }

  .nav-submenu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 48px;
    min-height: 56px;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
  }

  .nav-submenu-toggle::after {
    content: "";
    width: 9px;
    height: 9px;
    margin: 0 0 4px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    transition: transform 0.2s ease, margin 0.2s ease;
  }

  .nav-item[data-dropdown].open > .nav-item-head > .nav-submenu-toggle::after {
    margin-top: 5px;
    margin-bottom: 0;
    transform: rotate(225deg);
  }

  .nav-link:hover,
  .nav-item.open > .nav-item-head > .nav-link,
  .nav-item.open > .nav-link,
  .nav-link.active {
    color: var(--purple-dynamic);
  }

  .dropdown {
    position: static;
    width: 100%;
    box-shadow: none;
    border: none;
    background: #f8f5f8;
    padding: 4px 0;
    margin: 0 0 12px;
    border-radius: 8px;
    min-width: 0;
    overflow: hidden;
  }

  .nav-item:nth-child(2) .dropdown {
    width: 100%;
  }

  .nav-item:hover:not(.open) > .dropdown,
  .nav-item:focus-within:not(.open) > .dropdown {
    display: none;
  }

  .nav-item.open > .dropdown {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
  }

  .nav-item > .dropdown[hidden] {
    display: none !important;
  }

  .dropdown a {
    min-height: 44px;
    height: auto;
    padding: 11px 16px;
    border-bottom-color: #e6dfe7;
    font-size: 15px;
    line-height: 1.4;
    white-space: normal;
  }

  .lang {
    min-height: 64px;
    padding-top: 4px;
    gap: 8px;
  }

  .lang button,
  .lang .lang-link {
    min-width: 40px;
    min-height: 40px;
    border-radius: 20px;
  }

  .lang button.active,
  .lang .lang-link.active {
    background: #f4edf5;
  }

  .menu-toggle {
    display: inline-flex;
    position: relative;
    align-items: center;
    justify-content: center;
    gap: 0;
    width: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    border: 1px solid #d7ccd9;
    border-radius: 22px;
    background: #fff;
    color: var(--purple-dynamic);
    font-size: 0;
    line-height: 1;
    transition: background 0.2s ease, border-color 0.2s ease;
  }

  .menu-toggle::before {
    content: "";
    width: 18px;
    height: 14px;
    background:
      linear-gradient(currentColor 0 0) top / 100% 2px no-repeat,
      linear-gradient(currentColor 0 0) center / 100% 2px no-repeat,
      linear-gradient(currentColor 0 0) bottom / 100% 2px no-repeat;
  }

  .menu-toggle[aria-expanded="true"] {
    background: #f4edf5;
    border-color: #cab5ce;
    padding-left: 0;
  }

  .menu-toggle[aria-expanded="true"]::before {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 18px;
    height: 2px;
    background: currentColor;
    transform: translate(-50%, -50%) rotate(45deg);
    box-shadow: none;
  }

  .menu-toggle[aria-expanded="true"]::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 18px;
    height: 2px;
    background: currentColor;
    transform: translate(-50%, -50%) rotate(-45deg);
  }
}

/* Prototype artboard/header overrides */
@media (min-width: 768px) {
  body > .site-header {
    position: fixed;
    top: 0;
    left: 0;
    margin: 0;
    z-index: 1000;
    overflow: visible;
  }

  body > .site-header .header-inner,
  body > .site-header .nav,
  body > .site-header .nav-item {
    overflow: visible;
  }

  body > .site-header .dropdown {
    z-index: 1001;
  }

  .header-inner,
  .brand,
  .nav {
    gap: 30px;
  }

  .brand {
    flex: 0 0 auto;
    min-width: auto;
    overflow: visible;
  }

  .brand img {
    width: 200px;
  }

  .brand-title {
    max-width: none;
    min-width: auto;
    font-size: 24px;
    overflow: visible;
    text-overflow: clip;
  }

  .nav-link {
    font-size: 20px;
  }
}

@media (max-width: 767px) {
  .brand-title {
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 130px;
    min-width: 0;
    max-width: 130px;
    flex: 0 1 130px;
    font-size: clamp(13px, 3.8vw, 16px);
    letter-spacing: -.02em;
    line-height: 1.08;
    white-space: normal;
  }

  .brand-title span {
    display: block;
    white-space: nowrap;
  }

  .header-inner {
    gap: 12px;
  }

  .brand {
    min-width: 0;
    flex: 1 1 auto;
    gap: 12px;
    overflow: hidden;
  }

  .brand img {
    width: 126px;
    height: auto;
  }

  .nav {
    left: 0;
    width: 100%;
    height: calc(100dvh - var(--header-h));
    max-height: calc(100dvh - var(--header-h));
    padding: 10px 24px max(24px, env(safe-area-inset-bottom));
    box-shadow: none;
    transform: translate3d(0, -10px, 0);
  }

  .nav.open {
    transform: translate3d(0, 0, 0);
  }

  .menu-toggle {
    width: 44px;
    min-width: 44px;
    min-height: 42px;
    padding: 0;
  }

  .menu-toggle[aria-expanded="true"] {
    padding-left: 0;
  }

  .menu-toggle[aria-expanded="true"]::after {
    left: 50%;
    transform: translate(-50%, -50%) rotate(-45deg);
  }

  .menu-toggle[aria-expanded="true"]::before {
    left: 50%;
    transform: translate(-50%, -50%) rotate(45deg);
  }
}

@media (max-width: 374px) {
  .brand-title {
    display: none;
  }
}

/* Tablet-width phones and compact tablets have enough room for the complete
   brand lockup; keep it on one line instead of constraining it to the narrow
   mobile title column. */
@media (min-width: 576px) and (max-width: 767px) {
  .brand-title {
    width: auto;
    max-width: none;
    flex: 1 1 auto;
    font-size: clamp(13px, 2.4vw, 16px);
    white-space: nowrap;
  }

  .brand-title span {
    display: inline;
    white-space: nowrap;
  }
}
