/*
 * Encyclopedia reader pilot.
 * Layout density follows the supplied Pixiv Encyclopedia capture; typography,
 * section rules, and information hierarchy follow Japanese Wikipedia.
 */

.hh-encyclopedia-page {
  --hhe-bg: #eaecf0;
  --hhe-panel: #fff;
  --hhe-panel-2: #f8f9fa;
  --hhe-text: #202122;
  --hhe-muted: #54595d;
  --hhe-line: #c8ccd1;
  --hhe-accent: #3366cc;
  --hhe-accent-2: #1f6b57;
  --hhe-header: #31577b;
  --hhe-hero-start: #fff;
  --hhe-hero-end: #fff;
  --hhe-field: #fff;
  background: var(--hhe-bg);
  color: var(--hhe-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  font-size: 15px;
  line-height: 1.75;
}

html[data-theme="dark"] .hh-encyclopedia-page {
  --hhe-bg: #202122;
  --hhe-panel: #27292d;
  --hhe-panel-2: #2f3136;
  --hhe-text: #eaecf0;
  --hhe-muted: #a2a9b1;
  --hhe-line: #54595d;
  --hhe-accent: #8ab4f8;
  --hhe-accent-2: #69c9b0;
  --hhe-header: #1f364c;
  --hhe-hero-start: #27292d;
  --hhe-hero-end: #27292d;
  --hhe-field: #27292d;
}

.hh-encyclopedia-page::after {
  display: none;
}

.hh-encyclopedia-page a {
  color: var(--hhe-accent);
}

.hh-encyclopedia-page .hh-encyclopedia-header {
  position: sticky;
  top: 0;
  z-index: 50;
  grid-template-columns: minmax(12rem, 1fr) auto auto auto;
  min-height: 3.6rem;
  padding: .48rem max(1rem, calc((100vw - 1180px) / 2));
  border-bottom: 0;
  background: var(--hhe-header);
  box-shadow: 0 1px 4px rgb(0 0 0 / 18%);
}

.hh-encyclopedia-page .hh-encyclopedia-header > a,
.hh-encyclopedia-page .hh-encyclopedia-header nav a {
  color: #fff;
}

.hh-encyclopedia-page .hh-encyclopedia-header > a span {
  color: #9bd5f1;
  font-size: .66rem;
}

.hh-encyclopedia-page .hh-encyclopedia-header > a strong {
  font-size: .94rem;
}

.hh-encyclopedia-page .hh-encyclopedia-header nav a {
  min-height: 2.35rem;
  font-size: .8rem;
  text-decoration: none;
}

.hh-encyclopedia-page .hh-encyclopedia-header > :is(.hh-theme-toggle, .hh-search-open) {
  min-height: 2.3rem;
  border-color: rgb(255 255 255 / 38%);
  background: rgb(255 255 255 / 8%);
  color: #fff;
  transition: background-color 140ms cubic-bezier(.23, 1, .32, 1), transform 120ms cubic-bezier(.23, 1, .32, 1);
}

.hh-encyclopedia-page .hh-encyclopedia-header :is(.hh-theme-toggle__label, .hh-search-open__label),
.hh-encyclopedia-page .hh-encyclopedia-header :is(.hh-theme-toggle, .hh-search-open) [aria-hidden="true"] {
  color: #fff;
}

.hh-encyclopedia-page .hh-encyclopedia-header > :is(.hh-theme-toggle, .hh-search-open):active,
.hh-encyclopedia-page .hh-page-tools :is(a, button):active {
  transform: scale(.97);
}

.hh-encyclopedia-page .hh-encyclopedia-breadcrumb {
  max-width: 1180px;
  padding: .72rem 1rem .58rem;
  color: var(--hhe-muted);
  font-size: .72rem;
}

.hh-encyclopedia-page .hh-encyclopedia-breadcrumb a {
  color: var(--hhe-muted);
  text-decoration: none;
}

.hh-encyclopedia-page .hh-encyclopedia-main {
  width: min(1180px, calc(100% - 2rem));
  padding: .35rem 0 4rem;
}

.hh-encyclopedia-page .hh-reader-layout {
  grid-template-columns: minmax(9.75rem, 10.75rem) minmax(0, 43rem) minmax(13rem, 15rem);
  gap: 1.25rem;
}

.hh-encyclopedia-page .hh-reader-core {
  overflow: hidden;
  padding: 0 1.35rem 2rem;
  border: 1px solid var(--hhe-line);
  border-radius: .45rem;
  background: var(--hhe-panel);
  box-shadow: 0 1px 3px rgb(0 0 0 / 8%);
}

.hh-encyclopedia-page .hh-reader-core > .hh-encyclopedia-hero {
  margin: 0;
  padding: 1.35rem 0 1rem;
  border: 0;
  border-bottom: 1px solid var(--hhe-line);
  border-radius: 0;
  background: none;
}

.hh-encyclopedia-page .hh-reader-core > .hh-encyclopedia-hero > p:first-child {
  margin-bottom: .25rem;
  color: var(--hhe-accent-2);
  font-size: .67rem;
  letter-spacing: .08em;
}

.hh-encyclopedia-page .hh-reader-core > .hh-encyclopedia-hero h1 {
  font-family: inherit;
  font-size: clamp(2rem, 4vw, 2.55rem);
  font-weight: 650;
  letter-spacing: -.025em;
  line-height: 1.25;
}

.hh-encyclopedia-page .hh-entry-reading {
  margin: .12rem 0 .5rem;
  color: var(--hhe-muted);
  font-size: .72rem;
  letter-spacing: .06em;
}

.hh-encyclopedia-page .hh-reader-core > .hh-encyclopedia-hero h1 ~ p:last-child {
  max-width: 60ch;
  margin: .35rem 0 0;
  color: var(--hhe-muted);
  font-size: .84rem;
  line-height: 1.65;
}

.hh-encyclopedia-page .hh-editorial-article:has(> .hh-editorial-visual[data-editorial-visual]) {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 13rem;
  column-gap: 1.2rem;
}

.hh-encyclopedia-page .hh-editorial-article:has(> .hh-editorial-visual[data-editorial-visual]) > * {
  grid-column: 1 / -1;
}

.hh-encyclopedia-page .hh-reader-core .hh-editorial-heading {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: .7rem;
  margin-top: .65rem;
  padding: .5rem 0;
  border: 0;
  border-bottom: 1px solid var(--hhe-line);
  border-radius: 0;
  background: transparent;
}

.hh-encyclopedia-page .hh-taxonomy {
  margin: 0;
}

.hh-encyclopedia-page .hh-taxonomy :is(a, span, strong),
.hh-encyclopedia-page .hh-editorial-article .hh-edition strong {
  min-height: 1.55rem;
  padding: .12rem .45rem;
  border: 1px solid var(--hhe-line);
  border-radius: .25rem;
  background: var(--hhe-panel-2);
  color: var(--hhe-muted);
  font-size: .62rem;
  line-height: 1.25;
}

.hh-encyclopedia-page .hh-editorial-article .hh-edition {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: .5rem;
  padding: 0;
}

.hh-encyclopedia-page .hh-editorial-article .hh-edition span {
  color: var(--hhe-muted);
  font-size: .65rem;
}

.hh-encyclopedia-page .hh-reader-core .hh-page-tools {
  justify-content: flex-end;
  gap: .2rem;
  margin: .3rem 0 .55rem;
}

.hh-encyclopedia-page .hh-page-tools :is(a, button) {
  min-height: 1.9rem;
  padding: .2rem .48rem;
  border: 0;
  border-radius: .25rem;
  background: transparent;
  color: var(--hhe-muted);
  font-size: .64rem;
  transition: background-color 140ms cubic-bezier(.23, 1, .32, 1), color 140ms cubic-bezier(.23, 1, .32, 1), transform 120ms cubic-bezier(.23, 1, .32, 1);
}

.hh-encyclopedia-page .hh-editorial-article:has(> .hh-editorial-visual[data-editorial-visual]) > .hh-editorial-lead {
  grid-column: 1;
  grid-row: 3;
  margin: 0;
  padding: .25rem 0 .6rem;
  border: 0;
  background: transparent;
  font-size: .94rem;
}

.hh-encyclopedia-page .hh-editorial-lead p {
  margin: 0 0 .7rem;
  line-height: 1.85;
}

.hh-encyclopedia-page .hh-editorial-article:has(> .hh-editorial-visual[data-editorial-visual]) > .hh-editorial-visual[data-editorial-visual] {
  grid-column: 2;
  grid-row: 3;
  align-self: start;
  width: 100%;
  margin: .25rem 0 .85rem;
  border: 1px solid var(--hhe-line);
  border-radius: .3rem;
  background: var(--hhe-panel-2);
}

.hh-encyclopedia-page .hh-editorial-visual[data-editorial-visual] img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

.hh-encyclopedia-page .hh-editorial-visual figcaption {
  padding: .42rem .5rem;
  color: var(--hhe-muted);
  text-align: left;
  font-size: .63rem;
  line-height: 1.45;
}

.hh-encyclopedia-page .hh-editorial-article:has(> .hh-editorial-visual[data-editorial-visual]) > .hh-editorial-visual--gallery[data-editorial-visual] {
  grid-column: 1 / -1;
  grid-row: 4;
  width: 100%;
  margin: .65rem 0 1rem;
}

.hh-encyclopedia-page .hh-editorial-visual--gallery .hh-editorial-visual-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .75rem;
  padding: .75rem;
}

.hh-encyclopedia-page .hh-editorial-visual--gallery .hh-editorial-visual-card {
  overflow: hidden;
  border: 1px solid var(--hhe-line);
  border-radius: .3rem;
  background: var(--hhe-panel-2);
}

.hh-encyclopedia-page .hh-editorial-visual--gallery .hh-editorial-visual-grid img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  height: auto;
  max-height: none;
  margin: 0;
  padding: 0;
  background: #fff;
  object-fit: contain;
}

.hh-encyclopedia-page .hh-editorial-visual--gallery .hh-editorial-visual-card p {
  margin: 0;
  padding: .5rem .58rem;
  color: var(--hhe-muted);
  font-size: .67rem;
  line-height: 1.55;
}

.hh-encyclopedia-page .hh-reader-core .hh-encyclopedia-section,
.hh-encyclopedia-page .hh-reader-core .hh-encyclopedia-review {
  margin: 0;
  padding: 1.25rem 0 .35rem;
  border: 0;
  border-top: 1px solid var(--hhe-line);
  border-radius: 0;
  background: transparent;
}

.hh-encyclopedia-page .hh-reader-core .hh-encyclopedia-section h2 {
  margin: 0 0 .75rem;
  padding: 0 0 .38rem;
  border-bottom: 1px solid var(--hhe-line);
  font-family: inherit;
  font-size: 1.28rem;
  font-weight: 650;
  letter-spacing: -.015em;
  line-height: 1.4;
}

.hh-encyclopedia-page .hh-reader-core .hh-encyclopedia-section p {
  margin: .7rem 0;
  font-size: .93rem;
  line-height: 1.88;
}

.hh-encyclopedia-page .hh-encyclopedia-subsection {
  margin-top: 1.25rem;
}

.hh-encyclopedia-page .hh-encyclopedia-subsection h3 {
  margin: 0 0 .55rem;
  padding: .35rem .55rem;
  border: 0;
  border-left: 3px solid var(--hhe-accent);
  background: var(--hhe-panel-2);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 650;
  line-height: 1.5;
}

.hh-encyclopedia-page .hh-encyclopedia-meta {
  margin-top: .5rem;
  font-size: .82rem;
}

.hh-encyclopedia-page .hh-encyclopedia-meta caption {
  margin-bottom: .3rem;
  font-size: .7rem;
}

.hh-encyclopedia-page .hh-encyclopedia-meta :is(th, td) {
  padding: .48rem .55rem;
  border: 1px solid var(--hhe-line);
}

.hh-encyclopedia-page .hh-encyclopedia-meta th {
  width: 9.5rem;
  background: var(--hhe-panel-2);
  color: var(--hhe-text);
}

.hh-encyclopedia-page .hh-encyclopedia-table {
  font-size: .8rem;
}

.hh-encyclopedia-page .hh-encyclopedia-table :is(th, td) {
  padding: .42rem .5rem;
  border-color: var(--hhe-line);
}

.hh-encyclopedia-page .hh-encyclopedia-table :is(thead th, tbody th) {
  background: var(--hhe-panel-2);
}

.hh-encyclopedia-page .hh-article-scene {
  margin: 1rem 0 1.25rem;
  overflow: hidden;
  border: 1px solid var(--hhe-line);
  border-radius: .3rem;
  background: var(--hhe-panel-2);
}

.hh-encyclopedia-page .hh-article-scene a,
.hh-encyclopedia-page .hh-article-scene img {
  display: block;
  width: 100%;
}

.hh-encyclopedia-page .hh-article-scene img {
  max-height: 28rem;
  object-fit: contain;
  background: #111;
}

.hh-encyclopedia-page .hh-article-scene figcaption {
  padding: .48rem .6rem;
  color: var(--hhe-muted);
  font-size: .68rem;
  line-height: 1.5;
}

.hh-encyclopedia-page .hh-reader-toc-rail,
.hh-encyclopedia-page .hh-reader-related-rail {
  position: sticky;
  top: 4.4rem;
  max-height: calc(100dvh - 5.2rem);
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.hh-encyclopedia-page .hh-reader-toc-rail > .hh-toc,
.hh-encyclopedia-page .hh-reader-related-rail > .hh-encyclopedia-related {
  position: static;
  max-height: none;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.hh-encyclopedia-page .hh-reader-toc-rail > .hh-toc {
  padding: .4rem .25rem;
}

.hh-encyclopedia-page .hh-reader-toc-rail .hh-panel-label {
  display: none;
}

.hh-encyclopedia-page .hh-reader-toc-rail .hh-toc h2,
.hh-encyclopedia-page .hh-reader-related-rail .hh-encyclopedia-related h2 {
  margin: 0 0 .45rem;
  padding-bottom: .35rem;
  border-bottom: 1px solid var(--hhe-line);
  font-family: inherit;
  font-size: .84rem;
  font-weight: 700;
}

.hh-encyclopedia-page .hh-reader-toc-rail .hh-toc li {
  border-top: 0;
}

.hh-encyclopedia-page .hh-reader-toc-rail .hh-toc a {
  min-height: 1.75rem;
  padding: .22rem .15rem;
  color: var(--hhe-accent);
  font-size: .68rem;
  line-height: 1.4;
  grid-template-columns: 1.35rem 1fr;
}

.hh-encyclopedia-page .hh-reader-toc-rail .hh-toc a::before {
  color: var(--hhe-muted);
  font-size: .55rem;
}

.hh-encyclopedia-page .hh-reader-related-rail > .hh-encyclopedia-related {
  margin: 0;
  padding: .4rem 0;
}

.hh-encyclopedia-page .hh-reader-related-rail .hh-encyclopedia-related > div {
  gap: 0;
}

.hh-encyclopedia-page .hh-reader-related-rail .hh-encyclopedia-related > div a {
  padding: .48rem .15rem;
  border: 0;
  border-bottom: 1px solid var(--hhe-line);
  border-radius: 0;
  background: transparent;
}

.hh-encyclopedia-page .hh-reader-related-rail .hh-encyclopedia-related small {
  color: var(--hhe-accent-2);
  font-size: .58rem;
}

.hh-encyclopedia-page .hh-reader-related-rail .hh-encyclopedia-related strong {
  color: var(--hhe-text);
  font-size: .71rem;
  font-weight: 600;
  line-height: 1.4;
}

.hh-encyclopedia-page .hh-reader-related-rail .hh-encyclopedia-back {
  margin-top: .55rem;
  padding: .45rem;
  border: 1px solid var(--hhe-line);
  border-radius: .25rem;
  background: var(--hhe-panel-2);
  color: var(--hhe-accent);
  font-size: .65rem;
}

.hh-encyclopedia-page .hh-encyclopedia-footer {
  border-top: 1px solid var(--hhe-line);
  background: var(--hhe-header);
  color: #fff;
}

.hh-encyclopedia-page .hh-encyclopedia-footer a {
  color: #fff;
}

@media (hover: hover) and (pointer: fine) {
  .hh-encyclopedia-page .hh-reader-toc-rail .hh-toc a:hover,
  .hh-encyclopedia-page .hh-encyclopedia-breadcrumb a:hover,
  .hh-encyclopedia-page .hh-reader-related-rail .hh-encyclopedia-related > div a:hover strong {
    color: var(--hhe-accent);
  }

  .hh-encyclopedia-page .hh-page-tools :is(a, button):hover {
    background: var(--hhe-panel-2);
    color: var(--hhe-text);
  }

  .hh-encyclopedia-page .hh-encyclopedia-header > :is(.hh-theme-toggle, .hh-search-open):hover {
    background: rgb(255 255 255 / 16%);
  }
}

@media (max-width: 67.5rem) {
  .hh-encyclopedia-page .hh-reader-layout {
    grid-template-columns: minmax(9.5rem, 10.5rem) minmax(0, 43rem);
  }

  .hh-encyclopedia-page .hh-reader-related-rail > .hh-encyclopedia-related {
    margin-top: 1rem;
    padding: 1rem;
    border: 1px solid var(--hhe-line);
    border-radius: .35rem;
    background: var(--hhe-panel);
  }

  .hh-encyclopedia-page .hh-reader-related-rail {
    position: static;
    max-height: none;
    overflow: visible;
  }
}

@media (max-width: 47.99rem) {
  .hh-encyclopedia-page {
    background: var(--hhe-panel);
    font-size: 15px;
  }

  .hh-encyclopedia-page .hh-encyclopedia-header {
    position: static;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: .45rem;
    padding: .5rem .7rem;
  }

  .hh-encyclopedia-page .hh-encyclopedia-header nav {
    grid-column: 1 / -1;
    grid-row: 2;
    flex-wrap: nowrap;
    gap: .85rem;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .hh-encyclopedia-page .hh-encyclopedia-header nav::-webkit-scrollbar {
    display: none;
  }

  .hh-encyclopedia-page .hh-encyclopedia-header > .hh-theme-toggle,
  .hh-encyclopedia-page .hh-encyclopedia-header > .hh-search-open {
    grid-column: auto;
    grid-row: 1;
    width: auto;
  }

  .hh-encyclopedia-page .hh-encyclopedia-header :is(.hh-theme-toggle__label, .hh-search-open__label) {
    display: none;
  }

  .hh-encyclopedia-page .hh-encyclopedia-breadcrumb {
    flex-wrap: nowrap;
    overflow-x: auto;
    white-space: nowrap;
  }

  .hh-encyclopedia-page .hh-encyclopedia-main {
    width: 100%;
    padding-top: 0;
  }

  .hh-encyclopedia-page .hh-reader-layout {
    display: block;
  }

  .hh-encyclopedia-page .hh-reader-core {
    padding: 0 .9rem 1.5rem;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .hh-encyclopedia-page .hh-reader-core > .hh-encyclopedia-hero {
    padding-top: 1rem;
  }

  .hh-encyclopedia-page .hh-reader-core > .hh-encyclopedia-hero h1 {
    font-size: clamp(1.75rem, 9vw, 2.2rem);
  }

  .hh-encyclopedia-page .hh-reader-mobile-toc {
    margin: .75rem 0 0;
    border: 1px solid var(--hhe-line);
    border-radius: .3rem;
    background: var(--hhe-panel-2);
  }

  .hh-encyclopedia-page .hh-reader-mobile-toc > summary {
    min-height: 2.6rem;
    padding: .45rem .65rem;
    font-size: .8rem;
  }

  .hh-encyclopedia-page .hh-editorial-article:has(> .hh-editorial-visual[data-editorial-visual]) {
    display: block;
  }

  .hh-encyclopedia-page .hh-reader-core .hh-editorial-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .hh-encyclopedia-page .hh-editorial-visual[data-editorial-visual] {
    width: min(100%, 18rem);
    margin: .6rem auto 1rem;
  }

  .hh-encyclopedia-page .hh-editorial-visual--gallery[data-editorial-visual] {
    width: 100%;
  }

  .hh-encyclopedia-page .hh-editorial-visual--gallery .hh-editorial-visual-grid {
    grid-template-columns: 1fr;
  }

  .hh-encyclopedia-page .hh-reader-core .hh-encyclopedia-section,
  .hh-encyclopedia-page .hh-reader-core .hh-encyclopedia-review {
    scroll-margin-top: 1rem;
    padding-top: 1.1rem;
  }

  .hh-encyclopedia-page .hh-encyclopedia-meta :is(th, td) {
    display: table-cell;
    width: auto;
    padding: .4rem .45rem;
  }

  .hh-encyclopedia-page .hh-encyclopedia-meta th {
    width: 7.25rem;
  }

  .hh-encyclopedia-page .hh-article-scene {
    margin-inline: 0;
  }

  .hh-encyclopedia-page .hh-reader-related-rail > .hh-encyclopedia-related {
    margin: 0;
    padding: 1rem .9rem;
    border: 0;
    border-top: 1px solid var(--hhe-line);
    border-radius: 0;
    background: var(--hhe-panel-2);
  }
}

@media (prefers-reduced-motion: reduce) {
  .hh-encyclopedia-page *,
  .hh-encyclopedia-page *::before,
  .hh-encyclopedia-page *::after {
    transition-duration: 0ms !important;
  }
}
