/* INCI4ME BF6N29 R11: four public views + shared header navigation only.
   Scope: Info, Credits, Restrictions, INCI; desktop header controls; six mobile menu links.
   Does not change Analyze, Pricing, OCR, Score, account panel, or language picker layouts. */

/* The legacy WelcomePage rule limits the entire main element to 1060px.
   The page-scoped fix must release that ancestor before aligning its actual shell. */
body.inci-site.active-welcomepage .site-main {
    max-width: none !important;
    width: 100% !important;
}

/* Single public content width, aligned with the main Analyze cards (desktop).
   Specific selectors intentionally override old Bootstrap and per-view container widths. */
body.inci-site.active-welcomepage .site-main > .inci-r8-public-shell,
body.inci-site.active-credits .site-main > .credits-page,
body.inci-site.active-restrictions .site-main > .restrictions-page,
body.inci-site.active-archivioinci .site-main > .archive-page {
    width: min(980px, calc(100% - 24px)) !important;
    max-width: 980px !important;
    min-width: 0;
    margin-left: auto !important;
    margin-right: auto !important;
    box-sizing: border-box;
}

/* Same horizontal reference for the logo and Account/language on desktop.
   The existing JS can still measure page widths for the footer. */
@media (min-width: 992px) {
    body.inci-site:not(.inci-admin-portal-server) .inci-main-navbar #siteHeaderPanel {
        width: min(980px, calc(100vw - 32px)) !important;
        max-width: 980px !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }
}

/* ONLY the six first-level menu entries become two columns in portrait.
   Leave Account and language controls/dropdowns exactly as before. */
@media (max-width: 991.98px) and (orientation: portrait) {
    body.inci-site .inci-main-navbar #mainNavbar > ul.navbar-nav.mx-auto {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 8px !important;
        width: 100%;
    }
    body.inci-site .inci-main-navbar #mainNavbar > ul.navbar-nav.mx-auto > li.nav-item {
        width: 100%;
        min-width: 0;
        margin: 0;
    }
    body.inci-site .inci-main-navbar #mainNavbar > ul.navbar-nav.mx-auto > li.nav-item > a.nav-link {
        width: 100%;
        min-height: 44px;
        height: 100%;
        box-sizing: border-box;
        white-space: normal;
        overflow-wrap: anywhere;
    }
}


/* BF6N29 R12: landscape-only alignment and restrained headings.
   R11 portrait navigation and controls remain byte-for-byte unchanged above.
   Analyze/Pricing content and all business logic are out of scope. */
@media (min-width: 992px) and (orientation: landscape) {
    /* The header uses the same visible edges as the Analyze workspace.
       Remove Bootstrap horizontal padding only here, not in portrait. */
    body.inci-site:not(.inci-admin-portal-server) .inci-main-navbar #siteHeaderPanel {
        width: min(960px, calc(100vw - 32px)) !important;
        max-width: 960px !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        margin-left: auto !important;
        margin-right: auto !important;
        position: relative !important;
        display: flex !important;
        align-items: center !important;
        flex-wrap: nowrap !important;
    }
    body.inci-site:not(.inci-admin-portal-server) .inci-main-navbar #siteHeaderPanel > .navbar-brand {
        flex: 0 0 auto !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    body.inci-site:not(.inci-admin-portal-server) .inci-main-navbar #mainNavbar {
        position: static !important;
        display: flex !important;
        flex: 1 1 auto !important;
        min-width: 0 !important;
        align-items: center !important;
    }
    /* Center the six primary links on the full header, not the remaining
       space after the logo and Account/Login/language controls. */
    body.inci-site:not(.inci-admin-portal-server) .inci-main-navbar #mainNavbar > ul.navbar-nav.mx-auto {
        position: absolute !important;
        top: 50% !important;
        left: 50% !important;
        right: auto !important;
        transform: translate(-50%, -50%) !important;
        display: flex !important;
        flex: 0 0 auto !important;
        width: max-content !important;
        margin: 0 !important;
        padding: 0 !important;
        white-space: nowrap !important;
        justify-content: center !important;
    }
    body.inci-site:not(.inci-admin-portal-server) .inci-main-navbar #mainNavbar > .header-actions {
        margin-left: auto !important;
        margin-right: 0 !important;
        flex: 0 0 auto !important;
        justify-content: flex-end !important;
    }
}

/* The four public informational pages match Analyze's 980px desktop
   workspace. Keep their existing R11 responsive/portrait rules intact. */
@media (min-width: 768px) and (orientation: landscape) {
    body.inci-site.active-welcomepage .site-main > .inci-r8-public-shell,
    body.inci-site.active-credits .site-main > .credits-page,
    body.inci-site.active-restrictions .site-main > .restrictions-page,
    body.inci-site.active-archivioinci .site-main > .archive-page {
        width: min(980px, calc(100% - 24px)) !important;
        max-width: 980px !important;
        box-sizing: border-box !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }
    /* Smaller landscape hero titles: Info, Credits, INCI. */
    body.inci-site.active-welcomepage .site-main > .inci-r8-public-shell .discovery-hero h1,
    body.inci-site.active-credits .site-main > .credits-page .discovery-hero h1,
    body.inci-site.active-archivioinci .site-main > .archive-page .discovery-hero h1 {
        font-size: clamp(1.85rem, 2.2vw, 2.45rem) !important;
        line-height: 1.14 !important;
        letter-spacing: -0.025em !important;
    }
    body.inci-site.active-welcomepage .site-main > .inci-r8-public-shell .discovery-hero,
    body.inci-site.active-credits .site-main > .credits-page .discovery-hero,
    body.inci-site.active-archivioinci .site-main > .archive-page .discovery-hero {
        padding: clamp(1.35rem, 2vw, 2rem) !important;
    }
    /* Restrictions uses a page headline (h3) instead of a discovery hero. */
    body.inci-site.active-restrictions .site-main > .restrictions-page > .text-center > h3 {
        font-size: clamp(1.5rem, 1.9vw, 1.95rem) !important;
        line-height: 1.18 !important;
    }
    /* Section titles remain legible but no longer dominate the screen. */
    body.inci-site.active-welcomepage .site-main > .inci-r8-public-shell .discovery-section-header h2,
    body.inci-site.active-credits .site-main > .credits-page .discovery-section-header h2,
    body.inci-site.active-archivioinci .site-main > .archive-page .discovery-section-header h2 {
        font-size: clamp(1.4rem, 1.75vw, 1.85rem) !important;
        line-height: 1.2 !important;
    }
}

/* INCI4ME BF6N29 R13 - LANDSCAPE ONLY.
   Visual reference is the 1120px outer Analyze #myTabContent upload panel,
   NOT the legacy 960px navigation or 980px R12 informational shells.
   Intentionally no portrait selectors, no Analyze/Score/OCR overrides. */
@media (min-width: 768px) and (orientation: landscape) {
    /* A single reference from INCI to Credits, including Pricing.
       Release old Bootstrap and page-specific max-widths at the shell level. */
    body.inci-site.active-welcomepage .site-main {
        max-width: none !important;
        width: 100% !important;
    }
    body.inci-site.active-welcomepage .site-main > .inci-r8-public-shell,
    body.inci-site.active-credits .site-main > .credits-page,
    body.inci-site.active-restrictions .site-main > .restrictions-page,
    body.inci-site.active-archivioinci .site-main > .archive-page,
    body.inci-site.active-pricing .site-main > .pricing-page {
        width: min(1120px, calc(100vw - 32px)) !important;
        max-width: 1120px !important;
        min-width: 0 !important;
        margin-left: auto !important;
        margin-right: auto !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        box-sizing: border-box !important;
    }
    /* The INCI search card has its OWN 860px cap (independent from the
       archive-page cap): it must now occupy the whole public workspace. */
    body.inci-site.active-archivioinci .archive-page .archive-search-card {
        width: 100% !important;
        max-width: none !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        box-sizing: border-box !important;
    }
    body.inci-site.active-archivioinci .archive-page .archive-search-heading {
        width: 100% !important;
        max-width: none !important;
        box-sizing: border-box !important;
    }
    body.inci-site.active-archivioinci .archive-page .archive-search-form,
    body.inci-site.active-archivioinci .archive-page #ingrediente-input.archive-search-input {
        width: 100% !important;
        max-width: none !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
    }
}
@media (min-width: 992px) and (orientation: landscape) {
    /* Same visible left/right edges as the Analyze tab-content panel.
       R12's explicit 960px width compressed Login/Register against Credits. */
    body.inci-site:not(.inci-admin-portal-server) .inci-main-navbar #siteHeaderPanel {
        width: min(1120px, calc(100vw - 32px)) !important;
        max-width: 1120px !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }
    body.inci-site:not(.inci-admin-portal-server) .inci-main-navbar #siteHeaderPanel > .navbar-brand {
        margin-left: 0 !important;
        padding-left: 0 !important;
    }
    body.inci-site:not(.inci-admin-portal-server) .inci-main-navbar #mainNavbar > .header-actions {
        margin-left: auto !important;
        margin-right: 0 !important;
        padding-right: 0 !important;
    }
    body.inci-site:not(.inci-admin-portal-server) .inci-main-navbar #mainNavbar .language-dropdown > .language-current {
        padding-right: 0 !important;
        margin-right: 0 !important;
    }
}
/* At narrow landscape desktop widths the six links cannot stay absolutely
   centered between two unequal side blocks without colliding: center them
   in the available space instead. Portrait and wide desktop stay untouched. */
@media (min-width: 992px) and (max-width: 1279.98px) and (orientation: landscape) {
    body.inci-site:not(.inci-admin-portal-server) .inci-main-navbar #mainNavbar > ul.navbar-nav.mx-auto {
        position: static !important;
        transform: none !important;
        top: auto !important;
        left: auto !important;
        width: auto !important;
        min-width: 0 !important;
        flex: 1 1 auto !important;
        justify-content: center !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }
    body.inci-site:not(.inci-admin-portal-server) .inci-main-navbar #mainNavbar > ul.navbar-nav.mx-auto > li > .nav-link {
        padding-left: 6px !important;
        padding-right: 6px !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
}

/* INCI4ME BF6N29 R14 - DESKTOP LANDSCAPE MICRO-ADJUSTMENT.
   Move ONLY the six primary menu links 28px toward the logo.
   Existing logo, Login, Register, Account, language and 1120px shell stay put.
   Desktop <=1279px keeps R13 collision-safe layout. Portrait unchanged. */
@media (min-width: 1280px) and (orientation: landscape) {
    body.inci-site:not(.inci-admin-portal-server) .inci-main-navbar #mainNavbar > ul.navbar-nav.mx-auto {
        left: calc(50% - 28px) !important;
    }
}
