/* Custom Animations and Micro-interactions */
body {
    -webkit-tap-highlight-color: transparent;
    font-size: 1rem;
    overflow-x: hidden;
}

:root {
    font-size: 16.5px;
}

@media (min-width: 768px) {
    :root {
        font-size: 17px;
    }
}

@media (max-width: 380px) {
    :root {
        font-size: 16px;
    }
}

#app {
    min-height: 100svh;
}

#app.study-mode {
    padding-bottom: 0 !important;
    overflow: hidden;
}

/* Glassmorphism utilities */
.glass {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.dark .glass {
    background: rgba(30, 41, 59, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Loader */
.loader {
    border-top-color: #6366f1;
    -webkit-animation: spinner 1.5s linear infinite;
    animation: spinner 1.5s linear infinite;
}

@keyframes spinner {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Animations */
.fade-in {
    animation: fadeIn 0.3s ease-out forwards;
}

.slide-up {
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.slide-in-right {
    animation: slideInRight 0.3s ease-out forwards;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes slideInRight {
    from { transform: translateX(50px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

.dark ::-webkit-scrollbar-thumb {
    background: #475569;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Card Hover Effects */
.hover-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.hover-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

/* Flashcard Flip Animation */
.perspective-1000 {
    perspective: 1000px;
}

.transform-style-3d {
    transform-style: preserve-3d;
}

.backface-hidden {
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.rotate-y-180 {
    transform: rotateY(180deg);
}

.flip-card-inner {
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

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

/* Gradient text */
.text-gradient {
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-image: linear-gradient(to right, #6366f1, #ec4899);
}

/* Responsive study/check surfaces */
.app-screen {
    min-height: 100svh;
}

.study-shell {
    height: 100svh;
    min-height: 100svh;
    overflow: hidden;
}

.study-header,
.study-footer {
    flex: 0 0 auto;
}

.study-main {
    flex: 1 1 auto;
    min-height: 0;
    padding: clamp(0.5rem, 2svh, 1rem);
}

.study-footer {
    padding: clamp(0.5rem, 1.8svh, 1rem);
    padding-bottom: max(clamp(0.5rem, 1.8svh, 1rem), env(safe-area-inset-bottom));
}

.study-card {
    max-height: 100%;
}

.study-content {
    min-height: clamp(13rem, 42svh, 20rem);
    max-height: 100%;
    padding: clamp(1rem, 3.2svh, 2rem);
    overflow: hidden;
}

.fit-text {
    font-size: clamp(var(--fit-min, 1.25rem), var(--fit-fluid, 8vw), var(--fit-max, 3.6rem));
    line-height: 1.12;
    overflow-wrap: anywhere;
    word-break: break-word;
    hyphens: auto;
}

.meaning-text {
    line-height: 1.42;
}

.compact-status-row span:first-child {
    min-width: 0;
}

.home-card button {
    min-width: 0;
    white-space: normal;
    line-height: 1.2;
}

@media (max-width: 640px) {
    .study-header {
        padding: 0.55rem 0.65rem;
    }

    .study-main {
        padding: 0.55rem;
    }

    .study-content {
        min-height: clamp(11.5rem, 38svh, 16rem);
        padding: 0.95rem;
    }

    .study-footer {
        padding-left: 0.65rem;
        padding-right: 0.65rem;
    }

    .study-action {
        padding-top: 0.75rem !important;
        padding-bottom: 0.75rem !important;
        font-size: 1rem !important;
    }

    .home-group-grid {
        gap: 0.6rem;
    }
}
