/**
 * Practice Card 3D Styles
 * Immersive 3D card experience with flip animations and gestures
 */

/* Container */
.practice-card-3d-container {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  padding: 1rem;
  perspective: 1200px;
}

/* Progress Ring */
.card-progress-ring {
  position: relative;
  width: 70px;
  height: 70px;
  flex-shrink: 0;
}

.progress-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.progress-ring-bg {
  fill: none;
  stroke: rgba(28, 35, 37, 0.08);
  stroke-width: 6;
}

.progress-ring-fill {
  fill: none;
  stroke: url(#progressGradient);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 283;
  stroke-dashoffset: calc(283 - (283 * var(--progress)) / 100);
  transition: stroke-dashoffset 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.progress-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.85rem;
  font-weight: 600;
  color: #455255;
}

/* 3D Card Wrapper */
.card-3d-wrapper {
  position: relative;
  width: 100%;
  max-width: 500px;
  aspect-ratio: 4/5;
  perspective: 1000px;
  transform-style: preserve-3d;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

/* The 3D Card */
.card-3d {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

/* Card Faces */
.card-face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 24px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(255, 252, 248, 0.95));
  box-shadow: 
    0 20px 60px rgba(0, 0, 0, 0.1),
    0 0 0 1px rgba(0, 0, 0, 0.03);
  overflow: hidden;
}

.card-front {
  transform: rotateY(0deg);
}

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

/* Card Content */
.card-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 1.5rem;
}

/* Card Header */
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(28, 35, 37, 0.06);
}

.question-badge {
  font-size: 0.75rem;
  font-weight: 600;
  color: #be6438;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(190, 100, 56, 0.08);
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
}

.question-topic {
  font-size: 0.8rem;
  color: #627072;
}

/* Question Text */
.question-text-container {
  flex: 0 0 auto;
  margin-bottom: 1.5rem;
}

.question-text {
  font-family: "Iowan Old Style", "Palatino Linotype", serif;
  font-size: clamp(1.25rem, 3.5vw, 1.6rem);
  line-height: 1.35;
  color: #1c2325;
  margin: 0;
}

/* Options Grid */
.options-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex: 1;
  overflow-y: auto;
}

.option-btn {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 1rem 1.125rem;
  border: 2px solid rgba(28, 35, 37, 0.08);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  text-align: left;
  position: relative;
  overflow: hidden;
}

.option-btn:hover:not(:disabled) {
  border-color: rgba(190, 100, 56, 0.3);
  background: rgba(255, 255, 255, 0.9);
  transform: translateX(4px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

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

.option-btn.selected {
  border-color: #be6438;
  background: linear-gradient(135deg, rgba(190, 100, 56, 0.08), rgba(221, 184, 101, 0.08));
  box-shadow: 0 0 0 4px rgba(190, 100, 56, 0.1);
}

.option-btn.correct {
  border-color: #10B981;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(16, 185, 129, 0.05));
}

.option-btn.incorrect {
  border-color: #EF4444;
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.08), rgba(239, 68, 68, 0.03));
}

.option-letter {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(28, 35, 37, 0.06);
  font-weight: 700;
  font-size: 1rem;
  color: #455255;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.option-btn:hover .option-letter {
  background: rgba(190, 100, 56, 0.15);
  color: #be6438;
}

.option-btn.selected .option-letter {
  background: #be6438;
  color: white;
}

.option-btn.correct .option-letter {
  background: #10B981;
  color: white;
}

.option-btn.incorrect .option-letter {
  background: #EF4444;
  color: white;
}

.option-text {
  flex: 1;
  font-size: 0.95rem;
  color: #1c2325;
  line-height: 1.4;
}

.option-check {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #10B981;
  color: white;
  font-size: 0.9rem;
  opacity: 0;
  transform: scale(0);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.option-btn.correct .option-check,
.option-btn.selected.correct .option-check {
  opacity: 1;
  transform: scale(1);
}

/* Hint */
.card-hint {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  padding: 0.75rem;
  background: rgba(28, 35, 37, 0.03);
  border-radius: 12px;
}

.hint-icon {
  font-size: 1.1rem;
}

.hint-text {
  font-size: 0.85rem;
  color: #627072;
}

/* Card Back - Feedback */
.feedback-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(28, 35, 37, 0.06);
}

.feedback-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  animation: feedbackPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.feedback-icon.correct {
  background: linear-gradient(135deg, #10B981, #059669);
  color: white;
}

.feedback-icon.incorrect {
  background: linear-gradient(135deg, #EF4444, #DC2626);
  color: white;
}

.feedback-title {
  font-family: "Iowan Old Style", "Palatino Linotype", serif;
  font-size: 1.35rem;
  color: #1c2325;
  margin: 0;
}

.feedback-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  overflow-y: auto;
}

.feedback-message {
  font-size: 1rem;
  color: #455255;
  line-height: 1.5;
  margin: 0;
  text-align: center;
}

.correct-answer {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.08), rgba(16, 185, 129, 0.03));
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: 12px;
  padding: 1rem;
}

.answer-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: #059669;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.35rem;
}

.answer-value {
  font-size: 1rem;
  font-weight: 600;
  color: #065f46;
}

.explanation {
  background: rgba(28, 35, 37, 0.03);
  border-radius: 12px;
  padding: 1rem;
}

.explanation-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: #627072;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.explanation-text {
  font-size: 0.9rem;
  color: #455255;
  line-height: 1.5;
  margin: 0;
}

/* Next Button */
.next-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 1rem 1.5rem;
  background: linear-gradient(135deg, #be6438, #d97706);
  color: white;
  border: none;
  border-radius: 16px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-top: auto;
  box-shadow: 0 4px 16px rgba(190, 100, 56, 0.3);
}

.next-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(190, 100, 56, 0.4);
}

.next-btn:active {
  transform: translateY(0);
}

.next-arrow {
  transition: transform 0.2s ease;
}

.next-btn:hover .next-arrow {
  transform: translateX(4px);
}

/* Gesture Hint */
.card-gestures-hint {
  text-align: center;
  padding: 0.5rem;
}

.gesture-hint {
  font-size: 0.8rem;
  color: #627072;
  opacity: 0.7;
}

/* Navigation Buttons */
.card-nav-buttons {
  display: flex;
  gap: 1rem;
}

.nav-btn {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 2px solid rgba(28, 35, 37, 0.1);
  background: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.nav-btn:hover:not(:disabled) {
  border-color: rgba(190, 100, 56, 0.3);
  background: white;
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Animations */
@keyframes feedbackPop {
  0% {
    transform: scale(0) rotate(-180deg);
    opacity: 0;
  }
  50% {
    transform: scale(1.1) rotate(10deg);
  }
  100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

@keyframes cardShake {
  0%, 100% {
    transform: translateX(0);
  }
  20%, 60% {
    transform: translateX(-10px);
  }
  40%, 80% {
    transform: translateX(10px);
  }
}

@keyframes cardPulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1);
  }
  50% {
    transform: scale(1.02);
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.15);
  }
}

/* Loading State */
.card-loading {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 24px;
  z-index: 10;
}

.card-loading::after {
  content: '';
  width: 40px;
  height: 40px;
  border: 3px solid rgba(28, 35, 37, 0.1);
  border-top-color: #be6438;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Responsive */
@media (max-width: 600px) {
  .practice-card-3d-container {
    padding: 0.5rem;
  }
  
  .card-3d-wrapper {
    max-width: 100%;
  }
  
  .card-content {
    padding: 1.25rem;
  }
  
  .question-text {
    font-size: 1.15rem;
  }
  
  .option-btn {
    padding: 0.875rem 1rem;
  }
  
  .option-letter {
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
  }
  
  .option-text {
    font-size: 0.9rem;
  }
  
  .card-progress-ring {
    width: 60px;
    height: 60px;
  }
  
  .progress-text {
    font-size: 0.75rem;
  }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  .card-3d,
  .card-3d-wrapper,
  .option-btn,
  .nav-btn,
  .next-btn,
  .progress-ring-fill {
    transition: none !important;
    animation: none !important;
  }
  
  .feedback-icon {
    animation: none !important;
  }
}

/* Focus Styles */
.option-btn:focus-visible {
  outline: 3px solid #be6438;
  outline-offset: 2px;
}

.nav-btn:focus-visible,
.next-btn:focus-visible {
  outline: 3px solid #be6438;
  outline-offset: 2px;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
  .option-btn {
    border-width: 3px;
  }
  
  .option-btn.selected {
    border-color: #1c2325;
  }
  
  .card-face {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  .card-face {
    background: linear-gradient(145deg, #2d3748, #1a202c);
    box-shadow: 
      0 20px 60px rgba(0, 0, 0, 0.3),
      0 0 0 1px rgba(255, 255, 255, 0.05);
  }
  
  .question-text {
    color: #e2e8f0;
  }
  
  .option-btn {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
  }
  
  .option-text {
    color: #e2e8f0;
  }
  
  .option-letter {
    background: rgba(255, 255, 255, 0.1);
    color: #cbd5e0;
  }
}
