/* ==========================================================================
   DEVPEGS - Memory Pegs & Mental Models Styles
   ========================================================================== */

.pegs-control-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--bg-card);
  padding: 1rem 1.5rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-card);
  margin-bottom: 2rem;
}

.mode-toggle-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.mode-btn {
  padding: 0.45rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s;
  font-family: var(--font-sans);
}

.mode-btn.active {
  background: var(--accent-purple);
  color: #fff;
  border-color: var(--accent-purple);
  box-shadow: 0 0 15px rgba(168, 85, 247, 0.35);
}

.pegs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 1.75rem;
}

/* 3D Flip Card Container */
.peg-card-container {
  perspective: 1200px;
  height: 480px;
}

.peg-card {
  position: relative;
  width: 100%;
  height: 100%;
  text-align: left;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
  cursor: pointer;
}

.peg-card.flipped {
  transform: rotateY(180deg);
}

.peg-card-face {
  position: absolute;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-card);
  background: var(--bg-card);
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  box-shadow: var(--shadow-card);
}

/* Front Face */
.peg-card-front {
  background: linear-gradient(170deg, rgba(24, 33, 62, 0.85) 0%, rgba(12, 18, 36, 0.95) 100%);
  border-top: 3px solid var(--peg-color, var(--accent-indigo));
}

.peg-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.peg-number-badge {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.3rem;
  color: var(--peg-color, var(--accent-indigo));
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.2);
}

.peg-system-tag {
  font-size: 0.72rem;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.05em;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
}

/* Visual Illustration Box */
.peg-illustration {
  background: radial-gradient(circle at center, rgba(99, 102, 241, 0.15) 0%, rgba(0, 0, 0, 0.3) 100%);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin-bottom: 1.25rem;
  position: relative;
  min-height: 120px;
}

.peg-icon-large {
  font-size: 3.2rem;
  margin-bottom: 0.5rem;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.5));
}

.peg-rhyme-banner {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

.peg-metaphor-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
}

.peg-technical-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--peg-color, var(--accent-cyan));
  margin-bottom: 0.75rem;
}

.peg-story {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.55;
  margin-bottom: auto;
}

.flip-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
}

/* Back Face */
.peg-card-back {
  transform: rotateY(180deg);
  background: linear-gradient(170deg, rgba(16, 22, 45, 0.95) 0%, rgba(9, 13, 27, 0.98) 100%);
  border-top: 3px solid var(--accent-cyan);
}

.back-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.back-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
}

.brain-anchor-box {
  background: rgba(168, 85, 247, 0.1);
  border: 1px solid rgba(168, 85, 247, 0.25);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  margin-bottom: 1rem;
}

.brain-anchor-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-purple);
  margin-bottom: 0.25rem;
}

.brain-anchor-desc {
  font-size: 0.82rem;
  color: #e2e8f0;
  line-height: 1.45;
}

.back-code {
  background: #050811;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: #38bdf8;
  margin-bottom: 1rem;
  overflow-x: auto;
  line-height: 1.5;
}

.self-test-prompt {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.45;
  background: rgba(255, 255, 255, 0.04);
  padding: 0.65rem;
  border-radius: var(--radius-sm);
  margin-top: auto;
}

/* Flashcard Study Mode */
.flashcard-study-container {
  display: none;
  max-width: 600px;
  margin: 0 auto;
}

.flashcard-study-container.active {
  display: block;
}

.flashcard-progress-bar {
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.flashcard-progress-fill {
  height: 100%;
  background: var(--grad-primary);
  width: 20%;
  transition: width 0.3s ease;
}

.flashcard-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.5rem;
}

.study-btn {
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  border: none;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
  font-family: var(--font-sans);
}

.study-btn:hover {
  transform: translateY(-2px);
}

.study-btn.red {
  background: rgba(244, 63, 94, 0.2);
  color: var(--accent-rose);
  border: 1px solid rgba(244, 63, 94, 0.4);
}

.study-btn.yellow {
  background: rgba(245, 158, 11, 0.2);
  color: var(--accent-amber);
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.study-btn.green {
  background: rgba(16, 185, 129, 0.2);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.4);
}
