/*
 * Shared CSS for Parsons problem exercises
 * Used alongside shared.css
 */

/* Override body for scrollable layout */
body { overflow: auto; height: auto; min-height: 100vh; }

/* Parsons body wrapper (for fullscreen scaling) */
.parsons-body { flex: 1; overflow-y: auto; }

/* Task description */
.task-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}
.task-title {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.task-goal {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-dim);
  background: var(--node-bg);
  border: 1px solid var(--node-border);
  border-radius: 6px;
  padding: 8px 12px;
  display: inline-block;
}
.task-goal code {
  color: var(--accent);
  font-weight: 500;
}

/* Drop zone */
.drop-zone {
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.drop-zone-label {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dimmest);
  margin-bottom: 8px;
}

/* Drop slot row – line number + dashed area side by side */
.drop-slot-row {
  display: flex;
  align-items: center;
  gap: 0;
}

/* Placeholder slots */
.drop-slot {
  min-height: 40px;
  border: 1.5px dashed var(--border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  flex: 1;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.drop-slot.drag-over {
  border-color: var(--accent-border);
  background: var(--accent-bg);
}
.drop-slot .code-line {
  margin: 0;
  flex: 1;
}

/* Line number labels – outside the draggable area */
.line-label {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  color: var(--text-dimmest);
  width: 28px;
  min-width: 28px;
  text-align: right;
  padding-right: 8px;
  user-select: none;
  flex-shrink: 0;
}

/* Source area */
.source-area {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}
.source-area-label {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dimmest);
  margin-bottom: 8px;
}

/* Tabs (Kodelinjer / Konsoll) */
.source-area-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.source-tab {
  background: transparent;
  border: none;
  padding: 8px 12px;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dimmest);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.source-tab:hover { color: var(--text-dim); }
.source-tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.source-lines-pool {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 40px;
}
.source-lines-pool.hidden { display: none; }

/* Console panel (hidden until switched to Konsoll tab) */
.console-panel {
  display: none;
  flex-direction: column;
  gap: 2px;
  min-height: 40px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  line-height: 1.6;
  padding: 8px 16px;
  background: var(--bg-source);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
}
.console-panel.visible { display: flex; }
.console-line { white-space: pre-wrap; word-break: break-word; }
.console-line.error {
  color: #e57373;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.console-line-text { flex: 1; min-width: 0; }

/* "?" hint button next to error lines */
.console-help {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  padding: 0;
  background: rgba(229,115,115,0.15);
  color: #e57373;
  border: 1px solid rgba(229,115,115,0.4);
  border-radius: 50%;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.console-help:hover { background: rgba(229,115,115,0.3); border-color: rgba(229,115,115,0.7); }

/* Popup shown when "?" is clicked */
.console-hint-popup {
  position: fixed;
  z-index: 100;
  max-width: 280px;
  padding: 10px 12px;
  background: var(--bg-source);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.35);
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text);
}
.console-empty {
  color: var(--text-dimmest);
  font-style: italic;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
}

/* Source line wrapper – label + draggable code-line */
.source-line-wrapper {
  display: flex;
  align-items: center;
  gap: 0;
}
/* Fade label when code-line has been moved away */
.source-line-wrapper.empty .line-label {
  opacity: 0.25;
  transition: opacity 0.3s ease;
}

/* Draggable code lines */
.code-line {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  line-height: 1.6;
  padding: 8px 16px;
  background: var(--bg-source);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: grab;
  user-select: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease,
              opacity 0.15s ease, background 0.2s ease, border-color 0.2s ease;
  position: relative;
}
.code-line:hover {
  border-color: var(--accent-border);
  background: var(--accent-bg);
}
.code-line:active, .code-line.dragging {
  cursor: grabbing;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  z-index: 10;
  opacity: 0.9;
}
.code-line.drag-ghost { opacity: 0.3; }

/* Controls – sticky at bottom, never scrolls away */
.parsons-controls {
  background: var(--bg-controls);
  border-top: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  bottom: 0;
  z-index: 10;
  flex-shrink: 0;
}
.controls-left { display: flex; align-items: center; gap: 12px; }
.controls-right { display: flex; gap: 8px; }

/* Feedback */
.feedback {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  color: var(--text-dim);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.feedback.visible { opacity: 1; }
.feedback.correct { color: var(--accent); }
.feedback.incorrect { color: #e57373; }

/* Line states after check */
.code-line.correct-line {
  border-color: var(--accent-border);
  background: var(--accent-bg);
}
.code-line.correct-line::after {
  content: '✓';
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
}
.code-line.incorrect-line {
  border-color: rgba(229,115,115,0.5);
  background: rgba(229,115,115,0.1);
}
.code-line.incorrect-line::after {
  content: '✗';
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  font-weight: 700;
  color: #e57373;
}

/* Feedback bar */
.feedback-bar {
  display: none;
  padding: 10px 24px;
  text-align: center;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.3s ease;
}
.feedback-bar.visible { display: block; }
.feedback-bar.correct {
  background: var(--accent-bg);
  border-top: 2px solid var(--accent-border);
  color: var(--accent);
}
.feedback-bar.incorrect {
  background: rgba(229,115,115,0.08);
  border-top: 2px solid rgba(229,115,115,0.4);
  color: #e57373;
}

/* Zoom controls – fixed in viewport, never scrolls */
.zoom-controls {
  display: flex;
  flex-direction: row;
  position: fixed;
  bottom: 62px;
  right: 12px;
  z-index: 20;
}
:fullscreen .zoom-controls, .is-fullscreen .zoom-controls { bottom: 60px; }

/* Touch / mobile */
@media (pointer: coarse) {
  .code-line { padding: 12px 16px; font-size: 14px; -webkit-touch-callout: none; }
  .drop-slot { min-height: 48px; }
  .task-header { padding: 16px 16px 12px; }
  .drop-zone { padding: 12px 16px; }
  .source-area { padding: 12px 16px; }
  .parsons-controls { padding: 10px 16px; }
}

/* Fullscreen scaling */
:fullscreen body, .is-fullscreen body { height: 100%; }
:fullscreen .parsons-body, .is-fullscreen .parsons-body { flex: 1; min-height: 0; }
:fullscreen .task-title, .is-fullscreen .task-title { font-size: 20px; }
:fullscreen .task-goal, .is-fullscreen .task-goal { font-size: 16px; padding: 12px 16px; }
:fullscreen .code-line, .is-fullscreen .code-line { font-size: 18px; padding: 12px 20px; }
:fullscreen .line-label, .is-fullscreen .line-label { font-size: 14px; width: 34px; min-width: 34px; }
:fullscreen .drop-slot, .is-fullscreen .drop-slot { min-height: 52px; }
:fullscreen .drop-zone, .is-fullscreen .drop-zone { gap: 6px; padding: 24px 36px; }
:fullscreen .source-area, .is-fullscreen .source-area { padding: 24px 36px; }
:fullscreen .source-lines-pool, .is-fullscreen .source-lines-pool { gap: 6px; }
:fullscreen .feedback, .is-fullscreen .feedback { font-size: 16px; }
:fullscreen .parsons-controls, .is-fullscreen .parsons-controls { padding: 16px 36px; }
:fullscreen .drop-zone-label, .is-fullscreen .drop-zone-label,
:fullscreen .source-area-label, .is-fullscreen .source-area-label { font-size: 13px; }
:fullscreen .source-tab, .is-fullscreen .source-tab { font-size: 13px; padding: 10px 14px; }
:fullscreen .console-panel, .is-fullscreen .console-panel { font-size: 18px; padding: 12px 20px; }
:fullscreen .console-empty, .is-fullscreen .console-empty { font-size: 16px; }
