/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;700&display=swap');

:root {
  --bg-color: #0f172a;
  --text-main: #e2e8f0;
  --text-muted: #94a3b8;
  --primary: #3b82f6;
  --secondary: #10b981;
  --quiz-accent: #f59e0b;
  --card-bg: rgba(30, 41, 59, 0.7);
  --card-border: rgba(255, 255, 255, 0.1);
  --glass-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Outfit', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  /* Mobile Default: Stacked */
  min-height: 100vh;
  overflow-x: hidden;
  /* Prevent horizontal scroll */
}

/* Sidebar (Mobile Header) */
.sidebar {
  width: 100%;
  background: rgba(15, 23, 42, 0.95);
  border-bottom: 1px solid var(--card-border);
  /* Separator for mobile */
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  flex-shrink: 0;
  /* Don't shrink */
}

.logo-area h1 {
  font-size: 1.5rem;
  background: linear-gradient(45deg, var(--primary), var(--secondary));
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 0.2rem;
}

.control-group label {
  display: block;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  font-weight: 600;
}

/* Slider Customization */
input[type=range] {
  width: 100%;
  accent-color: var(--primary);
  margin-bottom: 0.5rem;
  height: 24px;
  /* Touchable height */
}

.level-indicator {
  font-size: 0.9rem;
  color: var(--primary);
  font-weight: bold;
  text-align: center;
}

/* Mode Switcher */
.mode-switch {
  display: flex;
  background: rgba(255, 255, 255, 0.05);
  padding: 0.25rem;
  border-radius: 0.5rem;
}

.mode-btn {
  flex: 1;
  border: none;
  background: none;
  color: var(--text-muted);
  padding: 0.75rem;
  /* Larger touch target */
  cursor: pointer;
  border-radius: 0.25rem;
  transition: all 0.3s ease;
  font-weight: 600;
  font-size: 1rem;
}

.mode-btn.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Main Content */
.main-content {
  flex: 1;
  padding: 1.5rem;
  position: relative;
  width: 100%;
}

.main-content::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle at 10% 20%, rgba(59, 130, 246, 0.15) 0%, transparent 20%),
    radial-gradient(circle at 90% 80%, rgba(16, 185, 129, 0.15) 0%, transparent 20%);
  pointer-events: none;
  z-index: -1;
}

.section {
  display: none;
  max-width: 100%;
  /* Full width on mobile */
  margin: 0 auto;
  animation: fadeIn 0.5s ease-out;
}

.section.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Learning Cards */
.scenario-box {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(59, 130, 246, 0.05));
  border: 1px solid rgba(59, 130, 246, 0.2);
  padding: 1.25rem;
  border-radius: 1rem;
  margin-bottom: 2rem;
  border-left: 4px solid var(--primary);
}

.layer-card {
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  border: 1px solid var(--card-border);
  border-radius: 1rem;
  margin-bottom: 1.5rem;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: var(--glass-shadow);
}

/* Disabled hover on touch devices usually, keeping for consistency */
.layer-card:hover {
  border-color: rgba(255, 255, 255, 0.2);
}

.layer-header {
  padding: 1rem 1.25rem;
  background: rgba(255, 255, 255, 0.03);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--card-border);
  flex-wrap: wrap;
  /* Allow wrapping on very small screens */
  gap: 0.5rem;
}

.layer-num {
  font-weight: 700;
  color: var(--primary);
  font-size: 1.1rem;
  margin-right: 0.5rem;
}

.layer-content {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  /* Stacked content on mobile */
  gap: 1.5rem;
}

.layer-info h3 {
  font-size: 0.9rem;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  margin-top: 1rem;
}

.layer-info h3:first-child {
  margin-top: 0;
}

.example-box {
  background: rgba(16, 185, 129, 0.1);
  padding: 1rem;
  border-radius: 0.5rem;
  border-left: 3px solid var(--secondary);
  font-size: 0.95rem;
}

code {
  background: rgba(0, 0, 0, 0.3);
  padding: 0.2rem 0.4rem;
  border-radius: 0.3rem;
  font-family: 'Courier New', monospace;
  font-size: 0.9em;
  color: #fbbf24;
  word-break: break-word;
  /* Handle long codes on mobile */
}

/* Quiz Styles */
.quiz-header {
  display: flex;
  flex-direction: column;
  /* Stacked header on mobile */
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 2rem;
}

.score-badge {
  background: var(--quiz-accent);
  color: black;
  padding: 0.5rem 1rem;
  border-radius: 2rem;
  font-weight: bold;
  align-self: flex-start;
}

.question-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  padding: 1.5rem;
  border-radius: 1rem;
}

.question-text {
  font-size: 1.15rem;
  margin-bottom: 1.5rem;
  font-weight: 600;
}

.option-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.option-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
  padding: 1rem;
  /* Good touch target */
  border-radius: 0.5rem;
  color: var(--text-main);
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
}

.option-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--primary);
}

.option-btn.selected {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.2);
}

.option-btn.correct {
  border-color: var(--secondary);
  background: rgba(16, 185, 129, 0.2);
}

.option-btn.wrong {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.2);
}

.feedback-area {
  margin-top: 1.5rem;
  padding: 1rem;
  border-radius: 0.5rem;
  animation: fadeIn 0.3s;
}

.feedback-correct {
  background: rgba(16, 185, 129, 0.1);
  color: var(--secondary);
  border: 1px solid var(--secondary);
}

.feedback-wrong {
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
  border: 1px solid #ef4444;
}

.btn-primary {
  background: var(--primary);
  color: white;
  border: none;
  padding: 1rem 1.5rem;
  /* Larger touch area */
  border-radius: 0.5rem;
  cursor: pointer;
  font-weight: 600;
  margin-top: 1.5rem;
  width: 100%;
}

.btn-primary:active {
  transform: scale(0.98);
}

/* Utils */
.hidden {
  display: none !important;
}

/* Interactive Elements */
.interactive-item {
  cursor: pointer;
  border-bottom: 1px dashed var(--text-muted);
  transition: all 0.2s;
  margin-right: 0.5rem;
  display: inline-block;
  padding: 2px 0;
  /* Slight padding for touch */
}

.interactive-item:hover {
  color: var(--primary);
  border-bottom: 1px solid var(--primary);
}

.interactive-item.hardware {
  color: #e0f2fe;
}

.interactive-item.protocol {
  font-family: 'Courier New', monospace;
  background: rgba(0, 0, 0, 0.2);
  padding: 2px 6px;
  border-radius: 4px;
  color: #fce7f3;
  border-bottom: none;
}

.interactive-item.protocol:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Detail Views */
.detail-container {
  padding: 0 1.25rem 1.25rem 1.25rem;
  animation: slideDown 0.3s ease-out;
}

.detail-box {
  background: rgba(15, 23, 42, 0.8);
  border-top: 1px solid var(--card-border);
  border-radius: 0.5rem;
  padding: 1rem;
  margin-top: 0.5rem;
  position: relative;
}

.detail-box.hardware {
  border-left: 3px solid var(--primary);
}

.detail-box.protocols {
  border-left: 3px solid #f472b6;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
  color: var(--text-main);
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 2rem;
  /* Easy to tap */
  cursor: pointer;
  line-height: 1;
  padding: 0 0.5rem;
}

.close-btn:hover {
  color: white;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Glossary & Tooltips */
.glossary-term {
  border-bottom: 1px dotted var(--text-muted);
  cursor: help;
  position: relative;
  color: #a5f3fc;
  font-weight: 500;
}

.glossary-term:hover {
  color: var(--primary);
  border-bottom: 1px solid var(--primary);
}

/* Tooltip text (hidden on mobile mostly, simplified behavior) */
.glossary-term::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #e2e8f0;
  padding: 0.5rem 0.8rem;
  border-radius: 6px;
  font-size: 0.85rem;
  white-space: normal;
  width: max-content;
  max-width: 200px;
  /* Smaller max width for mobile */
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  border: 1px solid var(--card-border);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 100;
  margin-bottom: 5px;
  font-weight: normal;
  text-align: center;
}

.glossary-term:hover::after {
  opacity: 1;
}

/* AI Prompt Box */
.ai-prompt-box {
  margin-top: 1rem;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--card-border);
  border-radius: 6px;
  padding: 0.8rem;
  font-size: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ai-label {
  font-weight: bold;
  color: #fca5a5;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.prompt-text {
  font-family: 'Courier New', monospace;
  background: #0f172a;
  padding: 0.6rem;
  border-radius: 4px;
  color: #e2e8f0;
  user-select: all;
  border-left: 3px solid var(--primary);
  overflow-x: auto;
  /* Scroll if too wide on mobile */
}

/* Quiz Badges & Progress */
.quiz-progress {
  display: flex;
  flex-wrap: wrap;
  /* Wrap on mobile */
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  gap: 0.5rem;
}

.badge {
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: bold;
  color: #1e293b;
}

.badge-easy {
  background-color: #86efac;
}

.badge-medium {
  background-color: #fca5a5;
}

.badge-hard {
  background-color: #f87171;
  color: white;
  border: 1px solid #ef4444;
}

/* End Screen Summary */
.summary-list {
  margin: 2rem 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.summary-item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--card-border);
  padding: 1rem;
  border-radius: 0.5rem;
  font-size: 0.95rem;
}

.summary-item.summary-correct {
  border-left: 3px solid var(--secondary);
}

.summary-item.summary-wrong {
  border-left: 3px solid #ef4444;
}

.summary-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.5rem;
  gap: 1rem;
}

.summary-details {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.text-green {
  color: var(--secondary);
  font-weight: bold;
}

.text-red {
  color: #ef4444;
  font-weight: bold;
}

.summary-explanation {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px dashed rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
}

/* ------------------------------------------------------------------ */
/* DESKTOP OVERRIDES                                                  */
/* ------------------------------------------------------------------ */

@media (min-width: 768px) {
  body {
    flex-direction: row;
    /* Side-by-side */
    height: 100vh;
    overflow: hidden;
    /* Scroll in containers */
  }

  /* Sidebar Fixed Width */
  .sidebar {
    width: 300px;
    height: 100%;
    /* Full height */
    border-right: 1px solid var(--card-border);
    border-bottom: none;
    padding: 2rem;
    gap: 2rem;
    overflow-y: auto;
  }

  /* Main Content Area */
  .main-content {
    overflow-y: auto;
    /* Scroll inside main content */
    padding: 2rem;
  }

  .section {
    max-width: 1000px;
    /* Limit width for reading comfort */
  }

  .layer-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  }

  .layer-header {
    padding: 1rem 1.5rem;
  }

  .layer-content {
    display: grid;
    grid-template-columns: 2fr 1fr;
    /* Split layout for cards */
    gap: 2rem;
    padding: 1.5rem;
  }

  .quiz-header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .score-badge {
    align-self: center;
  }

  .question-card {
    padding: 2rem;
  }

  .question-text {
    font-size: 1.25rem;
  }

  .detail-container {
    padding: 0 1.5rem 1.5rem 1.5rem;
  }

  .close-btn {
    font-size: 1.5rem;
  }

  .glossary-term::after {
    max-width: 250px;
  }
}

/* Impressum Link */
.impressum-link {
  display: inline-block;
  margin-top: 0.5rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-decoration: none;
  border-bottom: 1px dotted var(--text-muted);
  transition: color 0.2s, border-bottom 0.2s;
}

.impressum-link:hover {
  color: var(--primary);
  border-bottom: 1px solid var(--primary);
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  padding: 1.5rem;
  border-radius: 1rem;
  box-shadow: var(--glass-shadow);
}