/* ==========================================================================
   HOMEPAGE LAYOUT
   ========================================================================== */

/* ==========================================================================
   SMOOTH LOADING ANIMATIONS
   ========================================================================== */

/* ==========================================================================
   HOMEPAGE ANIMATIONS - Initial State (hidden until animated)
   ========================================================================== */

/* Initial state - hidden for main elements (above the fold) */
/* These will be animated by JavaScript adding .text-loaded class */
/* Fallback: auto-animate after short delay if JS doesn't run */
.homepage-container .hero-title,
.homepage-container .hero-subtitle,
.homepage-container .search-section,
.homepage-container .popular-searches,
.homepage-container .homepage-logo-section,
.homepage-container .search-container,
.homepage-container .section-title,
.homepage-container .section-subtitle,
.homepage-container .view-all-btn,
.homepage-container .domains-section,
.homepage-container .research-areas-grid,
.homepage-container .research-area-card {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease, transform 0.8s ease;
    /* Prevent layout shift during animation */
    will-change: opacity, transform;
    /* Fallback animation - elements become visible after 200ms if JS doesn't run */
    animation: fadeInUp 0.8s ease 0.2s forwards;
}

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile-only fade in animation (no translate) */
@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

/* Mobile fallback animation - fade only */
@media (max-width: 768px) {
    .homepage-container .hero-title,
    .homepage-container .hero-subtitle,
    .homepage-container .search-section,
    .homepage-container .popular-searches,
    .homepage-container .homepage-logo-section,
    .homepage-container .search-container,
    .homepage-container .section-title,
    .homepage-container .section-subtitle,
    .homepage-container .view-all-btn,
    .homepage-container .domains-section,
    .homepage-container .research-areas-grid,
    .homepage-container .research-area-card {
        animation: fadeIn 0.8s ease 0.2s forwards !important;
        transform: none !important;
    }
    
    /* Mobile: Remove translateY from .text-loaded class */
    .homepage-container .domains-section.text-loaded,
    .homepage-container .research-areas-grid.text-loaded,
    .homepage-container .research-area-card.text-loaded {
        transform: none !important;
    }
}


.homepage-container {
    position: relative;
    width: 100%;
    overflow: hidden;
}

/* ==========================================================================
   BACKGROUND ELEMENTS
   ========================================================================== */
.background-image-container {
    position: absolute;
    top: 0;
    right: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.scientist-image {
    position: absolute;
    right: 0;
    top: 0;
    width: 586px;
    height: 100%;
    object-fit: cover;
}

.image-gradient-overlay {
    position: absolute;
    right: 0;
    top: 0;
    width: 629px;
    height: 100%;
    background: linear-gradient(90deg, 
        black 0%, 
        rgba(0, 0, 0, 0.90) 20%, 
        rgba(0, 0, 0, 0.40) 39%, 
        rgba(0, 0, 0, 0.20) 87%);
}

/* ==========================================================================
   MAIN CONTENT
   ========================================================================== */
.main-content {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 86px);
    padding: 0 20px;
    gap: var(--spacing-3xl);
}

.hero-section {
    text-align: left;
    max-width: 1600px;
    z-index: 5;
    margin-left: 20px;
}

.hero-title {
    font-family: 'Helvetica Now Display';
    font-size: var(--font-size-xl);
    font-weight: 400;
    line-height: 1;
    margin-bottom: var(--spacing-lg);
    color: var(--color-text-primary);
    letter-spacing: 0.5px;
}

.hero-subtitle {
    font-size: var(--font-size-md);
    font-weight: 400;
    line-height: 1.2;
    margin-top: 40px;
    margin-bottom: 0;
    color: var(--color-text-secondary);
    max-width: 1600px;
}

.search-section {
    text-align: center;
    z-index: 5;
}

/* ==========================================================================
   HOMEPAGE LOGO SECTION
   ========================================================================== */
.homepage-logo-section {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 13px;
    margin-bottom: 40px;
}

.homepage-logo {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 6px;
}

.homepage-logo .logo-icon {
    width: 43px;
    height: 43px;
    background: url('assets/icons/logoFull.svg') no-repeat center;
    background-size: contain;
    filter: brightness(0) invert(1);
}

.homepage-logo .logo-text-ari {
    width: 100px;
    height: 43px;
    background: url('assets/icons/new-ari.svg') no-repeat center;
    background-size: contain;
    filter: brightness(0) invert(1);
}

.homepage-directory-title {
    color: #ffffff;
    font-family: 'Canela Text', 'Canela Trial', 'Canela', sans-serif;
    font-size: 10.5px;
    font-weight: 400;
    line-height: 1.2;
    text-align: left;
    margin-left: 2px;
}

/* ==========================================================================
   HOMEPAGE SEARCH OVERRIDES
   ========================================================================== */

.homepage-container .search-container {
    width: 100%;
    max-width: 100%;
}

.homepage-container .search-bar {
    width: 100%;
}

.homepage-container .search-input-group {
    gap: 15px;
}

.homepage-container .search-icon {
    width: 24px;
    height: 24px;
    background: url('assets/icons/logoFull.svg') no-repeat center;
    background-size: contain;
}

.homepage-container .search-input {
    color: #000000;
    font-size: 16px;
    font-family: 'Helvetica Now Display';
    font-weight: 400;
    line-height: 15.31px;
}

.homepage-container .search-button {
    width: 49px;
    height: 32px;
    padding: 4px 6px;
    background: #DBD9D9;
    border-radius: 18px;
    gap: 9.49px;
    transition: all 0.2s ease;
}

.homepage-container .search-button.disabled {
    background: #DBD9D9;
    opacity: 0.6;
}

.homepage-container .search-button.enabled {
    background: #000000;
    opacity: 1;
    transition: background-color 0.2s ease;
}

/* Homepage-specific hover effect for enabled button */
.homepage-container .search-button.enabled:hover {
    background: #333333; /* Dark grey on hover */
}

.homepage-container .arrow-icon {
    transform: none;
}

.homepage-container .popular-searches {
    margin-top: 24px;
    justify-content: flex-start !important; /* Force left alignment */
    text-align: left;
}

.homepage-container .popular-label {
    font-family: 'Helvetica Now Display';
    font-weight: 300;
}

.homepage-container .search-tag {
    border-radius: var(--radius-lg);
    line-height: 10px; /* Add this line to decrease line height */
}

/* View All Scientists Link */
.view-all-scientists-link {
    margin-top: 16px;
    text-align: left;
}

.view-all-link {
    color: #9D9B9B;
    text-decoration: underline;
    text-underline-offset: 3px;
    font-family: 'Helvetica Now Display', sans-serif;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.2;
    transition: opacity 0.2s ease;
}

.view-all-link:hover {
    opacity: 0.8;
}

/* ==========================================================================
   LOADING SPINNER STYLES
   ========================================================================== */

/* Loading spinner styles */
.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    text-align: center;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) !important;
    z-index: 10;
    width: auto;
    height: auto;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-message {
    color: #666;
    font-size: 14px;
    margin: 0;
}

/* ==========================================================================
   RESPONSIVE DESIGN
   ========================================================================== */
@media (max-width: 1200px) {
    .scientist-image {
        width: 400px;
        height: 600px;
    }
    
    .image-gradient-overlay {
        width: 450px;
        height: 650px;
    }
    
    .hero-title {
        font-size: 28px;
    }
    
    .hero-subtitle {
        font-size: 18px;
    }
}

/* ==========================================================================
   DOMAINS SECTION - Based on Tailwind Classes
   NOTE: This section is completely isolated and does NOT use search.css
   All domain section styles are scoped to prevent any conflicts
   ========================================================================== */

.domains-section {
    background: var(--color-bg-primary);
    padding: 180px 0 80px 0;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

/* Main container: h-[1193px] inline-flex flex-col justify-start items-center gap-12 */
.domains-section > div:first-child {
    height: 1193px;
    display: inline-flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    gap: 48px; /* gap-12 = 3rem = 48px */
}

/* Title: self-stretch justify-start text-Color-Text-default-primary--text text-3xl font-normal font-['Helvetica_Now_Display'] leading-10 */
.domains-section > div > div:first-of-type {
    align-self: stretch;
    justify-content: flex-start;
    font-size: 1.875rem; /* text-3xl = 30px */
    font-weight: 400; /* font-normal */
    font-family: 'Helvetica Now Display', sans-serif;
    line-height: 2.5rem; /* leading-10 = 40px */
    color: var(--color-text-primary);
}

/* Inner container: self-stretch flex flex-col justify-start items-center gap-6 */
.domains-section > div > div:last-child {
    align-self: stretch;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    gap: 24px; /* gap-6 = 1.5rem = 24px */
}

/* Header row only */
.domains-section .research-areas-header {
    align-self: stretch;
    display: inline-flex;
    justify-content: space-between;
    align-items: center;
}

/* "Research Area" text inside the header */
.domains-section .research-areas-header > div:first-child {
    width: 176px; /* w-44 = 11rem = 176px */
    justify-content: flex-start;
    color: white;
    font-size: 1.25rem; /* text-xl = 20px */
    font-weight: 500; /* font-medium */
    font-family: 'Helvetica Now Display', sans-serif;
    line-height: 1.5rem; /* leading-6 = 24px */
}

/* "View all" button in the header */
.domains-section .research-areas-header > a {
    padding-left: 0.875rem; /* px-3.5 = 14px */
    padding-right: 0.875rem;
    padding-top: 0.625rem; /* py-2.5 = 10px */
    padding-bottom: 0.625rem;
    border-radius: 34.21px;
    outline: 1px solid #525252; /* outline-neutral-700 */
    outline-offset: -1.14px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem; /* gap-2 = 8px */
    text-decoration: none;
}

/* Button text */
.domains-section .research-areas-header > a > div {
    text-align: center;
    justify-content: flex-start;
    color: white;
    font-size: 0.875rem; /* text-sm = 14px */
    font-weight: 400; /* font-normal */
    font-family: 'Helvetica Now Display', sans-serif;
    line-height: 0.75rem; /* leading-3 = 12px */
}

/* Grid container: research-areas-grid - 4 cards per row */
.research-areas-grid {
    display: grid;
    grid-template-columns: repeat(4, 192px); /* w-48 = 192px */
    grid-auto-rows: 128px; /* h-32 = 128px */
    gap: 16px;
    width: fit-content;
    margin: 0 auto;
}

/* Make sure grid children don't get header styles by accident */
.research-areas-grid > .research-area-card {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
}

/* Medium desktop - 3 cards per row */
@media (max-width: 1400px) {
    /* Remove fixed height to show all domains */
    .domains-section > div:first-child {
        height: auto !important;
        min-height: auto !important;
    }
    
    .research-areas-grid {
        grid-template-columns: repeat(3, 192px);
    }
}

/* Medium desktop - 2 cards per row */
@media (max-width: 1200px) {
    /* Remove fixed height to show all domains */
    .domains-section > div:first-child {
        height: auto !important;
        min-height: auto !important;
    }
    
    .research-areas-grid {
        grid-template-columns: repeat(2, 192px);
    }
}

/* Card: w-48 h-32 rounded-xl inline-flex flex-col justify-center items-center gap-2.5 */
.research-area-card {
    width: 192px; /* w-48 = 12rem = 192px */
    height: 128px; /* h-32 = 8rem = 128px */
    border-radius: 12px; /* rounded-xl */
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem; /* gap-3 = 12px - matches inner gap */
    cursor: pointer;
    background: #000000; /* Black by default */
    border: none;
    box-shadow: none;
    position: relative;
    overflow: visible; /* Changed from hidden to visible to allow text to show */
    transition: background-color 0.2s ease;
    padding: 29px 12px 12px 12px; /* Top padding for icon alignment, horizontal padding for text */
    box-sizing: border-box; /* Include padding in height calculation */
}

/* Hover state: lighter gray background */
.research-area-card:hover {
    background: #1B1B1B;
}

/* Inner card flex container: flex flex-col items-center gap-3 */
/* This inner div must have no padding/margin to ensure icons align perfectly */
.research-area-card > div {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem; /* gap-3 = 12px */
    width: 100%;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Icon container: w-10 h-10 relative overflow-hidden */
.research-area-card > div > div:first-child {
    width: 2.5rem; /* w-10 = 40px */
    height: 2.5rem; /* h-10 = 40px */
    position: relative;
    overflow: hidden;
}

/* Icon image: positioned absolutely */
.research-area-card img {
    position: absolute;
    object-fit: contain;
}

/* Text container: various widths (w-20, w-36, w-44, w-52) text-center justify-start text-Color-Text-default-secondary--text text-sm font-normal font-['Helvetica_Now_Display'] leading-5 */
.research-area-card > div > div:last-child {
    text-align: center;
    justify-content: flex-start;
    color: var(--color-text-secondary);
    font-size: 0.875rem; /* text-sm = 14px */
    font-weight: 400; /* font-normal */
    font-family: 'Helvetica Now Display', sans-serif;
    line-height: 1.4; /* Increased line height for better readability */
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    padding: 0 4px; /* Add horizontal padding to prevent text from touching edges */
    box-sizing: border-box;
    max-width: 100%;
}

/* Specific text widths - adjusted to account for padding */
.research-area-card > div > div:last-child.w-20 {
    max-width: 5rem; /* 80px */
    width: auto;
}

.research-area-card > div > div:last-child.w-36 {
    max-width: 9rem; /* 144px */
    width: auto;
}

.research-area-card > div > div:last-child.w-44 {
    max-width: 11rem; /* 176px */
    width: auto;
}

.research-area-card > div > div:last-child.w-52 {
    max-width: 13rem; /* 208px */
    width: auto;
}

/* Special card with shadow */
.research-area-card.shadow-\[0px_4px_4px_0px_rgba\(0\2c 0\2c 0\2c 0\.25\)\] {
    box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.25);
}

/* Card with pt-5 padding top - removed to ensure consistent centering */
/* .research-area-card.pt-5 removed - icons should always be centered */

@media (max-width: 768px) {
    /* Mobile-specific animations - fade only, no translation */
    /* For the entire search section, remove translateY and only fade in */
    .homepage-container .homepage-logo-section,
    .homepage-container .search-container,
    .homepage-container .hero-subtitle,
    .homepage-container .popular-searches,
    .homepage-container .search-section {
        transform: none !important;
        transition: opacity 0.8s ease !important;
    }
    
    /* Also remove translateY for other elements */
    .hero-title,
    .hero-subtitle,
    .search-section,
    .popular-searches {
        transform: none !important;
    }
    
    .main-content {
        padding: 0;
        margin: 0;
        min-height: calc(100vh - 300px);
        gap: 0;
        width: 100%;
        max-width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    
    
    .hero-title {
        font-size: 24px;
        text-align: left;
        width: calc(100% - 40px);
        margin: 0 20px 20px 20px; /* Add 20px bottom margin */
    }
    
    .hero-subtitle {
        font-size: 16px;
        text-align: left;
        width: calc(100% - 40px);
        margin: 32px 0px 0px 0px;
    }
    
    .hero-section {
        width: 100%;
        text-align: left;
        margin-left: 0;
    }
    
    .search-section {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: stretch; /* Allow child to use full width */
        padding: 0;
        margin: 0 0 40px 0; /* Add bottom margin for mobile */
    }
    
    .background-image-container {
        position: relative;
        width: 100%;
        height: 440px; /* Increased height for more image area */
        z-index: 1;
        padding: 0;
        margin: 0;
    }
    
    .scientist-image {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
        object-position: center -20%; /* Position image lower to push it down */
        padding: 0 !important;
        margin: 0 !important;
        left: 0 !important;
        right: 0 !important;
        top: 0 !important;
        bottom: 0 !important;
        position: absolute !important;
        min-width: 100% !important;
        min-height: 100% !important;
    }
    
    .image-gradient-overlay {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: linear-gradient(to bottom, 
            rgba(0, 0, 0, 1) 10%, 
            rgba(0, 0, 0, 0) 50%, 
            rgba(0, 0, 0, 1) 100%);
        z-index: 2;
    }
    
    .main-content {
        position: relative;
        background: #000000;
        z-index: 3;
    }
    
    
    .homepage-logo-section {
        margin-top: 180px;
        margin-bottom: 32px;
        gap: 12px;
        padding: 0px;
    }

    .homepage-logo {
        gap: 8px;
    }

    .homepage-logo .logo-icon {
        width: 43px !important;
        height: 43px !important;
    }

    .homepage-logo .logo-text-ari {
        width: 100px !important;
        height: 43px !important;
    }

    .homepage-directory-title {
        font-size: 10.5px !important;
        line-height: 1.2 !important;
        font-weight: 400 !important;
    }

    .search-section {
        padding: 0 20px !important;
        margin: 0 !important;
        width: 100% !important;
        box-sizing: border-box;
    }

    .search-container {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 12px 10px 12px 15px !important;
    }

    .search-bar {
        flex-direction: row !important;
        gap: 8px !important;
        width: 100% !important;
        flex: 1 !important;
        min-width: 0 !important;
    }
    
    .search-input-group {
        flex: 1 !important;
        min-width: 0 !important;
        max-width: calc(100% - 48px) !important;
    }
    
    
    .search-input {
        font-size: 16px !important; /* Increased font size for mobile */
        width: 100% !important;
        min-width: 0 !important;
    }
    
    /* Show only first 3 popular search tags on mobile */
    .search-tag:nth-child(n+4) {
        display: none;
    }
    
    /* Mobile popular searches pills padding */
    .search-tag {
        padding: 12px 15px !important;
    }
    
    /* Popular searches section with left-aligned text */
    .popular-searches {
        text-align: left !important;
        max-width: 500px;
        margin: 32px 0px 0px 0px !important;
        width: calc(100% - 40px) !important;
        align-items: flex-start !important;
    }
    
    .popular-label {
        text-align: left !important;
        margin-left: 0 !important;
    }
    
    .search-tags {
        justify-content: flex-start !important;
        flex-wrap: wrap;
        gap: 8px;
        align-items: flex-start !important;
    }
    
    /* View all scientists link mobile alignment */
    .view-all-scientists-link {
        margin-left: 20px;
    }
    
    /* Mobile domain section adjustments */
    .domains-section {
        padding: 60px 20px 100px 20px !important; /* Add 20px side padding and extra bottom padding for mobile */
        justify-content: flex-start !important; /* Prevent centering from adding extra space */
    }
    
    /* Reduce domain header font size on mobile */
    .domains-section > div > div:first-of-type {
        font-size: 1.25rem !important; /* Reduced from 1.875rem (30px) to 20px */
        line-height: 2rem !important; /* Reduced from 2.5rem (40px) to 32px */
    }
    
    /* Reduce Research Area subheading font size on mobile */
    .domains-section .research-areas-header > div:first-child {
        font-size: 1rem !important; /* Reduced from 1.25rem (20px) to 16px */
        line-height: 1.2rem !important; /* Reduced from 1.5rem (24px) to 24px */
    }
    
    /* Reduce gap between header and subheader on mobile */
    .domains-section > div:first-child {
        gap: 24px !important; /* Reduced from 48px to 24px on mobile */
    }
    
    /* Remove fixed height on mobile to allow all domains to show */
    .domains-section > div:first-child {
        height: auto !important;
        min-height: auto !important;
        width: 100% !important; /* Ensure full width to respect parent padding */
    }
    
    .research-areas-grid {
        grid-template-columns: repeat(2, calc((100% - 16px) / 2)) !important;
        gap: 16px !important;
    }
    
    .research-area-card {
        width: 100% !important;
        height: 110px !important;
        padding-top: 21px !important; /* Fixed top padding ensures icons align at same Y position on mobile */
        box-sizing: border-box !important; /* Include padding in height calculation */
    }
    
    /* Reduce text size slightly on mobile */
    .research-area-card > div > div:last-child {
        font-size: 0.8125rem !important; /* 13px instead of 14px */
    }
}

