/* tokisato.info（AstroPaper ベース）に合わせたデザイン */

:root,
html[data-theme="light"] {
  --fill: rgb(251, 254, 251);
  --text: rgb(40, 39, 40);
  --accent: rgb(40, 39, 40);
  --card: rgb(230, 230, 230);
  --card-muted: rgb(205, 205, 205);
  --border: rgb(236, 233, 233);
  --hover: #faa;
  color-scheme: light;
}

html[data-theme="dark"] {
  --fill: rgb(47, 55, 65);
  --text: rgb(230, 230, 230);
  --accent: rgb(230, 230, 230);
  --card: rgb(63, 75, 90);
  --card-muted: rgb(89, 107, 129);
  --border: rgb(59, 70, 85);
  --hover: rgba(255, 170, 170, 0.22);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme]) {
    --fill: rgb(47, 55, 65);
    --text: rgb(230, 230, 230);
    --accent: rgb(230, 230, 230);
    --card: rgb(63, 75, 90);
    --card-muted: rgb(89, 107, 129);
    --border: rgb(59, 70, 85);
    --hover: rgba(255, 170, 170, 0.22);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--fill);
  color: var(--text);
  font-family: "IBM Plex Mono", ui-monospace, "Hiragino Sans", "Noto Sans JP", "Yu Gothic", Meiryo, monospace;
  font-size: 16px;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; display: block; }
:focus-visible { outline: 2px dashed var(--accent); outline-offset: 2px; }

hr { border: 0; border-top: 1px solid var(--border); margin: 0; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link { position: absolute; left: -999px; top: 8px; background: var(--fill); padding: 4px 8px; z-index: 10; }
.skip-link:focus { left: 16px; }

/* ---------- ヘッダー ---------- */

.site-header,
main,
.site-footer {
  width: 100%;
  max-width: 768px;
  margin-inline: auto;
}

.nav-wrap {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 32px 16px 0;
  position: relative;
}

.site-header > hr { margin: 0 16px; }

.logo {
  display: block;
  max-width: 11ch;
  padding: 4px 0 16px;
  font-size: 24px;
  font-weight: 600;
  line-height: 32px;
}

.site-nav { display: flex; align-items: center; padding-top: 4px; }

.site-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}

.site-nav a,
#theme-btn {
  display: block;
  padding: 4px 12px;
  font-weight: 500;
}
.site-nav a:hover { color: var(--accent); opacity: 0.75; }
.site-nav a.active {
  text-decoration: underline wavy 2px;
  text-underline-offset: 4px;
}

#theme-btn {
  background: none;
  border: 0;
  color: inherit;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 0;
}
#theme-btn svg { width: 24px; height: 24px; fill: currentColor; }
#theme-btn:hover { opacity: 0.75; }
#sun-svg { display: none; }
html[data-theme="dark"] #moon-svg { display: none; }
html[data-theme="dark"] #sun-svg { display: block; }

.menu-toggle {
  display: none;
  width: 40px; height: 40px;
  padding: 10px 8px;
  background: none; border: 0; cursor: pointer; color: inherit;
  flex-direction: column; justify-content: space-between;
}
.menu-toggle span { display: block; height: 2px; background: currentColor; transition: transform 0.2s, opacity 0.2s, width 0.2s; }
.menu-toggle span:nth-child(2) { width: 75%; align-self: flex-end; }
.menu-toggle span:nth-child(3) { width: 50%; align-self: flex-end; }

@media (max-width: 639px) {
  .menu-toggle { display: flex; }
  .site-nav ul {
    display: none;
    position: absolute;
    top: 100%;
    left: 16px;
    right: 16px;
    padding: 8px 0 16px;
    flex-wrap: wrap;
    justify-content: center;
    background: var(--fill);
    z-index: 5;
  }
  .menu-open .site-nav ul { display: flex; }
  .menu-open .menu-toggle span:nth-child(1) { transform: translateY(8px) rotate(45deg); }
  .menu-open .menu-toggle span:nth-child(2) { opacity: 0; }
  .menu-open .menu-toggle span:nth-child(3) { width: 100%; transform: translateY(-8px) rotate(-45deg); }
}

/* ---------- 本文 ---------- */

main {
  flex: 1;
  padding: 0 16px 48px;
}

.page-title,
.section-title {
  margin: 36px 0 0;
  font-size: 24px;
  font-weight: 600;
  line-height: 32px;
}
.section-title { margin-bottom: 4px; }
.page-title + .doc { margin-top: 32px; }
/* 作品ページ：本文に「タイトル」の行があるときは大きな見出しを出さない（見出しは読み上げ用にだけ残す） */
h1.visually-hidden + .doc { margin-top: 36px; }
.page-title + .card-list { margin-top: 4px; }

main > hr { margin: 32px 0 0; }
.hero { padding-top: 32px; }

.go-back { display: inline-flex; gap: 0.5em; margin-top: 32px; }
.go-back:hover { opacity: 0.75; }

/* Docの中身（元サイトの .prose 相当） */
.doc { font-size: 16px; line-height: 1.75; overflow-wrap: anywhere; }
.doc > * + * { margin-top: 1.25em; }
.doc > :first-child { margin-top: 0; }
.doc p { margin: 0; }

.doc a {
  color: var(--accent);
  text-decoration: underline dashed;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}
.doc a:hover { text-decoration-style: solid; }

/* 見出し1 → h2（セクション見出し） */
.doc h2 { font-size: 1.5em; font-weight: 600; line-height: 1.4; margin: 2.2em 0 0.8em; }
/* 見出し2 → h3（小見出し） */
.doc h3 { font-size: 1em; font-weight: 600; line-height: 1.5; margin: 1.8em 0 0.2em; }
/* 見出し3〜6 → h4（小さなラベル） */
.doc h4 { font-size: 0.8em; font-weight: 600; line-height: 1.5; letter-spacing: 0.04em; opacity: 0.75; margin: 1.6em 0 0; }
.doc h2 + *, .doc h3 + *, .doc h4 + * { margin-top: 0; }

/* タイトル */
.doc .doc-title { font-size: 1.5em; font-weight: 600; }

/* サブタイトル → キャプション・クレジット・年や日付 */
.doc .caption { font-size: 0.75em; line-height: 1.6; opacity: 0.75; }
/* Docの空行 → 1行分の空き（本文の行の高さと同じ） */
.doc .blank { height: 1.75rem; margin: 0; }
.doc :is(h2, h3, h4) + .caption { margin-top: 0; }
.doc figure + .caption,
.doc .video + .caption { margin-top: 0.5em; }
.doc .caption + figure,
.doc .caption + .video { margin-top: 2em; }

/* 文字の行どうしは、Docと同じく間をあけない（あけたいときはDocで空行を入れる） */
.doc strong { font-weight: 600; }

.align-center { text-align: center; }
.align-end { text-align: right; }
.align-justify { text-align: justify; }

.doc figure { margin: 2em 0 0; }
.doc figure + figure { margin-top: 1.25em; }
.doc figure img { width: 100%; }
.doc p img { display: inline-block; vertical-align: middle; }

.doc hr { margin: 2em 0; }

.doc ul, .doc ol { padding-left: 1.5em; }
.doc li + li { margin-top: 0.25em; }

.doc .video { position: relative; aspect-ratio: 16 / 9; background: var(--card); margin-top: 2em; }
.doc .video:first-child { margin-top: 0; }
.doc .video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.doc .video + * { margin-top: 2em; }

.table-wrap { overflow-x: auto; }
.doc table { width: 100%; border-collapse: collapse; font-size: 0.875em; }
.doc td { padding: 0.5em 1em 0.5em 0; vertical-align: top; border-bottom: 1px solid var(--border); }
.doc td:first-child { white-space: nowrap; width: 1%; padding-right: 1.5em; }

.image-grid { display: grid; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); gap: 1rem; margin-top: 2em; }
.image-grid img { width: 100%; }
.image-grid p { font-size: 0.8em; opacity: 0.8; margin-top: 0.4em; }
@media (max-width: 599px) { .image-grid { grid-template-columns: 1fr; } }

/* ---------- 一覧（元サイトの card-post） ---------- */

.card-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--text);
}
.card { position: relative; border-bottom: 1px solid var(--text); }
/* 元サイト：スマホでは画像の下に文字、640px以上で横並び。ホバーでピンク */
.card-wrap { display: block; padding: 20px; transition: background-color 0.15s; }
.card-wrap:hover { background-color: var(--hover); }

.card-img { width: 100%; }
.card-img img { width: 100%; height: auto; border-radius: 4%; }
.card-img:empty { aspect-ratio: 16 / 9; background: var(--card); border-radius: 4%; }

.card-detail { width: 100%; padding-top: 16px; }
/* 「JP:」「EN:」のぶら下げインデント */
.card-line { margin: 0; font-size: 0.8em; line-height: 1.5; text-indent: -1.8em; padding-left: 1.8em; }
.card-foot { margin-top: 1.5em; text-align: right; }
.card-name,
.card-meta { margin: 0; font-size: 10px; line-height: 1.5; }

@media (min-width: 640px) {
  .card-wrap { display: flex; padding: 20px 16px; }
  .card-img { flex: 0 0 33.333%; }
  .card-detail { width: 75%; padding: 0 0 2.5em 28px; }
  .card-foot { position: absolute; right: 20px; bottom: 20px; margin: 0; }
}

/* ---------- フッター ---------- */

.site-footer > hr { margin: 0 16px; }
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 24px 16px;
}
.social { display: flex; gap: 4px; }
.social a { display: block; padding: 4px; }
.social a:hover { opacity: 0.75; }
.social svg { width: 24px; height: 24px; display: block; }
.copyright { margin: 0; font-size: 14px; }

/* タイトル（作品名）→ 作品ページの題名ブロック
   1行目（JP）を少し大きく太く、2行目以降（EN）は細く薄く。
   ラベル（JP / EN）は左に小さく置き、折り返した行は本文の頭にそろえる */
.doc .doc-title {
  position: relative;
  padding-left: 2.6em;
  font-size: 1.05em;
  font-weight: 600;
  line-height: 1.6;
  letter-spacing: 0.01em;
}
.doc .doc-title + .doc-title {
  margin-top: 0.4em;
  font-size: 0.85em;
  font-weight: 400;
  line-height: 1.7;
  opacity: 0.8;
  padding-left: calc(2.6em * 1.05 / 0.85);
}
.doc .doc-title .label {
  position: absolute;
  left: 0;
  top: 0.35em;
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  line-height: 1.6;
  padding: 0 0.4em;
  border: 1px solid currentColor;
  border-radius: 3px;
  opacity: 0.7;
}
.doc .doc-title + .doc-title .label { top: 0.3em; }
/* 動画・画像のあとの題名ブロックは、しっかり間をあける */
.doc :not(.doc-title) + .doc-title { margin-top: 2.25em; }
/* 題名のすぐ下の年：題名の文字の頭にそろえ、少し大きくはっきり */
.doc .doc-title + .caption {
  margin-top: 0.9em;
  padding-left: calc(2.6em * 1.05 / 0.85);
  font-size: 0.85em;
  font-weight: 500;
  letter-spacing: 0.06em;
  opacity: 0.9;
}

/* ---------- ページ送り（元サイトの Prev / Next） ---------- */
.pager { display: flex; justify-content: center; align-items: center; gap: 1.5rem; margin-top: 32px; }
.pager-link { padding: 4px 8px; font-weight: 500; }
a.pager-link:hover { opacity: 0.75; }
.pager-link.disabled { opacity: 0.35; }
.pager-count { font-size: 12px; opacity: 0.7; }
