/*
  Designed by instan <https://instan.fc2.page>
*/

/* ===== カラー・フォントの設定（ここを変えると全体の見た目が変わります） ===== */
:root {
  color-scheme: light dark;

  /* ライトモードの色（古紙色背景 + 墨文字） */
  --color-bg: #faf8f3;
  --color-text: #2a2622;
  --color-accent: #a64545;
  --color-line: #d8d2c4;
  --color-muted: #6b665c;

  /* フォント */
  --font-serif-ja: "Noto Serif JP", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --font-serif-en: "EB Garamond", "Times New Roman", serif;
  --font-body: var(--font-serif-en), var(--font-serif-ja);

  /* レイアウト */
  --content-width: 720px;
  --reading-width: 36rem;
  --header-height: 56px;

  accent-color: var(--color-accent);
}

/* ダークモード（OS のダーク設定が ON のときだけ上の色を上書き） */
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #1c1a17;
    --color-text: #ebe5d6;
    --color-accent: #d97a7a;
    --color-line: #3a342c;
    --color-muted: #9a9385;
  }
}

/* Scroll-driven animation 用の registered custom properties */
@property --header-bg-alpha {
  syntax: "<number>";
  inherits: false;
  initial-value: 0;
}

@property --drawer-backdrop {
  syntax: "<number>";
  inherits: true;
  initial-value: 0;
}

/* ===== 文字まわりの基本設定 ===== */
body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.7;
  text-align: justify;
  text-align-last: left;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

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

a:hover {
  text-decoration: underline;
}

:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: 500;
  line-height: 1.4;
  text-wrap: balance;
}

h1 {
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  margin: 2.5rem 0 1.25rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-line);
  letter-spacing: 0.05em;
}

h2 {
  font-size: 1.5rem;
  margin: 2.25rem 0 1rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--color-line);
}

h3 {
  font-size: 1.2rem;
  margin: 2rem 0 0.85rem;
  padding-left: 0.6rem;
  border-left: 3px solid var(--color-accent);
}

h4 {
  font-size: 1.05rem;
  margin: 1.75rem 0 0.6rem;
  color: var(--color-accent);
}

h5 {
  font-size: 0.95rem;
  margin: 1.5rem 0 0.5rem;
  letter-spacing: 0.1em;
}

h6 {
  font-size: 0.85rem;
  margin: 1.25rem 0 0.4rem;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.15em;
}

p + p {
  margin-top: 1em;
}

/* ===== 強調 / 引用 / 区切り / コード（本文中で使う inline / block 要素） ===== */
em {
  font-style: italic;
  color: var(--color-accent);
}

strong {
  font-weight: 500;
  background: linear-gradient(
    transparent 60%,
    color-mix(in oklab, var(--color-accent) 22%, transparent) 60%
  );
}

mark {
  background: color-mix(in oklab, var(--color-accent) 18%, transparent);
  color: inherit;
  padding: 0 0.2em;
}

blockquote {
  margin: 1.5em 0;
  padding: 0.5em 1.25em;
  border-left: 3px solid var(--color-line);
  color: var(--color-muted);
  font-style: italic;
}

ul {
  margin: 1em 0;
  padding-left: 1.75em;
  list-style: disc;
}

ol {
  margin: 1em 0;
  padding-left: 1.75em;
  list-style: decimal;
}

dl {
  margin: 1em 0;
}

dt {
  font-weight: 500;
  margin-top: 0.75em;
}

dd {
  margin-left: 1.5em;
}

table {
  width: 100%;
  margin: 1.5em 0;
  border-collapse: collapse;
  font-size: 0.95rem;
}

th,
td {
  padding: 0.5em 0.75em;
  border-bottom: 1px solid var(--color-line);
  text-align: left;
}

th {
  font-weight: 500;
  color: var(--color-muted);
}

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

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9em;
  background: color-mix(in oklab, var(--color-text) 8%, transparent);
  padding: 0.1em 0.3em;
  border-radius: 2px;
}

pre {
  margin: 1.5em 0;
  padding: 1em;
  background: color-mix(in oklab, var(--color-text) 5%, transparent);
  border-radius: 2px;
  overflow-x: auto;
  font-size: 0.9rem;
  line-height: 1.6;
}

pre code {
  background: transparent;
  padding: 0;
}

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

/* ===== フォーム要素 ===== */
label {
  display: block;
  font-size: 0.85rem;
  color: var(--color-muted);
  margin-bottom: 0.3em;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"],
input[type="search"],
input[type="url"],
input[type="tel"],
textarea,
select {
  -webkit-appearance: none;
  border: 1px solid var(--color-line);
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 0.5rem;
  border-radius: 0;
}

textarea {
  width: 100%;
  min-height: 4rem;
  margin: 0.5rem 0;
  resize: vertical;
}

select {
  padding-right: 1.75rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b665c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
}

button,
input[type="button"],
input[type="submit"],
input[type="reset"] {
  -webkit-appearance: none;
  background: var(--color-bg);
  color: var(--color-text);
  border: 1px solid var(--color-line);
  padding: 0.5rem 1.5rem;
  font-family: var(--font-body);
  font-size: 0.95rem;
  cursor: pointer;
  touch-action: manipulation;
  letter-spacing: 0.05em;
}

button:hover,
input[type="button"]:hover,
input[type="submit"]:hover,
input[type="reset"]:hover {
  border-color: var(--color-accent);
}

.form-actions {
  display: block;
  text-align: center;
}

/* ===== 画面上部の固定ヘッダー（サイト名 + メニュー） ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  height: var(--header-height);
  border-bottom: 1px solid transparent;
  background: color-mix(in oklab, var(--color-bg) calc(var(--header-bg-alpha) * 100%), transparent);
}

@supports (animation-timeline: scroll()) {
  .site-header {
    animation: header-solidify linear both;
    animation-timeline: scroll(root);
    animation-range: 0 80px;
  }

  @keyframes header-solidify {
    from {
      --header-bg-alpha: 0;
      border-bottom-color: transparent;
    }
    to {
      --header-bg-alpha: 1;
      border-bottom-color: var(--color-line);
    }
  }
}

/* JS fallback (main.js が .scrolled クラスを付与) */
.site-header.scrolled {
  --header-bg-alpha: 1;
  border-bottom-color: var(--color-line);
}

.site-header-inner {
  max-width: var(--content-width);
  margin: 0 auto;
  height: 100%;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-name {
  font-size: 1.1rem;
  font-weight: 500;
  text-decoration: none;
  color: var(--color-text);
  letter-spacing: 0.05em;
}

/* ===== ナビゲーション =====
   1 つの <nav class="site-nav"> をリンク編集の唯一の場所として運用する。
   SP では .drawer を popover + transform: translateX で右からスライドインするドロワー化、
   PC では .drawer を display: contents でフラット化してヘッダー内インラインにする。 */

/* SP: ハンバーガーで開くドロワー（デフォルト挙動） */
.drawer {
  --drawer-width: min(20rem, 80dvw);
  position: fixed;
  inset: 0 0 0 auto;
  width: var(--drawer-width);
  height: 100dvh;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--color-bg);
  border-left: 1px solid var(--color-line);
  box-shadow: -8px 0 24px -12px rgba(0, 0, 0, 0.25);
  color: var(--color-text);
  overflow: hidden;
  transform: translateX(105%);
  transition:
    transform 0.28s cubic-bezier(0.3, 0.7, 0.3, 1),
    display 0.28s allow-discrete,
    overlay 0.28s allow-discrete;
}

.drawer:popover-open {
  transform: translateX(0);
}

@starting-style {
  .drawer:popover-open {
    transform: translateX(105%);
  }
}

.drawer::backdrop {
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  transition:
    opacity 0.28s ease,
    display 0.28s allow-discrete,
    overlay 0.28s allow-discrete;
}

.drawer:popover-open::backdrop {
  opacity: 1;
}

@starting-style {
  .drawer:popover-open::backdrop {
    opacity: 0;
  }
}

.site-nav {
  height: 100%;
  overflow-y: auto;
  scrollbar-width: none;
}

.site-nav::-webkit-scrollbar {
  display: none;
}

.site-nav ul {
  padding: 4rem 1.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  /* base ul の list-style / margin を打ち消す */
  list-style: none;
  margin: 0;
}

.site-nav a {
  display: block;
  padding: 0.9rem 0.5rem;
  font-size: 1.05rem;
  text-decoration: none;
  color: var(--color-text);
  border-bottom: 1px solid var(--color-line);
  letter-spacing: 0.05em;
}

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

.drawer-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--color-line);
  border-radius: 4px;
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 16px;
  cursor: pointer;
  touch-action: manipulation;
  z-index: 1;
}

.drawer-close:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.nav-toggle {
  touch-action: manipulation;
  display: inline-flex;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.nav-toggle:hover {
  background: color-mix(in oklab, var(--color-text) 6%, transparent);
}

/* PC: ヘッダー内インラインに切り替え（768px以上）
   drawer の box を display: contents で消すことで、
   中の <nav> が .site-header-inner の flex 子として横並びになる。 */
@media (min-width: 768px) {
  .drawer {
    display: contents;
  }

  .site-nav {
    display: block;
    height: auto;
    overflow: visible;
  }

  .site-nav ul {
    flex-direction: row;
    gap: 1.5rem;
    padding: 0;
  }

  .site-nav a {
    display: inline;
    padding: 0;
    border-bottom: 0;
    font-size: 0.95rem;
  }

  .drawer-close,
  .nav-toggle {
    display: none;
  }
}

/* ===== 本文エリアの共通レイアウト（全ページ共通） ===== */
.site-main {
  flex: 1;
  width: 100%;
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 2.5rem 1rem 4rem;
}

section + section {
  margin-top: 3rem;
}

.page-title {
  font-size: 1.75rem;
  /* base h1 の margin shorthand を上書きして top も明示制御 */
  margin: 0 0 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--color-line);
}

.section-title {
  font-size: 1.35rem;
  /* base h2 の margin / 罫線を打ち消す */
  margin: 0 0 1rem;
  padding-bottom: 0;
  border-bottom: 0;
}

/* ===== トップページの大見出しエリア ===== */
.hero {
  padding: 2rem 0 3rem;
  text-align: center;
  border-bottom: 1px solid var(--color-line);
  margin-bottom: 2rem;
}

.hero-title {
  font-size: clamp(1.75rem, 5vw, 2.5rem);
  font-weight: 500;
  letter-spacing: 0.1em;
  /* base h1 の margin shorthand / 罫線を打ち消す */
  margin: 0 0 0.5rem;
  padding-bottom: 0;
  border-bottom: 0;
}

/* ===== トップページの各セクション（新着novels / news 抜粋） ===== */
.top-section {
  margin-top: 3rem;
}

.top-section-more {
  margin-top: 1rem;
  text-align: right;
  font-size: 0.85rem;
}

.top-news-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  /* base ul の list-style / padding / margin を打ち消す */
  list-style: none;
  margin: 0;
  padding-left: 0;
}

.top-news-item {
  display: grid;
  grid-template-columns: 6rem 1fr;
  gap: 1rem;
  font-size: 0.9rem;
}

.top-news-item time {
  color: var(--color-muted);
  font-family: var(--font-serif-en);
  font-style: italic;
}

/* ===== 作品一覧ページ（/novels/） ===== */
.novels-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  /* base ul の list-style / padding / margin を打ち消す */
  list-style: none;
  margin: 0;
  padding-left: 0;
}

.novel-card {
  padding: 1.25rem;
  border: 1px solid var(--color-line);
  border-radius: 2px;
  transition: border-color 0.2s;
}

.novel-card:hover {
  border-color: var(--color-accent);
}

.novel-card a {
  display: block;
  text-decoration: none;
  color: inherit;
}

.novel-card-title {
  font-size: 1.2rem;
  /* base h2 / h3 双方の margin / 罫線を打ち消す（カード内タイトル） */
  margin: 0 0 0.5rem;
  padding-bottom: 0;
  border-bottom: 0;
  padding-left: 0;
  border-left: 0;
}

.novel-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: var(--color-muted);
  margin-bottom: 0.75rem;
}

.novel-card-cat {
  font-size: 0.78rem;
  color: var(--color-muted);
}

.novel-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.novel-tag {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  font-size: 0.75rem;
  border: 1px solid var(--color-line);
  color: var(--color-muted);
  letter-spacing: 0.05em;
}

.novel-card-excerpt {
  font-size: 0.95rem;
  color: var(--color-muted);
}

/* ===== 作品本文ページ（/novels/NNN.html） ===== */
.novel-back {
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
  display: inline-block;
}

.novel-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--color-line);
}

.novel-title {
  font-size: 1.75rem;
  /* base h1 の罫線は .novel-header 側で持つので打ち消す */
  margin: 0 0 0.75rem;
  padding-bottom: 0;
  border-bottom: 0;
}

.novel-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: var(--color-muted);
}

.caution {
  margin: 1.5rem 0;
  padding: 1rem 1.25rem;
  border-left: 3px solid var(--color-accent);
  background: color-mix(in oklab, var(--color-accent) 5%, transparent);
  font-size: 0.9rem;
}

.caution-title {
  font-weight: 500;
  margin-bottom: 0.25rem;
  color: var(--color-accent);
}

.novel-body {
  max-width: var(--reading-width);
  margin: 2rem auto 3rem;
  font-size: 1rem;
  line-height: 1.95;
}

.novel-body p + p {
  margin-top: 1.4em;
  text-indent: 1em;
}

.novel-body p:first-child {
  text-indent: 0;
}

.novel-footer {
  text-align: center;
  padding-top: 2rem;
  border-top: 1px solid var(--color-line);
}

.novel-footer-back {
  display: inline-block;
  padding: 0.75rem 2rem;
  border: 1px solid var(--color-line);
  text-decoration: none;
  font-size: 0.95rem;
  transition:
    border-color 0.2s,
    color 0.2s;
}

.novel-footer-back:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

/* ===== お知らせ一覧ページ（/news/） ===== */
.news-list {
  display: flex;
  flex-direction: column;
  /* base ul の list-style / padding / margin を打ち消す */
  list-style: none;
  margin: 0;
  padding-left: 0;
}

.news-item {
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--color-line);
  display: grid;
  grid-template-columns: 6rem 1fr;
  gap: 1rem;
  align-items: start;
}

.news-date {
  font-family: var(--font-serif-en);
  font-size: 0.9rem;
  color: var(--color-muted);
  font-style: italic;
}

.news-body {
  font-size: 0.95rem;
}

@media (max-width: 600px) {
  .news-item {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }
  .top-news-item {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }
}

/* ===== aboutページ ===== */
.about-section {
  margin-bottom: 2rem;
}

.about-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.5rem 1.5rem;
  margin-top: 1rem;
}

.about-list dt {
  font-weight: 500;
  color: var(--color-muted);
  /* base dt の margin-top を打ち消す（grid 表示で不要） */
  margin-top: 0;
}

/* ===== つぶやきタイムライン（/timeline.html） ===== */
.timeline {
  display: flex;
  flex-direction: column;
  /* base ul の list-style / padding / margin を打ち消す */
  list-style: none;
  margin: 0;
  padding-left: 0;
}

.timeline-item {
  padding: 1.75rem 0;
  border-bottom: 1px solid var(--color-line);
}

.timeline-item:first-child {
  padding-top: 0.5rem;
}

.timeline-item:last-child {
  border-bottom: 0;
}

.timeline-item.is-pinned {
  border-left: 3px solid var(--color-accent);
  padding: 1.75rem 1.25rem;
  background: color-mix(in oklab, var(--color-accent) 5%, transparent);
}

.timeline-meta {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  color: var(--color-muted);
}

.timeline-pin {
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  color: var(--color-accent);
}

.timeline-pin::before {
  content: "[ ";
}

.timeline-pin::after {
  content: " ]";
}

.timeline-time {
  font-family: var(--font-serif-en);
  font-style: italic;
  color: var(--color-muted);
}

.timeline-body {
  font-size: 0.95rem;
  line-height: 1.85;
}

.timeline-body p {
  margin: 0 0 0.75em;
  text-wrap: pretty;
}

.timeline-body p:last-child {
  margin-bottom: 0;
}

.timeline-media {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.5rem;
}

/* 画像が 1 枚のときは横いっぱいに引き伸ばさない */
.timeline-media:has(a:only-child) {
  grid-template-columns: minmax(0, 320px);
}

.timeline-media a {
  display: block;
}

.timeline-media img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--color-line);
}

/* ===== 「まだありません」表示用（一覧が空のとき） ===== */
.empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--color-muted);
  font-style: italic;
}
