/* ==========================================================================
   段階1（ヘッダーとフッターだけ）を、Cocoon のサイトに合わせるための CSS（手で書いたもの）
   - header-footer.css（build.py がモックの CSS から作る）の後に読む
   - 本文の部分（記事・一覧・サイドバー）には効かせない。どの規則も、ヘッダー（.site-header）か
     フッター（#footer）の中だけに効く形にしてある。例外は、いちばん下の html の1つ（ページ内リンクの飛び先）
   ========================================================================== */

/* 文字の書式。Cocoon の設定（サイトのフォント・文字の大きさ）やスキンに関係なく、ヘッダーとフッターはデザインの書式にする
   （モックでは body に付けているもの）。
   letter-spacing・font-feature-settings・font-weight は、スキンがページ全体に付けることがあり（skin-grayish-topfull は
   文字の間隔を広げ、メニューが折り返した）、それがヘッダーとフッターに引き継がれないよう、初期の値に戻す */
.site-header,
.site-footer {
  font-family: var(--font);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.8;
  letter-spacing: normal;
  font-feature-settings: normal;
  overflow-wrap: anywhere;
}

.site-header {
  color: var(--ink);
}

/* リンクの色と、キーボードで操作しているときの枠（モックでは a・:focus-visible のすべてに付けているもの）。
   :where() で優先度を下げ、モックのクラスの指定（ロゴの色など）のほうが勝つようにする */
:where(.site-header, .site-footer) a {
  color: var(--accent-ink);
  text-underline-offset: .2em;
}

:where(.site-header, .site-footer) :focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* 画面には出さず、読み上げだけで伝える文字（検索欄のラベル）。モックの .sr-only を、ヘッダーとフッターの中だけに効かせる */
.site-header .sr-only,
.site-footer .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;
}

/* サイト名の入れ物（トップなどでは h1）。見出しの書式（大きさ・太さ・余白）は付けず、中のロゴの書式だけにする */
.mdk-site-title {
  margin: 0;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
}

/* Cocoon のフッターの外枠（上の余白・内側の余白・背景・幅）を外す。色と余白は、中の .site-footer が持つ */
body.mdk-hf #footer {
  margin: 0;
  padding: 0;
  background: var(--footer-bg);
}

/* #footer-in は Cocoon の .wrap（本文の幅の入れ物）でもあり、スキンが幅を !important で決めることがある
   （skin-grayish-topfull の「.wrap { width: min(91%, 1280px) !important }」で、フッターの中身が左に寄った）。!important で戻す */
body.mdk-hf #footer-in {
  width: auto !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* Cocoon の「サイトキー色」などの色の設定は、フッターのリンクにマウスを乗せたとき、薄い白の背景を付ける。付けない
   （文字の色は、header-footer.css のフッターの規則が、頭に body.mdk-hf #footer を付けて勝つようにしてある） */
body.mdk-hf #footer .site-footer a:hover {
  background-color: transparent;
}

/* ログインしているとき：画面の上の管理バー（WordPress）の下にヘッダーを止める（管理バーの高さは、PC 32px・スマホ 46px） */
body.admin-bar .site-header {
  top: 32px;
}

@media screen and (max-width: 782px) {
  body.admin-bar .site-header {
    top: 46px;
  }
}

/* 幅600px以下では、管理バーはページと一緒に流れて消えるので、ヘッダーは画面の一番上に止める */
@media screen and (max-width: 600px) {
  body.admin-bar .site-header {
    top: 0;
  }
}

/* スマホの画面下の Cocoon のボタン（メニュー・サイドバーなど）で開くパネルを、ヘッダーより上に出す。
   パネルはボタンの帯（Cocoon の .mobile-menu-buttons。重なりの順番 z-index: 3）の中にあり、z-index: 30 のヘッダーより下に描かれて、
   パネルの上の端と閉じるボタン（×）が、ヘッダーに隠れていた（2026-12-05、段階2の確認で見つけた）。
   パネルを開いている間だけ、ヘッダーをボタンの帯より下（2）にする（Cocoon の暗いカバーが、ほかの部分と同じようにヘッダーにもかかる）。
   :has() に対応していない古いブラウザでは、これまでどおり（パネルの外の暗い部分を押せば閉じられる） */
body:has(.mobile-menu-buttons input[id$="-menu-input"]:checked) .site-header {
  z-index: 2;
}

/* 固定したヘッダーの分だけ、ページ内リンク（Cocoon の目次・「コンテンツへスキップ」など）の飛び先を下げる
   （見出しがヘッダーの下に隠れないように）。84px は、ヘッダーの高さ（65px）に少しの間を足したもの（モックの --sticky-top と同じ） */
html {
  scroll-padding-top: 84px;
}

/* ログインしているときは、画面の上に止まる管理バーの高さ（PC 32px・幅782px以下 46px）の分も下げる
   （幅600px以下では、管理バーはページと一緒に流れるので足さない） */
@media screen and (min-width: 783px) {
  html:has(> body.admin-bar) {
    scroll-padding-top: calc(84px + 32px);
  }
}

@media screen and (min-width: 601px) and (max-width: 782px) {
  html:has(> body.admin-bar) {
    scroll-padding-top: calc(84px + 46px);
  }
}
