/* Scratch ↔ JS レッスンページ用スタイル */
/* scratch-js-01 テンプレートに基づくデザインシステム */

/* ========== レイアウト ========== */
.lesson-page {
  min-height: 100vh;
  background-color: #ffffff;
}

.lesson-container {
  max-width: 64rem;
  margin: 0 auto;
  padding: 2rem 1rem;
}

@media (min-width: 640px) {
  .lesson-container {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }
}

@media (min-width: 1024px) {
  .lesson-container {
    padding-left: 2rem;
    padding-right: 2rem;
    padding-top: 3rem;
    padding-bottom: 3rem;
  }
}

/* ========== ヘッダー ========== */
.lesson-header {
  margin-bottom: 2.5rem;
}

.lesson-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.tag {
  display: inline-flex;
  align-items: center;
  border-radius: 9999px;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
}

.tag-beginner {
  background-color: #d1fae5;
  color: #065f46;
}

.tag-topic {
  background-color: #dbeafe;
  color: #1e40af;
}

.lesson-title {
  margin-bottom: 0.5rem;
  font-size: 1.875rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.025em;
  color: #1f2937;
}

@media (min-width: 640px) {
  .lesson-title {
    font-size: 2.25rem;
  }
}

.lesson-subtitle {
  margin-bottom: 1.5rem;
  font-size: 1.125rem;
  font-weight: 500;
  color: #2563eb;
}

.learning-objectives {
  border-radius: 0.5rem;
  border: 1px solid #bfdbfe;
  background-color: #dbeafe;
  padding: 1rem;
}

.learning-objectives-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  color: #1e3a8a;
}

.learning-objectives-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.learning-objectives-list li {
  font-size: 0.875rem;
  color: #1e40af;
  line-height: 1.5;
  margin-bottom: 0.375rem;
}

.learning-objectives-list li:last-child {
  margin-bottom: 0;
}

/* ========== セクション ========== */
.lesson-section {
  margin-bottom: 3rem;
}

.section-heading {
  margin-bottom: 1rem;
  font-size: 1.5rem;
  font-weight: 700;
  color: #1f2937;
}

.section-intro {
  margin-bottom: 1.5rem;
  color: #6b7280;
  line-height: 1.625;
}

/* ========== ゴール紹介セクション ========== */
.goal-layout {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: 1fr;
}

@media (min-width: 768px) {
  .goal-layout {
    grid-template-columns: repeat(2, 1fr);
  }
}

.goal-text {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.goal-paragraph {
  color: #6b7280;
  line-height: 1.625;
}

.goal-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.stage {
  position: relative;
  width: 480px;
  max-width: 100%;
  height: 360px;
  background-color: #ffffff;
  border: 4px solid #000000;
  overflow: hidden;
}

.sprite {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 80px;
  height: 80px;
}

.preview-caption {
  margin-top: 0.75rem;
  font-size: 0.875rem;
  color: #6b7280;
  text-align: center;
}

/* ========== Scratch デモカード ========== */
.scratch-demo-card {
  border-radius: 0.75rem;
  border: 1px solid #e5e7eb;
  background-color: #ffffff;
  padding: 1.5rem;
}

.scratch-preview-area {
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #fef3c7;
  border-radius: 0.75rem;
  border: 2px solid #fbbf24;
  padding: 2rem;
}

.scratch-icon-placeholder {
  text-align: center;
}

.icon-large {
  display: block;
  margin: 0 auto 0.5rem;
  width: 2.5rem;
  height: 2.5rem;
  color: #f59e0b;
}

.scratch-preview-text {
  font-size: 0.875rem;
  color: #f59e0b;
}

.scratch-preview-subtext {
  font-size: 0.75rem;
  color: #d97706;
}

.scratch-features-title {
  margin-bottom: 1rem;
  font-size: 1rem;
  font-weight: 600;
  color: #1f2937;
}

.scratch-features-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.scratch-features-list li {
  font-size: 0.875rem;
  color: #6b7280;
  line-height: 1.625;
  margin-bottom: 0.5rem;
}

.scratch-features-list li:last-child {
  margin-bottom: 0;
}

.scratch-features-list strong {
  color: #1f2937;
}

/* ========== 比較ブロック ========== */
.comparison-block {
  border-radius: 0.75rem;
  border: 1px solid #e5e7eb;
  background-color: #ffffff;
  padding: 1.5rem;
}

.comparison-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: 1fr;
}

@media (min-width: 768px) {
  .comparison-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.comparison-side {
  display: flex;
  flex-direction: column;
}

.comparison-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  align-self: flex-start;
  border-radius: 9999px;
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.comparison-badge-scratch {
  background-color: #fef3c7;
  color: #92400e;
}

.comparison-badge-js {
  background-color: #d1fae5;
  color: #065f46;
}

.comparison-content {
  margin-bottom: 1rem;
  display: flex;
  height: 10rem;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 0.5rem;
  padding: 1rem;
  text-align: center;
}

.comparison-content-scratch {
  border: 2px dashed #fbbf24;
  background-color: #fef3c7;
}

.comparison-label {
  font-size: 0.875rem;
  color: #92400e;
  font-weight: 500;
}

.comparison-desc {
  font-size: 1.25rem;
  color: #92400e;
  margin: 0.5rem 0;
}

.comparison-code {
  margin-bottom: 1rem;
  overflow-x: auto;
  border-radius: 0.5rem;
  padding: 1rem;
}

.comparison-code-js {
  border: 1px solid #a7f3d0;
  background-color: #d1fae5;
}

.comparison-code code {
  font-family: 'Courier New', monospace;
  font-size: 0.75rem;
  color: #065f46;
  white-space: pre;
}

.comparison-explanation {
  font-size: 0.875rem;
  color: #6b7280;
  line-height: 1.625;
}

/* ========== 完成コード詳細カード ========== */
.code-detail-card {
  border-radius: 0.75rem;
  border: 1px solid #e5e7eb;
  background-color: #ffffff;
  overflow: hidden;
}

.code-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #e5e7eb;
  padding: 0.75rem 1rem;
}

.code-detail-info {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.code-filename {
  font-size: 0.875rem;
  font-weight: 500;
  color: #6b7280;
}

.code-detail-labels {
  display: none;
  align-items: center;
  gap: 1rem;
  font-size: 0.75rem;
  color: rgba(107, 114, 128, 0.6);
}

@media (min-width: 768px) {
  .code-detail-labels {
    display: flex;
  }
}

.code-label-item {
  border-radius: 0.25rem;
  background-color: #f3f4f6;
  padding: 0.125rem 0.5rem;
}

.code-copy-button {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  border-radius: 0.375rem;
  background-color: #ffffff;
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: #1f2937;
  border: 1px solid #e5e7eb;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
}

.code-copy-button:hover {
  background-color: rgba(107, 114, 128, 0.1);
}

.code-copy-button:active {
  background-color: rgba(107, 114, 128, 0.2);
}

.code-detail-header-row {
  display: none;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  border-bottom: 1px solid #e5e7eb;
  background-color: rgba(243, 244, 246, 0.3);
  padding: 0.5rem 1rem;
}

@media (min-width: 768px) {
  .code-detail-header-row {
    display: grid;
  }
}

.code-detail-col-header {
  font-size: 0.75rem;
  font-weight: 600;
  color: #6b7280;
}

.code-detail-body {
  padding: 1rem;
}

.code-line {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  border-bottom: 1px solid rgba(229, 231, 235, 0.5);
  padding: 0.5rem 0;
}

@media (min-width: 768px) {
  .code-line {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }
}

.code-line:last-child {
  border-bottom: none;
}

.code-line-separator {
  opacity: 0.5;
}

.code-line-code {
  overflow-x: auto;
  border-radius: 0.25rem;
  background-color: rgba(243, 244, 246, 0.5);
  padding: 0.375rem 0.75rem;
}

.code-line-code code {
  font-family: 'Courier New', monospace;
  font-size: 0.75rem;
  color: #1f2937;
}

.code-line-explanation {
  font-size: 0.75rem;
  color: #6b7280;
  line-height: 1.625;
}

@media (min-width: 768px) {
  .code-line-explanation {
    padding-top: 0.375rem;
    padding-bottom: 0.375rem;
  }
}

/* 全文表示 */
.code-full-details {
  margin-top: 1rem;
}

.code-full-summary {
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  color: #2563eb;
}

.code-full-summary:hover {
  text-decoration: underline;
}

.code-full-container {
  margin-top: 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid #e5e7eb;
  background-color: #f3f4f6;
}

.code-full-pre {
  overflow-x: auto;
  padding: 1rem;
}

.code-full-pre code {
  font-family: 'Courier New', monospace;
  font-size: 0.75rem;
  color: #1f2937;
  line-height: 1.625;
}

/* ========== 注目ポイント ========== */
.key-points-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 1024px) {
  .key-points-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.key-point-card {
  border-radius: 0.75rem;
  border: 2px solid;
  padding: 1.25rem;
}

.key-point-card-blue {
  border-color: #bfdbfe;
  background-color: #dbeafe;
}

.key-point-card-green {
  border-color: #a7f3d0;
  background-color: #d1fae5;
}

.key-point-card-amber {
  border-color: #fcd34d;
  background-color: #fef3c7;
}

.key-point-number-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.key-point-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 700;
  color: #ffffff;
  flex-shrink: 0;
}

.key-point-card-blue .key-point-number {
  background-color: #3b82f6;
}

.key-point-card-green .key-point-number {
  background-color: #10b981;
}

.key-point-card-amber .key-point-number {
  background-color: #f59e0b;
}

.key-point-title {
  font-size: 1rem;
  font-weight: 600;
}

.key-point-card-blue .key-point-title {
  color: #1e3a8a;
}

.key-point-card-green .key-point-title {
  color: #065f46;
}

.key-point-card-amber .key-point-title {
  color: #92400e;
}

.key-point-description {
  font-size: 0.875rem;
  line-height: 1.625;
}

.key-point-card-blue .key-point-description {
  color: #1e40af;
}

.key-point-card-green .key-point-description {
  color: #047857;
}

.key-point-card-amber .key-point-description {
  color: #78350f;
}

/* ========== 完成版リンク ========== */
.demo-links-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .demo-links-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.demo-link-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  border-radius: 0.75rem;
  border: 2px solid;
  padding: 1.25rem;
  text-decoration: none;
  transition: all 0.3s;
}

.demo-link-scratch {
  border-color: #fbbf24;
  background-color: #fef3c7;
}

.demo-link-scratch:hover {
  border-color: #f59e0b;
  background-color: #fde68a;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.demo-link-js {
  border-color: #10b981;
  background-color: #d1fae5;
}

.demo-link-js:hover {
  border-color: #059669;
  background-color: #a7f3d0;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.demo-link-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  border-radius: 9999px;
  flex-shrink: 0;
  transition: background-color 0.3s;
}

.demo-link-icon-scratch {
  background-color: #fbbf24;
}

.demo-link-scratch:hover .demo-link-icon-scratch {
  background-color: #f59e0b;
}

.demo-link-icon-js {
  background-color: #10b981;
}

.demo-link-js:hover .demo-link-icon-js {
  background-color: #059669;
}

.demo-link-icon svg {
  width: 1.5rem;
  height: 1.5rem;
  color: #ffffff;
}

.demo-link-content {
  flex: 1;
}

.demo-link-title {
  margin-bottom: 0.25rem;
  font-size: 1rem;
  font-weight: 600;
}

.demo-link-scratch .demo-link-title {
  color: #92400e;
}

.demo-link-js .demo-link-title {
  color: #065f46;
}

.demo-link-description {
  font-size: 0.875rem;
}

.demo-link-scratch .demo-link-description {
  color: #78350f;
}

.demo-link-js .demo-link-description {
  color: #047857;
}

.demo-link-arrow {
  width: 1.25rem;
  height: 1.25rem;
  transition: transform 0.3s;
}

.demo-link-scratch .demo-link-arrow {
  color: #fbbf24;
}

.demo-link-js .demo-link-arrow {
  color: #10b981;
}

.demo-link-card:hover .demo-link-arrow {
  transform: translateX(0.25rem);
}

/* ========== チャレンジカード ========== */
.challenges-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .challenges-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .challenges-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.challenge-card {
  border-radius: 0.5rem;
  border: 1px solid rgba(59, 130, 246, 0.2);
  background-color: rgba(59, 130, 246, 0.05);
  padding: 1rem;
  transition: box-shadow 0.3s;
}

.challenge-card:hover {
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.challenge-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.challenge-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 9999px;
  background-color: rgba(59, 130, 246, 0.1);
}

.challenge-icon svg {
  width: 1rem;
  height: 1rem;
  color: #2563eb;
}

.challenge-title {
  font-size: 1rem;
  font-weight: 600;
  color: #1f2937;
}

.challenge-description {
  font-size: 0.875rem;
  color: #6b7280;
  line-height: 1.625;
}

.challenge-description code {
  border-radius: 0.25rem;
  background-color: rgba(243, 244, 246, 0.8);
  padding: 0.125rem 0.375rem;
  font-family: 'Courier New', monospace;
  font-size: 0.75rem;
  color: #1f2937;
}

/* ========== ナビゲーション ========== */
.lesson-nav {
  border-top: 1px solid #e5e7eb;
  padding-top: 2rem;
  margin-top: 2rem;
}

.lesson-nav-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

@media (min-width: 640px) {
  .lesson-nav-buttons {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.nav-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: 0.5rem;
  border: 1px solid #e5e7eb;
  background-color: #ffffff;
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #1f2937;
  text-decoration: none;
  transition: background-color 0.2s;
}

.nav-button:hover {
  background-color: #f3f4f6;
}

.nav-button-center {
  text-align: center;
  border: none;
  background-color: transparent;
  color: #2563eb;
}

.nav-button-center:hover {
  background-color: transparent;
  text-decoration: underline;
}

.nav-button-next {
  background-color: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
}

.nav-button-next:hover {
  background-color: #1d4ed8;
}

.nav-button-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* ========== アイコン ========== */
.icon {
  width: 1.25rem;
  height: 1.25rem;
  display: inline-block;
  flex-shrink: 0;
}

/* ========== Scratch画像表示 ========== */
.scratch-image-container {
  position: relative;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  border-radius: 0.5rem;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid #f59e0b;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.scratch-image-container:hover {
  border-color: #d97706;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.scratch-screenshot {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 0.3s ease;
}

.scratch-image-container:hover .scratch-screenshot {
  transform: scale(1.02);
}

.image-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: all 0.3s ease;
}

.scratch-image-container:hover .image-overlay {
  background-color: rgba(0, 0, 0, 0.6);
  opacity: 1;
}

.icon-zoom {
  width: 3rem;
  height: 3rem;
  color: #ffffff;
  margin-bottom: 0.5rem;
}

.overlay-text {
  color: #ffffff;
  font-size: 0.875rem;
  font-weight: 600;
}

/* ========== 画像拡大モーダル ========== */
.image-modal {
  display: none;
  position: fixed;
  z-index: 9999;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.9);
  align-items: center;
  justify-content: center;
  padding: 2rem;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 2rem;
  color: #ffffff;
  font-size: 3rem;
  font-weight: 300;
  cursor: pointer;
  transition: color 0.3s ease;
  z-index: 10000;
}

.modal-close:hover,
.modal-close:focus {
  color: #f59e0b;
}

.modal-content {
  max-width: 90%;
  max-height: 85%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 0.5rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  animation: zoomIn 0.3s ease;
}

@keyframes zoomIn {
  from {
    transform: scale(0.8);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.modal-caption {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  color: #ffffff;
  background-color: rgba(0, 0, 0, 0.7);
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  font-size: 1rem;
  font-weight: 500;
  text-align: center;
}

@media (max-width: 640px) {
  .modal-close {
    top: 0.5rem;
    right: 1rem;
    font-size: 2.5rem;
  }

  .modal-content {
    max-width: 95%;
    max-height: 80%;
  }

  .image-modal {
    padding: 1rem;
  }

  .modal-caption {
    bottom: 1rem;
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
  }
}

/* ========== コード解説セクション ========== */
.code-explanation-section {
  margin-top: 2rem;
  padding: 1.5rem;
  background-color: #f9fafb;
  border-radius: 0.75rem;
  border: 1px solid #e5e7eb;
}

.code-explanation-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #1f2937;
  margin-bottom: 0.75rem;
}

.code-explanation-intro {
  font-size: 0.95rem;
  color: #4b5563;
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.explanation-parts {
  display: grid;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.explanation-part {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  background-color: #ffffff;
  border-radius: 0.5rem;
  border: 1px solid #e5e7eb;
}

.part-number {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #3b82f6;
  color: #ffffff;
  font-weight: 700;
  font-size: 1rem;
  border-radius: 50%;
}

.part-content {
  flex: 1;
}

.part-title {
  font-size: 1rem;
  font-weight: 600;
  color: #1f2937;
  margin-bottom: 0.5rem;
}

.part-description {
  font-size: 0.875rem;
  color: #6b7280;
  line-height: 1.6;
}

.part-description code {
  background-color: #f3f4f6;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  font-size: 0.875rem;
  color: #1f2937;
  font-family: 'Courier New', monospace;
}

.code-explanation-summary {
  font-size: 0.95rem;
  color: #374151;
  line-height: 1.6;
  padding: 1rem;
  background-color: #dbeafe;
  border-left: 4px solid #3b82f6;
  border-radius: 0.25rem;
}

.code-explanation-summary strong {
  color: #1e40af;
  font-weight: 600;
}

@media (max-width: 640px) {
  .explanation-part {
    flex-direction: column;
    gap: 0.75rem;
  }

  .part-number {
    width: 1.75rem;
    height: 1.75rem;
    font-size: 0.875rem;
  }
}
