/* ===== ADVANCED FEATURES STYLING ===== */
/* Skeleton Loading, Pull-to-Refresh, Micro-interactions, Visual Polish */

/* ===== SKELETON LOADING STATES ===== */
.skeleton-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--spacing-md);
    padding: var(--spacing-md);
}

.skeleton-card {
    background: rgba(255, 255, 255, 0.6);
    border-radius: var(--border-radius);
    padding: var(--spacing-md);
    box-shadow: var(--shadow-soft);
    animation: skeletonPulse 1.5s ease-in-out infinite;
}

.skeleton-accent {
    height: 4px;
    width: 100%;
    background: linear-gradient(90deg, 
        rgba(215, 193, 169, 0.3) 0%, 
        rgba(215, 193, 169, 0.5) 50%, 
        rgba(215, 193, 169, 0.3) 100%);
    background-size: 200% 100%;
    animation: shimmer 2s infinite;
    margin-bottom: var(--spacing-sm);
    border-radius: 2px;
}

.skeleton-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: var(--spacing-sm);
}

.skeleton-category {
    width: 80px;
    height: 24px;
    background: linear-gradient(90deg, 
        rgba(215, 193, 169, 0.3) 0%, 
        rgba(215, 193, 169, 0.5) 50%, 
        rgba(215, 193, 169, 0.3) 100%);
    background-size: 200% 100%;
    animation: shimmer 2s infinite;
    border-radius: 12px;
}

.skeleton-title {
    width: 70%;
    height: 28px;
    background: linear-gradient(90deg, 
        rgba(139, 115, 85, 0.2) 0%, 
        rgba(139, 115, 85, 0.4) 50%, 
        rgba(139, 115, 85, 0.2) 100%);
    background-size: 200% 100%;
    animation: shimmer 2s infinite 0.2s;
    border-radius: 4px;
    margin-bottom: var(--spacing-sm);
}

.skeleton-teaser {
    width: 100%;
    height: 16px;
    background: linear-gradient(90deg, 
        rgba(168, 155, 141, 0.2) 0%, 
        rgba(168, 155, 141, 0.4) 50%, 
        rgba(168, 155, 141, 0.2) 100%);
    background-size: 200% 100%;
    animation: shimmer 2s infinite 0.4s;
    border-radius: 4px;
    margin-bottom: 8px;
}

.skeleton-teaser.short {
    width: 60%;
}

.skeleton-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: var(--spacing-md);
}

.skeleton-button {
    width: 120px;
    height: 36px;
    background: linear-gradient(90deg, 
        rgba(215, 193, 169, 0.3) 0%, 
        rgba(215, 193, 169, 0.5) 50%, 
        rgba(215, 193, 169, 0.3) 100%);
    background-size: 200% 100%;
    animation: shimmer 2s infinite 0.6s;
    border-radius: 8px;
}

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

@keyframes skeletonPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ===== PULL TO REFRESH ===== */
.pull-to-refresh-indicator {
    position: fixed;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, rgba(248, 246, 240, 0.98) 0%, rgba(232, 230, 223, 0.95) 100%);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: 0 0 16px 16px;
    box-shadow: var(--shadow-medium);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    z-index: 1000;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid var(--color-divider);
    border-top: none;
}

.pull-to-refresh-indicator.ready {
    background: linear-gradient(135deg, rgba(212, 165, 116, 0.2) 0%, rgba(215, 193, 169, 0.3) 100%);
}

.pull-to-refresh-indicator.refreshing .pull-spinner {
    animation: spin 1s linear infinite;
}

.pull-spinner {
    width: 24px;
    height: 24px;
    color: var(--color-accent-hover);
}

.pull-text {
    font-family: var(--font-ui);
    font-size: 14px;
    color: var(--color-text-title);
    font-weight: 500;
}

/* ===== LAZY LOADING STATES ===== */
.poem-card-lazy {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
}

.poem-card-loaded {
    opacity: 1;
    transform: translateY(0) scale(1);
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

img[data-src] {
    opacity: 0;
    transition: opacity 0.5s ease;
}

img.loaded {
    opacity: 1;
}

/* ===== RIPPLE EFFECT ===== */
.ripple-effect {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(215, 193, 169, 0.6) 0%, transparent 70%);
    transform: scale(0);
    animation: ripple 0.6s ease-out;
    pointer-events: none;
}

@keyframes ripple {
    to {
        transform: scale(2);
        opacity: 0;
    }
}

/* ===== MICRO-INTERACTIONS ===== */
button, .nav-item, .poem-card, .filter-pill, .jewel-card {
    position: relative;
    overflow: hidden;
}

button:hover, .nav-item:hover, .poem-card:hover, .filter-pill:hover {
    transform: translateY(-2px) scale(1.02);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

button:active, .nav-item:active {
    transform: translateY(0) scale(0.98);
    transition: all 0.1s ease;
}

/* Success Animation */
.success-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    pointer-events: none;
}

.success-icon svg {
    filter: drop-shadow(0 2px 8px rgba(212, 165, 116, 0.5));
}

/* ===== LOADING SPINNER - DESERT THEME ===== */
.desert-spinner {
    width: 48px;
    height: 48px;
    position: relative;
    margin: 0 auto;
}

.desert-spinner::before,
.desert-spinner::after {
    content: '';
    position: absolute;
    border-radius: 50%;
}

.desert-spinner::before {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(215, 193, 169, 0.3);
    border-top-color: var(--color-accent);
    animation: spin 1s linear infinite;
}

.desert-spinner::after {
    width: 32px;
    height: 32px;
    top: 8px;
    left: 8px;
    border: 3px solid rgba(139, 115, 85, 0.2);
    border-bottom-color: var(--color-accent-hover);
    animation: spin 0.7s linear infinite reverse;
}

/* ===== GLOW EFFECTS ON ACTIVE CATEGORIES ===== */
.filter-pill.active,
.nav-item.active,
.ribbon-badge.active {
    position: relative;
    animation: breathingGlow 3s ease-in-out infinite;
}

.filter-pill.active::before,
.nav-item.active::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: inherit;
    background: linear-gradient(135deg, var(--color-hope), var(--color-accent));
    opacity: 0.3;
    filter: blur(8px);
    z-index: -1;
    animation: glowPulse 3s ease-in-out infinite;
}

@keyframes breathingGlow {
    0%, 100% {
        box-shadow: 0 0 10px rgba(212, 165, 116, 0.3),
                    0 0 20px rgba(212, 165, 116, 0.2),
                    0 0 30px rgba(212, 165, 116, 0.1);
    }
    50% {
        box-shadow: 0 0 20px rgba(212, 165, 116, 0.5),
                    0 0 30px rgba(212, 165, 116, 0.3),
                    0 0 40px rgba(212, 165, 116, 0.2);
    }
}

@keyframes glowPulse {
    0%, 100% {
        opacity: 0.3;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.05);
    }
}

/* ===== STAGGERED ANIMATIONS ===== */
.poem-card {
    animation: fadeInUp 0.6s ease-out backwards;
}

.poem-card:nth-child(1) { animation-delay: 0.05s; }
.poem-card:nth-child(2) { animation-delay: 0.12s; }
.poem-card:nth-child(3) { animation-delay: 0.18s; }
.poem-card:nth-child(4) { animation-delay: 0.25s; }
.poem-card:nth-child(5) { animation-delay: 0.31s; }
.poem-card:nth-child(6) { animation-delay: 0.38s; }
.poem-card:nth-child(7) { animation-delay: 0.44s; }
.poem-card:nth-child(8) { animation-delay: 0.51s; }
.poem-card:nth-child(9) { animation-delay: 0.57s; }

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95) rotate(-1deg);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1) rotate(0deg);
    }
}

/* ===== GRADIENT OVERLAYS ON IMAGES ===== */
.poem-card-image,
.jewel-card-image,
.fluistering-image {
    position: relative;
    overflow: hidden;
}

.poem-card-image::after,
.jewel-card-image::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, 
        transparent 0%, 
        rgba(0, 0, 0, 0.3) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.poem-card:hover .poem-card-image::after,
.jewel-card:hover .jewel-card-image::after {
    opacity: 1;
}

/* Category-specific gradient overlays */
.poem-card[data-category="الحب"] .poem-card-image::after {
    background: linear-gradient(180deg, 
        transparent 0%, 
        rgba(206, 128, 64, 0.4) 100%);
}

.poem-card[data-category="الخسارة"] .poem-card-image::after {
    background: linear-gradient(180deg, 
        transparent 0%, 
        rgba(95, 111, 82, 0.4) 100%);
}

.poem-card[data-category="الأمل"] .poem-card-image::after {
    background: linear-gradient(180deg, 
        transparent 0%, 
        rgba(212, 165, 116, 0.4) 100%);
}

.poem-card[data-category="التأمل"] .poem-card-image::after {
    background: linear-gradient(180deg, 
        transparent 0%, 
        rgba(169, 171, 136, 0.4) 100%);
}

.poem-card[data-category="الوحدة"] .poem-card-image::after {
    background: linear-gradient(180deg, 
        transparent 0%, 
        rgba(183, 175, 163, 0.4) 100%);
}

/* ===== INK BLEEDING TEXT EFFECTS ===== */
.poem-modal-title,
.poem-card-title,
.jewel-title {
    text-shadow: 
        0 1px 2px rgba(139, 115, 85, 0.3),
        0 2px 4px rgba(139, 115, 85, 0.2),
        1px 0 1px rgba(139, 115, 85, 0.1);
    filter: blur(0.2px);
}

.poem-modal-title::first-letter,
.poem-card-title::first-letter {
    text-shadow: 
        0 2px 4px rgba(206, 128, 64, 0.4),
        0 4px 8px rgba(206, 128, 64, 0.2),
        2px 0 2px rgba(206, 128, 64, 0.15);
    filter: blur(0.3px);
}

/* ===== SAND PARTICLE SYSTEM ===== */
.sand-particle {
    position: fixed;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 50;
    opacity: 0;
    box-shadow: 0 2px 4px rgba(168, 155, 141, 0.3);
}

.sand-particle.active {
    animation: sandDrift 4s ease-out forwards;
}

@keyframes sandDrift {
    0% {
        opacity: 0;
        transform: translateY(0) translateX(0) rotate(0deg);
    }
    10% {
        opacity: 0.6;
    }
    90% {
        opacity: 0.3;
    }
    100% {
        opacity: 0;
        transform: translateY(-120px) translateX(var(--drift-x, 20px)) rotate(360deg);
    }
}

/* Enhanced particle system with mouse interaction */
.particle-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    opacity: var(--particle-intensity, 0.5);
}

/* ===== PARALLAX LAYERS ===== */
.parallax-container {
    position: relative;
    overflow: hidden;
}

.parallax-layer {
    position: absolute;
    width: 100%;
    height: 100%;
    transition: transform 0.1s ease-out;
}

.parallax-layer.background {
    transform: translateY(var(--parallax-bg, 0));
}

.parallax-layer.foreground {
    transform: translateY(var(--parallax-fg, 0));
}

/* ===== HOVER SCALE TRANSFORMS ===== */
.interactive-element {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.interactive-element:hover {
    transform: scale(1.05) translateY(-2px);
}

.interactive-element:active {
    transform: scale(0.98) translateY(0);
}

/* ===== TOUCH FEEDBACK ===== */
@media (hover: none) and (pointer: coarse) {
    .interactive-element:active {
        transform: scale(0.95);
        opacity: 0.8;
    }
    
    button:active,
    .nav-item:active {
        background: rgba(215, 193, 169, 0.3);
    }
}

/* ===== CUSTOM CURSOR ZONES ===== */
.cursor-pen {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath fill='%238B7355' d='M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z'/%3E%3C/svg%3E") 12 12, pointer;
}

.cursor-compass {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='10' fill='none' stroke='%238B7355' stroke-width='2'/%3E%3Cpath fill='%238B7355' d='M12 2l2 8-2 2-2-2z'/%3E%3C/svg%3E") 12 12, pointer;
}

/* ===== BREATHING ANIMATIONS ===== */
@keyframes breathe {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.02);
        opacity: 0.95;
    }
}

.breathing-element {
    animation: breathe 4s ease-in-out infinite;
}

/* ===== SCROLL INDICATORS ===== */
.scroll-indicator {
    position: fixed;
    bottom: calc(var(--footer-height) + var(--spacing-lg));
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 80;
}

.scroll-indicator.visible {
    opacity: 1;
}

.scroll-indicator svg {
    width: 32px;
    height: 32px;
    color: var(--color-accent);
    animation: bounce 2s ease-in-out infinite;
}

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

/* ===== RESPONSIVE ADJUSTMENTS ===== */
@media (max-width: 768px) {
    .skeleton-container {
        grid-template-columns: 1fr;
    }
}

/* ===== ACCESSIBILITY ENHANCEMENTS ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .parallax-layer {
        transform: none !important;
    }
}

/* ===== FOCUS STATES ===== */
*:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 4px;
    border-radius: 4px;
}

button:focus-visible,
.nav-item:focus-visible {
    box-shadow: 0 0 0 4px var(--color-accent-subtle);
}

/* ===== EMOTIE RADAR: BOTTOM NAV PANEL ===== */
/* Radar expanded view - flies out from bottom nav */
.radar-expanded {
    position: fixed;
    bottom: calc(var(--footer-height) + 20px);
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    width: 280px;
    max-width: calc(100vw - 40px);
    background: linear-gradient(135deg, 
        rgba(248, 246, 240, 0.98) 0%, 
        rgba(232, 230, 223, 0.95) 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 2px solid var(--color-accent);
    border-radius: 16px;
    padding: var(--spacing-md);
    box-shadow: 0 12px 40px rgba(212, 165, 116, 0.4);
    z-index: 101;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.radar-expanded.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

#radarContent {
    max-height: 50vh;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--color-accent) rgba(0, 0, 0, 0.1);
}

#radarContent::-webkit-scrollbar {
    width: 6px;
}

#radarContent::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 3px;
}

#radarContent::-webkit-scrollbar-thumb {
    background: var(--color-accent);
    border-radius: 3px;
}

#radarContent::-webkit-scrollbar-thumb:hover {
    background: var(--color-accent-hover);
}

.radar-category-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-sm);
    margin-bottom: var(--spacing-xs);
    background: rgba(255, 255, 255, 0.5);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.radar-category-item:last-child {
    margin-bottom: 0;
}

.radar-category-item:hover {
    background: rgba(212, 165, 116, 0.2);
    transform: translateX(-4px);
    border-color: var(--color-accent);
}

.radar-category-item:active {
    transform: translateX(-4px) scale(0.98);
}

.radar-category-item.radar-empty {
    opacity: 0.5;
    cursor: not-allowed;
}

.radar-category-item.radar-empty:hover {
    background: rgba(255, 255, 255, 0.5);
    transform: none;
    border-color: transparent;
}

.radar-category-name {
    font-family: var(--font-display);
    font-size: clamp(20px, 3.5vw, 26px);
    font-weight: 400;
    line-height: 1.3;
    letter-spacing: 0.01em;
    color: #8B7355;
}

.radar-category-count {
    font-family: var(--font-ui);
    font-size: 16px;
    font-weight: 400;
    line-height: 1.45;
    letter-spacing: 0.02em;
    color: var(--color-text-secondary);
    background: rgba(93, 64, 55, 0.1);
    padding: 2px 8px;
    border-radius: 10px;
}

/* Mobile: Adjust radar for smaller screens */
@media (max-width: 767px) {
    .radar-expanded {
        width: calc(100vw - 32px);
        max-height: 60vh;
        overflow-y: auto;
        bottom: calc(var(--footer-height) + 12px);
    }
    
    .radar-category-name {
        font-size: 18px;
    }
}
