/* Tokyo Rock Girl — Novels
   サイト全体の見た目（チャンネルの見た目。シリーズ固有の値は series.yaml の site.theme から上書きする）。
   枠・リンク：trg-mv-glitch の見た目（黒地に白、黒いハロー、ブラウン管風のグリッチ）。
   本文：白地に黒文字で、画面の幅いっぱいを使う。 */

:root {
  --frame: #000;
  --frame-ink: #fff;
  --frame-dim: #9a9a9a;
  --paper: #fff;
  --ink: #111;
  --ink-dim: #555;
  --glitch-r: #ff2b4f;
  --glitch-c: #00e1ff;
  --accent: #fff;            /* series.yaml site.theme.accent で上書き */
  --halo: 0 0 6px rgba(0, 0, 0, .85), 0 0 2px rgba(0, 0, 0, .85);
  --font-ja: "Noto Serif JP", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --font-en: "Alumni Sans", "Arial Narrow", sans-serif;
  --edge: clamp(6px, 1.2vw, 14px);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--frame);
  color: var(--frame-ink);
  font-family: var(--font-ja);
  font-weight: 500;
  line-height: 1.8;
  overflow-x: hidden;
}

/* ブラウン管の走査線（枠の部分だけに見える。本文の白い紙は上に重ねる） */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: repeating-linear-gradient(to bottom,
    rgba(255, 255, 255, .045) 0 1px, transparent 1px 3px);
}

/* ゆっくり画面を下る明るい横帯（トラッキングバー） */
body::after {
  content: "";
  position: fixed;
  left: 0; right: 0;
  top: -20vh;
  height: 14vh;
  pointer-events: none;
  z-index: 0;
  background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, .05), transparent);
  animation: tracking 9s linear infinite;
}

@keyframes tracking { to { transform: translateY(140vh); } }

body > * { position: relative; z-index: 1; }

a { color: inherit; }

/* ---------------------------------------------------------------- 枠：ヘッダーとフッター */

.site-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px calc(var(--edge) + 8px);
  border-bottom: 1px solid rgba(255, 255, 255, .18);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-family: var(--font-en);
  font-size: 1.45rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  text-shadow: var(--halo);
  line-height: 1;
}

.brand img { width: 36px; height: 36px; border-radius: 50%; display: block; }
.brand small { font-size: .78em; color: var(--frame-dim); letter-spacing: .2em; }

.site-foot {
  padding: 22px calc(var(--edge) + 8px) 28px;
  font-family: var(--font-en);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--frame-dim);
  font-size: 1rem;
  text-align: center;
}

/* ---------------------------------------------------------------- グリッチ（リンク・見出し） */

.glitch, .nav a, .toc a, .card, .brand {
  transition: color .12s;
}

.nav a:hover, .nav a:focus-visible,
.toc a:hover, .toc a:focus-visible,
.brand:hover, .brand:focus-visible,
.card:hover .card-title, .card:focus-visible .card-title {
  text-shadow: -2px 0 var(--glitch-r), 2px 0 var(--glitch-c), var(--halo);
  animation: jitter .32s steps(2, end) infinite;
}

@keyframes jitter {
  0%   { transform: translate(0, 0); }
  25%  { transform: translate(-1px, 0); }
  50%  { transform: translate(1px, -1px); }
  75%  { transform: translate(0, 1px); }
  100% { transform: translate(0, 0); }
}

/* 見出しの文字が一瞬だけ横にずれて、色が分かれる */
.glitch { position: relative; display: inline-block; text-shadow: var(--halo); }
.glitch::before, .glitch::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
}
.glitch::before { color: var(--glitch-r); animation: slice 7s infinite steps(1); }
.glitch::after  { color: var(--glitch-c); animation: slice 7s infinite steps(1) reverse; animation-delay: .07s; }

@keyframes slice {
  0%, 93%, 100% { opacity: 0; transform: none; clip-path: inset(0 0 0 0); }
  94% { opacity: .85; transform: translate(-4px, 0); clip-path: inset(20% 0 55% 0); }
  95% { opacity: .85; transform: translate(5px, 0);  clip-path: inset(60% 0 12% 0); }
  96% { opacity: .85; transform: translate(-2px, 0); clip-path: inset(5% 0 80% 0); }
  97% { opacity: 0; }
}

:focus-visible { outline: 2px solid var(--glitch-c); outline-offset: 3px; }

/* ---------------------------------------------------------------- トップページ */

.hero {
  padding: clamp(40px, 9vw, 110px) calc(var(--edge) + 16px) clamp(28px, 5vw, 56px);
  text-align: center;
}

.hero img {
  width: clamp(120px, 22vw, 200px);
  height: auto;
  border-radius: 50%;
  display: block;
  margin: 0 auto 22px;
}

.hero h1 {
  margin: 0;
  font-family: var(--font-en);
  font-weight: 600;
  font-size: clamp(2.6rem, 8vw, 5.2rem);
  letter-spacing: .14em;
  line-height: 1;
  text-transform: uppercase;
}

.hero p {
  margin: 14px 0 0;
  font-family: var(--font-en);
  font-size: clamp(1.1rem, 2.4vw, 1.5rem);
  letter-spacing: .4em;
  text-transform: uppercase;
  color: var(--frame-dim);
}

.cards {
  /* 行の中央にそろえる（シリーズが一つでも、増えて折り返しても中央に並ぶ） */
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 18px;
  padding: 0 calc(var(--edge) + 16px) 40px;
  max-width: 1400px;
  margin: 0 auto;
}

.card {
  display: block;
  flex: 0 1 560px;
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, .55);
  background: rgba(0, 0, 0, .6);
  overflow: hidden;
}

.card-body { padding: 20px 22px 20px; }

.card-img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-bottom: 1px solid rgba(255, 255, 255, .25);
  filter: saturate(.9);
  transition: filter .2s;
}
.card:hover .card-img, .card:focus-visible .card-img { filter: saturate(1.05) brightness(1.08); }
.card:hover, .card:focus-visible { border-color: #fff; }

.card-title {
  display: inline-block;
  font-size: clamp(1.3rem, 2.6vw, 1.6rem);
  line-height: 1.5;
  text-shadow: var(--halo);
}

.card-en {
  margin-top: 4px;
  font-family: var(--font-en);
  font-size: 1.2rem;
  letter-spacing: .12em;
  color: var(--frame-dim);
}

.card-meta {
  margin-top: 16px;
  font-family: var(--font-en);
  font-size: 1.05rem;
  letter-spacing: .18em;
  text-transform: uppercase;
}

/* ---------------------------------------------------------------- 目次 */

.toc-head {
  padding: clamp(30px, 6vw, 70px) calc(var(--edge) + 16px) 10px;
  max-width: 1100px;
  margin: 0 auto;
}

.toc-head h1 {
  margin: 0;
  font-size: clamp(1.7rem, 4.6vw, 2.8rem);
  line-height: 1.4;
  font-weight: 600;
}

.toc-head .en {
  margin: 6px 0 0;
  font-family: var(--font-en);
  font-size: clamp(1.2rem, 2.4vw, 1.6rem);
  letter-spacing: .12em;
  color: var(--frame-dim);
}

.toc {
  max-width: 1100px;
  margin: 0 auto;
  padding: 10px calc(var(--edge) + 16px) 30px;
}

.toc section {
  border-top: 1px solid rgba(255, 255, 255, .22);
  padding: 18px 0 14px;
}

.toc h2 {
  margin: 0 0 8px;
  font-size: 1.2rem;
  font-weight: 600;
  text-shadow: var(--halo);
}

.toc h2 a { text-decoration: none; display: inline-block; }

.toc ol { list-style: none; margin: 0; padding: 0; }

.toc li a {
  display: flex;
  gap: 1em;
  padding: 6px 0;
  text-decoration: none;
  color: #e6e6e6;
}

.toc li .no {
  font-family: var(--font-en);
  font-size: 1.15rem;
  letter-spacing: .08em;
  color: var(--frame-dim);
  min-width: 3.2em;
}

.toc .wip {
  border-top: 1px solid rgba(255, 255, 255, .22);
  margin: 0;
  padding: 22px 0 6px;
  color: var(--frame-dim);
  letter-spacing: .08em;
}

.toc li a:hover .no, .toc li a:focus-visible .no { color: #fff; }

/* ---------------------------------------------------------------- ナビゲーション（前後・目次・トップ） */

.nav {
  display: grid;
  grid-template-columns: 1fr auto auto 1fr;
  gap: 6px 18px;
  align-items: center;
  padding: 10px calc(var(--edge) + 8px);
  font-size: .95rem;
}

.nav a, .nav span {
  text-decoration: none;
  text-shadow: var(--halo);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav .prev { justify-self: start; }
.nav .next { justify-self: end; text-align: right; }
.nav .mid {
  font-family: var(--font-en);
  font-size: 1.15rem;
  letter-spacing: .16em;
  text-transform: uppercase;
}
.nav .off { color: #444; }
.nav .lbl {
  font-family: var(--font-en);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--frame-dim);
  margin: 0 .5em;
}

@media (max-width: 640px) {
  .nav { grid-template-columns: 1fr 1fr; }
  .nav .prev { grid-column: 1; grid-row: 1; }
  .nav .next { grid-column: 2; grid-row: 1; }
  .nav .mid { justify-self: center; }
  .nav .lbl { display: none; }
}

/* ---------------------------------------------------------------- 本文（白い紙） */

.paper {
  background: var(--paper);
  color: var(--ink);
  margin: 0 var(--edge);
  padding: clamp(28px, 6vw, 84px) clamp(18px, 6vw, 112px) clamp(40px, 7vw, 96px);
  font-weight: 400;
  font-size: clamp(16px, calc(.95rem + .2vw), 19px);
  line-height: 2;
  letter-spacing: .02em;
  font-feature-settings: "palt" 0;
  word-break: normal;
  line-break: strict;
  overflow-wrap: anywhere;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .35);
}

.paper .kicker {
  margin: 0 0 .6em;
  font-size: .82em;
  color: var(--ink-dim);
  letter-spacing: .08em;
}

.paper h1, .paper h2 {
  font-weight: 600;
  line-height: 1.5;
  margin: 0 0 1.6em;
}
.paper h1 { font-size: 1.7em; }
.paper h2 { font-size: 1.35em; }
.paper h1 + blockquote { margin-top: -0.4em; }
.paper * + h2 { margin-top: 1.4em; }

.paper p { margin: 0 0 .9em; text-indent: 1em; }
.paper p.talk { text-indent: 0; }

.paper blockquote {
  margin: 0 0 1.8em 2em;
  color: #333;
  font-size: .9em;
  line-height: 1.9;
}
.paper blockquote p { text-indent: 0; margin: 0 0 .3em; }
.paper blockquote p.attr { text-align: right; color: var(--ink-dim); }

/* 本文中の文書の文面（手紙・記録・画面に残った文。原稿の > ） */
.paper blockquote.doc {
  margin: 0 0 .9em 1em;
  padding: .1em 0 .1em 1em;
  border-left: 2px solid #c8c8c8;
  color: var(--ink);
  font-size: 1em;
  line-height: inherit;
}
.paper blockquote.doc p { margin: 0 0 .5em; }
.paper blockquote.doc p:last-child { margin-bottom: 0; }

.paper hr {
  border: 0;
  height: auto;
  margin: 2.2em 0;
  text-align: center;
  color: #888;
  overflow: visible;
}
.paper hr::after { content: "＊　＊　＊"; letter-spacing: .3em; }

/* ルビ：<ruby> 要素は使わず、親文字（.rb）の上にルビの文字（.rt）を浮かせて置く（build.py）。
   <ruby> のままだと Safari はルビのある行だけ行間を広げ、CSS で位置を変えると崩れる（2026-12-02）。
   浮かせたルビは行の高さに関わらないので、どの行も同じ行間になる。行間（2）の上半分にルビが収まる。 */
.paper .rb {
  display: inline-block;
  position: relative;
  line-height: 1;
  text-indent: 0;
}
.paper .rt {
  position: absolute;
  left: 50%;
  bottom: 100%;
  transform: translateX(-50%);
  font-size: .5em;
  line-height: 1.1;
  letter-spacing: 0;
  white-space: nowrap;
  font-weight: 400;
  -webkit-user-select: none;
  user-select: none;
}


.paper .end {
  margin-top: 3em;
  text-align: center;
  color: #999;
  font-family: var(--font-en);
  letter-spacing: .3em;
}

@media (prefers-reduced-motion: reduce) {
  body::after, .glitch::before, .glitch::after { animation: none; display: none; }
  .nav a:hover, .toc a:hover, .brand:hover, .card:hover .card-title { animation: none; }
}
