/* ==========================================
   1. 基本設定・背景 (Base & Pattern)
   ========================================== */
body {
    margin: 0; padding: 0; font-family: sans-serif; height: auto;
    /* 背景パターンA: 方眼紙 */
    background-image: linear-gradient(#f0f0f0 1px, transparent 1px), 
                      linear-gradient(90deg, #f0f0f0 1px, transparent 1px);
    background-size: 20px 20px; background-color: #fff;
}

/* コンテンツ全体の基本設定 */
.content {
    max-width: 800px; margin: 0 auto; padding: 80px 20px 40px;
    line-height: 1.6; color: #333; min-height: 100vh;
}

.content h1 { font-size: 1.4rem; margin-bottom: 15px; padding-bottom: 5px; }

.content h2 {
    font-size: 1.2rem; color: #444; background-color: #f4f4f4;
    padding: 8px 15px; border-left: 5px solid #333; margin-bottom: 15px; border-radius: 2px;
}

.content p { margin-top: 0; margin-bottom: 10px; text-align: justify; word-break: break-word; }
.content i { font-style: italic; }

/* 共通のリンク設定 */
.content a { color: #007bff; text-decoration: underline; transition: 0.3s; }
.content a:hover { color: #0056b3; text-decoration: none; }

/* ==========================================
   2. ヘッダー・ロゴ・メニュー (Navigation)
   ========================================== */
.header {
    position: fixed; top: 0; left: 0; width: 100%; height: 60px;
    background-color: #333; z-index: 1000;
    display: flex; align-items: center; padding-left: 20px;
    color: white; box-sizing: border-box;
}

.logo {
    color: white; text-decoration: none; font-weight: bold;
    font-size: clamp(14px, 3vw, 20px); white-space: nowrap; line-height: 1;
    transition: all 0.3s ease; display: inline-block;
}
.logo:hover { color: #e8f80b; opacity: 0.8; transform: translateY(-1px); }
.logo:active { transform: scale(0.95); transition: 0.1s; }

/* ハンバーガーアイコン */
.hamburger-menu { position: fixed; top: 15px; right: 15px; width: 30px; height: 25px; z-index: 9999; cursor: pointer; }
.hamburger-menu span { position: absolute; left: 0; width: 100%; height: 2px; background-color: #fff; transition: 0.4s; }
.hamburger-menu span:nth-child(1) { top: 0; }
.hamburger-menu span:nth-child(2) { top: 11px; }
.hamburger-menu span:nth-child(3) { top: 22px; }
.hamburger-menu.active span:nth-child(1) { transform: translateY(11px) rotate(45deg); }
.hamburger-menu.active span:nth-child(2) { opacity: 0; }
.hamburger-menu.active span:nth-child(3) { transform: translateY(-11px) rotate(-45deg); }

/* メニュー画面 */
.nav-wrapper {
    position: fixed; top: 0; left: 0; width: 100%; height: 100vh;
    background: rgba(0, 0, 0, 0.9); z-index: 9000;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; visibility: hidden; transition: 0.5s;
}
.nav-wrapper.is-open { opacity: 1; visibility: visible; }
.nav-list { list-style: none; text-align: center; padding: 0; }
.nav-list a { color: white; text-decoration: none; font-size: 24px; display: block; padding: 15px; }

/* ==========================================
   3. 論文・DIY・図表 (Papers & Media)
   ========================================== */
/* 論文リストの区切り線 */
.publication-item { margin-bottom: 15px; border-bottom: 1px dotted #ddd; padding-bottom: 15px; }

/* 要旨ボックス */
.abstract { background-color: #f4f2f2; padding: 10px 15px; margin-top: 5px; border-left: 5px solid #393838; }

/* 画像並び (共通) */
.tight-group { display: flex; justify-content: center; align-items: flex-start; gap: 15px; margin: 30px auto; flex-wrap: wrap; width: 100%; }
.tight-group img {
    display: block; width: 150px; height: auto; padding: 3px; background-color: #fff;
    border: 1px solid #ccc; border-radius: 4px; box-shadow: 0 2px 5px rgba(0,0,0,0.1); transition: 0.3s;
}
/* .tight-group img:hover { border-color: #007bff; transform: scale(1.05); z-index: 10; } ****************************************************/

/* 画像とキャプションセット (item-set) */
.item-set { margin: 0; width: 300px; max-width: 100%; text-align: center; }
.item-set img {
    display: block; width: 100%; height: 200px; object-fit: cover;
    border: 1px solid #ccc; border-radius: 4px; padding: 5px; background: #fff; box-sizing: border-box;
}

/* --- 1枚並びのキャプション設定（これを基準にする） --- */
.single-image figcaption { 
    display: block;
    margin: 10px auto 0; /* 上に10pxの余白 */
    font-size: 0.9rem; 
    color: #666; 
    line-height: 1.4; 
    text-align: center;
    font-weight: normal; /* ★太字を解除 */
}

/* --- 2枚並びのキャプション設定（1枚並びに合わせる） --- */
.item-set figcaption {
    margin-top: 10px;    /* 上に10pxの余白 */
    font-size: 0.9rem;   /* 0.85remから0.9remに統一 */
    color: #666;         /* #333から#666に統一 */
    line-height: 1.4;    /* 1.2から1.4に統一 */
    text-align: center;
    font-weight: normal; /* ★太字を解除して統一 */
    
    /* 画像の高さがズレないための最低限の高さ確保のみ残す */
    min-height: 2.8em; 
    display: block;      /* flexからblockに戻して1枚並びと同じ挙動に */
}

/* 写真1枚 & 詳細画像 */
.single-image, .detail-img { 
    margin: 30px auto; 
    max-width: 500px; 
    width: 100%;       /* 幅を確保 */
    text-align: center; /* 中の要素を中央寄せ */
}

/* 画像本体の中央寄せを確実に */
.single-image img, .detail-img { 
    width: 100%; 
    height: auto; 
    border: 1px solid #ccc; 
    border-radius: 5px; 
    display: block; 
    margin: 0 auto 10px; /* ★画像自体を中央に置き、下に余白を作る */
    box-shadow: 0 4px 10px rgba(0,0,0,0.1); 
}

/* テーブル & ダウンロード */
.table-wrapper { width: 100%; overflow-x: auto; margin: 20px 0; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; min-width: 400px; }
th, td { border: 1px solid #ddd; padding: 10px; text-align: left; font-size: 0.9rem; }
th { background-color: #f4f4f4; }

.download-item { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 15px; }
.download-link img { transition: transform 0.2s; }
.download-link:hover img { transform: scale(1.1); opacity: 0.8; }

/* ==========================================
   4. 一覧ページ & クイズ (DIY / Gallery / Quiz)
   ========================================== */
.diy-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px; margin-top: 20px; }
.diy-card { border: 1px solid #ddd; text-decoration: none; color: inherit; transition: 0.3s; background: #fff; }
.diy-card:hover { transform: translateY(-5px); box-shadow: 0 5px 15px rgba(0,0,0,0.1); }
.diy-card img { width: 100%; height: 150px; object-fit: cover; }
.diy-card-text { padding: 15px; }
.diy-card-text h2 { font-size: 1.1rem; margin-bottom: 5px; border: none; }

.answer-accordion { max-width: 600px; margin: 30px auto; border: 2px solid #007bff; border-radius: 8px; overflow: hidden; }
.answer-accordion summary { padding: 15px; background-color: #f0f7ff; color: #007bff; font-weight: bold; cursor: pointer; outline: none; list-style: none; transition: 0.3s; }
.answer-accordion summary:hover { background-color: #e0efff; }
.answer-accordion summary::before { content: "▼ "; font-size: 0.8rem; }
.answer-content { padding: 20px; background-color: #fff; border-top: 1px solid #eee; line-height: 1.8; }
details[open] .answer-content { animation: fadeIn 0.5s ease; }
@keyframes fadeIn { 0% { opacity: 0; transform: translateY(-10px); } 100% { opacity: 1; transform: translateY(0); } }

/* ==========================================
   5. トップページ固有 (Home Sections)
   ========================================== */
/* What's New */
.news-section { background: #fdfdfd; border: 1px solid #eee; padding: 20px; margin-bottom: 40px; border-radius: 8px; }
.news-list { list-style: none; padding: 0; margin: 0; }
.news-list li { padding: 10px 0; border-bottom: 1px dotted #ccc; font-size: 0.95rem; }
.news-list .date { font-weight: bold; color: #666; margin-right: 15px; }

/* コンテンツカード */
.overview-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; margin-top: 20px; }
.overview-item { display: block; text-decoration: none; color: #333; border: 1px solid #eee; padding: 20px; border-radius: 8px; background: #fff; transition: 0.3s ease; }
.overview-item:hover { box-shadow: 0 10px 20px rgba(0,0,0,0.1); transform: translateY(-5px); border-color: #007bff; }
.more-text { font-weight: bold; color: #007bff; font-size: 0.85rem; }

/* 歩み・イントロセクション */
.home-intro { background-color: #f9f9f9; border: 1px solid #eee; padding: 30px; margin-top: 60px; border-radius: 8px; }
.intro-flex { display: flex; align-items: center; gap: 30px; }
.award-icon { flex-shrink: 0; }
.award-icon img { display: block; width: 120px; height: 120px; border-radius: 8px; box-shadow: 0 4px 10px rgba(0,0,0,0.1); background: #fff; padding: 5px; }
.book-info { display: flex; align-items: center; gap: 15px; margin-top: 15px; }

/* 歴代アイコン (Legacy) */
.legacy-area { margin-top: 20px; }
.legacy-icon-container { display: flex; gap: 8px; justify-content: flex-start; flex-wrap: wrap; margin-top: 10px; }
.legacy-icon-box { background-color: #000 !important; padding: 5px; border-radius: 4px; width: 60px; text-align: center; }
.legacy-icon-box img { width: 100%; display: block; margin-bottom: 3px; }
.legacy-icon-box span { color: #fff; font-size: 0.6rem; display: block; }
.banner-box img { height: 30px; object-fit: contain; margin-bottom: 8px !important; }

/* ==========================================
   6. お問い合わせ・フッター・スクロール (Utility)
   ========================================= */
.contact-section { padding: 20px 0 !important; background-color: #f4f4f4; text-align: left; border-top: 1px solid #eee; }
.contact-section .content { max-width: 800px; margin: 0 auto; padding: 0 20px; }
.email-link { display: inline-block; font-size: 1.1rem; color: #007bff; text-decoration: underline; font-weight: bold; margin-bottom: 5px; transition: 0.3s; }
.email-link:hover { background-color: #007bff; color: #fff; text-decoration: none; }
.footer { background-color: #333; color: #fff; padding: 30px 20px; text-align: center; }
.footer .copyright { font-size: 0.85rem; margin: 0; letter-spacing: 0.05em; }

/* アクセスカウンターのレイアウト調整 */
.access-counter {
    margin-bottom: 20px; /* 著作権表記（Copyright）との間隔 */
    text-align: center;
}

.access-counter img {
    border: 1px solid #555; /* 外側に薄い枠を付けてデジタル感を出す */
    padding: 2px;
    background-color: #000;
    display: inline-block;
}

/* ==========================================
   6. スクロールボタン (修正版)
   ========================================= */
.scroll-top {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    /* 初期状態：透明で見えない */
    background-color: rgba(0, 123, 255, 0.6); /* 青色を少し濃くしました */
    color: #ffffff !important;                /* 矢印を白で固定 */
    text-align: center;
    line-height: 50px;
    border-radius: 50%;
    z-index: 9999;                            /* 最前面に表示 */
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0;
    visibility: hidden;
    font-size: 24px;                          /* 矢印を大きく */
    font-weight: bold;
}

/* スクロールした時にJSで付与されるクラス */
.scroll-top.is-show {
    opacity: 1 !important;
    visibility: visible !important;
}

/* マウスを乗せた時 */
.scroll-top:hover {
    background-color: rgba(0, 123, 255, 1);    /* 不透明にする */
    transform: scale(1.1);
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

/* ==========================================
   7. レスポンシブ調整 (Responsive)
   ========================================== */
@media screen and (max-width: 640px) {
    .content { padding-top: 70px; }
    .nav-list a { font-size: 18px; padding: 10px; }
    .intro-flex { flex-direction: column; text-align: center; gap: 20px; }
    .tight-group { gap: 40px; }
    .item-set { width: 90%; }
}
