/* One continuous sheet behind the Japanese reading pages. */
body.jp {
  --paper: #fbf3d0;
  --panel-paper: var(--paper);
  --bubble-paper: #fcf5dc;
  --notebook-spacing: 1.75rem;
  --notebook-rule: rgb(131 101 133 / .19);
  background-color: var(--paper);
  background-image:
    var(--paper-grain, none),
    repeating-linear-gradient(
      to bottom,
      transparent 0 calc(var(--notebook-spacing) - 1px),
      var(--notebook-rule) calc(var(--notebook-spacing) - 1px) var(--notebook-spacing)
    );
}

body.jp :is(.masthead, .cast, .cast-card, .cast-portrait, .about, .news-summary, .numbers-note,
  .number-slip, .news-background, .place-note, .read-next-art) {
  background: transparent;
}

body.jp :is(.masthead, .front-intro, .section-label, .category-block > h3, .tile, .cast, .cast-card,
  .about, .site-footer, .news-summary, .news-background, .news-background-detail,
  .numbers-note, .number-slip, .front-backnumbers > h2, .home-comic-series > h2,
  .home-comic-series .home-comic + .home-comic, .related-rail h2, .related-bottom h2,
  .related-list li + li) {
  border: 0;
}

body.jp :is(.news-summary, .numbers-note, .news-background:not(.news-dialogue), .place-note) {
  padding-inline: 0;
}

body.jp .place-note .place-drawing {
  filter: url("#notebook-place-ink");
}

body.jp .home-comic-series .home-comic + .home-comic {
  padding-block-start: clamp(1.8rem, 3vw, 2.6rem);
}

/* Use the same line spacing for the rules and the text written above them. */
body.jp main :is(
  .front-intro p, .news-summary > p, .news-summary > h2, .news-dialogue-name, .news-dialogue-line,
  .news-background-sources, .place-copy .place-description, .cast-bio p, .about p,
  .comic-credits:not(:has(.news-summary)), .tile-text h3, .read-next-title,
  .issue-archive .archive-comics > li, .issue-archive .archive-dates > li
) {
  line-height: var(--notebook-spacing);
}

body.jp main :is(.front-intro, .feature-head, .story-head) :is(h1, h2, h3) {
  line-height: calc(2 * var(--notebook-spacing));
}

@media (max-width: 600px) {
  body.jp main :is(.front-intro, .feature-head, .story-head) :is(h1, h2, h3) {
    line-height: var(--notebook-spacing);
  }
}

body.jp main .news-summary .news-summary-title {
  margin-block-end: 0;
}

body.jp main .news-background.news-dialogue {
  row-gap: var(--notebook-spacing);
}

body.jp main .news-dialogue .news-background-sources {
  margin-block-start: 0;
}

.jp [data-notebook-aligned] {
  position: relative;
  inset-block-start: var(--notebook-shift, 0px);
}

.jp .notebook-baseline {
  display: inline-block;
  width: 0;
  height: 0;
  line-height: var(--notebook-spacing);
  vertical-align: baseline;
  pointer-events: none;
}

/* The paper in the scans becomes transparent and the pencil remains visible. */
.jp .notebook-filter { position: absolute; }

body.jp .cast-portrait > .cast-pencil-portrait {
  position: absolute;
  inset: 4%;
  display: block;
  width: 92%;
  height: 92%;
  object-fit: contain;
}

body.jp :is(.cast-portrait > .cast-pencil-portrait, .dango-front-art) {
  filter: url("#notebook-graphite") brightness(.64);
}

body.jp :is(.comic-panels-silent > .panel, .cast-portrait) {
  isolation: auto;
}

body.jp .comic-panels.comic-panels-silent,
body.jp .comic-panels.comic-panels-silent > .panel {
  background: transparent;
  border: 0;
}

body.jp .comic-panels.comic-panels-silent .panel img,
body.jp .story:has(.return[href^="/archive/"]) .comic-panels-silent .panel img,
body.jp .dango-strip > img {
  mix-blend-mode: normal;
  filter: url("#notebook-graphite");
}

/* Some older scans contain pencil borders within the image itself. */
body.jp .comic-panels-silent .trivia-panel > img {
  clip-path: inset(1%);
}

body.jp .dango-strip > img[src="/assets/japan/dango-tsugaru-toppu-rough.webp"] {
  clip-path: inset(2.6% 1.7%);
  mask-image: linear-gradient(to bottom, #000 44.55%, transparent 44.55% 47.3%, #000 47.3%);
}

body.jp .dango-front-art {
  mix-blend-mode: normal;
}

@media (prefers-contrast: more) {
  body.jp { background-image: none; }
}
