/*
 * Author page themes — docs/design/2026-09-11-author-styles.md §2–§4 and §8.
 *
 * The Worker prints data-style on the <html> of an author's Balise Page and of
 * their Story, card, recap and List pages, and links this file after the page
 * CSS. `magazine` is the page as it has always been and has no rules here.
 * Every other theme overrides the page tokens on :root and adds a few frames.
 *
 * What every theme keeps:
 * - A photograph is never tinted, filtered or redrawn. A theme changes the
 *   ground, the type and the frame around a picture, never its pixels.
 * - Shingō's brackets frame words, never photographs: a page cannot know who is
 *   in a picture, so brackets sit on text blocks only.
 * - Koma is light only; Yoru and Shingō are dark only. They set explicit
 *   colours rather than light-dark(), and hide the Story reader's appearance
 *   select, which has nothing to switch.
 * - Body text at least 7:1 on its ground, secondary text at least 4.5:1.
 * - Reduce Motion is honoured.
 *
 * Display faces are self-hosted (scripts/fetch-page-fonts.mjs). The Worker
 * links /page-fonts/<family>.css only on pages whose theme draws with it.
 */

/* ── Every theme ───────────────────────────────────────────────────────── */

/* styles.css and palette.css paint headings, links and buttons with --balise-*
   and --serif, and the card, recap and List CSS reads the short names. A
   themed page points all of them at its publication tokens. (Reader pages also
   do this on .publication-reader; the recap page has no such class.) */
:root:is([data-style="koma"], [data-style="yoru"], [data-style="shingo"]) {
  --paper: var(--publication-paper);
  --paper-raised: var(--publication-soft);
  --ink: var(--publication-ink);
  --muted: var(--publication-muted);
  --line: var(--publication-line);
  --clay: var(--publication-accent);
  --evergreen: var(--publication-strong);
  --evergreen-soft: var(--publication-strong-soft);
  --gold: var(--publication-gold);
  --balise-paper: var(--publication-paper);
  --balise-paper-raised: var(--publication-soft);
  --balise-ink: var(--publication-ink);
  --balise-muted: var(--publication-muted);
  --balise-line: var(--publication-line);
  --balise-clay: var(--publication-accent);
  --balise-evergreen: var(--publication-strong);
  --balise-evergreen-soft: var(--publication-strong-soft);
  --balise-gold: var(--publication-gold);
  --serif: var(--publication-display);
}

/* Nothing for the reader's appearance choice to switch. */
:root:is([data-style="koma"], [data-style="yoru"], [data-style="shingo"]) .story-controls select {
  display: none;
}

/* Words on a gold fill take the theme's dark ink, whatever the heading ink is. */
:root:is([data-style="koma"], [data-style="yoru"], [data-style="shingo"]) :is(.btn-gold, .btn-gold:hover) {
  color: var(--publication-on-gold);
}

/* On a dark ground the mark is paper over gold (BRAND.md). */
:root:is([data-style="yoru"], [data-style="shingo"]) .publication-brand img {
  content: url(/mark-dark.svg);
}

/* Yoru and Shingō size a picture to itself, so its frame hugs the photograph
   and no matte sits beside a portrait. */
:root:is([data-style="yoru"], [data-style="shingo"]) {
  --story-matte: transparent;
}
:root:is([data-style="yoru"], [data-style="shingo"]) :is(.story-hero, .publication-image, .story-highlight-photo) {
  background: transparent;
}
:root:is([data-style="yoru"], [data-style="shingo"]) :is(.story-hero, .story-figure, .story-highlight-photo) img {
  width: auto;
  max-width: 100%;
  height: auto;
  margin-inline: auto;
}
:root:is([data-style="yoru"], [data-style="shingo"]) .story-highlight-photo img {
  max-height: min(30rem, 54vw);
}
:root:is([data-style="yoru"], [data-style="shingo"]) :is(.deck-card, .deck-card img) {
  border-radius: 0;
}

@media (prefers-reduced-motion: reduce) {
  :root:is([data-style="koma"], [data-style="yoru"], [data-style="shingo"]) :is(*, *::before, *::after) {
    animation: none !important;
    transition: none !important;
  }
}

/* ── Koma 漫画 · manga ink, light only ────────────────────────────────────── */

:root[data-style="koma"] {
  color-scheme: light;
  --publication-frame: 6px;
  --publication-frame-line: #121212;
  --publication-mount: #fff;
  --publication-paper: #f7f7f3;
  --publication-ink: #121212;
  --publication-muted: #454542;
  --publication-line: #121212;
  --publication-soft: #eaeae4;
  --publication-accent: #121212;
  --publication-strong: #121212;
  --publication-strong-soft: #2b2b29;
  --publication-gold: #eea23f;
  --publication-on-gold: #121212;
  --publication-display: "Dela Gothic One", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "PingFang SC", "PingFang TC", "Noto Sans SC", "Noto Sans TC", sans-serif;
  --publication-stage: #121212;
  --publication-backdrop: rgba(18, 18, 18, 0.86);
}

/* Dela Gothic One has a single weight; asking for bold would synthesise one. */
:root[data-style="koma"] :is(h1, h2, h3):not(.story-highlights-head, .is-discovery h2),
:root[data-style="koma"] .publication-avatar {
  font-weight: 400;
  letter-spacing: 0.01em;
  line-height: 1.18;
}

/* Screentone that fades out before it reaches the words. */
:root[data-style="koma"] :is(.story-head, .list-head, .recap-head)::before {
  content: "";
  display: block;
  height: 18px;
  margin-bottom: 1.4rem;
  background: radial-gradient(#121212 30%, transparent 34%) 0 0 / 7px 7px;
  -webkit-mask-image: linear-gradient(90deg, #000, transparent 70%);
  mask-image: linear-gradient(90deg, #000, transparent 70%);
}

/* The author's initial is a panel too: a white square in a sumi border, set
   off the page with a hard shadow, a patch of screentone behind it. The tone
   sits under the panel and never under a word. */
:root[data-style="koma"] .publication-identity {
  position: relative;
}
:root[data-style="koma"] .publication-identity::before {
  content: "";
  position: absolute;
  left: -9px;
  /* The avatar sits at the row's vertical centre; the tone tucks behind its top-left corner. */
  top: calc(50% - 37px);
  width: 58px;
  height: 58px;
  background: radial-gradient(#121212 28%, transparent 32%) 0 0 / 6px 6px;
  -webkit-mask-image: linear-gradient(135deg, #000 40%, transparent 85%);
  mask-image: linear-gradient(135deg, #000 40%, transparent 85%);
}
:root[data-style="koma"] .publication-avatar {
  position: relative;
  border-radius: 0;
  background: #fff;
  color: #121212;
  border: 3px solid #121212;
  box-shadow: 5px 5px 0 #121212;
  margin-right: 5px;
}

/* The one spot colour: a gold stroke under each section heading. */
:root[data-style="koma"] .story-section h2 {
  display: inline;
  box-shadow: inset 0 -0.34em 0 var(--publication-gold);
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
:root[data-style="koma"] .story-section h2 + .story-prose {
  margin-top: 1.1rem;
}

/* Labels are inverse sumi tabs. */
:root[data-style="koma"] :is(.story-meta, .publication-kind, .list-head .card-kicker, .recap-head .card-kicker, .card-details-top .card-kicker) {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  background: #121212;
  color: #f7f7f3;
  letter-spacing: 0.08em;
}

/* Pictures are panels: a sumi border and a white gutter. */
:root[data-style="koma"] :is(.story-hero, .story-figure img, .story-highlight-photo img, .shared-card, .deck-card img) {
  border: 4px solid #121212;
  border-radius: 0;
  background: #fff;
}
:root[data-style="koma"] .publication-image {
  border-width: 4px;
}
:root[data-style="koma"] .deck-card {
  border-radius: 0;
}

/* A caption is the narration box on its panel. */
:root[data-style="koma"] :is(.story-hero, .story-figure, .story-highlight-photo) figcaption {
  position: relative;
  display: inline-block;
  max-width: calc(100% - 2rem);
  margin: -1.5rem 0 0 1rem;
  padding: 0.35rem 0.65rem;
  background: #fff;
  border: 2px solid #121212;
  color: #121212;
  font-weight: 700;
}

:root[data-style="koma"] :is(.story-save-actions button, .story-highlight-actions button, .publication-button, .story-controls button, .story-account-link, .btn, .deck-arrow, .deck-count, .card-reactions li, .story-discovery-dialog-actions button, .story-discovery-dialog-actions a) {
  border-radius: 0 !important;
}
:root[data-style="koma"] :is(.story-save-actions button, .story-highlight-actions button, .publication-button, .story-controls button) {
  border-width: 2px;
}

/* ── Yoru 夜 · city-pop night, dark only ─────────────────────────────────── */

:root[data-style="yoru"] {
  color-scheme: dark;
  --publication-frame: 0px;
  --publication-frame-line: transparent;
  --publication-mount: transparent;
  --publication-paper: #231d52;
  --publication-ink: #fdf6ff;
  --publication-muted: #cbb8e6;
  --publication-line: rgba(253, 246, 255, 0.2);
  --publication-soft: #2e2766;
  --publication-accent: #6ee7e3;
  --publication-strong: #fdf6ff;
  --publication-strong-soft: #e2d6f5;
  --publication-gold: #eea23f;
  --publication-on-gold: #231d52;
  --publication-display: system-ui, -apple-system, BlinkMacSystemFont, "Hiragino Sans", "PingFang SC", "PingFang TC", sans-serif;
  --publication-stage: #14102f;
  --publication-backdrop: rgba(12, 9, 32, 0.86);
  --yoru-title: "Train One", "Hiragino Sans", "PingFang SC", "PingFang TC", "Noto Sans SC", "Noto Sans TC", sans-serif;
  --yoru-neon: #ff5ea8;
}

/* Train One is for the page's title only: a neon sign, one per page. The glow
   belongs to the type and never reaches a photograph. */
:root[data-style="yoru"] :is(.publication-home-heading h1, .publication-identity h1, .story-head h1, .list-head h1, .recap-head h1, .card-details-head h2) {
  font-family: var(--yoru-title);
  font-weight: 400;
  letter-spacing: 0.02em;
  line-height: 1.2;
  color: #fff2fa;
  text-shadow: 0 0 0.05em var(--yoru-neon), 0 0 0.3em rgba(255, 94, 168, 0.75), 0 0 0.8em rgba(255, 94, 168, 0.4);
}
:root[data-style="yoru"] :is(.publication-site h2, .story-page h2, .story-page h3, .card-page h3, .list-page h2):not(.story-highlights-head, .is-discovery h2) {
  font-weight: 700;
  letter-spacing: 0;
}

/* Sunset stripes decorate the ground under a heading block. */
:root[data-style="yoru"] :is(.story-head, .publication-profile-head, .list-head, .recap-head)::after {
  content: "";
  display: block;
  grid-column: 1 / -1;
  width: min(16rem, 60%);
  height: 20px;
  margin-top: 1.6rem;
  background: linear-gradient(#ffb3d2 0 18%, transparent 18% 32%, #ff5ea8 32% 52%, transparent 52% 64%, #c44d9c 64% 80%, transparent 80% 88%, #7a4fb0 88%);
}

:root[data-style="yoru"] :is(.story-meta, .publication-kind) {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

/* Photographs sit in white print borders. */
:root[data-style="yoru"] :is(.story-hero img, .story-figure img, .story-highlight-photo img, .publication-image img, .shared-card, .deck-card img) {
  border: 10px solid #fdf6ff;
  border-radius: 0;
  background: #fdf6ff;
  box-shadow: 0 1.2rem 2.6rem rgba(8, 4, 28, 0.45);
}
:root[data-style="yoru"] :is(.story-hero, .story-figure, .story-highlight-photo) figcaption {
  background: transparent;
  color: var(--publication-accent);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: 0.04em;
}

:root[data-style="yoru"] :is(.story-save-actions button, .story-highlight-actions button, .publication-button) {
  background: transparent !important;
  color: #eaffff !important;
  border-color: #6ee7e3 !important;
  box-shadow: 0 0 0.9rem rgba(110, 231, 227, 0.45), inset 0 0 0.6rem rgba(110, 231, 227, 0.3);
}
:root[data-style="yoru"] :is(.story-save-actions button, .story-highlight-actions button)[aria-pressed="true"] {
  background: rgba(110, 231, 227, 0.18) !important;
}

/* ── Shingō 信号 · signal readouts, dark only ────────────────────────────── */

:root[data-style="shingo"] {
  color-scheme: dark;
  --publication-frame: 0px;
  --publication-frame-line: rgba(185, 243, 207, 0.28);
  --publication-mount: transparent;
  --publication-paper: #070a09;
  --publication-ink: #f3efe4;
  --publication-muted: #b9f3cf;
  --publication-line: rgba(185, 243, 207, 0.18);
  --publication-soft: #0c2921;
  --publication-accent: #eea23f;
  --publication-strong: #f3efe4;
  --publication-strong-soft: #d6d0c1;
  --publication-gold: #eea23f;
  --publication-on-gold: #070a09;
  --publication-display: "Hiragino Mincho ProN", "Hiragino Mincho Pro", "Yu Mincho", YuMincho, "Noto Serif JP", "Noto Serif CJK JP", "Songti SC", "Songti TC", "Noto Serif SC", "Noto Serif TC", serif;
  --publication-stage: #0c2921;
  --publication-backdrop: rgba(0, 0, 0, 0.86);
  --shingo-mono: ui-monospace, "SF Mono", Menlo, monospace;
}

/* A hairline grid at 6 % phosphor. */
:root[data-style="shingo"] body {
  background-image:
    linear-gradient(rgba(185, 243, 207, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(185, 243, 207, 0.06) 1px, transparent 1px);
  background-size: 48px 48px;
}
:root[data-style="shingo"] .story-page {
  background: transparent;
}

/* Mincho W6, with no negative tracking (ja and zh display type). */
:root[data-style="shingo"] :is(h1, h2, h3):not(.story-highlights-head, .is-discovery h2) {
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.12;
}

/* Readout labels with a trailing amber rule. */
:root[data-style="shingo"] :is(.story-meta, .publication-kind, .list-head .card-kicker, .recap-head .card-kicker) {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  color: var(--publication-accent);
  font-family: var(--shingo-mono);
  letter-spacing: 0.14em;
}
:root[data-style="shingo"] :is(.story-meta, .publication-kind, .list-head .card-kicker, .recap-head .card-kicker)::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(238, 162, 63, 0.5);
}

/* Corner brackets frame words, never a photograph. A profile header whose
   avatar is a photograph gets none, because the avatar sits inside it. */
:root[data-style="shingo"] :is(.story-head, .list-head, .recap-head, .card-details-head, .publication-home-heading, .publication-profile-head:not(:has(.publication-avatar img))) {
  padding: 1.4rem 1.4rem 1.2rem;
  background:
    linear-gradient(#eea23f 0 0) 0 0 / 22px 2px no-repeat,
    linear-gradient(#eea23f 0 0) 0 0 / 2px 22px no-repeat,
    linear-gradient(#eea23f 0 0) 100% 0 / 22px 2px no-repeat,
    linear-gradient(#eea23f 0 0) 100% 0 / 2px 22px no-repeat,
    linear-gradient(#eea23f 0 0) 0 100% / 22px 2px no-repeat,
    linear-gradient(#eea23f 0 0) 0 100% / 2px 22px no-repeat,
    linear-gradient(#eea23f 0 0) 100% 100% / 22px 2px no-repeat,
    linear-gradient(#eea23f 0 0) 100% 100% / 2px 22px no-repeat;
}

/* A photograph gets an amber rule along its top edge, outside the picture. */
:root[data-style="shingo"] :is(.story-hero img, .story-figure img, .story-highlight-photo img, .publication-image img, .shared-card, .deck-card img) {
  border-top: 2px solid #eea23f;
  border-radius: 0;
}
:root[data-style="shingo"] :is(.story-hero, .story-figure, .story-highlight-photo) figcaption {
  background: transparent;
  color: var(--publication-muted);
  font-family: var(--shingo-mono);
  letter-spacing: 0.04em;
}

:root[data-style="shingo"] :is(.story-save-actions button, .story-highlight-actions button, .publication-button) {
  border-radius: 0 !important;
  background: #eea23f !important;
  border-color: #eea23f !important;
  color: #070a09 !important;
}
:root[data-style="shingo"] :is(.story-save-actions button + button, .story-highlight-actions button + button, .publication-button.is-quiet, .publication-profile-actions [data-publication-follow][aria-pressed="true"]) {
  background: transparent !important;
  color: #eea23f !important;
}
:root[data-style="shingo"] :is(.story-save-actions button, .story-highlight-actions button)[aria-pressed="true"] {
  background: rgba(238, 162, 63, 0.2) !important;
  color: #f3efe4 !important;
}
