/* ================================================================
   JS OUTPUT CHALLENGE — SimplyJavaScript Game
   styles.css
   ================================================================ */

/* ── Reset & base ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #0d0d0d;
  color: #f0f0f0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ── Layout ── */
#game-wrapper {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  position: relative;
}

/* ── Top bar ── */
#top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 8px 16px;
  background: #111;
  border-bottom: 2px solid #FFC107;
  flex-shrink: 0;
  z-index: 20;
  gap: 4px 8px;
}

.top-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand {
  font-size: 0.95rem;
  font-weight: 700;
  color: #FFC107;
  letter-spacing: 0.3px;
  white-space: nowrap;
  text-decoration: none;
}
.brand:hover { color: #ffca28; }

/* ── Game controls ── */
.game-controls {
  display: flex;
  gap: 6px;
  align-items: center;
}

.ctrl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid #333;
  border-radius: 6px;
  background: rgba(255,255,255,0.04);
  color: #aaa;
  cursor: pointer;
  transition: all 0.15s;
}
.ctrl-btn:hover {
  border-color: #FFC107;
  color: #FFC107;
  background: rgba(255,193,7,0.08);
}
.ctrl-btn.active {
  border-color: #FFC107;
  color: #FFC107;
}
.ctrl-btn svg { width: 14px; height: 14px; fill: currentColor; pointer-events: none; }

/* ── Stats row ── */
.stats {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: nowrap;
  flex-shrink: 0;
}

.stat-item {
  font-size: 0.78rem;
  color: #999;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.stat-value {
  color: #FFC107;
  font-weight: 700;
  font-size: 0.9rem;
  min-width: 18px;
  text-align: center;
}

/* ── Timer bar ── */
#timer-bar-container {
  height: 3px;
  background: #1a1a1a;
  flex-shrink: 0;
  z-index: 10;
}

#timer-bar {
  height: 100%;
  background: linear-gradient(90deg, #FFC107, #ff9800);
  width: 100%;
  transition: width 0.3s linear;
}
#timer-bar.danger { background: linear-gradient(90deg, #f44336, #ff5722); }
#timer-bar.urgency { animation: timerPulse 0.5s ease-in-out infinite; }

@keyframes timerPulse {
  0%, 100% { opacity: 1; box-shadow: none; }
  50%      { opacity: 0.6; box-shadow: 0 0 10px rgba(244,67,54,0.7); }
}

/* ── Progress bar ── */
#progress-bar-container {
  height: 3px;
  background: #1a1a1a;
  flex-shrink: 0;
  z-index: 10;
}

#progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #66bb6a, #43a047);
  transition: width 0.4s ease;
}

/* ── Main game content area ── */
#game-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  background: radial-gradient(ellipse at 50% 0%, #131320 0%, #0a0a0a 80%);
}

/* ── Code block ── */
#code-section {
  width: 100%;
  max-width: 680px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #2a2a3a;
  background: #1a1a2e;
  animation: fadeSlideIn 0.35s ease-out;
}

#code-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  background: #16162a;
  border-bottom: 1px solid #2a2a3a;
}

.code-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.code-dot.red { background: #ff5f57; }
.code-dot.yellow { background: #ffbd2e; }
.code-dot.green { background: #28c840; }

.code-filename {
  font-size: 0.75rem;
  color: #666;
  margin-left: 6px;
  font-family: 'Fira Code', 'Consolas', monospace;
}

#code-block {
  margin: 0;
  padding: 0;
  overflow-x: auto;
  background: #1a1a2e;
  -webkit-overflow-scrolling: touch;
}

#code-text {
  font-family: 'Fira Code', 'Consolas', 'Courier New', monospace;
  font-size: 0.88rem;
  line-height: 1.7;
  color: #e0e0e0;
  white-space: pre;
  tab-size: 2;
  display: block;
  padding: 14px 16px 14px 0;
}

/* Line numbers */
.line-row {
  display: flex;
}
.line-num {
  flex-shrink: 0;
  width: 40px;
  text-align: right;
  padding-right: 14px;
  color: #444;
  user-select: none;
  -webkit-user-select: none;
  font-size: 0.78rem;
}
.line-code {
  flex: 1;
  min-width: 0;
}

/* Copy button */
#copy-btn {
  margin-left: auto;
  padding: 3px 10px;
  font-size: 0.7rem;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  border: 1px solid #333;
  border-radius: 4px;
  background: rgba(255,255,255,0.05);
  color: #888;
  cursor: pointer;
  transition: all 0.15s;
}
#copy-btn:hover {
  border-color: #FFC107;
  color: #FFC107;
}
#copy-btn.copied {
  border-color: #4caf50;
  color: #4caf50;
}

/* Syntax highlighting classes */
.kw   { color: #c678dd; }
.str  { color: #98c379; }
.num  { color: #d19a66; }
.fn   { color: #61afef; }
.cm   { color: #5c6370; font-style: italic; }
.op   { color: #56b6c2; }
.bi   { color: #e5c07b; }
.pr   { color: #e06c75; }

/* ── Prompt text ── */
#prompt-text {
  font-size: 1rem;
  font-weight: 600;
  color: #ccc;
  text-align: center;
}

/* ── Option buttons ── */
#options-container {
  width: 100%;
  max-width: 680px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.option-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border: 1.5px solid #2a2a3a;
  border-radius: 10px;
  background: rgba(255,255,255,0.03);
  color: #ddd;
  font-size: 0.88rem;
  font-family: 'Fira Code', 'Consolas', monospace;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  line-height: 1.4;
  word-break: break-word;
}

.option-btn:hover:not(.locked) {
  border-color: #FFC107;
  background: rgba(255,193,7,0.06);
  color: #fff;
  transform: translateY(-1px);
}

.option-btn:active:not(.locked) {
  transform: scale(0.98);
}

.option-letter {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.78rem;
  font-family: 'Inter', sans-serif;
  background: rgba(255,255,255,0.06);
  color: #888;
  transition: all 0.2s;
}

.option-btn:hover:not(.locked) .option-letter {
  background: rgba(255,193,7,0.15);
  color: #FFC107;
}

/* Selected state */
.option-btn.selected {
  border-color: #FFC107;
  background: rgba(255,193,7,0.08);
}
.option-btn.selected .option-letter {
  background: #FFC107;
  color: #111;
}

/* Correct state */
.option-btn.correct {
  border-color: #4caf50;
  background: rgba(76,175,80,0.1);
  color: #fff;
}
.option-btn.correct .option-letter {
  background: #4caf50;
  color: #fff;
}

/* Wrong state */
.option-btn.wrong {
  border-color: #f44336;
  background: rgba(244,67,54,0.1);
  color: #ccc;
}
.option-btn.wrong .option-letter {
  background: #f44336;
  color: #fff;
}

/* Locked (after answer) */
.option-btn.locked {
  cursor: default;
  opacity: 0.7;
}
.option-btn.locked.correct,
.option-btn.locked.wrong,
.option-btn.locked.selected {
  opacity: 1;
}

/* ── Feedback / Explanation section ── */
#feedback-section {
  width: 100%;
  max-width: 680px;
  border-radius: 10px;
  padding: 18px 20px;
  animation: fadeSlideIn 0.35s ease-out;
  border: 1px solid #2a2a3a;
}
#feedback-section.hidden { display: none; }

#feedback-section.correct-feedback {
  background: rgba(76,175,80,0.08);
  border-color: rgba(76,175,80,0.3);
}
#feedback-section.wrong-feedback {
  background: rgba(244,67,54,0.08);
  border-color: rgba(244,67,54,0.3);
}

#feedback-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 1rem;
  font-weight: 700;
}

#feedback-icon {
  font-size: 1.2rem;
}

#feedback-label {
  color: #fff;
}

#feedback-explanation {
  font-size: 0.88rem;
  line-height: 1.7;
  color: #bbb;
  user-select: text;
  -webkit-user-select: text;
}

#feedback-explanation code {
  font-family: 'Fira Code', monospace;
  background: rgba(255,255,255,0.07);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.82rem;
  color: #e5c07b;
}

/* ── Next button ── */
#next-btn {
  margin-top: 4px;
  animation: fadeSlideIn 0.3s ease-out;
}
#next-btn.hidden { display: none; }

/* ── Screen overlays ── */
.screen-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
  text-align: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.screen-overlay.hidden { display: none; }

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.screen-overlay:not(.hidden) > * {
  animation: fadeSlideIn 0.4s ease-out both;
}
.screen-overlay:not(.hidden) > *:nth-child(2) { animation-delay: 0.06s; }
.screen-overlay:not(.hidden) > *:nth-child(3) { animation-delay: 0.12s; }
.screen-overlay:not(.hidden) > *:nth-child(4) { animation-delay: 0.18s; }
.screen-overlay:not(.hidden) > *:nth-child(5) { animation-delay: 0.24s; }
.screen-overlay:not(.hidden) > *:nth-child(6) { animation-delay: 0.30s; }

.screen-title {
  font-size: 1.8rem;
  font-weight: 800;
  color: #FFC107;
  margin-bottom: 8px;
}

.screen-subtitle {
  font-size: 0.95rem;
  color: #aaa;
  margin-bottom: 28px;
  max-width: 460px;
  line-height: 1.6;
}

.screen-score {
  font-size: 2.8rem;
  font-weight: 800;
  color: #FFC107;
  margin-bottom: 4px;
}

.screen-score-label {
  font-size: 0.85rem;
  color: #888;
  margin-bottom: 22px;
}

.screen-stats {
  display: flex;
  gap: 24px;
  margin-bottom: 28px;
  flex-wrap: wrap;
  justify-content: center;
}

.screen-stat { text-align: center; }

.screen-stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
}

.screen-stat-label {
  font-size: 0.72rem;
  color: #777;
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Buttons ── */
.btn-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.btn {
  padding: 12px 32px;
  font-size: 0.9rem;
  font-weight: 700;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-primary {
  background: #FFC107;
  color: #111;
}
.btn-primary:hover {
  background: #ffca28;
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(255,193,7,0.3);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: transparent;
  color: #ccc;
  border: 1.5px solid #444;
}
.btn-secondary:hover {
  border-color: #FFC107;
  color: #FFC107;
}

/* ── Difficulty selector ── */
.difficulty-selector {
  display: flex;
  gap: 8px;
  margin-bottom: 22px;
  flex-wrap: wrap;
  justify-content: center;
}

.diff-btn {
  padding: 9px 20px;
  font-size: 0.82rem;
  font-weight: 600;
  border: 2px solid #3a3a3a;
  border-radius: 6px;
  background: transparent;
  color: #bbb;
  cursor: pointer;
  transition: all 0.2s;
}
.diff-btn:hover { border-color: #FFC107; color: #FFC107; }
.diff-btn.active {
  border-color: #FFC107;
  background: rgba(255,193,7,0.12);
  color: #FFC107;
}

/* ── Score pop animation ── */
.score-pop {
  animation: scoreBounce 0.35s ease-out;
}
@keyframes scoreBounce {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.35); }
  100% { transform: scale(1); }
}

/* ── Floating "+10" score text ── */
.float-score {
  position: absolute;
  font-size: 1.4rem;
  font-weight: 800;
  color: #4caf50;
  pointer-events: none;
  z-index: 100;
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
  animation: floatUp 0.85s ease-out forwards;
}
@keyframes floatUp {
  0%   { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-50px) scale(1.2); }
}

/* ── Toast notification ── */
.float-toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  font-size: 1.1rem;
  font-weight: 700;
  padding: 10px 28px;
  border-radius: 8px;
  background: rgba(20,20,30,0.92);
  border: 1px solid rgba(255,255,255,0.1);
  backdrop-filter: blur(6px);
  pointer-events: none;
  z-index: 300;
  animation: toastIn 0.3s ease-out forwards, toastOut 0.3s ease-in 0.8s forwards;
  white-space: nowrap;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-20px) scale(0.9); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(-50%) translateY(0); }
  to   { opacity: 0; transform: translateX(-50%) translateY(-10px); }
}

/* ── Question slide-in transition ── */
#game-content.slide-in {
  animation: slideIn 0.35s ease-out;
}
@keyframes slideIn {
  from { opacity: 0.5; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Responsive ── */
@media (max-width: 700px) {
  #game-content { padding: 16px 12px; gap: 14px; }
  #options-container { grid-template-columns: 1fr; }
  #code-text { font-size: 0.8rem; }
  .line-num { width: 32px; padding-right: 10px; font-size: 0.72rem; }
  .option-btn { padding: 14px 14px; min-height: 48px; }
}

@media (max-width: 600px) {
  #top-bar { padding: 6px 10px; gap: 3px 6px; }
  .top-left { gap: 8px; }
  .brand { font-size: 0.78rem; }
  .ctrl-btn { width: 26px; height: 26px; }
  .ctrl-btn svg { width: 11px; height: 11px; }
  .game-controls { gap: 4px; }
  .stats { gap: 10px; }
  .stat-item { font-size: 0.68rem; }
  .stat-value { font-size: 0.75rem; min-width: 14px; }
  #prompt-text { font-size: 0.9rem; }
  .option-btn { padding: 14px 14px; font-size: 0.82rem; }
  .option-letter { width: 26px; height: 26px; font-size: 0.72rem; }
  #feedback-section { padding: 14px 16px; }
  #feedback-explanation { font-size: 0.82rem; }
  .screen-title { font-size: 1.35rem; }
  .screen-score { font-size: 2rem; }
  .screen-stats { gap: 16px; }
  .btn { padding: 10px 24px; font-size: 0.82rem; }
  .float-toast { font-size: 0.95rem; padding: 8px 20px; }
}

@media (max-width: 380px) {
  .brand { font-size: 0.7rem; }
  .ctrl-btn { width: 24px; height: 24px; }
  .ctrl-btn svg { width: 10px; height: 10px; }
  .game-controls { gap: 3px; }
  .stats { gap: 8px; }
  .stat-item { font-size: 0.64rem; }
  .stat-value { font-size: 0.7rem; }
  #code-text { font-size: 0.74rem; }
}
