/* =========================================================
   Simulation Lab — base stylesheet
   テーマカラーや共通レイアウトをここで一元管理します。
   ========================================================= */

:root {
  --bg: #0c130d;
  --bg-elev: #141d16;
  --bg-card: #18241b;
  --border: #2a3a2f;
  --text: #e7f1e9;
  --text-dim: #9bb3a3;
  --accent: #51cf66;
  --accent-2: #63e6be;
  --accent-warm: #ffa94d;
  --radius: 14px;
  --maxw: 1100px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  --font: "Segoe UI", "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
  --mono: "Cascadia Code", "Consolas", monospace;
}

/* ライトテーマ（data-theme="light" で切替） */
:root[data-theme="light"] {
  --bg: #eef6f0;
  --bg-elev: #ffffff;
  --bg-card: #ffffff;
  --border: #cfe2d5;
  --text: #18271d;
  --text-dim: #57705f;
  --shadow: 0 8px 30px rgba(20, 60, 40, 0.08);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

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

.container {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- ヘッダー / ナビ ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 62px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
}
.brand:hover { text-decoration: none; }
.brand .dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 12px var(--accent);
}
/* ブランドアイコン（ファビコンと同じ森の絵） */
.brand-icon { width: 26px; height: 26px; border-radius: 7px; display: block; }
.nav-links { display: flex; align-items: center; gap: 22px; }
.nav-links a { color: var(--text-dim); font-size: 0.95rem; }
.nav-links a:hover, .nav-links a.active { color: var(--text); text-decoration: none; }

.theme-toggle {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  width: 38px; height: 38px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 1rem;
}
.nav-toggle { display: none; background: none; border: 0; color: var(--text); font-size: 1.5rem; cursor: pointer; }

/* ---------- ヒーロー ---------- */
.hero {
  position: relative;
  padding: 90px 0 70px;
  text-align: center;
  overflow: hidden;
}
.hero::before {
  content: "";
  position: absolute; inset: 0;
  background:
    radial-gradient(600px 300px at 30% 0%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%),
    radial-gradient(500px 280px at 75% 20%, color-mix(in srgb, var(--accent-2) 18%, transparent), transparent 70%);
  pointer-events: none;
}
.hero h1 {
  position: relative;
  font-size: clamp(2rem, 5vw, 3.2rem);
  line-height: 1.25;
  margin: 0 0 18px;
  letter-spacing: 0.5px;
}
.hero p {
  position: relative;
  max-width: 640px;
  margin: 0 auto 28px;
  color: var(--text-dim);
  font-size: 1.1rem;
}
.hero .cta { position: relative; display: inline-flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

.btn {
  display: inline-block;
  padding: 12px 22px;
  border-radius: 10px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
}
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #06121f; }
.btn-primary:hover { text-decoration: none; filter: brightness(1.05); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { text-decoration: none; border-color: var(--accent); }

/* ---------- セクション ---------- */
.section { padding: 56px 0; }
.section-head { margin-bottom: 28px; }
.section-head h2 { font-size: 1.7rem; margin: 0 0 8px; }
.section-head p { color: var(--text-dim); margin: 0; }
.eyebrow {
  display: inline-block;
  font-size: 0.78rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}

/* ---------- カードグリッド ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
}
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.card:hover { transform: translateY(-4px); border-color: var(--accent); box-shadow: var(--shadow); }
.card a.card-media, .card a.card-body { text-decoration: none; color: inherit; }
.card-media { aspect-ratio: 16 / 10; background: #000; overflow: hidden; }
.card-media img { width: 100%; height: 100%; object-fit: cover; }
.card-body { padding: 18px 20px 22px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-size: 0.72rem;
  padding: 3px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}
.card-body h3 { margin: 2px 0; font-size: 1.2rem; line-height: 1.4; }
.card-body p { margin: 0; color: var(--text-dim); font-size: 0.95rem; }
.card-meta { margin-top: auto; font-size: 0.82rem; color: var(--text-dim); }

/* ---------- 横スクロールカルーセル（トップの注目・便利ツール） ---------- */
.carousel-wrap { position: relative; }
.grid.carousel {
  display: flex;
  grid-template-columns: none;        /* grid 設定を無効化 */
  gap: 20px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;      /* きっちりスナップ */
  scroll-behavior: smooth;
  scroll-padding-left: 4px;
  padding: 4px 4px 10px;              /* スクロールバー・浮き上がり用の余白 */
  margin: 0 -4px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.grid.carousel::-webkit-scrollbar { height: 8px; }
.grid.carousel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }
.grid.carousel::-webkit-scrollbar-track { background: transparent; }
/* 1ビューにちょうど2件（gap 20px ぶんを差し引いた半分） */
.grid.carousel > .card {
  flex: 0 0 calc(50% - 10px);
  max-width: calc(50% - 10px);
}
/* 2件ずつ（奇数番目＝各ペアの先頭）でスナップ */
.grid.carousel > .card:nth-child(odd) { scroll-snap-align: start; }
/* スマホでは1件ずつ表示・全カードでスナップ */
@media (max-width: 600px) {
  .grid.carousel > .card { flex: 0 0 100%; max-width: 100%; scroll-snap-align: start; }
}

.carousel-btn {
  position: absolute;
  top: 96px;                           /* サムネイル中央あたり */
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 1.4rem; line-height: 1;
  cursor: pointer; z-index: 3;
  box-shadow: 0 4px 14px rgba(0,0,0,.3);
  transition: border-color .15s, color .15s, opacity .15s;
}
.carousel-btn:hover { border-color: var(--accent); color: var(--accent); }
.carousel-prev { left: -10px; }
.carousel-next { right: -10px; }
.carousel-btn[hidden] { display: none; }
@media (max-width: 600px) { .carousel-btn { display: none; } }

/* 一覧ページの絞り込み見出し（?lang= / ?tag= 指定時に表示） */
.filter-info { margin: 0 0 22px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.filter-info:empty { display: none; }
.filter-chip {
  font-size: 0.9rem;
  padding: 6px 14px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--text);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}
.filter-clear { font-size: 0.85rem; color: var(--text-dim); }
.filter-clear:hover { color: var(--accent); }

/* お問い合わせフォーム */
.contact-form { max-width: 640px; margin: 8px 0 0; }
.form-row { margin-bottom: 18px; }
.form-row label { display: block; font-size: 0.92rem; margin-bottom: 6px; color: var(--text); }
.form-row .req { color: var(--accent); margin-left: 4px; }
.form-row input,
.form-row textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 11px 13px;
  font: inherit;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.form-row input:focus,
.form-row textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.form-row textarea { resize: vertical; min-height: 150px; }
.form-actions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.form-note { font-size: 0.85rem; color: var(--text-dim); }
.form-status { margin-top: 14px; font-size: 0.9rem; color: var(--accent); }
/* ハニーポット（画面外に隠す。display:none にしないのはボットに気づかせないため） */
.hp-field { position: absolute; left: -9999px; top: auto; width: 1px; height: 1px; overflow: hidden; }

/* テーマカード（背景にテーマ別のイラストを薄く敷く）
   各カードに style="--topic-img:url('...')" で画像を指定する。
   左側はカード色のグラデーションで覆い、見出し・本文の可読性を確保。 */
.topic-card {
  background-image:
    linear-gradient(100deg,
      var(--bg-card) 38%,
      color-mix(in srgb, var(--bg-card) 35%, transparent) 64%,
      transparent 82%),
    var(--topic-img);
  background-repeat: no-repeat, no-repeat;
  background-position: center, right -10px bottom -10px;
  background-size: cover, 58%;
}
/* テーマ別の背景画像（パスはこの style.css からの相対）。
   新テーマを足すときはここに1行追加し、HTML側に同名クラスを付けるだけ。 */
.topic-control   { --topic-img: url('../img/topics/control.svg?v=20260614a'); }
.topic-structure { --topic-img: url('../img/topics/structure.svg?v=20260614a'); }
.topic-fluid     { --topic-img: url('../img/topics/fluid.svg?v=20260614a'); }
.topic-ml        { --topic-img: url('../img/topics/ml.svg?v=20260614a'); }
.topic-vehicle   { --topic-img: url('../img/topics/vehicle.svg?v=20260614a'); }
.topic-aviation  { --topic-img: url('../img/topics/aviation.svg?v=20260614a'); }
.topic-image     { --topic-img: url('../img/topics/image.svg?v=20260614a'); }
.topic-mechanism { --topic-img: url('../img/topics/mechanism.svg?v=20260614a'); }

/* クリック可能なテーマカード + 記事一覧パネル */
.topics-hint { color: var(--text-dim); font-size: 0.9rem; margin: -6px 0 14px; }
.topic-card { cursor: pointer; transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease; }
.topic-card:hover { transform: translateY(-3px); border-color: var(--accent); }
.topic-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.topic-card.topic-active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }

.topic-panel { display: none; margin-top: 18px; }
.topic-panel.show {
  display: block;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px;
}
.topic-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.topic-panel-head h3 { margin: 0; font-size: 1.05rem; }
.topic-panel-close {
  background: transparent; border: 1px solid var(--border); color: var(--text-dim);
  border-radius: 8px; width: 30px; height: 30px; cursor: pointer; line-height: 1; flex: none;
}
.topic-panel-close:hover { color: var(--text); border-color: var(--accent); }
.topic-empty { color: var(--text-dim); margin: 4px 0 0; }
.topic-list { list-style: none; margin: 0; padding: 0; }
.topic-list li { padding: 9px 0; border-top: 1px solid var(--border); }
.topic-list li:first-child { border-top: none; }
.topic-list li a { font-weight: 600; }
.topic-list-tags { display: inline-block; margin-left: 8px; font-size: 0.8rem; color: var(--text-dim); }

/* ---------- 記事ページ ---------- */
.article { padding: 48px 0 64px; }
.article-header { max-width: 760px; margin: 0 auto 32px; text-align: center; }
.article-header h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); margin: 14px 0 14px; }
.article-header .meta { color: var(--text-dim); font-size: 0.9rem; }
.prose { max-width: 760px; margin: 0 auto; }
.prose h2 { font-size: 1.5rem; margin: 42px 0 14px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.prose h3 { font-size: 1.2rem; margin: 28px 0 10px; }
.prose p { margin: 14px 0; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose figure { margin: 28px 0; }
.prose figure img { border-radius: var(--radius); border: 1px solid var(--border); margin: 0 auto; }
.prose figcaption { text-align: center; color: var(--text-dim); font-size: 0.85rem; margin-top: 8px; }
.prose code {
  font-family: var(--mono);
  background: var(--bg-elev);
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 0.9em;
  border: 1px solid var(--border);
}
.prose pre {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  overflow-x: auto;
}
.prose pre code { background: none; border: 0; padding: 0; }
.callout {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 14px 18px;
  margin: 22px 0;
}
.back-link { display: inline-block; margin-bottom: 8px; color: var(--text-dim); font-size: 0.9rem; }

/* スペック表 */
.spec-table { width: 100%; border-collapse: collapse; margin: 20px 0; font-size: 0.92rem; }
.spec-table th, .spec-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.spec-table th { color: var(--text-dim); font-weight: 600; width: 38%; }

/* ---------- 2カラムレイアウト（メイン＋サイドバー） ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 38px;
  align-items: start;
}
.layout-main { min-width: 0; }

.sidebar {
  position: sticky;
  top: 84px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.sidebar-widget {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 20px;
}
.widget-title {
  margin: 0 0 14px;
  font-size: 1rem;
  padding-left: 11px;
  border-left: 4px solid var(--accent);
}

/* プロフィール */
.sidebar-widget.profile { text-align: center; }
.profile-avatar {
  width: 92px; height: 92px;
  border-radius: 50%;
  margin: 0 auto 12px;
  border: 3px solid var(--border);
  background: var(--bg-elev);
  padding: 6px;
  object-fit: cover;
}
.profile-name { font-weight: 700; font-size: 1.1rem; margin-bottom: 8px; }
.profile-bio { color: var(--text-dim); font-size: 0.88rem; margin: 0 0 14px; text-align: left; }
.profile-link { font-size: 0.88rem; }

/* SNSボタン */
.sns-buttons { display: flex; flex-direction: column; gap: 10px; }
.sns-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.92rem;
  color: #fff;
  border: 1px solid transparent;
}
.sns-btn:hover { text-decoration: none; filter: brightness(1.08); }
.sns-btn svg { width: 20px; height: 20px; fill: currentColor; flex: none; }
.sns-btn.youtube { background: #ff0000; }
.sns-btn.x { background: #000; border-color: #2a2a2a; }
:root[data-theme="light"] .sns-btn.x { border-color: #000; }

/* サイドバーのリスト（カテゴリ等） */
.widget-list { list-style: none; margin: 0; padding: 0; }
.widget-list li { border-bottom: 1px solid var(--border); }
.widget-list li:last-child { border-bottom: 0; }
.widget-list a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 2px;
  color: var(--text);
  font-size: 0.9rem;
}
.widget-list a:hover { color: var(--accent); text-decoration: none; }
.widget-list a::after { content: "›"; color: var(--text-dim); }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; gap: 28px; }
  .sidebar { position: static; }
}

/* ---------- フッター ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 36px 0;
  color: var(--text-dim);
  font-size: 0.9rem;
}
.footer-inner { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 16px; }
.footer-inner a { color: var(--text-dim); }

/* ---------- 広告枠（アフィリエイト / AdSense 等） ----------
   使い方: <div class="ad-slot"> の中に各ASPの広告コードを貼るだけ。
   「広告」ラベルはステマ規制（景品表示法）対応で自動表示します。
   非表示にしたい枠は <div class="ad-slot" hidden> にすると消えます。 */
.ad-slot {
  margin: 30px auto;
  max-width: 760px;
  text-align: center;
  background: var(--bg-elev);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  min-height: 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  overflow: hidden;
}
.ad-slot::before {
  content: "広告";
  font-size: 0.68rem;
  letter-spacing: 1px;
  color: var(--text-dim);
}
.ad-slot:empty::after,
.ad-slot:has(> .ad-placeholder)::after { content: ""; }
/* コード未挿入時に表示されるプレースホルダー（貼り付け後は削除してOK） */
.ad-placeholder { color: var(--text-dim); font-size: 0.85rem; }
.ad-slot > img, .ad-slot > ins, .ad-slot > iframe { max-width: 100%; }

/* 一覧グリッドの中に置く広告（カード幅に馴染ませる） */
.ad-slot--card { margin: 0; max-width: none; height: 100%; min-height: 200px; }

/* ---------- YouTube 埋め込み / チャンネルボタン ---------- */
/* レスポンシブな16:9埋め込み枠。中に <iframe> を入れて使う */
.video-embed {
  position: relative;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: #000;
}
.video-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
/* 複数動画を並べるグリッド */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}
.video-grid .video-embed { max-width: none; }

/* YouTubeボタン（ブランドカラー） */
.btn-youtube {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #ff0000;
  color: #fff;
}
.btn-youtube:hover { text-decoration: none; filter: brightness(1.08); }
.btn-youtube svg { width: 20px; height: 20px; fill: currentColor; }

/* ---------- レスポンシブ ---------- */
@media (max-width: 720px) {
  .nav-links {
    position: absolute; top: 62px; left: 0; right: 0;
    flex-direction: column; align-items: flex-start; gap: 0;
    background: var(--bg-elev); border-bottom: 1px solid var(--border);
    padding: 8px 20px; display: none;
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 10px 0; width: 100%; }
  .nav-toggle { display: block; }
}
