/* ========================================
   AI Learning Book - Shared Stylesheet
   ======================================== */

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --color-bg: #f8f9fa;
  --color-surface: #ffffff;
  --color-text: #2d3436;
  --color-text-light: #636e72;
  --color-border: #dfe6e9;

  /* Category Colors */
  --color-cat1: #6c5ce7;   /* LLM基礎理論 - Purple */
  --color-cat1-light: #a29bfe;
  --color-cat1-bg: #f3f0ff;

  --color-cat2: #00b894;   /* AIエージェント設計 - Green */
  --color-cat2-light: #55efc4;
  --color-cat2-bg: #eefbf5;

  --color-cat3: #0984e3;   /* ツール活用・実践 - Blue */
  --color-cat3-light: #74b9ff;
  --color-cat3-bg: #eef5ff;

  --color-cat4: #e17055;   /* プロンプト・ワークフロー - Orange */
  --color-cat4-light: #fab1a0;
  --color-cat4-bg: #fff3ef;

  --color-accent: #fd79a8;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --max-width: 900px;
  --font-main: 'Noto Sans JP', 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

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

/* Typography */
h1, h2, h3, h4 {
  line-height: 1.4;
  font-weight: 700;
}

h1 { font-size: 2rem; margin-bottom: 1rem; }
h2 { font-size: 1.5rem; margin-top: 2.5rem; margin-bottom: 1rem; }
h3 { font-size: 1.25rem; margin-top: 2rem; margin-bottom: 0.75rem; }
h4 { font-size: 1.1rem; margin-top: 1.5rem; margin-bottom: 0.5rem; }

p {
  margin-bottom: 1rem;
  color: var(--color-text);
}

a {
  color: var(--color-cat3);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: var(--color-cat1);
  text-decoration: underline;
}

/* Page Layout */
.page-header {
  background: linear-gradient(135deg, var(--color-cat1) 0%, var(--color-cat3) 100%);
  color: white;
  padding: 3rem 2rem;
  text-align: center;
}

.page-header h1 {
  font-size: 2.2rem;
  margin-bottom: 0.5rem;
}

.page-header .subtitle {
  font-size: 1.25rem;
  font-weight: 500;
  opacity: 1;
  color: white;
  text-shadow: 0 1px 3px rgba(0,0,0,0.3);
  max-width: 700px;
  margin: 0.5rem auto 0;
  line-height: 1.7;
  letter-spacing: 0.02em;
}

.page-header.cat1 { background: linear-gradient(135deg, var(--color-cat1) 0%, #a29bfe 100%); }
.page-header.cat2 { background: linear-gradient(135deg, var(--color-cat2) 0%, #55efc4 100%); }
.page-header.cat3 { background: linear-gradient(135deg, var(--color-cat3) 0%, #74b9ff 100%); }
.page-header.cat4 { background: linear-gradient(135deg, var(--color-cat4) 0%, #fab1a0 100%); }

.breadcrumb {
  max-width: var(--max-width);
  margin: 1.5rem auto 0;
  padding: 0 1.5rem;
  font-size: 0.9rem;
  color: var(--color-text-light);
}

.breadcrumb a {
  color: var(--color-text-light);
}

.content {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

/* Cards */
.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem 2rem;
  margin-bottom: 1.5rem;
  border: 1px solid var(--color-border);
  transition: box-shadow 0.2s, transform 0.2s;
}

.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.card-link {
  display: block;
  color: inherit;
  text-decoration: none;
}

.card-link:hover {
  text-decoration: none;
  color: inherit;
}

.card-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.card-desc {
  font-size: 0.95rem;
  color: var(--color-text-light);
  line-height: 1.6;
}

/* Category Section */
.category-section {
  margin-bottom: 3rem;
}

.category-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 1rem;
  padding: 0.4rem 1rem;
  border-radius: var(--radius-sm);
}

.category-label.cat1 { background: var(--color-cat1-bg); color: var(--color-cat1); }
.category-label.cat2 { background: var(--color-cat2-bg); color: var(--color-cat2); }
.category-label.cat3 { background: var(--color-cat3-bg); color: var(--color-cat3); }
.category-label.cat4 { background: var(--color-cat4-bg); color: var(--color-cat4); }

.card.cat1 { border-left: 4px solid var(--color-cat1); }
.card.cat2 { border-left: 4px solid var(--color-cat2); }
.card.cat3 { border-left: 4px solid var(--color-cat3); }
.card.cat4 { border-left: 4px solid var(--color-cat4); }

/* Info Boxes */
.info-box {
  border-radius: var(--radius-sm);
  padding: 1.25rem 1.5rem;
  margin: 1.5rem 0;
  border-left: 4px solid;
}

.info-box.point {
  background: #eef5ff;
  border-color: var(--color-cat3);
}

.info-box.warn {
  background: #fff8e6;
  border-color: #fdcb6e;
}

.info-box.success {
  background: var(--color-cat2-bg);
  border-color: var(--color-cat2);
}

.info-box.example {
  background: var(--color-cat1-bg);
  border-color: var(--color-cat1);
}

.info-box-title {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 0.4rem;
}

/* Keyword Tags */
.keyword {
  display: inline-block;
  background: var(--color-cat1-bg);
  color: var(--color-cat1);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.2rem 0.7rem;
  border-radius: 20px;
  margin: 0.2rem 0.3rem 0.2rem 0;
}

/* Code Blocks */
code {
  font-family: var(--font-mono);
  background: #f1f2f6;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.9em;
}

pre {
  background: #2d3436;
  color: #dfe6e9;
  padding: 1.25rem 1.5rem;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 1rem 0;
  line-height: 1.6;
}

pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: 0.88rem;
}

/* Tables */
.table-wrapper {
  overflow-x: auto;
  margin: 1.5rem 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

thead th {
  background: var(--color-cat1);
  color: white;
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
}

tbody td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
}

tbody tr:nth-child(even) {
  background: #f8f9fa;
}

tbody tr:hover {
  background: #eef5ff;
}

/* Lists */
ul, ol {
  margin: 0.75rem 0 1rem 1.5rem;
}

li {
  margin-bottom: 0.4rem;
}

li::marker {
  color: var(--color-cat3);
}

/* Diagram / Visual Blocks */
.diagram {
  background: var(--color-surface);
  border: 2px dashed var(--color-border);
  border-radius: var(--radius);
  padding: 2rem;
  margin: 1.5rem 0;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.8;
  overflow-x: auto;
  white-space: pre;
}

/* PDF Slide Images */
.slide-figure {
  margin: 2rem 0;
  text-align: center;
}

.slide-figure img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--color-border);
}

.slide-figure figcaption {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--color-text-light);
}

/* Slide Gallery */
.slide-gallery {
  margin: 2.5rem 0;
  padding: 2rem;
  background: var(--color-surface);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
}

.slide-gallery h2 {
  margin-top: 0;
  margin-bottom: 1.5rem;
  font-size: 1.3rem;
  text-align: center;
}

.slide-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
}

.slide-gallery-grid figure {
  margin: 0;
  cursor: pointer;
  transition: transform 0.2s;
}

.slide-gallery-grid figure:hover {
  transform: scale(1.02);
}

.slide-gallery-grid img {
  width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
}

.slide-gallery-grid figcaption {
  text-align: center;
  font-size: 0.8rem;
  color: var(--color-text-light);
  margin-top: 0.3rem;
}

/* Lightbox for full-size slide viewing */
.lightbox-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.85);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  cursor: pointer;
}

.lightbox-overlay.active {
  display: flex;
}

.lightbox-overlay img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: var(--radius);
  box-shadow: 0 0 40px rgba(0,0,0,0.5);
}

/* Step List */
.step-list {
  list-style: none;
  margin-left: 0;
  counter-reset: step-counter;
}

.step-list li {
  counter-increment: step-counter;
  position: relative;
  padding-left: 3rem;
  margin-bottom: 1.5rem;
}

.step-list li::before {
  content: counter(step-counter);
  position: absolute;
  left: 0;
  top: 0;
  width: 2rem;
  height: 2rem;
  background: var(--color-cat3);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
}

/* Comparison Grid */
.comparison-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 1.5rem 0;
}

.comparison-item {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 1.25rem;
}

.comparison-item h4 {
  margin-top: 0;
}

/* Footer */
.page-footer {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1.5rem;
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  color: var(--color-text-light);
}

.page-footer a {
  color: var(--color-cat3);
}

/* Prev/Next Navigation */
.page-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--color-border);
}

.page-nav a {
  display: block;
  padding: 1rem 1.5rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  min-width: 200px;
  transition: box-shadow 0.2s;
}

.page-nav a:hover {
  box-shadow: var(--shadow-md);
  text-decoration: none;
}

.page-nav .nav-label {
  font-size: 0.8rem;
  color: var(--color-text-light);
  margin-bottom: 0.25rem;
}

.page-nav .nav-next {
  text-align: right;
  margin-left: auto;
}

/* Responsive */
@media (max-width: 768px) {
  .page-header {
    padding: 2rem 1rem;
  }

  .page-header h1 {
    font-size: 1.6rem;
  }

  .content {
    padding: 1.5rem 1rem 3rem;
  }

  .card {
    padding: 1.25rem;
  }

  .comparison-grid {
    grid-template-columns: 1fr;
  }

  .page-nav {
    flex-direction: column;
  }

  .page-nav a {
    min-width: auto;
  }

  .page-nav .nav-next {
    text-align: left;
  }

  table {
    font-size: 0.85rem;
  }

  thead th, tbody td {
    padding: 0.5rem 0.6rem;
  }
}

/* Index Page Specific */
.index-hero {
  background: linear-gradient(135deg, #2d3436 0%, #636e72 100%);
  color: white;
  padding: 4rem 2rem;
  text-align: center;
}

.index-hero h1 {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
}

.index-hero .lead {
  font-size: 1.3rem;
  font-weight: 500;
  opacity: 1;
  color: white;
  text-shadow: 0 1px 3px rgba(0,0,0,0.3);
  max-width: 700px;
  margin: 0 auto;
  line-height: 1.8;
  letter-spacing: 0.02em;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}

.category-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 2rem;
  border-top: 4px solid;
  transition: box-shadow 0.2s, transform 0.2s;
}

.category-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-3px);
}

.category-card.cat1 { border-top-color: var(--color-cat1); }
.category-card.cat2 { border-top-color: var(--color-cat2); }
.category-card.cat3 { border-top-color: var(--color-cat3); }
.category-card.cat4 { border-top-color: var(--color-cat4); }

.category-card h2 {
  margin-top: 0;
  font-size: 1.25rem;
}

.category-card .cat-icon {
  font-size: 2rem;
  margin-bottom: 0.75rem;
}

.article-list {
  list-style: none;
  margin: 1rem 0 0 0;
  padding: 0;
}

.article-list li {
  margin-bottom: 0.5rem;
}

.article-list a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  transition: background 0.15s;
}

.article-list a:hover {
  background: var(--color-bg);
  text-decoration: none;
}

.article-list a::before {
  content: '→';
  color: var(--color-text-light);
  flex-shrink: 0;
}
