:root {
  --top-nav-space: 3.4rem;
}

.top-nav {
  background: #ffffff;
  border-bottom: 1px solid rgba(127, 127, 127, 0.25);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  left: 0;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 20;
}

.wrapper {
  padding-top: 0;
}

.wrapper > section {
  padding-top: calc(4em + var(--top-nav-space));
}

.wrapper [id] {
  scroll-margin-top: 4.3rem;
}

.top-nav-inner {
  align-items: center;
  display: flex;
  gap: 1.5rem;
  justify-content: space-between;
  margin: 0 auto;
  max-width: 960px;
  min-height: 3.4rem;
  padding: 0 1rem;
}

.top-nav-brand a,
.top-nav-links a {
  color: inherit;
  text-decoration: none;
}

.top-nav-brand {
  align-items: center;
  display: flex;
  flex: 0 1 auto;
  gap: 0.7rem;
  min-width: 0;
  white-space: nowrap;
}

.top-nav-name {
  border-bottom: 1px solid transparent;
  font-size: 1.08rem;
  font-weight: 700;
}

.top-nav-divider {
  background: rgba(127, 127, 127, 0.32);
  display: inline-block;
  height: 1.7rem;
  width: 1px;
}

.top-nav-logo-link {
  align-items: center;
  border-bottom: 1px solid transparent;
  display: inline-flex;
  flex: 0 0 auto;
}

.top-nav-logo {
  display: block;
  max-width: 100%;
  object-fit: contain;
}

.top-nav-logo-hkust {
  height: 1.8rem;
  width: auto;
}

.top-nav-logo-idea {
  height: 1.45rem;
  width: auto;
}

.top-nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.1rem;
  font-size: 1.1rem;
}

.top-nav-links a,
.blog-back-link,
.blog-source-link,
.blog-read-link {
  color: inherit;
  text-decoration: none;
}

.top-nav-links a {
  border-bottom: 1px solid transparent;
  font-weight: 600;
}

.top-nav-links a:hover,
.top-nav-links a:focus-visible,
.top-nav-name:hover,
.top-nav-name:focus-visible,
.top-nav-logo-link:hover,
.top-nav-logo-link:focus-visible {
  border-bottom-color: currentColor;
}

@media (prefers-color-scheme: dark) {
  .top-nav {
    background: #20212b;
    border-bottom-color: rgba(218, 219, 223, 0.25);
  }
}

.blog-page,
.blog-post {
  max-width: 860px;
  width: 100%;
}

.blog-page-heading,
.blog-post-topline {
  align-items: baseline;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
}

.blog-page-heading {
  border-bottom: 1px solid rgba(127, 127, 127, 0.25);
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
}

.blog-kicker {
  color: #6b7280;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  margin: 0 0 0.35rem;
  text-transform: uppercase;
}

.blog-page h2,
.blog-post h2 {
  margin: 0;
}

.blog-post-source {
  margin: 0.55rem 0 0.75rem;
}

.blog-lead {
  margin: 0.65rem 0 0;
  max-width: 44rem;
}

.blog-back-link,
.blog-source-link,
.blog-read-link {
  border-bottom: 1px solid rgba(127, 127, 127, 0.55);
  font-size: 0.88rem;
  white-space: nowrap;
}

.blog-columns {
  display: grid;
  gap: 0.7rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0 0 2rem;
}

.blog-column-page-meta {
  align-items: center;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.blog-column-page-meta span {
  color: #6b7280;
  font-size: 0.8rem;
}

.blog-column-link {
  border: 1px solid rgba(127, 127, 127, 0.25);
  color: inherit;
  display: block;
  padding: 0.85rem;
  text-decoration: none;
}

.blog-column-link:hover,
.blog-column-link:focus-visible {
  border-color: currentColor;
}

.blog-column-link strong,
.blog-column-link span {
  display: block;
}

.blog-column-link span {
  font-size: 0.82rem;
  line-height: 1.5;
  margin-top: 0.35rem;
  opacity: 0.76;
}

.blog-list {
  display: grid;
  gap: 1.15rem;
}

.blog-list-item {
  border-bottom: 1px solid rgba(127, 127, 127, 0.2);
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(120px, 180px) minmax(0, 1fr);
  padding-bottom: 1.15rem;
}

.blog-list-cover {
  display: block;
}

.blog-list-cover img {
  aspect-ratio: 16 / 10;
  display: block;
  object-fit: cover;
  width: 100%;
}

.blog-list-content h3 {
  font-size: 1.08rem;
  line-height: 1.45;
  margin: 0.35rem 0 0.45rem;
}

.blog-list-content h3 a {
  color: inherit;
  text-decoration: none;
}

.blog-list-content h3 a:hover,
.blog-list-content h3 a:focus-visible {
  text-decoration: underline;
}

.blog-post-meta,
.blog-metrics {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  font-size: 0.8rem;
  gap: 0.55rem 0.9rem;
  line-height: 1.4;
}

.blog-post-meta {
  color: #6b7280;
}

.blog-post-meta span + span::before,
.blog-metrics span + span::before {
  content: "·";
  margin-right: 0.9rem;
}

.blog-metrics {
  color: #4b5563;
  margin-top: 0.45rem;
}

.blog-excerpt {
  font-size: 0.91rem;
  line-height: 1.6;
  margin: 0.55rem 0 0.55rem;
}

.blog-read-link {
  font-size: 0.82rem;
}

.blog-post-topline {
  margin-bottom: 1.2rem;
}

.blog-post-header {
  border-bottom: 1px solid rgba(127, 127, 127, 0.25);
  float: none;
  padding-bottom: 1.3rem;
  padding-top: 0;
  position: static;
  text-align: left;
  width: auto;
}

.blog-post-header h2 {
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.blog-metrics-large {
  font-size: 0.88rem;
  margin-top: 0.65rem;
}

.blog-metrics-note {
  color: #6b7280;
  font-size: 0.78rem;
  line-height: 1.5;
  margin: 0.7rem 0 0;
}

.blog-post-cover {
  display: block;
  margin-top: 1.15rem;
  max-height: 420px;
  object-fit: contain;
  width: 100%;
}

.blog-post-body {
  font-size: 1rem;
  line-height: 1.8;
  overflow-wrap: anywhere;
  padding-top: 1.3rem;
}

.blog-post-body figure {
  margin: 1.35rem 0;
}

.blog-post-body img {
  height: auto;
  max-width: 100%;
}

.blog-post-body figcaption {
  color: #6b7280;
  font-size: 0.83rem;
  line-height: 1.5;
  margin-top: 0.4rem;
  text-align: center;
}

.blog-post-body pre {
  overflow-x: auto;
}

.blog-post-body table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
}

@media (max-width: 700px) {
  :root {
    --top-nav-space: 5.4rem;
  }

  .top-nav-inner {
    min-height: 5.4rem;
  }

  .wrapper > header {
    padding-top: var(--top-nav-space);
  }

  .wrapper > section {
    padding-top: calc(20px + var(--top-nav-space));
  }

  .wrapper [id] {
    scroll-margin-top: 6.3rem;
  }

  .top-nav-inner {
    align-items: flex-start;
    display: grid;
    gap: 0.45rem;
    grid-template-columns: 1fr;
    justify-content: center;
    padding-bottom: 0.75rem;
    padding-top: 0.75rem;
  }

  .top-nav-brand {
    gap: 0.55rem;
    overflow-x: auto;
    scrollbar-width: none;
    width: 100%;
  }

  .top-nav-brand::-webkit-scrollbar {
    display: none;
  }

  .top-nav-name {
    font-size: 1.1rem;
  }

  .top-nav-divider {
    height: 1.5rem;
  }

  .top-nav-logo-hkust {
    height: 1.45rem;
  }

  .top-nav-logo-idea {
    height: 1.2rem;
  }

  .top-nav-links {
    flex-wrap: nowrap;
    gap: 0.3rem 1rem;
    overflow-x: auto;
    padding-bottom: 0.15rem;
    scrollbar-width: none;
    width: 100%;
  }

  .top-nav-links::-webkit-scrollbar {
    display: none;
  }

  .top-nav-links a {
    flex: 0 0 auto;
  }

  .blog-page-heading,
  .blog-post-topline {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.55rem;
  }

  .blog-columns {
    grid-template-columns: 1fr;
  }

  .blog-column-page-meta {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.35rem;
  }

  .blog-list-item {
    grid-template-columns: 1fr;
  }

  .blog-list-cover img {
    aspect-ratio: 16 / 9;
    max-height: 220px;
  }
}

.blog-post-layout {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
}

.blog-post-page .blog-post-layout {
  width: 100%;
}

.blog-post {
  max-width: none;
  min-width: 0;
}

.blog-toc {
  min-width: 0;
}

.blog-toc[hidden] {
  display: none;
}

.blog-toc details {
  border: 1px solid rgba(127, 127, 127, 0.25);
  padding: 0.85rem 1rem;
}

.blog-toc summary {
  color: #043361;
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 600;
  list-style: none;
}

.blog-toc summary::-webkit-details-marker {
  display: none;
}

.blog-toc summary::after {
  content: "+";
  float: right;
  font-size: 1rem;
  font-weight: 400;
  line-height: 1;
}

.blog-toc details[open] summary::after {
  content: "−";
}

.blog-toc nav {
  margin-top: 0.75rem;
}

.blog-toc ol {
  list-style: none;
  margin: 0;
  padding: 0;
}

.blog-toc ol ol {
  border-left: 1px solid rgba(127, 127, 127, 0.22);
  margin: 0.25rem 0 0.25rem 0.55rem;
  padding-left: 0.7rem;
}

.blog-toc li {
  margin: 0;
}

.blog-toc a {
  border-left: 2px solid transparent;
  color: inherit;
  display: block;
  font-size: 0.8rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
  padding: 0.22rem 0.35rem;
  text-decoration: none;
}

.blog-toc a:hover,
.blog-toc a:focus-visible,
.blog-toc a.is-active {
  border-left-color: currentColor;
  color: #043361;
}

@media (prefers-color-scheme: dark) {
  .blog-toc summary,
  .blog-toc a:hover,
  .blog-toc a:focus-visible,
  .blog-toc a.is-active {
    color: #3eb7f0;
  }
}

@media (min-width: 1200px) {
  .blog-post-page .wrapper {
    width: min(1220px, calc(100% - 40px));
  }

  .blog-post-page section {
    width: calc(100% - 270px);
  }

  .blog-post-layout {
    gap: 2rem;
    grid-template-columns: minmax(0, 1fr) 220px;
  }

  .blog-toc {
    max-height: calc(100vh - var(--top-nav-space) - 2rem);
    overflow-y: auto;
    position: sticky;
    top: calc(var(--top-nav-space) + 1rem);
  }

  .blog-toc details {
    border: 0;
    border-left: 1px solid rgba(127, 127, 127, 0.25);
    padding: 0 0 0 1rem;
  }
}

@media (max-width: 1199px) {
  .blog-toc {
    order: -1;
  }
}
