@font-face {
  font-family: "Contents Source Han";
  src: url("fonts/contents-regular.woff?v=bilingual-index") format("woff");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Contents Source Han";
  src: url("fonts/contents-medium.woff?v=bilingual-index") format("woff");
  font-weight: 500;
  font-display: swap;
}
:root {
  --contents-font: "Contents Source Han", "思源黑体 CN Medium", "Source Han Sans SC", sans-serif;
}

/* The full touch target surrounds a smaller visible index tab. */
.contents-tab {
  position: fixed;
  z-index: 12;
  top: 50%;
  left: max(8px, env(safe-area-inset-left));
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  padding: 0;
  isolation: isolate;
  color: #faf8f2;
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  touch-action: manipulation;
}
.contents-tab::before {
  content: "";
  position: absolute;
  inset: 5px;
  z-index: -1;
  border-radius: inherit;
  border: 1px solid rgb(240 239 231 / .30);
  background: rgb(10 12 14 / .69);
  backdrop-filter: blur(9px);
}
.contents-glyph { display: block; width: 22px; height: 22px; }
.contents-glyph .index-leaf { opacity: .67; }
.contents-tab:focus-visible { outline: 2px solid #fff; outline-offset: 0; }
@media (hover: hover) and (pointer: fine) {
  .contents-tab:hover::before { background-color: rgb(10 12 14 / .88); border-color: #f0efe79e; }
  .contents-tab:hover .index-leaf { opacity: 1; transform: translate(.6px, -.6px); }
}
@media (orientation: portrait) and (max-aspect-ratio: 3/4) {
  .contents-tab {
    top: max(10px, env(safe-area-inset-top)); left: max(8px, env(safe-area-inset-left));
    transform: none;
  }
}

html:has(#page-index[open]) { overflow: hidden; }
html:has(#page-index[open]) .folio { visibility: hidden; }
#page-index {
  --gutter: clamp(22px, 2.4vw, 39px);
  position: fixed;
  inset: 0 auto 0 0;
  margin: 0;
  width: min(390px, 89vw);
  height: 100%; height: 100dvh;
  max-width: none; max-height: none;
  overflow: hidden;
  padding: max(26px, env(safe-area-inset-top)) var(--gutter) max(16px, env(safe-area-inset-bottom));
  border: 0;
  border-right: 1px solid rgb(255 255 255 / .13);
  border-radius: 0;
  color: #f9f9f7;
  background: rgb(0 0 0 / .73);
  backdrop-filter: blur(13px);
  box-shadow: none;
  font: 400 15px/1.55 var(--contents-font);
  font-synthesis: none;
}
#page-index[open] { display: flex; flex-direction: column; }
#page-index::backdrop { background: rgb(0 0 0 / .13); backdrop-filter: none; }
#page-index .page-index__header {
  flex: none;
  min-height: 54px;
  padding-bottom: 13px;
  border-bottom: 1px solid rgb(255 255 255 / .24);
}
#page-index h2 {
  font: 500 clamp(22px, 1.85vw, 27px)/1.3 var(--contents-font);
  letter-spacing: .055em;
}
#page-index .page-index__header button {
  position: relative;
  width: 44px; height: 44px;
  margin-right: -10px;
  padding: 0;
  border: 0; border-radius: 50%;
  color: rgb(255 255 255 / .76);
  background: transparent;
  font: 400 0/0 var(--contents-font);
}
#page-index .page-index__header button::before, #page-index .page-index__header button::after {
  content: "";
  position: absolute; top: 50%; left: 50%;
  width: 16px; height: 1.25px;
  background: currentColor;
  transform: translate(-50%, -50%) rotate(45deg);
}
#page-index .page-index__header button::after { transform: translate(-50%, -50%) rotate(-45deg); }
#page-index .page-index__header button:hover { color: #fff; background: rgb(255 255 255 / .07); }
#page-index ol {
  flex: 1;
  display: block;
  min-height: 0;
  margin: 4px -8px 0;
  padding: 8px 8px 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgb(255 255 255 / .22) transparent;
  mask-image: linear-gradient(to bottom, transparent, #000 10px, #000 calc(100% - 12px), transparent);
}
#page-index li { display: block; }
#page-index a {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 3px;
  min-height: 55px;
  padding: 8px 6px;
  border-radius: 4px;
  color: #e0dfda;
  background: none;
  overflow-wrap: anywhere;
}
#page-index .index-zh {
  color: inherit;
  font: 400 15px/1.35 var(--contents-font);
  letter-spacing: .025em;
}
#page-index .index-en, #page-index h2 span {
  color: #b4b4b0;
  font: 400 11px/1.35 var(--contents-font);
  letter-spacing: .015em;
}
#page-index .index-en .index-apostrophe {
  font-family: Arial, "Helvetica Neue", Helvetica, "Liberation Sans", Roboto, sans-serif;
  color: inherit;
  letter-spacing: 0;
}
#page-index h2 span { display: block; margin-top: 3px; }
#page-index a:is(:hover, [aria-current="page"]) { color: white; background: rgb(255 255 255 / .075); }
#page-index a[aria-current="page"] .index-zh { font-weight: 500; color: #fff; }
#page-index a[aria-current="page"] .index-en { color: #d8d8d4; }
#page-index :is(a, button):focus-visible { outline: 1px solid rgb(255 255 255 / .78); outline-offset: 2px; }
.controls .folio { font-family: var(--contents-font); font-synthesis: none; }
.controls .folio-current { font-weight: 500; }
@media (max-width: 540px) {
  #page-index { --gutter: 24px; padding-top: max(16px, env(safe-area-inset-top)); }
  #page-index .page-index__header { padding-bottom: 8px; }
  #page-index a { min-height: 52px; }
}
@media (prefers-reduced-motion: no-preference) {
  html:not(.reduce-motion) .contents-tab::before { transition: background-color .2s, border-color .2s; }
  html:not(.reduce-motion) .contents-glyph .index-leaf { transition: opacity .2s, transform .2s; }
  html:not(.reduce-motion) #page-index[open] { animation: fade-in .2s ease-out; }
}
