/* ============================================================
   article.css — 記事ページ共通スタイル
   Dark theme base + Mobile responsive
   ============================================================ */

/* ── 0. ページ横スクロール完全禁止 ───────────────────────── */
html, body {
  overflow-x: hidden;
  max-width: 100%;
}

/* ── 0b. 記事目次（TOC）スタイル ─────────────────────────── */
.art-toc {
  background: #0d1a2d;
  border: 1px solid #1e3a5f;
  border-left: 3px solid #facc15;
  border-radius: 0 8px 8px 0;
  padding: 1rem 1.2rem;
  margin: 1.5rem 0 2rem;
  font-size: .88rem;
}
.art-toc-title {
  font-size: .78rem;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #facc15;
  margin-bottom: .75rem;
}
.art-toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: toc-counter;
}
.art-toc-item {
  counter-increment: toc-counter;
  padding: .3rem 0;
  border-bottom: 1px solid rgba(30,58,95,.5);
  display: flex;
  align-items: baseline;
  gap: .5rem;
}
.art-toc-item:last-child { border-bottom: none; }
.art-toc-item::before {
  content: counter(toc-counter);
  flex-shrink: 0;
  font-size: .72rem;
  font-weight: 900;
  color: #475569;
  width: 1.2rem;
  text-align: right;
}
.art-toc-item.art-toc-sub {
  padding-left: 1.5rem;
  counter-increment: none;
}
.art-toc-item.art-toc-sub::before { content: '–'; color: #1e3a5f; }
.art-toc-item a {
  color: #93c5fd;
  text-decoration: none;
  line-height: 1.5;
  transition: color .15s;
  flex: 1;
}
.art-toc-item a:hover { color: #facc15; opacity: 1; }

@media (max-width: 480px) {
  .art-toc { font-size: .82rem; padding: .8rem 1rem; }
  .art-toc-title { font-size: .72rem; }
}

/* ── 1. ダーク背景ベース ──────────────────────────────────── */
body {
  background: #0a1628;
  color: #cbd5e1;
}

/* ── 2. ヘッダー内ロゴ（記事ページ版） ───────────────────── */
.site-logo {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 1rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: .04em;
  line-height: 1.2;
}
.logo-img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.4));
}
/* logo-main/logo-sub を持つ場合のラッパー */
.site-logo > div {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.site-logo span {
  color: #facc15;
}

/* ── 3. グローバルナビ（記事ページ版 .global-nav） ─────────── */
.global-nav ul {
  display: flex;
  gap: 4px;
  list-style: none;
  padding: 0;
  margin: 0;
  align-items: center;
}
.global-nav ul li a {
  color: rgba(255,255,255,.85);
  font-size: .82rem;
  padding: 6px 10px;
  border-radius: 4px;
  display: block;
  white-space: nowrap;
  transition: background .18s;
}
.global-nav ul li a:hover {
  background: rgba(255,255,255,.15);
  opacity: 1;
}

/* ── 4. ダークパンくずリスト（<nav class="breadcrumb">） ───── */
nav.breadcrumb {
  background: #0d1e35;
  border-bottom: 1px solid #1e3a5f;
}
nav.breadcrumb ol {
  max-width: 1100px;
  margin: 0 auto;
  padding: .55rem 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: .2rem .5rem;
  list-style: none;
  font-size: .78rem;
  align-items: center;
}
nav.breadcrumb li {
  color: #64748b;
}
nav.breadcrumb li + li::before {
  content: '›';
  margin-right: .5rem;
  color: #334155;
}
nav.breadcrumb li a {
  color: #60a5fa;
  text-decoration: none;
  transition: color .18s;
}
nav.breadcrumb li a:hover {
  color: #93c5fd;
  opacity: 1;
}

/* ── 5. アートヒーロー ───────────────────────────────────── */
/* インライン <style> で flex 定義されている記事のヒーロー section。
   flex item の ogp-hero / art-thumb-img / art-hero-body が
   コンテナ幅を超えないよう !important で制約する */
.art-hero {
  background: #0a1628;
  overflow: hidden;          /* flex children のはみ出しをクリップ */
  box-sizing: border-box;
  max-width: 100% !important;
  width: 100% !important;
}
/* OGP カード: インラインで max-width:600px 指定されるが
   !important で 100% に抑える（container-query も再解決される） */
.ogp-hero {
  max-width: min(600px, 100%) !important;
  width: 100% !important;
  box-sizing: border-box;
  flex-shrink: 1 !important;
  min-width: 0 !important;
}

/* ── 5b. 記事ヒーロー内サムネイル（OGP カード置き換え） ───── */
.art-thumb-img {
  display: block;
  width: 100% !important;
  max-width: 560px;
  height: auto;
  margin: 20px auto 0;
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.45);
}

/* ── 6. メインコンテンツ・記事グリッド ──────────────────── */
.main-content {
  overflow: hidden;
  box-sizing: border-box;
  max-width: 100% !important;
  width: 100%;
}
.art-layout {
  overflow: hidden;
  box-sizing: border-box;
  max-width: 100% !important;
}
.art-body,
article.art-body {
  min-width: 0 !important;
  max-width: 100% !important;
  overflow-x: hidden;
  overflow-wrap: break-word;
  word-break: break-word;
  box-sizing: border-box;
}
.sidebar {
  min-width: 0 !important;
  max-width: 100% !important;
  box-sizing: border-box;
  overflow: hidden;
}

/* ── 7. テーブルのスクロール対応 ─────────────────────────── */
/* テーブルを囲む .data-table-wrap があれば自動スクロール */
.data-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 1rem 0 1.5rem;
}
/* art-body 内の全テーブル：横スクロールはテーブル自身で吸収 */
.art-body table {
  max-width: 100%;
  border-collapse: collapse;
}
/* ラッパーなしの生テーブルも横スクロール可能に */
.art-body > table,
.art-body section table,
.art-body div:not(.data-table-wrap) > table {
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── 8. フッター（記事ページ版） ────────────────────────── */
.site-footer {
  background: #0d1e35;
  border-top: 1px solid #1e3a5f;
  margin-top: 0;
}
.site-footer p {
  color: rgba(255,255,255,.45);
  font-size: .78rem;
  padding: 1.4rem 1.5rem;
  text-align: center;
  margin: 0;
}

/* ============================================================
   モバイル レスポンシブ
   ============================================================ */

/* ── SP: ヘッダー nav 折り返し ──────────────────────────── */
@media (max-width: 600px) {
  .header-inner {
    padding: 0 12px;
    height: 52px;
  }
  .global-nav ul {
    gap: 2px;
  }
  .global-nav ul li a {
    font-size: .72rem;
    padding: 5px 7px;
  }
  .site-logo {
    font-size: .88rem;
  }
}

/* ── SP: パンくずリスト ───────────────────────────────────── */
@media (max-width: 480px) {
  nav.breadcrumb ol {
    padding: .45rem 1rem;
    font-size: .72rem;
  }
}

/* ── SP: アートヒーロー ─────────────────────────────────── */
@media (max-width: 660px) {
  .art-hero {
    flex-direction: column;
    gap: 1rem;
    margin: 1rem auto;
    padding: 0 1rem;
  }
  .ogp-hero {
    max-width: 100%;
    width: 100%;
  }
  .art-hero-body {
    min-width: unset !important;
    width: 100%;
  }
  .art-title {
    font-size: 1.2rem !important;
  }
}

/* ── SP: 記事ヒーロー内サムネイル ───────────────────────── */
@media (max-width: 660px) {
  .art-thumb-img {
    max-width: 100%;
    margin: 12px auto 0;
    border-radius: 7px;
  }
}

/* ── SP: メインコンテンツ padding ────────────────────────── */
@media (max-width: 660px) {
  /* インラインスタイルを上書きするため !important */
  .art-hero {
    /* インライン flex art-hero のスタック化 */
    flex-direction: column !important;
    padding-left: 1rem !important;
    padding-right: 1rem !important;
    gap: 1rem !important;
    overflow: hidden !important;
  }
  .art-hero-body {
    min-width: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  .ogp-hero {
    width: 100% !important;
    max-width: 100% !important;
    flex-shrink: 1 !important;
  }
  .main-content {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
    overflow-x: hidden !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
  .art-layout {
    grid-template-columns: 1fr !important;
    overflow: hidden !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
  .art-body,
  article.art-body {
    min-width: 0 !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
  }
}

/* ── SP: 記事本文グリッド ────────────────────────────────── */
@media (max-width: 860px) {
  /* サイドバーを2列に整える */
  .sidebar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
  }
}
@media (max-width: 560px) {
  .sidebar {
    display: block;
  }
}

/* ── SP: セクション見出し ────────────────────────────────── */
@media (max-width: 480px) {
  .sec-head {
    font-size: 1.05rem !important;
    padding: .35rem .7rem;
  }
  .sec-sub {
    font-size: .9rem !important;
  }
}

/* ── SP: サマリーボックス ────────────────────────────────── */
@media (max-width: 480px) {
  .summary-box {
    padding: .9rem 1rem;
  }
  .summary-box ul {
    font-size: .86rem;
    line-height: 1.75;
  }
}

/* ── SP: ハイライトボックス ─────────────────────────────── */
@media (max-width: 480px) {
  .hlbox,
  .hlbox-red {
    font-size: .86rem;
    padding: .65rem .9rem;
  }
}

/* ── SP: データテーブル ──────────────────────────────────── */
@media (max-width: 660px) {
  /* テーブルをブロック表示にしてスクロールさせる */
  .art-body .data-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    font-size: .82rem;
  }
  .art-body .data-table th,
  .art-body .data-table td {
    padding: .4rem .6rem;
    white-space: nowrap;
  }
}

/* ── SP: フロータイムライン ─────────────────────────────── */
@media (max-width: 480px) {
  .flow-list li {
    flex-direction: column;
    gap: .4rem;
    padding: .6rem 0;
  }
  .flow-inning {
    align-self: flex-start;
    font-size: .72rem;
  }
  .flow-desc {
    font-size: .85rem;
  }
}

/* ── SP: バーチャート ────────────────────────────────────── */
@media (max-width: 480px) {
  .bar-row {
    gap: .5rem;
  }
  .bar-label {
    min-width: 44px;
    font-size: .74rem;
  }
  .bar-val {
    min-width: 36px;
    font-size: .78rem;
  }
  .bar-fill {
    font-size: .72rem;
  }
}

/* ── SP: チームカード ────────────────────────────────────── */
@media (max-width: 480px) {
  .team-cards {
    grid-template-columns: 1fr !important;
  }
}

/* ── SP: インパクトバッジ ────────────────────────────────── */
@media (max-width: 480px) {
  .impact-badge {
    font-size: .65rem;
  }
}

/* ── SP: 段落文字サイズ ─────────────────────────────────── */
@media (max-width: 480px) {
  .art-body p {
    font-size: .9rem;
    line-height: 1.8;
  }
  .art-body li {
    font-size: .88rem;
  }
}

/* ── SP: サイドボックス ──────────────────────────────────── */
@media (max-width: 480px) {
  .side-box {
    padding: .8rem 1rem;
  }
  .side-box h3 {
    font-size: .85rem;
  }
  .side-box ul li {
    font-size: .8rem;
  }
}

/* ── SP: OGP左パネルのスコア文字 ────────────────────────── */
/* cqw単位なので自動スケールするが、念のため最小値を確保 */
@media (max-width: 360px) {
  .ogp-hero {
    border-radius: 6px;
  }
}

/* ============================================================
   ダークモード（システム設定に合わせた微調整）
   記事自体はすでに暗いが、共有コンポーネントを整える
   ============================================================ */
@media (prefers-color-scheme: dark) {
  body {
    background: #0a1628;
    color: #cbd5e1;
  }
  nav.breadcrumb {
    background: #0d1e35;
    border-bottom-color: #1e3a5f;
  }
  .site-footer {
    background: #0d1e35;
    border-top-color: #1e3a5f;
  }

  /* ── 記事本文テキスト（旧スタイル記事対応 !important 必須） ─ */
  .art-body p      { color: #cbd5e1 !important; }
  .art-body li     { color: #cbd5e1 !important; }
  .art-body strong { color: #e2e8f0 !important; }
  article p        { color: #cbd5e1 !important; }
  article li       { color: #cbd5e1 !important; }
  article strong   { color: #e2e8f0 !important; }

  /* ── セクション見出し ─────────────────────────────────────── */
  .sec-head        { border-bottom-color: #1e3a5f !important; }
  .sec-head h2,
  .sec-head h3     { color: #e2e8f0 !important; }
  .sec-num         { background: rgba(192,57,43,.18) !important; color: #f87171 !important; }
  .sec-sub         { color: #93c5fd !important; border-left-color: #1e3a5f !important; }

  /* ── サマリーボックス ─────────────────────────────────────── */
  .summary-box {
    background: #0d1a2d !important;
    border-color: #1e3a5f !important;
    border-left-color: #3b82f6 !important;
  }
  .summary-box li  { color: #cbd5e1 !important; }
  .summary-box p   { color: #cbd5e1 !important; }

  /* ── ハイライトボックス ───────────────────────────────────── */
  .hlbox {
    background: rgba(250,204,21,.06) !important;
    border-color: rgba(250,204,21,.25) !important;
    border-left-color: #facc15 !important;
  }
  .hlbox p, .hlbox-red p { color: #e2e8f0 !important; }
  .hlbox.red, .hlbox-red {
    background: rgba(239,68,68,.07) !important;
    border-left-color: #ef4444 !important;
  }

  /* ── データテーブル ───────────────────────────────────────── */
  .data-table td,
  .score-table td,
  .eval-table td,
  .eval-table-compact td {
    color: #cbd5e1 !important;
    border-bottom-color: #1e3a5f !important;
  }
  .data-table tr:nth-child(even) td,
  .score-table tr:nth-child(even) td,
  .eval-table tr:nth-child(even) td,
  .eval-table-compact tr:nth-child(even) td {
    background: rgba(30,58,95,.2) !important;
  }
  .score-table .highlight-score { color: #e2e8f0 !important; }
  .score-table .score-total { background: rgba(30,58,95,.3) !important; }

  /* ── TOC（目次）サイドバー ────────────────────────────────── */
  .sidebar-toc { background: #0d1a2d !important; border-color: #1e3a5f !important; }
  .toc-list li { border-bottom-color: #1e3a5f !important; }
  .toc-list a  { color: #94a3b8 !important; }

  /* ── 関連記事 ─────────────────────────────────────────────── */
  .related-head  { color: #64748b !important; border-bottom-color: #1e3a5f !important; }
  .related-item  { background: #0d1a2d !important; border-color: #1e3a5f !important; }
  .related-title { color: #e2e8f0 !important; }

  /* ── サイドバー メタ・プロフィール ───────────────────────── */
  .sidebar-meta    { background: #0d1a2d !important; border-color: #1e3a5f !important; }
  .sidebar-profile { background: #0d1a2d !important; border-color: #1e3a5f !important; }
  .sidebar-meta h3,
  .sidebar-profile h3 { color: #e2e8f0 !important; }
  .sidebar-meta p,
  .sidebar-profile p  { color: #94a3b8 !important; }

  /* ── サイドボックス（共通） ───────────────────────────────── */
  .side-box            { background: #0d1a2d !important; border-color: #1e3a5f !important; }
  .side-box h3         { color: #facc15 !important; border-bottom-color: #1e3a5f !important; }
  .side-box ul li      { color: #94a3b8 !important; border-bottom-color: #0d1f3c !important; }
}
