/* ==========================================================================
   GLOBAL STYLES
   ========================================================================== */

/* Prevent double-tap zoom on mobile */
* {
    touch-action: manipulation;
    font-family: 'Helvetica Now Display', sans-serif;
    letter-spacing: 0.15px;
}

/* ==========================================================================
   HEADER
   ========================================================================== */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    padding: var(--spacing-lg) 20px;
    background: var(--color-bg-primary);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    height: 24px;
    flex-direction: row;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 21px;
}

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

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

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

.logo-link {
    display: inline-block;
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.logo-link:hover {
    opacity: 0.8;
}


.header-nav {
    display: flex;
    gap: var(--spacing-xl);
}

.nav-link {
    color: var(--color-text-primary);
    font-size: 15.8px;
    font-weight: 300;
    text-decoration: none;
    transition: color 0.2s ease;
}

.nav-link:hover {
    color: var(--color-surface-secondary);
}

/* Active nav link - bold for desktop only */
.desktop-nav .nav-link-active {
    font-weight: 500; /* Medium weight */
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-xl);
    height: 64px;
}

.sign-in-link {
    color: var(--color-text-primary);
    font-size: var(--font-size-sm);
    font-weight: 400;
    text-decoration: none;
    transition: color 0.2s ease;
}

.sign-in-link:hover {
    color: var(--color-surface-secondary);
}



/* ==========================================================================
   FOOTER
   ========================================================================== */
.footer {
    position: relative;
    z-index: 5;
    background: #000000;
    margin-top: 0;
    display: flex;
    align-items: center;
    padding: 64px; /* Desktop padding as default */
    opacity: 0;
    transition: opacity 0.6s ease;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0;
    width: 100%;
}

.footer-left {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.footer-copyright {
    color: #ffffff;
    font-size: 14px;
    font-weight: 400;
    line-height: 20px;
    font-family: 'Helvetica Now Display', sans-serif;
}

.footer-description {
    color: #999999;
    font-size: 14px;
    font-weight: 300;
    line-height: 16px;
    font-family: 'Helvetica Now Display', sans-serif;
}

.footer-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 16px;
}

/* New footer right structure based on Tailwind */
.footer-right > div {
    display: inline-flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-end;
    gap: 1rem; /* gap-4 = 16px */
}

/* Top row: Scientists Indexed with badge */
.footer-right > div > div:first-child {
    display: inline-flex;
    justify-content: flex-start;
    align-items: center;
    gap: 0.5rem; /* gap-2 = 8px */
}

/* Scientists Indexed label */
.footer-right > div > div:first-child > div:first-child {
    text-align: center;
    justify-content: flex-start;
    color: var(--Color-Text-default-secondary--text);
    font-size: 0.875rem; /* text-sm = 14px */
    font-weight: 300; /* font-light */
    font-family: 'Helvetica Now Display', sans-serif;
    line-height: 1rem; /* leading-4 = 16px */
}

/* Number 99,999 */
.footer-right > div > div:first-child > div:nth-child(2) {
    text-align: center;
    justify-content: flex-start;
    color: var(--Color-Text-default-primary--text);
    font-size: 0.875rem; /* text-sm = 14px */
    font-weight: 300; /* font-light */
    font-family: 'Helvetica Now Display', sans-serif;
    line-height: 1rem; /* leading-4 = 16px */
}

/* Stats badge container is now the third child */
.footer-right > div > div:first-child > div:nth-child(3) {
    position: relative;
    display: inline-block;
}

/* Badge container with tooltip */
.stats-badge-container {
    position: relative;
    display: inline-block;
}

/* Badge with arrow and number */
.stats-badge {
    padding-left: 0.25rem; /* px-1 = 4px */
    padding-right: 0.25rem;
    padding-top: 0.2rem; /* Increased from 0.125rem to make pill taller */
    padding-bottom: 0.2rem;
    background-color: #22c55e; /* bg-Color-Text-default-success - green color */
    border-radius: 20px;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 0.25rem; /* gap-1 = 4px */
    cursor: pointer;
}

/* Arrow icon image */
.stats-badge img {
    width: 0.75rem; /* w-3 = 12px */
    height: 0.75rem; /* h-3 = 12px */
    display: block;
}

/* Badge number 580 */
.stats-badge > div:last-child {
    text-align: center;
    justify-content: flex-start;
    color: var(--Color-Text-default-primary--text);
    font-size: 0.7rem; /* Reduced from 0.75rem (11px) */
    font-weight: 800; /* Increased from 400 to semi-bold */
    font-family: 'Helvetica Now Display', sans-serif;
    line-height: 0.75rem; /* leading-3 = 12px */
}

/* Tooltip - hidden by default */
.stats-badge-tooltip {
    position: absolute;
    bottom: 100%;
    right: 0;
    margin-bottom: 8px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    pointer-events: none;
    z-index: 1000;
}

/* Show tooltip on hover */
.stats-badge-container:hover .stats-badge-tooltip {
    opacity: 1;
    visibility: visible;
}

/* Tooltip content */
.stats-badge-tooltip > div {
    align-self: stretch;
    padding: 0.5rem; /* p-2 = 8px */
    background-color: #404040; /* bg-Color-Text-default-disabled */
    border-radius: 4px;
    outline: 0.50px solid rgba(255, 255, 255, 0.3);
    outline-offset: -0.50px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 0.625rem; /* gap-2.5 = 10px */
    overflow: visible;
    white-space: nowrap;
    min-width: fit-content;
}

/* Tooltip inner flex container */
.stats-badge-tooltip > div > div {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 0.625rem; /* gap-2.5 = 10px */
    min-width: fit-content;
}

/* Tooltip text */
.stats-badge-tooltip > div > div > div {
    width: auto;
    min-width: 7rem; /* w-28 = 112px */
    max-width: none;
    justify-content: flex-start;
    color: var(--Color-Text-default-primary--text);
    font-size: 0.75rem; /* text-xs = 12px */
    font-weight: 400; /* font-normal */
    font-family: 'Helvetica Now Display', sans-serif;
    line-height: 0.75rem; /* leading-3 = 12px */
    white-space: nowrap;
}

/* Bottom row: Terms and Privacy */
.footer-right > div > div:last-child {
    display: inline-flex;
    justify-content: flex-start;
    align-items: flex-start;
    gap: 1rem; /* gap-4 = 16px */
}

/* Terms and Privacy links */
.footer-right > div > div:last-child > a {
    justify-content: flex-start;
    color: var(--Color-Text-default-secondary--text);
    font-size: 0.875rem; /* text-sm = 14px */
    font-weight: 300; /* font-light */
    font-family: 'Helvetica Now Display', sans-serif;
    line-height: 1rem; /* leading-4 = 16px */
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer-right > div > div:last-child > a:hover {
    color: var(--Color-Text-default-primary--text);
}



/* ==========================================================================
   SEARCH COMPONENTS
   ========================================================================== */
.search-container {
    width: 100%;
    padding: 11.5px 11px 11.5px 15px;  
    background: white;
    border-radius: 44px;
    border: 1.14px solid #DBD9D9;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
    position: relative;
    z-index: 5;
}

/* Clear Button */
.clear-button {
    background: transparent;
    border: none;
    padding: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 0;
    height: 32px;
}

.clear-icon {
    width: 20px;
    height: 20px;
    opacity: 0.7;
}

/* Search Button */
.search-button {
    margin-left: 0;
}

.search-bar {
    width: 100%; /* Make it responsive to container width */
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Homepage-specific override */
.homepage-container .search-bar {
    width: 759px; /* Keep homepage width */
}

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

.search-input-group {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 1;
    min-width: 0;
}

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

.search-input {
    border: none;
    background: transparent;
    color: #000000; /* Black text when typing */
    font-size: 16px;
    font-family: 'Helvetica Now Display';
    font-weight: 400;
    line-height: 15.31px;
    outline: none;
    flex: 1;
    min-width: 0;
}

.search-input::placeholder {
    color: var(--color-text-placeholder); /* Keep placeholder color as is */
}

.search-button {
    width: 49px;
    height: 32px;
    padding: 4px 6px;
    background: #DBD9D9;
    border: none;
    border-radius: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9.49px;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

/* Remove the hover effect */
/* .search-button:hover {
    background: var(--color-border-primary);
} */

/* Disabled state */
.search-button.disabled {
    background: #DBD9D9;
    opacity: 0.6;
}

/* Enabled state */
.search-button.enabled {
    background: #000000; /* Black when characters exist */
    cursor: pointer;
    opacity: 1;
    transition: background-color 0.2s ease;
}

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

.arrow-icon {
    width: 20px;
    height: 20px;
    background: url('assets/icons/arrow-right.svg') no-repeat center;
    background-size: contain;
}

/* ==========================================================================
   POPULAR SEARCHES
   ========================================================================== */
.popular-searches {
    display: flex;
    align-items: center;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 40px;
}

.popular-label {
    color: var(--color-surface-secondary);
    font-size: 14px;
    font-weight: 400;
    line-height: 13.40px;
}

.search-tags {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;

}

.search-tag {
    padding: 9px var(--spacing-md); /* Reduced from 10px to 6px for smaller height */
    border: 1.14px solid var(--color-border-primary);
    border-radius: var(--radius-xl);
    background: transparent;
    color: var(--color-surface-secondary);
    font-size: var(--font-size-xs);
    font-family: var(--font-family);
    font-weight: 400;
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 1; /* Keep this to ensure text doesn't add extra height */
}

.search-tag:hover {
    background: var(--color-surface-secondary);
    color: var(--color-bg-primary);
}

/* ==========================================================================
   RESPONSIVE DESIGN
   ========================================================================== */

@media (max-width: 480px) {
    .header {
        padding: var(--spacing-sm) 15px;
    }
    
    .footer {
        padding: 30px 15px;
    }
}

/* ==========================================================================
   MOBILE STYLES
   ========================================================================== */
.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 24px;
    height: 24px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1001;
}

.hamburger-line {
    width: 100%;
    height: 2px;
    background-color: var(--color-text-primary);
    transition: all 0.3s ease;
    border-radius: 2px;
    position: relative;
}

.mobile-menu-toggle.active .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translate(0, 0);
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    margin-top: -1px;
}

.mobile-menu-toggle.active .hamburger-line:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.active .hamburger-line:nth-child(3) {
    transform: rotate(-45deg) translate(0, 0);
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    margin-top: -1px;
}

.mobile-nav {
    visibility: hidden;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: white;
    opacity: 0;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 1000;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

.mobile-nav.active {
    visibility: visible;
    opacity: 1;
}

.mobile-nav-header {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    padding: 20px;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1001;
}

.mobile-nav-logo .logo-icon {
    width: 24px;
    height: 24px;
    background-image: url('assets/logoFull.svg');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    filter: none;
}


.mobile-nav-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100vh;
    height: 100dvh; /* Use dynamic viewport height for iOS */
    gap: 0;
    padding: 0 20px;
    box-sizing: border-box;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
}

.mobile-nav-link {
    color: black;
    font-size: 24px;
    font-weight: 300;
    text-decoration: none;
    padding: 12px 0;
    margin: 8px 0;
    transition: color 0.2s ease;
    text-align: center;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

.mobile-nav-link:hover {
    color: #666;
}

.autopoiesis-link {
    display: flex;
    align-items: center;
    gap: 8px;
}

.diagonal-icon {
    width: 20px;
    height: 20px;
}

/* ==========================================================================
   MOBILE RESPONSIVE
   ========================================================================== */
@media (max-width: 768px) {
    .header {
        padding: 20px 20px;
    }
    
    .header-content {
        height: 24px;
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        width: 100%;
    }
    
    .header-left {
        display: flex;
        align-items: center;
        gap: 0;
        flex: 0 0 auto;
    }
    
    .header-right {
        display: flex;
        align-items: center;
        flex: 0 0 auto;
    }
    
    .desktop-nav {
        display: none;
    }
    
    
    .mobile-menu-toggle {
        display: none;
    }
    
    .logo-icon {
        width: 24px;
        height: 24px;
    }
    
    /* Hide logo text on mobile */
    .header-logo .logo-text-ari {
        display: none;
    }
    
    /* Change header logo to black when mobile nav is active */
    .header.mobile-nav-open .header-left .logo-icon {
        background-image: url('assets/icons/logo-black.svg');
        filter: none;
    }
    
    /* Change hamburger lines to black when mobile nav is active */
    .header.mobile-nav-open .mobile-menu-toggle .hamburger-line {
        background-color: black;
    }
    
    /* Add fade transition to body when mobile nav is active */
    body {
        transition: background-color 0.3s ease;
    }
    
    .mobile-nav-open body {
        background-color: white;
    }
    
    
    .mobile-menu-toggle {
        width: 18px;
        height: 18px;
        position: relative;
    }
    
    .hamburger-line {
        height: 1px;
    }
    
    /* Mobile search container styles */
    .search-container {
        padding: 10px 10px 10px 15px;
        border-radius: 33px;
        flex-direction: row;
        gap: 8px;
        width: calc(100% - 40px);
        max-width: calc(100% - 40px);
        margin: 20px auto;
        white-space: nowrap;
        height: 48px;
        display: flex;
        align-items: center;
        box-sizing: border-box;
        position: relative;
    }
    
    .search-bar {
        flex-direction: row;
        gap: 8px;
        width: 100%;
        flex: 1;
        min-width: 0;
        align-items: center;
    }
    
    .search-input-group {
        flex: 1;
        min-width: 0;
        max-width: calc(100% - 48px);
        display: flex;
        align-items: center;
    }
    
    .search-icon {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .search-button {
        width: 49px;
        height: 32px;
        flex-shrink: 0;
    }
    
    .search-input {
        font-size: 16px; /* Prevent iOS Safari zoom */
        width: 100%;
        min-width: 0;
        display: flex;
        align-items: center;
        line-height: 1;
    }
    
    /* Show only first 3 popular search tags on mobile */
    .search-tag:nth-child(n+4) {
        display: none;
    }
    
    /* Center the popular searches section */
    .popular-searches {
        text-align: center;
        max-width: 500px;
        margin: 0 auto;
    }
    
    .search-tags {
        justify-content: center;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    /* Mobile footer styles */
    .footer {
        padding: 40px;
        text-align: left;
    }
    
    .footer-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 24px;
    }
    
    .footer-left {
        align-items: flex-start;
    }
    
    .footer-right {
        align-self: flex-start;
        align-items: flex-start;
        gap: 16px;
    }
    
    /* Left align footer right container and links on mobile */
    .footer-right > div {
        align-items: flex-start !important;
    }
    
    .footer-right > div > div:last-child {
        justify-content: flex-start !important;
        align-items: flex-start !important;
    }
    
    .footer-links {
        gap: 16px;
    }
    
    .footer-link {
        font-size: 13px;
    }
    
    /* Mobile footer text - reduce size */
    .footer-copyright {
        font-size: 13px !important;
        line-height: 16px !important;
    }
    
    .footer-description {
        font-size: 13px !important;
        line-height: 14px !important;
    }
    
    .stats-label,
    .stats-number {
        font-size: 13px !important;
        line-height: 14px !important;
    }
    
    .footer-link {
        font-size: 13px !important;
        line-height: 14px !important;
    }
    
    /* Center the stats badge tooltip on mobile */
    .stats-badge-tooltip {
        right: auto !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
    }
    
    /* Center the tooltip text content on mobile */
    .stats-badge-tooltip > div > div {
        justify-content: center !important;
    }
    
    .stats-badge-tooltip > div > div > div {
        text-align: center !important;
        justify-content: center !important;
    }
    
}

@media (min-width: 769px) {
    .mobile-nav {
        display: none !important;
    }
    
    .mobile-menu-toggle {
        display: none !important;
    }
}