/*-- リセット ----------------------------------------------------------------------------------------*/
*:not(blockquote):not(blockquote *) {
  margin: 0;
  gap: 0;
}

/*-- 変数定義 ----------------------------------------------------------------------------------------*/
:root {
  --site-color: #f7b946;
  --post-icon: "✒️";
  --category-icon: "📖";
  --tag-icon: "🔖";
  --point-icon: "📍";
  --pointer-icon: "👉";
  --header-content-height: 1.5rem;
  --header-padding: 0.5rem;
  --header-height: calc(var(--header-content-height) + var(--header-padding) * 2);
  --aside-padding: 1rem;
  --content-padding: 1rem;
  --post-content-margin: 1rem;
  --post-content-width-cut: calc(var(--post-content-margin) * 2 + 1rem);
  --debug-display: none; /* デバッグ画面 表示:block/非表示:none */
}

/*-- 頁全体定義 --------------------------------------------------------------------------------------*/
body {
  font-family: sans-serif;
  background-color: #f5f5f5;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto 1fr auto;
  grid-template-areas: 
    "header header"
    "aside main"
    "aside footer";
  overflow: auto;
}

h1, h2 {
  border-left: solid 8px var(--site-color);
  background: var(--site-color);
  margin-bottom: 3px;
  padding: 0.5em;
  box-shadow: 5px 5px 10px rgba(0,0,0,0.3);
  border-radius: 5px;
}

button {
  background-color: #fae6c2;
  font-weight: bold;
  font-size: 1.25rem !important;
  color: black;
  padding: 0.5rem 1rem;
  border: 2px solid var(--site-color);
  box-shadow: 5px 5px 10px rgba(0,0,0,0.3);
  border-radius: 10px;
  cursor: pointer;
  margin-top: 1rem !important;
  margin-bottom: 1rem !important;
}
button:hover {
  background-color: var(--site-color);
}

/* 入力エレメントの文字サイズを本体に合わせる */
button, input, select, textarea {
  font-family : inherit;
  font-size   : 100%;
}

/* 単語が長すぎる場合、単語内でも折り返し可能とする */
li, div, th, td, p, span, a, h1, h2, h3, h4, h5 {
  overflow-wrap: break-word;
  word-break: break-word; /* Safari が overflow-wrap を完全にサポートしていないための対応 */
}
/* 通常の pre（文章用） */
/*
pre:not([class*="language-"]) {
  white-space: pre-wrap;
  overflow-wrap: break-word;
}
*/

.indented {
  margin-left: 1em;
}

/* アイコンの大きさ定義 */
.icon {
  width: 1.5rem;
  height: 1.5rem;
}

/* ボーダーライン定義 */
.separate-line {
  border-top: 1px solid gray;
  border-bottom: 1px solid gray;
  margin: 2rem 0;
  height: 3px;
}

/*
blockquote {
  margin-left: 1.2rem !important;
  padding-left: 0.8rem !important;
  border-left: 4px solid #ccc !important;
}

blockquote p {
  margin: 0.5rem 0 !important;
}
*/

pre, pre code, pre.line-numbers {
  -webkit-text-size-adjust: none !important;
}

a {
  font-weight: bold;
  text-decoration: none;
  display:inline-block;
}

/*-- ヘッダー定義 ------------------------------------------------------------------------------------*/
header {
  grid-area: header;
  position: sticky;
  top: 0;
  background-color: var(--site-color);
  border-top-left-radius: 0.5rem;
  border-top-right-radius: 0.5rem;
  padding: var(--header-padding);
  z-index: 1000;
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 5px 5px 10px rgba(0,0,0,0.3);
  border-radius: 5px;
}

/* サイドバー開閉ボタン定義 */
#toggleSidebar {
  width: 1rem;
  height: 1rem;
  position: relative;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.4s ease;
}
#toggleSidebar span {
  display: block;
  height: 3px;
  background: #333;
  border-radius: 2px;
  transition: transform 0.4s ease, opacity 0.3s ease;
}
/* 開いた状態（×） */
#toggleSidebar.open span:nth-child(1) {
  transform: translateY(0.4rem) rotate(45deg);
  background: #fff;
}
#toggleSidebar.open span:nth-child(2) {
  opacity: 0;
}
#toggleSidebar.open span:nth-child(3) {
  transform: translateY(-0.4rem) rotate(-45deg);
  background: #fff;
}
#toggleSidebar.open {
  transform: rotate(360deg) scale(0.9);
}
#toggleSidebar.open:hover {
  animation: pulse 1s linear infinite;
}
@keyframes spin {
  to { transform: rotate(45deg); }
}
@keyframes pulse {
  0% {
	  transform: scale(1);
	}
  25% {
	  transform: scale(1.05);
	}
	50% {
	  transform: scale(1) ;
	}
	50% {
	  transform: scale(0.95);
	}
	100% {
	  transform: scale(1) ;
	}
}
#toggleSidebar:hover {
  animation: pulse 1s linear infinite;
}

/* サイトタイトル定義 */
#site-title {
  display: flex;
  flex-direction: row;
  font-weight: bold;
  color: black;
}

/* ナビ定義 */
nav {
  display: flex;
  align-items: center;
  justify-content: space-evenly;
}

/* スクロール page-progress 定義 */
.scroll-progress {
  display:none;
}
@supports (animation-timeline: scroll()) {
  /* 対応ブラウザだけ page-progress 定義追加 */
  @keyframes page-progress{
    from { scale: 0 1; }
    to { scale: 1 1;}
  }
  .scroll-progress {
    display:block;
    position: fixed;
    /*top: var(--header-height);*/
    /*top: calc(var(--header-height) - 0.25rem);*/
    top: 0;
    left: 0;
    /*z-index: 997;*/
    z-index: 1001;
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 5px;
    height: 0.25rem;
    transform-origin: left;
    animation: page-progress linear;
    animation-timeline: scroll();
  }
}

/*-- サイドバー定義 -----------------------------------------------------------------------------------*/
aside {
  grid-area: aside;
  position: fixed;
  top: var(--header-height);
  height: calc(100vh - var(--header-height) - var(--aside-padding) * 2);
  background-color: var(--site-color);
  border-bottom-left-radius: 0.5rem;
  border-bottom-right-radius: 0.5rem;
  overflow: auto;
  box-shadow: 5px 5px 10px rgba(0,0,0,0.3);
  border-radius: 5px;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  z-index:1000;
  padding: var(--aside-padding);
  opacity: 0.9;
}
aside.open {
  transform: translateX(0);
}

aside section div{
  display: grid;
  grid-template-columns: 2rem 1fr 2rem;
  justify-items: start;
}

.side-sec-title {
  font-weight: bold;
}
.side-sec-title:hover {
  cursor: pointer;
  animation: pulse 1s linear infinite;
}
.toggle-detail {
  cursor: pointer;
  display: inline-block;
  transform: rotate(-90deg);
  transition: transform 0.4s ease;
}
.toggle-detail.open {
  transform: rotate(0deg);
}

aside section ul {
  overflow: hidden;
  height: 0;
  width: 0;
  transition: height 0.4s ease;
  interpolate-size: allow;
}
aside section ul.open {
  height: auto;
  width: auto;
}

.post-ul-style {
  list-style: none;
  padding-left: 1rem;
}
.post-ul-style li {
  position: relative;
  padding-left: 1.6rem;
}
.post-ul-style li::before {
  content: var(--post-icon);
  position: absolute;
  left: 0;
  top: 0.15rem; /* 微調整 */
  font-size: 0.9rem;
}

.category-ul-style {
  list-style: none;
  padding-left: 1rem;
}
.category-ul-style li {
  position: relative;
  padding-left: 1.6rem;
}
.category-ul-style li::before {
  content: var(--category-icon);
  position: absolute;
  left: 0;
  top: 0.15rem; /* 微調整 */
  font-size: 0.9rem;
}

.tag-ul-style {
  list-style: none;
  padding-left: 1rem;
}
.tag-ul-style li {
  position: relative;
  padding-left: 1.6rem;
}
.tag-ul-style li::before {
  content: var(--tag-icon);
  position: absolute;
  left: 0;
  top: 0.15rem; /* 微調整 */
  font-size: 0.9rem;
}

.point-ul-style {
  list-style: none;
  padding-left: 1rem;
}
.point-ul-style li {
  position: relative;
  padding-left: 1.6rem;
}
.point-ul-style li::before {
  content: var(--point-icon);
  position: absolute;
  left: 0;
  top: 0.15rem; /* 微調整 */
  font-size: 0.9rem;
}

.pointer-ul-style {
  list-style: none;
  padding-left: 1rem;
}
.pointer-ul-style li {
  position: relative;
  padding-left: 1.6rem;
}
.pointer-ul-style li::before {
  content: var(--pointer-icon);
  position: absolute;
  left: 0;
  top: 0.15rem; /* 微調整 */
  font-size: 0.9rem;
}

/*-- 背景の暗い幕（オーバーレイ） ---------------------------------------------------------------------*/
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.5); /* 黒の半透明 */
  z-index: 999; /* サイドバーのすぐ後ろ */
  
  /* 初期状態は非表示（クリックも透過） */
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* 開いたときのクラス */
.overlay.open {
  opacity: 1;
  visibility: visible;
}

/*-- メイン定義 -------------------------------------------------------------------------------------*/
main {
  grid-area: main;
}

#content {
  padding: var(--content-padding);
  background-color: white;
  box-shadow: 5px 5px 10px rgba(0,0,0,0.3);
  border-radius: 5px;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.post-list {
  height: 9rem;
  overflow-y: hidden;
  scrollbar-gutter: stable;
}
.post-list:hover {
  overflow-x: hidden;
  overflow-y: auto;
}

.tag-list {
  display: flex;
  gap: 0.5rem;
  height: 9rem;
  flex-wrap: wrap;
  overflow-y: hidden;
  scrollbar-gutter: stable;
}
.tag-list:hover {
  overflow-x: hidden;
  overflow-y: auto;
}
.tag-list a {
  padding: 1px;          /* 内側の余白 */
  color: #333;            /* 文字色 */
  text-decoration: none;  /* 下線を消す */
  background-color: #fae6c2; /* 背景色 */
  border: 1px solid var(--site-color);
  border-bottom: 1px solid rgba(0,0,0,0.3); /* 下に線を引く */
  border-radius: 5px;
}
.tag-list a:hover {
  text-decoration: none;  /* 下線を消す */
  background-color: var(--site-color); /* ホバー時の背景色 */
  color: #000;            /* ホバー時の文字色 */
}

/*-- フッター定義 -----------------------------------------------------------------------------------*/
footer {
  grid-area: footer;
  text-align: center;
  padding: 1rem;
  background-color: var(--site-color);
  box-shadow: 5px 5px 10px rgba(0,0,0,0.3);
  border-radius: 5px;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: repeat(auto-fill);
  row-gap: 0.5rem;
}

#footer-nav {
  display: flex;
  justify-content: center;
  gap: 2rem;
  padding-bottom: 1rem;
}

#important {
  display: flex;
  justify-content: center;
  gap: 2rem;
}

#footer-info {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
}

/*-- index 頁専用定義 -------------------------------------------------------------------------------*/
#board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  column-gap: 1.5rem;
  row-gap: 1.5rem;
  max-width: calc(100vw - var(--content-padding) * 2);
}

.chip {
  background-color: white;
  padding: 1rem;
  border: 1px solid #ddd;
  box-shadow: 5px 5px 10px rgba(0,0,0,0.3);
  border-radius: 5px;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto auto auto 1fr auto;
  row-gap: 1rem;
}

@supports (animation-timeline: view()) {
  /* 対応ブラウザだけ .chip に fade-in annimation 定義追加 */
  @keyframes fade-in {
    from {
      opacity: 0;
      translate: 0 3rem;
      scale: 0.5;
    }
    to {
      opacity: 1;
      translate: 0;
      scale: 1;
    }
  }
  .chip {
    animation: fade-in linear both;
    animation-timeline: view();
    animation-range: entry 0% cover 35%;
  }
}

.chip-image {
  width: 100%;
  height: auto;
  box-shadow: 5px 5px 10px rgba(0,0,0,0.3);
  border-radius: 5px;
  aspect-ratio: 2/1;
}

.chip-msg {
  width: 90%;
  justify-self: center;
}

#site-images {
  position: relative;
}

#title-image {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80%;
}

/*-- 一覧頁専用定義 ---------------------------------------------------------------------------------*/
/*
.tag-image {
  width: 100%;
  height: auto;
  box-shadow: 5px 5px 10px rgba(0,0,0,0.3);
  border-radius: 5px;
  aspect-ratio: 2/1;
}
.category-image {
  width: 100%;
  height: auto;
  box-shadow: 5px 5px 10px rgba(0,0,0,0.3);
  border-radius: 5px;
  aspect-ratio: 2/1;
}
.post-image {
  width: 100%;
  height: auto;
  box-shadow: 5px 5px 10px rgba(0,0,0,0.3);
  border-radius: 5px;
  aspect-ratio: 2/1;
}
.contact-image {
  width: 100%;
  height: auto;
  box-shadow: 5px 5px 10px rgba(0,0,0,0.3);
  border-radius: 5px;
  aspect-ratio: 2/1;
}
*/

/*-- 記事頁専用定義 ---------------------------------------------------------------------------------*/
.post-dates {
  text-align: right;
  margin-right: 1rem;
}

.post-content {
  line-height: 2.5;
  max-width: calc(100vw - var(--content-padding) * 2 - var(--post-content-width-cut));
  margin-right: var(--post-content-margin);
  margin-left: var(--post-content-margin);
}

.post-content > *:not(h1):not(h2):not(blockquote):not(blockquote *) {
  margin-right: 1rem;
  margin-left: 1rem;
}

.post-content h1, .post-content h2, .post-content table {
  line-height: 1.5;
  margin-top: 1rem;
  margin-bottom: 1rem;
}
.post-content pre {
  box-shadow: 5px 5px 10px rgba(0,0,0,0.3);
  border-radius: 5px;
}
.post-content pre:not([class*="language-"]) {
  background: #2d2d2d;
  color: #ccc;
  line-height: 1.2;
  padding: 1rem;
  overflow: auto;
  font-size: 1rem;
  font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
  max-width: fit-content;
}

/* 記事内テーブル定義 */
.post-content table {
  margin-top: 1rem;
  margin-bottom: 1rem;
}
.post-content table, .post-content table tr, .post-content table th, .post-content table td {
  border: 1px solid black;
  border-collapse: collapse;
}
.post-content table th {
  background-color: skyblue;
}
.post-content img {
  /*width: 100%;*/
  max-width: 100%;
  height: auto;
  box-shadow: 5px 5px 10px rgba(0,0,0,0.3);
  border-radius: 5px;
  /*aspect-ratio: 2/1;*/
  background-color: #2d2d2d;
  object-fit: scale-down;
}

/*
.post-license {
  text-align: center;
  font-size: 0.9rem;
  color: #777;
  margin-top: 1rem;
}
*/
.post-license {
  /*margin: 2.5rem 0 1.5rem;*/
  margin: 1rem 0 0 0;
  padding: 1rem 1.2rem;
  background: #fff8e6;        /* きつね色の淡い背景（柔らかい雰囲気） */
  border-left: 4px solid #f7b946; /* きつね色の濃いアクセント（ブランドカラー） */
  font-size: 0.9rem;
  color: #5a4a3a;             /* きつね色と相性の良い落ち着いたブラウン */
  border-radius: 6px;
}

/* 記事遷移ナビ定義 */
.post-nav {
  text-align: center;
  padding: 1rem;
  margin-top: 2rem;
  color: #777;
}
.post-nav a {
  margin: 1rem;
}

/* ポップアップ画面定義 */
.popup-wrapper {
  display: flex;
  position: fixed;
  top: var(--header-height);
  left: 0;
  width: 100vw;
  height: calc(100vh - var(--header-height));
  background-color: rgba(0, 0, 0, 0.5);
  justify-content: center;
  align-items: center;
  z-index: 998;

  /* 初期状態は非表示（クリックも透過） */
  opacity: 0;
  visibility: hidden;
  /*transition: opacity 0.3s ease, visibility 0.3s ease;*/
}
/* 開いたときのクラス */
.popup-wrapper.open {
  opacity: 1;
  visibility: visible;
}

@keyframes floatUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
.popup-content {
  background-color: #fff;
  padding: 1rem;
  border-radius: 5px;
  text-align: center;
  width: 70%;
  height: 70%;
  opacity: 0;
  display: flex;
  flex-direction: column;
}
/* 開いたときにアニメーションを付ける */
.popup-wrapper.open .popup-content {
  animation: floatUp 0.5s forwards;
}

#popup-iframe {
  width: 100%;
  height: 100%;
  box-shadow: 5px 5px 10px rgba(0,0,0,0.3);
  border-radius: 5px;
}

/* ASCII画像のSVG化に伴うオリジナルASCII画像の表示・非表示定義 */
figure figcaption {
  display: none; /* 表示:block / 非表示：none */
}

/*-- メディア毎の専用定義 ---------------------------------------------------------------------------*/
/* hover が不可能なデバイスだけに適用 */
@media (hover: none) and (pointer: coarse) {
  .tag-list, .post-list {
    overflow-y: auto;
  }
}

/* hover が可能なデバイスだけに適用 */
@media (hover: hover) and (pointer: fine) {
  /* マウスを乗せた時アニメーションする */
  a:hover {
    animation: pulse 1s linear infinite;
  }
}

/* 縦方向に短いメディア（例：古いPC、スマホ横画面など）だけに適用 */
@media (max-height: 768px) {
  .popup-content {
    height: 94%;
  }
}

/*-- 横方向に短いメディア（例：スマホ縦画面など）だけに適用 */
@media (max-width: 480px) {
  :root {
    --header-padding: 1.5rem;
  }
  body {
    font-size: small;
  }
  header nav, #important, #footer-info .separator {
    display: none;
  }
  #footer-info {
    flex-direction: column;
  }
  .post-content {
    line-height: 1.5;
    max-width: calc(100vw - var(--content-padding) * 2);
    margin-right: 0;
    margin-left: 0;
  }
  .popup-content {
    width: 80%;
  }
  .post-content pre {
    font-size: 1em;
  }
}

/*-- デバッグ情報専用定義 ---------------------------------------------------------------------------*/
#debugPanel {
  display: var(--debug-display);
  position: fixed;
  /*top: var(--header-height);*/
  top: 0;
  left: 0;
  z-index: 999999;
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  font-size: 12px;
  white-space: pre-wrap;
  pointer-events: none;
}