/* =========================================
   テーマ変数定義 (Color Palette)
   ========================================= */

/* ① 基本設定（ライトモード / Default） */
:root {
  /* --- レイアウトサイズ（共通） --- */
  --tab-width: 260px;
  --max-content-width: 980px;
  --section-padding: 80px;
  --radius-lg: 18px;
  --radius-pill: 999px;

  /* --- カラー: ライトモード --- */
  /* 青みを入れた爽やかなグラデーション */
  --bg-base: #ffffff;
  --bg-body: radial-gradient(circle at top, #e0efff 0%, #f8fbff 60%);
  --bg-nav: rgba(255, 255, 255, 0.85);
  --bg-section-border: #ffffff;
  --bg-overlay: rgba(255, 255, 255, 0.9); /* 画像に乗せる幕（白・すりガラス） */
  --bg-hero-overlay: rgba(255,255,255,0.85);
  --bg-card: #ffffff;
  --bg-input: #f8fafc;
  --bg-footer: #f8fafc;
  --bg-back-to-top: #ffffff;

  --text-main: #1e293b;  /* 濃いネイビーグレー */
  --text-muted: #64748b; /* スレートグレー */
  --text-inverse: #ffffff; /* ボタン文字は白 */
  --text-nav: #64748b;
  --text-nav-hover: #3fb4ff;

  /* アクセントは共通だが、視認性のために少し調整してもOK */
  --accent: #3fb4ff; 
  --accent-soft: rgba(63, 180, 255, 0.15);
  --accent-tag-bg: rgba(63, 180, 255, 0.08);

  --border-soft: #e2e8f0;
  --border-input: #cbd5e1;

  /* 影: 青みを含んだ柔らかい影 */
  --shadow-soft: 0 18px 45px rgba(63, 180, 255, 0.15);
  --shadow-card: 0 4px 20px rgba(0,0,0,0.05);

  /* --- カラー: ダークモード --- */

}

/* ② ライトモード（Light Mode Overrides） */
/* bodyタグに data-theme="light" が付いた時に上書き */
body[data-theme="dark"] {
  --bg-base: #0f0f0f;
  --bg-body: radial-gradient(circle at top, #151b2f 0, #05060a 55%);
  --bg-nav: rgba(5, 6, 10, 0.85);
  --bg-section-border: #1c2235;        /* セクション枠線 */
  --bg-overlay: rgba(0, 0, 0, 0.65);   /* 画像に乗せる幕（黒） */
  --bg-hero-overlay: rgba(0, 0, 0, 0.65); /* ヒーロー用 */
  --bg-card: radial-gradient(circle at top, rgba(255, 255, 255, 0.06), rgba(5, 6, 10, 0.95));
  --bg-input: rgba(255, 255, 255, 0.05);
  --bg-footer: #0a0b0f;
  --bg-back-to-top: rgba(255,255,255,0.08);

  --text-main: #f5f7ff;
  --text-muted: #a4a9c4;
  --text-inverse: #05060a; /* ボタン内の文字色 */
  --text-nav: #c8cce0;
  --text-nav-hover: #ffffff;

  --accent: #3fb4ff;
  --accent-soft: rgba(63, 180, 255, 0.2);
  --accent-tag-bg: rgba(63, 180, 255, 0.08);
  
  --border-soft: #1c2235;
  --border-input: rgba(255, 255, 255, 0.15);
  
  --shadow-soft: 0 18px 45px rgba(0, 0, 0, 0.55);
  --shadow-card: none;
}


/* =========================================
   基本スタイル
   ========================================= */
body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg-body);
  color: var(--text-main);
  line-height: 1.7;
  overflow-y: scroll;
  scroll-behavior: smooth;
  transition: background 0.3s ease, color 0.3s ease; /* テーマ切り替え時のアニメーション */
}

/* ===== ナビバー ===== */
.top-nav {
  position: sticky;
  top: 0;
  width: 100%;
  background: var(--bg-nav);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-soft);
  z-index: 50;
  transition: background 0.3s ease, border-color 0.3s ease;
}

.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-main);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.brand:visited { color: var(--text-main); }
.brand:hover { opacity: 0.85; text-decoration: none; }
.brand .logo { height: 28px; width: auto; display: block; }

.nav-list {
  list-style: none;
  display: flex;
  gap: 22px;
  margin: 0;
  padding: 0;
}

.nav-list a {
  position: relative;
  color: var(--text-nav);
  text-decoration: none;
  padding: 6px 4px;
  transition: color 0.25s ease;
  font-weight: 500;
}

.nav-list a:hover {
  color: var(--text-nav-hover);
}

.nav-list a.active {
  color: var(--text-main);
  font-weight: 600;
}

.nav-list a.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -4px;
  height: 2px;
  background: linear-gradient(90deg, #3fb4ff, #9f7bff);
  border-radius: 2px;
}

/* ===== Thanks Modal ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6); /* 共通で少し暗く */
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 200;
  backdrop-filter: blur(4px);
}

.modal.show { display: flex; }

.modal-content {
  background: var(--bg-card); /* カード背景変数を適用 */
  padding: 40px 30px;
  border-radius: 16px;
  text-align: center;
  max-width: 400px;
  width: 90%;
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-soft);
}

.modal-content h2 {
  margin-bottom: 12px;
  font-size: 1.4rem;
  color: var(--text-main);
}

.modal-content p {
  margin-bottom: 20px;
  color: var(--text-muted);
}

#modal-close {
  padding: 10px 20px;
  border-radius: 999px;
  background: linear-gradient(120deg, #3fb4ff, #9f7bff);
  color: var(--text-inverse); /* ボタン文字色変数 */
  font-weight: 600;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(63, 180, 255, 0.4);
}


/* ===== Contact Form ===== */
.contact-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-top: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.9rem;
  color: var(--text-main);
  font-weight: 500;
}

.form-group input,
.form-group textarea {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border-input);
  background: var(--bg-input);
  color: var(--text-main);
  font-size: 0.95rem;
  outline: none;
  transition: border 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  background: var(--bg-card); /* フォーカス時はカード色（白/黒）に */
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.contact-submit {
  margin-top: 10px;
  padding: 12px 20px;
  border-radius: 999px;
  background: linear-gradient(120deg, #3fb4ff, #9f7bff);
  color: var(--text-inverse);
  font-weight: 600;
  font-size: 1rem;
  border: none;
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.1s ease;
  box-shadow: 0 10px 25px rgba(63, 180, 255, 0.3);
}

.contact-submit:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

/* ===== Loading Spinner ===== */
.spinner {
  width: 16px;
  height: 16px;
  border: 3px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: none;
}

@keyframes spin { to { transform: rotate(360deg); } }

.button-loading .spinner { display: inline-block; }
.button-loading { pointer-events: none; opacity: 0.8; }


/* ===== セクション ===== */
.content {
  flex: 1;
  max-width: calc(100% - var(--tab-width));
  margin: 0 auto;
  scroll-snap-type: y mandatory;
}

section {
  padding: 40px 20px;
  display: flex;
  justify-content: center;
}

.section-inner {
  width: 100%;
  max-width: 900px;
  padding: 40px;
  border-radius: 18px;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--bg-section-border);
  box-shadow: var(--shadow-soft);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

/* 画像オーバーレイ（重要：ここでダーク/ライトの雰囲気を決定） */
.section-inner::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--bg-overlay); /* 黒 or 白 */
  z-index: 0;
  backdrop-filter: blur(2px);
  transition: background 0.3s ease;
}

.section-inner > * {
  position: relative;
  z-index: 1;
}

.section-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(63, 180, 255, 0.4);
  background: var(--accent-tag-bg);
  color: var(--accent);
  font-size: 0.75rem;
  margin-bottom: 18px;
  font-weight: 600;
}

.section-tag-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px rgba(63, 180, 255, 0.6);
}

.section-title {
  font-size: 1.9rem;
  margin-bottom: 12px;
  letter-spacing: 0.03em;
  color: var(--text-main);
}

.section-lead {
  font-size: 0.98rem;
  color: var(--text-muted);
  margin-bottom: 26px;
}

.section-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 26px;
  align-items: flex-start;
}

.section-text {
  font-size: 0.95rem;
  color: var(--text-main);
  opacity: 0.9;
}

.section-text p + p { margin-top: 1em; }
.section-text ul { margin-top: 0.8em; padding-left: 1.2em; }
.section-text li { margin-bottom: 0.4em; }

.section-images {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.image-card {
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border-soft);
  background: var(--bg-card);
  position: relative;
  box-shadow: var(--shadow-card);
}

.image-card img {
  width: 100%;
  display: block;
  object-fit: cover;
  max-height: 260px;
}

.image-caption {
  font-size: 0.78rem;
  color: var(--text-muted);
  padding: 8px 10px 10px;
  background: var(--bg-input); /* 入力欄と同じ薄い背景 */
}

/* ヒーローセクション専用 */
#hero .section-inner {
  padding-top: 52px;
  padding-bottom: 52px;
}

#hero .section-inner::before {
   background: var(--bg-hero-overlay); /* ヒーロー専用のオーバーレイ */
}

#hero .hero-title {
  font-size: 2.4rem;
  line-height: 1.25;
  margin-bottom: 14px;
  color: var(--text-main);
}

#hero .hero-title span.accent {
  background: linear-gradient(120deg, #3fb4ff, #9f7bff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

#hero .hero-lead {
  font-size: 1rem;
  color: var(--text-muted);
  max-width: 640px;
  margin-bottom: 26px;
}

#hero .hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 26px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

#hero .hero-meta span {
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-soft);
  background: var(--bg-card);
}

#hero .hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}

#hero .hero-cta a.primary {
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  background: linear-gradient(120deg, #3fb4ff, #9f7bff);
  color: var(--text-inverse);
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 8px 20px rgba(63, 180, 255, 0.4);
}

#hero .hero-cta a.secondary {
  padding: 10px 16px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-soft);
  font-size: 0.85rem;
  color: var(--text-muted);
  background: var(--bg-card);
  transition: all 0.2s ease;
}

#hero .hero-cta a.secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

#hero .hero-note {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 6px;
  opacity: 0.7;
}

/* ===== 背景画像（セクションごと） ===== */
#hero .section-inner { background-image: url("/images/bg-hero.jpg"); }
#django .section-inner { background-image: url("/images/bg-django.jpg"); }
#server .section-inner { background-image: url("/images/bg-server.jpg"); }
#azure .section-inner { background-image: url("/images/bg-azure.jpg"); }
#network .section-inner { background-image: url("/images/bg-network.jpg"); }
#about .section-inner { background-image: url("/images/bg-about.jpg"); }

/* ===== Back to Top Button ===== */
.back-to-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--bg-back-to-top);
  border: 1px solid var(--border-soft);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  color: var(--accent);
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease, background 0.3s ease;
  z-index: 300;
  backdrop-filter: blur(6px);
}

.back-to-top.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.back-to-top:hover {
  background: var(--border-soft);
  transform: translateY(-4px);
}


/* ===== Footer ===== */
.site-footer {
  padding: 30px 20px;
  background: var(--bg-footer);
  border-top: 1px solid var(--border-soft);
  transition: background 0.3s ease;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.footer-left {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.footer-right {
  display: flex;
  gap: 18px;
}

.footer-right a {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-decoration: none;
  transition: color 0.2s ease;
}

.footer-right a:hover {
  color: var(--text-nav-hover); /* フッターもナビと同じホバー色に */
}


/* ===== Breadcrumb ===== */
.breadcrumb {
  max-width: 900px;
  margin: 40px auto 20px;
  padding: 0 20px;
  font-size: 0.9rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.breadcrumb a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s ease;
}

.breadcrumb a:hover {
  color: var(--accent);
}

/* ナビバーの右端に配置 */
.theme-switch {
  width: 54px;
  height: 28px;
  background: var(--border-soft);
  border-radius: 999px;
  border: none;
  cursor: pointer;
  padding: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  transition: background 0.3s ease;
  margin-left: 20px;
}

/* 丸いハンドル */
.switch-handle {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  background: var(--text-main);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.35s ease, background 0.3s ease;
  color: var(--bg-base);
}

/* アイコン */
.icon-sun,
.icon-moon {
  width: 16px;
  height: 16px;
  position: absolute;
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* テーマ（初期） */
.icon-sun { opacity: 1; }

/* ダークテーマ */
body[data-theme="dark"] .icon-moon { opacity: 1; }
body[data-theme="dark"] .icon-sun { opacity: 0; }

/* ダークテーマ時のスライド位置 */
body[data-theme="dark"] .switch-handle {
  transform: translateX(26px);
}


/* ===== レスポンシブ (変更なし) ===== */
@media (max-width: 960px) {
  .page { flex-direction: column; }
  .content { max-width: 100%; }
  .section-grid { grid-template-columns: 1fr; }
  .nav-inner { flex-direction: column; align-items: flex-start; gap: 8px; }
  .nav-list { flex-wrap: wrap; gap: 14px; }
  section { padding: 20px 8px; }
  .section-inner { padding: 24px 20px 28px; }
  .section-title { font-size: 1.6rem; }
  .brand .logo { height: 22px; }  
}

@media (max-width: 600px) {
  #hero .hero-title { font-size: 1.4rem; }
  .nav-list a { font-size: 0.8rem; }
  .section-title { font-size: 1.4rem; }
  .brand .logo { height: 22px; }
  .footer-inner { flex-direction: column; text-align: center; }
}