/* =============================================
   Howto Series - Common Styles v1.0
   page.css の上に読み込まれることを前提
   ============================================= */

/* ===== CSS Custom Properties ===== */
:root {
  /* Colors - Light Theme */
  --howto-bg: #ffffff;
  --howto-surface: #f8f9fa;
  --howto-surface-hover: #f1f3f4;
  --howto-border: #e5e7eb;
  --howto-border-light: #f0f0f0;
  --howto-text: #1a1a1a;
  --howto-text-muted: #6b7280;
  --howto-text-dim: #9ca3af;

  /* Accent Colors */
  --howto-accent: #454c84;
  --howto-accent-light: #5b63a0;
  --howto-accent-bg: #eeeef8;

  /* Typography */
  --howto-font-display: 'Space Grotesk', sans-serif;
  --howto-font-body: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Spacing */
  --howto-space-xs: 0.25rem;
  --howto-space-sm: 0.5rem;
  --howto-space-md: 1rem;
  --howto-space-lg: 1.5rem;
  --howto-space-xl: 2rem;
  --howto-space-2xl: 3rem;
  --howto-space-3xl: 4rem;

  /* Border Radius */
  --howto-radius-sm: 8px;
  --howto-radius-md: 12px;
  --howto-radius-lg: 16px;
  --howto-radius-xl: 24px;

  /* Transitions */
  --howto-transition-fast: 150ms ease;
  --howto-transition-base: 250ms ease;
}

/* ===== Reset & Base (defpage 内オーバーライド) =====
   PWA ページと同様、CMS の defpage > main 内で
   独自のベーススタイルを適用する */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--howto-font-body);
  background: var(--howto-bg);
  color: var(--howto-text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ===== Container =====
   page.css の .page-container (max-width:800px) と同等。
   inc_howto.php 使用時のラッパー、またはwork HTML プレビュー用 */
.howto-container {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem;
  padding-bottom: var(--howto-space-3xl);
  font-family: var(--howto-font-body);
  line-height: 1.8;
  color: var(--howto-text);
}

/* ===== Breadcrumb ===== */
.breadcrumb {
  margin-bottom: var(--howto-space-lg);
  font-size: 0.8125rem;
}

.breadcrumb ol {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25em;
}

.breadcrumb li {
  display: flex;
  align-items: center;
  color: var(--howto-text-muted);
}

.breadcrumb li + li::before {
  content: '>';
  margin-right: 0.5em;
  color: var(--howto-text-dim);
}

.breadcrumb a {
  color: var(--howto-accent);
  text-decoration: none;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.breadcrumb [aria-current="page"] {
  color: var(--howto-text);
  font-weight: 500;
}

/* ===== Hero / Page Header ===== */
.howto-hero {
  text-align: center;
  margin-bottom: var(--howto-space-xl);
  padding: 1em 0;
}

.howto-hero-badge {
  display: inline-block;
  padding: var(--howto-space-xs) var(--howto-space-md);
  background: var(--howto-accent-bg);
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--howto-accent);
  letter-spacing: 0.08em;
  margin-bottom: var(--howto-space-md);
  animation: howtoFadeInUp 0.6s ease backwards;
}

.howto-hero-title {
  font-family: var(--howto-font-display);
  font-size: 2.75rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.02em;
  margin-bottom: var(--howto-space-sm);
  color: var(--howto-text);
  animation: howtoFadeInUp 0.6s ease 0.1s backwards;
}

.howto-hero-title .accent {
  color: var(--howto-accent);
}

.howto-hero-desc {
  font-size: 0.9375rem;
  color: var(--howto-text-muted);
  max-width: 480px;
  margin: 0 auto;
  line-height: 1.7;
  animation: howtoFadeInUp 0.6s ease 0.2s backwards;
}

/* ===== Table of Contents (TOC) ===== */
.toc {
  background: var(--howto-surface);
  border: 1px solid var(--howto-border);
  border-radius: var(--howto-radius-md);
  padding: var(--howto-space-md) var(--howto-space-lg);
  margin-bottom: var(--howto-space-2xl);
}

.toc-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--howto-text-muted);
  margin-bottom: var(--howto-space-sm);
  display: flex;
  align-items: center;
  gap: var(--howto-space-sm);
}

.toc-title i {
  color: var(--howto-accent);
}

.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  counter-reset: toc-counter;
}

.toc-list li {
  counter-increment: toc-counter;
}

.toc-list a {
  display: flex;
  align-items: center;
  padding: 0.375rem 0.5rem;
  border-radius: 6px;
  font-size: 0.875rem;
  color: var(--howto-text);
  text-decoration: none;
  transition: background var(--howto-transition-fast), color var(--howto-transition-fast);
}

.toc-list a::before {
  content: counter(toc-counter) ".";
  min-width: 1.5em;
  color: var(--howto-accent);
  font-weight: 600;
  font-size: 0.8125rem;
}

.toc-list a:hover {
  background: var(--howto-accent-bg);
  color: var(--howto-accent);
}

.toc-list a.active {
  background: var(--howto-accent-bg);
  color: var(--howto-accent);
  font-weight: 500;
}

/* ===== Section ===== */
.howto-section {
  margin-bottom: var(--howto-space-2xl);
  scroll-margin-top: 80px;
}

.howto-section > p {
  font-size: 0.9375rem;
  color: var(--howto-text-muted);
  line-height: 1.8;
  margin-bottom: var(--howto-space-lg);
}

.howto-section-title {
  font-size: 1.4rem;
  font-weight: 600;
  margin: 0 0 var(--howto-space-lg) 0;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--howto-accent-bg);
  color: var(--howto-text);
}

.howto-section-title .section-icon {
  margin-right: 0.5em;
  color: var(--howto-accent);
}

.howto-subsection-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: var(--howto-space-xl) 0 var(--howto-space-md);
  color: var(--howto-text);
}

/* ===== Step Guide ===== */
.howto-steps {
  display: flex;
  flex-direction: column;
  gap: var(--howto-space-xl);
}

.howto-step {
  display: flex;
  gap: var(--howto-space-md);
  scroll-margin-top: 80px;
}

.howto-step-number {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--howto-accent);
  border-radius: 50%;
  font-family: var(--howto-font-display);
  font-weight: 700;
  font-size: 0.875rem;
  color: white;
  margin-top: 2px;
}

.howto-step-content {
  flex: 1;
  min-width: 0;
}

.howto-step-title {
  font-size: 1.0625rem;
  font-weight: 600;
  margin-bottom: var(--howto-space-xs);
}

.howto-step-desc {
  font-size: 0.875rem;
  color: var(--howto-text-muted);
  line-height: 1.7;
  margin-bottom: var(--howto-space-md);
}

/* --- Step Images --- */
.howto-step-figure {
  background: var(--howto-surface);
  border: 1px solid var(--howto-border);
  border-radius: var(--howto-radius-md);
  overflow: hidden;
  max-width: 280px;
  margin-bottom: var(--howto-space-sm);
}

.howto-step-figure img {
  width: 100%;
  height: auto;
  display: block;
}

.howto-step-figure figcaption {
  text-align: center;
  font-size: 0.75rem;
  color: var(--howto-text-dim);
  padding: var(--howto-space-xs) var(--howto-space-sm);
  background: var(--howto-surface);
  border-top: 1px solid var(--howto-border-light);
}

/* 2枚並び */
.howto-step-figures {
  display: flex;
  gap: var(--howto-space-md);
  flex-wrap: wrap;
}

.howto-step-figures .howto-step-figure {
  max-width: 240px;
}

/* ===== Highlight Text ===== */
.hl {
  color: var(--howto-text);
  background: var(--howto-accent-bg);
  padding: 0.1em 0.4em;
  border-radius: 4px;
  font-weight: 500;
  font-size: 0.9em;
}

/* ===== Note / Info Box ===== */
.howto-note {
  display: flex;
  align-items: flex-start;
  gap: var(--howto-space-sm);
  padding: var(--howto-space-md) var(--howto-space-lg);
  background: var(--howto-accent-bg);
  border-radius: var(--howto-radius-md);
  margin: var(--howto-space-lg) 0;
  font-size: 0.875rem;
  color: var(--howto-text-muted);
  line-height: 1.7;
}

.howto-note > i {
  flex-shrink: 0;
  color: var(--howto-accent);
  margin-top: 0.25em;
}

.howto-note strong { color: var(--howto-text); }

.howto-note a {
  color: var(--howto-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ===== Flow Diagram ===== */
.flow-diagram {
  display: flex;
  flex-direction: column;
  gap: var(--howto-space-sm);
  padding: var(--howto-space-lg);
  background: var(--howto-surface);
  border-radius: var(--howto-radius-md);
  border: 1px solid var(--howto-border);
  margin: var(--howto-space-lg) 0;
  max-width: 480px;
}

.flow-step {
  display: flex;
  align-items: center;
  gap: var(--howto-space-sm);
  padding: var(--howto-space-sm) var(--howto-space-md);
  background: var(--howto-surface-hover);
  border-radius: 6px;
  font-size: 0.875rem;
}

.flow-step i { color: var(--howto-accent); width: 20px; text-align: center; }

.flow-arrow {
  text-align: center;
  color: var(--howto-text-dim);
  font-size: 0.75rem;
  padding-left: 20px;
}

/* ===== FAQ ===== */
.howto-faq-section {
  margin-top: var(--howto-space-2xl);
  padding-top: var(--howto-space-xl);
  border-top: 1px solid var(--howto-border);
}

.howto-faq-list {
  display: flex;
  flex-direction: column;
}

.howto-faq-item {
  border-bottom: 1px solid var(--howto-border);
}

.howto-faq-item summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--howto-space-md) 0;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  list-style: none;
  transition: color var(--howto-transition-fast);
}

.howto-faq-item summary::-webkit-details-marker { display: none; }

.howto-faq-item summary::after {
  content: '+';
  font-size: 1.25rem;
  color: var(--howto-text-dim);
  transition: transform var(--howto-transition-base);
  flex-shrink: 0;
  margin-left: var(--howto-space-md);
}

.howto-faq-item[open] summary::after { transform: rotate(45deg); }
.howto-faq-item summary:hover { color: var(--howto-accent); }

.howto-faq-answer {
  padding: 0 0 var(--howto-space-md);
  font-size: 0.875rem;
  color: var(--howto-text-muted);
  line-height: 1.7;
}

.howto-faq-answer ul {
  margin: var(--howto-space-sm) 0;
  padding-left: 1.5rem;
}

.howto-faq-answer li { margin: var(--howto-space-xs) 0; }

.howto-faq-answer a {
  color: var(--howto-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ===== Related Pages ===== */
.related-pages {
  margin-top: var(--howto-space-2xl);
  padding-top: var(--howto-space-xl);
  border-top: 1px solid var(--howto-border);
}

.related-pages-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: var(--howto-space-lg);
  color: var(--howto-text);
}

.related-pages-grid {
  display: flex;
  flex-direction: column;
  gap: var(--howto-space-sm);
}

.related-page-card {
  display: flex;
  align-items: center;
  gap: var(--howto-space-md);
  padding: var(--howto-space-md) var(--howto-space-lg);
  background: var(--howto-surface);
  border: 1px solid var(--howto-border);
  border-radius: var(--howto-radius-md);
  text-decoration: none;
  color: var(--howto-text);
  transition: background var(--howto-transition-fast), box-shadow var(--howto-transition-fast);
}

.related-page-card:hover {
  background: var(--howto-surface-hover);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  text-decoration: none;
}

.related-page-icon {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--howto-accent-bg);
  color: var(--howto-accent);
  border-radius: var(--howto-radius-sm);
  font-size: 1rem;
}

.related-page-body { flex: 1; min-width: 0; }

.related-page-name {
  font-weight: 600;
  font-size: 0.9375rem;
  margin-bottom: 0.125rem;
}

.related-page-desc {
  font-size: 0.8125rem;
  color: var(--howto-text-muted);
  line-height: 1.5;
}

.related-page-arrow {
  color: var(--howto-text-dim);
  font-size: 0.75rem;
  flex-shrink: 0;
  transition: transform var(--howto-transition-fast);
}

.related-page-card:hover .related-page-arrow {
  transform: translateX(3px);
  color: var(--howto-accent);
}

/* ===== Global Link Override for Howto ===== */
.howto-container a { color: var(--howto-accent); }
.howto-container a:hover { text-decoration: underline; }

/* ===== Animations ===== */
@keyframes howtoFadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Responsive: Mobile (< 600px) ===== */
@media (max-width: 600px) {
  .howto-container {
    padding: 1rem;
  }

  .howto-hero-title {
    font-size: 1.5rem;
  }

  .howto-section-title {
    font-size: 1.2rem;
  }

  .howto-step {
    flex-direction: column;
  }

  .howto-step-number {
    margin-bottom: var(--howto-space-xs);
  }

  .howto-step-figure {
    max-width: 100%;
  }

  .howto-step-figures {
    flex-direction: column;
  }

  .howto-step-figures .howto-step-figure {
    max-width: 100%;
  }

  .toc {
    padding: var(--howto-space-md);
  }
}

/* ===== Responsive: PC (>= 768px) ===== */
@media (min-width: 768px) {
  .howto-container {
    max-width: unset;
  }

  .howto-step {
    gap: var(--howto-space-lg);
  }

  .howto-step-number {
    width: 36px;
    height: 36px;
    font-size: 0.9375rem;
  }

  .toc-list {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
  }

  .toc-list a {
    padding: 0.25rem 0.5rem;
  }

  .related-pages-grid {
    flex-direction: row;
    gap: var(--howto-space-md);
  }

  .related-page-card {
    flex: 1;
    flex-direction: column;
    text-align: center;
    padding: var(--howto-space-lg);
  }

  .related-page-arrow {
    display: none;
  }
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
  .howto-container *,
  .howto-container *::before,
  .howto-container *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===== Print ===== */
@media print {
  .toc, .related-pages, .breadcrumb { display: none; }
  .howto-container { max-width: 100%; padding: 0; }
  .howto-step-figure { max-width: 200px; }
}
