/* ============================================================
   sanpo-common.css — sanpo-os 共通スタイル
   全ページ（index.html, report.html, 法的ページ等）で読み込む
   ============================================================ */

/* ── CSS変数（ダークモード＝デフォルト） ── */
:root {
  --bg-deep: #0d1f2d;
  --bg-grad-1: #1e4a5a;
  --bg-grad-2: #0f2a1e;
  --text-main: #d4e8e0;
  --text-sub: #8bb8a8;
  --text-faint: rgba(180, 215, 200, 0.5);
  --card-bg: rgba(255, 255, 255, 0.04);
  --card-border: rgba(140, 200, 180, 0.15);
  --accent: #7eceba;
  --accent-bg: rgba(126, 206, 186, 0.05);
  --accent-border: rgba(126, 206, 186, 0.12);
  --warn-bg: rgba(126, 206, 186, 0.06);
  --warn-border: rgba(126, 206, 186, 0.15);
  --warn-text: #7eceba;
  --stars-display: block;
  --mist-display: block;
}

/* ── ライトモード ── */
[data-theme="light"] {
  --bg-deep: #ffffff;
  --bg-grad-1: #ffffff;
  --bg-grad-2: #ffffff;
  --text-main: #333333;
  --text-sub: #3d3d3d;
  --text-faint: rgba(0, 0, 0, 0.65);
  --card-bg: #ffffff;
  --card-border: rgba(0, 0, 0, 0.08);
  --accent: #1a8a6e;
  --accent-bg: rgba(26, 138, 110, 0.06);
  --accent-border: rgba(26, 138, 110, 0.18);
  --warn-bg: rgba(26, 138, 110, 0.05);
  --warn-border: rgba(26, 138, 110, 0.18);
  --warn-text: #1a8a6e;
  --stars-display: none;
  --mist-display: none;
}

/* ── OS設定にも対応（手動切り替え優先） ── */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg-deep: #ffffff;
    --bg-grad-1: #ffffff;
    --bg-grad-2: #ffffff;
    --text-main: #333333;
    --text-sub: #3d3d3d;
    --text-faint: rgba(0, 0, 0, 0.65);
    --card-bg: #ffffff;
    --card-border: rgba(0, 0, 0, 0.08);
    --accent: #1a8a6e;
    --accent-bg: rgba(26, 138, 110, 0.06);
    --accent-border: rgba(26, 138, 110, 0.18);
    --warn-bg: rgba(26, 138, 110, 0.05);
    --warn-border: rgba(26, 138, 110, 0.18);
    --warn-text: #1a8a6e;
    --stars-display: none;
    --mist-display: none;
  }
}

/* ── リセット＋ベース ── */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: radial-gradient(ellipse at 30% 20%, var(--bg-grad-1) 0%, var(--bg-deep) 60%),
              radial-gradient(ellipse at 80% 80%, var(--bg-grad-2) 0%, transparent 60%);
  background-color: var(--bg-deep);
  background-attachment: fixed;
  font-family: 'Noto Serif JP', serif;
  color: var(--text-main);
  overflow-x: hidden;
  min-height: 100vh;
  transition: background-color 0.4s, color 0.4s;
}

/* ── 星空 ── */
.stars {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 0;
  display: var(--stars-display);
}
.star {
  position: absolute; border-radius: 50%;
  background: rgba(200, 240, 220, 0.7);
  animation: twinkle var(--dur, 4s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}
@keyframes twinkle {
  0%, 100% { opacity: 0.1; transform: scale(1); }
  50% { opacity: 0.9; transform: scale(1.4); }
}

/* ── 霧 ── */
.mist-layer {
  position: fixed; bottom: 0; left: -20%; width: 140%; height: 35vh;
  background: linear-gradient(to top, rgba(30, 80, 70, 0.18) 0%, transparent 100%);
  pointer-events: none; z-index: 0;
  animation: mistDrift 12s ease-in-out infinite alternate;
  display: var(--mist-display);
}
@keyframes mistDrift {
  0% { transform: translateX(0) scaleY(1); opacity: 0.6; }
  100% { transform: translateX(3%) scaleY(1.1); opacity: 1; }
}

/* ── テーマ切り替えボタン ── */
.theme-toggle {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 999;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  transition: all 0.3s;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.theme-toggle:hover {
  border-color: var(--accent);
  transform: scale(1.1);
}
/* アイコン切り替え: ダーク時は☀（ライトに切り替え）、ライト時は🌙（ダークに切り替え） */
.theme-toggle-icon-sun { display: inline; }
.theme-toggle-icon-moon { display: none; }
[data-theme="light"] .theme-toggle-icon-sun { display: none; }
[data-theme="light"] .theme-toggle-icon-moon { display: inline; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .theme-toggle-icon-sun { display: none; }
  :root:not([data-theme="dark"]) .theme-toggle-icon-moon { display: inline; }
}

/* ── 共通フッター ── */
.sanpo-footer {
  margin-top: 1.5rem;
  text-align: center;
  padding-top: 1rem;
  border-top: 1px solid rgba(140, 200, 180, 0.06);
}
.sanpo-footer-disclaimer {
  font-size: 0.58rem;
  color: var(--text-faint);
  line-height: 1.6;
  margin-bottom: 0.8rem;
}
.sanpo-footer-link {
  display: inline-block;
  font-size: 0.7rem;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: 0.08em;
  opacity: 0.7;
  transition: opacity 0.3s;
}
.sanpo-footer-link:hover { opacity: 1; }

/* ── ライトモード追加スタイル ── */
/* カードに軽いシャドウで浮かせる */
[data-theme="light"] .detail-inner,
[data-theme="light"] #fairyMessage,
[data-theme="light"] .upload-area,
[data-theme="light"] .result-card,
[data-theme="light"] .omamori-section,
[data-theme="light"] .category-card {
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06), 0 0 1px rgba(0, 0, 0, 0.08);
  border-color: rgba(0, 0, 0, 0.06);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .detail-inner,
  :root:not([data-theme="dark"]) #fairyMessage,
  :root:not([data-theme="dark"]) .upload-area,
  :root:not([data-theme="dark"]) .result-card,
  :root:not([data-theme="dark"]) .omamori-section,
  :root:not([data-theme="dark"]) .category-card {
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06), 0 0 1px rgba(0, 0, 0, 0.08);
    border-color: rgba(0, 0, 0, 0.06);
  }
}

/* テーマ切り替えボタンの視認性向上（ライト時） */
[data-theme="light"] .theme-toggle {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.12);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .theme-toggle {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.12);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  }
}

/* フッターのボーダーをライトモードで見やすく */
[data-theme="light"] .sanpo-footer {
  border-top-color: rgba(0, 0, 0, 0.08);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .sanpo-footer {
    border-top-color: rgba(0, 0, 0, 0.08);
  }
}
