/*
 * Numbers.Finance — socle commun à toutes les pages.
 * En-tête, recherche, pied de page et jetons de design. Les feuilles propres
 * à chaque page (analyse-styles.css, secteur-styles.css…) se chargent après.
 */

:root {
    --nf-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --nf-ink: #111827;
    --nf-ink-2: #4b5563;
    --nf-ink-3: #6b7280;
    --nf-line: #e5e7eb;
    --nf-line-soft: #f1f2f4;
    --nf-bg: #ffffff;
    --nf-bg-soft: #f8f9fa;
    --nf-accent: #2563eb;
    --nf-pos: #137333;
    --nf-neg: #c5221f;
    --nf-radius: 12px;
    --nf-header-h: 64px;
}

/* ---------- En-tête ---------- */
.nf-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    height: var(--nf-header-h);
    background: rgba(255, 255, 255, 0.96);
    -webkit-backdrop-filter: saturate(180%) blur(8px);
    backdrop-filter: saturate(180%) blur(8px);
    border-bottom: 1px solid var(--nf-line);
    font-family: var(--nf-font);
}

.nf-header-inner {
    display: flex;
    align-items: center;
    gap: 20px;
    height: 100%;
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 24px;
    box-sizing: border-box;
}

body.nf-page {
    padding-top: var(--nf-header-h);
}

.nf-logo {
    display: inline-flex;
    align-items: baseline;
    flex-shrink: 0;
    color: var(--nf-ink);
    font-family: var(--nf-font);
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.02em;
    text-decoration: none;
}

.nf-logo-sub {
    color: var(--nf-ink-3);
    font-weight: 500;
}

/* ---------- Recherche ---------- */
.nf-search {
    position: relative;
    flex: 0 1 420px;
    min-width: 0;
}

.nf-search-field {
    display: flex;
    align-items: center;
    height: 40px;
    padding: 0 4px 0 14px;
    background: var(--nf-bg-soft);
    border: 1px solid var(--nf-line);
    border-radius: 999px;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.nf-search-field:focus-within {
    background: #ffffff;
    border-color: #c7cbd1;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.nf-search-icon {
    color: var(--nf-ink-3);
    font-size: 14px;
}

.nf-search input[type="search"] {
    flex: 1 1 auto;
    min-width: 0;
    height: 100%;
    padding: 0 10px;
    border: none;
    outline: none;
    background: transparent;
    color: var(--nf-ink);
    font-family: var(--nf-font);
    font-size: 15px;
}

.nf-search input[type="search"]::-webkit-search-cancel-button {
    -webkit-appearance: none;
}

.nf-search-btn {
    flex-shrink: 0;
    height: 32px;
    padding: 0 14px;
    border: none;
    border-radius: 999px;
    background: var(--nf-ink);
    color: #ffffff;
    font-family: var(--nf-font);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.nf-search-btn:hover {
    background: #000000;
}

.nf-autocomplete {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    max-height: min(420px, 60vh);
    overflow-y: auto;
    background: #ffffff;
    border: 1px solid var(--nf-line);
    border-radius: var(--nf-radius);
    box-shadow: 0 12px 32px rgba(17, 24, 39, 0.12);
    z-index: 1002;
}

.nf-autocomplete.is-open {
    display: block;
}

.nf-autocomplete a {
    display: block;
    padding: 10px 14px;
    color: var(--nf-ink);
    text-decoration: none;
    border-bottom: 1px solid var(--nf-line-soft);
}

.nf-autocomplete a:last-child {
    border-bottom: none;
}

.nf-autocomplete a:hover,
.nf-autocomplete a.is-active {
    background: var(--nf-bg-soft);
}

.nf-ac-name {
    display: block;
    font-size: 14px;
    font-weight: 600;
}

.nf-ac-meta {
    display: block;
    margin-top: 2px;
    color: var(--nf-ink-3);
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nf-ac-empty {
    padding: 12px 14px;
    color: var(--nf-ink-3);
    font-size: 14px;
}

/* ---------- Navigation ---------- */
.nf-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}

.nf-nav a {
    padding: 8px 12px;
    border-radius: 8px;
    color: var(--nf-ink-2);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
}

.nf-nav a:hover {
    background: var(--nf-bg-soft);
    color: var(--nf-ink);
}

.nf-nav a[aria-current="page"] {
    color: var(--nf-ink);
    font-weight: 600;
}

/* Zone contextuelle (fiche, secteur) à droite de l'en-tête */
.nf-context {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    padding-left: 16px;
    border-left: 1px solid var(--nf-line);
}

.nf-context-text {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    min-width: 0;
    line-height: 1.25;
}

.nf-context-title {
    max-width: 260px;
    overflow: hidden;
    color: var(--nf-ink);
    font-size: 14px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nf-context-sub {
    color: var(--nf-ink-3);
    font-size: 12px;
}

.nf-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--nf-ink);
    font-size: 16px;
    cursor: pointer;
}

.nf-icon-btn:hover {
    background: var(--nf-bg-soft);
}

.nf-search-toggle {
    display: none;
}

/* Accueil : barre transparente, sans logo ni recherche (portés par le hero) */
.nf-header--home {
    position: absolute;
    background: transparent;
    border-bottom: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}

.nf-header--home .nf-logo {
    display: none;
}

.nf-header--home .nf-nav {
    margin-left: auto;
}

@media (max-width: 900px) {
    .nf-header--home .nf-nav {
        display: flex;
    }

    .nf-header--home .nf-nav a {
        padding: 8px 8px;
        font-size: 13px;
    }
}

/* ---------- Filtre de liste (pages secteurs / départements) ---------- */
.nf-filter {
    position: relative;
    max-width: 420px;
    margin: 0 0 24px;
}

.nf-filter input {
    width: 100%;
    height: 44px;
    padding: 0 70px 0 40px;
    border: 1px solid var(--nf-line);
    border-radius: 999px;
    background: var(--nf-bg-soft);
    color: var(--nf-ink);
    font-family: var(--nf-font);
    font-size: 15px;
    box-sizing: border-box;
    outline: none;
}

.nf-filter input:focus {
    background: #ffffff;
    border-color: #c7cbd1;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.nf-filter .fa-search {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--nf-ink-3);
    font-size: 14px;
}

.nf-filter-count {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--nf-ink-3);
    font-size: 13px;
}

@media (max-width: 768px) {
    .nf-filter input {
        font-size: 16px;
    }
}

/* ---------- Pied de page ---------- */
.nf-footer {
    margin-top: 64px;
    padding: 40px 24px 32px;
    border-top: 1px solid var(--nf-line);
    background: var(--nf-bg-soft);
    color: var(--nf-ink-3);
    font-family: var(--nf-font);
    font-size: 14px;
}

.nf-footer-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    max-width: 1200px;
    margin: 0 auto;
}

.nf-footer .nf-logo {
    font-size: 17px;
}

.nf-footer p {
    margin: 6px 0 0;
    max-width: 420px;
    line-height: 1.5;
}

.nf-footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 24px;
}

.nf-footer a {
    color: var(--nf-ink-2);
    text-decoration: none;
}

.nf-footer a:hover {
    color: var(--nf-ink);
    text-decoration: underline;
}

.nf-footer-legal {
    flex-basis: 100%;
    padding-top: 16px;
    border-top: 1px solid var(--nf-line);
    font-size: 13px;
}

/* ---------- Mobile ---------- */
@media (max-width: 900px) {
    .nf-nav {
        display: none;
    }

    .nf-context {
        margin-left: auto;
    }
}

@media (max-width: 768px) {
    :root {
        --nf-header-h: 56px;
    }

    .nf-header-inner {
        gap: 4px;
        padding: 0 8px 0 16px;
    }

    .nf-logo {
        font-size: 18px;
    }

    .nf-search-toggle {
        display: inline-flex;
        margin-left: auto;
    }

    .nf-context {
        margin-left: 0;
        padding-left: 4px;
        border-left: none;
    }

    .nf-context-title {
        max-width: 140px;
        font-size: 13px;
    }

    /* La recherche s'ouvre en bandeau sous l'en-tête */
    .nf-search {
        display: none;
    }

    .nf-header.search-open .nf-search {
        display: block;
        position: fixed;
        top: var(--nf-header-h);
        left: 0;
        right: 0;
        padding: 10px 12px;
        background: #ffffff;
        border-bottom: 1px solid var(--nf-line);
        box-shadow: 0 8px 20px rgba(17, 24, 39, 0.08);
    }

    .nf-header.search-open .nf-autocomplete {
        left: 12px;
        right: 12px;
    }

    .nf-search input[type="search"] {
        font-size: 16px; /* évite le zoom automatique d'iOS */
    }

    .nf-footer {
        margin-top: 40px;
        padding: 32px 16px 24px;
    }

    .nf-footer-inner {
        flex-direction: column;
        gap: 16px;
    }
}

/* Accueil : le bouton pause de l'animation passe en bas à droite pour libérer la navigation */
.nf-header--home ~ .hero-section .animation-control,
.hero-section .animation-control {
    top: auto !important;
    bottom: 20px;
}
