/* ============================================
   Scientific Gallery - Modern Modular CSS
   Kachin Amber Research Institute
   ============================================ */

/* ============================================
   Variables & Base Styles
   ============================================ */
:root {
    --primary-color: #3498db;
    --primary-dark: #2980b9;
    --secondary-color: #e74c3c;
    --secondary-dark: #c0392b;
    --accent-color: #27ae60;
    --accent-dark: #219a52;
    --text-primary: #2c3e50;
    --text-secondary: #555;
    --text-muted: #666;
    --bg-light: #f8f9fa;
    --bg-white: #ffffff;
    --border-color: #ddd;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 5px 15px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.15);
    --radius-sm: 5px;
    --radius-md: 10px;
    --radius-lg: 15px;
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --card-height: 620px;
    --image-height: 280px;
}

/* ============================================
   Gallery Container & Header
   ============================================ */
.scientific-gallery {
    padding: 60px 0;
    background: var(--bg-white);
}

.gallery-header {
    text-align: center;
    margin-bottom: 60px;
    padding: 0 20px;
}

.gallery-header h1 {
    color: var(--text-primary);
    font-size: 2.5em;
    margin-bottom: 20px;
    font-weight: 600;
}

.gallery-header p {
    font-size: 1.2em;
    color: var(--text-muted);
    max-width: 800px;
    margin: 0 auto;
    line-height: 1.6;
}

/* ============================================
   Search & Filter Section
   ============================================ */
.search-filter-section {
    background: var(--bg-light);
    padding: 30px 0;
    margin-bottom: 40px;
}

.search-box {
    max-width: 600px;
    margin: 0 auto 20px;
    position: relative;
}

.search-box input {
    width: 100%;
    padding: 15px 50px 15px 20px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 16px;
    transition: border-color var(--transition-normal);
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.search-box button {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--primary-color);
    border: none;
    color: white;
    padding: 10px 15px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition-normal);
}

.search-box button:hover {
    background: var(--primary-dark);
}

/* Category Filters */
.category-filters {
    text-align: center;
    margin-bottom: 20px;
}

.category-filters ul {
    list-style: none;
    display: inline-flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin: 0;
    padding: 0;
}

.category-filters li {
    margin: 0;
}

.category-filters button,
.category-filters a {
    display: block;
    padding: 10px 20px;
    background: var(--bg-white);
    color: var(--text-primary);
    text-decoration: none;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    transition: all var(--transition-normal);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
}

.category-filters button:hover,
.category-filters a:hover,
.category-filters button.active,
.category-filters a.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* ============================================
   Specimens Grid
   ============================================ */
.specimens-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 30px;
    margin-bottom: 60px;
    padding: 0 20px;
}

/* ============================================
   Specimen Card - Fixed Height & Structure
   ============================================ */
.specimen-card {
    background: var(--bg-white);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    transition:
        transform var(--transition-normal),
        box-shadow var(--transition-normal);
    display: flex;
    flex-direction: column;
    height: var(--card-height);
}

.specimen-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

/* ============================================
   Image Container - Fixed Height & Aspect Ratio
   ============================================ */
.specimen-images {
    position: relative;
    height: var(--image-height);
    overflow: hidden;
    background: #000;
    flex-shrink: 0;
}

.specimen-images img {
    width: 100%;
    height: 100%;
    object-fit: contain; /* Changed from cover to contain for better CT scan display */
    object-position: center;
    transition: transform var(--transition-normal);
    background: #000;
}

.specimen-card:hover .specimen-images img {
    transform: scale(1.05);
}

/* Image Overlay */
.image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.specimen-card:hover .image-overlay {
    opacity: 1;
}

.overlay-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    padding: 10px;
}

.overlay-btn {
    padding: 10px 15px;
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: background var(--transition-normal);
    cursor: pointer;
    border: none;
    white-space: nowrap;
}

.overlay-btn:hover {
    background: var(--primary-dark);
}

.overlay-btn.optical {
    background: var(--primary-color);
}

.overlay-btn.optical:hover {
    background: var(--primary-dark);
}

.overlay-btn.ct-scan {
    background: var(--secondary-color);
}

.overlay-btn.ct-scan:hover {
    background: var(--secondary-dark);
}

.overlay-btn.model-3d {
    background: var(--accent-color);
}

.overlay-btn.model-3d:hover {
    background: var(--accent-dark);
}

/* ============================================
   Specimen Info - Scrollable Content Area
   ============================================ */
.specimen-info {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.specimen-info h3 {
    color: var(--text-primary);
    margin: 0 0 10px 0;
    font-size: 1.3em;
    font-weight: 600;
    line-height: 1.3;
}

.specimen-info h3 .scientific-name {
    font-style: italic;
    display: block;
    font-size: 0.9em;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Metadata Grid */
.specimen-meta {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    font-size: 0.85em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.meta-item {
    display: flex;
    align-items: baseline;
    gap: 5px;
}

.meta-item strong {
    color: var(--text-primary);
    font-weight: 600;
}

/* Description */
.specimen-description {
    line-height: 1.5;
    color: var(--text-secondary);
    font-size: 0.9em;
    margin-bottom: 8px;
}

/* Tags */
.specimen-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: auto;
}

.tag {
    background: #ecf0f1;
    color: var(--text-primary);
    padding: 4px 10px;
    border-radius: var(--radius-lg);
    font-size: 0.75em;
    font-weight: 500;
}

/* ============================================
   3D Model Viewer Modal
   ============================================ */
.model-viewer-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.model-viewer-modal.active {
    display: block;
}

.model-viewer-content {
    position: relative;
    margin: 2% auto;
    width: 95%;
    height: 95%;
    max-width: 1600px;
    background: var(--bg-white);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.model-viewer-header {
    background: var(--text-primary);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.model-viewer-header h3 {
    margin: 0;
    font-size: 1.3em;
    font-weight: 600;
}

.close-model-viewer {
    color: white;
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    transition: opacity var(--transition-normal);
}

.close-model-viewer:hover {
    opacity: 0.7;
}

.model-viewer-container {
    background: #f0f0f0;
    height: calc(100% - 70px);
    position: relative;
    min-height: 500px;
}

/* Sketchfab Embed Styling */
.sketchfab-embed-wrapper {
    width: 100%;
    height: 100%;
    min-height: 500px;
}

.sketchfab-embed-wrapper iframe {
    width: 100%;
    height: 100%;
    min-height: 500px;
    border: none;
}

/* ============================================
   Image Type Badges
   ============================================ */
.image-type-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.75em;
    font-weight: 600;
    text-transform: uppercase;
    z-index: 10;
}

.image-type-badge.optical {
    background: var(--primary-color);
}

.image-type-badge.ct {
    background: var(--secondary-color);
}

/* ============================================
   Loading States
   ============================================ */
.specimen-card.loading {
    opacity: 0.5;
    pointer-events: none;
}

.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s linear infinite;
}

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

/* ============================================
   Responsive Design
   ============================================ */

/* Tablets */
@media (max-width: 992px) {
    .specimens-grid {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
        gap: 25px;
    }

    :root {
        --card-height: 580px;
        --image-height: 250px;
    }

    .gallery-header h1 {
        font-size: 2em;
    }

    .specimen-meta {
        grid-template-columns: 1fr;
        gap: 6px;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .specimens-grid {
        grid-template-columns: 1fr;
        gap: 20px;
        padding: 0 15px;
    }

    :root {
        --card-height: auto;
        --image-height: 220px;
    }

    .specimen-card {
        height: auto;
        min-height: 500px;
    }

    .gallery-header {
        margin-bottom: 40px;
    }

    .gallery-header h1 {
        font-size: 1.8em;
    }

    .gallery-header p {
        font-size: 1em;
    }

    .search-box {
        margin: 0 15px 20px;
    }

    .category-filters ul {
        padding: 0 15px;
    }

    .overlay-buttons {
        flex-direction: column;
        gap: 8px;
    }

    .overlay-btn {
        padding: 8px 12px;
        font-size: 13px;
    }

    .specimen-info {
        padding: 15px;
        overflow-y: visible;
    }

    .model-viewer-content {
        margin: 1% auto;
        width: 98%;
        height: 98%;
    }

    .model-viewer-container {
        min-height: 400px;
    }

    .model-viewer-header {
        padding: 15px;
    }

    .model-viewer-header h3 {
        font-size: 1.1em;
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    .specimens-grid {
        grid-template-columns: 1fr;
    }

    .gallery-header h1 {
        font-size: 1.5em;
    }

    .specimen-info h3 {
        font-size: 1.1em;
    }

    .overlay-btn {
        font-size: 12px;
        padding: 7px 10px;
    }
}

/* ============================================
   Utility Classes
   ============================================ */
.hidden {
    display: none !important;
}

.fade-in {
    animation: fadeIn 0.5s ease;
}

.fade-out {
    animation: fadeOut 0.5s ease;
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
    .image-overlay,
    .search-filter-section,
    .category-filters {
        display: none !important;
    }

    .specimen-card {
        page-break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
    }
}
