/* 読みものノートの土台。白地に黒の文字だけで組む、個人ブログのようなシンプルな見た目。
   フォント（Zen Kaku Gothic New）は、ビルド時に各ページの <head> へ <link> で入る（scripts/build-site.mjs）。
   @import で読むと、この CSS を読み終えるまでフォントの取得が始まらず、表示が遅れる。 */

:root {
    --paper: #FFFFFF;
    --paper-raised: #F5F5F5;
    --ink: #111111;
    --ink-soft: #444444;
    --muted: #777777;
    --rule: #E5E5E5;
    /* 解説ページ（assets/guide.css）も同じ名前で色を参照するので、アクセント色も黒系にそろえる */
    --indigo: #111111;
    --plum: #111111;
    --max-width: 680px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

body {
    background-color: var(--paper);
    color: var(--ink);
    font-family: 'Zen Kaku Gothic New', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', sans-serif;
    font-size: 16px;
    line-height: 1.9;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--ink);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

a:hover,
a:focus-visible {
    color: var(--muted);
}

a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 3px;
}

/* Shared page frame */
.page {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 32px 16px 80px;
}

.site-nav {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 16px;
    margin-bottom: 40px;
    font-size: 13px;
}

.site-nav a {
    text-decoration: none;
}

.site-nav .back-link {
    color: var(--muted);
}

.site-nav .tool-link {
    color: var(--ink);
    font-weight: 500;
}

.site-nav a:hover,
.site-nav a:focus-visible {
    text-decoration: underline;
}

/* Index page header */
.notebook-header {
    margin-bottom: 36px;
}

.notebook-header .eyebrow {
    display: block;
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 6px;
}

.notebook-header h1 {
    font-weight: 700;
    font-size: 28px;
    line-height: 1.5;
}

.notebook-header p {
    margin-top: 12px;
    color: var(--ink-soft);
    font-size: 15px;
}

/* 読みものの一覧: サイト名「棒と石」を出すのはここだけ */
.notebook-header .masthead {
    font-weight: 700;
    font-size: 40px;
    letter-spacing: 0.1em;
    line-height: 1.3;
}

.notebook-header .masthead-sub {
    margin-top: 6px;
    font-family: Georgia, 'Times New Roman', serif;
    font-style: italic;
    font-size: 13px;
    color: var(--muted);
}

.notebook-header .masthead-rule {
    display: none;
}

/* Article list (index page) */
.article-list {
    display: flex;
    flex-direction: column;
}

.article-entry {
    padding: 28px 0;
    border-bottom: 1px solid var(--rule);
}

.article-entry:first-child {
    padding-top: 0;
}

.article-entry time {
    display: block;
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 6px;
    font-variant-numeric: tabular-nums;
}

.article-entry h2 {
    font-weight: 700;
    font-size: 20px;
    line-height: 1.6;
    margin-bottom: 8px;
}

.article-entry h2 a {
    color: var(--ink);
    text-decoration: none;
}

.article-entry h2 a:hover,
.article-entry h2 a:focus-visible {
    text-decoration: underline;
    color: var(--ink);
}

.article-entry .excerpt {
    color: var(--ink-soft);
    font-size: 15px;
    line-height: 1.8;
    margin-bottom: 10px;
}

.article-entry .read-more {
    font-size: 14px;
}

/* 一覧ページのタブ（記事一覧・月別・カテゴリ別）: グレーの台の上で、選んだタブだけ白く浮かせる */
.article-tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    margin-bottom: 28px;
    background-color: #EEEEEE;
    border-radius: 10px;
}

.article-tab {
    flex: 1;
    min-height: 40px;
    padding: 8px 12px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    cursor: pointer;
}

.article-tab:hover {
    color: var(--ink);
}

.article-tab[aria-selected="true"] {
    background-color: #FFFFFF;
    color: var(--ink);
    font-weight: 700;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.article-tab:focus-visible {
    outline-offset: 1px;
}

/* 日付とタイトルだけの一覧: 1件ずつ薄いグレーの札にして、タイトルを立たせる */
.title-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.title-item {
    position: relative;
}

.title-item a {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 14px 40px 14px 16px;
    border-radius: 8px;
    background-color: #F8F8F8;
    color: var(--ink);
    text-decoration: none;
    transition: background-color 0.15s;
}

.title-item a:hover,
.title-item a:focus-visible {
    background-color: #EFEFEF;
    color: var(--ink);
}

.title-item time {
    font-size: 12.5px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.title-item .title-text {
    font-size: 16px;
    font-weight: 700;
    line-height: 1.6;
}

.title-item .title-excerpt {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
    margin-top: 4px;
    color: var(--ink-soft);
    font-size: 14px;
    font-weight: 400;
    line-height: 1.75;
}

.title-item .pin-mark {
    top: 16px;
    right: 14px;
}

/* 月別・カテゴリ別: まず「どの月・カテゴリに何件あるか」だけを並べ、選ぶとその記事が出る */
.group-picker {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    font-size: 14px;
    color: var(--muted);
}

.group-picker select {
    flex: 1;
    max-width: 280px;
    min-height: 40px;
    padding: 8px 36px 8px 12px;
    border: 1px solid #D6D6D6;
    border-radius: 8px;
    background: #FFFFFF url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23111' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat right 12px center;
    color: var(--ink);
    font: inherit;
    font-size: 15px;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

.group-picker select:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 2px;
}

.group-index {
    list-style: none;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.group-index a {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 16px;
    border-radius: 8px;
    background-color: #F8F8F8;
    color: var(--ink);
    font-weight: 700;
    text-decoration: none;
    transition: background-color 0.15s;
}

.group-index a:hover,
.group-index a:focus-visible {
    background-color: #EFEFEF;
    color: var(--ink);
}

.group-index .count,
.title-group .count {
    font-size: 13px;
    font-weight: 400;
    color: var(--muted);
}

.group-index a::after {
    content: "→";
    margin-left: auto;
    padding-left: 8px;
    color: var(--muted);
    font-weight: 400;
}

.group-index .count {
    order: 1;
}

.group-index a::after {
    order: 2;
}

.title-group h2 {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 12px;
    font-size: 18px;
    font-weight: 700;
}

.group-back {
    display: inline-block;
    margin-top: 20px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--muted);
    font: inherit;
    font-size: 14px;
    cursor: pointer;
}

.group-back:hover,
.group-back:focus-visible {
    color: var(--ink);
    text-decoration: underline;
    text-underline-offset: 3px;
}

@media (min-width: 640px) {
    .title-item a:not(.has-excerpt) {
        flex-direction: row;
        align-items: baseline;
        gap: 20px;
    }

    .title-item time {
        flex: none;
    }

    .group-index {
        grid-template-columns: 1fr 1fr;
    }
}

.empty-note {
    color: var(--muted);
    font-size: 14px;
    padding: 24px 0;
    border-bottom: 1px solid var(--rule);
}

/* 記事の中で、1文だけを立てて置く */
.article-body .pull {
    margin: 40px 0;
    padding-left: 16px;
    border-left: 3px solid var(--ink);
    font-weight: 700;
    font-size: 19px;
    line-height: 1.7;
}

/* 先頭に固定した記事の印: 画びょうを、記事の右上（日付の行の右端）に置く */
.article-entry.is-pinned {
    position: relative;
}

.pin-mark {
    position: absolute;
    top: 0; /* 先頭の記事は上の余白がないので、日付の行にそろう */
    right: 2px;
    line-height: 0;
    color: var(--ink);
}

.article-entry.is-pinned:not(:first-child) .pin-mark {
    top: 28px;
}

.pin-mark svg {
    fill: currentColor;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    transform: rotate(38deg);
}

/* Article page */
.article-head {
    margin-bottom: 40px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--rule);
}

.article-head h1 {
    font-weight: 700;
    font-size: 26px;
    line-height: 1.55;
    margin-bottom: 12px;
}

.article-meta {
    font-size: 13px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.article-meta span + span {
    margin-left: 16px;
}

.title-rule {
    display: none;
}

.article-body {
    font-size: 16.5px;
    line-height: 1.95;
    color: var(--ink);
    overflow-wrap: anywhere;
}

.article-body p {
    margin-bottom: 24px;
}

.article-body h2 {
    font-weight: 700;
    font-size: 20px;
    margin: 48px 0 18px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--ink);
    line-height: 1.6;
}

.article-body h3 {
    font-size: 17px;
    font-weight: 700;
    margin: 32px 0 12px;
    line-height: 1.6;
}

.article-body ul,
.article-body ol {
    margin: 0 0 24px 1.3em;
}

.article-body li {
    margin-bottom: 10px;
}

.article-body strong {
    font-weight: 700;
}

/* CTA to the tool, inline within an article */
.tool-cta {
    margin: 40px 0;
    padding: 20px 24px;
    background-color: var(--paper-raised);
    border-left: 3px solid var(--ink);
}

.tool-cta p {
    margin-bottom: 12px;
    font-size: 15px;
}

.tool-cta p:last-child {
    margin-bottom: 0;
}

.tool-cta a {
    font-weight: 500;
}

/* 記事の中のツールへのリンクは、それぞれのツールの色で出す。
   穴埋め暗記＝紫（#667eea → #764ba2）、えいたんカード＝オレンジ、なんか書け＝緑、Read the Room＝紺と水色、赤字デスク＝朱 */
.article-body a[href="/"],
.site-nav a[href="/"] {
    --tool: #5a67d8;
}

.article-body a[href^="/eitan-card/"],
.site-nav a[href^="/eitan-card/"] {
    --tool: #d9600b;
}

.article-body a[href^="/english-composition/"],
.site-nav a[href^="/english-composition/"] {
    --tool: #3c6552;
}

.article-body a[href^="/akaji-desk/"],
.site-nav a[href^="/akaji-desk/"] {
    --tool: #c41f17;
}

.article-body a[href="/read-the-room/"],
.article-body a[href^="/read-the-room/?"],
.site-nav a[href^="/read-the-room/"] {
    --tool: #3a63c8;
}

.article-body a[href="/"],
.article-body a[href^="/eitan-card/"],
.article-body a[href^="/english-composition/"],
.article-body a[href^="/akaji-desk/"],
.article-body a[href="/read-the-room/"],
.article-body a[href^="/read-the-room/?"],
.site-nav .tool-link {
    color: var(--tool, var(--ink));
    font-weight: 700;
    text-decoration-color: color-mix(in srgb, var(--tool, var(--ink)) 45%, transparent);
}

.article-body a[href="/"]:hover,
.article-body a[href^="/eitan-card/"]:hover,
.article-body a[href^="/english-composition/"]:hover,
.article-body a[href^="/akaji-desk/"]:hover,
.article-body a[href="/read-the-room/"]:hover,
.article-body a[href^="/read-the-room/?"]:hover {
    color: var(--tool);
    text-decoration-color: currentColor;
}

/* ツールへの案内枠: 中のリンク先のツールの色で、背景と左の線とボタンを塗る */
.tool-cta:has(a[href="/"]) {
    --tool: #5a67d8;
    --tool-fill: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.tool-cta:has(a[href^="/eitan-card/"]) {
    --tool: #d9600b;
    --tool-fill: #ff7a1a;
}

.tool-cta:has(a[href^="/english-composition/"]) {
    --tool: #3c6552;
    --tool-fill: #3c6552;
}

.tool-cta:has(a[href^="/akaji-desk/"]) {
    --tool: #c41f17;
    --tool-fill: #c41f17;
}

.tool-cta:has(a[href^="/read-the-room/"]) {
    --tool: #3a63c8;
    --tool-fill: #14161f;
}

.tool-cta:has(a[href="/"]),
.tool-cta:has(a[href^="/eitan-card/"]),
.tool-cta:has(a[href^="/english-composition/"]),
.tool-cta:has(a[href^="/akaji-desk/"]),
.tool-cta:has(a[href^="/read-the-room/"]) {
    border-left-color: var(--tool);
    background-color: color-mix(in srgb, var(--tool) 7%, #FFFFFF);
}

.tool-cta p:last-child a[href="/"],
.tool-cta p:last-child a[href^="/eitan-card/"],
.tool-cta p:last-child a[href^="/english-composition/"],
.tool-cta p:last-child a[href^="/akaji-desk/"],
.tool-cta p a[href^="/read-the-room/"] {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 999px;
    background: var(--tool-fill, var(--tool));
    color: #FFFFFF;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.5;
    text-decoration: none;
}

.tool-cta p a[href^="/read-the-room/"] {
    background: color-mix(in srgb, var(--tool) 12%, #FFFFFF);
    color: #2c4c9c;
}

.tool-cta p:last-child a[href="/"]:hover,
.tool-cta p:last-child a[href^="/eitan-card/"]:hover,
.tool-cta p:last-child a[href^="/english-composition/"]:hover,
.tool-cta p:last-child a[href^="/akaji-desk/"]:hover,
.tool-cta p a[href^="/read-the-room/"]:hover {
    filter: brightness(1.08);
    text-decoration: none;
}

.tool-cta p:last-child a[href="/"]:hover,
.tool-cta p:last-child a[href^="/eitan-card/"]:hover,
.tool-cta p:last-child a[href^="/english-composition/"]:hover,
.tool-cta p:last-child a[href^="/akaji-desk/"]:hover {
    color: #FFFFFF;
}

.tool-cta p a[href^="/read-the-room/"]:hover,
.tool-cta p a[href^="/read-the-room/"]:focus-visible {
    background: var(--tool-fill);
    color: #7aa7ff;
    filter: none;
}

/* Back numbers */
.back-numbers {
    margin-top: 64px;
}

.back-numbers h2 {
    font-size: 17px;
    font-weight: 700;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--ink);
}

.back-numbers ul {
    list-style: none;
}

.back-numbers li {
    padding: 14px 0;
    border-bottom: 1px solid var(--rule);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.back-numbers time {
    font-size: 12px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.back-numbers a {
    font-size: 15px;
    color: var(--ink);
    font-weight: 500;
    text-decoration: none;
}

.back-numbers a:hover,
.back-numbers a:focus-visible {
    text-decoration: underline;
    color: var(--ink);
}

/* Footer */
.site-footer {
    margin-top: 64px;
    padding-top: 24px;
    border-top: 1px solid var(--rule);
    font-size: 13px;
    color: var(--muted);
}

@media (min-width: 640px) {
    .page {
        padding: 56px 24px 96px;
    }

    .notebook-header h1 {
        font-size: 32px;
    }

    .notebook-header .masthead {
        font-size: 52px;
    }

    .article-head h1 {
        font-size: 30px;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

/* 記事内の図（SVG のグラフ）と、その数値の表 */
.article-figure {
    margin: 28px 0;
}

.figure-chart {
    display: block;
    width: 100%;
    height: auto;
    font-family: inherit;
}

.figure-chart .grid {
    stroke: var(--rule);
    stroke-width: 1;
}

.figure-chart .tick,
.figure-chart .axis-label {
    fill: var(--muted);
    font-size: 14px;
}

.figure-chart .value {
    fill: var(--ink);
    font-size: 15px;
    font-weight: 700;
}

.figure-chart .line {
    fill: none;
    stroke: var(--ink);
    stroke-width: 2;
    stroke-linejoin: round;
}

.figure-chart .dot {
    fill: var(--ink);
    stroke: var(--paper);
    stroke-width: 2;
}

.article-figure figcaption {
    margin-top: 10px;
    font-size: 13px;
    line-height: 1.7;
    color: var(--ink-soft);
}

.figure-data {
    margin-top: 8px;
    font-size: 13px;
}

.figure-data summary {
    cursor: pointer;
    color: var(--ink-soft);
}

.figure-data table {
    margin-top: 8px;
    border-collapse: collapse;
}

.figure-data th,
.figure-data td {
    padding: 4px 14px 4px 0;
    border-bottom: 1px solid var(--rule);
    text-align: left;
}

/* ---------- 言い換えの4つの条件（eigo-iikae-yottsu-no-jouken）の図と表 ---------- */
.figure-narrow { max-width: 420px; margin-left: auto; margin-right: auto; }
.figure-scatter .grid { stroke: var(--rule); }
.figure-scatter .dot { fill: var(--ink); }
.figure-scatter .value { font-size: 13px; fill: var(--ink); font-style: italic; }
.figure-scatter .tick, .figure-scatter .axis-label { font-size: 11px; fill: var(--muted); }

.layer-map { border: 1px solid var(--ink); padding: 16px; display: grid; gap: 14px; }
.layer-sentence { margin: 0; text-align: center; font-size: 17px; font-style: italic; line-height: 1.8; }
.layer-sentence .lm-word { font-weight: 700; border: 2px solid var(--ink); padding: 0 6px; font-style: normal; }
.layer-sentence .lm-around { border-bottom: 1px dashed var(--ink); }
.layer-group { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.layer-group-title { grid-column: 1 / -1; margin: 0; font-size: 12px; color: var(--muted); letter-spacing: .06em; border-bottom: 1px solid var(--rule); padding-bottom: 4px; }
.layer-cell { background: var(--paper-raised); padding: 10px 12px; }
.layer-cell p { margin: 0; }
.layer-name { font-weight: 700; font-size: 15px; }
.layer-what { font-size: 12px; color: var(--muted); margin-bottom: 4px !important; }
.layer-ex { font-size: 13px; line-height: 1.6; color: var(--ink-soft); }

.layer-table { width: 100%; border-collapse: collapse; margin: 16px 0 20px; font-size: 14px; line-height: 1.6; }
.layer-table th, .layer-table td { border-bottom: 1px solid var(--rule); padding: 8px 10px 8px 0; text-align: left; vertical-align: top; }
.layer-table thead th { border-bottom: 1px solid var(--ink); font-size: 12px; color: var(--muted); font-weight: 500; }
.layer-table td:first-child { white-space: nowrap; }

.gate-flow { border: 1px solid var(--ink); padding: 14px 16px; }
.gate-flow p { margin: 0; }
.gate-start { font-size: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--rule); }
.gate-row { display: grid; grid-template-columns: 7.5em 1fr; gap: 10px; align-items: baseline; padding: 9px 0; border-bottom: 1px dashed var(--rule); font-size: 14px; line-height: 1.6; }
.gate-name { font-weight: 700; }
.gate-name::after { content: ' ▼'; font-size: 10px; color: var(--muted); }
.gate-out s { font-style: italic; font-weight: 700; margin-right: 6px; }
.gate-out::before { content: '✗ '; font-weight: 700; }
.gate-soft::before { content: '△ '; font-weight: 700; }
.gate-pass::before { content: '✓ '; font-weight: 700; }
.gate-end { padding-top: 10px; font-size: 15px; }

@media (max-width: 480px) {
    .layer-group { grid-template-columns: 1fr; }
    .layer-sentence { font-size: 15px; }
    .gate-row { grid-template-columns: 1fr; gap: 2px; }
    .layer-table { font-size: 13px; }
    .layer-table td:first-child { white-space: normal; }
}
.article-body .layer-map p,
.article-body .gate-flow p { margin: 0; }
.article-body .layer-map .layer-what { margin-bottom: 4px; }
.layer-name { line-height: 1.4; }
.layer-what { line-height: 1.5; }
.gate-col { display: grid; gap: 4px; }

/* ---------- 言い換えの使い分け（iikae-*）の例文 ---------- */
.iikae-note { font-size: 12px; color: var(--muted); }
.article-body .iikae-examples { list-style: none; padding-left: 0; }
.article-body .iikae-examples li { padding: 12px 0; border-bottom: 1px solid var(--rule); line-height: 1.8; }
.iikae-layer { display: inline-block; font-size: 11px; font-weight: 700; border: 1px solid var(--ink); padding: 0 6px; margin-right: 8px; vertical-align: 1px; }
.iikae-fix { color: var(--ink-soft); font-size: 14px; }
.iikae-why { font-size: 14px; }
