/* Site header (header_2023.cfm)
   Scoped to #header.apHeader and prefixed "aph" so it overrides the older
   "header ..." rules in style_2023.css / responsive_2023.css without touching them.
   Heights are kept at or below the old header (68px desktop, 64px tablet/phone)
   so page content that was spaced for the old fixed header still clears it. */

#header.apHeader {
    --aph-ink: #17262f;
    --aph-ink-soft: #46555e;
    --aph-accent: #007ba9;          /* brand blue for text (4.5:1+) */
    --aph-line: rgba(23, 38, 47, 0.1);
    --aph-tile: #eef6fa;
    --aph-grad-brand: linear-gradient(90deg, #7fd12d 0%, #57b52f 22%, #45d0ef 60%, #1f97dd 100%);
    --aph-height: 68px;

    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 999;
    float: none;
    width: 100%;
    margin: 0;
    padding: 0;
    background: #ffffff;
    color: var(--aph-ink);
    font-family: 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    animation: none;
    transition: box-shadow .2s ease;
}

/* The old script adds .sticky on scroll; use it for a soft shadow only */
#header.apHeader.sticky {
    background: #ffffff;
    animation: none;
    box-shadow: 0 6px 20px -12px rgba(20, 35, 45, 0.35);
}

#header.apHeader *,
#header.apHeader *::before,
#header.apHeader *::after {
    box-sizing: border-box;
}

#header.apHeader ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

#header.apHeader p {
    margin: 0;
    font-family: inherit;
}

#header.apHeader svg {
    flex-shrink: 0;
}

#header.apHeader [hidden] {
    display: none !important;
}

#header.apHeader button {
    margin: 0;
    font-family: inherit;
    cursor: pointer;
}

/* ---------- Bar ---------- */

#header.apHeader .aphBar {
    position: relative;
    height: var(--aph-height);
}

/* Brand gradient line along the bottom of the bar */
#header.apHeader .aphBar::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--aph-grad-brand);
}

#header.apHeader .aphWrap {
    display: flex;
    align-items: center;
    gap: 32px;
    height: 100%;
    max-width: 1250px;
    margin: 0 auto;
    padding: 0 32px 2px;
}

#header.apHeader .aphLogo {
    flex-shrink: 0;
    width: auto;
    float: none;
}

#header.apHeader .aphLogo a {
    display: block;
    border-radius: 6px;
}

#header.apHeader .aphLogo img {
    display: block;
    width: 190px;
    height: auto;
}

/* ---------- Top-level nav ---------- */

/* Menu sits on the right, just before the buttons */
#header.apHeader .aphNav {
    flex: 0 1 auto;
    margin-left: auto;
}

#header.apHeader .aphMenu {
    display: flex;
    align-items: center;
    gap: 4px;
}

#header.apHeader .aphItem {
    position: relative;
}

/* Features panel is positioned against the full bar, not the item */
#header.apHeader .aphHasMega {
    position: static;
}

#header.apHeader .aphTop {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 44px;
    padding: 0 12px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--aph-ink);
    font-size: 15px;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
    transition: color .15s ease, background-color .15s ease;
}

#header.apHeader .aphTop:hover,
#header.apHeader .aphItem.is-open > .aphTop {
    color: var(--aph-accent);
    background: rgba(0, 123, 169, 0.06);
}

#header.apHeader .aphTop[aria-current="page"] {
    color: var(--aph-accent);
    box-shadow: inset 0 -2px 0 var(--aph-accent);
    border-radius: 0;
}

#header.apHeader .aphChevron {
    transition: transform .2s ease;
}

#header.apHeader .aphItem.is-open > .aphTop .aphChevron,
#header.apHeader .aphAccBtn[aria-expanded="true"] .aphChevron {
    transform: rotate(180deg);
}

/* ---------- Actions ---------- */

#header.apHeader .aphActions {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-left: auto;
}

/* When the menu is present it takes the auto margin; keep the buttons right after it */
#header.apHeader .aphNav + .aphActions {
    margin-left: 0;
}

/* The three buttons match the previous header exactly
   (same gradients, sizes and the Demo button's shine animation). */
#header.apHeader .aphBtn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 10px 20px;
    border-radius: 18px;
    color: #ffffff;
    font-size: 14px;
    font-weight: 500;
    line-height: 15px;
    white-space: nowrap;
    box-shadow: none;
    transition: all .3s ease-in-out;
}

#header.apHeader .aphBtn:hover {
    color: #ffffff;
}

#header.apHeader .aphBtnDemo {
    z-index: 0;
    isolation: isolate;
    overflow: hidden;
    font-weight: 700;
    background-image: linear-gradient(83.82deg, #e35d24, #f2b41e, #f2b41e, #e35d24);
    background-position: right;
    background-size: 200%;
}

#header.apHeader .aphBtnDemo::before {
    content: '';
    position: absolute;
    top: -35%;
    left: -30%;
    width: 24%;
    height: 170%;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(255, 248, 226, 0.18) 30%, rgba(255, 255, 255, 0.72) 50%, rgba(255, 248, 226, 0.18) 70%, rgba(255, 255, 255, 0) 100%);
    transform: translateX(-220%) skewX(-24deg);
    pointer-events: none;
    mix-blend-mode: screen;
    opacity: 0;
    z-index: 1;
    animation: header-demo-sheen 4.5s cubic-bezier(0.22, 1, 0.36, 1) infinite; /* keyframes in style_2023.css */
}

#header.apHeader .aphBtnDemo:hover {
    background-position: left;
}

#header.apHeader .aphBtnPayments {
    background: linear-gradient(90deg, #7fd12d 0%, #57b52f 100%);
}

#header.apHeader .aphBtnPayments:hover {
    background: linear-gradient(90deg, #57b52f 0%, #469b24 100%);
}

#header.apHeader .aphBtnLogin {
    background: linear-gradient(90deg, #45d0ef 0%, #1f97dd 100%);
}

#header.apHeader .aphBtnLogin:hover {
    background: linear-gradient(90deg, #1f97dd 0%, #147fc7 100%);
}

#header.apHeader .aphBtnLogin img {
    width: 10px;
    height: auto;
    margin-right: 5px;
}

/* ---------- Panels (shared) ---------- */

#header.apHeader .aphPanel {
    position: absolute;
    top: 100%;
    z-index: 2;
    visibility: hidden;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity .22s ease, transform .22s ease, visibility 0s linear .22s;
}

#header.apHeader .aphItem.is-open > .aphPanel,
/* Without JavaScript, open on hover / keyboard focus */
#header.apHeader:not(.aphJs) .aphHasPanel:hover > .aphPanel,
#header.apHeader:not(.aphJs) .aphHasPanel:focus-within > .aphPanel {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
    transition: opacity .22s ease, transform .22s ease, visibility 0s;
}

/* ---------- Features mega menu ---------- */

#header.apHeader .aphMega {
    left: 50%;
    width: min(1186px, calc(100vw - 32px));
    max-height: calc(100vh - var(--aph-height) - 24px);
    margin-left: calc(min(1186px, calc(100vw - 32px)) / -2);
    margin-top: 8px;
    overflow: auto;
    border: 1px solid var(--aph-line);
    border-radius: 18px;
    background: #ffffff;
    box-shadow: 0 24px 48px -24px rgba(20, 35, 45, 0.35);
}

/* Invisible bridge so the mouse can travel from the button to the panel */
#header.apHeader .aphMega::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 0;
    right: 0;
    height: 10px;
}

#header.apHeader .aphMegaInner {
    padding: 28px 32px 20px;
}

#header.apHeader .aphMegaTitle {
    margin-bottom: 20px;
    color: var(--aph-ink);
    font-size: 18px;
    font-weight: 600;
    line-height: 1.3;
}

#header.apHeader .aphMegaGroups {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px 28px;
}

#header.apHeader .aphGroupTitle {
    margin: 0 0 8px;
    padding: 0 10px;
    color: var(--aph-accent);
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1.5px;
    line-height: 1.4;
    text-transform: uppercase;
}

#header.apHeader .aphFeatureList li + li {
    margin-top: 2px;
}

#header.apHeader .aphFeature {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 10px;
    border-radius: 12px;
    color: var(--aph-ink);
    transition: background-color .15s ease;
}

#header.apHeader .aphFeature:hover {
    background: #f4f9fb;
}

/* Icon tile: the shared feature icons, recolored to brand blue with a mask */
#header.apHeader .aphFeatureIcon {
    display: inline-block;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background-color: var(--aph-tile);
    background-image: none;
    position: relative;
}

#header.apHeader .aphFeatureIcon::after {
    content: '';
    position: absolute;
    inset: 9px;
    background-color: var(--aph-accent);
    -webkit-mask: var(--aph-icon) center / contain no-repeat;
    mask: var(--aph-icon) center / contain no-repeat;
}

#header.apHeader .aphFeatureText {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    padding-top: 1px;
}

#header.apHeader .aphFeatureName {
    color: var(--aph-ink);
    font-size: 15px;
    font-weight: 600;
    line-height: 1.35;
}

#header.apHeader .aphFeatureDesc {
    color: var(--aph-ink-soft);
    font-size: 13.5px;
    line-height: 1.45;
}

#header.apHeader .aphFeature:hover .aphFeatureName,
#header.apHeader .aphFeature[aria-current="page"] .aphFeatureName {
    color: var(--aph-accent);
}

#header.apHeader .aphFeature[aria-current="page"] {
    background: #f4f9fb;
}

#header.apHeader .aphMegaFoot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 24px;
    padding: 14px 42px;
    border-top: 1px solid var(--aph-line);
    background:
        radial-gradient(600px 200px at 0% 0%, rgba(69, 208, 239, 0.1), transparent 70%),
        linear-gradient(90deg, #f6fafb 0%, #fbf8f3 100%);
}

#header.apHeader .aphMore {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 0;
    color: var(--aph-accent);
    font-size: 15px;
    font-weight: 600;
}

#header.apHeader .aphMore svg {
    transition: transform .2s ease;
}

#header.apHeader .aphMore:hover svg {
    transform: translateX(3px);
}

/* ---------- Resources dropdown ---------- */

#header.apHeader .aphDrop {
    left: 0;
    min-width: 230px;
    margin-top: 8px;
    padding: 8px;
    border: 1px solid var(--aph-line);
    border-radius: 14px;
    background: #ffffff;
    box-shadow: 0 20px 40px -22px rgba(20, 35, 45, 0.35);
}

#header.apHeader .aphDrop::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 0;
    right: 0;
    height: 10px;
}

#header.apHeader .aphDropLink {
    display: block;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--aph-ink);
    font-size: 15px;
    font-weight: 500;
}

#header.apHeader .aphDropLink:hover,
#header.apHeader .aphDropLink[aria-current="page"] {
    background: #f4f9fb;
    color: var(--aph-accent);
}

/* ---------- Menu button (tablet / phone) ---------- */

#header.apHeader .aphToggle {
    display: none;
    align-items: center;
    gap: 8px;
    height: 44px;
    padding: 0 12px;
    border: 1px solid var(--aph-line);
    border-radius: 999px;
    background: #ffffff;
    color: var(--aph-ink);
    font-size: 14px;
    font-weight: 600;
}

#header.apHeader .aphToggleBars {
    position: relative;
    width: 18px;
    height: 12px;
}

#header.apHeader .aphToggleBars::before,
#header.apHeader .aphToggleBars::after,
#header.apHeader .aphToggleBars span {
    content: '';
    position: absolute;
    left: 0;
    width: 18px;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
    transition: transform .2s ease, opacity .2s ease, top .2s ease;
}

#header.apHeader .aphToggleBars::before { top: 0; }
#header.apHeader .aphToggleBars span    { top: 5px; }
#header.apHeader .aphToggleBars::after  { top: 10px; }

#header.apHeader .aphToggle[aria-expanded="true"] .aphToggleBars::before { top: 5px; transform: rotate(45deg); }
#header.apHeader .aphToggle[aria-expanded="true"] .aphToggleBars span    { opacity: 0; }
#header.apHeader .aphToggle[aria-expanded="true"] .aphToggleBars::after  { top: 5px; transform: rotate(-45deg); }

/* ---------- Drawer (tablet / phone) ---------- */

#header.apHeader .aphDrawer {
    position: fixed;
    top: var(--aph-height);
    left: 0;
    right: 0;
    bottom: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 12px 20px 32px;
    background: #ffffff;
}

#header.apHeader .aphDrawerMenu > li {
    border-bottom: 1px solid var(--aph-line);
}

#header.apHeader .aphAccBtn,
#header.apHeader .aphDrawerLink {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 54px;
    padding: 0 4px;
    border: 0;
    background: transparent;
    color: var(--aph-ink);
    font-size: 17px;
    font-weight: 600;
    text-align: left;
}

#header.apHeader .aphAccBtn[aria-expanded="true"],
#header.apHeader .aphDrawerLink[aria-current="page"] {
    color: var(--aph-accent);
}

#header.apHeader .aphAccPanel {
    padding: 4px 0 16px;
}

#header.apHeader .aphAccPanel .aphGroupTitle {
    margin-top: 12px;
    padding: 0 4px;
}

#header.apHeader .aphDrawerFeatures {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 2px 12px;
}

#header.apHeader .aphDrawerFeature {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 48px;
    padding: 4px;
    border-radius: 10px;
    color: var(--aph-ink);
    font-size: 15px;
    font-weight: 500;
    line-height: 1.3;
}

#header.apHeader .aphDrawerFeature .aphFeatureIcon {
    width: 34px;
    height: 34px;
    border-radius: 9px;
}

#header.apHeader .aphDrawerFeature .aphFeatureIcon::after {
    inset: 8px;
}

#header.apHeader .aphDrawerFeature[aria-current="page"],
#header.apHeader .aphDrawerFeature:hover {
    background: #f4f9fb;
    color: var(--aph-accent);
}

#header.apHeader .aphAccPanel .aphMore {
    margin: 8px 4px 0;
}

#header.apHeader .aphDrawerSubLink {
    display: flex;
    align-items: center;
    min-height: 46px;
    padding: 0 4px 0 16px;
    color: var(--aph-ink);
    font-size: 16px;
    font-weight: 500;
}

#header.apHeader .aphDrawerSubLink[aria-current="page"],
#header.apHeader .aphDrawerSubLink:hover {
    color: var(--aph-accent);
}

#header.apHeader .aphDrawerNote {
    margin-top: 20px;
    color: var(--aph-ink-soft);
    font-size: 14px;
    text-align: center;
}

#header.apHeader .aphDrawerNote a {
    color: var(--aph-accent);
    font-weight: 600;
}

/* ---------- Keyboard focus ---------- */

#header.apHeader a:focus-visible,
#header.apHeader button:focus-visible {
    outline: 2px solid var(--aph-accent);
    outline-offset: 2px;
}

#header.apHeader .aphBtn:focus-visible,
#header.apHeader .aphToggle:focus-visible {
    outline-offset: 3px;
}

/* Menu button shows only the icon; "Menu" / "Close" is for screen readers */
#header.apHeader .aphToggleLabel {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

/* ---------- Medium desktop ---------- */

@media (max-width: 1366px) {
    #header.apHeader .aphBtn {
        padding: 10px 17px;
        line-height: 24px;
    }
}

@media (max-width: 1279px) {
    #header.apHeader .aphWrap {
        gap: 16px;
        padding-left: 24px;
        padding-right: 24px;
    }

    #header.apHeader .aphLogo img {
        width: 170px;
    }

    #header.apHeader .aphTop {
        padding: 0 10px;
    }

    #header.apHeader .aphMegaInner {
        padding: 24px 24px 16px;
    }

    #header.apHeader .aphMegaFoot {
        padding: 12px 34px;
    }
}

/* ---------- Tablet and phone: menu button + drawer ---------- */

@media (max-width: 1099px) {
    #header.apHeader {
        --aph-height: 64px;
    }

    #header.apHeader .aphNav {
        display: none;
    }

    #header.apHeader .aphNav + .aphActions {
        margin-left: auto;
    }

    #header.apHeader .aphToggle {
        display: inline-flex;
        width: 44px;
        padding: 0;
        justify-content: center;
    }

    #header.apHeader .aphBtn {
        padding: 10px 20px;
        line-height: 15px;
    }
}

@media (min-width: 1100px) {
    #header.apHeader .aphDrawer {
        display: none !important;
    }
}

/* Old header sizes: larger buttons on tablets */
@media (min-width: 768px) and (max-width: 991px) {
    #header.apHeader .aphLogo img {
        width: 150px;
    }

    #header.apHeader .aphActions {
        gap: 8px;
    }

    #header.apHeader .aphBtn {
        padding: 10px 22px;
        font-size: 16px;
        line-height: 25px;
    }
}

/* Old header sizes: compact buttons on phones */
@media (max-width: 767px) {
    #header.apHeader .aphWrap {
        gap: 8px;
        padding-left: 16px;
        padding-right: 16px;
    }

    #header.apHeader .aphLogo img {
        width: 150px;
    }

    #header.apHeader .aphActions {
        gap: 6px;
    }

    #header.apHeader .aphBtn {
        min-height: 34px;
        padding: 5px 10px;
        border-radius: 14px;
        font-size: 10px;
        line-height: 20px;
    }

    #header.apHeader .aphBtnDemo {
        min-width: 60px;
        padding: 5px 11px;
    }

    #header.apHeader .aphBtnLogin {
        min-width: 64px;
        padding: 5px 9px;
    }
}

/* As before: AP Payments hides and "Get the Demo" becomes "Demo" */
@media (max-width: 480px) {
    #header.apHeader .aphBtnPayments,
    #header.apHeader .aphBtnLong {
        display: none;
    }
}

@media (max-width: 400px) {
    #header.apHeader .aphLogo img {
        width: 128px;
    }
}

@media (max-width: 360px) {
    #header.apHeader .aphLogo img {
        width: 112px;
    }
}

@media (max-width: 379px) {
    #header.apHeader .aphDrawerFeatures {
        grid-template-columns: 1fr;
    }
}

@media (prefers-reduced-motion: reduce) {
    #header.apHeader *,
    #header.apHeader *::before,
    #header.apHeader *::after {
        transition: none !important;
    }

    #header.apHeader .aphBtnDemo::before {
        animation: none;
    }
}
