/**
 * Padhav Flashcards System - Independent Component
 * Location: assets/flashcard/flashcard.css
 */

#padhayi-flashcards {
  --card-radius: 28px;
  width: 100%;
  /* Size container so card fits viewport height and width nicely with 5:7 ratio */
  max-width: min(440px, calc((100vh - 220px) * (5 / 7)));
  margin: 0 auto;
  padding: 16px 8px;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  position: relative;
}

#padhayi-flashcards *,
#padhayi-flashcards *::before,
#padhayi-flashcards *::after {
  box-sizing: border-box;
}

/* =========================================================
   HEADER BAR (HINT ON TOP + ACTION BUTTONS)
   ========================================================= */
.fc-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 0 4px;
  gap: 10px;
}

#fc-hint {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #475569;
  background: #f1f5f9;
  padding: 6px 14px;
  border-radius: 999px;
  letter-spacing: 0.01em;
  margin: 0;
  border: 1px solid rgba(226, 232, 240, 0.85);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.03);
  transition: opacity 0.5s ease;
}

.fc-hint-icon {
  font-size: 13px;
  line-height: 1;
}

.fc-top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.fc-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid #e2e8f0;
  border-radius: 50%;
  background: #ffffff;
  color: #64748b;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.04);
}

.fc-action-btn:hover {
  background: #f8fafc;
  color: #0f172a;
  border-color: #cbd5e1;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.07);
}

.fc-action-btn:active {
  transform: scale(0.92);
}

.fc-action-btn svg {
  width: 15px;
  height: 15px;
}

.fc-action-btn.active {
  color: #059669;
  border-color: #a7f3d0;
  background: #ecfdf5;
}

/* =========================================================
   STAGE (STRICT 5:7 ASPECT RATIO)
   ========================================================= */
#fc-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 5 / 7;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  overflow: visible;
  perspective: 1200px;
}

#fc-stack {
  position: absolute;
  inset: 0;
  overflow: visible;
}

/* =========================================================
   CARD WITH DEEP ELEVATION SHADOWS
   ========================================================= */
.fc-card {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: var(--card-radius);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transform-origin: 50% 100%;
  will-change: transform, opacity;
  cursor: default;
  /* Deep, natural elevation shadows matching the reference design */
  box-shadow:
    0 24px 48px -12px rgba(15, 23, 42, 0.16),
    0 10px 22px -6px rgba(15, 23, 42, 0.08),
    0 0 0 1px rgba(15, 23, 42, 0.05);
}

.fc-card img,
.fc-card svg {
  pointer-events: none;
}

/* =========================================================
   FLIP MECHANISM (3D PERSPECTIVE)
   ========================================================= */
.fc-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.25, 1);
}

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

.fc-face {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  border-radius: var(--card-radius);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transform: translate3d(0, 0, 0);
  padding: 34px 30px;
  display: flex;
  flex-direction: column;
}

.fc-face::-webkit-scrollbar {
  display: none;
}

.fc-back {
  transform: rotateY(180deg) translate3d(0, 0, 0);
}

/* =========================================================
   ACTIVE CARD STATE
   ========================================================= */
.fc-active {
  cursor: grab;
}

.fc-active:active {
  cursor: grabbing;
}

/* =========================================================
   NORMAL SMOOTH TRANSITION
   ========================================================= */
.fc-smooth {
  transition:
    transform 0.78s cubic-bezier(0.35, 0, 0.25, 1),
    box-shadow 0.78s cubic-bezier(0.35, 0, 0.25, 1),
    opacity 0.65s cubic-bezier(0.35, 0, 0.25, 1);
}

/* =========================================================
   PHYSICAL THROW / NEXT ANIMATIONS (CALM, SMOOTH & MATCHING PREVIOUS)
   ========================================================= */
.fc-throw-left {
  transition: transform 0.78s cubic-bezier(0.35, 0, 0.25, 1) !important;
  transform: translate3d(calc(-50vw - 280px), 20px, 0) rotate(-22deg) !important;
  opacity: 1 !important;
  pointer-events: none !important;
}

.fc-throw-right {
  transition: transform 0.78s cubic-bezier(0.35, 0, 0.25, 1) !important;
  transform: translate3d(calc(50vw + 280px), 20px, 0) rotate(22deg) !important;
  opacity: 1 !important;
  pointer-events: none !important;
}

/* =========================================================
   TINDER STYLE BACK ANIMATION (SLIDES BACK IN FLUIDLY)
   ========================================================= */
.fc-previous-animation {
  transition: transform 0.78s cubic-bezier(0.35, 0, 0.25, 1) !important;
  opacity: 1 !important;
}

/* =========================================================
   CARD DESIGN & DECORATIONS
   ========================================================= */
.fc-top-accent {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 12px;
  border-top-left-radius: var(--card-radius);
  border-top-right-radius: var(--card-radius);
  z-index: 5;
}

/* Circular corner bubble exactly like image */
.fc-decoration-large {
  position: absolute;
  width: 170px;
  height: 170px;
  top: -30px;
  right: -30px;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0.85;
}

.fc-decoration-small {
  position: absolute;
  width: 96px;
  height: 96px;
  bottom: 80px;
  left: -48px;
  border-radius: 50%;
  opacity: 0.35;
  pointer-events: none;
}

/* =========================================================
   NUMBER BADGE (PILL IN TOP-LEFT)
   ========================================================= */
.fc-number {
  position: relative;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 6px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.03em;
  margin-top: 4px;
}

/* =========================================================
   QUESTION (FRONT)
   ========================================================= */
.fc-question-area {
  position: relative;
  z-index: 10;
  margin: auto 0;
  padding: 16px 0;
}

.fc-category {
  margin-bottom: 18px;
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.16em;
}

.fc-question {
  font-size: clamp(1.7rem, 5.2vw, 2.5rem);
  font-weight: 800;
  line-height: 1.24;
  letter-spacing: -0.035em;
  color: #0f172a;
  word-break: break-word;
}

.fc-think {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 24px;
  font-size: 12px;
  font-weight: 700;
  color: #64748b;
}

.fc-think-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 800;
}

.fc-card-footer {
  position: relative;
  z-index: 10;
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 12px;
}

.fc-flip-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  opacity: 0.85;
}

.fc-flip-indicator svg {
  width: 14px;
  height: 14px;
}

/* =========================================================
   ANSWER (BACK)
   ========================================================= */
.fc-answer-label {
  position: relative;
  z-index: 10;
  margin-top: 4px;
  margin-bottom: 18px;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.18em;
}

.fc-answer-area {
  position: relative;
  z-index: 10;
  margin: auto 0;
  padding: 12px 0;
}

.fc-answer {
  font-size: clamp(1.22rem, 4vw, 1.75rem);
  font-weight: 700;
  line-height: 1.5;
  color: #1e293b;
  word-break: break-word;
}

.fc-remember {
  margin-top: 22px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.75);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.03);
}

.fc-remember-label,
.fc-cue-label {
  margin-bottom: 4px;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.fc-remember-text {
  font-size: 13px;
  font-weight: 800;
  color: #1e293b;
  letter-spacing: 0.02em;
}

.fc-cue {
  margin-top: 10px;
  padding: 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.5);
}

.fc-cue-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.fc-cue-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  border-radius: 50%;
  background: white;
  font-size: 13px;
  font-weight: 900;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.05);
}

.fc-cue-label {
  color: #94a3b8;
}

.fc-cue-text {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.55;
  color: #334155;
}

/* =========================================================
   COMPLETION CARD
   ========================================================= */
.fc-completed-card {
  background: #ffffff !important;
  border: 2px solid #10b981;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 28px;
}

.fc-celebration-badge {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #d1fae5;
  color: #059669;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  margin-bottom: 20px;
  box-shadow: 0 8px 24px rgba(16, 185, 129, 0.2);
}

.fc-completed-title {
  font-size: 26px;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 8px;
}

.fc-completed-desc {
  font-size: 14px;
  color: #64748b;
  margin-bottom: 28px;
  line-height: 1.5;
}

.fc-completed-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 280px;
}

.fc-btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  background: #0f172a;
  color: #ffffff;
  border: none;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.15);
}

.fc-btn-primary:hover {
  background: #059669;
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(16, 185, 129, 0.25);
}

.fc-btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 24px;
  background: #f8fafc;
  color: #334155;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.fc-btn-secondary:hover {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #0f172a;
  transform: translateY(-1px);
}

/* =========================================================
   TINDER STYLE NAVIGATION (BOTTOM CONTROLS)
   ========================================================= */
#fc-navigation {
  position: relative;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-top: 24px;
}

#fc-previous,
#fc-next {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 62px;
  height: 62px;
  flex-shrink: 0;
  border-radius: 50%;
  background: #ffffff;
  cursor: pointer;
  outline: none;
  border: 1.5px solid rgba(226, 232, 240, 0.8);
  transition: all 0.28s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Tinder Rewind / Back button (Warm Amber / Gold) */
#fc-previous {
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.28);
  box-shadow:
    0 10px 24px -4px rgba(245, 158, 11, 0.28),
    0 4px 10px rgba(15, 23, 42, 0.05);
}

#fc-previous:hover {
  transform: scale(1.14);
  color: #d97706;
  border-color: rgba(245, 158, 11, 0.55);
  box-shadow:
    0 16px 36px -4px rgba(245, 158, 11, 0.42),
    0 6px 14px rgba(15, 23, 42, 0.08);
}

#fc-previous:active {
  transform: scale(0.90);
  box-shadow: 0 6px 16px -2px rgba(245, 158, 11, 0.3);
}

/* Tinder Like / Next button (Vibrant Emerald Green) */
#fc-next {
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.28);
  box-shadow:
    0 10px 24px -4px rgba(16, 185, 129, 0.3),
    0 4px 10px rgba(15, 23, 42, 0.05);
}

#fc-next:hover {
  transform: scale(1.14);
  color: #059669;
  border-color: rgba(16, 185, 129, 0.55);
  box-shadow:
    0 16px 36px -4px rgba(16, 185, 129, 0.45),
    0 6px 14px rgba(15, 23, 42, 0.08);
}

#fc-next:active {
  transform: scale(0.90);
  box-shadow: 0 6px 16px -2px rgba(16, 185, 129, 0.3);
}

#fc-previous svg,
#fc-next svg {
  width: 26px;
  height: 26px;
  transition: transform 0.22s ease;
}

#fc-previous:hover svg {
  transform: rotate(-16deg);
}

#fc-next:hover svg {
  transform: translateX(3px);
}

/* Counter pill in the center */
#fc-counter {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 94px;
  height: 44px;
  padding: 0 18px;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  background: #ffffff;
  font-size: 14px;
  font-weight: 800;
  color: #475569;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
}

/* =========================================================
   BOTTOM PROGRESS TRACK
   ========================================================= */
#fc-progress-wrapper {
  width: 100%;
  max-width: 380px;
  margin: 22px auto 0;
}

#fc-progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

#fc-progress-header span:first-child {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #94a3b8;
}

#fc-progress-text {
  font-size: 11px;
  font-weight: 800;
  color: #64748b;
}

#fc-progress-track {
  width: 100%;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #f1f5f9;
}

#fc-progress {
  width: 5%;
  height: 100%;
  border-radius: 999px;
  background: #10b981;
  transition: width 0.4s ease;
}

/* =========================================================
   MOBILE RESPONSIVENESS
   ========================================================= */
@media (max-width: 480px) {
  #padhayi-flashcards {
    padding-left: 10px;
    padding-right: 10px;
  }

  #fc-hint {
    font-size: 11px;
    padding: 5px 10px;
    gap: 4px;
    max-width: calc(100% - 130px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #fc-previous,
  #fc-next {
    width: 54px;
    height: 54px;
  }

  #fc-previous svg,
  #fc-next svg {
    width: 22px;
    height: 22px;
  }

  #fc-counter {
    min-width: 82px;
    height: 40px;
    font-size: 13px;
    padding: 0 14px;
  }

  .fc-face {
    padding: 24px 20px;
  }

  .fc-question {
    font-size: clamp(1.4rem, 6.5vw, 1.95rem);
  }

  .fc-answer {
    font-size: clamp(1.15rem, 5vw, 1.45rem);
  }

  .fc-category {
    margin-bottom: 14px;
  }

  .fc-think {
    margin-top: 16px;
  }

  .fc-remember {
    margin-top: 16px;
    padding: 12px;
  }

  .fc-cue {
    margin-top: 8px;
    padding: 12px;
  }
}

@media (max-height: 720px) {
  #padhayi-flashcards {
    max-width: min(380px, calc((100vh - 190px) * (5 / 7)));
    padding: 10px 6px;
  }

  .fc-top-bar {
    margin-bottom: 10px;
  }

  #fc-navigation {
    margin-top: 14px;
    gap: 14px;
  }

  #fc-previous,
  #fc-next {
    width: 52px;
    height: 52px;
  }

  .fc-face {
    padding: 20px 18px;
  }

  .fc-question {
    font-size: clamp(1.25rem, 5vw, 1.7rem);
  }

  .fc-answer {
    font-size: clamp(1.05rem, 4vw, 1.3rem);
  }

  .fc-category {
    margin-bottom: 10px;
  }

  .fc-think {
    margin-top: 10px;
  }

  .fc-remember {
    margin-top: 10px;
    padding: 10px;
  }

  .fc-cue {
    margin-top: 6px;
    padding: 10px;
  }

  #fc-progress-wrapper {
    margin-top: 12px;
  }
}
