/* github新聞
   組み：docs/decisions/0010-newspaper-design.md
   書体・順位の段階・タグ・ダークの色：0011
   ライトの紙の色と質感：0012
   題字のロゴ・日付、装飾の洗練：0013
   ダークの色、差し色、CSS の版の印：0014
   紙面の左右の波線、号数、本日の分野、トップ記事の1文字目：0015
   色はライトが既定。ダークは OS の設定か、右上のボタンで。 */
:root {
  color-scheme: light;
  --paper: #e6e9ec;
  --ink: #1a1c1f;
  --muted: #5b6068;
  --rule: #c3c8ce;
  --rule-strong: #1a1c1f;
  --edge: #9ba2aa;
  --accent: #b3261e;
  --up: #b3261e;
  --down: #1f5fbf;
  --link: #1a1c1f;
  --chip: #d6dbe0;
  --chip-strong: #c2c8cf;
  --warn-bg: #f3dfb0;
  --warn-fg: #6b4400;
  --font: "BIZ UDPGothic", Meiryo, "Hiragino Sans", "Hiragino Kaku Gothic ProN",
    "Noto Sans JP", "Yu Gothic UI", sans-serif;
  /* 新聞紙のざらつき：色なしのごく薄いノイズ */
  --texture-opacity: 0.6;  /* 紙の質感（paper_texture.webp）の濃さ。0 で消える */
}
/* ダーク：少し青みのある暗いグレー（茶色を含まない）。差し色はオレンジを含まない赤 */
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #15181c;
  --ink: #e4e8ee;
  --muted: #98a0ab;
  --rule: #2b3139;
  --rule-strong: #cfd5dd;
  --edge: #3e4651;
  --accent: #f0647a;
  --up: #f0647a;
  --down: #7aa7ff;
  --link: #e4e8ee;
  --chip: #232830;
  --chip-strong: #323944;
  --warn-bg: #3a3522;
  --warn-fg: #f0cf7a;
  --texture-opacity: 0;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #15181c;
    --ink: #e4e8ee;
    --muted: #98a0ab;
    --rule: #2b3139;
    --rule-strong: #cfd5dd;
    --edge: #3e4651;
    --accent: #f0647a;
    --up: #f0647a;
    --down: #7aa7ff;
  --up: #f0647a;
  --down: #7aa7ff;
    --link: #e4e8ee;
    --chip: #232830;
    --chip-strong: #323944;
    --warn-bg: #3a3522;
    --warn-fg: #f0cf7a;
    --texture-opacity: 0;
  }
}

/* ---- 土台 ---- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background-color: var(--paper); }
body {
  margin: 0;
  color: var(--ink);
  font-family: var(--font);
  font-size: 16.5px;
  line-height: 1.85;
  letter-spacing: 0.02em;
  overflow-wrap: anywhere;
  line-break: strict;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
p a, li a, dd a, .more, .edition a, .pager a, .archive .links a { color: var(--accent); }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86em;
  background: var(--chip);
  border-radius: 4px;
  padding: 1px 5px;
  word-break: break-all;
  letter-spacing: 0;
}
/* 紙の質感：写真から凹凸の明暗だけを取り出した画像（中心は明るさ 128）を、紙の色に soft-light で薄く重ねる。
   画面に固定し、原寸で敷き詰める（大きな明暗のむらは取り除いてあるので、継ぎ目は目立たない）（0018） */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: url("paper_texture.webp") repeat 0 0 / 1000px auto;
  mix-blend-mode: soft-light;
  opacity: var(--texture-opacity);
}
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* 紙面：左右にごく細かい波線（紙の切れ目）。スマホは画面の端から 6px 内側
   波の形は SVG を mask に使い、色は --edge で付ける（テーマで色が変わるように） */
.paper {
  position: relative;
  max-width: 62rem; min-height: 100vh;
  margin: 0 6px;
  --wave: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='6'%3E%3Cpath d='M2 0 Q3.6 1.5 2 3 T2 6' fill='none' stroke='black' stroke-width='0.9'/%3E%3C/svg%3E");
}
.paper::before, .paper::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 4px;
  background-color: var(--edge);
  -webkit-mask: var(--wave) repeat-y; mask: var(--wave) repeat-y;
  pointer-events: none;
}
.paper::before { left: -2px; }
.paper::after { right: -2px; }
@media (min-width: 1004px) {  /* 62rem（992px）＋左右の 6px */
  .paper { margin: 0 auto; }
}

/* ---- 幅 ---- */
main, footer.site { max-width: 62rem; margin: 0 auto; padding-left: 12px; padding-right: 12px; }
body.narrow main, body.narrow footer.site { max-width: 42rem; }

/* ---- 題字の欄：左にロゴ、右上に日付 ---- */
header.site { padding: 14px 12px 0; }
.nameplate {
  max-width: calc(62rem - 24px); margin: 0 auto;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding-bottom: 10px;
  border-bottom: 3px solid var(--rule-strong);
  position: relative;
}
.nameplate::after {  /* 太い線の下に細い線を添える（表罫） */
  content: ""; position: absolute; left: 0; right: 0; bottom: -7px;
  border-bottom: 1px solid var(--rule-strong);
}
.brand { display: block; flex: 0 1 auto; min-width: 0; }
.brand:hover { text-decoration: none; }
.logo { display: block; width: min(300px, calc(100vw - 150px)); height: auto; }  /* 日付の欄に要る幅を残して大きく（0022） */
.logo-dark { display: none; }
:root[data-theme="dark"] .logo-light { display: none; }
:root[data-theme="dark"] .logo-dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-light { display: none; }
  :root:not([data-theme="light"]) .logo-dark { display: block; }
}
.nameplate-side { flex: none; text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.dateline { margin: 0; line-height: 1.35; font-weight: 700; font-size: 13px; letter-spacing: 0.02em; white-space: nowrap; }
.dateline span { display: block; font-weight: 400; font-size: 11.5px; color: var(--muted); letter-spacing: 0.06em; }
.site-nav { display: flex; align-items: center; gap: 10px; font-size: 12.5px; }
.site-nav > a { color: var(--muted); }
.theme-toggle {
  display: grid; place-items: center;
  width: 28px; height: 28px;
  border: 1px solid var(--rule);
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.theme-toggle:hover { background: var(--chip); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-toggle svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle .moon { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .moon { display: block; }
}

/* ---- 期間のタブと版の情報 ---- */
.section-bar {  /* 左にタブ、右に件数を1行で（0025） */
  display: flex; flex-wrap: nowrap; align-items: baseline; justify-content: space-between; gap: 12px;
  margin-top: 16px; padding-bottom: 8px;
  border-bottom: 1px solid var(--rule-strong);
}
@media (max-width: 899px) {
  .section-bar .tab { padding: 0 10px; letter-spacing: 0.06em; }
  .section-bar .tab:first-child { padding-left: 0; }
  .section-bar .edition { font-size: 11.5px; letter-spacing: 0; }
}
.tabs { display: flex; align-items: baseline; font-size: 15px; letter-spacing: 0.12em; }
.tab { color: var(--muted); padding: 0 14px; border-left: 1px solid var(--rule); line-height: 1.2; }
.tab:first-child { padding-left: 0; border-left: 0; }
.tab:hover { color: var(--ink); text-decoration: none; }
.tab.active { color: var(--ink); font-weight: 700; }
.tab.disabled { opacity: 0.4; }
.edition { display: flex; flex-wrap: wrap; gap: 2px 14px; margin: 0; font-size: 12.5px; color: var(--muted); letter-spacing: 0.04em; }
.edition > * { white-space: nowrap; }

/* ---- 記事（一覧） ---- */
.cards { margin-top: 4px; }
.card { position: relative; padding: 18px 0 16px; border-bottom: 1px solid var(--rule-strong); break-inside: avoid; }  /* 詳しいページの節の線と同じ濃さ（0029） */
/* 要約のある記事は、記事のどこを押しても詳しいページへ（題名のリンクを記事全体に広げる。0025） */
.card.has-detail h2 a::after { content: ""; position: absolute; inset: 0; z-index: 1; }
.card.has-detail .more { position: relative; z-index: 2; }
.card.has-detail:hover .name { text-decoration: underline; text-underline-offset: 3px; }

/* 記事の頭（0022）：グリッドで組む。
   スマホ：1行目に順位・題名・印、一文と言語・スターはその下に記事の幅いっぱい
   PC：左に順位、真ん中に題名・一文・言語とスター、右上に印 */
.card-head {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "rank title marks" "dek dek dek" "meta meta meta";
  column-gap: 12px; margin-bottom: 10px;
}
.card-head .rank { grid-area: rank; align-self: end; }
.card-head h2 { grid-area: title; align-self: end; }
.card-head .marks { grid-area: marks; align-self: start; }
.card-head .dek { grid-area: dek; margin-top: 6px; }
.card-head .meta { grid-area: meta; }
.rank {
  color: var(--accent); font-weight: 700; line-height: 0.95; letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums; font-size: 24px;
}
/* 題名：「アカウント名/」を小さく薄く上に、リポジトリ名を大きく（0022） */
.owner { display: block; font-size: 12.5px; font-weight: 400; line-height: 1.35; color: var(--muted); letter-spacing: 0.02em; }
.name { display: block; }
.rank small { font-size: 0.38em; letter-spacing: 0; margin-left: 2px; }

/* 記事の右上の印（0019、0021）：顔ぶれ（新・続・再の囲み文字）と、前回からの順位の動き（▲▼→） */
.marks { display: flex; align-items: center; gap: 5px; padding-top: 2px; font-style: normal; }
.mark {
  display: inline-grid; place-items: center;
  width: 1.6em; height: 1.6em; font-size: 12px; font-style: normal; font-weight: 700; line-height: 1;
  border: 1.5px solid currentColor; border-radius: 3px;
}
.mark-new { color: var(--paper); background: var(--ink); border-color: var(--ink); }  /* 新：白抜き */
.mark-continuing { color: var(--muted); }                                              /* 続：控えめ */
.mark-returning { color: var(--ink); }                                                 /* 再：墨の枠 */
.move { font-size: 12px; font-style: normal; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: 0; }
.move.up { color: var(--up); }
.move.down { color: var(--down); }
.move.same { color: var(--muted); }
.tier-xl .mark { font-size: 14px; }
.tier-xl .move { font-size: 14px; }

/* 印の凡例（ページの末尾）。分野の囲みのすぐ下なら間を詰める */
.field-box + .legend { margin-top: 16px; }
.legend {
  display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 28px 0 0; padding-top: 10px;
  border-top: 1px solid var(--rule); font-size: 12px; color: var(--muted);
}
.legend > span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.legend .legend-title { font-weight: 700; color: var(--ink); letter-spacing: 0.08em; }
.legend .mark { width: 1.5em; height: 1.5em; font-size: 11px; }
/* 題名はリポジトリ名、その下に what を短い一文で（2行まで）（0020） */
.card h2 { font-size: 19px; line-height: 1.25; margin: 0; font-weight: 700; letter-spacing: 0.01em; overflow-wrap: break-word; }
.card h2 a { color: var(--ink); }
.card h2 a:hover { text-decoration: none; }
.card h2 a:hover .name { text-decoration: underline; text-underline-offset: 3px; }
.dek {
  margin: 0 0 5px; font-size: 14px; line-height: 1.55; color: var(--ink);
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
}
.tier-xl .rank { font-size: 64px; }
.tier-xl h2 { font-size: 27px; }
.tier-xl .owner { font-size: 14px; }
.tier-xl .dek { font-size: 16px; }
.tier-l .rank { font-size: 46px; }
.tier-l h2 { font-size: 22px; }
.tier-l .dek { font-size: 15px; }
.tier-m .rank { font-size: 34px; }
.tier-m h2 { font-size: 20px; }

/* 言語とスター：枠なしの小さな文字 */
.meta { display: flex; flex-wrap: wrap; gap: 2px 14px; align-items: center; font-size: 12.5px; color: var(--muted); }
.lang { display: inline-flex; align-items: center; gap: 5px; }
.lang i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.stars b { color: var(--ink); font-weight: 700; }
.tag { background: var(--chip-strong); border-radius: 999px; padding: 0 9px; font-size: 11.5px; line-height: 1.9; color: var(--ink); }
.tag.warn { background: var(--warn-bg); color: var(--warn-fg); }

.card .short { margin: 0 0 10px; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card .more { font-size: 13px; white-space: nowrap; }
.card .more::after { content: " →"; }

/* タグ：丸角で塗りつぶし。先頭（主な分野）は少し濃く */
.tags { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.tags li {
  margin: 0; padding: 0 10px; border-radius: 999px;
  background: var(--chip); color: var(--ink);
  font-size: 12px; line-height: 1.9;
}
.tags li:first-child { background: var(--chip-strong); font-weight: 700; }

.pending { color: var(--muted); font-size: 13px; margin: 0 0 4px; }
.orig { color: var(--muted); font-size: 13.5px; line-height: 1.65; margin: 0; }

/* トップ記事（最初の1件）は本文も大きく、書き出しを大きく（ドロップキャップ）。
   日本語は1文字目、英字は最初の単語（0026）。2件目以降の .drop は飾らない */
.cards > .card:first-child .short { font-size: 17.5px; line-height: 1.9; }
.cards > .card:first-child .short .drop,
.article-body .lead .drop {
  float: left; font-size: 3.1em; line-height: 1; font-weight: 700;
  margin: 0.08em 0.12em 0 0;
}
.cards > .card:first-child .short .drop-word,
.article-body .lead .drop-word { font-size: 2.6em; margin-top: 0.1em; margin-right: 0.18em; }

/* ---- 本日の分野（天気欄のような囲み） ---- */
.field-box {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px;
  margin: 32px 0 0; padding: 8px 12px;  /* ページの末尾、凡例の上（0023） */
  border: 1px solid var(--rule-strong);
  outline: 1px solid var(--rule); outline-offset: 2px;  /* 二重の枠 */
}
.field-box h2 { margin: 0; font-size: 13px; letter-spacing: 0.14em; white-space: nowrap; }
.field-box ul { list-style: none; display: flex; flex-wrap: wrap; gap: 2px 14px; margin: 0; padding: 0; font-size: 13px; }
.field-box li { margin: 0; white-space: nowrap; }
.field-box li b { margin-left: 4px; color: var(--accent); font-variant-numeric: tabular-nums; }

/* ---- 継続・失敗の一覧 ---- */
.panel { margin-top: 36px; }
.panel > h2 {
  font-size: 14px; letter-spacing: 0.14em; margin: 0; padding-bottom: 6px;
  border-bottom: 1px solid var(--rule-strong);
}
.errors ul, .archive { list-style: none; padding: 0; margin: 0; }
.errors li { padding: 9px 0; border-bottom: 1px solid var(--rule); }
.errors li { font-size: 14px; }

/* ---- ページの見出し（過去の日） ---- */
.page-title { margin: 22px 0 0; padding-bottom: 10px; border-bottom: 1px solid var(--rule-strong); }
.page-title h1 { font-size: 24px; margin: 0; letter-spacing: 0.08em; }
.page-title p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.archive li { padding: 12px 0; border-bottom: 1px solid var(--rule); }
.archive .date { font-weight: 700; font-size: 17px; margin-right: 12px; color: var(--ink); }
.archive .counts { font-size: 13px; color: var(--muted); }
.archive .links { display: flex; gap: 16px; font-size: 13px; margin-top: 2px; }

.pager { display: flex; justify-content: space-between; margin-top: 30px; font-size: 14px; }

/* ---- 詳しいページ（新聞の記事の形。0021） ---- */
.detail { margin-top: 22px; }
.article-head { padding-bottom: 14px; border-bottom: 3px solid var(--rule-strong); position: relative; }
.article-head::after {  /* 太い線の下に細い線を添える（表罫） */
  content: ""; position: absolute; left: 0; right: 0; bottom: -7px;
  border-bottom: 1px solid var(--rule-strong);
}
.article-kicker {
  display: flex; flex-wrap: wrap; gap: 2px 14px; margin: 0 0 6px;
  font-size: 12.5px; color: var(--muted); letter-spacing: 0.08em;
}
.article-kicker span:first-child { color: var(--accent); font-weight: 700; }
.detail h1.repo { font-size: 28px; line-height: 1.2; margin: 0 0 6px; letter-spacing: 0.01em; overflow-wrap: break-word; }
.detail h1.repo .owner { font-size: 14px; margin-bottom: 2px; }
.detail .dek { font-size: 17px; line-height: 1.6; margin: 0 0 10px; font-weight: 700; }
.byline { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin: 0 0 10px; font-size: 12.5px; color: var(--muted); }
.detail .tags { margin: 0; }
.article-body { margin-top: 22px; }
.article-body .lead { font-size: 17.5px; line-height: 1.9; margin: 0 0 8px; }
.article-body section { break-inside: avoid; }
.article-body h2 {
  font-size: 14px; letter-spacing: 0.14em; margin: 22px 0 6px; padding-top: 8px;
  border-top: 1px solid var(--rule-strong);
}
.article-body ul { padding-left: 1.2em; }
.info-box {
  margin: 30px 0 0; padding: 12px 16px 8px;
  border: 1px solid var(--rule-strong);
  outline: 1px solid var(--rule); outline-offset: 2px;  /* 二重の枠 */
}
.info-box h2 { margin: 0 0 8px; font-size: 13px; letter-spacing: 0.14em; }
.info-box .actions { margin: 0 0 10px; }
.info-box .note { color: var(--muted); }
.info-box .about { grid-template-columns: max-content 1fr; }
.button {
  display: inline-block;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  padding: 3px 16px;
  font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--ink);
}
.button:hover { background: var(--ink); color: var(--paper); text-decoration: none; }
.about { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: 13px; margin: 0 0 8px; }
.about dt { color: var(--muted); }
.about dd { margin: 0; }
.detail .orig { font-size: 14px; }

/* ---- フッター：横線は本文と同じ幅の内側に（左右の波線に届かないように） ---- */
footer.site {
  position: relative;
  margin-top: 56px; padding-top: 16px; padding-bottom: 32px;
  color: var(--muted); font-size: 12px; line-height: 1.7; text-align: center;
}
footer.site::before {
  content: ""; position: absolute; top: 0; left: 12px; right: 12px;
  border-top: 2px solid var(--rule-strong);
}
footer.site .feed-link { display: inline-block; margin-top: 6px; color: var(--muted); }

/* ---- PC：2段組み（左 → 右 → 次の行の順）、段のあいだに縦の罫線（0016） ---- */
@media (min-width: 900px) {
  main, footer.site { padding-left: 28px; padding-right: 28px; }
  footer.site::before { left: 28px; right: 28px; }
  header.site { padding: 22px 28px 0; }
  .nameplate { max-width: calc(62rem - 56px); }
  .logo { width: 400px; }
  .dateline { font-size: 17px; }
  .dateline span { font-size: 13px; }
  .detail h1.repo { font-size: 40px; }
  .detail h1.repo .owner { font-size: 16px; }
  /* PC の記事の頭：順位は左で3行ぶん、一文と言語・スターは題名と同じ位置から */
  .card-head { grid-template-areas: "rank title marks" "rank dek dek" "rank meta meta"; }
  .card-head .rank { align-self: start; }
  .card-head h2 { align-self: start; }
  .detail .dek { font-size: 19px; }
  /* 本文は2段組み。段のあいだに縦の罫線、節は段の途中で割らない */
  .article-body { columns: 2; column-gap: 44px; column-rule: 1px solid var(--rule); }
  .article-body .lead { column-span: all; font-size: 18px; max-width: 46rem; margin-bottom: 10px; }
  .article-body section:first-of-type h2 { margin-top: 10px; }
  .info-box .about { grid-template-columns: max-content 1fr max-content 1fr; }
  /* 詳しいページの2段組みと同じ組み方（0029）：段のあいだに切れ目のない縦の罫線を通し、
     記事を区切る横の線は各段の幅だけにして、縦の線とは交わらせない */
  .cards { display: grid; grid-template-columns: 1fr 1fr; column-gap: 44px; }
  .cards > .card:first-child { grid-column: 1 / -1; padding-bottom: 22px; border-bottom: 1px solid var(--rule-strong); }
  .cards > .card:nth-child(odd):not(:first-child)::before {  /* 右の記事の左に、段のあいだの縦の罫線 */
    content: ""; position: absolute; top: 0; bottom: -1px; left: -22px;
    border-left: 1px solid var(--rule); pointer-events: none;
  }
  .cards > .card:nth-child(3)::before { top: 18px; }  /* 最初の行は、トップ記事の下の線と交わらないように少し下から */
  .cards > .card:first-child .short { font-size: 18px; max-width: 46rem; }
  .tier-xl .rank { font-size: 84px; }
  .tier-xl h2 { font-size: 34px; }
  .tier-xl .dek { font-size: 17px; max-width: 46rem; }
}
