/**
 * Atlas Enhancements Stylesheet
 * Enhanced animations, micro-interactions, and visual polish
 */

/* ========================================
   IMPROVED ANIMATIONS & TRANSITIONS
   ======================================== */

/* Smooth all transitions */
* {
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Enhanced button interactions */
.hero-button,
.nav-link,
.nav-tab,
.action-btn,
.form-button,
button {
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.hero-button::after,
.nav-link::after,
.action-btn::after,
.form-button::after,
button:not(.burger-menu)::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
    pointer-events: none;
}

.hero-button:active::after,
.nav-link:active::after,
.action-btn:active::after,
.form-button:active::after,
button:not(.burger-menu):active::after {
    width: 300px;
    height: 300px;
    transition: width 0s, height 0s;
}

/* Loading state for buttons */
.form-button.loading,
button.loading {
    pointer-events: none;
    position: relative;
}

.form-button.loading::before,
button.loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ========================================
   BACK TO TOP BUTTON
   ======================================== */

.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 50px;
    height: 50px;
    background: var(--primary);
    color: white;
    border: 3px solid var(--dark);
    cursor: pointer;
    box-shadow: 6px 6px 0 var(--dark);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.9);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.back-to-top:hover {
    transform: translate(-2px, -2px);
    box-shadow: 8px 8px 0 var(--dark);
}

.back-to-top:active {
    transform: translate(2px, 2px);
    box-shadow: 4px 4px 0 var(--dark);
}

.back-to-top svg {
    width: 24px;
    height: 24px;
    stroke-width: 2.5px;
}

@media (max-width: 768px) {
    .back-to-top {
        bottom: 1rem;
        right: 1rem;
        width: 44px;
        height: 44px;
    }

    .back-to-top svg {
        width: 20px;
        height: 20px;
    }
}

/* ========================================
   COPY TO CLIPBOARD BUTTON
   ======================================== */

.copy-btn {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid var(--dark);
    padding: 0.5rem;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.1);
}

pre:hover .copy-btn {
    opacity: 1;
}

.copy-btn:hover {
    transform: translate(-1px, -1px);
    box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.15);
}

.copy-btn:active {
    transform: translate(1px, 1px);
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.1);
}

.copy-btn svg {
    display: block;
    width: 16px;
    height: 16px;
}

.copy-feedback {
    position: absolute;
    top: -30px;
    right: 0;
    background: var(--dark);
    color: white;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.copy-btn.copied .copy-feedback {
    opacity: 1;
}

.copy-btn.copied {
    background: var(--green);
    border-color: var(--green);
}

.copy-btn.copied svg {
    stroke: white;
}

/* ========================================
   ENHANCED FOCUS INDICATORS
   ======================================== */

.keyboard-focus {
    outline: 3px solid var(--primary) !important;
    outline-offset: 2px;
}

.mouse-focus {
    outline: none !important;
}

/* ========================================
   IMPROVED FORM VALIDATION
   ======================================== */

input.invalid,
textarea.invalid,
select.invalid {
    border-color: var(--red) !important;
    background: rgba(239, 68, 68, 0.05);
}

.error-message {
    display: block;
    color: var(--red);
    font-size: 0.875rem;
    font-weight: 600;
    margin-top: 0.5rem;
    animation: slideDown 0.3s ease;
}

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

/* ========================================
   ENHANCED TOOLTIPS
   ======================================== */

[data-tooltip] {
    position: relative;
}

.tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    background: var(--dark);
    color: white;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 600;
    white-space: nowrap;
    border-radius: 4px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    z-index: 1000;
}

.tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--dark);
}

.tooltip.visible {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-12px);
}

/* ========================================
   IMPROVED SKELETON LOADING STATES
   ======================================== */

.skeleton {
    background: linear-gradient(
        90deg,
        rgba(241, 245, 249, 0.4) 25%,
        rgba(241, 245, 249, 0.8) 50%,
        rgba(241, 245, 249, 0.4) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
    border-radius: 4px;
}

.skeleton-title {
    height: 2rem;
    width: 60%;
    margin-bottom: 1rem;
    border-radius: 4px;
}

.skeleton-card {
    height: 200px;
    border-radius: 0;
    border: 3px solid var(--dark);
}

/* ========================================
   SMOOTH PAGE TRANSITIONS
   ======================================== */

main {
    animation: fadeInPage 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* ========================================
   ENHANCED CARD HOVER EFFECTS
   ======================================== */

.feature-card,
.topic-item,
.lesson-card,
.group-card,
.blog-article {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.feature-card:hover,
.topic-item:hover,
.lesson-card:hover,
.group-card:hover {
    transform: translate(-4px, -4px) scale(1.02);
}

.feature-card:active,
.topic-item:active,
.lesson-card:active,
.group-card:active {
    transform: translate(2px, 2px) scale(0.98);
}

/* ========================================
   IMPROVED NAVIGATION ANIMATIONS
   ======================================== */

.nav-actions {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-actions.active {
    animation: slideInMenu 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.nav-link,
.nav-tab {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-actions .nav-link {
    animation: fadeInStagger 0.3s ease backwards;
}

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

@keyframes fadeInStagger {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ========================================
   SUBTLE PARALLAX EFFECT
   ======================================== */

.hero-background {
    transform: translateZ(0);
    will-change: transform;
}

@media (prefers-reduced-motion: no-preference) {
    .floating-shape {
        animation-duration: 25s;
    }
}

/* ========================================
   IMPROVED MODAL ANIMATIONS
   ======================================== */

/* Disable modal animations - they interfere with dynamic content loading */
/* The lessons modal loads content asynchronously and needs to remain visible */

/* ========================================
   ENHANCED TOAST NOTIFICATIONS
   ======================================== */

.toast {
    animation: slideInToast 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slideInToast {
    from {
        opacity: 0;
        transform: translateY(100%) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ========================================
   ACCESSIBILITY IMPROVEMENTS
   ======================================== */

/* High contrast mode support */
@media (prefers-contrast: high) {
    .hero-button,
    .nav-link,
    .action-btn {
        border-width: 4px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .back-to-top.visible {
        transform: translateY(0) scale(1);
    }

    .floating-shape {
        animation: none;
    }
}

/* ========================================
   IMPROVED LINK STATES
   ======================================== */

a:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

a:not(.nav-link):not(.hero-button):not(.action-btn):hover {
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
}

/* ========================================
   ENHANCED FORM ELEMENTS
   ======================================== */

input:focus,
textarea:focus,
select:focus {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.15);
}

input[type="checkbox"],
input[type="radio"] {
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

input[type="checkbox"]:hover,
input[type="radio"]:hover {
    transform: scale(1.1);
}

/* ========================================
   PERFORMANCE OPTIMIZATIONS
   ======================================== */

.hero-background,
.feature-card,
.floating-shape {
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Force GPU acceleration for smooth animations */
.hero-button,
.nav-link,
.action-btn,
.back-to-top {
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* ========================================
   IMPROVED MOBILE INTERACTIONS
   ======================================== */

@media (max-width: 768px) {
    /* Larger touch targets */
    button,
    a,
    input,
    select,
    textarea {
        min-height: 44px;
        min-width: 44px;
    }

    /* Improved burger menu animation */
    .burger-menu span {
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .burger-menu.active span:nth-child(1) {
        transform: rotate(45deg) translate(7px, 7px);
    }

    .burger-menu.active span:nth-child(3) {
        transform: rotate(-45deg) translate(7px, -7px);
    }

    /* Better mobile scroll performance */
    body {
        -webkit-overflow-scrolling: touch;
    }
}
