/* ===================================================
   PrepForge — Animations CSS
   Micro-interactions, transitions, keyframes
   =================================================== */

/* ─── Page Transitions ───────────────────────────────── */
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes fadeOut {
    from { opacity: 1; }
    to   { opacity: 0; }
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-16px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideInRight {
    from { opacity: 0; transform: translateX(40px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes slideOutRight {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(40px); }
}
@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.92); }
    to   { opacity: 1; transform: scale(1); }
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%      { transform: translateX(-8px); }
    40%      { transform: translateX(8px); }
    60%      { transform: translateX(-6px); }
    80%      { transform: translateX(6px); }
}
@keyframes inkDrop {
    0%   { transform: scale(0); opacity: 0.6; }
    60%  { transform: scale(1.3); opacity: 0.15; }
    100% { transform: scale(1.8); opacity: 0; }
}
@keyframes spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50%       { transform: scale(1.05); }
}
@keyframes shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position:  200% 0; }
}
@keyframes flipIn {
    from { transform: rotateY(-90deg); opacity: 0; }
    to   { transform: rotateY(0deg);   opacity: 1; }
}
@keyframes bounceIn {
    0%   { transform: scale(0.3); opacity: 0; }
    50%  { transform: scale(1.1); }
    70%  { transform: scale(0.95); }
    100% { transform: scale(1); opacity: 1; }
}
@keyframes penWrite {
    from { stroke-dashoffset: 300; }
    to   { stroke-dashoffset: 0; }
}
@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50%       { transform: translateY(-6px); }
}
@keyframes glow {
    0%, 100% { box-shadow: 0 0 8px rgba(245,158,11,0.3); }
    50%       { box-shadow: 0 0 20px rgba(245,158,11,0.6); }
}
@keyframes progressBar {
    from { width: 0; }
}
@keyframes countUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes heatCell {
    from { transform: scale(0); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}

/* ─── Applied Animations ─────────────────────────────── */
.page-enter  { animation: slideUp 0.3s ease forwards; }
.fade-in     { animation: fadeIn 0.25s ease forwards; }
.scale-in    { animation: scaleIn 0.25s cubic-bezier(0.34,1.56,0.64,1) forwards; }
.shake       { animation: shake 0.4s ease; }
.spin        { animation: spin 1s linear infinite; }
.float       { animation: float 3s ease-in-out infinite; }
.pulse       { animation: pulse 2s ease-in-out infinite; }

/* Skeleton loader */
.skeleton {
    background: linear-gradient(90deg, var(--bg-hover) 25%, var(--border) 50%, var(--bg-hover) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-md);
}

/* Spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
}
.spinner-lg {
    width: 36px;
    height: 36px;
    border-width: 3px;
}

/* ─── Flashcard 3D Flip ──────────────────────────────── */
.flashcard-scene {
    perspective: 800px;
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    height: 280px;
}
.flashcard {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.55s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}
.flashcard.flipped { transform: rotateY(180deg); }
.flashcard-face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    box-shadow: var(--shadow-paper);
    transition: border-color 0.3s;
}
.flashcard-face.front { border-color: var(--accent-blue); }
.flashcard-face.back  { transform: rotateY(180deg); border-color: var(--accent-green); }
.flashcard-face.front:hover { box-shadow: 0 8px 32px rgba(37,99,235,0.2); }

/* ─── Progress Bar ───────────────────────────────────── */
.progress-bar-wrap {
    height: 6px;
    background: var(--bg-hover);
    border-radius: var(--radius-full);
    overflow: hidden;
}
.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-purple));
    border-radius: var(--radius-full);
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    animation: glow 2s ease-in-out infinite;
}

/* ─── Stat Card Number Animation ─────────────────────── */
.stat-number { animation: countUp 0.6s cubic-bezier(0.34,1.56,0.64,1) both; }

/* ─── Hover Lift (cards) ─────────────────────────────── */
.hover-lift { transition: transform var(--transition), box-shadow var(--transition); }
.hover-lift:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

/* ─── Ink splash ripple on click ─────────────────────── */
.ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(37,99,235,0.18);
    animation: inkDrop 0.6s ease-out forwards;
    pointer-events: none;
}

/* ─── Nav item hover shimmer ─────────────────────────── */
.nav-item::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, rgba(255,255,255,0.06), transparent);
    opacity: 0;
    transition: opacity var(--transition);
}
.nav-item:hover::after { opacity: 1; }

/* ─── Dashboard heat map cells ───────────────────────── */
.heat-cell {
    animation: heatCell 0.3s ease both;
}

/* ─── Exam option states ─────────────────────────────── */
.option-card {
    transition: all var(--transition);
    cursor: pointer;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.option-card:hover { border-color: var(--accent-blue); background: var(--accent-blue-bg); transform: translateX(4px); }
.option-card.selected { border-color: var(--accent-blue); background: var(--accent-blue-bg); }
.option-card.correct  { border-color: var(--accent-green); background: var(--accent-green-bg); }
.option-card.wrong    { border-color: var(--accent-red); background: var(--accent-red-bg); }

/* ─── Page Loading Overlay ───────────────────────────── */
.page-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    gap: 0.75rem;
    color: var(--ink-muted);
    font-size: 0.9rem;
}

/* ─── Notification dot ───────────────────────────────── */
.notification-dot {
    width: 8px;
    height: 8px;
    background: var(--accent-red);
    border-radius: 50%;
    animation: pulse 1.5s ease-in-out infinite;
}

/* ─── View toggle ────────────────────────────────────── */
.view-toggle {
    display: flex;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}
.view-toggle-btn {
    padding: 0.4rem 0.7rem;
    background: transparent;
    color: var(--ink-muted);
    font-size: 0.85rem;
    transition: all var(--transition);
}
.view-toggle-btn.active { background: var(--accent); color: #fff; }
.view-toggle-btn:hover:not(.active) { background: var(--bg-hover); color: var(--ink-primary); }
