/*
Theme Name: Maah Theme Child
Theme URI: https://maahsachi.com
Description: maah-theme の子テーマ。技術ブログ風のタイポグラフィ・コード装飾・読みやすさを強化。
Author: maah
Author URI: https://maahsachi.com
Template: maah-theme
Version: 1.3.0
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: maah-theme-child
*/

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;500;700;800&family=JetBrains+Mono:wght@400;500;700&display=swap');

/* ===== フォントとカスタムプロパティ ===== */
:root {
    --font-body: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', 'Yu Gothic', Meiryo, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', Consolas, monospace;
    --color-text: #1f2933;
    --color-text-light: #52606d;
    --color-link: #0969da;
    --color-link-hover: #0550ae;
    --color-inline-code-bg: #f1f3f5;
    --color-inline-code-text: #d63384;
    --color-marker: rgba(241, 196, 15, 0.45);
    --color-quote-bg: #f7f9fb;
    --color-code-header-bg: #0d1828;
}

/* ===== body・タイポグラフィ ===== */
body {
    font-family: var(--font-body);
    font-feature-settings: 'palt';
    letter-spacing: 0.01em;
    color: var(--color-text);
}

/* ===== 記事本文 ===== */
.single-article__content {
    line-height: 1.85;
    font-size: 16.5px;
}

.single-article__content p {
    margin-bottom: 1.5em;
}

.single-article__content strong {
    background: linear-gradient(transparent 60%, var(--color-marker) 60%);
    padding: 0 2px;
}

.single-article__content a {
    color: var(--color-link);
    text-decoration: none;
    border-bottom: 1px solid transparent;
}

.single-article__content a:hover {
    color: var(--color-link-hover);
    border-bottom-color: currentColor;
}

/* ===== 見出し ===== */
.single-article__content h2 {
    font-size: 1.55rem;
    font-weight: 800;
    margin: 2.4em 0 1em;
    padding: 0.2em 0 0.5em 18px;
    border-left: none;
    border-bottom: 2px solid var(--color-border);
    position: relative;
}

.single-article__content h2::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.3em;
    bottom: 0.6em;
    width: 5px;
    background: var(--color-accent);
    border-radius: 2px;
}

.single-article__content h3 {
    border-left: none;
    padding-left: 22px;
    font-size: 1.2rem;
    font-weight: 700;
    margin: 2em 0 0.7em;
    position: relative;
}

.single-article__content h3::before {
    content: "#";
    position: absolute;
    left: 0;
    top: 0;
    color: var(--color-accent);
    font-weight: 800;
    font-family: var(--font-mono);
}

.single-article__content h4 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--color-text);
    margin: 1.6em 0 0.5em;
}

/* ===== コードブロック ===== */
.single-article__content pre {
    background: #0d1828;
    color: #e2e8f0;
    border-radius: 10px;
    padding: 18px 22px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    font-family: var(--font-mono);
    font-size: 0.88rem;
    line-height: 1.75;
    margin: 1.8em 0;
    position: relative;
}

.single-article__content pre::before {
    content: attr(data-lang);
    display: block;
    margin: -18px -22px 14px;
    padding: 8px 22px;
    background: var(--color-code-header-bg);
    color: #94a3b8;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    border-radius: 10px 10px 0 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.single-article__content pre:not([data-lang])::before {
    content: "CODE";
}

.single-article__content pre code {
    font-family: inherit;
}

/* ===== インラインコード ===== */
.single-article__content code {
    background: var(--color-inline-code-bg);
    color: var(--color-inline-code-text);
    padding: 2px 7px;
    border-radius: 5px;
    font-size: 0.86em;
    font-family: var(--font-mono);
    border: 1px solid #e6e8eb;
    margin: 0 2px;
}

.single-article__content pre code {
    background: none;
    color: inherit;
    padding: 0;
    border: none;
    margin: 0;
    font-size: 1em;
}

/* ===== 引用 ===== */
.single-article__content blockquote {
    background: var(--color-quote-bg);
    border-left: 4px solid var(--color-accent);
    padding: 18px 24px 18px 56px;
    position: relative;
    border-radius: 0 10px 10px 0;
    color: var(--color-text-light);
    font-style: normal;
}

.single-article__content blockquote::before {
    content: "\201C";
    position: absolute;
    left: 18px;
    top: 8px;
    font-size: 2.4rem;
    line-height: 1;
    color: var(--color-accent);
    font-family: Georgia, serif;
    opacity: 0.6;
}

/* ===== テーブル ===== */
.single-article__content table {
    font-size: 0.93rem;
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    overflow: hidden;
}

.single-article__content th {
    background: var(--color-primary);
    color: #fff;
}

.single-article__content tbody tr:nth-child(even) td {
    background: #fafbfc;
}

.single-article__content th,
.single-article__content td {
    border: none;
    border-bottom: 1px solid var(--color-border);
    padding: 11px 14px;
}

.single-article__content tbody tr:last-child td {
    border-bottom: none;
}

/* ===== post-card ===== */
.post-card {
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    border: 1px solid #eef0f3;
}

.post-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
}

.post-card__title {
    font-size: 1.05rem;
    line-height: 1.55;
}

.post-card__excerpt {
    color: #4b5563;
}

.category-badge {
    background: var(--color-primary);
}

/* ===== 目次 ===== */
.toc {
    background: #fcfcfd;
    border: 1px solid #eceef1;
    border-radius: 10px;
    padding: 22px 26px;
}

.toc__title {
    color: var(--color-text-light);
    font-weight: 700;
    font-size: 0.82rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: 14px;
}

.toc__title::before {
    content: "▸ ";
    color: var(--color-accent);
}

.toc a {
    color: var(--color-text);
}

.toc > ol > li::before {
    color: var(--color-text-muted);
    font-weight: 500;
}

.toc a:hover {
    color: var(--color-link);
    text-decoration: underline;
}

/* ===== パンくず ===== */
.breadcrumb {
    font-size: 0.78rem;
    padding-top: 22px;
}

/* ===== post-navigation ===== */
.post-navigation__item:hover {
    background: #fafbfc;
    border-color: var(--color-accent);
}

/* ===== share-buttons ===== */
.share-btn {
    border-radius: 8px;
    transition: transform 0.15s, opacity 0.2s;
}

.share-btn:hover {
    transform: translateY(-1px);
}

/* ===== single-article__thumbnail ===== */
.single-article__thumbnail {
    margin: 32px 0 40px;
}

/* ===== レスポンシブ ===== */
@media (max-width: 768px) {
    .single-article__content {
        font-size: 15.5px;
        line-height: 1.8;
    }

    .single-article__content h2 {
        font-size: 1.3rem;
        padding-left: 14px;
    }

    .single-article__content h2::before {
        width: 4px;
    }

    .single-article__content h3 {
        font-size: 1.1rem;
        padding-left: 18px;
    }

    .single-article__content pre {
        padding: 14px 16px;
        font-size: 0.82rem;
        border-radius: 8px;
    }

    .single-article__content pre::before {
        margin: -14px -16px 10px;
        padding: 6px 16px;
        border-radius: 8px 8px 0 0;
    }

    .single-article__content blockquote {
        padding: 14px 18px 14px 44px;
    }

    .single-article__content blockquote::before {
        font-size: 2rem;
        left: 12px;
    }
}

/* ===== フッター ===== */
.site-footer {
    font-size: 0.85rem;
}

.footer-section__title {
    letter-spacing: 0.04em;
    font-size: 0.85rem;
}

/* =============================================== */
/* ===== Zenn風リファイン（v1.1.0 追加） ===== */
/* =============================================== */

/* ===== 全体背景を白基調に ===== */
body {
    background: #ffffff;
}

/* ===== トップカード一覧の余白拡大 ===== */
.posts-grid {
    gap: 36px;
    padding: 56px 24px;
}

/* ===== post-card: Zenn風の軽い枠 + 影なし ===== */
.post-card {
    background: #ffffff;
    border-radius: 10px;
    border: 1px solid #e6e8eb;
    box-shadow: none;
}

.post-card:hover {
    transform: none;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
    border-color: #c8cdd3;
}

.post-card__thumbnail {
    background: #fafbfc;
}

.post-card__body {
    padding: 18px 22px 22px;
}

.post-card__meta {
    gap: 10px;
    margin-bottom: 12px;
}

.post-card__title {
    font-size: 1.04rem;
    font-weight: 700;
    line-height: 1.55;
    letter-spacing: -0.005em;
    margin-bottom: 10px;
}

.post-card__excerpt {
    color: #57606a;
    font-size: 0.83rem;
    line-height: 1.7;
}

.post-card__date {
    color: #6b7280;
    font-size: 0.78rem;
}

/* ===== category-badge: pill形 ===== */
.category-badge {
    background: #f3f4f6;
    color: #4b5563;
    font-weight: 600;
    border-radius: 999px;
    padding: 4px 12px;
    font-size: 0.7rem;
    letter-spacing: 0;
}

.category-badge:hover {
    background: #e5e7eb;
    color: #1f2933;
}

/* ===== パンくず軽量化 ===== */
.breadcrumb {
    color: #6b7280;
    padding-top: 28px;
    font-size: 0.78rem;
}

.breadcrumb a {
    color: #6b7280;
}

.breadcrumb__separator {
    color: #cbd5e1;
}

/* ===== 記事ページ本体 ===== */
.single-article {
    background: #ffffff;
    padding-top: 36px;
}

.single-article__header {
    margin-bottom: 32px;
}

.single-article__meta {
    margin-bottom: 14px;
    gap: 14px;
}

.single-article__title {
    font-size: 1.85rem;
    line-height: 1.45;
    font-weight: 800;
    letter-spacing: -0.015em;
}

.single-article__reading-time {
    color: #6b7280;
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.single-article__reading-time::before {
    content: "🕐";
    font-size: 0.85rem;
}

/* ===== 目次をさらに軽く ===== */
.toc {
    background: #fafbfc;
    border: 1px solid #eef0f3;
    padding: 20px 24px;
    border-radius: 8px;
    margin-bottom: 36px;
}

.toc__title {
    font-size: 0.78rem;
    margin-bottom: 12px;
}

.toc a {
    font-size: 0.87rem;
    color: #1f2933;
}

/* ===== h2 をミニマルに（左バー廃止、下線のみ） ===== */
.single-article__content h2 {
    padding-left: 0;
    border-left: none;
    border-bottom: 1px solid #e6e8eb;
    padding-bottom: 8px;
    margin: 2.4em 0 1em;
}

.single-article__content h2::before {
    content: none;
}

/* ===== h3 をシンプルに（# の主張弱め） ===== */
.single-article__content h3 {
    padding-left: 20px;
}

.single-article__content h3::before {
    color: #94a3b8;
    font-weight: 700;
}

/* ===== 本文リンク: 下線優先のZenn寄り表現 ===== */
.single-article__content a {
    border-bottom: none;
    text-decoration: underline;
    text-decoration-color: rgba(9, 105, 218, 0.35);
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
}

.single-article__content a:hover {
    text-decoration-color: currentColor;
    border-bottom: none;
}

/* ===== share-buttons: コンパクト化 ===== */
.share-buttons {
    gap: 8px;
    margin: 40px 0 32px;
    padding-top: 28px;
}

.share-btn {
    padding: 7px 14px;
    font-size: 0.78rem;
    border-radius: 6px;
}

/* ===== post-navigation: 軽く ===== */
.post-navigation {
    margin-top: 36px;
    padding-top: 28px;
    gap: 16px;
}

.post-navigation__item {
    padding: 14px 18px;
    border-color: #eef0f3;
    background: #fafbfc;
}

.post-navigation__item:hover {
    background: #ffffff;
    border-color: #c8cdd3;
}

.post-navigation__label {
    font-size: 0.7rem;
    color: #6b7280;
}

.post-navigation__title {
    font-size: 0.85rem;
    color: #1f2933;
}

/* ===== モバイル微調整 ===== */
@media (max-width: 768px) {
    .posts-grid {
        padding: 28px 16px;
        gap: 20px;
    }

    .single-article__title {
        font-size: 1.4rem;
    }

    .single-article {
        padding-top: 24px;
    }
}

/* =============================================== */
/* ===== v1.2.0: ヒーロー / 著者 / 関連記事 ===== */
/* =============================================== */

/* ===== ヒーローセクション（ミニマル版） ===== */
.hero {
    background: #ffffff;
    border-bottom: 1px solid #eef0f3;
    padding: 48px 24px 36px;
}

.hero__inner {
    max-width: 1200px;
    margin: 0 auto;
    text-align: center;
}

.hero__title {
    font-size: 1.6rem;
    font-weight: 800;
    color: #1f2933;
    line-height: 1.5;
    margin: 0 0 12px;
    letter-spacing: -0.005em;
}

.hero__br-sp { display: none; }

.hero__lead {
    color: #57606a;
    font-size: 0.92rem;
    line-height: 1.7;
    margin: 0 0 22px;
}

.hero__tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.hero__tag {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 999px;
    background: #f3f4f6;
    color: #4b5563;
    font-size: 0.78rem;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    border-bottom: none;
}

.hero__tag:hover {
    background: #e94560;
    color: #ffffff;
}

@media (max-width: 768px) {
    .hero {
        padding: 32px 16px 24px;
    }
    .hero__title {
        font-size: 1.25rem;
    }
    .hero__br-sp { display: inline; }
    .hero__lead {
        font-size: 0.85rem;
        margin-bottom: 18px;
    }
    .hero__tag {
        font-size: 0.72rem;
        padding: 5px 12px;
    }
}

/* ===== 著者プロフィールBox（記事下） ===== */
.author-box {
    max-width: 740px;
    margin: 56px auto 24px;
    padding: 24px 28px;
    background: #fafbfc;
    border: 1px solid #e6e8eb;
    border-radius: 12px;
    display: grid;
    grid-template-columns: 80px 1fr;
    gap: 22px;
    align-items: start;
}

.author-box__avatar img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    border: 2px solid #fff;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}

.author-box__label {
    font-size: 0.72rem;
    color: #6b7280;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin: 0 0 4px;
    font-weight: 600;
}

.author-box__name {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1f2933;
    margin: 0 0 8px;
}

.author-box__bio {
    font-size: 0.88rem;
    color: #4b5563;
    line-height: 1.75;
    margin: 0 0 12px;
}

.author-box__links {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.author-box__links a {
    font-size: 0.8rem;
    color: #0969da;
    text-decoration: none;
    border-bottom: none;
}

.author-box__links a:hover {
    text-decoration: underline;
}

@media (max-width: 768px) {
    .author-box {
        grid-template-columns: 64px 1fr;
        gap: 16px;
        padding: 18px 20px;
        margin: 40px 16px 16px;
    }
    .author-box__avatar img { width: 64px; height: 64px; }
}

/* ===== 関連記事ブロック ===== */
.related-posts {
    max-width: 1200px;
    margin: 48px auto 64px;
    padding: 0 24px;
}

.related-posts__title {
    font-size: 1.2rem;
    font-weight: 700;
    color: #1f2933;
    margin: 0 0 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e6e8eb;
    position: relative;
}

.related-posts__title::before {
    content: "▸";
    color: #e94560;
    margin-right: 8px;
}

.related-posts__grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.related-card {
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #e6e8eb;
    border-radius: 10px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: transform 0.15s, box-shadow 0.2s, border-color 0.2s;
    border-bottom: 1px solid #e6e8eb;
}

.related-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.07);
    border-color: #c8cdd3;
}

.related-card__thumb {
    aspect-ratio: 16 / 9;
    background: #fafbfc;
    overflow: hidden;
}

.related-card__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.related-card__body {
    padding: 14px 18px 18px;
}

.related-card__category {
    display: inline-block;
    background: #f3f4f6;
    color: #4b5563;
    font-size: 0.68rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 999px;
    margin-bottom: 8px;
}

.related-card__title {
    font-size: 0.92rem;
    font-weight: 700;
    line-height: 1.5;
    color: #1f2933;
    margin: 0;
}

@media (max-width: 768px) {
    .related-posts { padding: 0 16px; margin: 32px auto 40px; }
    .related-posts__grid { grid-template-columns: 1fr; gap: 14px; }
}

/* =============================================== */
/* ===== v1.2.1: トップカードの3カラム化 ===== */
/* =============================================== */
.posts-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 28px;
    padding: 40px 24px 64px;
}

.post-card__thumbnail {
    aspect-ratio: 16 / 9;
    height: auto;
}

.post-card__body {
    padding: 16px 18px 20px;
}

.post-card__title {
    font-size: 0.98rem;
    line-height: 1.55;
    margin-bottom: 8px;
}

.post-card__excerpt {
    font-size: 0.78rem;
    line-height: 1.65;
    -webkit-line-clamp: 3;
}

.post-card__meta {
    margin-bottom: 8px;
}

.post-card__date {
    font-size: 0.72rem;
}

@media (max-width: 960px) {
    .posts-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 22px;
    }
}

@media (max-width: 560px) {
    .posts-grid {
        grid-template-columns: 1fr;
        gap: 18px;
        padding: 24px 16px 40px;
    }
}

/* =============================================== */
/* ===== v1.3.0: コードブロックのコピーボタン ===== */
/* =============================================== */

/* pre は既に position: relative 済み（v1.0.0で設定） */
.single-article__content pre.has-copy-btn {
    padding-right: 80px; /* ボタンの逃げスペース */
}

.code-copy-btn {
    position: absolute;
    top: 8px;
    right: 12px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.06);
    color: #cbd5e1;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s, background 0.15s, color 0.15s, border-color 0.15s;
}

/* pre をhoverするとボタンが見える */
.single-article__content pre.has-copy-btn:hover .code-copy-btn,
.code-copy-btn:focus-visible {
    opacity: 1;
}

.code-copy-btn:hover {
    background: rgba(255, 255, 255, 0.14);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.25);
}

.code-copy-btn:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

.code-copy-btn.is-copied {
    background: rgba(16, 185, 129, 0.18);
    border-color: rgba(16, 185, 129, 0.45);
    color: #6ee7b7;
    opacity: 1;
}

.code-copy-btn.is-error {
    background: rgba(239, 68, 68, 0.18);
    border-color: rgba(239, 68, 68, 0.45);
    color: #fca5a5;
    opacity: 1;
}

/* タッチデバイスでは常時表示（hover不可なので） */
@media (hover: none) {
    .code-copy-btn {
        opacity: 1;
    }
}

/* pre::before（言語ラベル帯）と重ならないように、ボタンを帯の上に表示する */
.single-article__content pre.has-copy-btn .code-copy-btn {
    z-index: 2;
}
