/* ===============================
   Base & Color Themes
================================= */
:root {
  /* デフォルトテーマ（藤色） */
  --theme-primary: #6b5ba6;
  --theme-primary-dark: #4e3f85;
  --theme-primary-bg: #f3f0fa;
  --theme-primary-hint: #e4def7;

  /* 後方互換性のため古い変数名も維持 */
  --fuji: var(--theme-primary);
  --fuji-dark: var(--theme-primary-dark);
  --fuji-bg: var(--theme-primary-bg);
  --fuji-hint: var(--theme-primary-hint);
}

/* 青緑テーマ */
[data-theme='teal'] {
  --theme-primary: #008080;
  --theme-primary-dark: #006666;
  --theme-primary-bg: #e0f7f7;
  --theme-primary-hint: #b3e6e6;
}

/* 深緑テーマ */
[data-theme='forest'] {
  --theme-primary: #2d5016;
  --theme-primary-dark: #1a3009;
  --theme-primary-bg: #f0f7e8;
  --theme-primary-hint: #d4e6c7;
}

/* 深紅テーマ */
[data-theme='crimson'] {
  --theme-primary: #8b0000;
  --theme-primary-dark: #660000;
  --theme-primary-bg: #f7e8e8;
  --theme-primary-hint: #e6b3b3;
}

/* 紺青テーマ */
[data-theme='navy'] {
  --theme-primary: #1e3a8a;
  --theme-primary-dark: #1e40af;
  --theme-primary-bg: #e8f0fe;
  --theme-primary-hint: #c7d2fe;
}

/* オレンジテーマ */
[data-theme='orange'] {
  --theme-primary: #ea580c;
  --theme-primary-dark: #c2410c;
  --theme-primary-bg: #fff7ed;
  --theme-primary-hint: #fed7aa;
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
}
body {
  font-family: Arial, sans-serif;
  background: #f9f9f9;
  color: #111;
}

/* ===============================
   Global Nav
================================= */
.global-nav {
  background: var(--fuji);
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 3;
}
.nav-toggle {
  display: none;
  background: transparent;
  border: 0;
  cursor: pointer;
  padding: 8px;
  margin-right: 8px;
}
.nav-toggle .nav-toggle-bar {
  display: block;
  width: 22px;
  height: 2px;
  background: #fff;
  margin: 5px 0;
  border-radius: 1px;
}
.nav-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}
.nav-links a {
  color: #fff;
  text-decoration: none;
  font-weight: bold;
  padding: 8px 10px;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

/* 現在のページのナビゲーションリンク */
.nav-links a[aria-current='page'],
.nav-links span[aria-current='page'] {
  color: var(--fuji-dark);
  background-color: var(--fuji-bg);
  border-radius: 6px;
  cursor: default;
  pointer-events: none;
  font-weight: bold;
  padding: 8px 12px;
  display: inline-block;
  align-items: center;
  white-space: nowrap;
  transition: all 0.2s ease;
  width: fit-content;
}

/* ===============================
   Hero
================================= */
.hero {
  /* フォールバック背景色 */
  background: linear-gradient(
    135deg,
    var(--theme-primary) 0%,
    var(--theme-primary-dark) 100%
  );

  /* WebP対応ブラウザ用 */
  background-image: url('../imgs/hero_sample03.webp');
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;

  min-height: clamp(190px, 24vw, 350px);
  text-align: center;
  color: #fff;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 28px 20px;

  /* 読み込み中のスムーズな表示 */
  transition: background-image 0.3s ease;
}

/* WebP非対応ブラウザ用のフォールバック */
@supports not (background-image: url('../imgs/hero_sample03.webp')) {
  .hero {
    background-image: url('../imgs/hero_sample03.png');
  }
}

/* 画像読み込み中の表示改善 */
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    var(--theme-primary) 0%,
    var(--theme-primary-dark) 100%
  );
  opacity: 1;
  transition: opacity 0.5s ease;
  z-index: 0;
}

/* 画像読み込み完了後のオーバーレイ */
.hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1;
}

.hero h1,
.hero p.subtitle {
  position: relative;
  z-index: 2;
}

.hero h1 {
  font-size: 42px;
  margin-bottom: 15px;
}

.hero p.subtitle {
  font-size: 20px;
  margin: 0;
}

/* 画像読み込み完了時のアニメーション */
.hero.loaded::before {
  opacity: 0;
}

/* ===============================
   Profile
================================= */
.profile {
  display: grid;
  grid-template-columns: minmax(220px, 300px) 1fr;
  gap: 24px;
  align-items: start;
  padding: 40px 20px;
  background: #fff;
  max-width: 1100px;
  margin: 0 auto;
}
.profile img {
  width: 100%;
  max-width: 300px;
  height: auto;
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}
.profile-text h2 {
  margin-top: 0;
  font-size: 28px;
}
.profile-text .profile-name {
  font-size: 22px;
  font-weight: bold;
  margin: 10px 0;
}
.profile-name__meta {
  display: block;
  font-weight: normal;
  font-size: 0.95em;
  color: #555;
}

/* 書籍リンク */
/* Amazonリンク（汎用） */
a.book-link {
  text-decoration: none;
  color: var(--fuji);
  font-weight: bold;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
a.book-link:hover {
  text-decoration: none;
  opacity: 0.9;
}
a.book-link i {
  font-size: 0.95em;
}

/* プロフィール内のAmazonリンク（後方互換性のため維持） */
.profile-text a.book-link {
  text-decoration: none;
  color: var(--fuji);
  font-weight: bold;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.profile-text a.book-link:hover {
  text-decoration: none;
  opacity: 0.9;
}
.profile-text a.book-link i {
  font-size: 0.95em;
}

/* PDF項目コンテナ */
.pdf-item {
  margin: 12px 0;
  padding: 12px 16px 6px 16px;
  background: var(--fuji-bg);
  border-left: 4px solid var(--fuji);
  border-radius: 4px;
}
.pdf-item p {
  margin: 0 0 12px 0;
  line-height: 1.6;
}
.pdf-item p strong {
  color: var(--fuji-dark);
  font-weight: bold;
}

/* PDFリンク（汎用） */
a.pdf-link {
  text-decoration: none;
  color: #c62828;
  font-weight: bold;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
a.pdf-link:hover {
  opacity: 0.9;
}

/* ===============================
   Sections (4 boxes)
================================= */
.sections {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  padding: 32px 16px;
  max-width: 1100px;
  margin: 0 auto;
}
.section-box {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  text-align: center;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.section-box:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}
.section-box img {
  width: 100%;
  height: 160px;
  object-fit: cover;
}
.section-box h3 {
  margin: 12px 0 8px 0;
  font-size: 18px;
}
.section-box p {
  padding: 0 12px 16px 12px;
  color: #333;
  line-height: 1.6;
  font-size: 13px;
}

/* ===============================
   About Research
================================= */
.about-research {
  padding: 40px 20px;
  background: #fff;
  margin-top: 20px;
  line-height: 1.7;
  max-width: 1100px;
  margin-left: auto;
  margin-right: auto;
}
details {
  margin-bottom: 15px;
}
/* details内テキストブロック（summary以外）を明朝体に、左右パディング付与 */
details > *:not(summary) {
  font-family: 'Hiragino Mincho ProN', 'YuMincho', '游明朝', 'Noto Serif JP',
    'MS PMincho', serif;
  padding-left: 40px;
  padding-right: 40px;
}
/* details内の強調は可読性のためゴシック体に上書き */
details strong {
  font-family: system-ui, -apple-system, 'Segoe UI', 'Hiragino Kaku Gothic ProN',
    'YuGothic', '游ゴシック体', 'Noto Sans JP', Arial, sans-serif;
  font-weight: bold;
}
summary {
  font-weight: bold;
  cursor: pointer;
  background: var(--fuji-bg);
  padding: 10px;
  border-radius: 4px;
}
.close-link {
  display: block;
  margin-top: 20px;
  text-align: right;
}
.close-link a {
  color: var(--fuji);
  cursor: pointer;
  text-decoration: underline;
}

/* summary のデフォルト三角を消し、＋／－を中央揃えで表示 */
summary::-webkit-details-marker {
  display: none;
}
summary::marker {
  content: '';
}
details > summary {
  position: relative;
  padding-left: 1.1em;
  list-style: none;
}
details > summary::before {
  content: '＋';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
}
details[open] > summary::before {
  content: '－';
}

/* ===============================
   Theme Instructions
================================= */
/* 
テーマを変更するには、html要素にdata-theme属性を追加してください：

例：
<html data-theme="teal">     - 青緑テーマ
<html data-theme="forest">   - 深緑テーマ  
<html data-theme="crimson">  - 深紅テーマ
<html data-theme="navy">     - 紺青テーマ
<html data-theme="orange">   - オレンジテーマ
<html> または <html data-theme="default"> - デフォルト（藤色）テーマ

利用可能なテーマ：
- default: 藤色（#6b5ba6）
- teal: 青緑（#008080）
- forest: 深緑（#2d5016）
- crimson: 深紅（#8b0000）
- navy: 紺青（#1e3a8a）
- orange: オレンジ（#ea580c）
*/

/* ===============================
   Footer & Email Copy
================================= */
footer {
  background: var(--fuji-dark);
  color: #fff;
  text-align: center;
  padding: 20px;
}
.footer-contact {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin: 0 0 8px;
}
.copy-email {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  font-weight: bold;
}
.copy-email:hover {
  opacity: 0.9;
}
.copy-hint {
  color: var(--fuji-hint);
}
.copy-toast {
  margin-top: 6px;
  font-weight: bold;
  color: #fff;
  background: rgba(0, 0, 0, 0.25);
  padding: 2px 10px;
  border-radius: 9999px;
}

/* ===============================
   Page wrapper (sub pages)
================================= */
.page {
  padding: 40px 20px;
  background: #fff;
  max-width: 1100px;
  margin: 20px auto;
  line-height: 1.8;
}
.page .lede {
  color: #333;
  opacity: 0.95;
}

/* 教育論ページ：インライン連絡先ユニット */
.inline-contact {
  background: #fff;
  border: 1px solid var(--fuji-hint);
  border-radius: 8px;
  padding: 10px 12px;
  display: inline-flex;
  flex-direction: column;
  gap: 6px;
  margin: 8px 0 12px;
}
.inline-contact .copy-email {
  color: var(--fuji-dark);
}
.inline-contact .copy-hint {
  color: #555;
}
.inline-contact .copy-toast {
  align-self: flex-start;
}

/* PDF一覧（education） */
.pdf-list {
  list-style: none;
  padding-left: 0;
  /* 段落→リストは詰め、セット間は広げる */
  margin: 6px 0 0px;
  /* タイトル群を全体として右にオフセット */
  padding-left: 20px;
}

/* PDF一覧のレスポンシブ対応（others.html用） */
.pdf-list.responsive {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  padding-left: 0;
}

.pdf-list.responsive li {
  border-bottom: 1px dashed var(--fuji-hint);
  padding: 6px 8px;
}

/* タブレット以上で2列表示 */
@media (min-width: 768px) {
  .pdf-list.responsive {
    grid-template-columns: repeat(2, 1fr);
    gap: 0;
  }
}

/* デスクトップで3列表示 */
@media (min-width: 1024px) {
  .pdf-list.responsive {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* 大画面で4列表示 */
@media (min-width: 1400px) {
  .pdf-list.responsive {
    grid-template-columns: repeat(4, 1fr);
  }
}
.pdf-list li {
  display: flex;
  align-items: flex-start;
  /* アイコンとタイトルの間隔をやや拡大 */
  gap: 14px;
  padding: 6px 8px;
  border-bottom: 1px dashed var(--fuji-hint);
}
.pdf-list li i {
  color: #c62828;
  flex: 0 0 auto;
  margin-top: 2px;
}
.pdf-list li span {
  line-height: 1.7;
  /* タイトルを一段右に寄せる（アイコンとの視覚的距離を拡大） */
  padding-left: 4px;
}

/* 教育論ページのH3サブタイトル */
.page h3 {
  color: var(--fuji-dark);
  font-size: 18px;
  font-weight: bold;
  margin: 32px 0 8px 0;
  padding-bottom: 4px;
  border-bottom: 2px solid var(--fuji-hint);
}

/* 教材ページのH2セクションタイトル */
.page h2 {
  margin-top: 48px;
}

/* 教材ページのH3サブセクションタイトル */
.page h3 {
  margin-top: 50px;
}

/* 最初のH3は上マージンを小さく */
.page h3:first-of-type {
  margin-top: 24px;
}

/* Graph Art ギャラリー */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 16px;
  margin: 24px 0;
  padding: 20px;
  background: var(--fuji-bg);
  border-radius: 8px;
  border: 1px solid var(--fuji-hint);
}

.gallery-grid img {
  width: 100%;
  height: auto;
  max-width: 168px;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.gallery-grid img:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

/* レスポンシブ調整 */
@media (max-width: 768px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    padding: 16px;
  }
}

@media (max-width: 480px) {
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding: 12px;
  }
}

/* ===============================
   Page Headings
================================= */
.page h1 {
  text-align: center;
  line-height: 1.2;
}

h1 .subtitle {
  font-size: 0.6em;
  font-weight: normal;
  opacity: 0.8;
  display: block;
  margin-top: 0.1em;
}

/* ===============================
   Intro Section (Records page)
================================= */
.intro-section {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 32px;
}

.intro-content {
  flex: 1;
}

.intro-image {
  flex: 1;
  margin: 0;
  text-align: center;
}

.intro-image img {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  height: auto;
}

/* タブレット以上で横並び表示 */
@media (min-width: 768px) {
  .intro-section {
    flex-direction: row;
    align-items: flex-start;
    gap: 32px;
  }

  .intro-image {
    flex: 0 0 300px;
    max-width: 300px;
  }
}

/* デスクトップでより大きな画像 */
@media (min-width: 1024px) {
  .intro-image {
    flex: 0 0 400px;
    max-width: 400px;
  }
}

/* ===============================
   Goal Items (Records page)
================================= */
.goal-item {
  margin-bottom: 32px;
  padding: 24px;
  background: var(--fuji-bg);
  border-radius: 8px;
  border-left: 4px solid var(--fuji);
}

.goal-item h3 {
  margin: 0 0 16px 0;
  color: var(--fuji-dark);
  font-size: 20px;
  font-weight: bold;
}

.goal-content {
  background: #fff;
  padding: 20px;
  border-radius: 6px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.goal-content h4 {
  margin: 0 0 12px 0;
  color: var(--fuji);
  font-size: 16px;
  font-weight: bold;
  border-bottom: 2px solid var(--fuji-hint);
  padding-bottom: 6px;
}

.goal-content p {
  margin: 0 0 16px 0;
  line-height: 1.7;
}

.goal-content p:last-child {
  margin-bottom: 0;
}

/* ===============================
   Responsive
================================= */
@media (min-width: 1024px) {
  .sections {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 1024px) and (min-width: 641px) {
  /* 2×2 の2段表示のとき、画像が見切れないよう contain に */
  .section-box img {
    height: 200px;
    object-fit: contain;
    background: #fff;
  }
}

@media (max-width: 900px) {
  .profile {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 24px 16px;
  }
  .profile img {
    max-width: 300px;
    width: 100%;
    justify-self: center;
    margin: 0 auto;
  }
}

/* Mobile Nav（transform法でスムーズ開閉：ここが肝！） */
@media (max-width: 900px) {
  .global-nav {
    justify-content: space-between;
  }
  .nav-toggle {
    display: inline-block;
  }

  .nav-links {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--fuji);
    width: 100%;

    /* スムーズな開閉のため、scaleY ではなく max-height + opacity を使用 */
    opacity: 0;
    pointer-events: none;
    padding: 0;
    overflow: hidden;
    max-height: 0;

    will-change: max-height, opacity, padding;
    transition: max-height 0.28s linear, opacity 0.2s linear,
      padding 0.28s linear;
  }
  .nav-links.is-open {
    opacity: 1;
    padding: 10px 0;
    pointer-events: auto;
    max-height: 75vh;
  }

  /* メニュー項目の段階的フェードイン */
  .nav-links a {
    opacity: 0;
    transform: translateY(-4px);
    will-change: opacity, transform;
    transition: opacity 0.18s linear, transform 0.18s linear;
  }
  .nav-links.is-open a {
    opacity: 1;
    transform: translateY(0);
  }
  /* 個別ディレイは廃止して即時開始 */
}

/* 低モーション配慮 */
@media (max-width: 900px) and (prefers-reduced-motion: reduce) {
  .nav-links {
    transition: none;
  }
}

@media (max-width: 640px) {
  .section-box img {
    height: 120px;
  }
}

@media (max-width: 480px) {
  .profile img {
    max-width: 300px;
  }
  .profile-text h2 {
    font-size: 24px;
  }
  .profile-text .profile-name {
    font-size: 20px;
  }
}
