/* ===========================================
   CUSTOM UI/UX ENHANCEMENTS - "Улучшайся"
   =========================================== */

/* Animated Gradient Text */
.text-gradient {
    background: linear-gradient(135deg, #10b981 0%, #059669 50%, #34d399 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Gradient Border Utility */
.gradient-border {
    position: relative;
    background: white;
    background-clip: padding-box;
    border: 2px solid transparent;
}

.gradient-border::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    margin: -2px;
    border-radius: inherit;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

/* Enhanced Pulse Animation (for icons) */
@keyframes pulse-glow {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(1.05);
    }
}

.pulse-glow {
    animation: pulse-glow 2s ease-in-out infinite;
}

/* Floating Animation (for hero elements) */
@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-10px);
    }
}

.animate-float {
    animation: float 3s ease-in-out infinite;
}

/* Card Lift Effect (hover) */
.card-lift {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card-lift:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px -10px rgba(16, 185, 129, 0.3);
}

/* Shimmer Loading Effect */
@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

.shimmer {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.3) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    background-size: 1000px 100%;
    animation: shimmer 2s infinite;
}

/* Icon Bounce on Hover */
.icon-bounce:hover svg {
    animation: bounce 0.5s ease;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-5px);
    }
}

/* Gradient Progress Bar Glow */
.progress-glow {
    position: relative;
    overflow: visible;
}

.progress-glow::after {
    content: '';
    position: absolute;
    inset: -2px;
    background: inherit;
    filter: blur(8px);
    opacity: 0.5;
    z-index: -1;
}

/* Enhanced Focus States */
.focus-ring:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.3);
}

/* Better Active States for Touch */
@media (hover: none) {
    .touch-feedback:active {
        transform: scale(0.97);
        transition: transform 0.1s;
    }
}

/* Stagger Animation for Lists */
@keyframes fade-in-up {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.stagger-item {
    animation: fade-in-up 0.4s ease-out;
}

.stagger-item:nth-child(1) { animation-delay: 0.05s; }
.stagger-item:nth-child(2) { animation-delay: 0.1s; }
.stagger-item:nth-child(3) { animation-delay: 0.15s; }
.stagger-item:nth-child(4) { animation-delay: 0.2s; }
.stagger-item:nth-child(5) { animation-delay: 0.25s; }

/* Smooth Height Transitions */
.transition-height {
    transition: height 0.3s ease-out, opacity 0.3s ease-out;
}

/* Custom Scrollbar (for modals) */
.custom-scrollbar::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border-radius: 10px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
}

/* Gradient Background Utilities */
.bg-gradient-radial {
    background: radial-gradient(circle at center, var(--tw-gradient-stops));
}

/* Glass Morphism Effect */
.glass {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Neon Glow Effect */
.neon-glow {
    text-shadow: 0 0 10px rgba(16, 185, 129, 0.5),
                 0 0 20px rgba(16, 185, 129, 0.3),
                 0 0 30px rgba(16, 185, 129, 0.1);
}

/* Smooth Reveal Animation */
@keyframes reveal {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.animate-reveal {
    animation: reveal 0.5s ease-out;
}

/* Gradient Text Shimmer Animation */
@keyframes text-shimmer {
    0% {
        background-position: 0% 50%;
    }
    100% {
        background-position: 100% 50%;
    }
}

.text-shimmer {
    background: linear-gradient(90deg, #10b981, #059669, #34d399, #10b981);
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: text-shimmer 3s linear infinite;
}

/* ===========================================
   PWA SPLASH SCREEN & LOADING ANIMATIONS
   =========================================== */

/* Splash screen container */
.pwa-splash {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: linear-gradient(135deg, #ffffff 0%, #ecfdf5 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.5s ease-out, visibility 0.5s ease-out;
}

.pwa-splash.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Splash content container */
.pwa-splash-content {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem;
    animation: splash-fade-in 0.6s ease-out;
}

/* Animated background circles */
.pwa-splash-circles {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 300px;
    height: 300px;
    pointer-events: none;
}

.pwa-circle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(5, 150, 105, 0.1) 100%);
}

.pwa-circle-1 {
    width: 300px;
    height: 300px;
    animation: pulse-circle 3s ease-in-out infinite;
}

.pwa-circle-2 {
    width: 240px;
    height: 240px;
    animation: pulse-circle 3s ease-in-out infinite 0.5s;
}

.pwa-circle-3 {
    width: 180px;
    height: 180px;
    animation: pulse-circle 3s ease-in-out infinite 1s;
}

@keyframes pulse-circle {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.3;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.1);
        opacity: 0.15;
    }
}

/* App icon */
.pwa-splash-icon {
    position: relative;
    z-index: 10;
    width: 80px;
    height: 80px;
    margin-bottom: 1.5rem;
    filter: drop-shadow(0 10px 20px rgba(16, 185, 129, 0.2));
    animation: icon-bounce 2s ease-in-out infinite;
}

.pwa-splash-icon svg {
    width: 100%;
    height: 100%;
}

@keyframes icon-bounce {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-8px);
    }
}

/* App title */
.pwa-splash-title {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 2rem;
    animation: text-shimmer-splash 3s ease-in-out infinite;
    background-size: 200% auto;
}

@keyframes text-shimmer-splash {
    0%, 100% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
}

/* Loading bar */
.pwa-splash-loader {
    width: 200px;
    height: 4px;
    background: rgba(16, 185, 129, 0.1);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.pwa-loader-bar {
    height: 100%;
    background: linear-gradient(90deg, #10b981 0%, #059669 50%, #10b981 100%);
    background-size: 200% 100%;
    border-radius: 999px;
    animation: loader-slide 1.5s ease-in-out infinite;
}

@keyframes loader-slide {
    0% {
        transform: translateX(-100%);
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        transform: translateX(100%);
        background-position: 0% 50%;
    }
}

/* Subtitle text */
.pwa-splash-subtitle {
    font-size: 0.875rem;
    color: #6b7280;
    font-weight: 500;
    animation: fade-in-up 0.8s ease-out 0.3s both;
}

@keyframes splash-fade-in {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Content fade-in after splash */
.app-content {
    opacity: 0;
    animation: content-fade-in 0.5s ease-out 0.3s forwards;
}

@keyframes content-fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .pwa-splash-title {
        font-size: 1.75rem;
    }

    .pwa-splash-circles {
        width: 250px;
        height: 250px;
    }

    .pwa-circle-1 {
        width: 250px;
        height: 250px;
    }

    .pwa-circle-2 {
        width: 200px;
        height: 200px;
    }

    .pwa-circle-3 {
        width: 150px;
        height: 150px;
    }
}

/* Safe area support for notched devices */
@supports (padding: env(safe-area-inset-top)) {
    .pwa-splash-content {
        padding-top: calc(2rem + env(safe-area-inset-top));
    }
}

/* ===========================================
   PULL-TO-REFRESH STYLES
   =========================================== */

/* Container */
.ptr-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 40;
    pointer-events: none;
    will-change: transform;
    background: linear-gradient(180deg,
        rgba(255, 255, 255, 1) 0%,
        rgba(255, 255, 255, 0.95) 80%,
        rgba(255, 255, 255, 0) 100%
    );
    padding-top: env(safe-area-inset-top, 0);
}

/* Indicator wrapper */
.ptr-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    margin-top: env(safe-area-inset-top, 0);
}

/* Arrow icon */
.ptr-arrow {
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    will-change: transform;
}

/* Spinner animation */
.ptr-spinner svg {
    animation: ptr-spin 1s linear infinite;
}

@keyframes ptr-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Success icon animation */
.ptr-success {
    animation: ptr-success-bounce 0.5s ease-out;
}

@keyframes ptr-success-bounce {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Text label */
.ptr-indicator p {
    user-select: none;
    -webkit-user-select: none;
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .ptr-indicator {
        padding: 0.75rem;
    }

    .ptr-indicator svg {
        width: 1.25rem;
        height: 1.25rem;
    }

    .ptr-indicator p {
        font-size: 0.75rem;
    }
}

/* Disable on desktop */
@media (hover: hover) and (pointer: fine) {
    .ptr-container {
        display: none;
    }
}

/* Disable native pull-to-refresh */
body {
    overscroll-behavior-y: contain;
}

/* ===========================================
   BOOK CARD ANIMATIONS & STYLES
   =========================================== */

/* Book card hover lift effect */
.book-card {
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.3s ease;
}

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

/* Progress bar animation */
.progress-bar-animated {
    position: relative;
    overflow: hidden;
}

.progress-bar-animated::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.3) 50%,
        transparent 100%
    );
    animation: progress-shimmer 2s ease-in-out infinite;
}

@keyframes progress-shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* Book cover placeholder animation */
.book-card .w-12.h-16 {
    position: relative;
    overflow: hidden;
}

.book-card .w-12.h-16::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent 30%,
        rgba(255, 255, 255, 0.1) 50%,
        transparent 70%
    );
    animation: book-shine 3s ease-in-out infinite;
}

@keyframes book-shine {
    0%, 100% {
        transform: rotate(45deg) translateY(100%);
    }
    50% {
        transform: rotate(45deg) translateY(-100%);
    }
}

/* Status badge pulse for reading */
.book-card .bg-blue-100.text-blue-700 {
    animation: reading-pulse 2s ease-in-out infinite;
}

@keyframes reading-pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* Book card expand animation */
.book-card [x-collapse] {
    transition: height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Action buttons hover effect */
.book-card button {
    transition: all 0.2s ease;
}

.book-card button:active {
    transform: scale(0.97);
}

/* Stagger animation for book list */
.book-card {
    animation: book-appear 0.4s ease-out;
    animation-fill-mode: both;
}

.book-card:nth-child(1) { animation-delay: 0.05s; }
.book-card:nth-child(2) { animation-delay: 0.1s; }
.book-card:nth-child(3) { animation-delay: 0.15s; }
.book-card:nth-child(4) { animation-delay: 0.2s; }
.book-card:nth-child(5) { animation-delay: 0.25s; }
.book-card:nth-child(6) { animation-delay: 0.3s; }
.book-card:nth-child(7) { animation-delay: 0.35s; }
.book-card:nth-child(8) { animation-delay: 0.4s; }

@keyframes book-appear {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Records section hover */
.bg-amber-50:hover,
.bg-blue-50:hover {
    transform: translateX(4px);
    transition: transform 0.2s ease;
}

/* Chart container styling */
#reading-chart {
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.05));
}
