/* ==========================================================================
   ac-base.css — 新レイアウトの外枠（全ページ共通）
   --------------------------------------------------------------------------
   既存の記事ページにも読み込むので、ここでは .ac- で始まるクラスだけを
   書く。body・h1 などの要素そのものには触らない（記事の見た目を壊さないため）。
   変数も --ac- で始める（記事側の --ink や --line とぶつけないため）。

   色の名前は藍染の濃淡から取っている。
     甕覗（かめのぞき）… いちばん淡い藍。見本布の地
     縹（はなだ）………… 中くらいの藍。塗りの柄
     藍（あい）…………… 濃い藍。ボタン・リンク・線の柄
     褐（かち）…………… 黒に近い藍。本文
   暖色は桃の1色だけ（総まとめのゲームの札）。
   ========================================================================== */

:root {
  --ac-font-display: 'Zen Old Mincho', 'Hiragino Mincho ProN', 'Yu Mincho', serif;
  --ac-font-body: 'BIZ UDPGothic', 'Hiragino Sans', 'Yu Gothic', sans-serif;

  --ac-paper: #F5F6F4;
  --ac-sheet: #FFFFFF;
  --ac-ink: #1B2433;
  --ac-ink-soft: #4F5969;
  --ac-line: rgba(27, 36, 51, 0.13);
  --ac-line-strong: rgba(27, 36, 51, 0.32);
  --ac-ai: #26467A;
  --ac-on-ai: #FFFFFF;
  --ac-sw-bg: #E4ECF1;
  --ac-sw-mid: #8DAFC8;
  --ac-sw-ink: #26467A;
  --ac-momo-bg: #FBE9E6;
  --ac-momo: #D98A84;

  --ac-bar-h: 56px;
  --ac-wide: 1120px;
  --ac-read: 720px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ac-paper: #10151D;
    --ac-sheet: #171E29;
    --ac-ink: #E6EBF2;
    --ac-ink-soft: #A9B3C2;
    --ac-line: rgba(230, 235, 242, 0.14);
    --ac-line-strong: rgba(230, 235, 242, 0.36);
    --ac-ai: #8DB3DD;
    --ac-on-ai: #10151D;
    --ac-sw-bg: #17263A;
    --ac-sw-mid: #2F4A6B;
    --ac-sw-ink: #8DB3DD;
    --ac-momo-bg: #3A2427;
    --ac-momo: #D98A84;
  }
}

:root[data-theme="dark"] {
  --ac-paper: #10151D;
  --ac-sheet: #171E29;
  --ac-ink: #E6EBF2;
  --ac-ink-soft: #A9B3C2;
  --ac-line: rgba(230, 235, 242, 0.14);
  --ac-line-strong: rgba(230, 235, 242, 0.36);
  --ac-ai: #8DB3DD;
  --ac-on-ai: #10151D;
  --ac-sw-bg: #17263A;
  --ac-sw-mid: #2F4A6B;
  --ac-sw-ink: #8DB3DD;
  --ac-momo-bg: #3A2427;
  --ac-momo: #D98A84;
}

/* --- 見本布（和柄）。定義は ac-shell.js が <svg> で差し込む --------------- */
.ac-pt-bg { fill: var(--ac-sw-bg); }
.ac-pt-ln { fill: none; stroke: var(--ac-sw-ink); stroke-width: 1.2; }
.ac-pt-fan { fill: var(--ac-sw-bg); stroke: var(--ac-sw-ink); stroke-width: 1.2; }
.ac-pt-fl { fill: var(--ac-sw-mid); }
.ac-pt-momo-bg { fill: var(--ac-momo-bg); }
.ac-pt-momo { fill: var(--ac-momo); }

.ac-swatch { display: block; width: 100%; height: 100%; }

/* --- 上の帯 ------------------------------------------------------------ */
.ac-spacer { height: var(--ac-bar-h); }

.ac-bar {
  position: fixed; inset: 0 0 auto 0; z-index: 9990;
  height: var(--ac-bar-h);
  background: color-mix(in srgb, var(--ac-paper) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--ac-line);
  font-family: var(--ac-font-body);
  color: var(--ac-ink);
}
/* 記事側の header{} / footer{} への指定（余白・枠・角丸・並べ方）を、外枠では打ち消す */
.ac-bar, .ac-foot {
  display: block; margin: 0; padding: 0; gap: 0; width: auto; max-width: none;
  border-radius: 0; border-left: 0; border-right: 0; box-shadow: none;
  line-height: 1.6; letter-spacing: normal; text-align: left;
}
.ac-bar { border-top: 0; }
.ac-foot { border-bottom: 0; }
.ac-bar-in {
  box-sizing: border-box;
  max-width: calc(var(--ac-wide) + 48px); height: 100%;
  margin: 0 auto; padding: 0 24px;
  display: flex; align-items: center; gap: 28px;
}
.ac-brand {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--ac-font-display); font-weight: 500;
  font-size: 17px; letter-spacing: .04em; line-height: 1;
  color: var(--ac-ink); text-decoration: none; white-space: nowrap;
}
.ac-brand { min-width: 0; }
.ac-brand span { overflow: hidden; text-overflow: ellipsis; }
.ac-brand svg { width: 22px; height: 22px; border-radius: 5px; flex: none; }
.ac-nav { display: flex; gap: 22px; margin-right: auto; }
.ac-nav a {
  font-size: 14.5px; color: var(--ac-ink-soft); text-decoration: none;
  padding: 6px 0; border-bottom: 1.5px solid transparent;
}
.ac-nav a:hover { color: var(--ac-ink); border-bottom-color: var(--ac-line-strong); }
.ac-nav a[aria-current="page"] { color: var(--ac-ink); border-bottom-color: var(--ac-ai); }

.ac-search {
  display: flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 10px 0 12px; min-width: 200px;
  border: 1px solid var(--ac-line); border-radius: 8px;
  background: var(--ac-sheet); color: var(--ac-ink-soft);
  font: inherit; font-size: 14px; cursor: pointer;
}
.ac-search:hover { border-color: var(--ac-line-strong); color: var(--ac-ink); }
.ac-search svg { width: 16px; height: 16px; flex: none; }
.ac-search span { margin-right: auto; }
.ac-search kbd {
  font: inherit; font-size: 12px; line-height: 1;
  padding: 3px 6px; border: 1px solid var(--ac-line); border-radius: 4px;
}
.ac-menu-btn {
  display: none; flex: none; white-space: nowrap; height: 36px; padding: 0 12px;
  border: 1px solid var(--ac-line); border-radius: 8px;
  background: var(--ac-sheet); color: var(--ac-ink); font: inherit; font-size: 14px; cursor: pointer;
}
.ac-drop {
  position: fixed; inset: var(--ac-bar-h) 0 auto 0; z-index: 9989;
  background: var(--ac-paper); border-bottom: 1px solid var(--ac-line);
  padding: 8px 16px 16px; font-family: var(--ac-font-body);
}
.ac-drop[hidden] { display: none; }
.ac-drop a {
  display: block; padding: 12px 4px; border-bottom: 1px solid var(--ac-line);
  color: var(--ac-ink); text-decoration: none; font-size: 16px;
}

/* 既存の search.js が出す右上の丸ボタンは、帯の検索に置き換えるので隠す */
html.ac-has-shell .ss-fab { display: none !important; }

/* 記事側の「上に貼り付く帯」を、新しい帯の下にずらす
   （.nav … copilot / hosting / secrets / security-game-guide、.slidebar … ai-data-01〜04） */
html.ac-has-shell .nav, html.ac-has-shell .slidebar { top: var(--ac-bar-h) !important; }
/* ページ内リンクで飛んだ先の見出しが、帯に隠れないように */
html.ac-has-shell { scroll-padding-top: calc(var(--ac-bar-h) + 16px); }

/* --- ボタン ------------------------------------------------------------- */
.ac-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 20px; box-sizing: border-box;
  border-radius: 8px; border: 1px solid var(--ac-line-strong);
  background: transparent; color: var(--ac-ink);
  font-family: var(--ac-font-body); font-size: 15px; font-weight: 700;
  text-decoration: none; cursor: pointer;
}
.ac-btn:hover { border-color: var(--ac-ink); }
.ac-btn.is-primary { background: var(--ac-ai); border-color: var(--ac-ai); color: var(--ac-on-ai); }
.ac-btn.is-primary:hover { filter: brightness(1.12); }

.ac-bar a:focus-visible, .ac-bar button:focus-visible,
.ac-btn:focus-visible, .ac-foot button:focus-visible, .ac-foot a:focus-visible,
.ac-lesson-nav a:focus-visible, .ac-rail a:focus-visible, .ac-crumb a:focus-visible,
.ac-crumb button:focus-visible, .ac-drop a:focus-visible {
  outline: 2px solid var(--ac-ai); outline-offset: 3px; border-radius: 6px;
}

/* --- レッスンページの外枠（既存の記事ページに差し込む） ------------------- */
.ac-crumb {
  box-sizing: border-box;
  max-width: calc(var(--ac-wide) + 48px); margin: 0 auto; padding: 14px 24px;
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px;
  font-family: var(--ac-font-body); font-size: 13.5px; color: var(--ac-ink-soft);
}
.ac-crumb-path { display: flex; align-items: center; gap: 8px; margin-right: auto; min-width: 0; }
.ac-crumb-path a { color: var(--ac-ink-soft); text-decoration: none; }
.ac-crumb-path a:hover { color: var(--ac-ink); text-decoration: underline; }
.ac-crumb-path .ac-chip {
  display: inline-block; width: 30px; height: 16px; border-radius: 3px; overflow: hidden; flex: none;
}
.ac-crumb-path .ac-sep { opacity: .5; }
.ac-crumb button {
  height: 32px; padding: 0 12px; border: 1px solid var(--ac-line); border-radius: 8px;
  background: var(--ac-sheet); color: var(--ac-ink); font: inherit; cursor: pointer;
}

/* コースの目次：広い画面では右に固定、狭い画面では引き出し */
.ac-rail {
  position: fixed; z-index: 9980;
  top: calc(var(--ac-bar-h) + 16px); right: 16px; bottom: 16px;
  width: 280px; box-sizing: border-box; overflow: auto;
  background: var(--ac-sheet); border: 1px solid var(--ac-line); border-radius: 12px;
  padding: 0 0 12px; font-family: var(--ac-font-body); color: var(--ac-ink);
  box-shadow: 0 24px 48px -24px rgba(16, 21, 29, .45);
}
.ac-rail[hidden] { display: none; }
.ac-rail-swatch { height: 56px; border-radius: 11px 11px 0 0; overflow: hidden; }
.ac-rail-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px 10px; }
.ac-rail-head a {
  margin-right: auto; font-family: var(--ac-font-display); font-weight: 500;
  font-size: 17px; letter-spacing: .03em; color: var(--ac-ink); text-decoration: none;
}
.ac-rail-head button {
  border: 0; background: transparent; color: var(--ac-ink-soft); font: inherit; font-size: 13px;
  cursor: pointer; padding: 6px;
}
.ac-rail ol { list-style: none; margin: 0; padding: 0 8px; counter-reset: ac-l; }
.ac-rail li a {
  display: grid; grid-template-columns: 22px 1fr; gap: 6px; align-items: baseline;
  padding: 8px 8px; border-radius: 8px;
  font-size: 14px; line-height: 1.5; color: var(--ac-ink); text-decoration: none;
}
.ac-rail li a::before {
  counter-increment: ac-l; content: counter(ac-l);
  font-size: 12px; color: var(--ac-ink-soft); text-align: right;
}
.ac-rail li a:hover { background: var(--ac-paper); }
.ac-rail li a[aria-current="page"] { background: var(--ac-sw-bg); font-weight: 700; }
.ac-rail li small { display: block; font-size: 12px; color: var(--ac-ink-soft); font-weight: 400; }
.ac-rail li.is-finale a::before { content: "\25C6"; color: var(--ac-ai); }

/* 前後のレッスン */
.ac-lesson-nav {
  box-sizing: border-box; max-width: 880px; margin: 48px auto; padding: 0 24px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  font-family: var(--ac-font-body); color: var(--ac-ink);
}
.ac-lesson-nav a {
  display: block; padding: 16px 18px; border: 1px solid var(--ac-line); border-radius: 12px;
  background: var(--ac-sheet); color: var(--ac-ink); text-decoration: none;
}
.ac-lesson-nav a:hover { border-color: var(--ac-ai); }
.ac-lesson-nav .is-next { grid-column: 2; text-align: right; }
.ac-lesson-nav small { display: block; font-size: 12.5px; color: var(--ac-ink-soft); margin-bottom: 4px; }
.ac-lesson-nav b { font-size: 15.5px; line-height: 1.5; }

/* --- 下の帯 ------------------------------------------------------------ */
.ac-foot {
  border-top: 1px solid var(--ac-line); background: var(--ac-paper);
  font-family: var(--ac-font-body); color: var(--ac-ink-soft); font-size: 13.5px;
}
.ac-foot-in {
  box-sizing: border-box; max-width: calc(var(--ac-wide) + 48px); margin: 0 auto; padding: 22px 24px;
  display: flex; align-items: center; flex-wrap: wrap; gap: 12px 24px;
}
.ac-foot p { margin: 0 auto 0 0; }
.ac-theme { display: inline-flex; border: 1px solid var(--ac-line); border-radius: 8px; overflow: hidden; }
.ac-theme button {
  border: 0; background: transparent; color: var(--ac-ink-soft);
  font: inherit; font-size: 13px; padding: 7px 12px; cursor: pointer;
}
.ac-theme button + button { border-left: 1px solid var(--ac-line); }
.ac-theme button[aria-pressed="true"] { background: var(--ac-sheet); color: var(--ac-ink); font-weight: 700; }

@media (max-width: 1759px) {
  .ac-rail { right: 0; top: var(--ac-bar-h); bottom: 0; border-radius: 0; width: min(320px, 88vw); }
  .ac-rail-swatch { border-radius: 0; }
}
@media (max-width: 860px) {
  .ac-nav, .ac-search span, .ac-search kbd { display: none; }
  .ac-search { flex: none; min-width: 0; margin-left: auto; padding: 0 10px; }
  .ac-menu-btn { display: inline-block; }
  .ac-bar-in { gap: 10px; padding: 0 16px; }
  .ac-crumb { padding: 12px 16px; }
  .ac-lesson-nav { grid-template-columns: 1fr; padding: 0 16px; }
  .ac-lesson-nav .is-next { grid-column: auto; }
}
@media (max-width: 420px) {
  .ac-brand { font-size: 15px; }
}
@media print {
  .ac-bar, .ac-spacer, .ac-rail, .ac-crumb, .ac-lesson-nav, .ac-foot, .ac-drop { display: none !important; }
}
