/* ============================================
   CompTIA A+ 学習サイト 共通スタイル
   ============================================ */
:root {
  --c1: #c8102e;            /* CompTIAレッド系アクセント */
  --c1-dark: #9a0c23;
  --core1: #0b6e99;         /* Core 1 ブルー */
  --core2: #2e7d32;         /* Core 2 グリーン */
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #1f2430;
  --muted: #5b6472;
  --border: #e2e6ec;
  --ok: #2e7d32;
  --ng: #c62828;
  --warn: #ef6c00;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(20, 30, 50, .08), 0 4px 16px rgba(20, 30, 50, .06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161b;
    --card: #1e2129;
    --text: #e8eaf0;
    --muted: #9aa3b2;
    --border: #313644;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", Meiryo, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
}

/* ページ全体の横スクロール・横パンを禁止。
   横に広い要素（ナビ・表）は各自の内側でだけスクロールさせる。
   clip はスクロールコンテナを作らないため sticky ヘッダーと共存できる */
html, body {
  overflow-x: hidden;   /* 古いブラウザ用フォールバック */
  overflow-x: clip;
  max-width: 100%;
}

/* ---------- ヘッダー / ナビ ---------- */
.site-header {
  background: linear-gradient(135deg, #1a2233 0%, #2b3550 100%);
  color: #fff;
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.header-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  font-weight: 700;
  font-size: 1.05rem;
  color: #fff;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.brand .badge-aplus {
  background: var(--c1);
  color: #fff;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: .85rem;
  letter-spacing: .5px;
}

nav.main-nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-left: auto;
}

nav.main-nav a {
  color: #d5dbe8;
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: .92rem;
  white-space: nowrap;
  transition: background .15s, color .15s;
}

nav.main-nav a:hover { background: rgba(255, 255, 255, .12); color: #fff; }
nav.main-nav a.active { background: var(--c1); color: #fff; }

/* ---------- レイアウト ---------- */
.container { max-width: 1080px; margin: 0 auto; padding: 28px 20px 64px; }

.hero {
  background: linear-gradient(135deg, #1a2233 0%, #34415f 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 36px 32px;
  margin-bottom: 28px;
}

.hero h1 { margin: 0 0 10px; font-size: 1.7rem; line-height: 1.4; }
.hero p { margin: 6px 0; color: #ccd4e4; max-width: 46em; }
.hero .hero-note { font-size: .85rem; color: #9fb0cf; }

h2.section-title {
  font-size: 1.25rem;
  border-left: 5px solid var(--c1);
  padding-left: 12px;
  margin: 40px 0 16px;
}

h2.section-title:first-of-type { margin-top: 8px; }

h3 { font-size: 1.05rem; margin: 24px 0 8px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }

/* ---------- テーブル ---------- */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;  /* 表のスワイプがページ側に伝わらないように */
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: .92rem;
  background: var(--card);
}

th, td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; vertical-align: top; }
th { background: rgba(200, 16, 46, .07); white-space: nowrap; }

/* ---------- バッジ・タグ ---------- */
.tag {
  display: inline-block;
  border-radius: 999px;
  padding: 1px 10px;
  font-size: .78rem;
  font-weight: 600;
  margin-right: 6px;
  vertical-align: middle;
}

.tag-core1 { background: rgba(11, 110, 153, .12); color: var(--core1); }
.tag-core2 { background: rgba(46, 125, 50, .12); color: var(--core2); }
.tag-free { background: rgba(46, 125, 50, .12); color: var(--ok); }
.tag-paid { background: rgba(239, 108, 0, .12); color: var(--warn); }
.tag-jp { background: rgba(200, 16, 46, .1); color: var(--c1); }
.tag-en { background: rgba(90, 100, 120, .12); color: var(--muted); }
.tag-official { background: rgba(26, 34, 51, .12); color: var(--text); }
.tag-caution { background: rgba(198, 40, 40, .12); color: var(--ng); }

/* ---------- ドメインバー ---------- */
.domain-row { margin-bottom: 14px; }
.domain-row .domain-label { display: flex; justify-content: space-between; font-size: .92rem; margin-bottom: 4px; }
.domain-bar { background: var(--border); border-radius: 999px; height: 10px; overflow: hidden; }
.domain-bar > span { display: block; height: 100%; border-radius: 999px; }
.bar-core1 > span { background: var(--core1); }
.bar-core2 > span { background: var(--core2); }

/* ---------- objective アコーディオン ---------- */
details.obj {
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 10px;
  background: var(--card);
  overflow: hidden;
}

details.obj summary {
  cursor: pointer;
  padding: 12px 16px;
  font-weight: 600;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
}

details.obj summary::-webkit-details-marker { display: none; }
details.obj summary::before { content: "▸"; color: var(--c1); transition: transform .15s; }
details.obj[open] summary::before { transform: rotate(90deg); }
details.obj .obj-body { padding: 0 18px 14px 34px; font-size: .93rem; color: var(--text); }
details.obj .obj-body ul { margin: 6px 0; padding-left: 18px; }
details.obj .obj-body li { margin: 3px 0; }

.obj-pct {
  margin-left: auto;
  font-size: .8rem;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
}

/* ---------- リソースリスト ---------- */
.res-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.res-item:last-child { border-bottom: none; }
.res-item a { color: var(--core1); font-weight: 600; text-decoration: none; word-break: break-all; }
.res-item a:hover { text-decoration: underline; }
.res-item .res-desc { font-size: .9rem; color: var(--muted); margin-top: 2px; }

/* ---------- 注意ボックス ---------- */
.callout {
  border-left: 5px solid var(--warn);
  background: rgba(239, 108, 0, .07);
  border-radius: 8px;
  padding: 14px 18px;
  margin: 16px 0;
  font-size: .93rem;
}

.callout.danger { border-left-color: var(--ng); background: rgba(198, 40, 40, .07); }
.callout.info { border-left-color: var(--core1); background: rgba(11, 110, 153, .07); }
.callout .callout-title { font-weight: 700; margin-bottom: 4px; }

/* ---------- クイズ ---------- */
.quiz-setup label { display: block; margin: 10px 0 4px; font-weight: 600; font-size: .95rem; }

.quiz-setup select, .quiz-setup input[type="number"] {
  font-size: 1rem;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  min-width: 220px;
}

.btn {
  display: inline-block;
  background: var(--c1);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 11px 26px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s, transform .05s;
  text-decoration: none;
}

.btn:hover { background: var(--c1-dark); }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: transparent; color: var(--c1); border: 2px solid var(--c1); }
.btn.secondary:hover { background: rgba(200, 16, 46, .08); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.quiz-progress { font-size: .9rem; color: var(--muted); margin-bottom: 10px; display: flex; justify-content: space-between; }

.q-domain { font-size: .8rem; font-weight: 700; letter-spacing: .3px; margin-bottom: 6px; }

.q-text { font-size: 1.05rem; font-weight: 600; margin-bottom: 16px; line-height: 1.7; }

.choices { display: grid; gap: 10px; }

.choice {
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  cursor: pointer;
  background: var(--card);
  font-size: .97rem;
  text-align: left;
  color: var(--text);
  transition: border-color .1s, background .1s;
  display: flex;
  gap: 10px;
  align-items: baseline;
}

.choice:hover { border-color: var(--core1); }
.choice .choice-key { font-weight: 700; color: var(--muted); }
.choice.correct { border-color: var(--ok); background: rgba(46, 125, 50, .1); }
.choice.wrong { border-color: var(--ng); background: rgba(198, 40, 40, .1); }
.choice.dim { opacity: .55; }
.choice:disabled { cursor: default; }

.explain {
  margin-top: 16px;
  border-radius: 10px;
  padding: 14px 18px;
  font-size: .93rem;
  background: rgba(11, 110, 153, .08);
  border-left: 5px solid var(--core1);
}

.explain .verdict { font-weight: 700; margin-bottom: 6px; }
.explain .verdict.ok { color: var(--ok); }
.explain .verdict.ng { color: var(--ng); }

.quiz-nav { margin-top: 18px; display: flex; gap: 12px; justify-content: flex-end; }

/* 結果画面 */
.score-big { font-size: 2.6rem; font-weight: 800; text-align: center; margin: 10px 0 2px; }
.score-sub { text-align: center; color: var(--muted); margin-bottom: 18px; }
.result-pass { color: var(--ok); }
.result-fail { color: var(--warn); }

.review-item { border-bottom: 1px solid var(--border); padding: 12px 0; font-size: .93rem; }
.review-item:last-child { border-bottom: none; }
.review-q { font-weight: 600; }
.review-a { margin-top: 4px; }
.review-a .ok { color: var(--ok); font-weight: 700; }
.review-a .ng { color: var(--ng); font-weight: 700; }

/* ---------- 暗記カード ---------- */
.memo-table td:first-child { font-weight: 600; white-space: nowrap; }

kbd, code.inline {
  background: rgba(120, 130, 150, .15);
  border-radius: 5px;
  padding: 1px 6px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: .88em;
}

/* ---------- チェックリスト ---------- */
.checklist { list-style: none; padding: 0; }
.checklist li { padding: 6px 0; display: flex; gap: 10px; align-items: baseline; }
.checklist input[type="checkbox"] { transform: scale(1.2); accent-color: var(--c1); }

/* ---------- フッター ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 24px 20px 40px;
  text-align: center;
  color: var(--muted);
  font-size: .82rem;
}

.site-footer a { color: var(--muted); }

/* ============================================
   モバイル最適化（〜720px）
   ============================================ */
@media (max-width: 720px) {

  /* ヘッダー: ブランド行＋横スクロール1行ナビ（縦幅を圧縮） */
  .header-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 8px 0 0;
  }

  .brand { padding: 0 14px 4px; font-size: 1rem; }

  nav.main-nav {
    margin-left: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 0 10px 8px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    overscroll-behavior-x: contain;  /* ナビのスワイプがページ側に伝わらないように */
    touch-action: pan-x pan-y;
    min-width: 0;
    max-width: 100%;
  }

  nav.main-nav::-webkit-scrollbar { display: none; }

  nav.main-nav a {
    padding: 8px 14px;       /* タップしやすい高さを確保 */
    font-size: .95rem;
    flex-shrink: 0;
  }

  /* レイアウト余白の圧縮 */
  .container { padding: 18px 14px 48px; }
  .hero { padding: 24px 18px; margin-bottom: 22px; }
  .hero h1 { font-size: 1.28rem; }
  .card { padding: 16px 16px; }
  h2.section-title { margin: 30px 0 14px; font-size: 1.15rem; }

  /* フォーム・ボタンは全幅でタップしやすく */
  .quiz-setup select,
  .quiz-setup input[type="number"] {
    width: 100%;
    min-width: 0;
    padding: 12px 14px;
    font-size: 16px;         /* iOSの自動ズーム防止に16px以上 */
  }

  .btn { display: block; width: 100%; text-align: center; padding: 14px 20px; }
  .btn + .btn { margin-top: 10px; }
  .quiz-nav { flex-direction: row; }
  .quiz-nav .btn { flex: 1; width: auto; display: inline-block; }

  /* 選択肢のタップ領域を拡大 */
  .choice { padding: 14px 14px; min-height: 48px; }
  .q-text { font-size: 1rem; }

  /* テーブル・アコーディオン */
  table { font-size: .86rem; }
  th, td { padding: 7px 9px; }
  details.obj summary { padding: 12px 12px; }
  details.obj .obj-body { padding: 0 14px 12px 24px; }
  .obj-pct { display: none; }  /* 狭い画面では補足ラベルを省略 */

  /* チェックリストのタップ領域 */
  .checklist li { padding: 4px 0; }
  .checklist label { display: flex; gap: 10px; align-items: baseline; padding: 6px 0; width: 100%; }

  .score-big { font-size: 2.1rem; }
}
