/* 野帖 ── Feral Notes */

:root {
  --text: #2b2b28;
  --muted: #6d6d66;
  --accent: #4a5d46;
  --hairline: #e0dfda;
  --bg: #f3f3f2;
  --panel-bg: rgba(243, 243, 242, 0.96);
}

:root[data-theme="dark"] {
  --text: #e4e2db;
  --muted: #a09f95;
  --accent: #93ac8d;
  --hairline: #34352f;
  --bg: #1c1d1b;
  --panel-bg: rgba(28, 29, 27, 0.96);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic",
    "Noto Sans JP", Meiryo, system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.9;
  color: var(--text);
  background: var(--bg);
  transition: background 0.3s ease, color 0.3s ease;
}

.wrap {
  max-width: 66ch;
  margin: 0 auto;
  padding: 0 1.25rem;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

a:hover {
  color: var(--text);
}

/* 固定メニュー */
.menu-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 20;
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.25rem;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: var(--panel-bg);
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 0.25rem 1rem rgba(0, 0, 0, 0.08);
}

.menu-toggle span {
  display: block;
  width: 1rem;
  height: 1px;
  margin: 0 auto;
  background: currentColor;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.menu-toggle.is-open span:nth-child(1) {
  transform: translateY(5px) rotate(45deg);
}

.menu-toggle.is-open span:nth-child(2) {
  opacity: 0;
}

.menu-toggle.is-open span:nth-child(3) {
  transform: translateY(-5px) rotate(-45deg);
}

.menu-panel {
  position: fixed;
  top: 4rem;
  right: 1rem;
  z-index: 19;
  width: min(22rem, calc(100vw - 2rem));
  max-height: calc(100vh - 5rem);
  overflow: auto;
  border: 1px solid var(--hairline);
  background: var(--panel-bg);
  box-shadow: 0 0.75rem 2rem rgba(0, 0, 0, 0.12);
}

.menu-panel-inner {
  padding: 1rem;
}

.menu-links {
  display: flex;
  gap: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--hairline);
  font-size: 0.9rem;
}

.menu-links a,
.menu-writing a {
  color: var(--text);
  text-decoration: none;
}

.menu-links a:hover,
.menu-writing a:hover {
  color: var(--accent);
}

.menu-heading {
  margin: 1rem 0 0.5rem;
  font-size: 0.75rem;
  color: var(--muted);
  letter-spacing: 0;
}

.menu-writing ol {
  list-style: none;
  padding: 0;
  margin: 0;
}

.menu-writing li {
  padding: 0.45rem 0;
  border-top: 1px solid var(--hairline);
  font-size: 0.9rem;
  line-height: 1.5;
}

.entry-title-link {
  display: block;
}

.entry-title-main,
.entry-title-sub {
  display: block;
}

.entry-title-sub {
  margin-top: 0.08rem;
  color: var(--muted);
  font-size: 0.92em;
}

/* ヘッダー */
.site-header {
  border-bottom: 1px solid var(--hairline);
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-top: 1.5rem;
  padding-bottom: 1rem;
}

main {
  margin-top: 2.5rem;
}

.site-name {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}

.site-nav a {
  margin-left: 1.25rem;
  color: var(--muted);
  text-decoration: none;
}

.site-nav a:hover {
  color: var(--accent);
}

/* ダークモード切り替え */
.theme-toggle {
  background: none;
  border: none;
  padding: 0;
  margin-left: 1.25rem;
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
}

.theme-toggle:hover {
  color: var(--accent);
}

/* ヒーロー（全ページ共通の最上部画像） */
.hero {
  position: relative;
}

.hero img {
  display: block;
  width: 100%;
  height: min(55vh, 460px);
  object-fit: cover;
}

:root[data-theme="dark"] .hero img {
  filter: brightness(0.82);
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(25, 30, 25, 0.5), rgba(25, 30, 25, 0) 60%);
}

.hero-text {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 1.75rem;
  z-index: 1;
}

.hero-title {
  font-size: clamp(1.5rem, 4.5vw, 2.3rem);
  font-weight: 600;
  line-height: 1.4;
  color: #fff;
  margin: 0;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.45);
  animation: emerge 2s ease-out both;
}

.hero-subtitle {
  color: rgba(255, 255, 255, 0.92);
  font-size: 0.95rem;
  margin: 0.4rem 0 0;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.45);
  animation: emerge 2.4s ease-out 0.5s both;
}

/* 詩的に浮かび上がるタイトル */
@keyframes emerge {
  from {
    opacity: 0;
    transform: translateY(0.5em);
    filter: blur(6px);
  }
  to {
    opacity: 1;
    transform: none;
    filter: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero-title,
  .hero-subtitle {
    animation: none;
  }
}

/* 記事リスト */
.post-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.post-list li {
  margin-bottom: 1.5rem;
}

.post-list .post-meta {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.post-list .post-title {
  margin: 0;
  font-size: 1.05rem;
}

/* 型ラベル */
.type-label {
  display: inline-block;
  font-size: 0.75rem;
  color: var(--accent);
  border: 1px solid currentColor;
  border-radius: 2px;
  padding: 0 0.4em;
  margin-right: 0.6em;
  vertical-align: 0.08em;
}

/* 記事ページ */
.post-shell {
  display: grid;
  grid-template-columns: clamp(14rem, 19vw, 18rem) minmax(0, 78ch);
  gap: clamp(3rem, 6vw, 6rem);
  align-items: start;
  width: calc(100vw - 2.5rem);
  margin-left: calc(50% - 50vw + 1.25rem);
}

.post-sidebar {
  position: sticky;
  top: 5rem;
  max-height: calc(100vh - 6rem);
  overflow: auto;
  padding-right: 1.25rem;
  border-right: 1px solid var(--hairline);
}

.post-sidebar-heading {
  margin: 0 0 0.75rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.post-sidebar ol {
  list-style: none;
  padding: 0;
  margin: 0;
}

.post-sidebar li {
  margin: 0;
  padding: 0.6rem 0;
  border-top: 1px solid var(--hairline);
  font-size: 0.9rem;
  line-height: 1.5;
}

.post-sidebar a {
  color: var(--muted);
  text-decoration: none;
}

.post-sidebar a:hover,
.post-sidebar .is-current a {
  color: var(--accent);
}

.post-sidebar .is-current a {
  font-weight: 600;
}

.post {
  font-size: 1.14rem;
  line-height: 2;
  min-width: 0;
}

.post-header {
  padding-top: 1.5rem;
  margin-bottom: 2.5rem;
}

.post-meta {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0;
}

.post-description {
  color: var(--muted);
  margin: 0.25rem 0 0.75rem;
}

h2 {
  font-size: 1.42rem;
  margin: 2.8rem 0 1rem;
}

h3 {
  font-size: 1.18rem;
  margin: 2rem 0 0.75rem;
}

img {
  max-width: 100%;
  height: auto;
}

blockquote {
  margin: 1.5rem 0;
  padding-left: 1rem;
  border-left: 2px solid var(--hairline);
  color: var(--muted);
}

table {
  display: block;
  width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: 0.9rem;
  line-height: 1.6;
}

th,
td {
  border-bottom: 1px solid var(--hairline);
  padding: 0.35rem 0.6rem;
  vertical-align: top;
  text-align: left;
}

/* AI補助の表示 */
.ai-note {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--hairline);
  font-size: 0.85rem;
  color: var(--muted);
}

.post-pager {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 1rem;
  align-items: center;
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--hairline);
}

.pager-slot {
  min-width: 0;
}

.pager-slot span {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.pager-slot a {
  display: block;
  font-size: 0.95rem;
  line-height: 1.5;
  text-decoration: none;
}

.pager-next {
  text-align: right;
}

.pager-home {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  color: var(--accent);
  text-decoration: none;
}

.pager-home:hover {
  color: var(--text);
  border-color: var(--accent);
}

/* フッター */
.site-footer {
  margin-top: 4rem;
}

.footer-name {
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
  margin: 2rem 0;
}

@media (max-width: 920px) {
  .post-shell {
    display: block;
    width: 100%;
    margin-left: 0;
  }

  .post-sidebar {
    display: none;
  }
}

@media (max-width: 640px) {
  .header-inner {
    padding-right: 3rem;
  }

  .site-nav {
    display: none;
  }

  .hero img {
    height: min(42vh, 360px);
  }

  .post-pager {
    grid-template-columns: 1fr auto 1fr;
    gap: 0.75rem;
  }

  .pager-slot a {
    font-size: 0.86rem;
  }
}
