/* css/base.css */
/* フォントは授業ページと同じシステムフォントを使用（Google Fonts 不要） */

:root {
  /* --- Colors（授業ページと統一） --- */
  --col-bg: #f8fafc;
  --col-text: #1e293b;
  --col-text-sub: #64748b;

  --col-primary: #0ea5e9;
  --col-primary-light: #e0f2fe;
  --col-primary-dark: #0284c7;
  --col-accent: #f43f5e;
  --col-accent-light: #ffe4e6;
  --col-success: #10b981;
  --col-success-light: #d1fae5;
  --col-warning: #f59e0b;
  --col-warning-light: #fef3c7;

  /* グラデーション */
  --gradient-primary: linear-gradient(135deg, #0ea5e9 0%, #8b5cf6 100%);
  --gradient-accent: linear-gradient(135deg, #f43f5e 0%, #fb923c 100%);
  --gradient-hero: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --gradient-card-hover: linear-gradient(135deg, rgba(14,165,233,0.04) 0%, transparent 40%, rgba(139,92,246,0.035) 100%);

  /* --- Compatibility Aliases --- */
  --col-main: var(--col-primary);
  --col-sub: var(--col-text-sub);
  --text-main: var(--col-text);
  --text-sub: var(--col-text-sub);
  --col-highlight: #fef08a;

  /* --- Z-Index Layer Management --- */
  --z-header: 100;
  --z-sim-controls: 200;
  --z-slide-nav: 500;
  --z-pointer: 1000;
  --z-modal: 2000;
  --z-toast: 15000;
  --z-back-to-top: 900;

  /* --- Component Settings（授業ページと統一） --- */
  --card-bg: rgba(255, 255, 255, 0.82);
  --card-shadow:
    0 1px 2px rgba(0,0,0,0.03),
    0 4px 16px rgba(148,163,184,0.08),
    0 16px 48px rgba(148,163,184,0.06);
  --card-radius: 20px;
  --card-border: rgba(226, 232, 240, 0.7);
  --card-border-width: 1px;
  --card-backdrop: blur(20px) saturate(1.8);

  --card-width: 860px;

  --font-base: "Noto Sans JP", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "BIZ UDPGothic", "Meiryo", system-ui, sans-serif;

  /* --- Transitions --- */
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* レスポンシブ --card-width（メインサイト base.css と統一） */
@media (min-width: 1024px) {
  :root { --card-width: min(1100px, 92vw); }
}
@media (max-width: 767px) {
  :root { --card-width: 100%; }
}

/* ダークモードは未使用（ライトモード固定） */

/* --- Base Styles --- */
body {
  font-family: var(--font-base);
  background-color: var(--col-bg);
  background-image: linear-gradient(135deg, rgba(14,165,233,0.04) 0%, transparent 40%, rgba(139,92,246,0.035) 100%);
  background-size: cover;
  background-attachment: fixed;
  color: var(--col-text);
  margin: 0;
  padding: 20px 2vw;
  line-height: 1.9;
  font-size: 18px;
  -webkit-font-smoothing: antialiased;
}

/* スクロールバー装飾 */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}
h1, h2, h3, button, input {
  font-family: var(--font-base);
}

a {
  text-decoration: none;
  color: inherit;
}

/* --- ページ遷移アニメーション --- */
@keyframes pageEnter {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.page-enter {
  animation: pageEnter 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* --- スタガーアニメーション --- */
@keyframes staggerFadeIn {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.stagger-item {
  opacity: 0;
  animation: staggerFadeIn 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* --- パルスアニメーション --- */
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* --- シマーアニメーション（スケルトンローディング） --- */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: linear-gradient(90deg, var(--card-border) 25%, rgba(255,255,255,0.3) 50%, var(--card-border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
}

/* --- ローディングオーバーレイ --- */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(248, 250, 252, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: var(--z-modal);
  transition: opacity 0.3s;
}
.loading-overlay-hide {
  opacity: 0;
  pointer-events: none;
}
.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--card-border);
  border-top-color: var(--col-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.loading-message {
  margin: 0;
  color: var(--col-text-sub);
  font-weight: 500;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- アプリ用トースト（index/viewer） --- */
.app-toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.app-toast-container .app-toast {
  pointer-events: auto;
  padding: 12px 20px;
  background: var(--col-text);
  color: #fff;
  border-radius: 12px;
  font-size: 0.95rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  transition: opacity 0.3s, transform 0.3s;
}
.app-toast.app-toast-error {
  background: var(--col-accent);
}
.app-toast.app-toast-hide {
  opacity: 0;
  transform: translateY(8px);
}

/* --- アクセシビリティ: フォーカス表示 --- */
:focus-visible {
  outline: 2px solid var(--col-primary);
  outline-offset: 2px;
}
button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid var(--col-primary);
  outline-offset: 2px;
}

/* --- スキップリンク --- */
.skip-link {
  position: absolute;
  top: -100px;
  left: 12px;
  padding: 12px 20px;
  background: var(--col-primary);
  color: #fff;
  border-radius: 8px;
  font-weight: 700;
  z-index: 10000;
  transition: top 0.2s;
}
.skip-link:focus {
  top: 12px;
}

/* --- サイトフッター（全ページ共通） --- */
.site-footer {
  margin-top: auto;
  padding: 24px 16px 28px;
  background: var(--card-bg);
  border-top: 1px solid var(--card-border);
  text-align: center;
  transition: background var(--transition-normal), border-color var(--transition-normal);
}
.site-footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  font-size: 0.9rem;
  color: var(--col-text-sub);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 0;
}
.site-footer-inner a {
  color: var(--col-primary);
  font-weight: 500;
  transition: color var(--transition-fast);
}
.site-footer-inner a:hover {
  text-decoration: underline;
}
.site-footer-sep {
  margin: 0 10px;
  color: var(--card-border);
}

/* --- Back-to-Top ボタン --- */
.back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--z-back-to-top);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--gradient-primary);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  box-shadow: 0 4px 16px rgba(59,130,246,0.35);
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px);
  transition: all var(--transition-normal);
}
.back-to-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.back-to-top:hover {
  transform: translateY(-2px) scale(1.1);
  box-shadow: 0 8px 28px rgba(59,130,246,0.5);
}
.back-to-top:active {
  transform: scale(0.95);
}

/* --- 広告枠 --- */
.ad-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 90px;
  background: #f1f5f9;
  border-radius: 12px;
  margin: 16px 0;
}
.ad-slot:empty {
  display: none;
}
.ad-slot--top { margin-top: 24px; }
.ad-slot--sidebar { margin: 16px 0; }

/* --- プログレスバー（ページ上部） --- */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 3px;
  background: var(--gradient-primary);
  z-index: 99999;
  transition: width 0.1s linear;
  border-radius: 0 2px 2px 0;
}