/* =============================================
   SECTION SORT GAME — style.css
   scenario5-grocery/section-game/
   ============================================= */

:root {
  --green: #43a047;
  --dark-green: #2e7d32;
  --light-green: #e8f5e9;
  --red: #e53935;
  --light-red: #ffebee;
  --gold: #f9a825;
  --light-gold: #fff8e1;
  --blue: #1e88e5;
  --light-blue: #e3f2fd;
  --purple: #8e24aa;
  --light-purple: #f3e5f5;
  --orange: #ef6c00;
  --light-orange: #fff3e0;
  --teal: #00897b;
  --light-teal: #e0f2f1;
  --pink: #d81b60;
  --light-pink: #fce4ec;
  --grey: #f5f5f5;
  --mid-grey: #888;
  --dark: #1a1a2e;
  --white: #ffffff;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);
  --radius: 16px;
  --radius-sm: 10px;
  --transition: all 0.25s ease;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--grey);
  color: var(--dark);
  min-height: 100vh;
  line-height: 1.5;
}

/* =============================================
   TOP NAV
   ============================================= */
.top-nav {
  background: var(--dark);
  color: white;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.top-nav .logo {
  font-weight: 800;
  font-size: 1.2rem;
}

.nav-links {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.nav-links a {
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  transition: var(--transition);
  white-space: nowrap;
}

.nav-links a:hover,
.nav-links a.active {
  background: rgba(255, 255, 255, 0.15);
  color: white;
}

/* =============================================
   CONTAINER
   ============================================= */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* =============================================
   GAME HEADER
   ============================================= */
.game-header {
  text-align: center;
  padding: 28px 20px 16px;
}

.game-header h1 {
  font-size: 2rem;
  margin-bottom: 8px;
}

.game-header p {
  color: var(--mid-grey);
  font-size: 1rem;
  max-width: 600px;
  margin: 0 auto;
}

/* =============================================
   DIFFICULTY SELECTOR
   ============================================= */
.difficulty-selector {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.diff-btn {
  padding: 8px 18px;
  border: 2px solid #ddd;
  border-radius: 30px;
  background: white;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition);
}

.diff-btn:hover {
  border-color: var(--green);
}

.diff-btn.active {
  background: var(--green);
  color: white;
  border-color: var(--green);
}

/* =============================================
   SCORE BAR
   ============================================= */
.score-bar {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  margin: 16px 0 12px;
}

.score-item {
  background: var(--white);
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  text-align: center;
  min-width: 100px;
}

.score-item .score-label {
  font-size: 0.7rem;
  color: var(--mid-grey);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.score-item .score-value {
  font-size: 1.4rem;
  font-weight: 800;
  margin-top: 2px;
}

.correct-text {
  color: var(--green);
}

.mistake-text {
  color: var(--red);
}

.timer {
  color: var(--orange);
}

.streak-text {
  color: var(--gold);
}

/* =============================================
   PROGRESS BAR
   ============================================= */
.progress-wrapper {
  max-width: 500px;
  margin: 0 auto 20px;
  text-align: center;
}

.progress-bar {
  width: 100%;
  height: 10px;
  background: #e0e0e0;
  border-radius: 10px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--green), var(--teal));
  border-radius: 10px;
  transition: width 0.4s ease;
}

.progress-label {
  font-size: 0.78rem;
  color: var(--mid-grey);
  margin-top: 6px;
  font-weight: 600;
}

/* =============================================
   BUTTONS
   ============================================= */
.btn {
  padding: 10px 22px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-green {
  background: var(--green);
  color: white;
}
.btn-green:hover {
  background: var(--dark-green);
}

.btn-gold {
  background: var(--gold);
  color: var(--dark);
}
.btn-gold:hover {
  background: #f57f17;
  color: white;
}

.btn-outline {
  background: var(--white);
  color: var(--dark);
  border: 2px solid #ddd;
}
.btn-outline:hover {
  border-color: var(--green);
  color: var(--green);
}

.btn-red {
  background: var(--red);
  color: white;
}
.btn-red:hover {
  background: #c62828;
}

/* =============================================
   CONTROLS ROW
   ============================================= */
.controls {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

/* =============================================
   HINT PANEL
   ============================================= */
.hint-panel {
  background: var(--light-gold);
  border: 2px solid var(--gold);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  margin-bottom: 20px;
  display: none;
}

.hint-panel.show {
  display: block;
}

.hint-panel h4 {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  color: var(--orange);
}

.hint-panel p {
  font-size: 0.9rem;
  color: #666;
  line-height: 1.5;
}

/* =============================================
   TOUCH HINT (mobile only)
   ============================================= */
.touch-hint {
  display: none;
  text-align: center;
  font-size: 0.85rem;
  color: var(--mid-grey);
  margin-bottom: 12px;
}

@media (pointer: coarse) {
  .touch-hint {
    display: block;
  }
}

/* =============================================
   GAME LAYOUT — 2-column (tray + sections)
   ============================================= */
.game-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 800px) {
  .game-layout {
    grid-template-columns: 1fr;
  }
}

/* =============================================
   ITEM TRAY (left panel)
   ============================================= */
.item-tray {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  position: sticky;
  top: 80px;
}

.item-tray h3 {
  font-size: 1.1rem;
  margin-bottom: 4px;
}

.item-tray .tray-subtitle {
  font-size: 0.82rem;
  color: var(--mid-grey);
  margin-bottom: 16px;
}

.tray-items {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 60px;
}

.tray-empty-msg {
  text-align: center;
  color: var(--green);
  font-weight: 700;
  padding: 20px;
  font-size: 1rem;
}

/* =============================================
   GROCERY ITEM (draggable chip)
   ============================================= */
.grocery-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--light-green);
  border: 2px solid transparent;
  border-radius: 30px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: grab;
  transition: var(--transition);
  user-select: none;
  white-space: nowrap;
}

.grocery-item:active {
  cursor: grabbing;
}

.grocery-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.grocery-item.dragging {
  opacity: 0.4;
  transform: scale(0.95);
}

.grocery-item.selected {
  outline: 3px solid var(--green);
  outline-offset: 2px;
}

.grocery-item .item-emoji {
  font-size: 1.2rem;
}

/* Correct state */
.grocery-item.correct {
  background: var(--light-green);
  border-color: var(--green);
  cursor: default;
  opacity: 0.85;
}

.grocery-item.correct::after {
  content: ' ✅';
  font-size: 0.8rem;
}

/* Wrong state */
.grocery-item.wrong {
  animation: shake 0.5s ease;
  border-color: var(--red);
  background: var(--light-red);
}

/* Auto-sorted (from Check All) */
.grocery-item.auto-sorted {
  background: var(--light-orange);
  border-color: var(--orange);
}

.grocery-item.auto-sorted::after {
  content: ' 🔶';
  font-size: 0.8rem;
}

/* =============================================
   ANIMATIONS
   ============================================= */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

@keyframes pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes celebrate {
  0% { transform: scale(1) rotate(0deg); }
  25% { transform: scale(1.2) rotate(-5deg); }
  50% { transform: scale(1.2) rotate(5deg); }
  75% { transform: scale(1.1) rotate(-3deg); }
  100% { transform: scale(1) rotate(0deg); }
}

/* =============================================
   SECTIONS GRID (right side)
   ============================================= */
.sections-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

/* =============================================
   SECTION DROP ZONE
   ============================================= */
.section-zone {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 3px dashed #ddd;
  transition: var(--transition);
  overflow: hidden;
}

.section-zone.drag-over {
  border-color: var(--green);
  background: var(--light-green);
  transform: scale(1.02);
  box-shadow: var(--shadow-lg);
}

.section-zone.section-complete {
  border-color: var(--green);
  border-style: solid;
  background: linear-gradient(135deg, var(--white), var(--light-green));
}

.section-header {
  padding: 16px 20px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.section-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.section-header h4 {
  font-size: 1.05rem;
  line-height: 1.2;
}

.section-header .section-hint {
  font-size: 0.78rem;
  color: var(--mid-grey);
  font-weight: 400;
}

.section-count {
  font-size: 0.75rem;
  background: var(--grey);
  padding: 2px 10px;
  border-radius: 20px;
  font-weight: 700;
  margin-left: auto;
  white-space: nowrap;
}

.section-count.complete {
  background: var(--green);
  color: white;
  animation: pop 0.3s ease;
}

.section-drop-area {
  min-height: 60px;
  padding: 10px 16px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-content: flex-start;
}

.drop-placeholder {
  width: 100%;
  text-align: center;
  color: #ccc;
  font-size: 0.85rem;
  padding: 14px;
  font-style: italic;
}

/* =============================================
   TOAST NOTIFICATIONS
   ============================================= */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 14px 28px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.95rem;
  z-index: 200;
  transition: transform 0.3s ease, opacity 0.3s ease;
  opacity: 0;
  pointer-events: none;
  max-width: 90vw;
  text-align: center;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.success {
  background: var(--green);
  color: white;
}

.toast.error {
  background: var(--red);
  color: white;
}

.toast.info {
  background: var(--blue);
  color: white;
}

/* =============================================
   MODAL (completion screen)
   ============================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 20px;
}

.modal-overlay.show {
  display: flex;
}

.modal-box {
  background: white;
  border-radius: var(--radius);
  padding: 36px;
  max-width: 520px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.4s ease;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-box h2 {
  font-size: 1.8rem;
  margin: 12px 0 8px;
}

.modal-box .big-emoji {
  font-size: 4rem;
  animation: celebrate 0.6s ease;
}

.modal-box p {
  color: var(--mid-grey);
  margin-bottom: 8px;
}

.modal-stats {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin: 20px 0;
  flex-wrap: wrap;
}

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

.modal-stat .stat-val {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--green);
}

.modal-stat .stat-label {
  font-size: 0.78rem;
  color: var(--mid-grey);
  text-transform: uppercase;
  font-weight: 600;
}

.modal-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 12px 0;
}

.badge-chip {
  background: var(--light-gold);
  color: var(--dark);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 20px;
  flex-wrap: wrap;
}

/* =============================================
   LEARNING SUMMARY
   ============================================= */
.learning-summary {
  margin: 32px 0;
  background: var(--white);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
}

.learning-summary h3 {
  text-align: center;
  font-size: 1.3rem;
  margin-bottom: 20px;
}

.summary-sections {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.summary-section {
  padding: 16px;
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--green);
}

.summary-section h4 {
  font-size: 0.95rem;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.summary-section .summary-items {
  font-size: 0.85rem;
  color: var(--mid-grey);
  line-height: 1.6;
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 600px) {
  .game-header h1 {
    font-size: 1.5rem;
  }

  .score-bar {
    gap: 8px;
  }

  .score-item {
    padding: 8px 14px;
    min-width: 80px;
  }

  .score-item .score-value {
    font-size: 1.1rem;
  }

  .sections-grid {
    grid-template-columns: 1fr;
  }

  .modal-box {
    padding: 24px 18px;
  }

  .modal-stats {
    gap: 12px;
  }

  .nav-links a {
    padding: 4px 10px;
    font-size: 0.78rem;
  }
}