/* 2-Stack PDA and DTM Equivalence Experiment Styles */

/* Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Inter', system-ui, sans-serif;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: #fff;
  color: #1e293b;
  line-height: 1.5;
  min-height: 100vh;
  padding: 15px;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
}

/* Quick Guide Styles */
.guide-container {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(0, 0, 0, 0.04);
  border-radius: 12px;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.05);
  padding: 8px;
  margin-bottom: 12px;
  transform: translateY(0);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.guide-container:hover {
  transform: translateY(-0.25rem);
  box-shadow: 0 1.25rem 2.5rem rgba(59, 130, 246, 0.08);
}

.guide-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.guide-header svg {
  color: #1e293b;
}

.guide-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: #1e293b;
}

.guide-steps {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
}

.guide-step {
  background: rgba(243, 244, 246, 0.7);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(0, 0, 0, 0.04);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 6px;
  width: 23%;
}

.step-number {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: white !important;
  font-size: 0.75rem;
}

/* Step number colors matching exp7/new exactly */
.step-number.blue {
  background: #3B82F6;
}

.step-number.green {
  background: #10B981;
}

.step-number.purple {
  background: #6366F1;
}

.step-number.red {
  background: #EF4444;
}

.step-text {
  font-size: 0.75rem;
  text-align: center;
  color: #1e293b;
  font-weight: 500;
}

/* Control Panel */
.control-panel {
  background: rgba(243, 244, 246, 0.7);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(0, 0, 0, 0.04);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.control-group:last-child {
  margin-bottom: 0;
}

.control-group label {
  font-weight: 600;
  color: #1e293b;
  font-size: 0.875rem;
  white-space: nowrap;
}

.control-group select {
  padding: 8px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: white;
  font-size: 0.875rem;
  color: #374151;
}

.control-btn {
  background: #fff;
  color: #374151;
  border: 1px solid #e5e7eb;
  box-shadow: 0 0.125rem 0.5rem rgba(59, 130, 246, 0.06);
  transition: all 0.2s ease;
  font-weight: 500;
  font-size: 1rem;
  font-family: 'Inter', system-ui, sans-serif;
  padding: 0.75rem 1.5rem;
  min-width: 110px;
  min-height: 2.5rem;
  border-radius: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.control-btn:hover {
  filter: brightness(0.95);
  box-shadow: 0 0.25rem 1rem rgba(59, 130, 246, 0.10);
  transform: scale(1.05);
}

.control-btn:active {
  filter: brightness(0.90);
  transform: scale(0.95);
}

.control-btn.primary {
  background: #3B82F6;
  color: #fff;
  border: none;
}

.control-btn.secondary {
  background: #6366F1;
  color: #fff;
  border: none;
}

.control-btn.success {
  background: #10B981;
  color: #fff;
  border: none;
}

.control-btn.reset {
  background: #EF4444;
  color: #fff;
  border: none;
}

.control-btn.orange {
  background: #fb923c;
  color: #fff;
  border: none;
}

.control-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Status Group */
.status-group {
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
  align-items: center;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
}

.status-label {
  font-weight: 500;
  color: #6b7280;
  font-size: 0.875rem;
}

.status-indicator span:last-child {
  font-weight: 600;
  color: #1e293b;
  font-size: 0.875rem;
}

/* Main Panels */
.main-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  margin-bottom: 15px;
}

.panel {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(0, 0, 0, 0.04);
  border-radius: 1.5rem;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.05);
  padding: 15px;
  transform: translateY(0);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.panel:hover {
  transform: translateY(-0.25rem);
  box-shadow: 0 1.25rem 2.5rem rgba(59, 130, 246, 0.08);
}

.panel-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 0.5rem;
}

/* Choice Selection Panels */
.choice-selection-panel {
  margin-top: 20px;
  padding: 15px;
  background: rgba(243, 244, 246, 0.7);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(0, 0, 0, 0.04);
  border-radius: 12px;
}

.selection-header {
  margin-bottom: 12px;
}

.selection-header h4 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: #1e293b;
  text-align: center;
}

.choice-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.choice-button {
  background: #fff;
  color: #374151;
  border: 1px solid #e5e7eb;
  box-shadow: 0 0.125rem 0.5rem rgba(59, 130, 246, 0.06);
  transition: all 0.2s ease;
  font-weight: 500;
  font-size: 0.875rem;
  font-family: 'Inter', system-ui, sans-serif;
  padding: 0.75rem 1rem;
  min-height: 2.5rem;
  border-radius: 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  text-align: left;
  line-height: 1.4;
  position: relative;
}

.choice-button:hover {
  filter: brightness(0.95);
  box-shadow: 0 0.25rem 1rem rgba(59, 130, 246, 0.10);
  transform: scale(1.02);
  border-color: #3B82F6;
  background: rgba(59, 130, 246, 0.05);
}

.choice-button:active {
  filter: brightness(0.90);
  transform: scale(0.98);
}

.choice-button.selected {
  border-color: #3B82F6;
  background: rgba(59, 130, 246, 0.1);
  color: #1e40af;
}

.choice-button.incorrect {
  border-color: #EF4444;
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
  animation: incorrectChoice 0.6s ease-out;
}

.choice-button.incorrect:hover {
  border-color: #dc2626;
  background: rgba(239, 68, 68, 0.15);
}

.choice-button.incorrect::after {
  content: "Click to change";
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.75rem;
  color: #EF4444;
  opacity: 0.8;
  font-weight: 500;
}

.choice-button.correct {
  border-color: #10B981;
  background: rgba(16, 185, 129, 0.1);
  color: #059669;
  animation: correctChoice 0.6s ease-out;
  cursor: default;
}

.choice-button.correct::after {
  content: "✓";
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1rem;
  color: #10B981;
  font-weight: bold;
}

@keyframes slideInMessage {
  from {
    transform: translateY(-10px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.choice-button.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

@keyframes correctChoice {
  0% { transform: scale(1); }
  50% { transform: scale(1.02); box-shadow: 0 0 20px rgba(16, 185, 129, 0.4); }
  100% { transform: scale(1); }
}

@keyframes incorrectChoice {
  0% { transform: scale(1); }
  50% { transform: scale(1.02); box-shadow: 0 0 20px rgba(239, 68, 68, 0.4); }
  100% { transform: scale(1); }
}

/* Feedback styles */
.pda-feedback,
.dtm-feedback {
  padding: 12px;
  border-radius: 8px;
  font-size: 0.875rem;
  text-align: center;
  background: rgba(243, 244, 246, 0.7);
  color: #6b7280;
  border: 1px solid rgba(0, 0, 0, 0.04);
  font-weight: 500;
}

.pda-feedback.success,
.dtm-feedback.success {
  background: rgba(16, 185, 129, 0.1);
  color: #059669;
  border-color: rgba(16, 185, 129, 0.2);
}

.pda-feedback.error,
.dtm-feedback.error {
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
  border-color: rgba(239, 68, 68, 0.2);
}

.pda-feedback.hint,
.dtm-feedback.hint {
  background: rgba(59, 130, 246, 0.1);
  color: #1e40af;
  border-color: rgba(59, 130, 246, 0.2);
}

/* Completion message */
.completion-message {
  text-align: center;
  padding: 20px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: 12px;
  color: #059669;
  backdrop-filter: blur(6px);
}

.completion-message h4 {
  margin: 0 0 10px 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.completion-message p {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 500;
}

.status-group {
  display: flex;
  gap: 20px;
  margin-left: auto;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
}

.status-label {
  font-size: 0.875rem;
  color: #6b7280;
}

#current-step,
#machine-status {
  font-weight: 600;
  color: #1e293b;
}

/* Main Panels */
.main-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  margin-bottom: 15px;
}

.panel {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(6px);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.04);
}

.panel-title {
  margin: 0 0 20px 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: #1e293b;
  text-align: center;
}

/* PDA Styles */
.pda-state-info {
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
  padding: 12px;
  background: rgba(59, 130, 246, 0.1);
  border-radius: 12px;
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.current-state,
.remaining-input,
.head-position {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.label {
  font-size: 0.75rem;
  color: #6b7280;
  font-weight: 500;
}

#pda-current-state,
#pda-remaining-input,
#dtm-current-state,
#dtm-head-position {
  font-size: 1.1rem;
  font-weight: 600;
  color: #3B82F6;
}

.stacks-container {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
  justify-content: center;
}

.stack-group {
  flex: 1;
  max-width: 150px;
}

.stack-header {
  text-align: center;
  margin-bottom: 10px;
}

.stack-header h4 {
  margin: 0 0 4px 0;
  font-size: 1rem;
  color: #1e293b;
  font-weight: 600;
}

.stack-description {
  font-size: 0.75rem;
  color: #6b7280;
  font-style: italic;
}

.stack-visual {
  border: 2px solid #3B82F6;
  border-radius: 12px;
  min-height: 200px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  padding: 10px;
  position: relative;
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.1);
}

.stack-bottom {
  background: #3B82F6;
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-weight: 600;
  margin-top: auto;
}

.stack-element {
  background: rgba(243, 244, 246, 0.9);
  border: 1px solid #e5e7eb;
  padding: 8px 12px;
  margin: 2px 0;
  border-radius: 8px;
  font-weight: 600;
  width: 80%;
  text-align: center;
  animation: stackPush 0.3s ease-out;
  color: #1e293b;
  backdrop-filter: blur(4px);
}

@keyframes stackPush {
  from {
    transform: translateY(-20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.stack-element.popping {
  animation: stackPop 0.3s ease-out forwards;
}

@keyframes stackPop {
  from {
    transform: translateY(0);
    opacity: 1;
  }
  to {
    transform: translateY(-20px);
    opacity: 0;
  }
}

/* DTM Styles */
.dtm-state-info {
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
  padding: 12px;
  background: rgba(59, 130, 246, 0.1);
  border-radius: 12px;
  border: 1px solid rgba(59, 130, 246, 0.2);
}

#dtm-current-state,
#dtm-head-position {
  font-size: 1.1rem;
  font-weight: 600;
  color: #3b82f6;
}

.tape-container {
  margin-bottom: 20px;
}

.tape-header {
  text-align: center;
  margin-bottom: 10px;
}

.tape-header h4 {
  margin: 0 0 4px 0;
  font-size: 1rem;
  color: #1e293b;
  font-weight: 600;
}

.tape-description {
  font-size: 0.75rem;
  color: #6b7280;
  font-style: italic;
}

.tape-visual {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 2px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(6px);
  border-radius: 12px;
  border: 2px solid #3B82F6;
  overflow-x: auto;
  min-height: 80px;
  position: relative;
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.1);
}

.tape-cell {
  width: 40px;
  height: 40px;
  border: 2px solid #3B82F6;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: #1e293b;
  position: relative;
  transition: all 0.3s ease;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.1);
}

.tape-cell.blank {
  color: #9ca3af;
  border-style: dashed;
  background: rgba(243, 244, 246, 0.8);
}

.tape-cell.current {
  background: #3B82F6;
  color: white;
  transform: scale(1.1);
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.5);
  z-index: 2;
}

.tape-head {
  position: absolute;
  bottom: -10px;
  transform: translateX(-50%);
  transition: left 0.5s ease;
  z-index: 3;
}

.head-indicator {
  color: #ef4444;
  font-size: 1.8rem;
  font-weight: bold;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.tape-head.pulse {
  animation: headPulse 0.6s ease-out;
}

@keyframes headPulse {
  0% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.2); }
  100% { transform: translateX(-50%) scale(1); }
}

.tape-head.moving {
  animation: headMove 0.5s ease-in-out;
}

@keyframes headMove {
  0% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-8px); }
  100% { transform: translateX(-50%) translateY(0); }
}

.tape-cell.writing {
  animation: cellWrite 0.3s ease-out;
}

@keyframes cellWrite {
  0% { background: white; transform: scale(1); }
  50% { background: #fbbf24; transform: scale(1.1); }
  100% { background: white; transform: scale(1); }
}

.tape-cell.flash {
  animation: cellFlash 0.2s ease-out;
}

@keyframes cellFlash {
  0% { background: #10b981; }
  100% { background: white; }
}

/* Transition Info */
.transition-info {
  padding: 12px;
  background: rgba(243, 244, 246, 0.7);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(0, 0, 0, 0.04);
  border-radius: 12px;
  text-align: center;
}

.transition-label {
  font-size: 0.875rem;
  color: #6b7280;
  margin-bottom: 5px;
  font-weight: 500;
}

.transition-text {
  font-weight: 600;
  color: #1e293b;
}

/* Comparison Panel */
.comparison-panel {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(0, 0, 0, 0.04);
  border-radius: 1.5rem;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.05);
  padding: 15px;
  margin-bottom: 12px;
  transform: translateY(0);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.comparison-panel:hover {
  transform: translateY(-0.25rem);
  box-shadow: 0 1.25rem 2.5rem rgba(59, 130, 246, 0.08);
}

.comparison-panel h3 {
  margin: 0 0 15px 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: #1e293b;
  text-align: center;
}

.comparison-content {
  background: rgba(243, 244, 246, 0.7);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(0, 0, 0, 0.04);
  border-radius: 12px;
  padding: 15px;
}

.comparison-step {
  font-size: 0.95rem;
  line-height: 1.6;
  color: #1e293b;
  font-weight: 500;
}

/* Final result styling */
.final-result {
  padding: 20px;
  border-radius: 12px;
  text-align: center;
  backdrop-filter: blur(6px);
}

.final-result.success {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(5, 150, 105, 0.05));
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.final-result.error {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(220, 38, 38, 0.05));
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.final-result h4 {
  margin: 0 0 15px 0;
  font-size: 1.5rem;
  font-weight: 700;
}

.final-result.success h4 {
  color: #059669;
}

.final-result.error h4 {
  color: #dc2626;
}

.result-status {
  font-size: 1.1rem;
  margin-bottom: 20px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(0, 0, 0, 0.04);
  border-radius: 8px;
  font-weight: 600;
}

.result-details {
  margin-bottom: 20px;
  text-align: left;
}

.result-details p {
  margin: 8px 0;
  font-size: 0.95rem;
  color: #1e293b;
  font-weight: 500;
}

.equivalence-explanation {
  text-align: left;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(0, 0, 0, 0.04);
  padding: 15px;
  border-radius: 12px;
  margin-top: 15px;
}

.equivalence-explanation h5 {
  margin: 0 0 10px 0;
  font-size: 1rem;
  color: #1e293b;
  font-weight: 600;
}

.equivalence-explanation ul {
  margin: 10px 0;
  padding-left: 20px;
}

.equivalence-explanation li {
  margin: 8px 0;
  font-size: 0.9rem;
  line-height: 1.4;
  color: #374151;
  font-weight: 500;
}

.equivalence-note {
  margin-top: 15px;
  padding: 12px;
  background: rgba(59, 130, 246, 0.1);
  border-left: 4px solid #3B82F6;
  border-radius: 8px;
  font-style: italic;
  color: #1e40af;
  font-weight: 500;
  backdrop-filter: blur(6px);
}

/* Theory Panel */
.theory-panel {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(0, 0, 0, 0.04);
  border-radius: 1.5rem;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.05);
  padding: 15px;
  transform: translateY(0);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.theory-panel:hover {
  transform: translateY(-0.25rem);
  box-shadow: 0 1.25rem 2.5rem rgba(59, 130, 246, 0.08);
}

.theory-panel h3 {
  margin: 0 0 15px 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: #1e293b;
  text-align: center;
}

.theory-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 15px;
}

.theory-item {
  background: rgba(243, 244, 246, 0.7);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(0, 0, 0, 0.04);
  border-radius: 12px;
  padding: 15px;
}

.theory-item h4 {
  margin: 0 0 10px 0;
  font-size: 1rem;
  font-weight: 600;
  color: #1e293b;
}

.theory-item p {
  margin: 8px 0;
  font-size: 0.875rem;
  line-height: 1.5;
  color: #374151;
  font-weight: 500;
}

.theory-item strong {
  color: #1e293b;
  font-weight: 600;
}

/* Responsive Design */
@media (max-width: 1024px) {
  .main-panels {
    grid-template-columns: 1fr;
  }

  .stacks-container {
    flex-direction: column;
    align-items: center;
  }

  .theory-content {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .control-panel {
    flex-direction: column;
    align-items: stretch;
  }

  .status-group {
    margin-left: 0;
    justify-content: center;
  }

  .guide-steps {
    grid-template-columns: 1fr;
  }
}
