/* ==========================================================================
   Adventure (運算思維大冒險) — Assessment System Stylesheet
   Depends on /css/main.css for shared design tokens.
   ========================================================================== */

.adventure-shell {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

/* ---------- Header ---------- */
.adventure-header {
  background: linear-gradient(135deg, #56ab2f 0%, #1e8449 55%, #0d6b3d 100%);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}
.adventure-header .pill {
  background: rgba(255, 255, 255, 0.18);
}
.adventure-header h1 {
  font-size: 2rem;
  font-weight: 900;
  margin: 8px 0 6px;
}
.adventure-header p {
  margin: 0;
  opacity: 0.92;
  max-width: 60ch;
}
.adventure-header .floating-icon {
  position: absolute;
  right: -20px;
  bottom: -24px;
  font-size: 10rem;
  opacity: 0.08;
  transform: rotate(-12deg);
}

/* ---------- Problem selector ---------- */
.problem-toolbar {
  background: #fff;
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 20px;
}
.problem-toolbar select {
  min-width: 320px;
  max-width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--gray-200);
  font-size: 0.95rem;
  font-family: inherit;
}
.mode-switch {
  display: inline-flex;
  gap: 6px;
  background: var(--gray-100);
  padding: 4px;
  border-radius: 999px;
}
.mode-switch button {
  border: none;
  background: transparent;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 700;
  color: var(--gray-500);
  font-family: inherit;
  transition: background 0.15s ease, color 0.15s ease;
}
.mode-switch button.active {
  background: #fff;
  color: var(--brand-700);
  box-shadow: var(--shadow-sm);
}
.mode-switch button[data-mode="scratch"].active {
  color: #b45309;
}
.mode-switch button[data-mode="python"].active {
  color: #1e40af;
}

/* ---------- Problem card ---------- */
.problem-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-100);
  margin-top: 16px;
}
.problem-card h2 {
  margin: 0 0 8px;
  font-size: 1.25rem;
  font-weight: 800;
}
.problem-meta {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.difficulty-badge {
  background: var(--brand-50);
  color: var(--brand-700);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
}
.difficulty-badge.d-1 { background: #ecfdf5; color: #047857; }
.difficulty-badge.d-2 { background: #eff6ff; color: #1d4ed8; }
.difficulty-badge.d-3 { background: #fef3c7; color: #b45309; }
.difficulty-badge.d-4 { background: #fee2e2; color: #b91c1c; }
.difficulty-badge.d-5 { background: #ede9fe; color: #6d28d9; }
.tag-list { display: flex; gap: 6px; flex-wrap: wrap; }
.tag {
  background: var(--gray-100);
  color: var(--gray-700);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
}
.example-block {
  background: var(--gray-50);
  border-radius: 10px;
  padding: 12px 14px;
  margin-top: 12px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--gray-700);
}
.example-block .row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ---------- Workspace layout ---------- */
.workspace-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-top: 20px;
}
.workspace-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 16px 18px 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-100);
  min-height: 620px;
  display: flex;
  flex-direction: column;
}
.workspace-title {
  font-weight: 800;
  margin: 0 0 10px;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 10px;
}
#blocklyDiv {
  flex: 1;
  min-height: 560px;
  border-radius: 12px;
  background: var(--gray-50);
  border: 1px dashed var(--gray-200);
}
#pythonEditor {
  flex: 1;
  min-height: 560px;
  background: #0f172a;
  color: #e2e8f0;
  border: 1px solid #1e293b;
  border-radius: 12px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 15px;
  padding: 16px;
  box-sizing: border-box;
  resize: vertical;
  outline: none;
  line-height: 1.6;
}

/* ---------- Control panel ---------- */
.control-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #fff;
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-100);
  min-height: 620px;
}
.control-panel h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
}
.control-panel .btn {
  justify-content: flex-start;
  gap: 10px;
  width: 100%;
}
.control-panel .btn-primary,
.control-panel .btn-success,
.control-panel .btn-danger,
.control-panel .btn-secondary { width: 100%; }
.btn-success {
  background: linear-gradient(135deg, var(--success-500), var(--success-600));
  color: #fff;
  box-shadow: var(--shadow);
}
.btn-warning {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
}

/* ---------- Result / Judge panel ---------- */
.result-panel,
.judge-panel {
  background: var(--gray-50);
  border-radius: 12px;
  border: 1px solid var(--gray-100);
  padding: 12px 14px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 0.88rem;
  white-space: pre-wrap;
  min-height: 60px;
  color: var(--gray-800);
}
.judge-panel { margin-top: 16px; }
.test-result {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--gray-200);
  margin: 6px 0;
  font-family: inherit;
  font-size: 0.9rem;
}
.test-result.pass { border-left: 4px solid var(--success-500); }
.test-result.fail { border-left: 4px solid var(--danger-500); }
.status-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
}
.status-dot.pass { background: var(--success-500); }
.status-dot.fail { background: var(--danger-500); }
.judge-summary {
  text-align: center;
  font-weight: 900;
  padding: 10px;
  margin-top: 10px;
}
.judge-summary.pass { color: var(--success-600); }
.judge-summary.fail { color: var(--danger-600); }

/* ---------- Auth gate ---------- */
.adventure-gate {
  max-width: 560px;
  margin: 48px auto 0;
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 32px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--gray-100);
}
.adventure-gate h2 {
  margin: 8px 0 6px;
  font-size: 1.4rem;
  font-weight: 900;
}
.adventure-gate p {
  color: var(--gray-600);
  margin-bottom: 20px;
}

/* ---------- Progress table ---------- */
.progress-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: var(--radius);
  overflow: hidden;
}
.progress-table th,
.progress-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--gray-100);
  font-size: 0.92rem;
}
.progress-table th {
  background: var(--gray-50);
  font-weight: 800;
  color: var(--gray-700);
}
.progress-table tr:last-child td { border-bottom: none; }
.progress-table td.status.pass { color: var(--success-600); font-weight: 700; }
.progress-table td.status.fail { color: var(--danger-600); font-weight: 700; }

/* ---------- Leaderboard ---------- */
.leaderboard-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-100);
  margin-top: 20px;
}
.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
}
.leaderboard-table th {
  background: var(--gray-50);
  padding: 12px;
  text-align: left;
  font-weight: 800;
  color: var(--gray-700);
}
.leaderboard-table td {
  padding: 12px;
  border-top: 1px solid var(--gray-100);
}
.leaderboard-table .rank-1 { color: #b45309; font-weight: 900; font-size: 1.1rem; }
.leaderboard-table .rank-2 { color: #6b7280; font-weight: 900; }
.leaderboard-table .rank-3 { color: #9a3412; font-weight: 800; }

/* ---------- Admin problem list ---------- */
.assessment-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 20px 0 12px;
}
.assessment-toolbar input[type="search"] {
  min-width: 260px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--gray-200);
  font-family: inherit;
  font-size: 0.95rem;
}
.assessment-list {
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--gray-100);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.assessment-row {
  display: grid;
  grid-template-columns: 200px 1.6fr 120px 140px 100px 140px;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-100);
  align-items: center;
  font-size: 0.9rem;
}
.assessment-row.header {
  background: var(--gray-50);
  font-weight: 800;
  color: var(--gray-700);
  font-size: 0.85rem;
}
.assessment-row:last-child { border-bottom: none; }
.assessment-row .actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}
.assessment-row .actions .btn {
  padding: 6px 10px;
  font-size: 0.82rem;
}

/* ---------- Editor form ---------- */
.editor-tabs {
  display: inline-flex;
  gap: 4px;
  background: var(--gray-100);
  padding: 4px;
  border-radius: 999px;
  margin-bottom: 12px;
}
.editor-tabs button {
  border: none;
  background: transparent;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 700;
  color: var(--gray-500);
  font-family: inherit;
}
.editor-tabs button.active {
  background: #fff;
  color: var(--brand-700);
  box-shadow: var(--shadow-sm);
}
.testcase-block {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  padding: 14px;
  margin: 10px 0;
}
.testcase-block .row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.testcase-block .row-full { grid-column: span 2; }
.testcase-block label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--gray-600);
}
.testcase-block input,
.testcase-block textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 0.88rem;
}
.import-preview {
  background: var(--gray-50);
  border-radius: 12px;
  border: 1px dashed var(--gray-300);
  padding: 16px;
  max-height: 380px;
  overflow: auto;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 0.85rem;
  white-space: pre-wrap;
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .workspace-layout { grid-template-columns: 1fr; }
  .assessment-row { grid-template-columns: 1fr; gap: 6px; }
  .assessment-row.header { display: none; }
  .assessment-row .actions { justify-content: flex-start; }
}
@media (max-width: 640px) {
  .adventure-header { padding: 20px 18px; }
  .adventure-header h1 { font-size: 1.4rem; }
  .problem-toolbar select { min-width: 100%; }
}


/* Adventure fixes 2026-07-13 */
body[data-page^="adventure"] .site-nav { position: relative; z-index: 120; }
body[data-page^="adventure"] .site-nav-inner { position: relative; z-index: 121; }
.workspace-card { overflow: hidden; }
#blocklyDiv { position: relative; z-index: 1; overflow: hidden; }
.blocklyDropDownDiv, .blocklyWidgetDiv, .blocklyTooltipDiv { z-index: 40 !important; }
.blocklyToolboxDiv, .blocklyFlyout { z-index: 20 !important; }
.assessment-row .actions { flex-wrap: wrap; }
.assessment-row .actions .btn-danger { white-space: nowrap; }
@media (max-width: 1100px) { .assessment-row .actions .btn { width: auto; } }
