:root {
  --topic-nav-height: 52px;
  --header-height: var(--topic-nav-height);
}

.atlas-topic-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--color-paper);
  font-family: var(--font-body);
}

.atlas-topic-nav {
  display: flex;
  height: var(--topic-nav-height);
  align-items: stretch;
  justify-content: center;
  gap: clamp(12px, 4vw, 52px);
  padding-inline: 8px;
  border-bottom: 1px solid var(--color-border);
  box-sizing: border-box;
}

.atlas-chapter-dropdown {
  position: relative;
  display: flex;
  align-items: stretch;
}

.atlas-chapter-dropdown > button {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 6px;
  border: 0;
  background: transparent;
  color: var(--color-red-dark);
  white-space: nowrap;
  cursor: pointer;
}

.atlas-chapter-dropdown > button::after {
  width: 6px;
  height: 6px;
  border-right: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  content: "";
}

.atlas-chapter-dropdown > button[aria-expanded="true"] { background: var(--color-control); }

.atlas-chapter-nav {
  position: absolute;
  inset: 100% 0 auto auto;
  min-width: 132px;
  padding: 4px;
  border: 1px solid var(--color-border);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-panel);
}

.atlas-chapter-dropdown:nth-child(-n+3) .atlas-chapter-nav {
  inset-inline: 0 auto;
}

.atlas-topic-header a {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 36px;
  padding-inline: 4px;
  color: var(--color-ink);
  text-decoration: none;
  white-space: nowrap;
}

.atlas-topic-nav > a,
.atlas-chapter-dropdown > button {
  font-size: 20px;
  font-weight: 700;
}
.atlas-chapter-nav a {
  min-height: 44px;
  justify-items: start;
  padding-inline: 12px;
  font-size: 14px;
}
.atlas-chapter-nav a:is(:hover, :focus-visible) { background: var(--color-control); }
.atlas-topic-header a:is(:hover, :focus-visible, [aria-current="page"]) {
  color: var(--color-red-dark);
}

.atlas-chapter-dropdown > button[aria-current="page"]::before {
  position: absolute;
  inset: auto 4px 0;
  height: 2px;
  background: var(--color-red-dark);
  content: "";
}

.atlas-topic-header :is(a, button):focus-visible { outline-offset: -3px; }

@media (max-width: 540px) {
  :root { --topic-nav-height: 46px; }
  .atlas-topic-nav { gap: clamp(2px, 1.5vw, 8px); padding-inline: 4px; }
  .atlas-topic-nav > a { padding-inline: 3px; }
  .atlas-topic-nav > a,
  .atlas-chapter-dropdown > button { font-size: 17px; }
}
