/* =========================================================
   image-tools 公開サイト 共通スタイル（ガワ）
   ※ ツール本体のスタイルは各ツールHTML内にインライン。
      ここはヘッダー/フッター/タイル/記事/広告枠など“サイトの器”のみ。
      色・数値は共通設計書 §3 のデザイントークンに従う。
   ========================================================= */

:root {
  --bg:           #F7F8FA;  /* ページ背景 */
  --surface:      #FFFFFF;  /* カード背景 */
  --border:       #E4E7EC;
  --text:         #1A1D23;
  --text-sub:     #6B7280;
  --accent:       #2563EB;
  --accent-hover: #1D4ED8;
  --accent-soft:  #EFF6FF;
  --success:      #16A34A;
  --warning:      #D97706;
  --error:        #DC2626;

  --radius-card: 12px;
  --radius-ctrl: 8px;
  --shadow-card: 0 1px 3px rgba(0, 0, 0, .08);
  --font: "Hiragino Kaku Gothic ProN", "Noto Sans JP", system-ui, sans-serif;
}

* { box-sizing: border-box; }

/* ページ内リンク(#usage 等)の着地を滑らかにする。誤操作防止のためモーション低減設定は尊重する */
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.7;
}

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

/* スクリーンリーダー専用（見た目は隠すがSEO/読み上げ用に残す） */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- ヘッダー ---------- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 16px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-size: 20px; font-weight: 700; }
.tool-nav { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.tool-nav a { color: var(--text-sub); font-weight: 500; }
.tool-nav a:hover { color: var(--accent); }

/* ナビ開閉（スマホのみ）。JSを使わないためチェックボックス＋labelで開閉する。
   PCではトグルを隠しナビを常時展開する（ナビを隠すと回遊率＝広告表示回数が落ちるため）。 */
.nav-check {
  /* hidden 属性だとキーボード操作できないため、視覚的に隠しつつフォーカス可能にする */
  position: absolute;
  width: 1px; height: 1px;
  opacity: 0;
  pointer-events: none;
}
.nav-toggle {
  display: none;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  /* 角丸はデザイントークンのボタン標準値(8px)ではなく4px。
     ヘッダーはサイトのガワでツール本体とは別レイヤーという整理で、
     シャープに見せるためナビトグルのみの例外とする（共通設計書 §3.3 / サイト構造_設計書 §6.0）。 */
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}
.nav-toggle:hover { border-color: var(--accent); }
.nav-check:focus-visible + .nav-toggle { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- ヘッダー直下のリーダーボード広告（全幅・空スロット） ---------- */
.leaderboard {
  max-width: 1180px;
  margin: 16px auto 0;
  padding: 0 24px;
}
.leaderboard .ad-ph { min-height: 90px; }

/* ---------- レイアウト（メイン + 右レールの2カラム。左レールは廃止） ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 24px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px;
}
.main { min-width: 0; }

/* 単カラム版（about/privacy/contact等の規約系ページ）。右レール・広告は持たず読みやすさを優先する */
.layout--single { grid-template-columns: minmax(0, 760px); justify-content: center; }

/* 右レール（広告＋実用ウィジェットを縦に積む。広告一色にしない） */
.rail { display: flex; flex-direction: column; gap: 16px; }

/* スクロール追従（修飾クラス）。ページのコンテンツが十分長く、追従の効果が出る
   ページにだけ付与する（記事一覧・記事ページ）。トップページはコンテンツが短く
   すぐ追従範囲を使い切ってしまうため付与しない（2026-07-21 ユーザー判断）。
   align-self:start が無いとグリッド行いっぱいに伸びて sticky が効かない。
   ※追従はするが広告の中身は再読み込みしない（自動リフレッシュはインプレッション水増しに当たる） */
.rail--sticky {
  position: sticky;
  top: 16px;
  align-self: start;
}

/* ---------- ツールページの2カラム（ワイド画面のみ） ----------
   ツールページは直リンク流入が多いと想定されるため、回遊導線（ランキング）と
   広告枠を右レールに置く。ただしツール本体が 840px を確保できない画面では
   ツールの使い勝手を優先してレールを出さない（1240px 未満は1カラム）。 */
/* 上余白はレイアウト側で持つ。左右カラムの開始位置を揃えるため、
   FV広告の margin-top ではなくここで確保する（ズレ防止） */
.tool-layout { max-width: 1240px; margin: 0 auto; padding-top: 12px; }
.tool-rail { display: none; }

/* 「使い方」への飛びリンク（ツールヘッダー直下）。使い方が記事末尾にあり気づきにくいための導線 */
.tool-usage-link { margin: 4px 0 0; font-size: 12px; }
.tool-usage-link a { color: var(--accent); font-weight: 700; }
.tool-usage-link a:hover { text-decoration: underline; }

@media (min-width: 1240px) {
  .tool-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 24px;
    padding: 12px 24px 0;
  }
  /* グリッド内では列幅に任せる（単カラム時の中央寄せ指定を打ち消す） */
  .tool-layout > .tool-page-main { max-width: none; padding: 0; }

  /* スクロール追従。align-self:start がないとグリッド行いっぱいに伸びて sticky が効かない。
     ※追従はするが広告の中身は再読み込みしない（自動リフレッシュはインプレッション水増しに当たる） */
  .tool-rail {
    display: flex;
    position: sticky;
    top: 16px;
    align-self: start;
  }
}
.rail-widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 16px;
}
.rail-widget h2 { font-size: 14px; margin: 0 0 8px; }

/* 広告プレースホルダ（枠線＋ラベルで“額装”し、編集コンテンツと区別する） */
.ad-ph {
  position: relative;
  border: 2px dashed #C4C9D4;
  border-radius: var(--radius-card);
  background: var(--surface);
  min-height: 250px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-sub);
  font-size: 13px;
}
.ad-ph .ad-label {
  position: absolute; top: 8px; right: 8px;
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 4px;
}

/* アクセスランキング（右レールのウィジェット） */
.rank-list { list-style: none; margin: 0; padding: 0; }
.rank-list li { display: flex; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); }
.rank-list li:first-child { border-top: 0; }
.rank-num { color: var(--accent); font-weight: 700; flex: none; }
.rank-list a:hover { color: var(--accent); }

/* ---------- 記事タイルグリッド ---------- */
.article-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

/* 記事カード（軽いタイル：上に画像、下は白地にカテゴリ＋タイトル）
   画像はグラデ＋アイコンのみ。タイトルはHTMLテキストで出す（SEO・可読性のため）。 */
.lcard {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.lcard:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(0, 0, 0, .10);
  transform: translateY(-2px);
}
/* 高さは canvas の実寸（1200×545 = 2.2:1）に追従させる */
.lcard-img { display: block; width: 100%; height: auto; }
.lcard-body { padding: 12px 14px 14px; }
.lcard-cat {
  display: inline-block;
  font-size: 11px; font-weight: 700; color: #fff;
  padding: 2px 8px; border-radius: 4px; margin-bottom: 6px;
}
.lcard-title { font-size: 15px; font-weight: 700; margin: 0; line-height: 1.5; color: var(--text); }
.lcard-date { font-size: 11px; color: var(--text-sub); margin-top: 6px; }

.ad-label.is-pr { background: #FDE9C8; color: #8a5a00; }
.ad-label.is-ad { background: var(--accent-soft); color: var(--accent); }

/* 記事グリッド下の「すべての記事を見る」導線（トップページのみ・§3.1） */
.view-all { margin: 8px 0; text-align: right; font-size: 13px; }
.view-all a:hover { color: var(--accent); }
/* 直後の .promo の margin-top(24px) と相殺(collapse)されるため、
   view-all が直前にある場合だけ狭める（記事一覧ページの .promo には影響しない） */
.view-all + .promo { margin-top: 8px; }

/* ---------- 下部の「おすすめ / PR」セクション（アフィリ・ネイティブ広告を隔離） ---------- */
.promo { margin-top: 24px; }
.promo-head { display: flex; align-items: baseline; gap: 8px; margin: 0 0 12px; }
.promo-head h2 { font-size: 16px; margin: 0; }
.promo-head .tag {
  font-size: 11px; font-weight: 700; color: #8a5a00;
  background: #FDE9C8; padding: 2px 8px; border-radius: 4px;
}
.promo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.promo-grid .ad-ph { min-height: 120px; }

/* ---------- ページ見出し（記事一覧など） ---------- */
.page-head { margin: 0 0 16px; }
.page-head h1 { font-size: 20px; margin: 0 0 4px; }
.page-head p { color: var(--text-sub); font-size: 12px; margin: 0; }

/* ---------- 記事ページ ---------- */
.article {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
}
.article-head { padding: 20px 24px 16px; }
.article-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.article-date { font-size: 11px; color: var(--text-sub); }
.article-title { font-size: 24px; font-weight: 700; line-height: 1.5; margin: 0; }
.article-hero { display: block; width: 100%; height: auto; }

.article-body { padding: 24px; }
.article-body p { margin: 0 0 16px; line-height: 1.9; }
.article-body .lead { color: var(--text-sub); }
.article-body h2 {
  font-size: 16px; font-weight: 700; margin: 32px 0 8px;
  padding-left: 10px; border-left: 4px solid var(--accent);
  /* 飛びリンク着地時、見出しの真上でなく記事カードの上端が見える高さで止まるようにする
     (article-bodyのpadding 24px + このh2のmargin-top 32px 分を見込んだ値) */
  scroll-margin-top: 64px;
}
.article-body ul { margin: 0 0 16px; padding-left: 20px; }
.article-body li { margin-bottom: 6px; line-height: 1.9; }
.article-body a { color: var(--accent); text-decoration: underline; }

/* ---------- お問い合わせページの簡易UI（<form>禁止のためselect+buttonのみで構成） ---------- */
.contact-form {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin: 16px 0;
}
.contact-form label { font-weight: 700; font-size: 13px; }
.contact-form select {
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-ctrl);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.contact-form button {
  height: 40px;
  padding: 0 20px;
  border: 0;
  border-radius: var(--radius-ctrl);
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.contact-form button:hover { background: var(--accent-hover); }
.contact-note { font-size: 12px; color: var(--text-sub); min-height: 1.4em; }

/* 記事下の回遊導線 */
.related { padding: 0 24px 24px; }
.related h2 { font-size: 14px; margin: 24px 0 8px; }
.related-links { display: flex; flex-wrap: wrap; gap: 8px; }
.related-links a {
  border: 1px solid var(--border); border-radius: var(--radius-ctrl);
  padding: 8px 12px; font-size: 13px;
  transition: border-color .15s ease, background .15s ease;
}
.related-links a:hover { border-color: var(--accent); background: var(--accent-soft); }

/* 記事内の広告スロット */
.article-ad { padding: 0 24px 24px; }

/* ---------- ツール一覧（導線カード帯） ---------- */
.tool-directory {
  margin-top: 24px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
}
.tool-directory h2 { font-size: 16px; margin: 0 0 12px; }
.tool-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
.tool-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-ctrl);
  padding: 12px 14px;
  transition: border-color .15s ease, background .15s ease;
}
.tool-card:hover { border-color: var(--accent); background: var(--accent-soft); }
.tool-card .name { font-weight: 700; }
.tool-card .desc { color: var(--text-sub); font-size: 12px; }
.tool-card.is-planned { opacity: .6; }

/* ---------- フッター ---------- */
.site-footer {
  margin-top: 24px;
  padding: 24px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-sub);
  font-size: 12px;
  text-align: center;
}
.site-footer nav { display: inline-flex; flex-wrap: wrap; gap: 8px 16px; justify-content: center; }
.site-footer a:hover { color: var(--accent); }

/* ---------- レスポンシブ（スマホ幅 375px 想定） ---------- */
@media (max-width: 768px) {
  .layout {
    grid-template-columns: 1fr;   /* 1カラムに */
    padding: 16px;
  }
  .rail { display: none; }         /* 右レール広告はスマホでは非表示（リーダーボードは残す） */
  .article-grid { grid-template-columns: 1fr; } /* 記事は1列 */
  .promo-grid { grid-template-columns: 1fr; }
  .leaderboard { padding: 0 16px; }

  /* ヘッダーを1行に収める。ナビは折り返すと2行になり上部を圧迫するため開閉式にする */
  .site-header { padding: 12px 16px; gap: 12px; }
  .nav-toggle { display: inline-flex; }
  .tool-nav { display: none; }
  .nav-check:checked ~ .tool-nav {
    display: flex;
    width: 100%;
    gap: 8px 16px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
  }
}
