/* Additional custom styles for CS Quest */

:root {
  --site-bg: #ffffff;
  --surface-bg: #ffffff;
  --surface-muted: #f8fafc;
  --surface-strong: #f1f5f9;
  --text-primary: #1f2937;
  --text-contrast: #ffffff;
  --border-muted: #e2e8f0;
  --accent-primary: #6366f1;
  --accent-secondary: #ec4899;
  --hero-bg: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --castle-iron: #525968;
  --castle-brick: #8b3f3f;
  --castle-gold: #b69253;
}

[data-theme="castle"] {
  --site-bg: #d9d6cf;
  --surface-bg: #f3f1ec;
  --surface-muted: #e6e2da;
  --surface-strong: #d6d0c5;
  --text-primary: #2e3138;
  --text-contrast: #f7f4ee;
  --border-muted: #8f8172;
  --accent-primary: #6f7684;
  --accent-secondary: #8b3f3f;
  --hero-bg: linear-gradient(135deg, #6f7684 0%, #8b3f3f 100%);
  --castle-iron: #4f5767;
  --castle-brick: #7f3a3a;
  --castle-gold: #b89a5d;
}

html,
body {
  background: var(--site-bg);
  color: var(--text-primary);
}

body {
  font-family: 'Poppins', sans-serif;
}

.page-columns,
.page-layout-article,
main.content,
.content {
  color: var(--text-primary);
}

#theme-switch-wrapper {
  display: flex;
  align-items: center;
}

.theme-switch-control {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(0, 0, 0, 0.12);
}

.theme-switch-control .form-check-input {
  margin: 0;
  cursor: pointer;
}

.theme-switch-label,
.theme-switch-icon {
  color: #ffffff;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1;
}

/* Hero section styling */
.hero {
  background: var(--hero-bg);
  color: var(--text-contrast);
  padding: 4rem 2rem;
  border-radius: 1rem;
  margin-bottom: 2rem;
  text-align: center;
}

.hero h1 {
  font-size: 3rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.hero p {
  font-size: 1.3rem;
  opacity: 0.95;
}

[data-theme="castle"] .hero {
  border: 2px solid rgba(255, 255, 255, 0.28);
  background-image:
    linear-gradient(135deg, rgba(255, 255, 255, 0.05), rgba(0, 0, 0, 0.1)),
    var(--hero-bg);
  position: relative;
}

[data-theme="castle"] .hero::before {
  content: "⚔️  The Castle Quest  ⚔️";
  display: inline-block;
  margin-bottom: 1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.78rem;
  font-weight: 700;
  color: #f2e3c6;
}

/* Quest card grid */
.quest-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}

.quest-card {
  background: var(--surface-bg);
  border: 2px solid var(--border-muted);
  border-radius: 1rem;
  padding: 1.5rem;
  transition: all 0.3s ease;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.quest-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  border-color: var(--accent-primary);
}

[data-theme="castle"] .quest-card {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.55) 0%, rgba(255, 255, 255, 0.35) 100%),
    var(--surface-bg);
  border-color: #8d8275;
  border-radius: 0.8rem;
}

[data-theme="castle"] .quest-card:hover {
  border-color: var(--castle-brick);
  box-shadow: 0 14px 22px rgba(46, 49, 56, 0.22);
}

.quest-number {
  display: inline-block;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  color: white;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.2rem;
  margin-bottom: 1rem;
}

/* Code blocks */
pre {
  background: #1e293b !important;
  border-radius: 0.5rem;
  padding: 1rem;
  margin: 1rem 0;
  border: 2px solid #334155;
}

code {
  font-family: 'Fira Code', monospace;
}

/* Pyodide/Shinylive interactive elements */
.pyodide-cell {
  margin: 1.5rem 0;
  border: 2px solid var(--accent-primary);
  border-radius: 0.5rem;
  overflow: hidden;
}

.run-button {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  font-weight: 600;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s ease;
}

.run-button:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

[data-theme="castle"] .run-button {
  background: linear-gradient(135deg, var(--castle-iron), var(--castle-brick));
  border: 1px solid rgba(255, 255, 255, 0.2);
}

[data-theme="castle"] .run-button:hover {
  box-shadow: 0 6px 14px rgba(79, 87, 103, 0.45);
}

/* Progress indicators */
.progress-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  background: #10b981;
  color: white;
  border-radius: 1rem;
  font-size: 0.85rem;
  font-weight: 600;
}

/* Mobile responsive */
@media (max-width: 768px) {
  .hero h1 {
    font-size: 2rem;
  }
  
  .hero p {
    font-size: 1.1rem;
  }
  
  .quest-grid {
    grid-template-columns: 1fr;
  }
}

/* Animation for code execution */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.executing {
  animation: pulse 1s ease-in-out infinite;
}

/* QR code section */
.qr-code-section {
  text-align: center;
  padding: 2rem;
  background: var(--surface-muted);
  border-radius: 1rem;
  margin: 2rem 0;
}

/* Highlight boxes */
.highlight-box {
  padding: 1rem;
  margin: 1rem 0;
  border-radius: 0.5rem;
  border-left: 4px solid;
}

.highlight-info {
  background: #dbeafe;
  border-color: var(--accent-primary);
}

.highlight-success {
  background: #d1fae5;
  border-color: #10b981;
}

.highlight-warning {
  background: #fef3c7;
  border-color: #f59e0b;
}

[data-theme="castle"] .navbar,
[data-theme="castle"] .navbar-dark {
  background: linear-gradient(90deg, #4e535d 0%, #6d3a3a 100%) !important;
  box-shadow: inset 0 -3px 0 rgba(255, 255, 255, 0.12), 0 3px 10px rgba(46, 49, 56, 0.22);
}

[data-theme="castle"] .navbar-brand,
[data-theme="castle"] .navbar .nav-link,
[data-theme="castle"] .navbar .navbar-nav .nav-link,
[data-theme="castle"] .navbar .navbar-nav .show > .nav-link {
  color: #ffffff !important;
}

[data-theme="castle"] .navbar .nav-link:hover,
[data-theme="castle"] .navbar .navbar-nav .nav-link:hover {
  color: #ffffff !important;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 0.4rem;
}

[data-theme="castle"] .navbar .nav-link.active,
[data-theme="castle"] .navbar .navbar-nav .nav-link.active,
[data-theme="castle"] .navbar .navbar-nav .show > .nav-link {
  color: #ffffff !important;
  background: rgba(255, 255, 255, 0.24);
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 0.45rem;
}

[data-theme="castle"] .sidebar,
[data-theme="castle"] #quarto-sidebar,
[data-theme="castle"] .quarto-sidebar {
  background: var(--surface-strong);
  border-right: 1px solid var(--border-muted);
}

[data-theme="castle"] body {
  background-image:
    radial-gradient(circle at 12% 14%, rgba(255, 255, 255, 0.18), transparent 34%),
    linear-gradient(0deg, rgba(79, 87, 103, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(79, 87, 103, 0.08) 1px, transparent 1px);
  background-size: auto, 28px 28px, 28px 28px;
}

[data-theme="castle"] h1,
[data-theme="castle"] h2,
[data-theme="castle"] h3,
[data-theme="castle"] h4 {
  color: #3e424b;
  letter-spacing: 0.015em;
}

[data-theme="castle"] h1,
[data-theme="castle"] h2 {
  border-bottom: 2px solid rgba(127, 58, 58, 0.35);
  padding-bottom: 0.2rem;
}

[data-theme="castle"] a {
  color: var(--castle-brick);
}

[data-theme="castle"] a:hover {
  color: #5f2a2a;
}

[data-theme="castle"] .theme-switch-control {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.5);
}

[data-theme="castle"] .theme-switch-label {
  color: #f3ead9;
}

[data-theme="castle"] .hero,
[data-theme="castle"] .quest-card,
[data-theme="castle"] .highlight-box,
[data-theme="castle"] .tip-box,
[data-theme="castle"] .story-box,
[data-theme="castle"] .concept-box,
[data-theme="castle"] .challenge-box,
[data-theme="castle"] .solution-box,
[data-theme="castle"] .qr-code-section {
  box-shadow: 0 6px 16px rgba(46, 49, 56, 0.15);
}

[data-theme="castle"] .highlight-box {
  background: #ded8cf;
}

[data-theme="castle"] .highlight-info {
  background: #d5d8df;
  border-color: #6f7684;
}

[data-theme="castle"] .highlight-success {
  background: #d4dbd1;
  border-color: #667564;
}

[data-theme="castle"] .highlight-warning {
  background: #e3d8c8;
  border-color: #8e6e4e;
}

[data-theme="castle"] .tip-box {
  background: #d7d4db;
  border-left: 4px solid #6f7684;
}

[data-theme="castle"] .story-box,
[data-theme="castle"] .concept-box,
[data-theme="castle"] .challenge-box,
[data-theme="castle"] .solution-box {
  border-radius: 0.7rem;
  border-left-width: 6px;
}

[data-theme="castle"] .quest-badge,
[data-theme="castle"] .progress-badge {
  background: linear-gradient(135deg, var(--castle-iron), var(--castle-gold));
  color: #fffaf0;
}
