/* GENERAL RESET */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  display: flex;
  font-family: 'Helvetica Neue', Arial, sans-serif;
  font-size: 1rem;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;  
  flex-direction: column;
  min-height: 100vh;
  background: linear-gradient(135deg, #fff8dc 0%, #f0f4f8 100%);
}

.wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  width: 100%; 
}

h1 {
  width: 100%;
  font-size: 1.8rem;
  color: #fff;
  text-align: center;
  padding-top: 0;
  padding: 0.5rem 0.5rem;
  border-radius: 12px;
  background: linear-gradient(to right, #a8d08d, #6fa86f);
  border-radius: 0 0 16px 16px;
  box-shadow: 0 3px 8px rgba(0,0,0,0.15);
  margin: 0rem 0 0.5rem 0;
}

h1 + select {
  margin-top: 1rem;
}

footer {
  text-align: center;
  padding: 1rem 0;
  font-size: 0.9rem;
  color: #000;
  background: #fff;
}

/* Dropdown */
select {
  width: 90%;
  max-width: 400px;
  border-radius: 12px;
  padding: 0.8rem 0.8rem;
  border: 1px solid #ccc; 
  background: #fefdf7;
  box-shadow: 0 6px 12px rgba(0,0,0,0.15);
  font-size: 1rem;
  color: #000;
  cursor: pointer;
  margin-top: 0;
  margin-bottom: 1rem;
  display: block;
  transition: transform 0.2s, background 0.2s;  
}

select:hover {
  transform: scale(1.02);
  background: #fffde7;
}

.card-container {
  width: 90%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.card {
  margin-top: 0.5rem;
  width: 100%;
  height: clamp(260px, 45vh, 500px);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1rem;
  box-shadow: 0 6px 12px rgba(0,0,0,0.15);
  cursor: pointer;
  transition: transform 0.4s ease, background 0.4s ease;
  position: relative;
  transform-style: preserve-3d;
  background: #ffeec9;
  margin-bottom: 0.5rem;  
  border: 3px solid #fff;  
  white-space: pre-line;
}

.card .front,
.card .back {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 16px;
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  font-size: clamp(1.3rem, 3vw, 1.8rem);
}

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

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

.old-card {
  border: 3px dashed #FF9900;   /* makes it obvious */
  background-color: #FFF8E1;
  animation: pulse 0.5s ease;   /* subtle attention */
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

#card-count {
  text-align: center;
  font-size: 1rem;
  color: #333;
  font-weight: 500;
  margin-bottom: 0.5rem;
  margin-top: 0.3rem;
}

.slider-container {
  width: 80%;
  max-width: 400px;
  margin: 0.5rem auto 0 auto;
  position: relative;    
  height: 30px; 
  display: flex;
  align-items: center;
  justify-content: center;
}

#card-slider {
  width: 100%;
  position: absolute; 
  left: 0;
  top: 50%;
  transform: translateY(-50%);
}

#card-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  background: #4CAF50;
  border-radius: 50%;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  cursor: grab;
  transition: transform 0.2s;
}

#card-slider::-webkit-slider-thumb:active {
  transform: scale(1.2);
}

/* Controls (buttons) */
.controls {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
  margin-top: 1rem;
}

.button-group {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
  max-width: 100%;
}

button {
  flex: 1 1 30%; /* three buttons per row */
  min-width: 90px;
  max-width: 120px;
  height: 35px;
  padding: 0.4rem 0.8rem;
  border: none;
  border-radius: 12px;
  background: linear-gradient(to bottom, #4CAF50, #3e8e41);
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease;
}

button.active-reverse {
  background: linear-gradient(to bottom, #ff6b6b, #e04f4f);
  color: #fff;
  transform: scale(1.1);
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

button:hover {
  transform: scale(1.05);
  background: linear-gradient(to bottom, #3e8e41, #2f6d31);
}

.button-group:last-child {
  margin-bottom: 1em; /* add space after the last row only */
}

/* Footer */
footer {
  width: 100%;
  padding: 12px 0;
  text-align: center;
  color: #555;
  background: #f8f8f8;
  border-top: 1px solid #ddd;
  font-size: 0.9rem;
  margin-top: 15px;
  border-radius: 13px 13px 0 0;
}

@media (max-width: 400px) {
  h1 {
    font-size: 1.4rem;
    padding: 0.8rem 0;
  }

  select {
    width: 90%;
    font-size: 0.95rem;
    padding: 0.5rem 1rem;
  }

  .card {
    height: 260px !important;
    font-size: 1.3rem;
    padding: 1rem;
  }

  button {
    min-width: 90px;
    height: 40px;
    font-size: 0.95rem;
    padding: 0.5rem 1.5rem;
  }

  /* Ensure all buttons inside button-group are same size */
  .button-group button {
    width: 100px;       /* fixed width */
    height: 50px;       /* fixed height */
    font-size: 0.95rem;
    padding: 0;         /* remove extra padding to avoid stretching */
    flex: 0 0 auto;     /* disable flex growth/shrink */
  }
}

#next-batch, #repeat-batch, #start-quiz {
  /* Override global button rules */
  min-width: unset !important;
  max-width: unset !important;
  margin: 10px 0;
  font-size: 1rem;
  width: 130px;
}

/*****
 * 
 * 
 *  quizz mode
 * 
 * **/


h2 {
  width: 100%;
  margin: 0rem 0 1rem 0;
}

#quiz-progress {
  text-align: left;
  width: 100%;
  font-size: 0.9rem;
  color: #555;
  margin-bottom: 0.5rem;
}

#quiz-question{
  width: 100%;
  max-width: 400px;
  flex-direction: column;
  align-items: center;
  /* --- MOBILE-FRIENDLY HEIGHT --- */
  min-height: 130px;
  height: auto; 
  padding: 1.2rem 1rem;
  border-radius: 16px;
  display: flex;
  justify-content: center;
  text-align: center;
  box-shadow: 0 6px 12px rgba(0,0,0,0.15);
  cursor: pointer;
  transition: transform 0.4s ease, background 0.4s ease;
  position: relative;
  transform-style: preserve-3d;
  background: #ffeec9;
  margin-bottom: 1rem;  
  border: 3px solid #fff;
}

.quiz-container {
  width: 100%;
  max-width: 400px;
  margin: 0 auto; /* center it */
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Flash animations */
@keyframes flashGreen {
  0% { background-color: #ffeec9; }
  50% { background-color: #b7e4c7; }
  100% { background-color: #ffeec9; }
}

@keyframes flashRed {
  0% { background-color: #ffeec9; }
  50% { background-color: #f8a5a5; }
  100% { background-color: #ffeec9; }
}

@keyframes flashOrange {
  0% { background-color: #ffeec9; }
  50% { background-color: #f9d784; }
  100% { background-color: #ffeec9; }
}

#quiz-question.flash-correct {
  animation: flashGreen 0.8s ease;
}

#quiz-question.flash-wrong {
  animation: flashRed 0.8s ease;
}

#quiz-question.flash-warning {
  animation: flashOrange 0.8s ease;
}

.quiz-options button {
  /* Override global button rules */
  min-width: unset !important;
  max-width: unset !important;
  width: 100% !important;
  display: block;
  width: 100%;
  margin: 10px 0;
  font-size: 1rem;
}

.quiz-button{
  margin: 20px 10px;
}

#quiz-next, #quiz-exit {
  /* Override global button rules */
  min-width: unset !important;
  max-width: unset !important;
  margin: 10px 0;
  font-size: 1rem;
}

#quiz-next:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background-color: #ccc;   /* faded background */
  color: #666;              /* faded text */
  border-color: #aaa;       /* faded border */
}

#quiz-exit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background-color: #ccc;   /* faded background */
  color: #666;              /* faded text */
  border-color: #aaa;       /* faded border */
}

#quiz-feedback {
  margin-top: 15px;
  font-weight: bold;
}
