/*
Theme Name: Akihito Theme
Author: Akihito Kimura
Description: Minimal custom theme for music & emotion research
Version: 1.3
*/

/* ==================================================
    0. CSS変数定義 (Color Palette & Settings)
   ================================================== */
:root {
    /* Base Colors (Light Mode) */
    --bg-body: #fafafa;
    --text-main: #222222;
    --text-sub: #777777;
    --text-meta: #888888;
    --text-link: inherit;
    --border-color: rgba(0, 0, 0, 0.1);
    
    /* Components */
    --code-bg: #f4f4f4;
    --code-border: #dddddd;
    --hover-line: #000000;
    --sidebar-hover-bg: rgba(255, 255, 255, 0.05);

    /* Typography */
    --font-base: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Courier New", monospace;
}

/* Dark Mode Variables Override */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-body: #111111;
        --text-main: #e6e6e6;
        --text-sub: rgba(255, 255, 255, 0.7);
        --text-meta: rgba(255, 255, 255, 0.6);
        --border-color: rgba(255, 255, 255, 0.15);
        
        --code-bg: #1e1e1e;
        --code-border: #333333;
        --hover-line: rgba(255, 255, 255, 0.95);
    }
}

/* ==================================================
    1. 基本設定 & リセット
   ================================================== */
body {
    font-family: var(--font-base);
    font-weight: 400;
    letter-spacing: 0.02em;
    background: var(--bg-body);
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;
    transition: background 0.3s ease, color 0.3s ease;
}

a {
    color: inherit;
    text-decoration: none;
    transition: opacity 0.2s ease, color 0.2s ease;
}

/* タイトル等の軽さ調整 */
.home .post-title,
.blog .post-title {
    font-weight: 400;
    letter-spacing: 0.025em;
}

.home .site-main { margin-top: 6rem; }
.blog .post-item { margin-bottom: 3.5rem; }

/* --- フロントページ固有 --- */
.front-blog-title {
    line-height: 1.2;
    margin-bottom: 0.4rem;
}

.front-hero {
    /* font-size: 0.95rem; */
    font-size: 0.85rem;
    font-weight: 400;
    opacity: 0.6;
    line-height: 1.6;
    /* letter-spacing: 0.02em; */
    letter-spacing: 0.08em;
    margin-bottom: 3.5rem;
}

.front-latest h3 {
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    opacity: 0.55;
    line-height: 1.4;
    margin-top: 0.2rem;
    margin-bottom: 1.8rem;
}

.front-latest-item h3 {
    transition: opacity 0.2s ease;
}
.front-latest-item a:hover h3 {
    opacity: 0.65;
}

.front-latest-list .front-latest-item .latest-date {
    font-size: 0.7rem;
    color: var(--text-meta);
    margin-top: 0.2rem;
    line-height: 1.2;
    opacity: 0.7; /* Dark mode adjustments handled via var or opacity */
}

/* ==================================================
    2. レイアウト & ヘッダー/フッター
   ================================================== */
.site-main,
.site-footer,
.post-nav-wrapper {
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
    padding: 0 1.5rem;
}

.site-main { margin: 4rem auto; }

/* --- ヘッダー --- */
.site-header { padding: 2.5rem 0 1.5rem; }

.header-inner {
    max-width: 720px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1.5rem;
}

/* --- サイトタイトル --- */
.site-title {
    margin: 0;
    line-height: 1.2em;
}

.site-title a {
    font-size: 1.5rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    display: inline-flex;
    align-items: center;
    gap: 0.6rem; /* 画像と文字の間の距離 */
    /*text-decoration: none;*/
}

.header-logo {
    /* 文字の高さに合わせると綺麗に収まります */
    height: 1.5em; 
    width: auto;
    flex-shrink: 0;
    vertical-align: middle;
    /*display: block;*/
}

/* --- ナビゲーション共通 --- */
.site-nav a,
.fixed-nav a,
.front-nav a {
    position: relative;
    color: var(--text-sub);
    text-decoration: none;
}

.site-nav a,
.fixed-nav a { font-size: 0.95rem; }

.front-nav { margin-bottom: 2rem; }
.front-nav a {
    font-size: 1.2rem;
    letter-spacing: 0.04em;
}
.fixed-nav { margin-bottom: 2rem; }

/* 下線アニメーション */
.site-nav a::after,
.fixed-nav a::after,
.front-nav a::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: -2px;
    width: 100%;
    height: 1px;
    background: currentColor;
    opacity: 0;
    transition: opacity 0.2s ease;
}
.site-nav a:hover::after,
.fixed-nav a:hover::after,
.front-nav a:hover::after {
    opacity: 0.6;
    color: var(--hover-line);
}

/* --- フッター --- */
.site-footer {
    margin: 6rem auto 3rem;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-meta);
}

@media screen and (max-width: 1024px) {
    .header-inner {
        display: grid;
        grid-template-columns: 1fr 1fr;
        /* 全体を中央に寄せる */
        justify-content: center; 
        /* 中身の要素を中央に寄せる */
        justify-items: center;   
        
        width: 100%;
        max-width: 320px; /* ここを少し広げたり狭めたりして微調整 */
        margin: 0 auto;   /* これが左右中央配置の要です */
        padding: 0;       /* 親要素の余白をリセット */
    }

    .site-title {
        grid-column: 1 / 3;
        text-align: center;
        width: 100%;
        margin-left: 0;   /* タイトルの左余白を消す */
        margin-right: 0;  /* タイトルの右余白を消す */
    }

    .site-nav {
        /* aタグ自体に元々ついているかもしれない余白をリセット */
        margin: 0; 
        padding: 0.5rem 0; 
        width: 100%;
        text-align: center;
        
        /* もしaタグに「display: inline-block」などがある場合、
           意図しない隙間ができるので、それを防ぐ */
        box-sizing: border-box;
    }
}

/* ==================================================
    3. 記事・コンテンツ共通 (.post-content)
   ================================================== */
.post-content .wp-block-table { border-bottom: none; }

.post-title {
    font-size: 2rem;
    margin-bottom: 3.5rem;
    letter-spacing: 0.01em;
}

.post-timestamp {
    font-size: 0.7rem;
    color: var(--text-meta);
    text-align: right;
    margin-bottom: 2.8rem;
}

.post-content {
    font-size: 0.95rem;
    line-height: 2.05;
}
.post-content p { margin-bottom: 2.2rem; }

.post-content h2 {
    font-size: 1.22rem;
    font-weight: 500;
    margin: 5.5rem 0 2.8rem;
}
.post-content h3 { font-weight: 600; }

.pause { margin: 3.5rem 0; }
.turn { margin: 4.5rem 0; font-weight: 500; }

/* Blockquote */
blockquote p { margin: 0; }
blockquote br { display: block; margin-bottom: 0.6em; }
blockquote { color: var(--text-sub); } /* Default color */

/* 画像・動画・埋め込みすべてを16:9にする */
/* 1. 画像そのものの設定 */
/* .post-content img { */
    /* display: block; */
    /* width: 100%; 強制的に横幅いっぱいに広げる */
    /* max-width: 100%; */
    /* aspect-ratio: 16 / 9; */
    /* object-fit: cover;      16:9の枠に合わせて画像を切り取る */
    /* margin: 4rem auto;      上下に余白、左右は中央 */
/* } */

.post-content img {
    /* 1. 枠（窓）の設定 */
    width: 100%;            /* 親要素の幅いっぱいに拡大・縮小する */
    max-width: 100%;
    aspect-ratio: 16 / 9;   /* 常に16:9の「窓」を維持 */
    
    /* 2. 中身（画像）の設定 */
    object-fit: contain;    /* 画像を一切切り取らず、16:9の枠の中に収める */
    
    /* 3. レイアウトの設定 */
    display: block;
    margin: 4rem auto;
    
    /* 4. 隙間の処理 (重要) */
    background-color: transparent; /* 背景を透かして「空間」として見せる */

    /* 画像を16:9の枠内の「真ん中」に置く指示 */
    object-position: center;

    /* 5-a. 装飾（庭のエッセンスを反映） */
    background-color: #f0f0f0; /* 庭の背景よりわずかに濃い色 */
    border: 1px solid rgba(0,0,0,0.03); 
    padding: 20px; /* 写真の周りに意図的な余白を作る */
    box-sizing: border-box;

    /* 5-b. 額縁（マット）のデザイン */
    /* padding: 30px; 16:9の枠の中に意図的な余白を作る */
    /* background-color: #f2f2f2; 庭の背景(#fafafa)より、一段だけ落ち着いた色 */
    /* box-sizing: border-box; */
    /* border: 1px solid rgba(0,0,0,0.02); 境界線をうっすら引く */

    /* 6-a. 軽い影をつけて浮いているように見せる */
    /* filter: sepia(10%) contrast(95%) brightness(105%);  */
    /* ほんの少し温かみを出し、コントラストを和らげる */

    /* 6-b. 光のトーン（統一感の正体） */
    filter: 
        brightness(1.02) /* わずかに光を足す（太陽の解放区） */
        contrast(0.9)    /* コントラストを抑えて目に優しく */
        saturate(0.8);   /* 彩度を2割削って、落ち着いた印象に */
        
    transition: filter 0.5s ease; /* ホバー時に変化させるための準備 */
}

    /* 7. [オプション] 読み手が写真に注目した時だけ、色が戻る演出 */
.post-content img:hover {
    filter: brightness(1) contrast(1) saturate(1); /* 本来の色に戻る */
}

/* 2. WordPressの画像囲み（figureタグ）への対策 */
.post-content figure {
    margin: 4rem 0;         /* figure自体の左右マージンを0にして100%幅を確保 */
    width: 100%;
    max-width: 100%;
    text-align: center;     /* キャプションがある場合のための中央寄せ */
}

/* 3. 動画・埋め込み（iframe）も同様に */
.post-content video,
.post-content iframe,
.post-content .wp-block-embed__wrapper {
    width: 100%;
    aspect-ratio: 16 / 9;
    height: auto;
    margin: 4rem auto;
}

/* ==================================================
    4. テンプレート別スタイル
   ================================================== */
/* --- Thought --- */
.template-thought-post p { line-height: 2.05; }
.template-thought-post blockquote {
    margin: 4rem 0;
    padding-left: 1.5rem;
    border-left: 3px solid #bbb;
    font-style: italic;
    color: #555; /* Override specific to this template if needed, or use var */
}
@media (prefers-color-scheme: dark) {
    .template-thought-post blockquote { color: #aaa; }
}

/* --- Tech --- */
.template-tech-post p {
    line-height: 1.7;
    margin-bottom: 1.9em;
}
.template-tech-post pre,
.template-tech-post code {
    font-family: var(--font-mono);
    font-size: 0.95em;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.template-tech-post code {
    background: rgba(0,0,0,0.05);
    padding: 0.15em 0.4em;
    border-radius: 4px;
}
.template-tech-post pre {
    margin: 2rem 0 3.5rem;
    padding: 1.2rem 1.4rem;
    background: var(--code-bg);
    border: 1px solid var(--code-border);
    border-radius: 4px;
    overflow-x: auto;
}
/* Dark mode specifics for code inline */
@media (prefers-color-scheme: dark) {
    .template-tech-post code { background: rgba(255,255,255,0.1); }
}

/* --- Diary --- */
.template-diary-post h3 {
    position: relative;
    padding-left: 1.2rem;
}
.template-diary-post h3::before {
    content: "•";
    position: absolute;
    left: 0;
    opacity: 0.5;
}
.template-diary-post p {
    line-height: 1.9;
    letter-spacing: 0.015em;
}
.template-diary-post blockquote {
    border-left: 2px dotted currentColor;
    opacity: 0.6;
}
/* Drop cap */
.template-diary-post .post-content p:first-of-type::first-letter {
    float: left;
    font-size: 1.6em;
    margin-right: 0.1em;
}
.template-diary-en-post .post-content p:first-of-type::first-letter {
    font-size: 3.4em;
}

/* --- Fixed Pages (About / Listen) --- */
.post-fixed.about ul {
    list-style: none;
    padding: 0;
    margin: 2.5rem 0 4rem;
}
.post-fixed.about li { margin-bottom: 0.8rem; }
.post-fixed.about li + li { margin-top: 0.9rem; }
.post-fixed.about { padding-bottom: 4rem; }

.fixed-nav a,
.post-fixed.about a,
.post-fixed.listen a {
    font-size: 0.95rem;
    color: inherit;
    letter-spacing: 0.02em;
    opacity: 0.85;
    transition: opacity 0.2s ease;
}
.post-fixed.about a:hover,
.post-fixed.listen a:hover {
    opacity: 1;
}

/* --- Fixed Pages (Archives) --- */
.archive-year {
    font-size: 1.2rem;
    font-weight: 400;
    letter-spacing: 0.1em;
    margin-bottom: 0.3rem; /* サブタイトルとの距離を詰める */
}

/* サブタイトル：独自のクラスで「庭」のエッセンスを表現 */
.archive-year-subtitle {
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--text-sub); /* 既存の変数を使用 */
    opacity: 0.85;
    margin-bottom: 1.8rem; /* 下の月リストとの距離 */
    letter-spacing: 0.08em;
    font-style: italic; /* 少し修辞的なニュアンス */
}

/* 月リストの調整 */
.archive-month-list {
    display: flex;
    flex-wrap: wrap; 
    /* gap（隙間）を調整。左右の余白を考慮 */
    gap: 1.5rem 2%; 
    padding-left: 0.2rem;
    list-style: none;
    margin: 0 0 4rem 0;
}

.archive-month-list li {
    /* 1行に6個並べる計算： (100% / 6) - (隙間の調整分) */
    /* 15% 前後に設定すると、ちょうど6個並んで7個目で折り返されます */
    width: 15%; 
    min-width: 80px; /* スマホなどで潰れすぎないための保険 */
    box-sizing: border-box;
}

/* 7月以降（7個目以降）の見た目に変化をつけたい場合はここ（任意） */
/* .archive-month-list li:nth-child(n+7) { ... } */

.archive-month-list li a {
    display: block; /* クリック領域を広げる */
    font-size: 0.9rem;
    color: var(--text-sub);
    transition: color 0.2s ease;
    white-space: nowrap; /* 月と件数が離れないように */
}

.archive-month-list li a:hover {
    color: var(--text-main); /* 既存の変数を使用 */
    text-decoration: underline;
}

.post-count {
    font-size: 0.75rem;
    opacity: 0.65;
    margin-left: 0.2rem;
    font-feature-settings: "tnum"; /* 数字の幅を揃えて整列させる */
}

/* ホバー時にリンクと一緒に少しだけ色が濃くなる演出 */
.archive-month-list li a:hover .post-count {
    opacity: 0.6;
}

/* ==================================================
    5. テーブル
   ================================================== */
.post-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 2rem 0;
    font-size: 0.9rem;
    line-height: 1.6;
    border: 1px solid transparent; /* Placeholder for dark mode structure */
}

@media (prefers-color-scheme: dark) {
    .post-content table { border-color: #444; color: #ddd; }
}

.post-content th {
    font-weight: 500;
    text-align: left;
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid var(--border-color);
    opacity: 0.8;
}

/* --- 偶数行 (Even) に薄い色をつける --- */
.post-content tr:nth-child(even) {
    background-color: rgba(0, 0, 0, 0.01); /* 白(#fafafa)に近い、ごく淡いグレー */
}

/* --- ホバー時に一行を際立たせる (オプション) --- */
/* .post-content tr:hover {
    background-color: rgba(0, 0, 0, 0.03);
    transition: background-color 0.2s ease;
} */

@media (prefers-color-scheme: dark) {
    .post-content th {
        background-color: #333;
        color: #fff;
        border-color: #555;
        opacity: 0.85;
    }
}

.post-content td {
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid var(--border-color);
    font-weight: 400;
}

/* @media (prefers-color-scheme: dark) {
    .post-content tr:nth-child(even) td { background-color: #222; border-color: #555; }
    .post-content tr:nth-child(odd) td { background-color: #1a1a1a; border-color: #555; }
} */

@media (prefers-color-scheme: dark) {
    /* 本文の偶数行：#222 */
    .post-content tbody tr:nth-child(even) td {
        background-color: #222;
    }
    /* 本文の奇数行：#1a1a1a */
    .post-content tbody tr:nth-child(odd) td {
        background-color: #1a1a1a;
    }
    /* 見出し行：#222（偶数行と同じ色に固定） */
    /* .post-content thead th {
        background-color: #222;
    } */
}

.post-content tr:last-child td { border-bottom: none; }
.post-content table + p { margin-top: 1.5rem; }
/* ==================================================
    6. サイドバー / アーカイブ / 記事一覧
   ================================================== */
.content-and-sidebar-wrap {
    display: flex;
    gap: 60px;
}

.main-content {
    flex: 1;
    min-width: 0;
}

.site-sidebar {
    width: 80px;
    overflow: visible;
}

/* ウィジェットメニュー */
.site-sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0;
}
.site-sidebar li {
    font-size: 0.85rem;
    margin-bottom: 0.8rem;
    line-height: 1.4;
}

.site-sidebar a:hover {
    color: var(--text-sub);
    background: var(--sidebar-hover-bg);
    border-radius: 4px;
    padding-left: 8px; /* Slide animation */
    transition: all 0.3s ease;
}
@media (prefers-color-scheme: dark) {
    .site-sidebar a:hover { color: #fff; }
}

/* ツリー構造 (Sub-menu) */
.site-sidebar .sub-menu {
    display: block;
    visibility: visible;
    opacity: 1;
    margin-top: 0.5rem;
    margin-left: 0.5rem;
    padding-left: 0.8rem;
    border-left: 1px dotted var(--border-color);
}
.site-sidebar .sub-menu li {
    font-size: 0.78rem;
    margin-bottom: 0.4rem;
    opacity: 0.85;
}

/* 親項目（リンクなし） */
/* .site-sidebar a[href="#"] {
    cursor: default;
    display: block;
    pointer-events: none;
} */

/* Ajax Load More Button */
#load-more {
    display: block;
    margin: 3.5rem auto 0;
    background: none;
    border: none;
    font-size: 0.9rem;
    letter-spacing: 0.08em;
    opacity: 0.55;
    cursor: pointer;
    text-align: center;
    color: inherit;
}
#load-more:hover { opacity: 1; }

/* ページナビゲーション */
.post-nav {
    margin: 6rem 0 4rem;
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-sub);
}
.post-nav-link {
    display: inline-block;
    margin: 0.5rem 1rem;
}
.post-nav-link.index { font-weight: 500; }
.post-nav-link:hover { color: var(--text-main); }

/* ==================================================
    7. アニメーションユーティリティ
   ================================================== */
@media (prefers-reduced-motion: no-preference) {
    .fade-target {
        opacity: 0;
        transform: translateY(12px);
        transition: opacity 0.6s ease-out, transform 0.6s ease-out;
    }
    .fade-target.is-visible {
        opacity: 1;
        transform: translateY(0);
    }
}
@media (prefers-reduced-motion: reduce) {
    .fade-target {
        opacity: 1 !important;
        transform: none !important;
        transition: none !important;
    }
}

/* ==================================================
    8. レスポンシブデザイン (Mobile)
   ================================================== */
@media (max-width: 767px) {
    /* --- レイアウト変更: 縦積み --- */
    .content-and-sidebar-wrap {
        flex-direction: column;
        display: flex;
        gap: 20px;
    }
    .main-content, .site-sidebar { width: 100%; flex: auto; }

    /* --- サイドバー調整 --- */
    .site-sidebar {
        margin-top: 4rem;
        text-align: center;
    }
    .site-sidebar ul { display: block; }
    .site-sidebar a {
        font-size: 0.95rem;
        display: inline-block;
        padding: 0.2rem 0;
    }
    .site-sidebar a[href="#"] { pointer-events: none; }

    /* モバイルでのサブメニューツリー */
    .site-sidebar .sub-menu {
        display: inline-block;
        text-align: left;
        margin: 0.5rem 0 1.5rem 1rem;
        padding-left: 1rem;
    }
    .site-sidebar .sub-menu li a::before {
        content: "– ";
        opacity: 0.4;
    }

    /* --- ヘッダー & ナビゲーション (中央揃え・2カラム) --- */
    /* PCサイズ以上（例えば1025px〜）の時だけ、この設定を活かす */
　@media screen and (min-width: 1025px) {
   　 .header-inner {
       　 display: flex;
        　flex-wrap: wrap;
        　justify-content: center;
        　gap: 15px 0;
        　padding: 0 1rem;
    　}
　}

    /* 4つのnavを2列のグリッド状に配置 */
    /*.site-nav {
        /*flex: 0 0 50%;*/ /* ちょうど半分 */
        /*display: block;
        margin: 0;
        text-align: center;
    }*/

    /* リンク(a)の設定：枠を消して下線を復活 */
    .site-nav a {
        display: inline-block; /* 幅いっぱいではなくテキスト分のみ */
        padding: 8px 0;
        background: none;      /* 背景（枠）を消去 */
        border-radius: 0;
        font-size: 0.9rem;
        /* color: var(--text-sub); */
    }

    /* モバイルでも下線アニメーションを有効化 */
    .site-nav a::after {
        content: '';
        position: absolute;
        left: 0;
        bottom: 2px; /* 下線の位置調整 */
        width: 100%;
        height: 1px;
        background: currentColor;
        /* opacity: 0.4; モバイルでは最初から少し見えていても良いかもしれません */
        display: block;
    }

　/* ダークモード */
    @media (prefers-color-scheme: dark) {
        .site-nav a {
            background: none;
        }
    }

    /* --- 共通レイアウト調整 --- */
    .site-main { margin: 2rem auto; }
    .header-inner, .site-footer, .post-nav-wrapper { padding: 0 1rem; }

    /* タイトル改行制御 */
    /*.site-title a {
        display: block;
        word-break: keep-all;
        overflow-wrap: break-word;
        line-height: 1.4em;
    }*/

    .post-timestamp { margin-bottom: 1.0rem; }
    #load-more { display: none; }

    /* --- Archives (Mobile) --- */
    .archive-month-list {
        justify-content: center;
        gap: 1rem 2rem;
    }

    /* --- はみ出し防止 --- */
    .post-item .index-title,
    .post-item .post-timestamp,
    .post-content {
        word-wrap: break-word;
        overflow-wrap: break-word;
        width: 100%;
        box-sizing: border-box;
    }
    .post-item, .post-content { overflow-x: hidden; }
}

@media (max-width: 480px) {
    .site-header .site-title {
        font-size: 1.1rem;
        padding: 10px 0;
    }
}