/*
Theme Name: Smart Study Theme
Description: 大学受験向け学習法サイトのオリジナルテーマ
Version: 1.0
Author: Your Name
*/

/* Google Fontsの読み込み */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;500;700&family=Noto+Serif+JP:wght@400;700&display=swap');

/* 全体のリセットとベース設定 */
body { margin: 0; padding: 0; }
.mag-top-wrapper { font-family: 'Noto Sans JP', sans-serif; color: #333; line-height: 1.6; }

/* ヒーローセクション */
.mag-hero {
  position: relative; height: 60vh; min-height: 400px;
  background-image: url('https://picsum.photos/id/180/1200/800'); /* トップ画像のURLに変更してください */
  background-size: cover; background-position: center;
  display: flex; align-items: center; justify-content: center; margin-bottom: 80px;
}
.mag-hero::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255, 255, 255, 0.5);
}
.mag-hero-content {
  position: relative; z-index: 1; text-align: center;
  background: rgba(255, 255, 255, 0.9); padding: 40px 60px; box-shadow: 0 10px 30px rgba(0,0,0,0.05);
}
.mag-hero-title { font-family: 'Noto Serif JP', serif; font-size: 2.5rem; letter-spacing: 0.1em; margin-bottom: 10px; color: #2c3e50; }
.mag-hero-subtitle { font-size: 1rem; color: #555; letter-spacing: 0.05em; }

/* セクション共通 */
.mag-section { max-width: 1000px; margin: 0 auto 100px; padding: 0 20px; }
.mag-section.mag-bg-gray { background-color: #f8f9fa; max-width: 100%; padding: 60px 20px; }
.mag-inner { max-width: 1000px; margin: 0 auto; }
.mag-section-title { font-family: 'Noto Serif JP', serif; font-size: 2rem; text-align: center; margin-bottom: 50px; color: #2c3e50; }
.mag-section-title span { display: block; font-family: 'Noto Sans JP', sans-serif; font-size: 0.8rem; color: #888; margin-top: 5px; letter-spacing: 0.1em; }

/* カードレイアウト */
.mag-card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 40px 30px; }
.mag-card { text-decoration: none; color: #333; display: block; transition: transform 0.3s ease; }
.mag-card:hover { transform: translateY(-5px); }
.mag-card-img { width: 100%; aspect-ratio: 3 / 2; background-size: cover; background-position: center; position: relative; margin-bottom: 15px; background-color: #eee; }
.mag-cat-badge { position: absolute; top: 0; left: 0; background-color: #2c3e50; color: #fff; font-size: 0.75rem; padding: 5px 12px; letter-spacing: 0.05em; }
.mag-date { font-size: 0.8rem; color: #999; display: block; margin-bottom: 5px; }
.mag-card-title { font-size: 1.1rem; line-height: 1.5; font-weight: 500; margin: 0; }

/* 科目別ボタン */
.mag-subject-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 15px; }
.mag-subject-btn { display: inline-block; padding: 15px 30px; background: #fff; border: 1px solid #ddd; color: #333; text-decoration: none; text-align: center; min-width: 120px; transition: all 0.3s ease; }
.mag-subject-btn:hover { border-color: #2c3e50; background: #2c3e50; color: #fff; }
.mag-subject-btn span { display: block; font-size: 0.8rem; margin-top: 5px; color: inherit; }

/* JSアニメーション用 */
.js-fade-in { opacity: 0; transform: translateY(20px); transition: opacity 0.8s ease, transform 0.8s ease; }
.js-fade-in.is-show { opacity: 1; transform: translateY(0); }

/* --- 共通ヘッダー・フッター --- */
.site-header { background: #fff; padding: 20px; border-bottom: 1px solid #eee; }
.site-header-inner { max-width: 1000px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; }
.site-logo a { font-family: 'Noto Serif JP', serif; font-size: 1.5rem; color: #2c3e50; text-decoration: none; font-weight: bold; }
.site-footer { background: #2c3e50; color: #fff; text-align: center; padding: 30px 20px; margin-top: 100px; }
.copyright { font-size: 0.8rem; letter-spacing: 0.05em; }

/* --- 記事詳細ページ (single.php) --- */
.mag-single-wrapper { max-width: 800px; margin: 60px auto 100px; padding: 0 20px; }
.mag-article-header { text-align: center; margin-bottom: 40px; }
.single-badge { position: relative; display: inline-block; margin-bottom: 15px; }
.mag-article-title { font-family: 'Noto Serif JP', serif; font-size: 2.2rem; line-height: 1.4; color: #2c3e50; margin-bottom: 15px; }
.mag-article-thumb { margin-bottom: 40px; text-align: center; }
.mag-article-thumb img { max-width: 100%; height: auto; border-radius: 4px; }

/* 記事本文内のデザイン調整 */
.mag-article-content { font-size: 1.05rem; line-height: 1.8; color: #333; }
.mag-article-content h2 { font-family: 'Noto Serif JP', serif; font-size: 1.6rem; color: #2c3e50; border-bottom: 2px solid #2c3e50; padding-bottom: 10px; margin: 50px 0 20px; }
.mag-article-content h3 { font-size: 1.3rem; border-left: 4px solid #2c3e50; padding-left: 10px; margin: 40px 0 20px; }
.mag-article-content p { margin-bottom: 20px; }
.mag-article-content img { max-width: 100%; height: auto; margin: 30px 0; }

/* --- カテゴリー・アーカイブページ --- */
.mag-archive-header { margin-bottom: 50px; text-align: center; }
.mag-archive-desc { margin-top: -20px; margin-bottom: 40px; font-size: 0.95rem; color: #555; }

/* ページネーション（ページ送り）のデザイン */
.mag-pagination { margin-top: 60px; text-align: center; }
.mag-pagination .nav-links { display: inline-flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.mag-pagination .page-numbers { display: inline-block; padding: 10px 15px; border: 1px solid #ddd; color: #333; text-decoration: none; transition: all 0.3s ease; background: #fff; }
.mag-pagination .page-numbers:hover,
.mag-pagination .page-numbers.current { background: #2c3e50; color: #fff; border-color: #2c3e50; }
.mag-pagination .screen-reader-text { display: none; /* リーダー用の非表示テキスト */ }

/* --- グローバルナビゲーション（ドロップダウン対応） --- */
.global-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
}
.global-nav li {
    position: relative; /* 子メニューの基準位置 */
}
.global-nav li a {
    display: block;
    padding: 15px 20px;
    color: #333;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    transition: background 0.3s;
}
.global-nav li a:hover {
    background: #f8f9fa;
}

/* 階層メニュー（子カテゴリー）を最初は隠す */
.global-nav li ul {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    width: 200px; /* ドロップダウンの幅 */
    background: #fff;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    flex-direction: column;
    z-index: 100;
}
/* マウスオーバーで子カテゴリーを表示 */
.global-nav li:hover > ul {
    display: flex;
}
/* ドロップダウン内のリンク調整 */
.global-nav li ul li a {
    padding: 12px 20px;
    font-size: 0.85rem;
    border-bottom: 1px solid #eee;
}
/* 孫階層のメニューを右側に展開する */
.global-nav li ul li ul {
    top: 0;
    left: 100%;
}

/* --- トップページ：ポータルグリッド --- */
.portal-grid {
    display: grid;
    /* パソコンでは3列、スマホでは1〜2列に自動調整 */
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 30px;
    margin-top: 20px;
}
.portal-card {
    background: #fff;
    padding: 30px 20px;
    border-radius: 8px;
    text-align: center;
    text-decoration: none;
    color: #333;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    transition: all 0.3s ease;
    border: 1px solid #eee;
}
.portal-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
    border-color: #2c3e50;
}
.portal-icon {
    font-size: 2.5rem;
    margin-bottom: 15px;
}
.portal-title {
    font-family: 'Noto Serif JP', serif;
    font-size: 1.2rem;
    color: #2c3e50;
    margin: 0 0 10px;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 10px;
    display: inline-block;
}
.portal-desc {
    font-size: 0.85rem;
    color: #666;
    line-height: 1.5;
    margin: 0;
}

/* --- パンくずリスト --- */
.breadcrumb {
    max-width: 1000px;
    margin: 20px auto;
    padding: 0 20px;
    font-size: 0.85rem;
    color: #666;
}
.breadcrumb ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}
.breadcrumb li {
    margin-right: 5px;
}
.breadcrumb li a {
    color: #2c3e50;
    text-decoration: none;
    transition: color 0.3s;
}
.breadcrumb li a:hover {
    color: #000;
    text-decoration: underline;
}

/* --- トップページ以外の画像調整（少し高さを抑える） --- */
body:not(.home) .mag-hero {
    height: 30vh;
    min-height: 200px;
    margin-bottom: 20px;
}

/* --- X (旧Twitter) アイコンのデザイン --- */
/* フッター用 */
.social-icon-x {
    display: inline-flex;
    align-items: center;
    color: #fff; /* フッターの背景が暗い場合は白 */
    text-decoration: none;
    transition: opacity 0.3s ease;
}
.social-icon-x:hover {
    opacity: 0.7;
}

/* ヘッダー用 */
.social-icon-x-header {
    display: inline-flex;
    align-items: center;
    color: #333; /* ヘッダーの背景が明るい場合は黒・ダークグレー */
    transition: color 0.3s ease;
}
.social-icon-x-header:hover {
    color: #666;
}

/* --- 全体の2カラムレイアウト --- */
.site-wrapper {
    display: flex;
    max-width: 1200px; /* サイト全体の幅 */
    margin: 0 auto;
    align-items: flex-start; /* サイドバーが下に伸びすぎないようにする */
}
.site-main {
    flex-grow: 1;
    width: calc(100% - 280px); /* サイドバーの幅を引いたサイズ */
    padding: 20px 30px;
    background: #fff; /* メインエリアの背景白 */
}

/* --- サイドバーのデザイン --- */
.site-sidebar {
    width: 280px;
    flex-shrink: 0;
    background: #fff;
    border-right: 1px solid #eee;
    padding-bottom: 30px;
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar-logo a {
    display: block;
    background: #b71c1c; /* 画像のような濃い赤 */
    color: #fff;
    font-size: 1.5rem;
    font-weight: bold;
    text-align: center;
    padding: 20px 10px;
    text-decoration: none;
    font-family: sans-serif;
}
.sidebar-nav ul { list-style: none; padding: 0; margin: 0; }
.sidebar-nav li { border-bottom: 1px solid #eee; }
.sidebar-nav a {
    display: flex;
    align-items: center;
    justify-content: space-between; /* テキストと矢印を両端に */
    padding: 15px 20px;
    color: #333;
    text-decoration: none;
    font-size: 0.95rem;
    transition: background 0.2s;
}
.sidebar-nav a::after {
    content: "〉"; /* 右側の矢印 */
    color: #333; /* #cccから濃いグレーに変更 */
    font-size: 1rem; /* 少し大きく */
    font-weight: bold;
}
.sidebar-nav a:hover { background: #f9f9f9; color: #b71c1c; }

/* バナーボタン */
.sidebar-banner { padding: 20px; }
.banner-btn {
    display: block;
    background: #0277bd;
    color: #fff;
    text-align: center;
    padding: 15px;
    border-radius: 5px;
    text-decoration: none;
    font-weight: bold;
}
.banner-btn span { font-size: 0.8rem; font-weight: normal; }

/* --- 右側のタブ型グローバルナビゲーション --- */
.tab-nav { margin-bottom: 20px; border-bottom: 3px solid #b71c1c; }
.tab-nav ul { display: flex; list-style: none; padding: 0; margin: 0; }
.tab-nav li { flex: 1; text-align: center; }
.tab-nav a {
    display: block;
    padding: 12px 10px;
    background: #e0e0e0;
    color: #333;
    text-decoration: none;
    font-weight: bold;
    font-size: 0.9rem;
    border-radius: 5px 5px 0 0;
    margin-right: 2px;
}
.tab-nav a:hover, .tab-nav .current-menu-item a {
    background: #b71c1c;
    color: #fff;
}

/* --- スマホ対応（1カラムに戻す） --- */
.mobile-only-header { display: none; } /* PCでは上部ヘッダーを隠す */

@media screen and (max-width: 768px) {
    .site-wrapper { flex-direction: column; }
    .site-sidebar { width: 100%; border-right: none; border-bottom: 2px solid #b71c1c;
	position: static; 
        height: auto; 
        overflow-y: visible; }
    .site-main { width: 100%; padding: 15px; }
    .mobile-only-header { display: block; }
    .sidebar-logo { display: none; } /* スマホでは上部ヘッダーにロゴが出るのでサイドバーのロゴは消す */
    .tab-nav ul { flex-wrap: wrap; }
    .tab-nav li { min-width: 50%; margin-bottom: 2px; }
}

/* --- サイドバーの子メニュー（アコーディオン） --- */

/* 1. 子メニューを持つ親の矢印を下向き（∨）にする */
.sidebar-nav li.menu-item-has-children > a::after {
    content: "∨"; 
    color: #333; /* こちらも濃いグレーに */
    font-weight: bold; /* 太字にする */
    transform: rotate(0deg);
    transition: transform 0.3s ease;
}
/* 開いた時は矢印を上向き（∧）にする */
.sidebar-nav li.menu-item-has-children.is-open > a::after {
    transform: rotate(180deg);
}

/* 2. 子メニューを包む枠（最初は隠しておく） */
.sidebar-nav .sub-menu {
    display: none; /* 初期状態は非表示 */
    padding: 10px;
    background: #f9f9f9;
    border-bottom: 1px solid #eee;
}

/* 3. クラスが付いて「開いた時」はグリッド（3列）で表示する */
.sidebar-nav li.is-open > .sub-menu {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* 3列に均等割り */
    gap: 5px; /* ボタン同士の隙間 */
}

/* 4. 子メニューの各ボタンのデザイン */
.sidebar-nav .sub-menu li {
    border-bottom: none; /* 親の線を消す */
}
.sidebar-nav .sub-menu a {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px 5px;
    font-size: 0.8rem;
    font-weight: bold;
    color: #fff !important; /* 文字は白 */
    border-radius: 3px;
    text-align: center;
}
.sidebar-nav .sub-menu a::after {
    content: none; /* 子メニューには矢印を出さない */
}

/* 5. 画像のように順番に色を変える魔法のコード */
.sidebar-nav .sub-menu li:nth-child(6n+1) a { background: #8e24aa; } /* 1番目: 紫 */
.sidebar-nav .sub-menu li:nth-child(6n+2) a { background: #1976d2; } /* 2番目: 青 */
.sidebar-nav .sub-menu li:nth-child(6n+3) a { background: #c62828; } /* 3番目: 赤 */
.sidebar-nav .sub-menu li:nth-child(6n+4) a { background: #f57c00; } /* 4番目: オレンジ */
.sidebar-nav .sub-menu li:nth-child(6n+5) a { background: #fbc02d; } /* 5番目: 黄色 */
.sidebar-nav .sub-menu li:nth-child(6n+6) a { background: #2e7d32; } /* 6番目: 緑 */

/* --- 横スクロール（はみ出し）防止 --- */
.site-wrapper, .site-sidebar, .site-main {
    box-sizing: border-box;
    max-width: 100%;
    overflow-x: hidden;
}

/* =========================================
   スマホでの文字サイズ最適化（強制上書き版）
========================================= */
@media screen and (max-width: 768px) {
    
    /* 1. 本文（段落やリストなど）の文字サイズを強制的に小さくする */
    .site-main p, 
    .site-main div, 
    .site-main li,
    .site-main span {
        font-size: 15px !important; /* ここを14pxや16pxにして調整可能です */
        line-height: 1.8 !important;
    }

    /* 2. 記事のタイトル（一番大きい見出し）を小さくする */
    .site-main h1, 
    .mag-hero-title {
        font-size: 22px !important; /* PCよりだいぶ小さめに設定 */
        line-height: 1.4 !important;
        margin-bottom: 15px !important;
    }

    /* 3. 本文中の見出し（H2やH3）もバランスよく小さくする */
    .site-main h2 {
        font-size: 18px !important;
    }
    .site-main h3 {
        font-size: 16px !important;
    }
    /* --- スマホで表（テーブル）を横スクロールさせる --- */
    .site-main table {
        display: block !important;
        width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch; /* iPhoneでのスクロールを滑らかにする */
        white-space: nowrap; /* セル内の文字を無理に改行させない */
    }
}

/* --- 記事一覧カードのアイキャッチ画像を切り取らず全体表示する --- */
.mag-card-img {
    background-size: contain !important; /* 画像全体を枠内に収める */
    background-repeat: no-repeat !important; /* 画像が足りない部分で繰り返されるのを防ぐ */
    background-position: center !important; /* 画像を中央に配置する */
    background-color: #f5f5f5 !important; /* 画像の左右や上下にできる余白の色（薄いグレー） */
}