/* =====================================================
   article.css
   記事ページ固有スタイル
   よかぺんらい - yokapenrai.com
   ===================================================== */

/* -----------------------------------
   記事ヒーロー（ヘッダー部）
----------------------------------- */
.article-hero {
  background: linear-gradient(160deg, var(--purple-deep) 0%, var(--purple-mid) 55%, var(--purple-light) 100%);
  padding: clamp(3rem, 8vw, 5rem) var(--content-padding) clamp(2.5rem, 6vw, 4rem);
  position: relative;
  overflow: hidden;
}

.article-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 40% at 90% 20%, rgba(212, 160, 23, 0.12) 0%, transparent 60%),
    radial-gradient(ellipse 40% 60% at 10% 80%, rgba(212, 160, 23, 0.07) 0%, transparent 50%);
  pointer-events: none;
}

.article-hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(212, 160, 23, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(212, 160, 23, 0.06) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
}

.article-hero-inner {
  position: relative;
  z-index: 1;
  max-width: var(--max-width);
  margin: 0 auto;
}

/* カテゴリ・タグ行 */
.article-meta-top {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1.2rem;
  flex-wrap: wrap;
}

.category-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--gold-bright);
  color: var(--purple-deep);
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.25rem 0.7rem;
  border-radius: 2px;
  text-decoration: none;
}

.tag-badge {
  display: inline-block;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.72rem;
  padding: 0.2rem 0.6rem;
  border-radius: 2px;
  text-decoration: none;
  transition: background 0.2s;
}

#article-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.tag-badge:hover {
  background: rgba(255, 255, 255, 0.18);
}

/* バージョンラベルバッジ（サム版/ロウ版） */
.version-label-badge {
  display: inline-block;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.7rem;
  border-radius: 2px;
  letter-spacing: 0.04em;
}

/* タイトル */
.article-title {
  font-family: var(--font-serif);
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 700;
  color: #ffffff;
  line-height: 1.4;
  letter-spacing: 0.02em;
  margin-bottom: 1.2rem;
}

@media (max-width: 600px) {
  .article-title { font-size: 1.5rem; }
}

/* タイトル絵文字（h1内、title-mainの前） */
.title-emoji {
  display: inline;
  margin-right: 0.3rem;
}

/* サブタイトル（h1内、article-title-mainの下に表示） */
.article-subtitle {
  display: block;
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.85);
  line-height: 1.5;
  letter-spacing: 0.02em;
  margin-top: 0.6rem;
}

@media (max-width: 600px) {
  .article-subtitle { font-size: 1.05rem; }
}

/* リード文 */
.article-lead {
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.82);
  line-height: 1.8;
  margin-bottom: 1.6rem;
  max-width: 620px;
}

/* 著者・日時行 */
.article-meta-bottom {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.author-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.author-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--gold-bright);
  overflow: hidden;
  background: var(--purple-pale);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: var(--purple-deep);
  font-weight: 700;
}

.author-name {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.9);
  font-weight: 500;
}

.meta-sep {
  color: rgba(255, 255, 255, 0.3);
  font-size: 0.75rem;
}

.article-date {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.6);
  font-family: var(--font-thai);
  letter-spacing: 0.03em;
}

.reading-time {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.55);
}

/* -----------------------------------
   記事レイアウト（本文＋サイドバー）
----------------------------------- */
.article-layout {
  max-width: 1100px;
  margin: 0 auto;
  padding: 3rem var(--content-padding) 5rem;
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 3rem;
  align-items: start;
}

@media (max-width: 880px) {
  .article-layout {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
  .article-sidebar { order: 1; }
}

/* -----------------------------------
   記事本文カード
----------------------------------- */
.article-body {
  background: var(--bg-card);
  border-radius: 4px;
  border: 1px solid var(--border);
  box-shadow: 0 2px 20px var(--shadow);
  padding: clamp(1.5rem, 4vw, 2.5rem);
  animation: fadeUp 0.5s ease both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* -----------------------------------
   目次（TOC）
----------------------------------- */
.toc {
  background: var(--purple-pale);
  border-left: 3px solid var(--purple-mid);
  border-radius: 0 4px 4px 0;
  padding: 1.2rem 1.4rem;
  margin-bottom: 2.5rem;
}

.toc-title {
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--purple-mid);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 0.7rem;
}

.toc-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.toc-list li a {
  font-size: 0.88rem;
  color: var(--purple-mid);
  text-decoration: none;
  transition: color 0.2s;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.toc-list li a::before {
  content: '・';
  color: var(--gold-warm);
  font-size: 1rem;
  flex-shrink: 0;
}

.toc-list li a:hover {
  color: var(--purple-deep);
  text-decoration: underline;
}

.toc-list .toc-h3 { padding-left: 1.2rem; }
.toc-list .toc-h3 a::before { content: '−'; font-size: 0.8rem; }

/* -----------------------------------
   本文（prose）
----------------------------------- */
.prose h2 {
  font-family: var(--font-serif);
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--purple-deep);
  margin: 2.5rem 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--gold-bright);
}

.prose h3 {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--purple-mid);
  margin: 2rem 0 0.8rem;
  padding-left: 0.8rem;
  border-left: 3px solid var(--gold-bright);
}

.prose h4 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 1.5rem 0 0.5rem;
}

.prose p {
  margin-bottom: 1.3rem;
  font-size: 1rem;
  color: var(--text-body);
}

.prose a {
  color: var(--purple-mid);
  text-decoration: underline;
  text-decoration-color: var(--gold-warm);
  text-underline-offset: 3px;
  transition: color 0.2s;
}

.prose a:hover { color: var(--purple-deep); }

.prose strong { color: var(--purple-deep); font-weight: 700; }

.prose em { font-style: italic; color: var(--text-muted); }

.prose ul,
.prose ol {
  padding-left: 1.5rem;
  margin-bottom: 1.3rem;
}

.prose li {
  margin-bottom: 0.4rem;
  font-size: 1rem;
}

.prose ul li::marker { color: var(--gold-warm); }

.prose blockquote {
  background: var(--gold-pale);
  border-left: 4px solid var(--gold-bright);
  border-radius: 0 4px 4px 0;
  padding: 1rem 1.4rem;
  margin: 1.5rem 0;
  font-style: italic;
  color: var(--text-muted);
}

.prose blockquote p { margin-bottom: 0; }

.prose pre {
  background: var(--purple-deep);
  border-radius: 4px;
  padding: 1.2rem 1.4rem;
  overflow-x: auto;
  margin: 1.5rem 0;
}

.prose pre code {
  font-family: 'Courier New', monospace;
  font-size: 0.88rem;
  color: var(--gold-line);
  background: none;
  padding: 0;
}

.prose code {
  background: var(--purple-pale);
  color: var(--purple-mid);
  font-size: 0.88em;
  padding: 0.15em 0.4em;
  border-radius: 3px;
  font-family: 'Courier New', monospace;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.92rem;
}

.prose th {
  background: var(--purple-deep);
  color: var(--gold-bright);
  font-weight: 700;
  padding: 0.6rem 1rem;
  text-align: left;
  letter-spacing: 0.04em;
}

.prose td {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-body);
}

.prose tr:nth-child(even) td { background: var(--purple-pale); }

.prose img {
  width: 100%;
  border-radius: 4px;
  margin: 1.5rem 0;
  border: 1px solid var(--border);
}

.prose figure { margin: 1.5rem 0; }

.prose figcaption {
  font-size: 0.8rem;
  color: var(--text-light);
  text-align: center;
  margin-top: 0.5rem;
}

.prose hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

/* Info Box */
.info-box {
  background: var(--purple-pale);
  border: 1px solid rgba(92, 45, 155, 0.2);
  border-radius: 4px;
  padding: 1.1rem 1.4rem;
  margin: 1.5rem 0;
  font-size: 0.92rem;
}

.info-box-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--purple-mid);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.4rem;
}

/* 埋め込み（YouTube等） */
.embed-wrapper {
  position: relative;
  width: 100%;
  margin: 1.5rem 0;
  border-radius: 4px;
  overflow: hidden;
}

.embed-wrapper.ratio-16x9 { aspect-ratio: 16 / 9; }
.embed-wrapper.ratio-4x3  { aspect-ratio: 4 / 3; }
.embed-wrapper.ratio-1x1  { aspect-ratio: 1 / 1; }

.embed-wrapper iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* -----------------------------------
   記事フッター（タグ・シェアボタン）
----------------------------------- */
.article-footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.tag-link {
  display: inline-block;
  background: var(--purple-pale);
  color: var(--purple-mid);
  font-size: 0.78rem;
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  text-decoration: none;
  border: 1px solid rgba(92, 45, 155, 0.2);
  transition: background 0.2s, color 0.2s;
}

.tag-link:hover {
  background: var(--purple-mid);
  color: #fff;
}

.share-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.share-label {
  font-size: 0.78rem;
  color: var(--text-light);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.9rem;
  border-radius: 3px;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  transition: opacity 0.2s;
}

.share-btn:hover { opacity: 0.8; }
.share-btn.x    { background: #000; color: #fff; }
.share-btn.line { background: #06C755; color: #fff; }

/* -----------------------------------
   前後記事ナビ
----------------------------------- */
.article-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 2rem;
}

@media (max-width: 540px) {
  .article-nav { grid-template-columns: 1fr; }
}

.article-nav-link {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 1rem 1.2rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  text-decoration: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.article-nav-link:hover {
  border-color: var(--purple-light);
  box-shadow: 0 2px 12px var(--shadow-hover);
}

.article-nav-link.prev { text-align: left; }
.article-nav-link.next { text-align: right; }

.nav-direction {
  font-size: 0.72rem;
  color: var(--text-light);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav-title {
  font-family: var(--font-serif);
  font-size: 0.92rem;
  color: var(--purple-deep);
  line-height: 1.4;
}

/* -----------------------------------
   サイドバー
----------------------------------- */
.article-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  position: sticky;
  top: 76px;
}

.sidebar-widget {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 2px 12px var(--shadow);
  overflow: hidden;
}

.widget-header {
  background: var(--purple-deep);
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.widget-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--gold-bright);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.widget-body { padding: 1rem; }

.profile-widget-body {
  padding: 1.2rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.7rem;
}

.profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 3px solid var(--gold-bright);
  background: var(--purple-pale);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  overflow: hidden;
}

/* profile-avatar内のimgスタイル（article-diff.cssより移管） */
.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.profile-name {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 700;
  color: var(--purple-deep);
}

.profile-bio {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.7;
  text-align: left;
}

.category-list {
  list-style: none;
  display: flex;
  flex-direction: column;
}

.category-list li a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 1rem;
  font-size: 0.88rem;
  color: var(--text-body);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s, color 0.15s;
}

.category-list li:last-child a { border-bottom: none; }

.category-list li a:hover {
  background: var(--purple-pale);
  color: var(--purple-mid);
}

.category-count {
  font-size: 0.75rem;
  color: var(--text-light);
  background: var(--border);
  padding: 0.1rem 0.45rem;
  border-radius: 10px;
}

.related-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.related-list li a {
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
  font-size: 0.85rem;
  color: var(--text-body);
  text-decoration: none;
  line-height: 1.45;
  transition: color 0.2s;
}

.related-list li a::before {
  content: '・';
  color: var(--gold-warm);
  flex-shrink: 0;
  font-size: 1rem;
}

.related-list li a:hover { color: var(--purple-mid); }

/* -----------------------------------
   チャット会話ブロック（記事内Claude会話ログ）
----------------------------------- */
/* チャット会話ブロック全体のラッパー */
.chat-block {
  margin: 1.8rem 0;
  padding: 1.2rem;
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* 各発話行 */
.chat-row {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  max-width: 100%;
}

/* 自分（ぺんらい）：右寄せ */
.chat-row.me {
  flex-direction: row-reverse;
  margin-left: 15%;
}

/* Claude：左寄せ */
.chat-row.claude {
  margin-right: 15%;
}

/* アバター（イニシャル円形） */
.chat-avatar {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  font-family: var(--font-sans);
}

.chat-row.me .chat-avatar {
  background: var(--purple-mid);
  color: #fff;
}

.chat-row.claude .chat-avatar {
  background: var(--gold-bright);
  color: var(--purple-deep);
}

/* 吹き出し本体 */
.chat-bubble {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
}

/* 発話者名 */
.chat-name {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-light);
  letter-spacing: 0.04em;
}

.chat-row.me .chat-name { text-align: right; }

/* 吹き出し本文 */
.chat-text {
  font-size: 0.92rem;
  line-height: 1.75;
  padding: 0.65rem 1rem;
  border-radius: 12px;
  position: relative;
  word-break: break-word;
}

.chat-text p {
  margin-bottom: 0.4rem;
}
.chat-text p:last-child {
  margin-bottom: 0;
}

/* 自分：紫系の吹き出し（右上を角丸なしに） */
.chat-row.me .chat-text {
  background: var(--purple-pale);
  color: var(--text-body);
  border-top-right-radius: 4px;
}

/* Claude：ゴールド系の吹き出し（左上を角丸なしに） */
.chat-row.claude .chat-text {
  background: var(--gold-pale);
  color: var(--text-body);
  border-top-left-radius: 4px;
}

/* 吹き出し内のコードの見た目を本文よりやや小さめに */
.chat-text code {
  font-size: 0.85em;
}

/* レスポンシブ：スマホでは左右マージンを縮める＆grid化 */
@media (max-width: 640px) {
  .chat-row.me { margin-left: 5%; }
  .chat-row.claude { margin-right: 5%; }

  /* チャット行をgrid化：1行目＝アバター＋名前（2カラム）、2行目＝本文（全幅1カラム） */
  .chat-row {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 0.3rem 0.5rem;
  }

  .chat-row.me {
    flex-direction: unset;
    grid-template-columns: 1fr auto;
  }

  .chat-avatar {
    grid-row: 1;
    grid-column: 1;
  }

  .chat-bubble {
    display: contents;
  }

  .chat-name {
    grid-row: 1;
    grid-column: 2;
  }

  .chat-row.me .chat-name {
    grid-column: 1;
    text-align: right;
  }

  .chat-row.me .chat-avatar {
    grid-column: 2;
  }

  .chat-text {
    grid-row: 2;
    grid-column: 1 / -1;
  }
}
