/* =============================================== */
/* core.css - EGIC学習サイト共通スタイルシート (v4.0) */
/* =============================================== */

@import url('https://fonts.googleapis.com/css2?family=M+PLUS+Rounded+1c:wght@400;700;800&display=swap');

:root {
  /* デフォルト変数（各サイトのtheme-*.cssで上書きすること） */
  --primary-color: #00796b;      /* メインカラー */
  --primary-dark: #004d40;       /* 濃いメインカラー */
  --primary-light: #b2dfdb;      /* 薄いメインカラー */
  --accent-color: #ffca28;       /* アクセントカラー */
  
  --background-light: #f0f4f8;   /* ページ全体の背景 */
  --background-main: #ffffff;    /* 記事部分の背景 */
  
  --text-color: #333333;         /* 本文の文字色 */
  --header-text-color: #ffffff;  /* ヘッダーの文字色 */
  
  --font-family-main: 'M PLUS Rounded 1c', sans-serif;
  --max-width-main: 1000px;      /* コンテンツ幅 */
  --border-radius-main: 16px;    /* 角丸の大きさ */
}

/* --- 基本設定 --- */
body {
  font-family: var(--font-family-main);
  margin: 0;
  padding: 0;
  background-color: var(--background-light);
  color: var(--text-color);
  line-height: 1.8; /* 読みやすく少し広めに */
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--primary-dark);
  transition: color 0.3s;
}

a:hover {
  color: var(--primary-color);
}

img {
  max-width: 100%;
  height: auto;
}

/* --- ヘッダー --- */
header {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  color: var(--header-text-color);
  padding: 2rem 1rem;
  text-align: center;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

header h1 {
  font-weight: 800;
  margin: 0;
  font-size: 2.5rem;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

header p {
  margin-top: 0.5rem;
  font-weight: 700;
  opacity: 0.9;
}

/* --- グローバルナビゲーション --- */
nav {
  background-color: var(--primary-dark);
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  padding: 0.5rem 0;
  position: sticky; /* スクロールしても上に張り付く（任意） */
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  border-bottom: 4px solid var(--accent-color);
}

nav a {
  color: var(--header-text-color);
  padding: 0.8rem 1.5rem;
  text-decoration: none;
  font-weight: 700;
  border-radius: 4px;
  margin: 0 0.2rem;
}

nav a:hover, nav a.active {
  background-color: rgba(255, 255, 255, 0.2);
  color: #fff;
}

/* --- パンくずリスト (v4.0) --- */
.breadcrumb-container {
  background-color: #ffffff;
  border-bottom: 1px solid #e0e0e0;
  padding: 0.8rem 0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.03);
}

.breadcrumb {
  max-width: var(--max-width-main);
  margin: 0 auto;
  padding: 0 2rem;
  list-style: none;
  font-size: 0.9rem;
}

.breadcrumb li {
  display: inline;
}

.breadcrumb li:not(:last-child)::after {
  content: '>';
  margin: 0 0.8em;
  color: #999;
}

.breadcrumb a {
  color: var(--primary-dark);
  text-decoration: none;
  font-weight: bold;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.breadcrumb li.current {
  color: #666;
  font-weight: bold;
}

/* --- メインコンテンツエリア --- */
main {
  max-width: var(--max-width-main);
  margin: 3rem auto;
  padding: 3rem;
  background-color: var(--background-main);
  border-radius: var(--border-radius-main);
  box-shadow: 0 10px 30px rgba(0,0,0,0.05);
}

/* 記事内見出し */
main h1 {
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--primary-dark);
  border-bottom: 4px solid var(--primary-color);
  padding-bottom: 0.5rem;
  margin-bottom: 2rem;
  margin-top: 0;
}

main h2 {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-color);
  border-left: 8px solid var(--primary-color);
  background-color: var(--primary-light); /* 背景色で強調 */
  padding: 0.8rem 1.2rem;
  margin-top: 3.5rem;
  margin-bottom: 1.5rem;
  border-radius: 0 8px 8px 0;
}

main h3 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary-dark);
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  border-bottom: 2px dashed var(--primary-light);
  padding-bottom: 0.3rem;
}

/* --- キャラクターボックス --- */
.character-box {
  margin: 2.5em 0;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 4px 15px rgba(0,0,0,0.05);
  overflow: hidden; /* ヘッダーの角丸のため */
  border: 2px solid #eee; /* デフォルト枠線 */
}

.character-dialog-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background-color: #f5f5f5; /* デフォルト背景 */
  border-bottom: 1px solid rgba(0,0,0,0.05);
}

.character-icon {
  width: 60px;
  height: auto;
  flex-shrink: 0;
  filter: drop-shadow(2px 2px 2px rgba(0,0,0,0.1));
}

.character-name {
  font-weight: 800;
  font-size: 1.2em;
}

.character-dialog-body {
  padding: 1.5rem;
  font-size: 1.05rem;
}

.character-dialog-body p:last-child {
  margin-bottom: 0;
}

/* --- 単元一覧カード (Unit Card) --- */
.unit-card-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
  margin-bottom: 3rem;
}

a.unit-card {
  display: block;
  text-decoration: none;
  background-color: #ffffff;
  border-radius: 12px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.05);
  border: 2px solid transparent;
  transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
  overflow: hidden;
  height: 100%;
}

a.unit-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 25px rgba(0,0,0,0.15);
  border-color: var(--primary-color);
}

.unit-card-header {
  padding: 1.2rem;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  align-items: center;
  gap: 1rem;
  background-color: rgba(0,0,0,0.02);
}

.unit-card-number {
  flex-shrink: 0;
  width: 45px;
  height: 45px;
  background-color: var(--primary-color);
  color: #ffffff;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1rem;
  font-weight: 800;
  box-shadow: 2px 2px 5px rgba(0,0,0,0.1);
}

.unit-card-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 0;
  color: var(--text-color);
  line-height: 1.4;
}

.unit-card-body {
  padding: 1.5rem;
  font-size: 0.95rem;
  color: #555;
  line-height: 1.6;
}

/* --- 開閉式詳細（details/summary） --- */
details {
  margin: 1.5rem 0;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  background-color: #fff;
}

summary {
  font-weight: 700;
  cursor: pointer;
  padding: 1rem;
  background-color: #f9f9f9;
  border-radius: 6px;
  color: var(--primary-dark);
  list-style: none; /* デフォルトの三角を消す */
  position: relative;
  padding-left: 2.5rem;
}

/* カスタム矢印 */
summary::before {
  content: "▶";
  position: absolute;
  left: 1rem;
  transition: transform 0.2s;
  color: var(--primary-color);
}

details[open] summary::before {
  transform: rotate(90deg);
}

summary:hover {
  background-color: #f0f0f0;
}

details[open] div {
  padding: 1.5rem;
  border-top: 1px solid #e0e0e0;
}

/* --- フッター --- */
footer {
  background-color: var(--primary-dark);
  color: var(--header-text-color);
  text-align: center;
  padding: 3rem 1rem;
  margin-top: 5rem;
}

footer a {
  color: rgba(255,255,255,0.8);
  text-decoration: underline;
}

footer a:hover {
  color: #fff;
  text-decoration: none;
}

/* =============================================== */
/* --- レスポンシブ対応 (メディアクエリ) --- */
/* =============================================== */

/* --- タブレット以下のサイズ (幅が1024px以下の場合) --- */
@media (max-width: 1024px) {
  main {
    margin: 2rem 1.5rem;
    padding: 2rem;
  }
}

/* --- スマートフォン向けのサイズ (幅が768px以下の場合) --- */
@media (max-width: 768px) {
  header h1 { font-size: 2rem; }
  
  nav a {
    padding: 0.6rem 0.8rem;
    font-size: 0.9rem;
    margin: 0;
  }

  main {
    margin: 1.5rem 1rem;
    padding: 1.5rem;
    border-radius: 8px;
  }
  
  main h1 {
    font-size: 1.8rem;
  }
  
  main h2 {
    font-size: 1.4rem;
    padding: 0.6rem 1rem;
    border-left-width: 6px;
  }

  .breadcrumb-container {
    padding: 0.5rem 1rem;
  }
  .breadcrumb {
    padding: 0;
    font-size: 0.85rem;
  }
  
  /* キャラクターボックスをスマホ用に調整 */
  .character-dialog-header {
    padding: 0.8rem;
    gap: 0.8rem;
  }
  .character-icon {
    width: 50px;
  }
  .character-name {
    font-size: 1.1em;
  }
  .character-dialog-body {
    padding: 1rem;
    font-size: 0.95rem;
  }

  /* 単元カードを1列に */
  .unit-card-container {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}