/*
 * Mehr Guard Page Transitions v2.2
 * Fast, smooth animations - no theme/font flashing
 * Uses font preloading and font-display: block for FOUT prevention
 */

/* ==========================================================================
   PREVENT THEME FLASHING - Critical Fix
   ========================================================================== */

/* Ensure theme class is respected immediately */
html,
body {
    color-scheme: dark light;
}

html.dark,
html[data-theme="dark"] {
    color-scheme: dark;
}

html.light,
html[data-theme="light"] {
    color-scheme: light;
}

/* Prevent FOUC (Flash of Unstyled Content) */
html {
    visibility: visible;
}

/* ==========================================================================
   DISABLE VIEW TRANSITIONS API (Causes Theme Flashing)
   ========================================================================== */

/* Don't use @view-transition - it causes the dark->light flash */

/* ==========================================================================
   KEYFRAME ANIMATIONS - Fast & Snappy
   ========================================================================== */

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideOutUp {
    from {
        opacity: 1;
        transform: translateY(0);
    }

    to {
        opacity: 0;
        transform: translateY(-8px);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-8px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.98);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ==========================================================================
   PAGE ENTRANCE ANIMATIONS - Fast
   ========================================================================== */

/* Main content - fast slide up */
.main-content {
    animation: slideInUp 0.15s ease-out;
}

/* Sidebar - instant, no animation */
.sidebar {
    animation: none;
}

/* Content scroll area */
.content-scroll {
    animation: fadeIn 0.12s ease-out;
}

/* ==========================================================================
   STAGGERED CONTENT - Minimal Delays
   ========================================================================== */

.hero-card,
.threat-hero,
.privacy-hero,
.page-header {
    animation: scaleIn 0.15s ease-out;
}

.challenge-card,
.scoreboard-card,
.settings-card,
.format-section,
.preview-column {
    animation: scaleIn 0.18s ease-out;
}

/* Sidebar nav - subtle stagger */
.sidebar-nav .nav-link {
    animation: slideInLeft 0.1s ease-out;
    animation-fill-mode: backwards;
}

.sidebar-nav .nav-link:nth-child(1) {
    animation-delay: 0.02s;
}

.sidebar-nav .nav-link:nth-child(2) {
    animation-delay: 0.04s;
}

.sidebar-nav .nav-link:nth-child(3) {
    animation-delay: 0.06s;
}

.sidebar-nav .nav-link:nth-child(4) {
    animation-delay: 0.08s;
}

.sidebar-nav .nav-link:nth-child(5) {
    animation-delay: 0.10s;
}

.sidebar-nav .nav-link:nth-child(6) {
    animation-delay: 0.12s;
}

/* ==========================================================================
   FONT LOADING - FOUC Prevention
   Uses visibility: hidden to completely hide icons until font renders.
   This prevents text like "dashboard" from briefly appearing.
   ========================================================================== */

/* Hide icon text content until font renders (font-display: block does the timing) */
.material-symbols-outlined {
    /* Override any inline text styling - font handles visibility via font-display: block */
    color: inherit;
}

/* Ensure icons have minimum size to prevent layout shift */
.material-symbols-outlined:empty::before {
    content: '\00a0';
    /* Non-breaking space to maintain height */
    visibility: hidden;
}

/* ==========================================================================
   PAGE EXIT ANIMATION - Ultra Fast
   ========================================================================== */

body.page-exit {
    animation: fadeOut 0.08s ease-out forwards;
    pointer-events: none;
}

body.page-exit .main-content {
    animation: slideOutUp 0.08s ease-out forwards;
}

/* ==========================================================================
   INTERACTIVE ELEMENTS - Snappy
   ========================================================================== */

/* Navigation links */
.nav-link {
    transition:
        background-color 0.1s ease,
        color 0.1s ease,
        transform 0.08s ease;
}

.nav-link:hover {
    transform: translateX(2px);
}

.nav-link:active {
    transform: translateX(1px) scale(0.99);
}

/* Buttons */
button,
.btn-primary,
.btn-secondary,
.btn-danger {
    transition:
        background-color 0.1s ease,
        transform 0.08s ease,
        box-shadow 0.1s ease;
}

button:hover,
.btn-primary:hover,
.btn-secondary:hover {
    transform: translateY(-1px);
}

button:active,
.btn-primary:active,
.btn-secondary:active {
    transform: translateY(0) scale(0.98);
}

/* Cards */
.feature-card,
.attack-card,
.list-card,
.format-card {
    transition:
        transform 0.12s ease,
        box-shadow 0.12s ease;
}

.feature-card:hover,
.attack-card:hover {
    transform: translateY(-2px);
}

/* ==========================================================================
   TOAST & MODAL - Fast
   ========================================================================== */

.toast {
    transition:
        transform 0.15s cubic-bezier(0.34, 1.2, 0.64, 1),
        opacity 0.1s ease;
}

.toast.hidden {
    opacity: 0;
    transform: translateY(12px) scale(0.95);
    pointer-events: none;
}

.toast:not(.hidden) {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.modal-overlay {
    transition: opacity 0.12s ease;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    transition:
        transform 0.15s cubic-bezier(0.34, 1.2, 0.64, 1),
        opacity 0.1s ease;
}

.modal-overlay.hidden .modal-content {
    transform: scale(0.95) translateY(10px);
    opacity: 0;
}

.modal-overlay:not(.hidden) .modal-content {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* ==========================================================================
   DROPDOWN ANIMATIONS
   ========================================================================== */

.profile-dropdown,
.notification-dropdown {
    transition:
        opacity 0.1s ease,
        transform 0.12s ease;
    transform-origin: top right;
}

.profile-dropdown.hidden,
.notification-dropdown.hidden {
    opacity: 0;
    transform: scale(0.95) translateY(-4px);
    pointer-events: none;
}

/* ==========================================================================
   REDUCED MOTION - Accessibility
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}