/*
 * スタッフ研修「シーシャ製品知識編」— 共通スタイルシート
 * OCHER アースカラー系。章別 HTML ファイルで共有。
 *
 * CSS 変数の上書きで全章のカラーが一括変更される。
 * 変更は script.js の配色 UI + localStorage で永続化される。
 */

/* =========================================================
   1. CSS カスタムプロパティ（全章共通）
   ========================================================= */
:root {
  /* OCHER ブランドカラーシステム（ロゴVI準拠） */
  --primary:       #D09809;   /* OCHER 黄土色 — 基調・見出し（代表調整を確定・旧 Dark Brown #3B2115） */
  --accent:        #ECC656;   /* OCHER Ocher — 強調・アクセント */
  --background:    #fbf7ec;   /* Ocher を薄めた紙系背景 */
  --surface:       #ffffff;   /* カード背景 */
  --surface-alt:   #f5ecd2;   /* Ocher 淡カード */
  --text:          #3B2115;   /* OCHER Dark Brown でテキスト統一 */
  --text-muted:    #6e5a48;   /* Dark Brown 系 muted */
  --border:        #e3d4a8;   /* Ocher 薄ボーダー */
  --danger:        #E83828;   /* OCHER Bright Red — 警告・過加熱 */
  --safe:          #00453F;   /* OCHER Deep Green — 最適域・安全 */
  --warning:       #C9913A;   /* Ocher 系の注意ゾーン */

  /* タイポグラフィ */
  --font-body:     'Noto Serif JP', 'Hiragino Mincho ProN', Georgia, serif;
  --font-ui:       'Noto Sans JP', 'Hiragino Sans', 'Helvetica Neue', sans-serif;
  --font-mono:     'Fira Code', 'Courier New', monospace;
  --font-size-base: 17px;
  --line-height:   1.85;

  /* スペーシング */
  --spacing-xs:    4px;
  --spacing-sm:    8px;
  --spacing-md:    16px;
  --spacing-lg:    32px;
  --spacing-xl:    56px;

  /* ボーダー・シャドウ */
  --radius-sm:     4px;
  --radius-md:     8px;
  --radius-lg:     16px;
  --shadow-sm:     0 1px 4px rgba(44, 35, 24, 0.08);
  --shadow-md:     0 4px 16px rgba(44, 35, 24, 0.12);
  --shadow-lg:     0 8px 32px rgba(44, 35, 24, 0.16);

  /* レイアウト */
  --content-max:   820px;
  --sidebar-w:     280px;
}

/* =========================================================
   2. リセット・ベース
   ========================================================= */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: var(--font-size-base);
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: var(--line-height);
  color: var(--text);
  background-color: var(--background);
  -webkit-font-smoothing: antialiased;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  opacity: 0.85;
}

/* =========================================================
   3. レイアウト構造
   ========================================================= */

/* --- 3-1. 共通ページラッパー --- */
.page-wrapper {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--spacing-lg) var(--spacing-md);
}

/* --- 3-2. index.html 専用グリッド（2カラム） --- */
.index-grid {
  display: grid;
  grid-template-columns: 1fr var(--sidebar-w);
  gap: var(--spacing-lg);
  align-items: start;
}

@media (max-width: 860px) {
  .index-grid {
    grid-template-columns: 1fr;
  }
}

/* =========================================================
   4. タイポグラフィ
   ========================================================= */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-ui);
  font-weight: 700;
  line-height: 1.35;
  color: var(--text);
}

h1 { font-size: clamp(1.6rem, 4vw, 2.4rem); letter-spacing: -0.02em; }
h2 { font-size: clamp(1.2rem, 3vw, 1.7rem); border-bottom: 2px solid var(--border); padding-bottom: var(--spacing-sm); margin-bottom: var(--spacing-md); margin-top: var(--spacing-xl); }
h3 { font-size: clamp(1.05rem, 2.5vw, 1.25rem); margin-top: var(--spacing-lg); margin-bottom: var(--spacing-sm); }
h4 { font-size: 1rem; font-weight: 700; margin-top: var(--spacing-md); }

p {
  margin-bottom: var(--spacing-md);
}

strong {
  font-weight: 700;
  color: var(--primary);
}

ul, ol {
  margin-left: var(--spacing-lg);
  margin-bottom: var(--spacing-md);
}

li {
  margin-bottom: var(--spacing-xs);
}

/* =========================================================
   5. カテゴリチップ（.chapter-chip）
   ========================================================= */
.chapter-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-sm);
  background: var(--primary);
  color: #fff;
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--radius-sm);
  margin-bottom: var(--spacing-lg);
}

.chapter-chip::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
}

/* header.chapter-chip（block 要素として使う場合） */
header.chapter-chip {
  display: flex;
  width: fit-content;
}

/* =========================================================
   6. 章ナビゲーション（.chapter-nav）
   ========================================================= */
.chapter-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-md);
  padding: var(--spacing-md) 0;
  margin-top: var(--spacing-xl);
  border-top: 1px solid var(--border);
  font-family: var(--font-ui);
  font-size: 0.9rem;
}

.chapter-nav a {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-xs);
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  transition: background 0.15s, border-color 0.15s;
}

.chapter-nav a:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  text-decoration: none;
}

.chapter-nav a[href*="index"] {
  background: var(--surface-alt);
}

/* =========================================================
   7. スライド・セクション（.slide）
   ========================================================= */
.chapter-content {
  /* 章ファイルのメインコンテナ */
}

.slide {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--spacing-lg) clamp(var(--spacing-lg), 5vw, 48px);
  margin-bottom: var(--spacing-lg);
  border: 1px solid var(--border);
  position: relative;
}

.slide + .slide {
  border-top: none;
}

/* スライド番号バッジ */
.slide-number {
  position: absolute;
  top: var(--spacing-md);
  right: var(--spacing-md);
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  padding: 2px 8px;
  letter-spacing: 0.05em;
}

/* =========================================================
   8. カード（.card）
   ========================================================= */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-md);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-md);
}

.card__title {
  font-family: var(--font-ui);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: var(--spacing-xs);
}

.card__body {
  font-size: 0.95rem;
}

/* =========================================================
   9. 表（table）
   ========================================================= */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: var(--spacing-md);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-ui);
  font-size: 0.88rem;
}

thead {
  background: var(--primary);
  color: #fff;
}

thead th {
  padding: var(--spacing-sm) var(--spacing-md);
  text-align: left;
  font-weight: 700;
  letter-spacing: 0.03em;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

tbody tr:nth-child(even) {
  background: var(--surface-alt);
}

tbody tr:hover {
  background: #ede7de;
}

tbody td {
  padding: var(--spacing-sm) var(--spacing-md);
  vertical-align: top;
}

/* =========================================================
   10. コードブロック・温度チャート（code / pre / .temp-chart）
   ========================================================= */
code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1px 6px;
}

pre {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--spacing-md) var(--spacing-lg);
  overflow-x: auto;
  line-height: 1.7;
  margin-bottom: var(--spacing-md);
  white-space: pre;
}

pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
}

/* 温度帯カラー（気化プロセス図解と対応） */
.temp-under   { color: #6d7d8a; }         /* 130°C以下 — 灰色 */
.temp-optimal { color: var(--safe); font-weight: 700; }  /* 最適域 — グリーン */
.temp-over    { color: var(--danger); font-weight: 700; } /* 過加熱 — レッド */
.temp-charcoal { color: #c0392b; font-style: italic; }   /* 炭燃焼域 */

/* =========================================================
   11. 図解枠（.figure-container / .figure-caption）
   ========================================================= */
.figure-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 680px;
  margin: var(--spacing-lg) auto;
  padding: var(--spacing-md);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.figure-container svg {
  width: 100%;
  height: auto;
  display: block;
}

.figure-caption {
  margin-top: var(--spacing-sm);
  font-family: var(--font-ui);
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
  letter-spacing: 0.02em;
}

/* 並列比較図（2つ横並び） */
.figure-row {
  display: flex;
  gap: var(--spacing-lg);
  justify-content: center;
  flex-wrap: wrap;
  margin: var(--spacing-lg) 0;
}

.figure-row .figure-container {
  flex: 1 1 260px;
  max-width: 340px;
  margin: 0;
}

/* =========================================================
   12. 写真スロット枠（.photo-slot）
   ========================================================= */
.photo-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 220px;
  max-width: 480px;
  margin: var(--spacing-lg) auto;
  border: 2px dashed var(--accent);
  border-radius: var(--radius-md);
  background: #fbf7f2;
  padding: var(--spacing-lg);
  text-align: center;
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  gap: var(--spacing-sm);
}

.photo-slot__icon {
  font-size: 2.5rem;
  opacity: 0.4;
}

.photo-slot__label {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.photo-slot__note {
  font-size: 0.78rem;
  opacity: 0.7;
}

/* =========================================================
   13. 【更新予定】プレースホルダー（.placeholder-update）
   ========================================================= */
.placeholder-update {
  display: inline-block;
  background: #fff4cc;
  border: 1.5px solid #e6b800;
  border-radius: var(--radius-sm);
  color: #7a5800;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 2px 8px;
  margin-left: var(--spacing-xs);
  vertical-align: middle;
}

/* 本文中の更新予定ブロック */
.update-notice {
  background: #fff9e0;
  border-left: 4px solid #e6b800;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: var(--spacing-sm) var(--spacing-md);
  margin-bottom: var(--spacing-md);
  font-family: var(--font-ui);
  font-size: 0.88rem;
  color: #5c4400;
}

/* =========================================================
   14. 情報ハイライトボックス（.highlight-box）
   ========================================================= */
.highlight-box {
  background: var(--surface-alt);
  border-left: 4px solid var(--primary);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: var(--spacing-md) var(--spacing-lg);
  margin: var(--spacing-md) 0;
  font-family: var(--font-ui);
  font-size: 0.95rem;
}

.highlight-box--warning {
  background: #fff5e6;
  border-left-color: var(--warning);
  color: #5c3300;
}

.highlight-box--danger {
  background: #fff0ee;
  border-left-color: var(--danger);
  color: #5c0f00;
}

.highlight-box--safe {
  background: #edf7f0;
  border-left-color: var(--safe);
  color: #1a3d27;
}

/* =========================================================
   15. 発表者ノート（.presenter-note）
   ========================================================= */
.presenter-note {
  display: none; /* 印刷時のみ表示 */
  background: #f0f4ff;
  border: 1px solid #c0ccee;
  border-radius: var(--radius-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  margin-top: var(--spacing-md);
  font-family: var(--font-ui);
  font-size: 0.82rem;
  color: #334;
  line-height: 1.6;
}

.presenter-note::before {
  content: 'Notes: ';
  font-weight: 700;
  color: #5566aa;
}

/* =========================================================
   16. index.html 専用パーツ
   ========================================================= */

/* --- 表紙ヘッダー --- */
.cover-header {
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: var(--spacing-xl) clamp(var(--spacing-lg), 6vw, 56px);
  margin-bottom: var(--spacing-lg);
  position: relative;
  overflow: hidden;
}

.cover-header::after {
  content: '';
  position: absolute;
  right: -60px;
  top: -60px;
  width: 300px;
  height: 300px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 50%;
  pointer-events: none;
}

.cover-header__eyebrow {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.75;
  margin-bottom: var(--spacing-sm);
}

.cover-header__title {
  font-family: var(--font-ui);
  font-size: clamp(1.5rem, 4.5vw, 2.5rem);
  font-weight: 900;
  letter-spacing: -0.02em;
  margin-bottom: var(--spacing-sm);
  color: #fff;
  border: none;
  padding: 0;
}

.cover-header__subtitle {
  font-size: 1rem;
  opacity: 0.85;
  margin-bottom: var(--spacing-md);
}

.cover-header__meta {
  display: flex;
  gap: var(--spacing-md);
  font-family: var(--font-ui);
  font-size: 0.82rem;
  opacity: 0.7;
}

/* --- 目次カード（章リンク） --- */
.chapter-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-lg);
}

.chapter-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: var(--spacing-md);
  text-decoration: none;
  color: var(--text);
  transition: box-shadow 0.2s, transform 0.15s, border-color 0.15s;
  position: relative;
  overflow: hidden;
}

.chapter-card::before {
  content: '';
  display: block;
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--accent);
  transition: width 0.2s;
}

.chapter-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--accent);
  text-decoration: none;
}

.chapter-card:hover::before {
  width: 6px;
  background: var(--primary);
}

.chapter-card__number {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: var(--spacing-xs);
}

.chapter-card__title {
  font-family: var(--font-ui);
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: var(--spacing-xs);
  color: var(--text);
}

.chapter-card__summary {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.55;
  flex: 1;
}

.chapter-card__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--spacing-sm);
  font-family: var(--font-ui);
  font-size: 0.78rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding-top: var(--spacing-xs);
}

/* --- 必ず覚えてほしい3点 --- */
.key-points {
  background: var(--surface);
  border: 2px solid var(--primary);
  border-radius: var(--radius-md);
  padding: var(--spacing-lg);
  margin-bottom: var(--spacing-lg);
}

.key-points__title {
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: var(--spacing-md);
}

.key-point-item {
  display: flex;
  gap: var(--spacing-md);
  padding: var(--spacing-sm) 0;
  border-bottom: 1px solid var(--border);
}

.key-point-item:last-child {
  border-bottom: none;
}

.key-point-item__num {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 700;
}

.key-point-item__text {
  font-size: 0.95rem;
  padding-top: 4px;
}

/* --- 時間配分バー --- */
.time-bar-wrapper {
  margin-bottom: var(--spacing-lg);
}

.time-bar {
  display: flex;
  height: 12px;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: var(--spacing-sm);
}

.time-bar__segment {
  transition: flex 0.3s;
}

.time-bar__legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-xs) var(--spacing-md);
  font-family: var(--font-ui);
  font-size: 0.78rem;
}

.time-bar__legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.time-bar__dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}


/* =========================================================
   18. 温度グラデーション図（FIG-A-3 対応 SVG 周辺）
   ========================================================= */
.temp-scale {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.temp-zone {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-sm) var(--spacing-md);
  font-family: var(--font-ui);
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
  margin-bottom: 2px;
}

.temp-zone--under   { background: #eef2f5; color: #4a5568; }
.temp-zone--optimal { background: #edf7f0; color: #1a3d27; font-weight: 700; border: 1.5px solid var(--safe); }
.temp-zone--over    { background: #fff0ee; color: #5c0f00; font-weight: 700; }
.temp-zone--charcoal { background: #3d1a0a; color: #fff; font-weight: 700; }

.temp-zone__range {
  font-weight: 700;
  min-width: 100px;
  font-size: 0.9em;
}

/* =========================================================
   19. @media print
   ========================================================= */
@media print {
  :root {
    --background: #fff;
    --surface:    #fff;
    --shadow-sm: none;
    --shadow-md: none;
    --shadow-lg: none;
  }


  body {
    font-size: 12pt;
    color: #000;
    background: #fff;
  }

  .page-wrapper {
    max-width: 100%;
    padding: 0;
  }

  .slide {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ccc;
    margin-bottom: 16pt;
  }

  .chapter-nav { display: none; }

  .chapter-chip {
    background: #333;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .presenter-note {
    display: block; /* 印刷時に発表者ノートを表示 */
    border: 1pt dashed #999;
    page-break-inside: avoid;
  }

  a::after {
    content: ' (' attr(href) ')';
    font-size: 0.75em;
    opacity: 0.5;
  }

  .chapter-card::after { content: ''; }
}

/* =========================================================
   20. iPad レスポンシブ
   ========================================================= */

/* iPad 縦（768px） */
@media (max-width: 1024px) {
  :root {
    --sidebar-w: 240px;
    --spacing-xl: 40px;
  }

  .chapter-cards {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }
}

/* iPad 縦（768px以下）・モバイル */
@media (max-width: 768px) {
  :root {
    --font-size-base: 15px;
    --spacing-lg:  24px;
    --spacing-xl:  36px;
  }


  .figure-row {
    flex-direction: column;
    align-items: center;
  }

  .chapter-nav {
    flex-wrap: wrap;
    font-size: 0.82rem;
  }

  .chapter-nav a {
    padding: var(--spacing-xs) var(--spacing-sm);
  }

  .slide {
    padding: var(--spacing-md);
  }

  .cover-header {
    padding: var(--spacing-lg);
  }
}

/* =========================================================
   21. アクセシビリティ補助
   ========================================================= */
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* =========================================================
   22. 検索ジャンプ後のスライドハイライト
   ========================================================= */
.slide {
  scroll-margin-top: 24px;
}

@keyframes slideHighlightFade {
  0%,
  60% {
    box-shadow: 0 0 0 3px var(--accent), var(--shadow-sm);
    border-color: var(--accent);
  }
  100% {
    box-shadow: var(--shadow-sm);
    border-color: var(--border);
  }
}

.slide--highlighted {
  animation: slideHighlightFade 2.5s ease-out forwards;
}
