/* study-note: layout.css
 * 作用：全站页头、导航、搜索图标、移动抽屉、页脚、返回顶部。
 * 原则：layout.css 是所有页面共用骨架；首页具体栏目放在 pages/home.css。
 */
.site-header {
  position: relative;
  z-index: 30;
  background: var(--color-primary);
  color: #fff;
  box-shadow: none;
}

.masthead {
  position: relative;
}

.masthead-inner {
  min-height: var(--masthead-height);
  padding: var(--brand-logo-edge-y) 0;
  display: block;
  position: relative;
}

.brand {
  position: absolute;
  left: calc(var(--brand-anchor-x) + var(--header-logo-offset-x));
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  width: var(--brand-logo-width);
  height: var(--brand-logo-height);
  max-width: 100%;
  min-width: 0;
}

.brand-picture {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
}

.brand-logo {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  /* contain 让 logo 完整显示，不裁左右边缘，也不因宽高约束被拉伸。 */
  object-fit: contain;
  object-position: left center;
}

.nav-toggle {
  display: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.masthead-links {
  position: absolute;
  right: 0;
  top: var(--topbar-link-offset-y);
  display: flex;
  align-items: center;
  gap: 8px;
  justify-self: end;
}

.topbar-links-list {
  display: block;
}

.topbar-menu {
  position: relative;
  flex: none;
}

.topbar-trigger {
  list-style: none;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.92);
  font-size: var(--font-size-toplink);
  line-height: 1.2;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  transition: background var(--motion-fast), color var(--motion-fast), transform var(--motion-fast), box-shadow var(--motion-fast);
}

.topbar-trigger::-webkit-details-marker {
  display: none;
}

.topbar-trigger::marker {
  content: "";
}

.topbar-trigger:hover,
.topbar-trigger:focus-visible {
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
  box-shadow: 0 8px 18px rgba(60, 10, 20, 0.14);
}

.topbar-trigger:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.72);
  outline-offset: 3px;
}

.topbar-menu[open] .topbar-trigger {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(60, 10, 20, 0.16);
}

.gate-icon {
  width: 25px;
  height: 25px;
  overflow: visible;
}

.gate-icon path {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.15;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.gate-roof,
.gate-lintel,
.gate-base,
.gate-column,
.gate-door,
.gate-center,
.gate-chevron {
  transform-box: fill-box;
  transform-origin: center;
  transition: transform 0.26s ease, opacity 0.26s ease, stroke-width 0.26s ease;
}

.gate-roof {
  stroke-width: 2.35;
}

.gate-lintel,
.gate-base {
  opacity: 0.92;
}

.gate-column {
  opacity: 0.96;
}

.gate-door {
  opacity: 0.78;
}

.gate-center {
  opacity: 0.58;
}

.gate-chevron {
  opacity: 0.72;
  transform-origin: 24px 31px;
}

.topbar-menu[open] .gate-roof {
  transform: translateY(-1px);
}

.topbar-menu[open] .gate-lintel {
  transform: scaleX(0.92);
}

.topbar-menu[open] .gate-door-left {
  transform: translateX(-4px) rotate(-8deg);
}

.topbar-menu[open] .gate-door-right {
  transform: translateX(4px) rotate(8deg);
}

.topbar-menu[open] .gate-center {
  opacity: 0.22;
}

.topbar-menu[open] .gate-chevron {
  opacity: 1;
  transform: rotate(180deg);
}

.topbar-menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 9px);
  z-index: 20;
  width: max-content;
  min-width: 122px;
  padding: 4px;
  display: none;
  gap: 2px;
  border-radius: var(--radius-sm);
  background: #fff;
  color: #2d2623;
  box-shadow: 0 18px 36px rgba(31, 39, 52, 0.22);
  transform-origin: top right;
  animation: topbarDropdownReveal 0.22s ease both;
}

.topbar-menu[open] .topbar-menu-list {
  display: grid;
}

.topbar-menu-list a {
  min-height: 36px;
  display: flex;
  align-items: center;
  padding: 0 9px;
  border-radius: 3px;
  color: #2d2623;
  font-size: var(--font-size-toplink);
  line-height: 1.2;
  white-space: nowrap;
  transition: background var(--motion-fast), color var(--motion-fast), transform var(--motion-fast), box-shadow var(--motion-fast);
}

.topbar-menu-list a + a {
  border-top: 1px solid rgba(var(--color-primary-rgb), 0.08);
}

.topbar-menu-list a:hover,
.topbar-menu-list a:focus-visible {
  background: var(--color-hover-blue);
  color: #fff;
  transform: translateX(3px);
  box-shadow: 0 6px 14px rgba(31, 95, 159, 0.18);
}

.top-search-toggle {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: transparent;
  box-shadow: none;
  transition: background var(--motion-fast), transform var(--motion-fast), box-shadow var(--motion-fast);
}

.top-search-toggle:hover,
.top-search-toggle:focus-visible {
  background: rgba(255, 255, 255, 0.16);
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(60, 10, 20, 0.14);
}

.top-search-toggle svg {
  width: 20px;
  height: 20px;
}

@keyframes topbarDropdownReveal {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.site-search-popover {
  position: absolute;
  right: 0;
  top: calc(var(--topbar-link-offset-y) + 34px);
  width: min(380px, calc(100vw - 24px));
  padding: 14px;
  background: #fff;
  color: #2d2623;
  border-radius: var(--radius-sm);
  box-shadow: 0 22px 42px rgba(31, 39, 52, 0.2);
  z-index: 80;
}

.site-search-form {
  display: grid;
  gap: 10px;
}

.site-search-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-primary);
}

.site-search-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.site-search-field input {
  width: 100%;
  min-width: 0;
  height: 40px;
  border: 1px solid rgba(var(--color-primary-rgb), 0.18);
  border-radius: 999px;
  padding: 0 14px;
  font-size: 14px;
  color: #2d2623;
  background: #fff;
}

.site-search-field input:focus {
  outline: 2px solid rgba(var(--color-primary-rgb), 0.18);
  outline-offset: 1px;
}

.site-search-submit {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
}

.site-search-submit svg {
  width: 17px;
  height: 17px;
  stroke-width: 2;
}

.main-nav {
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.main-nav .wrap {
  position: relative;
  display: flex;
  justify-content: center;
}

.nav-list {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 0;
  margin-right: 0;
  transform: translateX(var(--header-nav-offset-x));
}

.nav-item {
  position: relative;
  flex: 0 0 var(--nav-item-width);
  width: var(--nav-item-width);
  min-width: 0;
}

.nav-item > a {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--line-nav);
  padding: 0 8px;
  font-size: var(--font-size-nav);
  font-weight: 700;
  line-height: 1.2;
  color: #fff;
  text-align: center;
  transition: background var(--motion-fast);
}

.nav-item > a:hover,
.nav-item > a:focus-visible,
.nav-item.is-open > a {
  background: rgba(255, 255, 255, 0.10);
}

.mega-menu {
  position: absolute;
  left: 0;
  top: 100%;
  width: 100%;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(6px);
  transition:
    opacity var(--motion-fast),
    transform var(--motion-fast),
    visibility var(--motion-fast);
  z-index: 70;
}

.nav-item:hover .mega-menu,
.nav-item.is-open .mega-menu,
.nav-item:focus-within .mega-menu {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

.mega-panel {
  width: 100%;
  background: var(--color-hover-blue);
  color: #fff;
  box-shadow: 0 16px 28px rgba(23, 74, 124, 0.20);
  border-top: 2px solid var(--color-hover-blue-dark);
  border-radius: 0 0 4px 4px;
}

.mega-column {
  display: flex;
  flex-direction: column;
  padding: 6px 0;
}

.mega-column a {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--line-subnav);
  padding: 5px 8px;
  font-size: var(--font-size-subnav);
  line-height: 1.25;
  color: rgba(255, 255, 255, 0.92);
  text-align: center;
  word-break: keep-all;
  transition: background var(--motion-fast), color var(--motion-fast);
}

.mega-column a:hover,
.mega-column a:focus-visible {
  color: #fff;
  background: rgba(255, 255, 255, 0.13);
}

.site-footer {
  background: var(--color-primary);
  color: rgba(255, 255, 255, 0.9);
  padding: 36px 0 28px;
}

.footer-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 12px 14px;
}

.footer-column h3 {
  margin-bottom: 8px;
  font-size: var(--font-size-footer-heading);
  line-height: 1.18;
  font-weight: 800;
  color: #fff;
}

.footer-column {
  text-align: center;
}

.footer-column h3 a {
  display: inline-block;
  padding: 0;
  font-size: inherit;
  line-height: inherit;
  font-weight: inherit;
  color: #fff;
}

.footer-column a {
  display: block;
  padding: 2px 0;
  font-size: var(--font-size-footer-link);
  line-height: var(--line-footer-link);
  color: rgba(255, 255, 255, 0.72);
  transition: color var(--motion-fast);
}

.footer-column h3 a,
.footer-column a {
  white-space: nowrap;
}

.footer-column a:hover,
.footer-column a:focus-visible {
  color: #fff;
}

.footer-divider {
  height: 1px;
  margin: 24px 0 22px;
  background: rgba(255, 255, 255, 0.18);
}

.footer-bottom {
  display: grid;
  grid-template-columns: minmax(260px, 0.86fr) minmax(360px, 1.42fr) auto;
  gap: clamp(24px, 4vw, 68px);
  align-items: center;
}

.footer-logo-block {
  display: flex;
  align-items: center;
  min-width: 0;
}

.footer-logo {
  display: block;
  width: min(var(--footer-logo-width), 100%);
  height: auto;
  max-height: var(--footer-logo-max-height);
  object-fit: contain;
  object-position: left center;
  flex: none;
}

.footer-contact {
  min-width: 0;
  width: 100%;
  justify-self: stretch;
  text-align: center;
}

.footer-contact h3 {
  font-size: clamp(17px, 1.2vw, 21px);
  line-height: 1.35;
  margin-bottom: 10px;
  color: #fff;
  font-weight: 800;
}

.footer-contact p {
  font-size: clamp(13px, 0.9vw, 15px);
  line-height: 1.75;
  color: rgba(255, 255, 255, 0.84);
}

.footer-copyright {
  margin-top: 6px;
  font-size: clamp(12px, 0.84vw, 14px);
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.86);
}

.footer-socials {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  justify-self: end;
}

.footer-social-card {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 72px;
  color: #fff;
  text-align: center;
}

.footer-social-card:hover,
.footer-social-card:focus-visible {
  color: #fff;
}

.footer-social-icon {
  display: block;
  width: 44px;
  height: 44px;
  object-fit: contain;
  transition: transform var(--motion-fast), opacity var(--motion-fast);
}

.footer-social-card:hover .footer-social-icon,
.footer-social-card:focus-visible .footer-social-icon {
  transform: translateY(-2px);
  opacity: 0.92;
}

.footer-social-card span {
  display: block;
  font-size: 13px;
  line-height: 1.2;
  font-weight: 700;
  white-space: nowrap;
}

.back-to-top {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(var(--color-primary-rgb), 0.95);
  color: #fff;
  box-shadow: 0 10px 24px rgba(55, 20, 20, 0.28);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
  z-index: 50;
}

.back-to-top.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.back-to-top svg {
  width: 22px;
  height: 22px;
  margin: 0 auto;
  fill: currentColor;
}

.mobile-drawer {
  position: fixed;
  inset: 0;
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

.mobile-drawer.is-open {
  opacity: 1;
  pointer-events: auto;
}

.mobile-drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(25, 18, 18, 0.55);
}

.mobile-drawer-panel {
  position: absolute;
  top: 0;
  left: 0;
  width: min(84vw, 360px);
  height: 100%;
  background: #fff;
  color: var(--color-text);
  transform: translateX(-100%);
  transition: transform 0.26s ease;
  overflow-y: auto;
}

.mobile-drawer.is-open .mobile-drawer-panel {
  transform: translateX(0);
}

.mobile-drawer-head {
  height: 64px;
  padding: 0 18px 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--color-primary);
  color: #fff;
  font-size: 18px;
  font-weight: 800;
}

.drawer-close {
  color: #fff;
}

.mobile-utility-links {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 18px 16px 10px;
  background: #f8f7f5;
}

.mobile-utility-links a {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--color-primary);
  background: #fff;
}

.mobile-nav {
  padding: 10px 16px 20px;
}

.mobile-nav details {
  border-bottom: 1px solid #ece7e2;
}

.mobile-nav summary {
  list-style: none;
  cursor: pointer;
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 16px;
  font-weight: 700;
  color: #2e2927;
}

.mobile-nav summary::-webkit-details-marker {
  display: none;
}

.mobile-nav summary::after {
  content: '+';
  font-size: 20px;
  color: var(--color-primary);
}

.mobile-nav details[open] summary::after {
  content: '\2212';
}

.mobile-submenu {
  padding: 0 0 14px;
  display: grid;
  gap: 8px;
}

.mobile-submenu a,
.mobile-nav-link {
  display: block;
  padding: 6px 0;
  font-size: 14px;
  color: #5c5450;
}

.mobile-nav-link {
  padding-top: 12px;
  font-weight: 700;
  color: var(--color-primary);
}

@media (max-width: 1180px) {
  .footer-bottom {
    grid-template-columns: minmax(240px, 0.9fr) minmax(300px, 1.25fr) auto;
    gap: clamp(18px, 3vw, 36px);
  }

  .footer-logo {
    width: min(var(--footer-logo-width), 100%);
    max-height: var(--footer-logo-max-height);
  }

  .footer-social-icon {
    width: 40px;
    height: 40px;
  }
}

@media (min-width: 768px) {
  .footer-bottom {
    grid-template-columns: minmax(300px, 420px) minmax(360px, 520px) minmax(120px, 1fr);
    gap: clamp(16px, 2vw, 28px);
  }

  .footer-contact {
    justify-self: start;
    width: 100%;
    text-align: center;
  }

  .footer-socials {
    justify-self: end;
    justify-content: flex-end;
  }
}

@media (max-width: 920px) {
  .masthead-inner {
    min-height: var(--masthead-height);
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 8px;
  }

  .brand {
    position: static;
    left: auto;
    top: auto;
    transform: none;
    grid-column: 1;
    grid-row: 1;
    justify-self: start;
    width: var(--brand-logo-width);
    max-width: 100%;
  }

  .topbar-links-list {
    display: none;
  }

  .nav-toggle {
    display: inline-flex;
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
  }

  .masthead-links {
    position: static;
    grid-column: 3;
    grid-row: 1;
  }

  .top-search-toggle {
    width: 36px;
    height: 36px;
  }

  .site-search-popover {
    left: 12px;
    right: 12px;
    width: auto;
  }

  .main-nav {
    display: none;
  }
}

@media (max-width: 767px) {
  .site-footer {
    padding: 26px 0 22px;
  }

  .masthead-inner {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    gap: clamp(2px, 0.8vw, 4px) 4px;
    min-height: var(--masthead-height);
    align-items: start;
    padding: 2px 0;
  }

  .brand {
    grid-row: 1 / 3;
    align-self: start;
  }

  .brand-picture,
  .brand-logo {
    height: auto;
  }

  .nav-toggle,
  .top-search-toggle {
    width: clamp(26px, 5vw, 36px);
    height: clamp(26px, 5vw, 36px);
  }

  .nav-toggle {
    grid-column: 2;
    grid-row: 1;
    align-self: start;
  }

  .top-search-toggle svg,
  .nav-toggle svg {
    width: clamp(17px, 3.2vw, 20px);
    height: clamp(17px, 3.2vw, 20px);
  }

  .masthead-links {
    grid-column: 2;
    grid-row: 2;
    display: flex;
    align-self: start;
    justify-self: end;
  }

  .footer-columns {
    display: none;
  }

  .footer-divider {
    display: none;
  }

  .footer-bottom {
    grid-template-columns: 1fr;
    gap: 14px;
    justify-items: center;
    text-align: center;
  }

  .footer-logo-block {
    justify-content: center;
  }

  .footer-logo {
    width: min(var(--footer-logo-mobile-width), 100%);
    max-height: var(--footer-logo-mobile-max-height);
  }

  .footer-contact {
    text-align: center;
  }

  .footer-contact h3 {
    margin-bottom: 6px;
    font-size: 16px;
  }

  .footer-contact p {
    font-size: 12px;
    line-height: 1.5;
  }

  .footer-copyright {
    margin-top: 4px;
    font-size: 12px;
  }

  .footer-socials {
    justify-content: center;
    justify-self: center;
    gap: 18px;
  }

  .footer-social-card {
    min-width: 58px;
    gap: 5px;
  }

  .footer-social-icon {
    width: 34px;
    height: 34px;
  }

  .footer-social-card span {
    font-size: 12px;
  }

  .back-to-top {
    right: 14px;
    bottom: 14px;
    width: 44px;
    height: 44px;
  }
}