/* ================================================================
   CRISIS Support Center — Article Page
   ================================================================ */

/* ─── Layout ─── */
.article-layout {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 64px;
  padding: 48px 0 80px;
}

/* ─── Article Header ─── */
.article-header {
  margin-bottom: 40px;
}

.article-category {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: var(--radius-lg);
  border: 1px solid color-mix(in oklch, currentColor 22%, transparent);
  box-shadow: var(--inset-shadow-xs);
  background-image: linear-gradient(to bottom, oklch(1 0 0 / 0.6), transparent);
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 16px;
}

.article-title {
  font-family: var(--font-display);
  font-size: 28px;
  line-height: 1.35;
  letter-spacing: -0.02em;
  font-weight: 700;
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  margin-top: 16px;
  font-size: 13px;
  color: var(--muted);
}

.article-meta-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.article-meta-item svg {
  opacity: 0.5;
}

/* ─── Article Body ─── */
.article-body > * + * {
  margin-top: 24px;
}

.article-body h2 {
  font-family: var(--font-display);
  font-size: 20px;
  line-height: 1.35;
  letter-spacing: -0.015em;
  font-weight: 650;
  margin-top: 48px;
  padding-top: 32px;
  scroll-margin-top: 104px;
  border-top: 1px solid var(--border);
}

.article-body h2:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.article-body h3 {
  font-size: 16px;
  line-height: 1.45;
  font-weight: 600;
  margin-top: 32px;
  scroll-margin-top: 104px;
}

.article-body p {
  font-size: 15px;
  line-height: 1.85;
  color: var(--text-secondary);
}

.article-body a {
  color: var(--brand-link);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: color-mix(in oklch, var(--brand-link) 30%, transparent);
  transition: text-decoration-color 0.15s;
}

.article-body a:hover {
  text-decoration-color: var(--brand-link);
}

/* ─── Markdown Lists ─── */
.article-body > ol {
  list-style: none;
  counter-reset: article-step;
  margin: 16px 0;
  padding: 0;
}

.article-body > ol > li {
  counter-increment: article-step;
  position: relative;
  margin-top: 10px;
  padding: 6px 0 10px 2.6em;
  font-size: 15px;
  line-height: 1.8;
  color: var(--text-secondary);
}

.article-body > ol > li:first-child {
  margin-top: 0;
}

.article-body > ol > li::before {
  content: counter(article-step);
  position: absolute;
  left: 0;
  top: 5px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: var(--brand);
}

.article-body ul {
  margin: 12px 0;
  padding-left: 1.5em;
  list-style: disc;
}

.article-body ul li {
  font-size: 15px;
  line-height: 1.85;
  color: var(--text-secondary);
}

.article-body ul li + li {
  margin-top: 8px;
}

.article-body li > ol,
.article-body li > ul {
  margin-top: 8px;
}

.article-body ol ol {
  list-style: decimal;
  margin-top: 8px;
  padding-left: 1.5em;
}

.article-body ol ol > li {
  margin-top: 6px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.article-body ol ol > li::before {
  content: none;
}

/* ─── Steps ─── */
.steps {
  counter-reset: step;
  display: flex;
  flex-direction: column;
}

.step {
  counter-increment: step;
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 16px;
  padding: 24px 0;
  border-bottom: 1px solid var(--border);
}

.step:first-child {
  padding-top: 0;
}

.step:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.step-number {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  flex: 0 0 auto;
}

.step-number::before {
  content: counter(step);
}

.step-body > * + * {
  margin-top: 12px;
}

.step-text > * + * {
  margin-top: 16px;
}

.step-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.5;
  padding-top: 4px;
}

.step-text {
  font-size: 14px;
  line-height: 1.8;
  color: var(--text-secondary);
}

/* ─── Screenshots ─── */
.screenshot {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-soft);
}

.screenshot-img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: linear-gradient(135deg, var(--stone-200) 0%, var(--stone-100) 50%, var(--stone-200) 100%);
}

/* 実画像はクロップせず元の縦横比のまま表示（16:9はプレースホルダのみ） */
img.screenshot-img {
  aspect-ratio: auto;
  height: auto;
  object-fit: unset;
  background: var(--surface-soft);
}

/* クリックで原寸大の画像を別タブで開く（キャプチャを拡大して確認できるように） */
.screenshot-link {
  display: block;
  cursor: zoom-in;
}

.screenshot-link:hover img.screenshot-img {
  opacity: 0.75;
}

.screenshot-caption {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
  background: var(--surface);
}

/* ─── Inline Code ─── */
.article-body code:not([class*="language-"]) {
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  word-break: break-word;
}

/* ─── Code Blocks ─── */
.article-body pre:not([class*="language-"]) {
  margin: 16px 0;
  padding: 16px;
  overflow: auto;
  border-radius: var(--radius-sm);
  background: #272822;
}

.article-body pre:not([class*="language-"]) code {
  display: block;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #f8f8f2;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre;
  word-break: normal;
}

/* ─── Plan Notice (プラン限定機能の注記) ─── */
.plan-notice {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 14px 20px;
  margin-bottom: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid #fde68a;
  background: #fefce8;
  font-size: 14px;
  line-height: 1.75;
  color: #713f12;
}

.plan-notice a {
  color: #854d0e;
  text-decoration: underline;
}

.plan-notice-icon {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  margin-top: 2px;
  color: #ca8a04;
}

/* ─── Callouts ─── */
.callout {
  display: flex;
  gap: 14px;
  padding: 16px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid;
  font-size: 14px;
  line-height: 1.75;
}

.callout-icon {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  margin-top: 2px;
}

.callout-body > * + * {
  margin-top: 6px;
}

.callout-title {
  font-size: 13px;
  font-weight: 600;
}

.callout-text {
  color: var(--text-secondary);
}

.callout-info {
  background: #eff6ff;
  border-color: #A3C7F5;
}
.callout-info .callout-icon {
  color: #2563eb;
}
.callout-info .callout-title {
  color: #1e40af;
}

.callout-tip {
  background: #ecfdf5;
  border-color: #A1E5C7;
}
.callout-tip .callout-icon {
  color: #059669;
}
.callout-tip .callout-title {
  color: #065f46;
}

.callout-warning {
  background: #fffbeb;
  border-color: #FCD78B;
}
.callout-warning .callout-icon {
  color: #d97706;
}
.callout-warning .callout-title {
  color: #92400e;
}

.callout-danger {
  background: #fef2f2;
  border-color: #FFB8B7;
}
.callout-danger .callout-icon {
  color: #dc2626;
}
.callout-danger .callout-title {
  color: #991b1b;
}

/* ─── Tables ─── */
.article-table-wrap,
.article-body > .article-table-wrap {
  overflow-x: auto;
}

.article-table,
.article-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  line-height: 1.6;
}

.article-table th,
.article-table td,
.article-body table th,
.article-body table td {
  padding: 10px 16px;
  border: 1px solid var(--border);
  text-align: left;
}

.article-table th,
.article-body table th {
  background: var(--surface-soft);
  font-weight: 600;
  font-size: 13px;
  color: var(--text-secondary);
}

.article-table td,
.article-body table td {
  color: var(--text-secondary);
}

.article-table td code,
.article-body table td code {
  font-size: 12px;
}

/* ─── Related Articles ─── */
.related-section {
  margin-top: 56px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}

.related-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 16px;
}

.related-list {
  display: flex;
  flex-direction: column;
}

.related-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  color: var(--text-secondary);
  transition: color 0.15s;
}

.related-item:hover {
  color: var(--brand-link);
}

.related-item-arrow {
  flex: 0 0 auto;
  font-size: 14px;
  color: var(--muted);
  transition: all 0.15s var(--ease);
}

.related-item:hover .related-item-arrow {
  color: var(--brand-link);
  transform: translateX(3px);
}

/* ─── TOC Sidebar ─── */
.toc {
  position: sticky;
  top: 104px;
  align-self: start;
}

.toc-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
  margin-bottom: 12px;
}

.toc-list,
#TableOfContents > ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  border-left: 2px solid var(--border);
  padding: 0;
  margin: 0;
}

.toc-item a,
#TableOfContents > ul > li > a {
  display: block;
  padding: 6px 0 6px 16px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
  border-left: 2px solid transparent;
  margin-left: -2px;
  transition:
    color 0.15s,
    border-color 0.15s;
  text-decoration: none;
}

.toc-item a:hover,
#TableOfContents a:hover {
  color: var(--text);
}

.toc-item.is-active a,
#TableOfContents li.toc-item.is-active > a {
  color: var(--brand-link);
  border-left-color: var(--brand-link);
  font-weight: 500;
}

/* Nested (sub) items — h3 inside TOC */
#TableOfContents > ul > li > ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc-item.is-sub a,
#TableOfContents > ul > li > ul > li > a {
  display: block;
  padding: 6px 0 6px 28px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
  border-left: 2px solid transparent;
  margin-left: -2px;
  transition:
    color 0.15s,
    border-color 0.15s;
  text-decoration: none;
}

/* ─── Responsive — Article ─── */
@media (max-width: 900px) {
  .article-layout {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .toc {
    position: static;
    margin-bottom: 32px;
    padding-bottom: 32px;
    border-bottom: 1px solid var(--border);
  }
}

@media (max-width: 640px) {
  .article-layout {
    padding: 32px 0 56px;
  }

  .article-title {
    font-size: 22px;
  }

  .step {
    grid-template-columns: 32px 1fr;
    gap: 12px;
  }

  .article-body > ol > li {
    padding-left: 2.4em;
  }

  .article-body > ol > li::before {
    top: 5px;
    width: 20px;
    height: 20px;
    font-size: 10px;
  }
}
