/*
 * Fi1m — Layout: container, header, navigation, ask bar, footer
 * =============================================================
 */

/* 1. Container */
.container {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 var(--container-pad);
}

/* 2. Header
   Sticks to the top, slides away as the reader scrolls down and comes back the moment they scroll up (site.js sets
   .is-hidden). --header-offset, also set by site.js, is the height the header currently occupies at the top of the
   viewport (0 while hidden) so the other sticky things — the browse filter bar, the facts panel — sit under it rather
   than behind it. */
:root {
    --header-offset: 0px;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 30;
    background: var(--background);
    padding: 20px 0;
    border-bottom: 1px solid var(--border-color);
    transition: transform 0.3s ease, border-color 0.3s ease, background-color 0.3s ease;
}

.site-header.is-hidden {
    transform: translateY(-100%);
}

.site-header--plain {
    border-bottom: none;
}

@media (prefers-reduced-motion: reduce) {
    .site-header {
        transition: border-color 0.3s ease, background-color 0.3s ease;
    }
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.logo {
    font-size: 42px;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.02em;
    line-height: 1;
}

.logo:hover {
    color: var(--primary);
}

/* 3. Navigation */
.nav-links {
    display: flex;
    gap: 24px;
    align-items: center;
}

.nav-links a {
    color: var(--text-color);
    font-weight: 500;
    transition: color 0.3s ease;
}

.nav-links a:hover,
.nav-links a[aria-current="page"] {
    color: var(--primary);
}

.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--search-background);
    transition: background-color 0.3s ease;
    margin-left: 4px;
}

.theme-toggle:hover {
    background-color: var(--search-focus-background);
}

.theme-toggle svg {
    width: 22px;
    height: 22px;
    color: var(--text-color);
    transition: transform 0.3s ease;
}

.theme-toggle:hover svg {
    transform: rotate(15deg);
}

/* Icon pair: sun shows in dark, moon shows in light */
.icon-sun { display: block; }
.icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }

/* 4. Ask bar (the conversational search box) */
.ask-bar {
    position: relative;
    display: flex;
    align-items: center;
    background-color: var(--search-background);
    border-radius: 60px;
    padding: 0.3rem 0.4rem 0.3rem 1.2rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: box-shadow 0.3s ease, background-color 0.3s ease;
}

.ask-bar:focus-within {
    background-color: var(--search-focus-background);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.ask-input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    padding: 0.5rem 0;
    font-size: 1rem;
    color: var(--text-color);
    outline: none;
}

.ask-input::placeholder {
    color: var(--placeholder-color);
}

.ask-send {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: transparent;
    color: var(--text-color-muted);
    transition: background-color 0.3s ease, transform 0.2s ease, color 0.3s ease;
}

.ask-send:disabled {
    cursor: default;
}

.ask-send.active {
    background-color: var(--primary);
    color: #fff;
}

.ask-send.active:hover {
    transform: scale(1.05);
}

.ask-send svg {
    width: 20px;
    height: 20px;
}

.ask-bar--header {
    width: 400px;
}

.ask-bar--hero {
    padding: 0.5rem 0.5rem 0.5rem 1.5rem;
    margin: 2rem 0 1.5rem;
}

.ask-bar--hero .ask-input {
    padding: 0.75rem 0;
    font-size: 1.05rem;
}

.ask-bar--hero .ask-send {
    width: 46px;
    height: 46px;
}

/* 5. Mobile menu */
.mobile-menu-toggle {
    display: none;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    background-color: var(--search-background);
    border-radius: 50%;
}

.mobile-menu-toggle svg {
    width: 24px;
    height: 24px;
    color: var(--text-color);
}

.mobile-menu {
    position: fixed;
    top: 0;
    right: -100%;
    width: 100%;
    height: 100%;
    background-color: var(--background);
    z-index: 1000;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
    padding: 20px;
}

.mobile-menu.active {
    right: 0;
}

.mobile-menu-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
}

.mobile-menu-overlay.active {
    display: block;
}

.mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
}

.mobile-menu-close {
    color: var(--text-color);
}

.mobile-menu-links {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.mobile-menu-links a {
    color: var(--text-color);
    font-size: 24px;
    margin-bottom: 20px;
    font-weight: 400;
}

.mobile-menu-links a[aria-current="page"] {
    color: var(--primary);
}

.mobile-menu-footer {
    margin-top: auto;
    padding-top: 20px;
}

.mobile-theme-toggle {
    width: auto;
    height: auto;
    background-color: var(--theme-toggle-bg);
    border-radius: 30px;
    padding: 10px 20px;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.mobile-theme-toggle span {
    font-size: 16px;
    font-weight: 500;
    color: var(--theme-toggle-text);
}

.mobile-theme-toggle svg {
    color: var(--theme-toggle-text);
}

.mobile-theme-toggle .label-dark { display: inline; }
.mobile-theme-toggle .label-light { display: none; }
[data-theme="light"] .mobile-theme-toggle .label-dark { display: none; }
[data-theme="light"] .mobile-theme-toggle .label-light { display: inline; }

/* 6. Footer */
.site-footer {
    background-color: var(--background);
    border-top: 1px solid var(--border-color);
    padding: 60px 0 30px;
    margin-top: 80px;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.footer-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr 1fr 2fr;
    gap: 30px;
    margin-bottom: 50px;
}

.footer-col {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.footer-col .logo {
    margin-bottom: 15px;
}

.footer-description {
    color: var(--gray);
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 20px;
    max-width: 90%;
}

.social-links {
    display: flex;
    gap: 12px;
}

.social-link {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--search-background);
    color: var(--text-color);
    transition: all 0.3s ease;
}

.social-link svg {
    width: 16px;
    height: 16px;
}

.social-link:hover {
    background-color: var(--primary);
    color: white;
    transform: translateY(-3px);
}

.footer-heading {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--gray);
    position: relative;
    display: inline-block;
    padding-bottom: 8px;
}

.footer-heading::after {
    content: '';
    position: absolute;
    width: 30px;
    height: 2px;
    background-color: var(--primary);
    bottom: 0;
    left: 0;
}

.footer-links {
    list-style: none;
    width: 100%;
}

.footer-links li {
    margin-bottom: 10px;
}

.footer-links a {
    color: var(--gray);
    font-size: 0.95rem;
    transition: color 0.3s ease, transform 0.3s ease;
    display: inline-block;
}

.footer-links a:hover {
    color: var(--text-color);
    transform: translateX(3px);
}

.newsletter-text {
    color: var(--gray);
    font-size: 0.9rem;
    margin-bottom: 15px;
}

.newsletter-form {
    display: flex;
    margin-bottom: 15px;
    width: 100%;
}

.newsletter-input {
    flex: 1;
    min-width: 0;
    padding: 12px 15px;
    border: none;
    background-color: var(--search-background);
    border-radius: 4px 0 0 4px;
    color: var(--text-color);
    font-size: 0.9rem;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.newsletter-input:focus {
    outline: none;
    background-color: var(--search-focus-background);
}

.newsletter-button {
    padding: 0 20px;
    background-color: var(--primary);
    color: white;
    font-weight: 600;
    border-radius: 0 4px 4px 0;
    transition: background-color 0.3s ease;
}

.newsletter-button:hover {
    background-color: var(--link-hover);
}

.newsletter-privacy {
    font-size: 0.8rem;
    color: var(--gray);
}

.footer-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    padding-top: 20px;
    margin-bottom: 15px;
    border-top: 1px solid var(--border-color);
    transition: border-color 0.3s ease;
}

.footer-legal {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

.footer-legal a {
    color: var(--gray);
    font-size: 0.85rem;
}

.footer-legal a:hover {
    color: var(--primary);
}

.footer-copyright {
    color: var(--gray);
    font-size: 0.85rem;
}

/* The one-line AI disclosure, on every page */
.footer-ai {
    font-size: 0.85rem;
    color: var(--gray);
    text-align: right;
}

.footer-ai a {
    color: var(--text-color);
    border-bottom: 1px solid var(--border-color);
}

.footer-ai a:hover {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* 7. Responsive */
@media (max-width: 1024px) {
    .ask-bar--header {
        width: 260px;
    }

    .footer-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .newsletter-col {
        grid-column: span 4;
    }
}

@media (max-width: 768px) {
    .logo {
        font-size: 34px;
    }

    .header-content {
        flex-wrap: wrap;
    }

    .ask-bar--header {
        order: 3;
        width: 100%;
        margin-top: 12px;
    }

    .nav-links {
        display: none;
    }

    .mobile-menu-toggle {
        display: flex;
    }

    .footer-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .footer-col:first-child,
    .newsletter-col {
        grid-column: span 2;
    }

    .footer-bottom {
        flex-direction: column;
        align-items: flex-start;
    }

    .footer-ai { text-align: left; }

    .footer-legal {
        gap: 12px 20px;
    }
}

@media (max-width: 480px) {
    .footer-grid {
        grid-template-columns: 1fr;
    }

    .footer-col:first-child,
    .newsletter-col {
        grid-column: 1;
    }
}
