/* Hebrew Learning App — Animations */

/* ── Card flip ── */
.card-scene {
  perspective: 1000px;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
}

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

.card-3d.flipped {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  width: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius);
  overflow: hidden;
}

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

/* ── Swipe feedback flashes ── */
@keyframes flashGreen {
  0%   { box-shadow: inset 0 0 0 4px var(--success), 0 0 60px rgba(45,158,95,0.5); }
  100% { box-shadow: none; }
}
@keyframes flashRed {
  0%   { box-shadow: inset 0 0 0 4px var(--danger), 0 0 60px rgba(192,57,43,0.5); }
  100% { box-shadow: none; }
}
.flash-know { animation: flashGreen 0.5s ease-out; }
.flash-review { animation: flashRed 0.5s ease-out; }

/* ── Swipe drag ── */
.card-3d.dragging {
  transition: none;
  cursor: grabbing;
}

/* ── Slide in from right ── */
@keyframes slideInRight {
  from { transform: translateX(60px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
.slide-in-right { animation: slideInRight 0.3s ease-out; }

/* ── Slide in from left ── */
@keyframes slideInLeft {
  from { transform: translateX(-60px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
.slide-in-left { animation: slideInLeft 0.3s ease-out; }

/* ── Fade up ── */
@keyframes fadeUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.fade-up { animation: fadeUp 0.4s ease-out; }

/* ── Bounce in ── */
@keyframes bounceIn {
  0%   { transform: scale(0.8); opacity: 0; }
  60%  { transform: scale(1.05); opacity: 1; }
  100% { transform: scale(1); }
}
.bounce-in { animation: bounceIn 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275); }

/* ── Progress ring animation ── */
@keyframes ringFill {
  from { stroke-dashoffset: 251.2; }
}
.ring-progress {
  animation: ringFill 1.2s ease-out forwards;
  transform-origin: 50% 50%;
  transform: rotate(-90deg);
}

/* ── Badge toast ── */
.badge-toast {
  position: fixed;
  bottom: calc(var(--nav-height) + 16px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink-2);
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.95rem;
  color: var(--paper);
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity 0.35s ease, transform 0.35s ease;
  z-index: 9999;
  white-space: nowrap;
}
.badge-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.badge-toast-icon {
  font-size: 1.6rem;
  font-family: 'Frank Ruhl Libre', serif;
}

/* ── Quiz answer animations ── */
@keyframes correctPulse {
  0%   { transform: scale(1); background: var(--success); }
  50%  { transform: scale(1.04); }
  100% { transform: scale(1); background: var(--success); }
}
@keyframes wrongShake {
  0%, 100% { transform: translateX(0); background: var(--danger); }
  20%  { transform: translateX(-8px); }
  40%  { transform: translateX(8px); }
  60%  { transform: translateX(-4px); }
  80%  { transform: translateX(4px); }
}
.answer-correct { animation: correctPulse 0.4s ease-out forwards; }
.answer-wrong   { animation: wrongShake 0.4s ease-out forwards; }

/* ── Learn stage reveal ── */
@keyframes stageReveal {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.stage-reveal { animation: stageReveal 0.35s ease-out; }

/* ── Encyclopedia panel slide ── */
@keyframes panelSlideIn {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}
@keyframes panelSlideOut {
  from { transform: translateX(0); }
  to   { transform: translateX(100%); }
}
.panel-enter { animation: panelSlideIn 0.35s cubic-bezier(0.4, 0, 0.2, 1); }
.panel-exit  { animation: panelSlideOut 0.3s ease-in; }

/* ── Skeleton loading ── */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--ink-2) 25%, var(--ink-3) 50%, var(--ink-2) 75%);
  background-size: 800px 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius-sm);
  color: transparent !important;
}

/* ── Completion screen ── */
@keyframes popIn {
  0%   { transform: scale(0) rotate(-15deg); opacity: 0; }
  70%  { transform: scale(1.1) rotate(3deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); }
}
.pop-in { animation: popIn 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; }

/* ── Stagger children ── */
.stagger-children > * {
  opacity: 0;
  animation: fadeUp 0.4s ease-out forwards;
}
.stagger-children > *:nth-child(1) { animation-delay: 0.05s; }
.stagger-children > *:nth-child(2) { animation-delay: 0.12s; }
.stagger-children > *:nth-child(3) { animation-delay: 0.19s; }
.stagger-children > *:nth-child(4) { animation-delay: 0.26s; }
.stagger-children > *:nth-child(5) { animation-delay: 0.33s; }
.stagger-children > *:nth-child(6) { animation-delay: 0.40s; }
