/* TBT Flashcards v1.0.0 */

.tbt-flashcard-app {
  --tbt-blue: #0856c9;
  --tbt-blue-dark: #064a9e;
  --tbt-blue-light: #e8f0fc;
  --tbt-blue-glow: rgba(8, 86, 201, 0.15);
  --card-bg: #ffffff;
  --text-primary: #1a2332;
  --text-secondary: #5a6a7e;
  --text-muted: #8a96a6;
  --border: #e2e8f0;
  --radius: 24px;
  --shadow: 0 25px 50px -12px rgba(0,0,0,0.15);
  --shadow-hover: 0 25px 50px -12px rgba(0,0,0,0.22);
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);

  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-weight: 300;
  color: var(--text-primary);
  width: 100%;
  max-width: 842px;
  margin: 0 auto;
  position: relative;
  box-sizing: border-box;
}

.tbt-flashcard-app *,
.tbt-flashcard-app *::before,
.tbt-flashcard-app *::after {
  box-sizing: border-box;
}

/* ── Header ── */
.tbt-flashcard-app .fc-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin-bottom: 20px;
  padding: 0 4px;
  gap: 12px;
}

.tbt-flashcard-app .fc-set-title {
  font-weight: 700;
  font-size: 18px;
  color: var(--tbt-blue);
  letter-spacing: -0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* ── Card Scene ── */
.tbt-flashcard-app .fc-card-scene {
  perspective: 1200px;
  width: 100%;
  height: 595px;
  cursor: pointer;
  margin-bottom: 20px;
}

.tbt-flashcard-app .fc-card {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.4, 0, 0.2, 1);
}

.tbt-flashcard-app .fc-card.is-flipped {
  transform: rotateY(180deg);
}

.tbt-flashcard-app .fc-card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 36px;
  transition: box-shadow var(--transition);
  overflow: hidden;
}

.tbt-flashcard-app .fc-card-scene:hover .fc-card-face {
  box-shadow: var(--shadow-hover);
}

/* ── Card counter (inside card, top-right) ── */
.tbt-flashcard-app .fc-card-counter {
  position: absolute;
  top: 20px;
  right: 24px;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.5px;
}

.tbt-flashcard-app .fc-card-front .fc-card-counter {
  color: #c0c4cc;
}

.tbt-flashcard-app .fc-card-back .fc-card-counter {
  color: rgba(255,255,255,0.4);
}

/* ── Front card ── */
.tbt-flashcard-app .fc-card-front {
  background: var(--card-bg);
  border: 1px solid var(--border);
}

.tbt-flashcard-app .fc-card-front::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--tbt-blue);
  border-radius: var(--radius) var(--radius) 0 0;
}

.tbt-flashcard-app .fc-word {
  font-weight: 700;
  font-size: 44px;
  color: var(--text-primary);
  text-align: center;
  line-height: 1.2;
  letter-spacing: -0.5px;
}

.tbt-flashcard-app .fc-audio-btn {
  margin-top: 20px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: rgba(8, 86, 201, 0.08);
  color: var(--tbt-blue);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  position: relative;
}

.tbt-flashcard-app .fc-audio-btn:hover {
  background: rgba(8, 86, 201, 0.15);
  transform: scale(1.08);
}

.tbt-flashcard-app .fc-audio-btn svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

/* Loading spinner while the TTS proxy request is in flight. */
.tbt-flashcard-app .fc-audio-btn.is-loading {
  cursor: wait;
}

.tbt-flashcard-app .fc-audio-btn.is-loading svg {
  opacity: 0;
}

.tbt-flashcard-app .fc-audio-btn.is-loading::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid rgba(8, 86, 201, 0.25);
  border-top-color: var(--tbt-blue);
  animation: tbt-fc-spin 0.8s linear infinite;
}

/* Transient error state when the proxy call fails. */
.tbt-flashcard-app .fc-audio-btn.has-error {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  animation: tbt-fc-shake 0.4s ease-in-out;
}

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

@keyframes tbt-fc-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

/* ── Back card ── */
.tbt-flashcard-app .fc-card-back {
  background: var(--tbt-blue);
  border: none;
  transform: rotateY(180deg);
  gap: 16px;
}

.tbt-flashcard-app .fc-card-back::before {
  display: none;
}

.tbt-flashcard-app .fc-translation {
  font-weight: 700;
  font-size: 34px;
  color: #ffffff;
  text-align: center;
  line-height: 1.3;
}

.tbt-flashcard-app .fc-phonetic {
  font-family: 'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', monospace;
  font-size: 16px;
  font-weight: 400;
  color: rgba(255,255,255,0.7);
  text-align: center;
  background: rgba(0,0,0,0.15);
  padding: 6px 16px;
  border-radius: 8px;
}

.tbt-flashcard-app .fc-back-divider {
  width: 80%;
  border-top: 1px solid rgba(255,255,255,0.15);
}

.tbt-flashcard-app .fc-example {
  font-size: 19px;
  font-weight: 300;
  font-style: italic;
  color: #ffffff;
  text-align: center;
  line-height: 1.5;
  max-width: 90%;
}

.tbt-flashcard-app .fc-example:not(:empty)::before {
  content: '\201C';
}

.tbt-flashcard-app .fc-example:not(:empty)::after {
  content: '\201D';
}

/* ── Navigation ── */
.tbt-flashcard-app .fc-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tbt-flashcard-app .fc-nav-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: white;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
}

.tbt-flashcard-app .fc-nav-btn:hover:not(:disabled) {
  border-color: var(--tbt-blue);
  color: var(--tbt-blue);
  box-shadow: 0 2px 12px var(--tbt-blue-glow);
  transform: translateY(-1px);
}

.tbt-flashcard-app .fc-nav-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.tbt-flashcard-app .fc-nav-btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* ── Finish card ── */
.tbt-flashcard-app .fc-finish-message {
  font-weight: 700;
  font-size: 28px;
  color: var(--tbt-blue);
  text-align: center;
  line-height: 1.4;
}

.tbt-flashcard-app .fc-finish-sub {
  font-weight: 300;
  font-size: 18px;
  color: var(--text-secondary);
  text-align: center;
  margin-top: 8px;
}

/* ── Confetti canvas ── */
.tbt-flashcard-app .fc-confetti {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
}

/* ── Slide animations ── */
.tbt-flashcard-app .fc-card.slide-left {
  animation: tbt-fc-slideLeft 0.25s ease-out;
}

.tbt-flashcard-app .fc-card.slide-right {
  animation: tbt-fc-slideRight 0.25s ease-out;
}

@keyframes tbt-fc-slideLeft {
  0% { opacity: 0; transform: translateX(30px); }
  100% { opacity: 1; transform: translateX(0); }
}

@keyframes tbt-fc-slideRight {
  0% { opacity: 0; transform: translateX(-30px); }
  100% { opacity: 1; transform: translateX(0); }
}

/* ── Responsive ── */
@media (max-width: 480px) {
  .tbt-flashcard-app .fc-card-scene {
    height: 300px;
  }

  .tbt-flashcard-app .fc-word {
    font-size: 32px;
  }

  .tbt-flashcard-app .fc-translation {
    font-size: 24px;
  }

  .tbt-flashcard-app .fc-card-face {
    padding: 32px 24px;
  }

  .tbt-flashcard-app .fc-set-title {
    font-size: 15px;
  }

  .tbt-flashcard-app .fc-card-counter {
    top: 14px;
    right: 16px;
    font-size: 12px;
  }
}
