@font-face {
  font-family: 'NF Alegreya SC';
  src: url('/fonts/alegreya-sc/AlegreyaSC-Regular.ttf') format('truetype');
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: 'NF Neucha';
  src: url('/fonts/neucha/Neucha.ttf') format('truetype');
  font-weight: 400;
  font-display: swap;
}

.sourcebook--nf {
  --rh-sourcebook-accent: #483686;
  --rh-sourcebook-accent-muted: #b8adcf;
  --rh-sourcebook-heading-color: #4a0e0b;
  --rh-sourcebook-heading-underline-image: none;
  --rh-sourcebook-heading-underline-color: transparent;
  --rh-sourcebook-surface-bg: #faf9f5;
  --rh-sourcebook-text: #211e1d;
  --rh-sourcebook-text-muted: #484849;
  --rh-sourcebook-reader-background-image: url('/styles/sourcebooks/assets/nf/page-background.webp');
  --rh-sourcebook-page-background-image: var(--rh-sourcebook-reader-background-image);
  --rh-sourcebook-canvas-background-position: left top;
  --rh-sourcebook-canvas-background-size: 500px 300px;
  --rh-sourcebook-table-odd-bg: #55a33c33;
  --rh-sourcebook-table-even-bg: #55a33c1a;
  --rh-sourcebook-table-hover-bg: #55a33c40;
  --rh-sourcebook-table-header-bg: transparent;
  --rh-sourcebook-table-border: transparent;
  --rh-sourcebook-notable-bg: #dda33c1a;
  --rh-sourcebook-narrative-bg: #8763ff1a;
  --rh-sourcebook-narrative-border: #8763ff;
  --rh-sourcebook-callout-border: #cc6300;
  --rh-sourcebook-branded-callout-border: #281328;
  --rh-sourcebook-nav-header-bg: #e6e0ed;
  --rh-sourcebook-nav-active-bg: #eae5f2;
  --rh-sourcebook-nav-border: #c6bfce;
  --rh-sourcebook-nav-depth-0-bg: var(--rh-sourcebook-surface-bg);
  --rh-sourcebook-nav-depth-1-bg: #f5f2f6;
  --rh-sourcebook-nav-depth-2-bg: #efecf2;
  --rh-sourcebook-nav-depth-3-bg: #ebe7ef;
  --rh-sourcebook-toc-header-bg: var(--rh-sourcebook-accent);
  --rh-sourcebook-toc-column-width: 30ch;
}

.sourcebook-reader-page.sourcebook--nf {
  position: relative;
  isolation: isolate;
}

/* Each corner shows its own half of the 1920 × 919 artwork. */
.sourcebook-reader-page.sourcebook--nf::before,
.sourcebook-reader-page.sourcebook--nf::after {
  content: '';
  position: absolute;
  z-index: -1;
  top: 0;
  width: min(50%, 960px);
  aspect-ratio: 960 / 919;
  max-height: 100%;
  background: left top / 200% auto no-repeat url('/styles/sourcebooks/assets/nf/page-edges.webp');
  pointer-events: none;
}

.sourcebook-reader-page.sourcebook--nf::before {
  left: 0;
}

.sourcebook-reader-page.sourcebook--nf::after {
  right: 0;
  background-position: right top;
}

.sourcebook-reader-page.sourcebook--nf .rh-breadcrumbs {
  background-color: color-mix(in srgb, var(--rh-sourcebook-surface-bg) 90%, transparent);
  border-radius: 0.375rem;
  padding-inline: 0.375rem;
}

.sourcebook--nf .sourcebook-reader-main {
  --rh-sourcebook-heading-font: 'NF Alegreya SC', Georgia, serif;
  container-type: inline-size;
}

.sourcebook--nf .sourcebook-content-block-title,
.sourcebook--nf .sourcebook-content-html :is(h1, h2, h3, h4):not(:where(.statblock *, .dnd5e2 *, aside *, .notable *, .quest *, .narrative *, .advice *)) {
  font-weight: 400;
  font-synthesis: none;
  line-height: 1.15;
  text-wrap: balance;
}

.sourcebook--nf .nf-chapter-opening {
  text-align: center;
  margin: 0.35rem 0 0.7rem;
}

.sourcebook--nf .sourcebook-content-html .nf-chapter-opening > h1 {
  font: 400 clamp(1.65rem, 6cqi, 3rem)/1.08 var(--rh-sourcebook-heading-font);
  letter-spacing: 0.045em;
  margin: 0.2em 0;
  padding: 0;
  border: 0;
}

.sourcebook--nf .nf-chapter-opening::after {
  content: '';
  display: block;
  width: min(100%, 46rem);
  aspect-ratio: 2162 / 96;
  margin: 0 auto;
  background: center / contain no-repeat url('/styles/sourcebooks/assets/nf/filigree-rule.png');
}

.sourcebook--nf .nf-chapter-opening .nf-chapter-label {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5em;
  margin: 0;
  font: 400 1.2rem/1.2 var(--rh-sourcebook-heading-font);
  color: var(--rh-sourcebook-text-muted);
  text-transform: uppercase;
}

.sourcebook--nf .nf-chapter-label::before,
.sourcebook--nf .nf-chapter-label::after {
  content: '';
  width: clamp(1rem, 7cqi, 5.5rem);
  aspect-ratio: 693 / 205;
  background: center / contain no-repeat url('/styles/sourcebooks/assets/nf/filigree-left.png');
}

.sourcebook--nf .nf-chapter-label::after {
  background-image: url('/styles/sourcebooks/assets/nf/filigree-right.png');
}

.sourcebook--nf .sourcebook-reader-content .nf-section-rule {
  clear: both;
  width: min(100%, 850px);
  height: auto;
  aspect-ratio: 216 / 10.2;
  border: 0;
  margin: 1rem auto;
  background: center / contain no-repeat url('/styles/sourcebooks/assets/nf/section-divider.svg');
  opacity: 0.07;
}

.sourcebook--nf .nf-item-entry > h2 {
  font-size: 1.45rem;
  border: 0;
  margin-bottom: 0.3em;
}

.sourcebook--nf .nf-credits { display: flow-root; line-height: 1.4; }
.sourcebook--nf .nf-credits + .nf-credits { margin-top: 1.2rem; }
.sourcebook--nf .nf-cover { width: min(100%, 20rem); margin: 1em auto; }

.sourcebook--nf .narrative::before,
.sourcebook--nf .narrative::after,
.sourcebook--nf .narrative > :last-child::before,
.sourcebook--nf .narrative > :last-child::after {
  background-color: #244859;
}

.sourcebook--nf figure.content-embed--image figcaption {
  color: var(--rh-sourcebook-text);
  font: 400 0.8125rem/1.35 'NF Neucha', cursive;
  text-align: center;
  text-transform: none;
  letter-spacing: normal;
}

/* The published images retain the filenames used for the module's art credits. */
.sourcebook--nf figure.content-embed--image:has(> img[src*="/netherils-fall/"]) {
  position: relative;
  padding-top: 0.8rem;
  anchor-scope: --nf-illustration;

  &:has(> img:is([src*="/nf-cover"])) { --illustrator: "Оливье Бернар"; }
  &:has(> img:is([src*="/00-001."])) { --illustrator: "Альваро Кальво Эскудеро"; }
  &:has(> img:is([src*="/01-001."], [src*="/01-002."], [src*="/01-003."], [src*="/03-002."])) { --illustrator: "Лука Банконе"; }
  &:has(> img:is([src*="/02-001."])) { --illustrator: "Алехандро Пачеко"; }
  &:has(> img:is([src*="/02-002."], [src*="/06-001."])) { --illustrator: "Зузанна Вузик"; }
  &:has(> img:is([src*="/03-001."])) { --illustrator: "Джулиан Кок"; }
  &:has(> img:is([src*="/04-001."], [src*="/04-002."])) { --illustrator: "Сэмюэл Перин"; }
  &:has(> img:is([src*="/06-002."], [src*="/06-003."], [src*="/06-004."], [src*="/06-005."])) { --illustrator: "Джон Тедрик"; }
  &:has(> img:is([src*="/map-"])) { --illustrator: "Майк Шлей"; }
  &:has(> img:is([src*="/map-00.01-"])) { --illustrator: "Адам Кук"; }

  /* The numbered book illustrations have a notch in the upper-right corner. */
  &:has(img[src*="/netherils-fall/arts/0"]) {
    --credit-inset: calc(anchor-size(width) * 0.056 + 1px);
  }

  &:has(img[src$="/03-002.birds-mountain.webp"]) {
    --credit-inset: calc(anchor-size(width) * 0.103 + 1px);
  }

  &:has(img:is([src$="/06-002.caldron-magen.webp"], [src$="/06-003.terran-magen.webp"], [src$="/06-004.virvos-magen.webp"])) {
    --credit-inset: calc(anchor-size(width) * 0.067 + 1px);
  }

  > img { anchor-name: --nf-illustration; }

  &::after {
    content: var(--illustrator);
    position: absolute;
    top: 0;
    right: 0;
    color: #505159;
    font: 500 clamp(7px, 1.1cqi, 9px)/1.15 system-ui, sans-serif;
    text-align: right;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    pointer-events: none;
  }

  @supports (position-anchor: --nf-illustration) {
    &::after {
      position-anchor: --nf-illustration;
      top: auto;
      bottom: anchor(top);
      right: calc(anchor(right) + var(--credit-inset, 0px));
    }
  }
}

@container (max-width: 34rem) {
  .sourcebook--nf .sourcebook-reader-content figure.right.three {
    float: none;
    width: 100%;
    margin: 0.5rem auto 1rem;
  }

  .sourcebook--nf .sourcebook-reader-content figure.right.three > img {
    width: auto;
    max-height: 16rem;
    margin-inline: auto;
  }
}
