/* ──────────────────────────────────────────────
   UPSCALE — Flashcards App CSS
────────────────────────────────────────────── */

/* ── Page layout ── */
.fc-page {
  max-width: 900px;
  margin: 0 auto;
  padding: 32px 16px 60px;
  min-height: calc(100vh - 70px);
}

/* Due badge on home page */
.due-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  background: rgba(var(--gold-rgb),0.2);
  color: var(--gold);
  border: 1px solid rgba(var(--gold-rgb),0.3);
  animation: pulseBadge 2s ease-in-out infinite;
}
@keyframes pulseBadge {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.7; }
}

/* Breadcrumb */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 24px;
}
.breadcrumb a { color: var(--indigo-light); }
.breadcrumb a:hover { color: var(--indigo); }
.breadcrumb-sep { color: var(--text-muted); }

/* Empty state */
.fc-empty {
  text-align: center;
  padding: 60px 24px;
  max-width: 400px;
  margin: 0 auto;
}
.fc-empty-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.5; }
.fc-empty-title { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.fc-empty-text  { font-size: 14px; color: var(--text-muted); line-height: 1.6; margin-bottom: 24px; }

/* ── STUDY SESSION ── */
.study-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 0;
}

/* The session HUD reads as one floating bar rather than a hairline strip:
   it is the only chrome on the page, so it carries the deck name, progress
   and exit together on a white pill with the kit's card shadow. */
.study-header {
  margin: 14px auto 0;
  width: min(1040px, calc(100% - 28px));
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-radius: var(--radius-full);
  background: #fff;
  box-shadow: var(--shadow-card);
  position: sticky;
  top: 14px;
  z-index: 50;
}

.study-title {
  font-family: var(--font-display);
  font-size: 15.5px;
  font-weight: 800;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}
.study-title .clay { flex: none; }
.study-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.study-progress-bar-wrap {
  flex: 1;
  max-width: 300px;
}
.study-progress-track {
  height: 8px;
  background: var(--m-flashcard-duel-tint);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.study-progress-fill {
  height: 100%;
  background: var(--m-flashcard-duel);
  border-radius: var(--radius-full);
  transition: width 0.4s var(--ease-out, ease);
}

.study-counter {
  font-family: var(--font-display);
  font-size: 13.5px;
  font-weight: 800;
  color: var(--ink-2);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.study-close {
  width: 34px; height: 34px;
  flex: none;
  background: var(--bg-soft);
  border: 0;
  border-radius: 50%;
  color: var(--ink-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.study-close:hover { background: var(--m-flashcard-duel-tint); color: var(--ink); }

.study-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  gap: 24px;
  touch-action: none;
}

/* ── 3D Flip Card ── */
.fc-card-scene {
  width: 100%;
  max-width: 600px;
  height: 320px;
  perspective: 1200px;
  cursor: pointer;
  position: relative;
}

.fc-card {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.4, 0.2, 0.2, 1);
  border-radius: var(--radius-lg);
}

.fc-card.flipped { transform: rotateY(180deg); }
.fc-card.dragging { transition: none; }

.fc-card-face {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-lg);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 36px 32px;
  text-align: center;
  /* A solid card, not a tinted pane: at 5% overlay it was barely separable
     from the page and the whole screen read as empty. */
  background: #fff;
  border: 0;
  box-shadow: var(--shadow-float, 0 18px 44px rgba(30, 27, 75, 0.14)),
              inset 0 0 0 1.5px rgba(30, 27, 75, 0.06);
}

.fc-card-front { }
/* the answer side takes the method's tint so the flip is legible at a glance */
.fc-card-back {
  transform: rotateY(180deg);
  background: linear-gradient(165deg, #fff 0%, var(--m-flashcard-duel-tint2) 60%, var(--m-flashcard-duel-tint) 100%);
  box-shadow: var(--shadow-float, 0 18px 44px rgba(30, 27, 75, 0.14)),
              inset 0 0 0 1.5px rgba(var(--m-flashcard-duel-rgb), 0.18);
}

.fc-card-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 20px;
}
.fc-card-back .fc-card-label { color: var(--indigo-light); }

.fc-card-question {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.45;
}

.fc-card-answer {
  font-size: 15px;
  color: var(--text-primary);
  line-height: 1.7;
  white-space: pre-line;
  max-height: 200px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(var(--overlay-rgb), 0.1) transparent;
}

.fc-card-hint {
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.fc-tap-hint {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 16px;
  animation: tapPulse 2s ease-in-out infinite;
}
@keyframes tapPulse {
  0%, 100% { opacity: 0.6; }
  50%       { opacity: 1; }
}

.fc-card-status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  position: absolute;
  top: 14px; right: 14px;
}
.dot-new      { background: var(--indigo-light); }
.dot-learning { background: var(--gold); }
.dot-review   { background: var(--emerald); }
.dot-mastered { background: var(--purple); }

/* Swipe direction overlays */
.swipe-overlay {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-lg);
  opacity: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 22px;
  font-weight: 800;
  pointer-events: none;
  transition: opacity 0.1s ease;
  z-index: 10;
}
.swipe-overlay .overlay-label { font-size: 14px; font-weight: 700; }
.swipe-overlay.right { background: rgba(var(--emerald-rgb),0.2);  color: var(--emerald); border: 2px solid rgba(var(--emerald-rgb),0.4); border-radius: var(--radius-lg); }
.swipe-overlay.left  { background: rgba(var(--rose-rgb),0.2);   color: var(--rose);    border: 2px solid rgba(var(--rose-rgb),0.4); border-radius: var(--radius-lg); }
.swipe-overlay.up    { background: rgba(var(--accent-rgb),0.2);  color: var(--indigo-light); border: 2px solid rgba(var(--accent-rgb),0.4); border-radius: var(--radius-lg); }
.swipe-overlay.down  { background: rgba(var(--warning-rgb),0.2);  color: var(--warning);   border: 2px solid rgba(var(--warning-rgb),0.4); border-radius: var(--radius-lg); }

/* Mobile swipe hint strip */
.swipe-hints {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 20px;
  font-size: 11px;
  color: var(--text-muted);
  padding: 8px 16px;
  background: rgba(var(--overlay-rgb), 0.03);
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
}
.swipe-hint-item { display: flex; align-items: center; gap: 4px; }
.swipe-hint-item .arrow { font-size: 14px; }
.swipe-hint-item .sh-label { font-size: 10px; }

/* ── Rating buttons ── */
.rating-area {
  width: 100%;
  max-width: 600px;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}
.rating-area.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.rating-btns {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.rating-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 15px 10px 13px;
  border-radius: 20px;
  border: 0;
  cursor: pointer;
  transition: transform var(--transition-base), box-shadow var(--transition-base);
  font-family: var(--font-display);
  font-size: 14.5px;
  font-weight: 800;
  line-height: 1.2;
  /* solid tinted surfaces with a ring, matching the kit's chips and cards —
     these were transparent outlines that disappeared against the page */
  box-shadow: var(--shadow-card);
}
.rating-btn:hover { transform: translateY(-3px); box-shadow: var(--shadow-card-hover); }
.rating-btn:active { transform: translateY(0); }

.rating-btn .rb-emoji   { font-size: 20px; margin-bottom: 2px; }
/* 9-10px was below the point of being readable; these carry the keyboard
   shortcut and the next-interval preview, which are the useful parts. */
.rating-btn .rb-key     { font-family: var(--font-body); font-size: 11px; font-weight: 600; opacity: 0.72; letter-spacing: 0.2px; }
.rating-btn .rb-preview { font-family: var(--font-body); font-size: 11.5px; font-weight: 700; opacity: 0.85; margin-bottom: 1px; }
.rating-btn .rb-preview::before { content: '['; }
.rating-btn .rb-preview::after  { content: ']'; }

.rating-btn.forgot {
  background: #FFE4EF; color: #BE185D;
  box-shadow: var(--shadow-card), inset 0 0 0 1.5px rgba(236, 72, 153, 0.22);
}
.rating-btn.hard {
  background: #FFF6D6; color: #B45309;
  box-shadow: var(--shadow-card), inset 0 0 0 1.5px rgba(245, 158, 11, 0.22);
}
.rating-btn.good {
  background: #EDEBFF; color: #4338CA;
  box-shadow: var(--shadow-card), inset 0 0 0 1.5px rgba(79, 70, 229, 0.22);
}
.rating-btn.easy {
  background: #DDF7F0; color: #0F766E;
  box-shadow: var(--shadow-card), inset 0 0 0 1.5px rgba(20, 184, 166, 0.22);
}
.rating-btn.forgot:hover { box-shadow: var(--shadow-card-hover), inset 0 0 0 1.5px rgba(236, 72, 153, 0.4); }
.rating-btn.hard:hover   { box-shadow: var(--shadow-card-hover), inset 0 0 0 1.5px rgba(245, 158, 11, 0.4); }
.rating-btn.good:hover   { box-shadow: var(--shadow-card-hover), inset 0 0 0 1.5px rgba(79, 70, 229, 0.4); }
.rating-btn.easy:hover   { box-shadow: var(--shadow-card-hover), inset 0 0 0 1.5px rgba(20, 184, 166, 0.4); }

.rating-btn.loading {
  pointer-events: none;
  opacity: 0.5;
}

/* ── Session complete overlay ── */
.session-complete {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--scrim-bg);
  backdrop-filter: blur(12px);
}
.session-complete.show { display: flex; }

.session-complete-card {
  max-width: 400px;
  width: 90%;
  padding: 48px 36px;
  text-align: center;
  background: #fff;
  border-radius: 24px;
  box-shadow: var(--shadow-float);
  animation: scaleIn 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes scaleIn {
  from { transform: scale(0.85); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.sc-trophy { margin-bottom: 16px; display: flex; justify-content: center; }
.sc-title   { font-size: 26px; font-weight: 800; margin-bottom: 8px; }
.sc-sub     { font-size: 14px; color: var(--text-muted); margin-bottom: 28px; line-height: 1.6; }
.sc-xp      { font-size: 36px; font-weight: 800; color: var(--gold); margin-bottom: 4px; }
.sc-xp-label{ font-size: 12px; color: var(--text-muted); margin-bottom: 28px; }
.sc-stats   { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 28px; }
.sc-stat    { padding: 12px 8px; background: rgba(var(--overlay-rgb), 0.04); border-radius: var(--radius-md); border: 1px solid var(--border-subtle); }
.sc-stat-val{ font-size: 22px; font-weight: 700; margin-bottom: 2px; }
.sc-stat-lbl{ font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.sc-actions { display: flex; gap: 10px; }

/* Card exit animation */
.fc-card-scene.exit-right { animation: slideRight 0.35s ease forwards; }
.fc-card-scene.exit-left  { animation: slideLeft  0.35s ease forwards; }
.fc-card-scene.exit-up    { animation: slideUp    0.35s ease forwards; }
.fc-card-scene.exit-down  { animation: slideDown  0.35s ease forwards; }
.fc-card-scene.enter      { animation: cardEnter  0.35s ease forwards; }

@keyframes slideRight { to { transform: translateX(120%) rotate(10deg); opacity: 0; } }
@keyframes slideLeft  { to { transform: translateX(-120%) rotate(-10deg); opacity: 0; } }
@keyframes slideUp    { to { transform: translateY(-80%) scale(0.9); opacity: 0; } }
@keyframes slideDown  { to { transform: translateY(80%) scale(0.9); opacity: 0; } }
@keyframes cardEnter  { from { transform: scale(0.92) translateY(20px); opacity: 0; } to { transform: scale(1) translateY(0); opacity: 1; } }

/* No cards state */
.no-cards-state {
  text-align: center;
  padding: 60px 24px;
}
.no-cards-icon  { margin-bottom: 16px; display: flex; justify-content: center; }
.no-cards-title { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.no-cards-text  { font-size: 14px; color: var(--text-muted); margin-bottom: 24px; line-height: 1.6; }

/* ── Stats page ── */
.stats-overview {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.stats-table { width: 100%; border-collapse: collapse; }
.stats-table th, .stats-table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border-subtle); font-size: 13px; }
.stats-table th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); font-weight: 600; }
.stats-table tr:last-child td { border-bottom: none; }
.stats-table tr:hover td { background: rgba(var(--overlay-rgb), 0.02); }

.stats-subject-badge {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 600; padding: 2px 8px;
  border-radius: 999px; margin: 2px 4px 2px 0;
  background: rgba(var(--overlay-rgb), 0.06); color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.progress-bar { height: 6px; background: rgba(var(--overlay-rgb), 0.06); border-radius: var(--radius-full); overflow: hidden; width: 80px; display: inline-block; vertical-align: middle; margin-left: 8px; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--rose), var(--gold), var(--emerald)); border-radius: var(--radius-full); }

/* ── Responsive ── */
@media (max-width: 900px) {
  .fc-card-scene { height: 280px; }
}

@media (max-width: 640px) {
  .fc-card-scene { height: 260px; max-width: 100%; }
  .fc-card-face  { padding: 24px 20px; }
  .fc-card-question { font-size: 17px; }

  .rating-btns { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .rating-btn  { padding: 12px 6px; font-size: 12px; }
  .rating-btn .rb-emoji { font-size: 18px; }

  .swipe-hints { display: flex; }

  .stats-overview { grid-template-columns: repeat(2, 1fr); }
  .sc-stats { grid-template-columns: repeat(3, 1fr); }
  .sc-actions { flex-direction: column; }

  .study-header { padding: 12px 16px; gap: 10px; }
  .study-progress-bar-wrap { display: none; }

  .stats-table th, .stats-table td { padding: 10px 12px; font-size: 12px; }
}

@media (max-width: 400px) {
  .fc-card-face { padding: 20px 16px; }
  .fc-card-question { font-size: 15px; }
  .rating-btn .rb-emoji { font-size: 16px; }
  .sc-stats { grid-template-columns: repeat(2, 1fr); }
  .stats-overview { grid-template-columns: 1fr 1fr; }
}
