/* Top bar */
.topbar {
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(74, 64, 53, 0.08);
  position: sticky;
  top: 0;
  background: rgba(244, 239, 230, 0.95);
  backdrop-filter: blur(8px);
  z-index: 10;
}

.topbar__left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar__hamburger {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 4px;
  cursor: pointer;
}

.topbar__hamburger span {
  display: block;
  height: 1.5px;
  background: var(--ink-light);
  transition: width 0.2s;
}

.topbar__hamburger span:nth-child(1) { width: 16px; }
.topbar__hamburger span:nth-child(2) { width: 12px; }
.topbar__hamburger span:nth-child(3) { width: 16px; }

.topbar__chapter-label {
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--earth-muted);
  text-transform: uppercase;
}

.topbar__chapter-title {
  font-family: var(--font-prose);
  font-size: 13px;
  color: var(--ink-deep);
}

/* Progress ring */
.progress-ring {
  width: 32px;
  height: 32px;
  position: relative;
}

.progress-ring svg {
  transform: rotate(-90deg);
}

.progress-ring__bg {
  fill: none;
  stroke: rgba(74, 64, 53, 0.1);
  stroke-width: 2;
}

.progress-ring__fill {
  fill: none;
  stroke: var(--ink-light);
  stroke-width: 2;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.15s ease;
}

.progress-ring__text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  color: var(--ink-light);
}

/* Chapter drawer */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.drawer-overlay--open {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(320px, 85vw);
  background: linear-gradient(180deg, var(--stone-start), var(--stone-end));
  z-index: 51;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.drawer::-webkit-scrollbar {
  display: none;
}

.drawer--open {
  transform: translateX(0);
}

.drawer__header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid rgba(244, 239, 230, 0.06);
}

.drawer__header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.drawer__title-sub {
  font-size: 9px;
  letter-spacing: 3px;
  color: rgba(244, 239, 230, 0.35);
  text-transform: uppercase;
}

.drawer__title {
  font-family: var(--font-prose);
  font-size: 16px;
  color: var(--parchment);
  margin-top: 2px;
}

.drawer__close {
  color: rgba(244, 239, 230, 0.3);
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
}

.drawer__nav {
  display: flex;
  gap: 16px;
  margin-top: 16px;
}

.drawer__nav-link {
  font-size: var(--label-size);
  letter-spacing: 1px;
  color: rgba(244, 239, 230, 0.4);
  cursor: pointer;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(244, 239, 230, 0.1);
  text-transform: uppercase;
  transition: color 0.2s;
}

.drawer__nav-link:hover {
  color: rgba(244, 239, 230, 0.6);
}

.drawer__chapters {
  padding: 16px 24px;
}

.drawer__section-label {
  font-size: 9px;
  letter-spacing: 2px;
  color: rgba(244, 239, 230, 0.25);
  text-transform: uppercase;
  margin-bottom: 12px;
}

.drawer__chapter-entry {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(244, 239, 230, 0.04);
  cursor: pointer;
  transition: background 0.2s;
}

.drawer__chapter-entry:hover {
  background: rgba(244, 239, 230, 0.02);
  margin: 0 -24px;
  padding-left: 24px;
  padding-right: 24px;
}

.drawer__chapter-numeral {
  font-size: 11px;
  color: rgba(244, 239, 230, 0.2);
  min-width: 20px;
}

.drawer__chapter-title {
  font-family: var(--font-prose);
  font-size: 13px;
  color: var(--parchment-dim);
}

.drawer__chapter-entry--current {
  background: rgba(244, 239, 230, 0.03);
  margin: 0 -24px;
  padding-left: 24px;
  padding-right: 24px;
  position: relative;
}

.drawer__chapter-entry--current::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(to bottom, transparent, var(--gold-thread), transparent);
}

.drawer__chapter-entry--current .drawer__chapter-numeral {
  color: var(--gold-thread);
}

.drawer__chapter-entry--current .drawer__chapter-title {
  color: var(--parchment);
}

.drawer__chapter-entry--interlude .drawer__chapter-numeral {
  color: rgba(244, 239, 230, 0.15);
}

.drawer__chapter-entry--interlude .drawer__chapter-title {
  color: rgba(244, 239, 230, 0.35);
  font-style: italic;
}

.drawer__interlude-label {
  margin: 8px 0 4px;
  font-size: 8px;
  letter-spacing: 2px;
  color: rgba(244, 239, 230, 0.15);
  text-transform: uppercase;
}

/* Annotation tooltip */
.annotation {
  border-bottom: 1.5px dotted var(--annotation-dot);
  cursor: pointer;
  transition: border-color 0.2s;
}

.annotation:hover {
  border-color: rgba(74, 64, 53, 0.5);
}

.annotation-tooltip {
  margin: 0 -8px 0;
  padding: 14px 16px;
  background: rgba(42, 36, 32, 0.04);
  border-radius: 6px;
  border-left: 2px solid rgba(74, 64, 53, 0.2);
  overflow: hidden;
  max-height: 0;
  opacity: 0;
}

.annotation-tooltip--open {
  max-height: 300px;
  opacity: 1;
}


.annotation-tooltip__name {
  font-family: var(--font-prose);
  font-size: 14px;
  color: var(--ink-deep);
  margin-bottom: 2px;
}

.annotation-tooltip__chinese {
  font-size: 12px;
  color: var(--earth-muted);
  margin-bottom: 2px;
}

.annotation-tooltip__epithet {
  font-family: var(--font-prose);
  font-size: 12px;
  font-style: italic;
  color: var(--ink-mid);
  margin-bottom: 8px;
}

.annotation-tooltip__category {
  font-size: 9px;
  letter-spacing: 1.5px;
  color: var(--earth-muted);
  text-transform: uppercase;
  margin-bottom: 6px;
}

.annotation-tooltip__role {
  font-size: 11px;
  color: var(--ink-light);
  margin-bottom: 6px;
}

.annotation-tooltip__notes {
  font-family: var(--font-prose);
  font-size: 12px;
  color: var(--ink-mid);
  line-height: 1.6;
  margin-bottom: 8px;
}

.annotation-tooltip__link {
  font-size: 11px;
  color: var(--earth-muted);
  cursor: pointer;
  display: inline-block;
}

.annotation-tooltip__link:hover {
  color: var(--ink-mid);
}

.annotation-tooltip--dark {
  background: rgba(30, 26, 22, 0.95);
  border-left-color: rgba(196, 168, 122, 0.25);
}

.annotation-tooltip--dark .annotation-tooltip__name {
  color: var(--parchment);
}

.annotation-tooltip--dark .annotation-tooltip__chinese {
  color: var(--gold-thread);
}

.annotation-tooltip--dark .annotation-tooltip__epithet {
  color: var(--parchment-dim);
}

.annotation-tooltip--dark .annotation-tooltip__category {
  color: var(--gold-dim);
}

.annotation-tooltip--dark .annotation-tooltip__role {
  color: var(--parchment-ghost);
}

.annotation-tooltip--dark .annotation-tooltip__notes {
  color: var(--parchment-dim);
}

.annotation-tooltip--dark .annotation-tooltip__link {
  color: rgba(196, 168, 122, 0.5);
}

.annotation-tooltip--dark .annotation-tooltip__link:hover {
  color: var(--gold-thread);
}

/* Chapter-end navigation */
.chapter-end-nav {
  padding: 24px var(--page-padding-mobile) 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid rgba(74, 64, 53, 0.08);
  max-width: var(--reading-max-width);
  margin: 0 auto;
}

.chapter-end-nav__side {
  cursor: pointer;
  transition: opacity 0.2s;
}

.chapter-end-nav__side:hover {
  opacity: 0.7;
}

.chapter-end-nav__label {
  font-size: 9px;
  color: var(--earth-muted);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.chapter-end-nav__title {
  font-family: var(--font-prose);
  font-size: 11px;
  color: var(--ink-mid);
  margin-top: 2px;
}

.chapter-end-nav__side--next {
  text-align: right;
}

.chapter-end-nav__divider {
  width: 1px;
  height: 24px;
  background: rgba(74, 64, 53, 0.12);
}
