/* emotion_navigation.css - Responsive Emotion Navigation Styles */

/* =============================================================================
   View Toggle Controls
   ============================================================================= */
.view-toggle {
    transition: all 0.2s ease;
}

.view-toggle .btn {
    min-width: 80px;
    transition: all 0.2s ease;
}

.view-toggle .btn.active {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
    color: white;
}

/* =============================================================================
   Emotion Wheel View Styles
   ============================================================================= */
.emotion-wheel-view {
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.emotion-wheel-container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    overflow: hidden;
}

.emotion-wheel-header {
    background: linear-gradient(135deg, var(--bs-primary) 0%, #A0522D 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

.emotion-wheel-header h2 {
    margin: 0 0 10px 0;
    font-size: 2rem;
    font-weight: 300;
}

.emotion-wheel-header p {
    margin: 0;
    opacity: 0.9;
    font-size: 1.1rem;
}

.wheel-content {
    position: relative;
    padding: 0;
    background: white;
}

.sunburst-wrapper {
    width: 100%;
    /* Reserve square space for wheel to prevent CLS */
    aspect-ratio: 1 / 1;
    max-height: 950px; /* Cap height on large screens */
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle, #fefefe 0%, #f8f9fa 100%);
    overflow: hidden; /* Prevent tooltip/breadcrumb hover from causing layout shift */
    padding: 10px;
    /* Isolate layout to prevent child changes from affecting parent dimensions */
    contain: layout;
}

.wheel-loading {
    color: var(--bs-primary);
}

/* Reserve space for emotion wheel to prevent CLS */
#emotion-wheel {
    /* Use aspect-ratio to reserve space that scales with viewport */
    aspect-ratio: 1 / 1;
    width: 100%;
    max-width: 1100px; /* Larger wheel to fill available space */
    margin: 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
    /* Prevent internal changes from affecting container size */
    overflow: hidden;
    contain: layout;
}

/* =============================================================================
   Card Grid View Styles
   ============================================================================= */
.emotion-card-view {
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.emotion-groups {
    display: grid;
    gap: 2rem;
}

.emotion-group {
    border: 1px solid var(--bs-border-color);
    border-radius: 12px;
    overflow: hidden;
    transition: box-shadow 0.2s ease;
    background: white;
}

.emotion-group:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.emotion-group-header {
    background-color: var(--bs-light);
    border-bottom: 1px solid var(--bs-border-color);
}

.emotion-group-header h3 a {
    color: var(--bs-primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

.emotion-group-header h3 a:hover {
    color: #A0522D;
}

.expand-toggle {
    transition: all 0.2s ease;
}

.expand-toggle .bi-chevron-down {
    transition: transform 0.2s ease;
}

.expand-toggle[aria-expanded="true"] .bi-chevron-down {
    transform: rotate(180deg);
}

/* =============================================================================
   Emotion Grid Layout
   ============================================================================= */
.emotion-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    padding: 1.5rem;
}

.emotion-card-wrapper {
    position: relative;
}

.emotion-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 1rem;
    border: 1px solid var(--bs-border-color);
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    background: white;
    transition: all 0.2s ease;
    min-height: 80px;
    position: relative;
    overflow: hidden;
}

.emotion-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(var(--bs-primary-rgb), 0.15);
    text-decoration: none;
    color: inherit;
}

.emotion-card-content {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.emotion-name {
    font-weight: 500;
    color: var(--bs-primary);
    transition: color 0.2s ease;
}

.emotion-card:hover .emotion-name {
    color: #A0522D;
}

.emotion-level {
    font-size: 0.75rem;
    align-self: flex-start;
}

.emotion-card.secondary {
    border-left: 3px solid #17a2b8;
}

.emotion-card.tertiary {
    border-left: 3px solid #28a745;
}

.emotion-card-hover {
    position: absolute;
    top: 50%;
    right: 1rem;
    transform: translateY(-50%);
    opacity: 0;
    transition: opacity 0.2s ease;
    color: var(--bs-primary);
}

.emotion-card:hover .emotion-card-hover {
    opacity: 1;
}

/* =============================================================================
   Sibling Navigation Styles - FILE FOLDER TABS
   ============================================================================= */
.emotion-sibling-nav {
    background: transparent;
    border: none;
    padding: 0;
}

/* Add connecting line for tertiary emotions (no children folder) */
.emotion-sibling-nav.no-children .d-flex {
    position: relative;
}

.emotion-sibling-nav.no-children .d-flex::after {
    content: '';
    position: absolute;
    bottom: -1px; /* Connect to bottom of tabs */
    left: 0;
    right: 0;
    height: 2px;
    background: var(--bs-primary);
    z-index: 1; /* Below tabs */
}

/* Make sibling buttons look like folder tabs */
.sibling-emotion-btn {
    transition: all 0.2s ease;
    position: relative;
    border-radius: 8px 8px 0 0 !important; /* Tab shape - rounded top, flat bottom */
    margin-right: 2px;
    margin-bottom: -1px; /* Clean overlap with folder content */
    z-index: 2;
}

/* Active tab (current emotion) - strong primary color */
.sibling-emotion-btn.btn-primary {
    background-color: var(--bs-primary); /* Strong primary background */
    border-color: var(--bs-primary);
    border-bottom: none !important; /* No bottom border for active tab */
    color: white; /* White text for good contrast */
    font-weight: 600;
    z-index: 3; /* Above other tabs and folder */
}

/* Inactive tabs - brown outline to blend with folder system */
.sibling-emotion-btn.btn-outline-primary {
    background-color: #f8f9fa; 
    border-color: var(--bs-primary); /* Brown outline matching folder */
    color: var(--bs-primary); /* Brown text */
    font-weight: 500;
}

.sibling-emotion-btn.btn-outline-primary:hover {
    background-color: #e9ecef;
    border-color: var(--bs-primary);
    color: var(--bs-primary); /* Keep brown text on hover */
}


/* Mobile sibling grid */
.emotion-sibling-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
}

.emotion-sibling-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    border: 1px solid var(--bs-border-color);
    border-radius: 6px;
    text-decoration: none;
    color: var(--bs-primary);
    background: white;
    transition: all 0.2s ease;
    font-size: 0.875rem;
    min-height: 48px; /* Touch-friendly */
}

.emotion-sibling-card:hover {
    background-color: rgba(var(--bs-primary-rgb), 0.1);
    border-color: var(--bs-primary);
    text-decoration: none;
    color: var(--bs-primary);
}

.emotion-sibling-card.current {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
    color: white;
}

.emotion-sibling-card.current:hover {
    background-color: #A0522D;
    border-color: #A0522D;
    color: white;
}

.emotion-sibling-card .emotion-name {
    font-weight: 500;
}

/* =============================================================================
   Child Navigation Styles - FOLDER CONTENTS
   ============================================================================= */
.emotion-children-folder {
    background: rgba(var(--bs-primary-rgb), 0.05); /* Subtle primary tint */
    border: 2px solid var(--bs-primary);
    border-top: 2px solid var(--bs-primary); /* Full top border across entire width */
    border-radius: 0 8px 8px 8px; /* Square top-left corner to align with tabs */
    padding: 1rem;
    margin-top: 0; /* Clean connection - no Bootstrap margins to fight */
    position: relative;
    z-index: 1; /* Below the active tab */
}



.child-emotion-btn {
    transition: all 0.2s ease;
    position: relative;
    font-size: 0.875rem; /* Slightly smaller than siblings */
    background-color: var(--bs-secondary); /* Dark Slate Gray from theme */
    border-color: var(--bs-secondary);
    color: white;
    font-weight: 500;
}

.child-emotion-btn:hover {
    background-color: #3e5a5a; /* Lighter slate gray on hover */
    border-color: #3e5a5a;
    color: white;
    transform: translateY(-1px); /* Slight lift on hover */
}

/* Mobile child emotion grid */
.emotion-child-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 0.5rem;
}

.emotion-child-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    text-decoration: none;
    color: #6c757d;
    background: white;
    transition: all 0.2s ease;
    font-size: 0.8125rem; /* Smaller than siblings */
    min-height: 40px; /* Slightly smaller than siblings */
}

.emotion-child-card:hover {
    background-color: rgba(108, 117, 125, 0.1);
    border-color: #6c757d;
    text-decoration: none;
    color: #495057;
}

.emotion-child-card .emotion-name {
    font-weight: 500;
    color: inherit;
}

.emotion-child-card i {
    font-size: 0.75rem;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

.emotion-child-card:hover i {
    opacity: 1;
}

/* =============================================================================
   View Transitions
   ============================================================================= */
.emotion-wheel-view.hiding,
.emotion-card-view.hiding {
    opacity: 0;
    transform: translateY(-10px);
}

.emotion-wheel-view.showing,
.emotion-card-view.showing {
    opacity: 1;
    transform: translateY(0);
}

/* =============================================================================
   Mobile Responsive Design
   ============================================================================= */
@media (max-width: 768px) {
    /* Hide wheel view on mobile */
    #wheel-view {
        display: none !important;
    }
    
    /* Always show card view on mobile */
    #card-view {
        display: block !important;
    }
    
    /* Adjust emotion grid for mobile */
    .emotion-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 0.75rem;
        padding: 1rem;
    }
    
    .emotion-card {
        min-height: 60px;
        padding: 0.75rem;
    }
    
    .emotion-group-header {
        padding: 1rem;
    }
    
    .emotion-group-header h3 {
        font-size: 1.1rem;
    }
    
    .expand-toggle {
        font-size: 0.875rem;
        padding: 0.25rem 0.5rem;
    }
    
    /* Mobile sibling navigation adjustments */
    .emotion-sibling-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 0.5rem;
    }
    
    .emotion-sibling-card {
        padding: 0.5rem;
        font-size: 0.8rem;
        min-height: 44px; /* Maintain touch targets */
    }
    
    /* Mobile child navigation adjustments */
    .emotion-children-folder {
        padding: 0.75rem;
        margin-top: 0.5rem; /* More spacing on mobile */
        border-radius: 8px; /* Regular rounded corners on mobile */
    }
    
    .emotion-child-grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
        gap: 0.375rem;
    }
    
    .emotion-child-card {
        padding: 0.375rem 0.5rem;
        font-size: 0.75rem;
        min-height: 36px; /* Smaller than siblings on mobile */
    }
}

/* =============================================================================
   Touch Device Optimizations
   ============================================================================= */
@media (hover: none) {
    .emotion-card:hover {
        transform: none;
        box-shadow: 0 2px 8px rgba(var(--bs-primary-rgb), 0.1);
    }
    
    .emotion-card-hover {
        opacity: 1; /* Always show on touch devices */
    }
}

/* =============================================================================
   Desktop Enhancements
   ============================================================================= */
@media (min-width: 992px) {
    .emotion-groups {
        gap: 2.5rem;
    }
    
    .emotion-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
        gap: 1.25rem;
        padding: 2rem;
    }
    
    .emotion-card {
        padding: 1.25rem;
        min-height: 90px;
    }
    
    .emotion-wheel-header {
        padding: 40px;
    }
    
    .emotion-wheel-header h2 {
        font-size: 2.5rem;
    }
}

/* =============================================================================
   Print Styles
   ============================================================================= */
@media print {
    .view-toggle,
    .expand-toggle,
    .emotion-card-hover {
        display: none !important;
    }
    
    .emotion-wheel-view {
        display: none !important;
    }
    
    .emotion-card-view {
        display: block !important;
    }
    
    .emotion-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
}
/* Hierarchical card view tweaks */
.emotion-chip {
  border-color: var(--bs-gray-300);
  transition: box-shadow .15s ease, transform .15s ease;
}
.emotion-chip:hover,
.emotion-chip:focus {
  box-shadow: 0 .25rem .5rem rgba(0,0,0,.05);
  transform: translateY(-1px);
}

#emotion-primary-nav .nav-link.active {
  background-color: var(--bs-primary);
  color: #fff;
}

/* Folder tile styling */
.emotion-folder .card-header {
  background-color: var(--bs-light);
}
.emotion-folder .preview-chips .badge {
  border-color: var(--bs-gray-300);
}
.emotion-folder .card-footer a.small {
  color: var(--bs-secondary);
}
.emotion-folder .card-footer a.small:hover {
  color: var(--bs-primary);
}
