/* Terminal テーマの上書き用。テーマ本体は触らない。
   見た目は https://panr.github.io/terminal-css/ のデモサイトに合わせている。
   テーマの既定値（themes/terminal/assets/css/main.css）:
     --background: #1a170f   暗い茶色
     --foreground: #eceae5   本文の文字色
     --accent:     #eec35e   見出し・リンク・カーソルの色（アンバー）
   デモサイトの配色も同じ値。キーカラー(--accent)だけ淡いグリーンに変えている。
   変えたい行だけコメントを外して値を書き換える。
   配色は https://panr.github.io/terminal-css/ で見ながら作れる。 */
:root {
  /* --background: #1a170f; */
  /* --foreground: #eceae5; */
  --accent: #7ef29d; /* 淡いグリーン（テーマ既定は #eec35e のアンバー） */
}

/* --- 幅・余白: 最大幅は固定し、広い画面では中央に寄せる。余白はデモの body の padding:20px と同じ --- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  border-right: none; /* テーマ既定は右側に薄い縦線 */
}

/* --- ロゴ: キーカラー(--accent)の塗り + 白文字 --- */
.logo {
  background: var(--accent);
  color: #fff;
}

.header__logo::after {
  margin-left: 20px;
  background: repeating-linear-gradient(
    90deg, var(--accent), var(--accent) 2px, transparent 0, transparent 8px
  );
}

/* 本文中の画像（/uploads/ 直置き含む）が画面幅を超えないようにする */
.post-content img,
.post-content figure img {
  max-width: 100%;
  height: auto;
}

/* --- 記事の目次 --- */
.table-of-contents {
  margin: 20px 0;
  padding: 10px 20px;
  border: 1px solid var(--accent);
}

.table-of-contents h2 {
  margin: 0 0 10px;
  font-size: 1rem;
}

/* 入れ子: 階層ごとにインデントする。ul の margin はテーマの 4ch を詰めて 2ch にする */
.table-of-contents ul {
  margin: 0 0 0 2ch;
}

.table-of-contents > nav > ul,
.table-of-contents #TableOfContents > ul {
  margin-left: 0;
}

.table-of-contents li {
  margin: 2px 0;
}

/* 先頭の見出しが # でないとき、Hugo は空の階層を 1 つ作る。印とインデントを消して詰める */
.table-of-contents #TableOfContents > ul > li:not(:has(> a)) {
  list-style: none;
}

.table-of-contents #TableOfContents > ul > li:not(:has(> a)) > ul {
  margin-left: 0;
}

/* 広い画面では記事を 2 カラムにし、目次を右側に固定表示（スクロールについてくる） */
@media (min-width: 1100px) {
  .post:has(> .table-of-contents) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 260px;
    column-gap: 40px;
    align-items: start;
  }

  .post:has(> .table-of-contents) > * {
    grid-column: 1;
  }

  .post:has(> .table-of-contents) > .table-of-contents {
    grid-column: 2;
    grid-row: 1 / span 20;
    position: sticky;
    top: 20px;
    margin: 0;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    font-size: 0.9rem;
  }
}

/* --- 検索ページ(Pagefind UI)をテーマの配色に合わせる --- */
#search {
  --pagefind-ui-primary: var(--accent);
  --pagefind-ui-text: var(--foreground);
  --pagefind-ui-background: var(--background);
  --pagefind-ui-border: var(--accent);
  --pagefind-ui-tag: var(--background);
  --pagefind-ui-font: inherit;
  --pagefind-ui-border-radius: 0;
}

/* ヒットした語は黄色の蛍光ペン風にする（検索結果・記事内の両方） */
#search mark,
.post-content mark.pagefind-highlight {
  background: #ffe14d;
  color: #1a170f;
  padding: 0 2px;
}

/* --- トップページ: 広い画面では右側にカテゴリ・タグ・PR のサイドエリア（記事の目次と同じ見た目） --- */
.home-side {
  display: none;
}

@media (min-width: 1100px) {
  .home {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 260px;
    column-gap: 40px;
    align-items: start;
  }

  .home-side {
    display: block;
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    padding: 10px 20px;
    border: 1px solid var(--accent);
    font-size: 0.9rem;
  }

  .home-side-section + .home-side-section {
    margin-top: 20px;
  }

  .home-side h2 {
    margin: 0 0 10px;
    font-size: 1rem;
  }

  .home-side ul {
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .home-side li {
    margin: 2px 0;
  }

  /* タグは折り返して横に並べる */
  .home-side-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 12px;
  }

  .home-side-count {
    opacity: 0.6;
  }

  .home-side-promo p {
    margin: 0;
  }
}

/* --- ヘッダー: 上スクロール時だけ表示する（下スクロールで隠れる） --- */
.header {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 10px 0;
  background: var(--background);
  transition: transform 0.2s ease;
}

.header--hidden {
  transform: translateY(-100%);
}
