@media (min-width: 1024px) {
  .navbar {
    position: relative;
    justify-content: space-between;
    flex-wrap: nowrap;
  }

  .navbar-nav {
    gap: var(--nav-gap);
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    justify-content: center !important;
    margin-inline: 0;
    flex-wrap: nowrap;
    max-width: calc(100% - var(--brand-logo-width) - var(--nav-right-width));
  }

  .navbar-nav > :not(:last-child) {
    margin-inline: 0;
  }

  .navbar > .order-1 {
    flex: 0 0 var(--nav-right-width);
    justify-content: flex-end;
    white-space: nowrap;
  }
}

@media (max-width: 1400px) and (min-width: 1024px) {
  .navbar-nav {
    position: static;
    left: auto;
    transform: none;
    margin-inline: 0;
  }

  .navbar-brand {
    margin-left: calc(var(--spacing) * 6);
  }
}

:root {
  --brand-logo-width: clamp(170px, 20vw, 300px);
  --brand-logo-height: clamp(42px, 7vw, 100px);
  --brand-logo-left: clamp(0.5rem, 2.5vw, 3.75rem);
  --nav-font-size: clamp(0.95rem, 1.2vw, 1.3rem);
  --nav-gap: clamp(0.5rem, 1.6vw, 2.5rem);
  --nav-right-width: clamp(6rem, 12vw, 10rem);
}

.navbar-brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--brand-logo-width);
  height: var(--brand-logo-height);
  margin-left: var(--brand-logo-left);
  background: var(--site-logo-light) no-repeat center / contain;
  overflow: hidden;
  text-indent: -9999px;
  white-space: nowrap;
  font-size: 0;
}

.dark .navbar-brand {
  background-image: var(--site-logo-dark);
}

@media (max-width: 1023.98px) {
  .navbar {
    min-height: var(--brand-logo-height);
    justify-content: space-between;
  }

  .navbar-nav {
    position: static;
    left: auto;
    transform: none;
    margin-inline: 0;
    gap: calc(var(--spacing) * 4);
  }

  .navbar-brand {
    margin-left: calc(var(--spacing) * 2);
  }

  .nav-link {
    font-size: calc(var(--text-base) * 1);
  }
}

@media (max-width: 768px) {
  :root {
    --brand-logo-width: 170px;
    --brand-logo-height: 42px;
  }

  .navbar-brand {
    margin-left: calc(var(--spacing) * 2);
  }
}

#site-header.header {
  padding-block: 0;
}

.navbar {
  min-height: var(--brand-logo-height);
  align-items: center;
}

.nav-link {
  font-size: var(--nav-font-size);
  white-space: nowrap;
}

@media (max-width: 1280px) {
  .nav-link {
    font-size: var(--nav-font-size);
  }

  .navbar-nav {
    gap: var(--nav-gap);
  }
}

@media (max-width: 1023.98px) {
  .nav-link {
    font-size: var(--nav-font-size);
  }

  .navbar-nav {
    gap: var(--nav-gap);
  }
}

.hero-carousel-wrapper {
  margin: 0 calc(50% - 50vw);
}

/* Remove top gap above the hero carousel so it touches the navbar */
#hero-carousel {
  margin-top: 0;
  padding-top: 0;
}

.hero-carousel {
  position: relative;
  width: 100vw;
  height: 90vh;
  overflow: hidden;
  background: #000;
}

/* Reduce gap between hero carousel and next section on home */
.page-home #hero-carousel {
  padding-bottom: 0;
}

.page-home #hero-carousel + .hbb-section {
  padding-top: 5;
}

.hero-slide {
  position: absolute;
  inset: 0;
  background-position: center;
  background-size: cover;
  opacity: 0;
  transition: opacity 800ms ease;
}

.hero-slide.is-active {
  opacity: 1;
}

.hero-slide::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0.35));
}

.hero-slide-content {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  color: #fff;
  padding: 0 6vw;
}

.hero-slide-title {
  font-size: clamp(2rem, 4vw, 4rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-bottom: 0.5rem;
}

.hero-slide-subtitle {
  font-size: clamp(1rem, 1.6vw, 1.4rem);
  opacity: 0.9;
}

.hero-slide-title,
.hero-slide-subtitle {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 500ms ease, transform 700ms ease;
}

.hero-slide.is-active .hero-slide-title {
  opacity: 1;
  transform: translateY(0);
  transition-delay: 120ms;
}

.hero-slide.is-active .hero-slide-subtitle {
  opacity: 1;
  transform: translateY(0);
  transition-delay: 220ms;
}

/* Make Mermaid diagrams wider than the prose column */
.prose .mermaid {
  width: 70vw;
  max-width: 70vw;
  margin-left: calc(50% - 35vw);
  margin-right: calc(50% - 35vw);
}

.prose .mermaid svg {
  width: 100%;
  height: auto;
}

@media (max-width: 768px) {
  .prose .mermaid {
    width: 100%;
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
  }
}

/* Widen the intro block text and Bilibili embed */
#intro .prose {
  width: 70vw;
  max-width: 70vw;
}

#intro .bili-video {
  width: 70vw;
  max-width: 70vw;
  margin-left: auto;
  margin-right: auto;
}

@media (max-width: 768px) {
  #intro .prose,
  #intro .bili-video {
    width: 100%;
    max-width: 100%;
  }
}

/* Home portfolio block: use 80% viewport width on desktop */
#recent-papers > .mx-auto.max-w-7xl {
  width: 90vw;
  max-width: 90vw;
}

@media (max-width: 1023.98px) {
  #recent-papers > .mx-auto.max-w-7xl {
    width: 100%;
    max-width: 100%;
  }
}

@media (max-width: 768px) {
  .blox-collection .flex.flex-col.items-center.px-6 {
    padding-left: 0;
    padding-right: 0;
  }

  .blox-collection .flex.flex-col.items-center.px-6 > .container {
    width: 90vw;
    max-width: 90vw;
    margin-left: auto;
    margin-right: auto;
    padding-left: 0;
    padding-right: 0;
  }

  .blox-collection [role="article"] {
    width: 100%;
  }

  .blox-collection [role="article"] h3 {
    width: 90%;
    margin-left: auto;
    margin-right: auto;
    font-size: 1rem;
    line-height: 1.4;
  }
}

/* Partner logos: larger size and keep original colors */
#partners img {
  height: clamp(5.5rem, 9vw, 7.5rem);
  width: auto;
  filter: none !important;
  opacity: 1 !important;
}

/* Publication pages: widen text content */
.page-publications {
  --publication-text-width: 60vw;
}

.page-publications .max-w-screen-xl {
  max-width: 100%;
}

.page-publications article > main {
  width: var(--publication-text-width);
  max-width: var(--publication-text-width);
  margin-left: auto;
  margin-right: auto;
}

.page-publications main > h1,
.page-publications main > .max-w-prose.grid {
  width: 100%;
  max-width: 100%;
  margin-left: 0;
  margin-right: 0;
}

.page-publications .max-w-prose.grid > div:first-child + div {
  text-align: justify;
  text-justify: inter-ideograph;
}

.page-publications .prose {
  text-align: justify;
  text-justify: inter-ideograph;
}

.page-publications .prose p {
  margin: 0;
}

.page-publications .prose p + p {
  margin-top: 0.75rem;
}

.page-publications .max-w-prose.grid > div:first-child + div p {
  margin: 0;
}

.page-publications .max-w-prose.grid > div:first-child + div p + p {
  margin-top: 0.75rem;
}

/* Publications list page title alignment */
.page-publications .page-body .prose h1 {
  text-align: center;
}

.page-publications .publication-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: flex-end;
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 0.75rem;
  background: rgba(248, 250, 252, 0.65);
}

.page-publications .publication-filters__field {
  display: flex;
  flex-direction: column;
  min-width: 11rem;
  gap: 0.35rem;
}

.page-publications .publication-filters__field label {
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: rgba(30, 41, 59, 0.9);
}

.page-publications .publication-filters__field select {
  padding: 0.45rem 0.6rem;
  border-radius: 0.55rem;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: #fff;
  min-height: 2.2rem;
}

.page-publications .publication-filters__status {
  margin-left: auto;
  font-size: 0.9rem;
  color: rgba(51, 65, 85, 0.9);
}

.page-publications .publication-filters__empty {
  margin-bottom: 0.9rem;
  color: rgba(185, 28, 28, 0.9);
  font-size: 0.92rem;
}

.dark .page-publications .publication-filters {
  border-color: rgba(100, 116, 139, 0.6);
  background: rgba(15, 23, 42, 0.45);
}

.dark .page-publications .publication-filters__field label,
.dark .page-publications .publication-filters__status {
  color: rgba(226, 232, 240, 0.95);
}

.dark .page-publications .publication-filters__field select {
  background: rgba(2, 6, 23, 0.8);
  color: rgba(226, 232, 240, 0.95);
  border-color: rgba(100, 116, 139, 0.7);
}

.dark .page-publications .publication-filters__empty {
  color: rgba(252, 165, 165, 0.95);
}

.page-publications .prose,
.page-publications .max-w-prose,
.page-publications .container.mx-auto.prose,
.page-publications time {
  width: 100%;
  max-width: 100%;
  margin-left: 0;
  margin-right: 0;
}

@media (max-width: 768px) {
  .page-publications article > main,
  .page-publications .prose,
  .page-publications .max-w-prose,
  .page-publications .container.mx-auto.prose,
  .page-publications time {
    width: 100%;
    max-width: 100%;
  }

  .page-publications main > h1,
  .page-publications main > .max-w-prose.grid {
    width: 100%;
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
  }
}

.hero-carousel-indicators {
  position: absolute;
  left: 50%;
  bottom: 2vh;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
}

/* Home page section reveal */
.page-home .hbb-section.reveal,
.page-about-us .hbb-section.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 700ms ease, transform 700ms ease;
  transition-delay: var(--reveal-delay, 0ms);
}

.page-home .hbb-section.reveal.is-visible,
.page-about-us .hbb-section.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .page-home .hbb-section.reveal,
  .page-about-us .hbb-section.reveal,
  .hero-slide-title,
  .hero-slide-subtitle {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

.hero-indicator {
  width: 28px;
  height: 4px;
  border-radius: 999px;
  border: 0;
  padding: 0;
  background: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  transition: background 200ms ease, transform 200ms ease;
}

.hero-indicator.is-active {
  background: rgba(255, 255, 255, 0.95);
  transform: scaleX(1.15);
}

/* Dev hero: reduce internal whitespace (template defaults are min-h-[80vh] and py-20) */
.blox-dev-hero > .min-h-\[80vh\] {
  min-height: clamp(22rem, 46vh, 32rem);
}

.blox-dev-hero > .min-h-\[80vh\] > .py-20 {
  padding-top: clamp(1rem, 3vh, 2rem);
  padding-bottom: clamp(1rem, 3vh, 2rem);
}

@media (max-width: 768px) {
  .blox-dev-hero > .min-h-\[80vh\] {
    min-height: auto;
  }

  .blox-dev-hero > .min-h-\[80vh\] > .py-20 {
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
  }
}
