/* =========================
   GLOBAL RESET
   ========================= */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: #f4f5f7;
  color: #222;
}

/* =========================
   APP LAYOUT
   ========================= */
.app {
  max-width: 420px;
  margin: 0 auto;
  padding: 1.25rem 1rem 2rem;
  text-align: center;
}

h1 {
  font-size: 1.25rem;
  margin-bottom: 1.5rem;
}

/* =========================
   CARD STAGE
   ========================= */
.card-stage {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 2rem;
}

/* =========================
   FLASHCARD CORE
   ========================= */
.flashcard {
  width: 320px;
  height: 200px;

  position: relative;
  perspective: 1000px;

  transform-style: preserve-3d;
  overflow: hidden;

  cursor: pointer;
}

/* =========================
   CARD FACES
   ========================= */
.flashcard-face {
  position: absolute;
  inset: 0;

  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;

  padding: 1.25rem;

  background: #fdfdfb;
  border: 1px solid #d6d6d6;
  border-radius: 16px;

  backface-visibility: hidden;
  transform-style: preserve-3d;

  box-shadow:
    0 6px 16px rgba(0, 0, 0, 0.06),
    0 18px 36px rgba(0, 0, 0, 0.08);

  transition: transform 0.6s cubic-bezier(0.4, 0.2, 0.2, 1);
}

/* Front / Back positioning */
.flashcard-front {
  transform: rotateY(0deg);
}

.flashcard-back {
  transform: rotateY(180deg);
}

/* Flip state */
.flashcard.is-flipped .flashcard-front {
  transform: rotateY(-180deg);
}

.flashcard.is-flipped .flashcard-back {
  transform: rotateY(0deg);
}

/* =========================
   FRONT FACE LAYOUT (stacked)
   ========================= */
.flashcard-front {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.35rem;
}

.front-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* =========================
   TYPOGRAPHY CONTAINMENT
   ========================= */
.flashcard-front h2 {
  font-size: 1.6rem;
  font-weight: 600;
  margin: 0;
  max-width: 100%;
  word-break: break-word;
}

/* phonetic */
.phonetic {
  margin-top: 0.25rem;
  font-size: 0.95rem;
  font-style: italic;
  text-decoration: underline;
  color: #5b6b7a;
}

.flashcard-back p {
  font-size: 1rem;
  line-height: 1.5;
  margin: 0;
  max-width: 100%;
  word-break: break-word;

  /* meaning colored */
  color: #1f2937;
}

/* Passage text */
.passage {
  margin-top: 0.6rem;
  font-size: 0.85rem;
  font-style: italic;
  color: #444;
}

/* =========================
   AUDIO BUTTON
   ========================= */
.audio-btn {
  position: absolute;
  top: 12px;
  right: 12px;

  width: 36px;
  height: 36px;

  border-radius: 50%;
  border: none;
  background: #f1f1f1;

  display: grid;
  place-items: center;

  cursor: pointer;
  z-index: 2;
}

.audio-btn:active {
  transform: scale(0.95);
}

/* =========================
   ARROWS (card navigation)
   ========================= */
.card-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.nav-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);

  background: transparent;
  border: none;
  font-size: 2rem;
  color: rgba(0, 0, 0, 0.35);

  cursor: pointer;
  padding: 0.25rem;
}

.nav-prev {
  left: -36px;
}

.nav-next {
  right: -36px;
}

.nav-arrow:hover {
  color: rgba(0, 0, 0, 0.6);
}

/* =========================
   CHILD NAVIGATION + PROGRESS
   ========================= */
.child-controls {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.child-controls .child-arrow {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: rgba(0,0,0,0.35);
  cursor: pointer;
}

.child-controls .child-arrow:hover {
  color: rgba(0,0,0,0.6);
}

/* Progress bar */
.progress-bar {
  flex: 1;
  height: 6px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar > .fill {
  height: 100%;
  width: 0%;
  background: #1f2937;
  border-radius: 999px;
}

/* =========================
   ACTION BAR
   ========================= */
.action-bar {
  display: flex;
  justify-content: center;
}

#download-btn {
  padding: 0.75rem 1.25rem;
  font-size: 0.95rem;

  border-radius: 12px;
  border: none;
  background: #1f2937;
  color: #ffffff;

  cursor: pointer;
}

#download-btn:active {
  transform: scale(0.97);
}

/* =========================
   MOBILE SAFETY
   ========================= */
@media (max-width: 360px) {
  .flashcard {
    width: 280px;
    height: 180px;
  }
}
