/**
 * Beautiful Memory Visualization Styles
 * "Inside Out 2" inspired crystal orb visualization
 * Jony Ive design: radical simplicity, meaningful animation, material honesty
 */

/* ============================================
   Emotion Color Variables
   ============================================ */
:root {
    /* Joy - Warm yellow */
    --memory-joy: #EAB308;
    --memory-joy-glow: rgba(234, 179, 8, 0.4);
    --memory-joy-rgb: 234, 179, 8;

    /* Calm - Soft blue */
    --memory-calm: #93C5FD;
    --memory-calm-glow: rgba(147, 197, 253, 0.4);
    --memory-calm-rgb: 147, 197, 253;

    /* Sadness - Deep blue */
    --memory-sadness: #3B82F6;
    --memory-sadness-glow: rgba(59, 130, 246, 0.4);
    --memory-sadness-rgb: 59, 130, 246;

    /* Anger - Vivid red */
    --memory-anger: #EF4444;
    --memory-anger-glow: rgba(239, 68, 68, 0.4);
    --memory-anger-rgb: 239, 68, 68;

    /* Fear - Purple */
    --memory-fear: #A855F7;
    --memory-fear-glow: rgba(168, 85, 247, 0.4);
    --memory-fear-rgb: 168, 85, 247;

    /* Surprise - Pink */
    --memory-surprise: #EC4899;
    --memory-surprise-glow: rgba(236, 72, 153, 0.4);
    --memory-surprise-rgb: 236, 72, 153;

    /* Love/Trust - Green */
    --memory-love: #22C55E;
    --memory-love-glow: rgba(34, 197, 94, 0.4);
    --memory-love-rgb: 34, 197, 94;

    /* Anticipation - Light yellow */
    --memory-anticipation: #FDE047;
    --memory-anticipation-glow: rgba(253, 224, 71, 0.4);
    --memory-anticipation-rgb: 253, 224, 71;

    /* Default/neutral */
    --memory-default: #9CA3AF;
    --memory-default-glow: rgba(156, 163, 175, 0.4);
    --memory-default-rgb: 156, 163, 175;

    /* Default orb variables (used when no emotion class applied) */
    --orb-rgb: 156, 163, 175;
    --orb-glow: rgba(156, 163, 175, 0.4);
}


/* ============================================
   Memory Grid Container
   ============================================ */
.memories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1.5rem;
    padding: 1.5rem;
    max-height: calc(80vh - 200px);
    overflow-y: auto;
}

.memories-grid-compact {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 1rem;
    padding: 1rem;
}


/* ============================================
   Crystal Orb Base Styles
   Inside Out 2 inspired: clean, luminous, inviting
   ============================================ */
.memory-orb {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    cursor: pointer;

    /* Smooth transitions */
    transition: transform 250ms ease, box-shadow 250ms ease;

    /* Gentle float animation */
    animation: orb-float 4s ease-in-out infinite;

    /* Clean gradient - light source from top */
    background: radial-gradient(
        circle at 50% 30%,
        rgba(var(--orb-rgb), 1) 0%,
        rgba(var(--orb-rgb), 0.85) 40%,
        rgba(var(--orb-rgb), 0.6) 100%
    );

    /* Soft glow */
    box-shadow:
        0 0 25px var(--orb-glow),
        0 0 50px rgba(var(--orb-rgb), 0.2),
        inset 0 -8px 20px rgba(0, 0, 0, 0.15);
}

/* Glass shine - single clean highlight */
.memory-orb::before {
    content: '';
    position: absolute;
    top: 10%;
    left: 20%;
    width: 35%;
    height: 35%;
    border-radius: 50%;
    background: radial-gradient(
        circle at 50% 50%,
        rgba(255, 255, 255, 0.7) 0%,
        rgba(255, 255, 255, 0.3) 40%,
        transparent 70%
    );
    pointer-events: none;
}

/* Subtle bottom reflection */
.memory-orb::after {
    content: '';
    position: absolute;
    bottom: 15%;
    right: 20%;
    width: 20%;
    height: 15%;
    border-radius: 50%;
    background: radial-gradient(
        circle at 50% 50%,
        rgba(255, 255, 255, 0.2) 0%,
        transparent 70%
    );
    pointer-events: none;
}

/* Hover state - lift and glow */
.memory-orb:hover {
    transform: scale(1.1) translateY(-4px);
    box-shadow:
        0 0 35px var(--orb-glow),
        0 0 70px rgba(var(--orb-rgb), 0.3),
        0 10px 25px rgba(0, 0, 0, 0.2),
        inset 0 -8px 20px rgba(0, 0, 0, 0.15);
}

/* Active/pressed state */
.memory-orb:active {
    transform: scale(1.05) translateY(-2px);
    transition-duration: 100ms;
}


/* ============================================
   Salience Size Variants
   ============================================ */
.memory-orb.salience-high {
    width: 100px;
    height: 100px;
}

.memory-orb.salience-medium {
    width: 80px;
    height: 80px;
}

.memory-orb.salience-low {
    width: 64px;
    height: 64px;
}

/* Preview (home page) size */
.memory-orb.orb-preview {
    width: 64px;
    height: 64px;
}


/* ============================================
   Emotion Color Classes
   Each emotion has its own color identity while sharing
   the same 3D glass material properties
   ============================================ */
.memory-orb.emotion-joy {
    --orb-rgb: 234, 179, 8;
    --orb-glow: rgba(234, 179, 8, 0.4);
}

.memory-orb.emotion-calm {
    --orb-rgb: 147, 197, 253;
    --orb-glow: rgba(147, 197, 253, 0.4);
}

.memory-orb.emotion-sadness {
    --orb-rgb: 59, 130, 246;
    --orb-glow: rgba(59, 130, 246, 0.4);
}

.memory-orb.emotion-anger {
    --orb-rgb: 239, 68, 68;
    --orb-glow: rgba(239, 68, 68, 0.4);
}

.memory-orb.emotion-fear {
    --orb-rgb: 168, 85, 247;
    --orb-glow: rgba(168, 85, 247, 0.4);
}

.memory-orb.emotion-surprise {
    --orb-rgb: 236, 72, 153;
    --orb-glow: rgba(236, 72, 153, 0.4);
}

.memory-orb.emotion-love,
.memory-orb.emotion-trust,
.memory-orb.emotion-love-trust {
    --orb-rgb: 34, 197, 94;
    --orb-glow: rgba(34, 197, 94, 0.4);
}

.memory-orb.emotion-anticipation {
    --orb-rgb: 253, 224, 71;
    --orb-glow: rgba(253, 224, 71, 0.4);
}

/* Default/no emotion */
.memory-orb.emotion-default {
    --orb-rgb: 156, 163, 175;
    --orb-glow: rgba(156, 163, 175, 0.4);
}


/* ============================================
   Dual Emotion Gradient Styles
   "Inside Out 2" inspired: organic radial blend of two emotions
   ============================================ */
.memory-orb.dual-emotion {
    /* Override the single-color gradient with a dual-color radial blend */
    background: radial-gradient(
        circle at 30% 30%,
        rgba(var(--orb-primary-rgb), 1) 0%,
        rgba(var(--orb-primary-rgb), 0.8) 35%,
        rgba(var(--orb-secondary-rgb), 0.7) 65%,
        rgba(var(--orb-secondary-rgb), 0.9) 100%
    );

    /* Combined glow from both colors */
    box-shadow:
        0 0 25px var(--orb-primary-glow),
        0 0 50px var(--orb-secondary-glow),
        inset 0 -8px 20px rgba(0, 0, 0, 0.15);
}

.memory-orb.dual-emotion:hover {
    box-shadow:
        0 0 35px var(--orb-primary-glow),
        0 0 70px var(--orb-secondary-glow),
        0 10px 25px rgba(0, 0, 0, 0.2),
        inset 0 -8px 20px rgba(0, 0, 0, 0.15);
}


/* ============================================
   Float Animation
   Gentle, organic movement
   ============================================ */
@keyframes orb-float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-4px);
    }
}

/* Staggered animation delays for grid */
.memory-orb:nth-child(1) { animation-delay: 0s; }
.memory-orb:nth-child(2) { animation-delay: 0.2s; }
.memory-orb:nth-child(3) { animation-delay: 0.4s; }
.memory-orb:nth-child(4) { animation-delay: 0.6s; }
.memory-orb:nth-child(5) { animation-delay: 0.8s; }
.memory-orb:nth-child(6) { animation-delay: 1.0s; }
.memory-orb:nth-child(7) { animation-delay: 1.2s; }
.memory-orb:nth-child(8) { animation-delay: 1.4s; }
.memory-orb:nth-child(9) { animation-delay: 1.6s; }
.memory-orb:nth-child(10) { animation-delay: 1.8s; }
.memory-orb:nth-child(11) { animation-delay: 2.0s; }
.memory-orb:nth-child(12) { animation-delay: 2.2s; }


/* ============================================
   Memory Modal Styles
   ============================================ */
.memories-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 300ms ease, visibility 300ms ease;
}

.memories-modal-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.memories-modal-backdrop.memories-modal-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.memories-modal {
    width: 90%;
    max-width: 1000px;
    max-height: 85vh;
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: scale(0.95);
    opacity: 0;
    transition: transform 300ms ease, opacity 300ms ease;
}

.memories-modal-backdrop.active .memories-modal {
    transform: scale(1);
    opacity: 1;
}


/* ============================================
   Modal Header
   ============================================ */
.memories-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.memories-modal-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
}

.memories-modal-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 200ms ease;
}

.memories-modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
}


/* ============================================
   Modal Controls (Filters)
   ============================================ */
.memories-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.memories-filter-select {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
    font-size: 0.875rem;
    cursor: pointer;
    transition: border-color 200ms ease, background 200ms ease;
}

.memories-filter-select:hover {
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
}

.memories-filter-select:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.4);
}


/* ============================================
   Modal Grid Content
   ============================================ */
.memories-modal-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}


/* ============================================
   Memory Detail Modal
   ============================================ */
.memory-detail-modal {
    width: 90%;
    max-width: 600px;
    max-height: 85vh;
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.memory-detail-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem 1.5rem;
    text-align: center;
}

.memory-detail-orb {
    width: 120px;
    height: 120px;
    margin-bottom: 1.5rem;

    /* Slower, more contemplative animation for detail view */
    animation: orb-float 5s ease-in-out infinite;

    /* Enhanced glow for larger orb */
    box-shadow:
        0 0 40px var(--orb-glow),
        0 0 80px rgba(var(--orb-rgb), 0.25),
        inset 0 -10px 25px rgba(0, 0, 0, 0.15);
}

.memory-detail-orb.salience-high {
    width: 160px;
    height: 160px;
}

.memory-type-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
    background: rgba(255, 255, 255, 0.1);
}

.memory-type-badge.type-moment {
    background: rgba(236, 72, 153, 0.2);
    color: #EC4899;
}

.memory-type-badge.type-essence {
    background: rgba(168, 85, 247, 0.2);
    color: #A855F7;
}

.memory-detail-summary {
    font-size: 1.25rem;
    font-weight: 500;
    line-height: 1.5;
    margin: 0;
    max-width: 90%;
}

.memory-detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    margin-top: 1rem;
    font-size: 0.875rem;
    opacity: 0.7;
}

.memory-meta-item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}


/* ============================================
   Evidence Section
   ============================================ */
.memory-evidence-section {
    padding: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.memory-evidence-title {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.6;
    margin: 0 0 1rem 0;
}

.memory-evidence-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.memory-evidence-card {
    padding: 1rem;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    opacity: 0;
    animation: evidence-fade-in 300ms ease forwards;
}

.memory-evidence-card:nth-child(1) { animation-delay: 0ms; }
.memory-evidence-card:nth-child(2) { animation-delay: 150ms; }
.memory-evidence-card:nth-child(3) { animation-delay: 300ms; }
.memory-evidence-card:nth-child(4) { animation-delay: 450ms; }
.memory-evidence-card:nth-child(5) { animation-delay: 600ms; }
.memory-evidence-card:nth-child(6) { animation-delay: 750ms; }

@keyframes evidence-fade-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.memory-evidence-quote {
    font-style: italic;
    line-height: 1.6;
    margin: 0 0 0.5rem 0;
}

.memory-evidence-quote::before {
    content: '"';
    opacity: 0.5;
}

.memory-evidence-quote::after {
    content: '"';
    opacity: 0.5;
}

.memory-evidence-date {
    font-size: 0.75rem;
    opacity: 0.5;
}


/* ============================================
   Linked Entries Section
   ============================================ */
.memory-linked-section {
    padding: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.memory-linked-title {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.6;
    margin: 0 0 1rem 0;
}

.memory-linked-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.memory-linked-entry {
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 200ms ease, border-color 200ms ease;
}

.memory-linked-entry:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}


/* ============================================
   Navigation Arrows (Detail Modal)
   ============================================ */
.memory-nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 200ms ease, transform 200ms ease;
    z-index: 10;
}

.memory-nav-arrow:hover {
    background: rgba(255, 255, 255, 0.2);
}

.memory-nav-arrow:active {
    transform: translateY(-50%) scale(0.95);
}

.memory-nav-arrow.prev {
    left: 1rem;
}

.memory-nav-arrow.next {
    right: 1rem;
}

.memory-nav-arrow:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}


/* ============================================
   Empty State
   ============================================ */
.memories-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1.5rem;
    text-align: center;
}

.memories-empty-orb {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 2px dashed rgba(255, 255, 255, 0.3);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.5;
}

.memories-empty-title {
    font-size: 1.125rem;
    font-weight: 500;
    margin: 0 0 0.5rem 0;
}

.memories-empty-description {
    font-size: 0.875rem;
    opacity: 0.6;
    margin: 0;
    max-width: 300px;
}


/* ============================================
   Home Page Preview Section
   ============================================ */
.memories-preview-section {
    padding: 1.5rem;
}

.memories-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.memories-preview-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.memories-preview-link {
    font-size: 0.875rem;
    opacity: 0.7;
    cursor: pointer;
    transition: opacity 200ms ease;
}

.memories-preview-link:hover {
    opacity: 1;
}

.memories-preview-grid {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}


/* ============================================
   Load More Button
   ============================================ */
.memories-load-more {
    display: flex;
    justify-content: center;
    padding: 1.5rem;
}

.memories-load-more-btn {
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: transparent;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 200ms ease, border-color 200ms ease;
}

.memories-load-more-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
}

.memories-load-more-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}


/* ============================================
   Responsive Adjustments
   ============================================ */
@media (max-width: 768px) {
    .memories-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 1rem;
        padding: 1rem;
    }

    .memory-orb {
        width: 64px;
        height: 64px;
    }

    .memory-orb.salience-high {
        width: 80px;
        height: 80px;
    }

    .memory-orb.salience-medium {
        width: 64px;
        height: 64px;
    }

    .memory-orb.salience-low {
        width: 52px;
        height: 52px;
    }

    .memories-modal {
        width: 95%;
        max-height: 90vh;
    }

    .memory-detail-modal {
        width: 95%;
    }

    .memory-nav-arrow {
        width: 36px;
        height: 36px;
    }
}


/* ============================================
   Reduced Motion - Accessibility
   Respect user preferences while maintaining visual identity
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    .memory-orb {
        animation: none;
    }

    .memory-orb::before,
    .memory-orb::after {
        animation: none;
    }

    .memory-orb:hover {
        transform: scale(1.08);
    }

    .memory-evidence-card {
        animation: none;
        opacity: 1;
    }
}
