/**
 * Shared header styles — loaded on all pages.
 */

:root {
  --font-light: "Taipei Sans TC Light", sans-serif;
  --header-height: clamp(4rem, 10vw, 5rem);
  --page-padding-x: clamp(1rem, 4vw, 3rem);
}

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) minmax(0, 2fr);
  align-items: center;
  gap: clamp(0.75rem, 2vw, 2rem);
  min-height: var(--header-height);
  padding: 0.75rem var(--page-padding-x);
  background: rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(0.5rem);
  min-width: 0;
}

.site-header__logo {
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  justify-self: start;
}

.site-header__logo:hover,
.site-header__logo:active,
.site-header__logo:focus,
.site-header__logo:focus-visible {
  opacity: 1;
  outline: none;
}

.site-header__logo img {
  height: 1.75rem;
  width: auto;
  display: block;
}

.search-bar {
  position: relative;
  grid-column: 2;
  justify-self: center;
  display: flex;
  align-items: center;
  width: min(clamp(9rem, 22vw, 22.5rem), 100%);
  max-width: min(22.5rem, calc(100vw - 26rem));
  height: 2.5rem;
  padding: 0.25rem;
  border-radius: 1.25rem;
  background: #fff;
  min-width: 0;
  z-index: 0;
}

.search-bar__input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0 0.75rem 0 1rem;
  border: none;
  border-radius: 1rem;
  outline: none;
  background: transparent;
  font-family: var(--font-light);
  font-size: 1.125rem;
  color: #333;
}

.search-bar__input::placeholder {
  color: #999;
}

.search-bar__btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 2rem;
  padding: 0;
  border: none;
  border-radius: 1rem;
  background: #9a9a9a;
  cursor: pointer;
  transition: background 0.2s;
}

.search-bar__btn:hover {
  background: #888;
}

.search-bar__btn img {
  width: 1.375rem;
  height: 1.375rem;
  display: block;
}

.site-header__right {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0.75rem;
  grid-column: 3;
  justify-self: end;
  position: relative;
  min-width: 0;
  z-index: 1;
}

.site-header__nav {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0.75rem;
  min-width: 0;
}

/* 包装 div 使用 inline-flex，避免内部 inline-flex 链接产生行盒偏移 */
.site-header__authors-wrap,
.site-header__nav-wrap {
  display: inline-flex;
  align-items: center;
  align-self: center;
  position: relative;
  flex-shrink: 0;
  line-height: 0;
}

.site-header__nav-item {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0  clamp(0.75rem, 1.5vw, 1.25rem);
  border-radius: 1.25rem;
  white-space: nowrap;
  border: 0.0625rem solid #7b6cf0;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  transition: background 0.3s;
  height: 2.2rem;
  box-sizing: border-box;
  line-height: 1;
  vertical-align: middle;
}

.site-header__nav-cn {
  font-family: var(--font-light);
  font-size: clamp(0.8125rem, 1.8vw, 1.25rem);
  line-height: 1.2;
}

.site-header__nav-en {
  font-size: clamp(0.9375rem, 1.8vw, 1.25rem);
  line-height: 1.2;
}

.site-header__nav-item:hover,
.site-header__nav-item.is-active {
  background: #7b6cf0;
}

.site-header__more-panel,
.site-header__submenu {
  display: none;
  position: absolute;
  top: calc(100% + 0.75rem);
  left: 0;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.75rem;
  z-index: 10;
  line-height: normal;
}

.site-header__nav-wrap:hover .site-header__submenu {
  display: flex;
}

.site-header__submenu::before {
  content: "";
  position: absolute;
  top: -0.75rem;
  left: 0;
  right: 0;
  height: 0.75rem;
}

.site-header__more-panel.is-open {
  display: flex;
}

.site-header__more-item,
.site-header__submenu-item {
  width: auto;
}

.site-header__menu {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  flex-shrink: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: opacity 0.2s;
}

.site-header__menu:hover,
.site-header__menu.is-open {
  opacity: 0.85;
}

.site-header__menu img {
  width: 1.5rem;
  height: auto;
  display: block;
}

@media (max-width: 100rem) {
  .site-header {
    grid-template-columns: minmax(0, auto) minmax(0, 1fr) minmax(0, auto);
    gap: clamp(0.75rem, 1.5vw, 1.5rem);
  }

  .search-bar {
    grid-column: 2;
    justify-self: center;
    width: min(clamp(12.5rem, 28vw, 22.5rem), 100%);
    max-width: min(22.5rem, calc(100vw - 28rem));
  }

  .site-header__nav-item {
    padding-left: clamp(0.45rem, 0.75vw, 0.75rem);
    padding-right: clamp(0.45rem, 0.75vw, 0.75rem);
  }

  .site-header__nav-cn {
    font-size: clamp(0.75rem, 1.25vw, 1rem);
  }

  .site-header__nav-en {
    font-size: clamp(0.8125rem, 1.25vw, 1rem);
  }

  .site-header__right,
  .site-header__nav {
    gap: 0.4rem;
  }
}

@media (max-width: 75rem) {
  .site-header__nav-en {
    display: none;
  }
}

@media (max-width: 64rem) {
  .site-header__nav {
    gap: 0.5rem;
  }
}

@media (max-width: 56.25rem) {
  .search-bar {
    display: none;
  }
}

@media (max-width: 48rem) {
  .site-header__nav {
    display: none;
  }

  .site-header__mobile-overlay {
    position: fixed;
    inset: 0;
    top: var(--header-height);
    z-index: 99;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: clamp(1.5rem, 6vw, 2.5rem) var(--page-padding-x) 3rem;
    background: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(0.35rem);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.28s ease, visibility 0.28s ease;
  }

  .site-header__mobile-overlay.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  .site-header__mobile-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: min(100%, 18rem);
    margin: 0 auto;
    line-height: normal;
  }

  .site-header__mobile-item {
    display: block;
    width: 100%;
    padding: 0.75em 0 0.45em;
    border: none;
    background: transparent;
    border-radius: 0;
    height: auto;
    text-align: center;
    color: rgba(255, 255, 255, 0.9);
    position: relative;
    font-family: var(--font-light);
    font-size: clamp(15px, 4.2vw, 19px);
    letter-spacing: 0.1em;
    line-height: 1.4;
    white-space: nowrap;
    transition: color 0.2s;
  }

  .site-header__mobile-item:hover {
    color: #f9e064;
    background: transparent;
    opacity: 1;
  }

  .site-header__mobile-item.is-active {
    color: #c4b8e8;
    background: transparent;
  }

  .site-header__mobile-item.is-active::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 20%;
    right: 20%;
    height: 2px;
    background: #9b8fd4;
    border-radius: 1px;
  }

  .site-header__mobile-sep {
    display: block;
    width: min(100%, 12rem);
    height: 1px;
    margin: 0.35em 0;
    background: rgba(155, 143, 212, 0.45);
  }
}

@media (min-width: 48.0625rem) {
  .site-header__mobile-overlay {
    display: none !important;
  }
}

body.is-mobile-menu-open {
  overflow: hidden;
}

/* ── Footer logos (shared) ── */
.footer__logos {
  display: flex;
  align-items: center;
  gap: clamp(12px, 2vw, 28px);
  flex-wrap: nowrap;
}

.footer__logos .footer__logo-star {
  width: auto;
  max-width: min(280px, 42vw);
  display: block;
}

.footer__logos .footer__logo-chc img {
  width: auto;
  height: clamp(32px, 4vw, 52px);
  max-width: min(280px, 42vw);
  display: block;
}

.footer__logo-chc {
  flex-shrink: 0;
}

.footer__logo-chc:hover,
.footer__logo-chc:active,
.footer__logo-chc:focus,
.footer__logo-chc:focus-visible {
  opacity: 1;
  outline: none;
}
