/*
Theme Name: Keio Emergency Bulletin
Theme URI: https://example.keio.ac.jp/
Author: Design Team
Description: 大学向け緊急用お知らせサイトのシングルカラムテーマ。緊急告知バナー（カスタマイザー制御）、最新のお知らせ全文表示、過去のお知らせアーカイブ、日英併記、WYSIWYG本文（リスト・リンク・太字・下線・添付ファイル）に対応。PC/モバイル対応・アクセシビリティ配慮。
Version: 2.4.5
Requires at least: 6.0
Tested up to: 6.5
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: keio-emergency
*/

/* ===== Reset & base ===== */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: #ffffff;
  color: #1a1c22;
  font-family: "Noto Sans JP", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.7;
  overflow-wrap: anywhere;
}
a { color: #0b3d91; }
a:hover { color: #072a66; }
:focus-visible { outline: 3px solid #0b3d91; outline-offset: 2px; border-radius: 2px; }
img { max-width: 100%; height: auto; }

.site { min-height: 100vh; display: flex; flex-direction: column; }
.wrap { max-width: 960px; margin: 0 auto; }
.pad-x { padding-left: clamp(16px, 4vw, 32px); padding-right: clamp(16px, 4vw, 32px); }

/* ===== Skip link ===== */
.skip-link {
  position: absolute; left: -999px; top: 8px;
  background: #0b3d91; color: #fff; padding: 10px 16px;
  border-radius: 4px; z-index: 50; text-decoration: none; font-weight: 700;
}
.skip-link:focus { left: 8px; color: #fff; }

/* ===== Emergency banner ===== */
@keyframes pulseDot { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
.emergency-banner { background: #a1160a; color: #fff; }
.emergency-banner .inner {
  display: flex; align-items: flex-start; gap: 14px;
  padding-top: 16px; padding-bottom: 16px;
}
.emergency-banner .dot {
  flex: none; width: 14px; height: 14px; margin-top: 7px; border-radius: 50%;
  background: #ffd8d2; box-shadow: 0 0 0 4px rgba(255,255,255,.25);
  animation: pulseDot 1.4s ease-in-out infinite;
}
.emergency-banner .title {
  margin: 0; font-weight: 900; font-size: clamp(17px, 2.4vw, 20px); letter-spacing: .02em;
}
.emergency-banner .body { margin: 4px 0 0; font-size: 15px; line-height: 1.6; opacity: .95; }
.emergency-banner .body [lang="en"] { display: inline-block; margin-left: 2px; }
@media (prefers-reduced-motion: reduce) { .emergency-banner .dot { animation: none; } }

/* ===== Header (white, matching keio.ac.jp) ===== */
.site-header { background: #ffffff; color: #1a1a1a; border-bottom: 1px solid #e3e3e0; }
.site-header .inner {
  display: flex; align-items: center; gap: 16px;
  padding-top: clamp(18px, 3.2vw, 24px); padding-bottom: clamp(18px, 3.2vw, 24px);
}
.site-logo { flex: none; display: block; }
.site-logo img { display: block; width: 44px; height: 44px; object-fit: contain; }
.site-branding { min-width: 0; flex: 1; }
.site-title {
  margin: 0; font-family: "Noto Serif JP", serif; font-weight: 700;
  font-size: clamp(19px, 3.2vw, 26px); line-height: 1.3; letter-spacing: .01em; color: #1b2a4a;
}
.site-title a { color: inherit; text-decoration: none; }
.site-subtitle { margin: 3px 0 0; font-size: 12px; letter-spacing: .05em; color: #6b6f79; }

/* ===== サイト説明（固定ページ ID 140） =====
 * 絞り込みバーと同じ薄いグレーだと操作パネルの続きに見えるため、濃紺ベタにしている。
 * 本文は編集画面から入るので、段落・リンク・強調・リスト・見出しまで面倒を見る。
 * 絞り込み中は assets/filter.js が hidden にする。
 */
.site-intro {
  background: #1b2a4a; border-radius: 8px;
  padding: clamp(18px, 3vw, 26px) clamp(18px, 3vw, 24px); margin-bottom: 28px;
  color: #e8edf7;
}
.site-intro p { margin: 0 0 12px; font-size: 16px; line-height: 1.85; }
.site-intro > *:last-child { margin-bottom: 0; }
.site-intro a { color: #9fc0ff; text-underline-offset: 3px; }
.site-intro a:hover { color: #c8dbff; }
.site-intro strong, .site-intro b { color: #fff; font-weight: 700; }
.site-intro h2, .site-intro h3, .site-intro h4 {
  margin: 0 0 10px; font-size: 18px; font-weight: 700; line-height: 1.5; color: #fff;
}
.site-intro ul, .site-intro ol { margin: 0 0 12px; padding-left: 1.4em; font-size: 16px; line-height: 1.85; }
.site-intro li { margin-bottom: 6px; }

/* ===== Main ===== */
.site-main { flex: 1 0 auto; width: 100%; padding-top: clamp(20px, 4vw, 40px); padding-bottom: clamp(20px, 4vw, 40px); }
/* トップだけは部門ページの帯を画面端まで広げるため、余白を内側のラッパーに持たせる。 */
.site-main-front { padding-top: 0; padding-bottom: 0; }
.front-main { padding-top: clamp(20px, 4vw, 40px); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.section-head h2 { margin: 0; font-size: clamp(18px, 2.6vw, 22px); font-weight: 900; letter-spacing: .02em; }
.section-head .en,
.section-head .result-count { margin: 0; font-size: 13px; color: #5b5f6b; letter-spacing: .03em; }

/* ===== Filter bar: 対象者ボタン + キャンパスボタン + 部門のモーダル（上から3段） ===== */
/* ヘッダーにあった対象者の帯をこの枠に統合している（絞り込みは1か所だけ）。 */
.notice-filter {
  background: #f5f6f9; border: 1px solid #e6e7ea; border-radius: 8px;
  padding: 16px clamp(16px, 3vw, 22px); margin-bottom: 24px;
}

/* 各段（対象者・キャンパス・部門）は罫線で区切る。最後の段には引かない。 */
.notice-filter-row {
  margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px solid #e3e5ea;
}
.notice-filter-row:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: 0; }

.notice-filter-label {
  display: block; margin-bottom: 6px;
  font-size: 12px; font-weight: 700; letter-spacing: .03em; color: #5b5f6b;
}

/* --- 対象者・キャンパス（ボタン群、見た目は共通） --- */
.filter-buttons { display: flex; align-items: stretch; gap: 8px; flex-wrap: wrap; }
.filter-buttons button {
  display: inline-flex; align-items: center; padding: 7px 14px;
  font-size: 14px; font-weight: 700; color: #1b2a4a; background: #fff;
  font-family: inherit; line-height: 1.4; cursor: pointer;
  border: 1px solid #cfd3db; border-radius: 6px; white-space: nowrap;
}
.filter-buttons button:hover { border-color: #1b2a4a; background: #eef1f6; color: #1b2a4a; }
.filter-buttons button[aria-current] {
  color: #fff; background: #1b2a4a; border-color: #1b2a4a;
}
.filter-buttons button[aria-current]:hover { background: #142138; color: #fff; }

/* --- 部門（モーダルを開くボタン） --- */
/* 1段まるごと使うので、幅いっぱいには広げず対象者ボタンの並びと釣り合う幅に抑える。 */
.filter-dept-button {
  width: 100%; max-width: 420px; font-family: inherit; font-size: 15px; line-height: 1.4;
  color: #1b2a4a; background: #fff;
  border: 1px solid #1b2a4a; border-radius: 4px; padding: 11px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  text-align: left; cursor: pointer;
}
.filter-dept-button:hover { background: #eef1f6; }
.filter-dept-button .caret { flex: none; font-size: 13px; }
.filter-dept-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Department modal --- */
.filter-modal[hidden] { display: none; }
.filter-modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: flex-start; justify-content: center;
  padding: clamp(16px, 5vh, 48px) 16px;
}
.filter-modal-backdrop { position: absolute; inset: 0; background: rgba(20,24,40,.55); }
.filter-modal-panel {
  position: relative; display: flex; flex-direction: column;
  width: 100%; max-width: 520px; max-height: 100%;
  background: #fff; border: 1px solid #1b2a4a; border-radius: 4px;
  box-shadow: 0 20px 50px rgba(0,0,0,.3);
}
.filter-modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 22px 10px;
}
.filter-modal-title {
  margin: 0; font-size: 17px; font-weight: 700; color: #1b2a4a;
  border-bottom: 3px solid #f2c200; padding-bottom: 2px;
}
.filter-modal-close {
  flex: none; font-family: inherit; font-size: 20px; line-height: 1; color: #1b2a4a;
  background: transparent; border: 0; border-radius: 4px; padding: 6px 8px; cursor: pointer;
}
.filter-modal-close:hover { background: #eef1f6; }

.filter-modal-body { flex: 1; overflow: auto; padding: 0 22px; }
.dept-options { list-style: none; margin: 0; padding: 0; }
.dept-options li { border-bottom: 1px solid #f0f0f0; }
.dept-option {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 4px; font-size: 15px; color: #1a1c22; cursor: pointer;
}
.dept-option input {
  flex: none; width: 17px; height: 17px; accent-color: #1b2a4a; cursor: pointer;
}
.dept-option:hover { background: #f7f9fd; }

.filter-modal-foot {
  display: flex; gap: 12px; padding: 16px 22px 20px; border-top: 1px solid #e6e7ea;
}
.filter-clear {
  flex: 1; font-family: inherit; font-size: 15px; font-weight: 700; line-height: 1.4;
  color: #1b2a4a; background: #fff; border: 1px solid #1b2a4a;
  border-radius: 4px; padding: 13px 22px; cursor: pointer;
}
.filter-clear:hover { background: #eef1f6; }

.notice-filter-empty {
  background: #fafafa; border: 1px solid #e3e3e0; border-radius: 8px;
  padding: 32px; color: #5b5f6b; font-size: 15px;
}
.notice[hidden], .notice-filter-empty[hidden], .site-intro[hidden],
.department-note[hidden], .department-notes[hidden] { display: none; }
.notice-list { display: flex; flex-direction: column; gap: 24px; margin-bottom: 28px; }

/* ===== 部門ごとの常設ページ「基本情報」（投稿一覧の下） =====
 * 投稿と地続きに見えないよう、背景色の違う全幅の帯に白カードを並べる。
 * 見出しは「最新のお知らせ」と同じ .section-head を使う。
 * 帯を画面端まで広げるため、front-page.php では wrap の外（main 直下）に置く。
 * 表示中の1枚も無いときは assets/filter.js が帯ごと隠す。
 */
.department-notes {
  background: #eef1f6; border-top: 1px solid #dde2ea;
  padding: clamp(24px, 4vw, 36px) 0 clamp(28px, 5vw, 44px);
}
/* hidden な1枚が間に挟まっても余白が残らないよう gap で並べる。 */
.department-notes-inner { display: flex; flex-direction: column; gap: 16px; }
.department-note {
  background: #fff; border: 1px solid #dde2ea; border-radius: 8px;
  padding: clamp(16px, 3vw, 22px);
}
.department-note p { margin: 0 0 12px; font-size: 15px; line-height: 1.85; color: #33363f; }
.department-note > *:last-child { margin-bottom: 0; }
.department-note h2, .department-note h3 {
  margin: 0 0 10px; font-size: 20px; font-weight: 700; line-height: 1.5; color: #1b2a4a;
}
.department-note h4 { margin: 0 0 8px; font-size: 16px; font-weight: 700; line-height: 1.5; color: #1b2a4a; }
.department-note ul, .department-note ol { margin: 0 0 12px; padding-left: 1.4em; font-size: 15px; line-height: 1.85; color: #33363f; }
.department-note li { margin-bottom: 6px; }
.department-note a { text-underline-offset: 3px; }
.department-note a:hover { color: #072a66; }

/* ===== Notice card ===== */
.notice {
  background: #fff; border: 1px solid #e2e2dd; border-radius: 8px;
  padding: clamp(20px, 3.5vw, 32px); box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.notice-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.notice-date { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 15px; color: #5b5f6b; }
.notice-title { margin: 0 0 12px; font-size: clamp(19px, 2.8vw, 24px); font-weight: 700; line-height: 1.45; text-wrap: pretty; }

/* ===== Notice band above the title (pattern 1c) =====
 * 発信部門・対象者をカード上部の帯にボタン風で表示する。
 */
.notice { padding: 0; overflow: hidden; }
.notice-band {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 12px clamp(20px, 3.5vw, 32px);
  background: #f5f6f9; border-bottom: 1px solid #e6e7ea;
}
.notice-inner { padding: 20px clamp(20px, 3.5vw, 32px) clamp(20px, 3.5vw, 32px); }
.notice:not(:has(.notice-band)) .notice-inner { padding-top: clamp(20px, 3.5vw, 32px); }

.notice-from { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 700; color: #33363f; }
.notice-from-label {
  font-size: 11px; font-weight: 700; letter-spacing: .04em; color: #5b5f6b;
  border: 1px solid #d0d0c8; border-radius: 3px; padding: 1px 6px;
}
.notice-band-sep { width: 1px; height: 14px; background: #d0d0c8; }
.audience-label { font-size: 12px; font-weight: 700; color: #5b5f6b; letter-spacing: .03em; }
.audience-chip {
  font-size: 13px; font-weight: 700; line-height: 1.4; color: #0b3d91;
  background: #eef2fb; border: 1px solid #c7cfdf; border-radius: 100px; padding: 2px 11px;
}
.campus-label { font-size: 12px; font-weight: 700; color: #5b5f6b; letter-spacing: .03em; }
/* キャンパスも対象者と同じチップ表示に揃える。 */
.campus-name {
  font-size: 13px; font-weight: 700; line-height: 1.4; color: #0b3d91;
  background: #eef2fb; border: 1px solid #c7cfdf; border-radius: 100px; padding: 2px 11px;
}

/* ===== WYSIWYG body ===== */
.notice-body { font-size: 16px; line-height: 1.9; color: #26282f; }
.notice-body p { margin: 0 0 14px; }
.notice-body ul, .notice-body ol { margin: 0 0 14px; padding-left: 1.4em; }
.notice-body li { margin-bottom: 6px; }
.notice-body strong, .notice-body b { font-weight: 700; }
.notice-body em, .notice-body i { font-style: italic; }
.notice-body u, .notice-body ins { text-decoration: underline; text-underline-offset: 3px; }
.notice-body s, .notice-body del, .notice-body strike { text-decoration: line-through; }
.notice-body mark { background: #fff2ac; padding: 0 .15em; }
.notice-body sub, .notice-body sup { font-size: .8em; }
.notice-body blockquote {
  margin: 0 0 14px; padding: 8px 0 8px 16px; border-left: 4px solid #d6d6cf; color: #4a4d57;
}
.notice-body h2, .notice-body h3, .notice-body h4 { font-weight: 700; line-height: 1.5; margin: 22px 0 10px; }
.notice-body h2 { font-size: 20px; }
.notice-body h3 { font-size: 18px; }
.notice-body h4 { font-size: 16px; }
.notice-body a { color: #0b3d91; text-underline-offset: 3px; }
.notice-body a:hover { color: #072a66; }
.notice-body a[target="_blank"]::after { content: " ↗"; font-size: .85em; }

/* ===== Attachments ===== */
.attachments-label { margin: 20px 0 10px; font-size: 13px; font-weight: 700; color: #5b5f6b; letter-spacing: .04em; }
.attachments { display: flex; flex-direction: column; gap: 8px; }
.attachment {
  display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit;
  border: 1px solid #e2e2dd; border-radius: 6px; padding: 12px 14px; background: #faf9f6;
}
.attachment:hover { border-color: #0b3d91; background: #f2f5fc; }
.attachment .icon {
  flex: none; width: 38px; height: 38px; border-radius: 5px; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: ui-monospace, monospace; font-size: 11px; font-weight: 700;
}
.attachment .name { display: block; font-weight: 700; font-size: 15px; }
.attachment .meta { display: block; font-size: 13px; color: #5b5f6b; }
.attachment .icon.pdf { background: #a1160a; }
.attachment .icon.doc { background: #0b3d91; }
.attachment .icon.xls { background: #1f6b3a; }
.attachment .icon.img { background: #5b5f6b; }
.attachment .icon.file { background: #33363f; }

/* ===== Archive link (front page bottom) ===== */
.archive-link { margin-top: 36px; }
.archive-link a {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  text-decoration: none; color: inherit; background: #fff;
  border: 1px solid #d6d6cf; border-radius: 8px; padding: 20px clamp(18px, 3vw, 26px);
}
.archive-link a:hover { border-color: #0b3d91; background: #f7f9fd; }
.archive-link .jp { display: block; font-weight: 900; font-size: 17px; }
.archive-link .en { display: block; font-size: 13px; color: #5b5f6b; margin-top: 2px; }
.archive-link .arrow { flex: none; color: #0b3d91; font-size: 22px; font-weight: 700; }

/* ===== Pagination ===== */
.pagination { margin-top: 32px; display: flex; justify-content: center; }
.pagination .page-numbers {
  display: inline-flex; min-width: 42px; height: 42px; align-items: center; justify-content: center;
  padding: 0 10px; margin: 0 4px; border: 1px solid #d6d6cf; border-radius: 6px;
  background: #fff; color: #0b3d91; text-decoration: none; font-weight: 700; font-variant-numeric: tabular-nums;
}
.pagination .page-numbers:hover { border-color: #0b3d91; background: #f7f9fd; }
.pagination .page-numbers.current { background: #0b1f4d; color: #fff; border-color: #0b1f4d; }
.pagination .page-numbers.dots { border-color: transparent; background: transparent; }

/* ===== Empty / back link ===== */
/* お知らせ0件のとき。次のブロックと接しないよう .notice-list と同じ余白を持たせる。 */
.notice-empty {
  background: #fff; border: 1px solid #e2e2dd; border-radius: 8px;
  padding: 32px; color: #5b5f6b; margin-bottom: 28px;
}
.back-link { margin-top: 28px; }
.back-link a { font-weight: 700; text-decoration: none; }
.back-link a::before { content: "← "; }

/* ===== Footer ===== */
.site-footer { background: #0b1f4d; color: #c4cfe6; }
.site-footer .inner { padding-top: clamp(20px, 4vw, 32px); padding-bottom: clamp(20px, 4vw, 32px); font-size: 13px; line-height: 1.8; }
.site-footer .name { margin: 0 0 6px; font-weight: 700; color: #fff; font-family: "Noto Serif JP", serif; }
.site-footer p { margin: 0; }
.site-footer .en { margin: 6px 0 0; color: #8fa0c6; }

/* ===== WP core helpers ===== */
.screen-reader-text {
  border: 0; clip: rect(1px,1px,1px,1px); clip-path: inset(50%);
  height: 1px; width: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute;
}
.aligncenter { display: block; margin-left: auto; margin-right: auto; }
.alignleft { float: left; margin: 0 1.2em 1em 0; }
.alignright { float: right; margin: 0 0 1em 1.2em; }
.wp-caption { max-width: 100%; }
.wp-caption-text { font-size: 13px; color: #5b5f6b; }
