/**
 * Rust学習サイト カスタムスタイル
 */

/* ========================================
   進捗バッジ
   ======================================== */

#progress-badge {
  display: inline-block;
  margin-left: 12px;
  padding: 4px 10px;
  font-size: 0.7em;
  font-weight: bold;
  border-radius: 12px;
  vertical-align: middle;
}

.progress-partial {
  background-color: #fef3c7;
  color: #92400e;
}

.progress-complete {
  background-color: #d1fae5;
  color: #065f46;
}

/* ダークモード */
.navy #progress-badge.progress-partial,
.coal #progress-badge.progress-partial,
.ayu #progress-badge.progress-partial {
  background-color: #78350f;
  color: #fef3c7;
}

.navy #progress-badge.progress-complete,
.coal #progress-badge.progress-complete,
.ayu #progress-badge.progress-complete {
  background-color: #065f46;
  color: #d1fae5;
}

/* ========================================
   テストチェックボックス
   ======================================== */

.test-checkbox-container {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding: 12px 16px;
  background-color: #f3f4f6;
  border-radius: 8px;
  border-left: 4px solid #9ca3af;
  transition: all 0.2s ease;
}

.test-checkbox-container.checked {
  background-color: #d1fae5;
  border-left-color: #10b981;
}

.test-checkbox {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: #10b981;
}

.test-label {
  font-size: 0.95em;
  color: #374151;
  cursor: pointer;
  user-select: none;
}

/* ダークモード */
.navy .test-checkbox-container,
.coal .test-checkbox-container,
.ayu .test-checkbox-container {
  background-color: #1f2937;
}

.navy .test-checkbox-container.checked,
.coal .test-checkbox-container.checked,
.ayu .test-checkbox-container.checked {
  background-color: #064e3b;
}

.navy .test-label,
.coal .test-label,
.ayu .test-label {
  color: #d1d5db;
}

/* ========================================
   ダッシュボード
   ======================================== */

.dashboard-container {
  max-width: 900px;
  margin: 0 auto;
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
}

.dashboard-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.dashboard-btn {
  padding: 8px 16px;
  font-size: 0.9em;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: opacity 0.2s;
}

.dashboard-btn:hover {
  opacity: 0.85;
}

.btn-export {
  background-color: #3b82f6;
  color: white;
}

.btn-import {
  background-color: #8b5cf6;
  color: white;
}

.btn-reset {
  background-color: #ef4444;
  color: white;
}

/* 進捗カード */
.progress-card {
  background-color: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
}

.navy .progress-card,
.coal .progress-card,
.ayu .progress-card {
  background-color: #1f2937;
  border-color: #374151;
}

.progress-card h3 {
  margin-top: 0;
  margin-bottom: 16px;
  font-size: 1.2em;
}

/* 進捗バー */
.progress-bar-container {
  background-color: #e5e7eb;
  border-radius: 8px;
  height: 24px;
  overflow: hidden;
  margin-bottom: 8px;
}

.navy .progress-bar-container,
.coal .progress-bar-container,
.ayu .progress-bar-container {
  background-color: #374151;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #10b981, #059669);
  border-radius: 8px;
  transition: width 0.5s ease;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  color: white;
  font-size: 0.85em;
  font-weight: bold;
  min-width: fit-content;
}

.progress-text {
  color: #6b7280;
  font-size: 0.9em;
}

.navy .progress-text,
.coal .progress-text,
.ayu .progress-text {
  color: #9ca3af;
}

/* Phase別進捗 */
.phase-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.phase-card {
  background-color: #f9fafb;
  border-radius: 8px;
  padding: 16px;
}

.navy .phase-card,
.coal .phase-card,
.ayu .phase-card {
  background-color: #111827;
}

.phase-card h4 {
  margin-top: 0;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.phase-icon {
  font-size: 1.2em;
}

/* クイズリスト */
.quiz-list {
  list-style: none;
  padding: 0;
  margin: 12px 0 0 0;
  font-size: 0.9em;
}

.quiz-list li {
  padding: 6px 0;
  border-top: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.navy .quiz-list li,
.coal .quiz-list li,
.ayu .quiz-list li {
  border-top-color: #374151;
}

.quiz-list li:first-child {
  border-top: none;
}

.quiz-list a {
  text-decoration: none;
  color: inherit;
}

.quiz-list a:hover {
  text-decoration: underline;
}

.quiz-score {
  font-size: 0.85em;
  color: #6b7280;
  font-weight: 500;
}

.quiz-score.perfect {
  color: #10b981;
}

.navy .quiz-score,
.coal .quiz-score,
.ayu .quiz-score {
  color: #9ca3af;
}

.navy .quiz-score.perfect,
.coal .quiz-score.perfect,
.ayu .quiz-score.perfect {
  color: #34d399;
}

.progress-bar.complete {
  background: linear-gradient(90deg, #10b981, #34d399);
}

/* 統計テーブル */
.stats-table {
  width: 100%;
  border-collapse: collapse;
}

.stats-table th,
.stats-table td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid #e5e7eb;
}

.navy .stats-table th,
.navy .stats-table td,
.coal .stats-table th,
.coal .stats-table td,
.ayu .stats-table th,
.ayu .stats-table td {
  border-bottom-color: #374151;
}

.stats-table th {
  font-weight: 600;
  color: #6b7280;
}

.navy .stats-table th,
.coal .stats-table th,
.ayu .stats-table th {
  color: #9ca3af;
}

/* ========================================
   レスポンシブ
   ======================================== */

@media (max-width: 768px) {
  .dashboard-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .dashboard-actions {
    width: 100%;
  }

  .dashboard-btn {
    flex: 1;
    text-align: center;
  }

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

/* ========================================
   確認テスト詳細スタイル
   ======================================== */

details {
  margin-bottom: 16px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
}

.navy details,
.coal details,
.ayu details {
  border-color: #374151;
}

details summary {
  padding: 12px 16px;
  background-color: #f9fafb;
  cursor: pointer;
  font-weight: 500;
  list-style: none;
}

details summary::-webkit-details-marker {
  display: none;
}

details summary::before {
  content: '▶ ';
  font-size: 0.8em;
  margin-right: 8px;
  transition: transform 0.2s;
  display: inline-block;
}

details[open] summary::before {
  transform: rotate(90deg);
}

.navy details summary,
.coal details summary,
.ayu details summary {
  background-color: #1f2937;
}

details > *:not(summary):not(.test-checkbox-container) {
  padding: 16px;
}

/* ========================================
   ファイル入力の非表示
   ======================================== */

#import-input {
  display: none;
}

/* ========================================
   選択式クイズ
   ======================================== */

.quiz-container {
  margin: 24px 0;
  padding: 24px;
  background-color: #f9fafb;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
}

.navy .quiz-container,
.coal .quiz-container,
.ayu .quiz-container {
  background-color: #1f2937;
  border-color: #374151;
}

/* 問題 */
.quiz-question {
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid #e5e7eb;
}

.quiz-question:last-of-type {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.navy .quiz-question,
.coal .quiz-question,
.ayu .quiz-question {
  border-bottom-color: #374151;
}

.quiz-question-text {
  font-size: 1.1em;
  font-weight: 600;
  margin-bottom: 16px;
  color: #374151;
}

.navy .quiz-question-text,
.coal .quiz-question-text,
.ayu .quiz-question-text {
  color: #e5e7eb;
}

/* 選択肢 */
.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.quiz-option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 18px;
  text-align: left;
  background-color: white;
  border: 2px solid #d1d5db;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 1em;
  font-family: inherit;
  color: inherit;
}

.navy .quiz-option,
.coal .quiz-option,
.ayu .quiz-option {
  background-color: #374151;
  border-color: #4b5563;
  color: #e5e7eb;
}

.quiz-option:hover:not(:disabled) {
  border-color: #3b82f6;
  background-color: #eff6ff;
}

.navy .quiz-option:hover:not(:disabled),
.coal .quiz-option:hover:not(:disabled),
.ayu .quiz-option:hover:not(:disabled) {
  background-color: #1f2937;
  border-color: #60a5fa;
}

.quiz-option.selected {
  border-color: #3b82f6;
  background-color: #dbeafe;
}

.navy .quiz-option.selected,
.coal .quiz-option.selected,
.ayu .quiz-option.selected {
  border-color: #60a5fa;
  background-color: #1e3a5f;
}

.quiz-option.correct {
  border-color: #10b981 !important;
  background-color: #d1fae5 !important;
}

.navy .quiz-option.correct,
.coal .quiz-option.correct,
.ayu .quiz-option.correct {
  border-color: #34d399 !important;
  background-color: #064e3b !important;
}

.quiz-option.incorrect {
  border-color: #ef4444 !important;
  background-color: #fee2e2 !important;
}

.navy .quiz-option.incorrect,
.coal .quiz-option.incorrect,
.ayu .quiz-option.incorrect {
  border-color: #f87171 !important;
  background-color: #7f1d1d !important;
}

.quiz-option.show-correct:not(.selected) {
  border-color: #10b981;
  border-style: dashed;
}

.quiz-option:disabled {
  cursor: default;
  opacity: 0.9;
}

.option-label {
  font-weight: bold;
  color: #6b7280;
  min-width: 28px;
}

.navy .option-label,
.coal .option-label,
.ayu .option-label {
  color: #9ca3af;
}

.option-text {
  flex: 1;
}

/* 解説 */
.quiz-explanation {
  margin-top: 16px;
  padding: 16px;
  background-color: #ecfdf5;
  border-radius: 8px;
  border-left: 4px solid #10b981;
  font-size: 0.95em;
  line-height: 1.6;
}

.navy .quiz-explanation,
.coal .quiz-explanation,
.ayu .quiz-explanation {
  background-color: #064e3b;
  color: #d1fae5;
}

/* フッター */
.quiz-footer {
  margin-top: 24px;
  text-align: center;
}

.quiz-button {
  padding: 12px 24px;
  font-size: 1em;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.quiz-submit {
  background-color: #3b82f6;
  color: white;
}

.quiz-submit:hover:not(:disabled) {
  background-color: #2563eb;
}

.quiz-submit:disabled {
  background-color: #9ca3af;
  cursor: not-allowed;
}

.quiz-reset {
  background-color: #6b7280;
  color: white;
  margin-right: 12px;
}

.quiz-reset:hover {
  background-color: #4b5563;
}

/* 結果表示 */
.quiz-result {
  padding: 24px;
  background-color: white;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  margin-bottom: 16px;
}

.navy .quiz-result,
.coal .quiz-result,
.ayu .quiz-result {
  background-color: #374151;
  border-color: #4b5563;
}

.quiz-score {
  font-size: 1.3em;
  font-weight: bold;
  color: #1f2937;
  margin-bottom: 16px;
}

.quiz-score.perfect {
  color: #10b981;
}

.navy .quiz-score,
.coal .quiz-score,
.ayu .quiz-score {
  color: #f3f4f6;
}

.navy .quiz-score.perfect,
.coal .quiz-score.perfect,
.ayu .quiz-score.perfect {
  color: #34d399;
}

.quiz-actions {
  margin-bottom: 24px;
}

/* ========================================
   広告バナー
   ======================================== */

.affiliate-banner {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid #e5e7eb;
}

.navy .affiliate-banner,
.coal .affiliate-banner,
.ayu .affiliate-banner {
  border-top-color: #4b5563;
}

.affiliate-banner-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.affiliate-banner-container {
  transition: opacity 0.5s ease;
}

.affiliate-banner-container.fade-out {
  opacity: 0;
}

.affiliate-iframe {
  border: none;
  display: block;
  overflow: hidden;
}

.affiliate-banner-controls {
  display: flex;
  align-items: center;
  gap: 16px;
}

.affiliate-banner-nav {
  width: 32px;
  height: 32px;
  border: 1px solid #d1d5db;
  border-radius: 50%;
  background-color: white;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.navy .affiliate-banner-nav,
.coal .affiliate-banner-nav,
.ayu .affiliate-banner-nav {
  background-color: #374151;
  border-color: #4b5563;
  color: #e5e7eb;
}

.affiliate-banner-nav:hover {
  background-color: #f3f4f6;
  border-color: #9ca3af;
}

.navy .affiliate-banner-nav:hover,
.coal .affiliate-banner-nav:hover,
.ayu .affiliate-banner-nav:hover {
  background-color: #4b5563;
}

.affiliate-banner-indicator {
  font-size: 0.9em;
  color: #6b7280;
}

.navy .affiliate-banner-indicator,
.coal .affiliate-banner-indicator,
.ayu .affiliate-banner-indicator {
  color: #9ca3af;
}

/* ========================================
   クイズ レスポンシブ対応
   ======================================== */

@media (max-width: 600px) {
  .quiz-container {
    padding: 16px;
  }

  .quiz-option {
    padding: 12px 14px;
  }

  .affiliate-banner-wrapper {
    transform: scale(0.85);
    transform-origin: center;
  }
}

/* ========================================
   感謝メッセージ（広告正常表示時）
   ======================================== */

.affiliate-thanks {
  margin-top: 12px;
  font-size: 0.85em;
  color: #6b7280;
  text-align: center;
}

.navy .affiliate-thanks,
.coal .affiliate-thanks,
.ayu .affiliate-thanks {
  color: #9ca3af;
}

/* ========================================
   広告ブロック時のフォールバックバナー
   ======================================== */

.affiliate-fallback {
  padding: 20px 24px;
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border-radius: 12px;
  border: 2px dashed #f59e0b;
  max-width: 468px;
  margin: 0 auto;
}

.fallback-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  transition: opacity 0.5s ease;
}

.fallback-content.fade-out {
  opacity: 0;
}

.fallback-text {
  flex: 1;
  text-align: left;
}

.fallback-message {
  font-size: 1.1em;
  font-weight: 600;
  color: #92400e;
  margin: 0 0 8px 0;
  line-height: 1.4;
}

.fallback-note {
  font-size: 0.85em;
  color: #a16207;
  margin: 0;
}

.fallback-image {
  flex-shrink: 0;
}

.fallback-image img {
  display: block;
  width: 100px;
  height: auto;
}

.fallback-indicator {
  margin-top: 12px;
  font-size: 0.85em;
  color: #b45309;
  text-align: center;
}

/* ダークテーマ */
.navy .affiliate-fallback,
.coal .affiliate-fallback,
.ayu .affiliate-fallback {
  background: linear-gradient(135deg, #78350f 0%, #92400e 100%);
  border-color: #b45309;
}

.navy .fallback-message,
.coal .fallback-message,
.ayu .fallback-message {
  color: #fef3c7;
}

.navy .fallback-note,
.coal .fallback-note,
.ayu .fallback-note {
  color: #fde68a;
}

.navy .fallback-indicator,
.coal .fallback-indicator,
.ayu .fallback-indicator {
  color: #fcd34d;
}

/* フォールバック レスポンシブ */
@media (max-width: 600px) {
  .affiliate-fallback {
    padding: 16px;
    margin: 0 8px;
  }

  .fallback-content {
    flex-direction: column-reverse;
    text-align: center;
  }

  .fallback-text {
    text-align: center;
  }

  .fallback-image img {
    width: 80px;
  }

  .fallback-message {
    font-size: 1em;
  }
}
