/* Base */
/*
 * Breakpoint guideline for new styles:
 *   sm:  560px  (smartphone)       -> @media (max-width:560px)
 *   md:  760px  (portrait tablet)  -> @media (max-width:760px)
 *   lg: 1000px  (landscape tablet) -> @media (max-width:1000px)
 * CSS custom properties cannot be used in media-query conditions. Keep these
 * values as the shared convention; existing breakpoints remain unchanged.
 */
/*
 * z-index 階層（既存値は変更しない）
 *   -2〜-1   背景装飾
 *   1〜3     コンテンツ内の重なり
 *   20〜70   サイト内ヘッダー・ドロップダウン
 *   120      レゾナのチャット起動ボタン
 *   200      スキップリンク
 *   999      サイト固有のモーダル
 *   9999     ページカウンター（YACHO）
 *   10000    ending_pv の開始画面
 *   10010    ending_pv の固定フッター（通常カウンターより上になるため要注意）
 *   10020    ending_pv の音量コントロール
 *   10030    ending_pv のページカウンター退避位置
 *   99999    ページ一覧モーダル（YACHO）
 */
:root {
  --ui-line: #d9dcde;
  --ui-neutral-light: #dadce0;
  --ui-text-muted: #777d82;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", sans-serif;
  --font-serif: "Yu Mincho", "Hiragino Mincho ProN", serif;
}
* {
  box-sizing: border-box;
}
html {
  scrollbar-gutter: stable;
}
body {
  margin: 0;
}
.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;
}

/* Fiction footer */
:root {
  --fiction-footer-size: 12px;
  --fiction-footer-line-height: 1.5;
  --fiction-footer-pad: 12px;
  --footer-notice-height: 60px; /* 12px × 1.5 × 2行 + 上下余白24px */
  --footer-yacho-height: 28px;
  --fiction-footer-min-height: calc(var(--footer-notice-height) + var(--footer-yacho-height));
  --site-credit: "©旅するうまさん";
}

body {
  min-height: 100vh;
}
#app {
  display: flex;
  flex-direction: column;
  flex: 1;
}
#app > main,
body > main {
  flex: 1;
}
body:has(> main),
body:has(> #app) {
  display: flex;
  flex-direction: column;
}
body > .site-footer {
  margin-top: auto;
}

@supports not selector(body:has(> main)) {
  body {
    display: flex;
    flex-direction: column;
  }
}

.fiction-note {
  margin: 0;
  box-sizing: border-box;
  min-height: var(--footer-notice-height);
  padding-block: var(--fiction-footer-pad);
  font-size: var(--fiction-footer-size);
  line-height: var(--fiction-footer-line-height);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", "Yu Gothic", Meiryo, sans-serif;
  font-weight: 400;
  letter-spacing: 0;
  color: inherit;
  text-align: center;
  white-space: normal;
  display: block;
}

.fiction-line {
  display: inline;
  white-space: normal;
}

.fiction-note::before {
  content: var(--site-credit);
  display: block;
  margin-bottom: 2px;
  color: inherit;
  font: inherit;
  letter-spacing: 0;
  text-align: center;
  white-space: nowrap;
}

.site-footer .footer-bottom,
body > .site-footer:not(:has(.footer-bottom)),
#app > .site-footer {
  box-sizing: border-box;
  height: auto;
  min-height: var(--footer-notice-height);
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 0 16px;
  border-top: 0;
  text-align: center;
}

.site-footer {
  background: var(--fiction-footer-bg, #f1f1ef);
  color: var(--fiction-footer-fg, #6f6f6b);
  border-top: var(--fiction-footer-border, 0);
}

body > .site-footer {
  padding-block: 0;
  border-top: var(--fiction-footer-border, 0);
}
.site-footer .footer-bottom {
  flex: 0 0 auto;
  margin-block: 0;
  justify-content: center;
  border: 0;
  background: transparent;
  color: inherit;
}

/* YACHO adds this direct child during publish. Keep it directly below the notice. */
body > footer > p[style*="margin-top"],
footer > p:has(a[href*="yacho"]),
footer > div:has(a[href*="yacho"]) {
  box-sizing: border-box !important;
  height: var(--footer-yacho-height) !important;
  min-height: var(--footer-yacho-height) !important;
  margin: 0 !important;
  padding: 2px 0 8px !important;
  border: 0 !important;
  font-size: var(--fiction-footer-size) !important;
  line-height: var(--fiction-footer-line-height) !important;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", "Yu Gothic", Meiryo, sans-serif !important;
  font-weight: 400 !important;
  letter-spacing: 0 !important;
  color: inherit !important;
  text-align: center !important;
  opacity: 0.55 !important;
}
body > footer > p[style*="margin-top"]::before,
body > footer > p[style*="margin-top"]::after,
footer > p:has(a[href*="yacho"])::before,
footer > p:has(a[href*="yacho"])::after,
footer > div:has(a[href*="yacho"])::before,
footer > div:has(a[href*="yacho"])::after {
  content: none !important;
  display: none !important;
}
body > footer > p[style*="margin-top"] a,
footer > p:has(a[href*="yacho"]) a,
footer > div:has(a[href*="yacho"]) a {
  color: inherit !important;
}

/* index.html receives a separate YACHO-only footer during publish. */
body > footer[style*="text-align:center"]:not(.site-footer):not(.journal-footer),
body > footer:has(> p > a[href*="yacho"]):not(.site-footer):not(.journal-footer) {
  box-sizing: border-box !important;
  width: 100% !important;
  height: auto !important;
  min-height: var(--footer-yacho-height) !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  background: var(--fiction-footer-bg, #f1f1ef) !important;
  color: var(--fiction-footer-fg, #6f6f6b) !important;
}

.site-footer .fiction-note {
  display: block;
  width: 100%;
}

@media (max-width: 640px) {
  body > .site-footer:not(:has(.footer-bottom)) {
    min-height: 98px;
  }
}

#app > .site-footer {
  width: 100%;
  align-self: stretch;
}
#app > .site-footer {
  flex: 0 0 auto;
  justify-content: center;
}
#app > .site-footer > .fiction-note {
  width: 100%;
  margin-inline: auto;
}

@media (max-width: 640px) {
  .fiction-line {
    white-space: normal;
  }
}

/* Page counter */
.page-counter,
#page-counter {
  position: fixed !important;
  right: auto !important;
  bottom: max(12px, env(safe-area-inset-bottom, 0px)) !important;
  left: max(12px, env(safe-area-inset-left, 0px)) !important;
  top: auto !important;
  box-sizing: border-box !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 92px !important;
  min-width: 92px !important;
  max-width: 92px !important;
  height: 54px !important;
  min-height: 54px !important;
  max-height: 54px !important;
  margin: 0 !important;
  font: 500 16px/1 var(--font-sans) !important;
  letter-spacing: 0.05em;
  color: #fff;
  background: rgba(0, 0, 0, 0.75);
  padding: 0 !important;
  border: 0 !important;
  border-radius: 999px !important;
  pointer-events: none;
  z-index: 9999 !important;
  transition: background 0.15s;
}

/* YACHO appends page-counter.css after common.css during publish. */
body > #page-counter,
body > .page-counter {
  right: auto !important;
  bottom: max(12px, env(safe-area-inset-bottom, 0px)) !important;
  left: max(12px, env(safe-area-inset-left, 0px)) !important;
  top: auto !important;
}

#page-counter[data-yacho-visit-mode="modal"],
#page-counter[data-yacho-visit-mode="page"] {
  pointer-events: auto;
  cursor: pointer;
}

#page-counter[data-yacho-visit-mode="modal"]:hover,
#page-counter[data-yacho-visit-mode="page"]:hover {
  background: rgba(0, 0, 0, 0.88);
}

/* Page list modal */
.page-list-popup {
  position: fixed;
  left: max(12px, env(safe-area-inset-left, 0px));
  right: auto;
  bottom: calc(max(12px, env(safe-area-inset-bottom, 0px)) + 52px);
  z-index: 99999 !important;
  width: 340px;
  height: min(320px, 60vh);
  overflow-y: auto;

  background: #1a1a1a;
  color: #e0e0e0;

  border-radius: 8px;
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(255, 255, 255, 0.08);
}

.page-list-popup.hidden {
  display: none;
}

.page-list-popup__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  position: sticky;
  top: 0;
  background: #1a1a1a;
  z-index: 1;
}

.page-list-popup__title {
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
}

.page-list-popup__close {
  background: none;
  border: none;
  color: #888;
  font-size: 1rem;
  cursor: pointer;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  line-height: 1;
}

.page-list-popup__close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.page-list-popup__body {
  padding: 0.25rem 0;
}

.page-list__items {
  list-style: none;
  padding: 0;
  margin: 0;
}

.page-list__item {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.page-list__item:last-child {
  border-bottom: none;
}

.page-list__page-no {
  flex-shrink: 0;
  width: 2rem;
  font-size: 0.8rem;
  color: #666;
  font-variant-numeric: tabular-nums;
}

.page-list__status {
  flex-shrink: 0;
  width: 1.2rem;
  text-align: center;
  font-size: 0.75rem;
  color: #555;
}

.page-list__item.is-visited .page-list__status {
  color: #4fc3f7;
}

.page-list__title {
  flex: 1;
  font-size: 0.82rem;
  line-height: 1.4;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-list__title.is-hidden {
  color: #555;
  font-style: italic;
}

.page-list__link {
  color: #e0e0e0;
  text-decoration: none;
}

.page-list__link:hover {
  color: #fff;
  text-decoration: underline;
}

/* ending_pv のカウンター位置は ending_pv.css 側で指定している。
 * ここにも同じセレクタを置くと二重管理になるため持たない。 */
