/* サイト共通の小ネタ（js/extras.js）— 全ページで読み込む */

/* ── ページを移るときに、ふわっと切り替える（View Transitions）──
   対応ブラウザ（Chrome・Edge・Safari 18.2 以降）だけで動き、未対応のブラウザでは普通に切り替わる */
@view-transition { navigation: auto; }
::view-transition-old(root),
::view-transition-new(root) { animation-duration: 0.45s; }
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
}

/* ── アクセス解析の設定：右下のボタンとパネル ── */
.privacy-btn {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 150;   /* プログレスバー（60）より前、ハンバーガーメニュー（200）より後ろ */
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0;
  color: rgba(232,237,245,0.75);
  background: rgba(5,8,16,0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 50%;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.privacy-btn:hover,
.privacy-btn:focus-visible,
.privacy-btn[aria-expanded="true"] {
  color: #fff;
  border-color: rgba(255,255,255,0.5);
  outline: none;
}
/* 計測 OFF のときはクッキーに斜線 */
.privacy-btn.is-off::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 1.6px;
  background: currentColor;
  transform: rotate(-45deg);
}

.privacy-panel {
  position: fixed;
  right: 14px;
  bottom: 58px;
  z-index: 150;
  width: min(300px, calc(100% - 28px));
  padding: 16px 18px 14px;
  font-family: 'Noto Serif JP', serif;
  font-size: 12px;
  line-height: 1.8;
  color: #e8edf5;
  background: rgba(10,18,32,0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.5);
  text-align: left;
  cursor: auto;   /* トップは独自カーソル（cursor: none）のため通常に戻す */
}
.privacy-panel[hidden] { display: none; }
.privacy-panel-title {
  font-family: 'JetBrains Mono', 'Noto Serif JP', monospace;
  font-size: 11px;
  letter-spacing: 0.2em;
  color: #a8d0ff;
  margin-bottom: 8px;
}
.privacy-panel p { margin: 0 0 12px; color: rgba(232,237,245,0.8); }
.privacy-panel .privacy-note { margin: 10px 0 0; color: #8ba0c0; font-size: 11px; }
.privacy-link {
  display: inline-block;
  margin-top: 10px;
  font-size: 11px;
  color: #8ba0c0;
  text-decoration: none;
  border-bottom: 1px solid rgba(255,255,255,0.2);
}
.privacy-link:hover { color: #fff; border-color: #fff; }

/* 初めての人向け：クッキーがポンと出て、2回かじられる（js/extras.js の playIntro） */
.privacy-btn.is-intro { animation: cookie-pop 0.45s cubic-bezier(.2,1.6,.4,1) both; }
.privacy-btn.is-chomp { animation: cookie-chomp 0.3s ease; }
.cookie-crumb {
  position: fixed;
  z-index: 151;
  width: 3px;
  height: 3px;
  background: rgba(232,237,245,0.85);
  pointer-events: none;
  animation: crumb-fall 0.7s ease-in forwards;
}
.privacy-hint {
  position: fixed;
  right: 58px;
  bottom: 19px;
  z-index: 150;
  padding: 5px 12px;
  font-family: 'Noto Serif JP', serif;
  font-size: 12px;
  color: #e8edf5;
  white-space: nowrap;
  background: rgba(10,18,32,0.9);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 999px;
  pointer-events: none;
  animation: hint-in 0.3s ease both;
}
.privacy-hint.is-out { animation: hint-out 0.4s ease forwards; }
@keyframes cookie-pop {
  from { transform: scale(0); }
  to   { transform: scale(1); }
}
@keyframes cookie-chomp {
  0%   { transform: scale(1) rotate(0); }
  30%  { transform: scale(0.88) rotate(-8deg); }
  60%  { transform: scale(1.06) rotate(4deg); }
  100% { transform: scale(1) rotate(0); }
}
@keyframes crumb-fall {
  from { opacity: 1; transform: translate(0, 0); }
  to   { opacity: 0; transform: translate(var(--dx), var(--dy)); }
}
@keyframes hint-in {
  from { opacity: 0; transform: translateX(8px); }
  to   { opacity: 1; transform: none; }
}
@keyframes hint-out {
  to { opacity: 0; transform: translateX(8px); }
}

/* ON / OFF スイッチ */
.privacy-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
.privacy-switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.privacy-switch-track {
  position: relative;
  flex: none;
  width: 38px;
  height: 22px;
  border-radius: 11px;
  background: rgba(255,255,255,0.18);
  transition: background 0.2s;
}
.privacy-switch-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
}
.privacy-switch input:checked + .privacy-switch-track { background: #6fdc8c; }
.privacy-switch input:checked + .privacy-switch-track::after { transform: translateX(16px); }
.privacy-switch input:focus-visible + .privacy-switch-track { outline: 2px dashed #a8d0ff; outline-offset: 2px; }
.privacy-switch input:disabled + .privacy-switch-track { opacity: 0.5; }
.privacy-switch-label { font-size: 13px; }

/* ── このページの重さと表示時間（js/extras.js の showPageWeight） ── */
.page-weight {
  margin: 14px 0 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.35);
  text-align: center;
}
/* トップは画面下のプログレスバーのすぐ下に出す（背景は暗いぼかし） */
.progress-bar .page-weight {
  position: absolute;
  z-index: 1;
  top: 6px;
  left: 0;
  margin: 0;
  font-size: 9px;
  text-align: left;   /* 中央の章の並びと切り分けて、左端に寄せる */
  color: rgba(255,255,255,0.45);
  pointer-events: none;
}
