/**
 * Theme Grid Component
 * Styles for research themes section and theme blocks
 */

/* Research Themes Section */
.research-themes {
    margin: 4em auto;
    max-width: 1200px;
}

@media (max-width: 768px) {
    .research-themes {
        padding: 0 0.5em;
    }
}

.section-title {
    text-align: center;
    font-size: 2.5em;
    margin-bottom: 0.5em;
    color: var(--color-text-title);
    font-weight: 500;
    letter-spacing: -0.02em;
}

.section-subtitle {
    text-align: center;
    font-size: 1.2em;
    color: var(--color-text-secondary);
    margin-bottom: 3em;
}

/* Theme Grid Layout - One theme per row */
.theme-grid {
    display: flex;
    flex-direction: column;
    gap: 2em;
    margin-top: 2em;
}

/* Theme Block Styling - Liquid Glass Effect */
.theme-block {
    padding: 2em;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    top: 0;
    /* Ensure top transition works */
    display: flex;
    flex-direction: row;
    gap: 2em;
    align-items: stretch;
    min-height: 250px;
    isolation: isolate;

    /* Liquid Glass - Base Layer */
    background: linear-gradient(135deg,
            rgba(93, 143, 179, 0.18) 0%,
            rgba(137, 207, 240, 0.10) 50%,
            rgba(46, 46, 46, 0.15) 100%);

    /* Frosted glass blur - enhanced for image background */
    backdrop-filter: blur(30px) saturate(180%);
    -webkit-backdrop-filter: blur(30px) saturate(180%);

    border-radius: var(--radius-xl);
    border: 1.5px solid rgba(255, 255, 255, 0.15);
    overflow: hidden;
    /* Clip distorted background to rounded corners */

    /* Layered shadows for depth */
    box-shadow:
        0 8px 32px rgba(93, 143, 179, 0.12),
        0 2px 8px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);

    /* Animation */
    opacity: 0;
    animation: themeBlockFadeIn 0.8s ease-out forwards;
}

/* Staggered animation delays for theme blocks */
.theme-block:nth-child(1) {
    animation-delay: 0.1s;
}

.theme-block:nth-child(2) {
    animation-delay: 0.2s;
}

.theme-block:nth-child(3) {
    animation-delay: 0.3s;
}

.theme-block:nth-child(4) {
    animation-delay: 0.4s;
}

.theme-block:nth-child(5) {
    animation-delay: 0.5s;
}

.theme-block:nth-child(6) {
    animation-delay: 0.6s;
}

@keyframes themeBlockFadeIn {
    from {
        opacity: 0;
        /* transform removed to prevent containing block creation */
    }

    to {
        opacity: 1;
        /* transform removed */
    }
}

/* Liquid Glass - Highlight Layer (light refraction) */
.theme-block::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius-xl);
    padding: 1.5px;
    background: linear-gradient(135deg,
            rgba(255, 255, 255, 0.3) 0%,
            rgba(255, 255, 255, 0.1) 40%,
            rgba(255, 255, 255, 0) 70%);
    -webkit-mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    mask-composite: exclude;
    pointer-events: none;
    opacity: 0.7;
    transition: opacity 0.4s ease;
    z-index: 1;
}

/* Liquid Glass - Illumination Layer (ambient glow) */
.theme-block::after {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: var(--radius-xl);
    background: radial-gradient(circle at 30% 20%,
            rgba(137, 207, 240, 0.15) 0%,
            transparent 50%);
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
    z-index: 0;
}

.theme-block:hover::before {
    opacity: 1;
}

.theme-block:hover::after {
    opacity: 0.8;
}

.theme-block:hover {
    top: -10px;
    /* Use top instead of transform */
    /* scale(1.01) removed to avoid transform */
    border-color: rgba(255, 255, 255, 0.25);
    box-shadow:
        0 20px 48px rgba(93, 143, 179, 0.25),
        0 8px 16px rgba(0, 0, 0, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
    background: linear-gradient(135deg,
            rgba(93, 143, 179, 0.25) 0%,
            rgba(137, 207, 240, 0.15) 50%,
            rgba(46, 46, 46, 0.18) 100%);
}

/* Theme-specific glass tints - unified liquid glass effect */
.theme-block[data-theme="superconducting"]:hover,
.theme-block[data-theme="qec"]:hover,
.theme-block[data-theme="tensor"]:hover,
.theme-block[data-theme="neural"]:hover {
    background: linear-gradient(135deg,
            rgba(93, 143, 179, 0.25) 0%,
            rgba(137, 207, 240, 0.15) 50%,
            rgba(46, 46, 46, 0.18) 100%);
}

.theme-block[data-theme="superconducting"]:hover::after,
.theme-block[data-theme="qec"]:hover::after,
.theme-block[data-theme="tensor"]:hover::after,
.theme-block[data-theme="neural"]:hover::after {
    background: radial-gradient(circle at 30% 20%,
            rgba(137, 207, 240, 0.2) 0%,
            transparent 60%);
}

/* Ensure all content is above glass layers */
.theme-block>* {
    position: relative;
    z-index: 2;
}

/* Theme Info Section (left side) */
.theme-info {
    flex: 0 0 33%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    border-right: 2px solid rgba(255, 255, 255, 0.12);
    padding-right: 2em;
}

/* Theme Icon */
.theme-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 1em;
    color: var(--color-theme-1);
    transition: all 0.4s ease;
    flex-shrink: 0;
    /* Add subtle glow effect */
    filter: drop-shadow(0 0 8px currentColor) drop-shadow(0 0 4px currentColor);
}

.theme-block:hover .theme-icon {
    transform: scale(1.1) rotate(5deg);
    /* Enhanced glow on hover */
    filter: drop-shadow(0 0 16px currentColor) drop-shadow(0 0 8px currentColor) drop-shadow(0 0 4px currentColor);
}

.theme-block[data-theme="superconducting"] .theme-icon {
    color: var(--color-theme-1);
}

.theme-block[data-theme="qec"] .theme-icon {
    color: var(--color-theme-2);
}

.theme-block[data-theme="tensor"] .theme-icon {
    color: var(--color-theme-3);
}

.theme-block[data-theme="neural"] .theme-icon {
    color: var(--color-theme-4);
}

/* Theme Title */
.theme-title {
    font-size: 1.5em;
    margin: 0 0 0.8em 0;
    text-align: center;
    color: var(--color-text-title);
    font-weight: 600;
    flex-shrink: 0;
}

/* Theme Description */
.theme-description {
    font-size: 1em;
    line-height: 1.6;
    color: var(--color-text-body);
    margin: 0 0 1.5em 0;
    text-align: center;
    flex-grow: 1;
}

/* Project Previews within Theme Cards (right side) */
.theme-projects-preview {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr));
    gap: 1em;
    align-content: start;
    max-width: 100%;
}

/* Responsive projects grid */
@media (min-width: 1200px) {
    .theme-projects-preview {
        grid-template-columns: repeat(2, 1fr);
        max-width: 100%;
    }
}

@media (min-width: 1600px) {
    .theme-projects-preview {
        grid-template-columns: repeat(3, 1fr);
        max-width: 100%;
    }
}

@media (max-width: 1199px) and (min-width: 1025px) {
    .theme-projects-preview {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 1024px) {
    .theme-projects-preview {
        grid-template-columns: 1fr;
    }
}

.preview-project {
    border: 1px solid rgba(93, 143, 179, 0.2);
    border-radius: var(--radius-badge);
    margin-bottom: 0.8em;
    transition: all 0.3s ease;
    position: relative;
    overflow: visible;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

.preview-project:hover {
    border-color: rgba(93, 143, 179, 0.4);
    transform: translateX(5px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Background image for preview projects */
.preview-project-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 1;
    border-radius: var(--radius-badge);
    pointer-events: none;
}

/* Content wrapper with overlay - dark background when there's an image */
.preview-project:has(.preview-project-bg) .preview-project-content {
    position: relative;
    z-index: 2;
    padding: 0.8em;
    background: linear-gradient(to bottom,
            rgba(30, 30, 30, 0.85) 0%,
            rgba(30, 30, 30, 0.9) 100%);
    display: flex;
    flex-direction: column;
    border-radius: var(--radius-badge);
    box-sizing: border-box;
    min-height: 120px;
    flex: 1;
}

/* Content wrapper - transparent blue background when there's no image */
.preview-project:not(:has(.preview-project-bg)) .preview-project-content {
    position: relative;
    z-index: 2;
    padding: 0.8em;
    background: rgba(93, 143, 179, 0.1);
    min-height: 120px;
    display: flex;
    flex-direction: column;
    border-radius: var(--radius-badge);
    box-sizing: border-box;
    flex: 1;
}

.preview-project:not(:has(.preview-project-bg)):hover .preview-project-content {
    background: rgba(93, 143, 179, 0.15);
}

.preview-project h5 {
    font-size: 0.9em;
    color: white;
    margin: 0;
    font-weight: 600;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    flex: 1;
    min-width: 0;
    line-height: 1.3;
}

.preview-project p {
    font-size: 0.8em;
    color: rgba(255, 255, 255, 0.8);
    margin: 0;
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.preview-project .project-badge {
    display: inline-block;
    padding: 0.2em 0.5em;
    border-radius: var(--radius-badge);
    border: none !important;
    border-width: 0 !important;
    border-style: none !important;
    outline: none !important;
    box-shadow: none !important;
    font-size: 0.7em;
    font-weight: 600;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    flex-shrink: 0;
}

.preview-project .project-badge.completed {
    background: var(--color-status-completed-bg);
    color: var(--color-status-completed-light);
    border: none !important;
}

.preview-project .project-badge.ongoing {
    background: var(--color-status-ongoing-bg);
    color: var(--color-status-ongoing-light);
    border: none !important;
}

.preview-project .project-badge.potential {
    background: var(--color-content-type-bg);
    color: var(--color-content-type-light);
    border: none !important;
}

.preview-project-header {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    margin-bottom: 0.5em;
    gap: 0.5em;
    flex-wrap: wrap;
}

.preview-project .learn-more-link {
    color: var(--color-content-type-light);
    text-decoration: none;
    font-size: 0.8em;
    font-weight: 600;
    margin-top: 0.5em;
    display: inline-block;
    transition: all 0.3s ease;
}

.preview-project .learn-more-link:hover {
    color: var(--color-content-type-light);
    transform: translateX(3px);
}

/* Theme Stats */
.theme-stats {
    display: flex;
    flex-direction: column;
    gap: 0.5em;
    margin-top: 1.5em;
    padding-top: 1.5em;
    border-top: 1px solid rgba(93, 143, 179, 0.2);
    width: 100%;
}

.stat {
    font-size: 0.85em;
    color: rgba(255, 255, 255, 0.7);
    text-align: left;
}

.stat strong {
    color: var(--color-content-type-light);
    font-size: 1.2em;
    margin-right: 0.3em;
}

/* Expanded Theme View Styles */
.theme-expanded-description {
    font-size: 1.2em;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 2em;
    text-align: center;
    padding-bottom: 1em;
    border-bottom: 2px solid rgba(93, 143, 179, 0.3);
}

.project-section-title {
    font-size: 1.8em;
    margin: 2em 0 1em 0;
    color: var(--color-text-title);
    text-align: left;
    font-weight: 600;
}

.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5em;
    margin-bottom: 2em;
}

.project-item {
    background: linear-gradient(135deg, rgba(93, 143, 179, 0.1) 0%, rgba(46, 46, 46, 0.2) 100%);
    border: 1px solid rgba(93, 143, 179, 0.3);
    border-radius: var(--radius-md);
    padding: 1.5em;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

.project-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(93, 143, 179, 0.2);
    border-color: rgba(93, 143, 179, 0.5);
}

.project-thumbnail {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: var(--radius-badge);
    margin-bottom: 1em;
}

.project-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.project-content h4 {
    font-size: 1.3em;
    margin: 0 0 0.5em 0;
    color: white;
}

.project-content p {
    flex-grow: 1;
    margin: 0.5em 0;
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.5;
}

.project-badge {
    display: inline-block;
    padding: 0.3em 0.8em;
    border-radius: var(--radius-md);
    font-size: 0.85em;
    font-weight: 600;
    margin-bottom: 0.8em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.project-badge.completed {
    background: var(--color-status-completed-bg);
    color: var(--color-status-completed-light);
    border: 1px solid var(--color-status-completed-border);
}

.project-badge.ongoing {
    background: var(--color-status-ongoing-bg);
    color: var(--color-status-ongoing-light);
    border: 1px solid var(--color-status-ongoing-border);
}

.project-badge.potential {
    background: var(--color-content-type-bg);
    color: var(--color-content-type-light);
    border: 1px solid var(--color-content-type-border);
}

.project-link {
    display: inline-block;
    margin-top: 1em;
    color: var(--color-content-type-light);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    align-self: flex-start;
}

.project-link:hover {
    color: var(--color-content-type-light);
    transform: translateX(5px);
}

.no-projects {
    text-align: center;
    padding: 3em;
    color: rgba(255, 255, 255, 0.6);
    font-size: 1.1em;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .theme-grid {
        grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    }

    .projects-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }
}

@media (max-width: 1024px) {
    .theme-block {
        flex-direction: column;
    }

    .theme-info {
        flex: 1;
        border-right: none;
        border-bottom: 2px solid rgba(93, 143, 179, 0.2);
        padding-right: 0;
        padding-bottom: 1.5em;
    }

    .theme-projects-preview {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .theme-grid {
        gap: 1.5em;
    }

    .theme-block {
        min-height: auto;
        padding: 1.5em;
    }

    .section-title {
        font-size: 2em;
    }

    .projects-grid {
        grid-template-columns: 1fr;
    }

    .project-section-title {
        font-size: 1.5em;
    }
}