/*
 * Launch polish: focus visibility, touch targets and the catalogue cross-link.
 * Loaded last so it can settle inconsistencies without editing every component
 * stylesheet. No layout or colour decisions are changed here.
 */

/* ------------------------------------------------------ overflow guard ---
 * Several entrance animations are `fade-left`, which starts the element
 * translated to the right of its final position. With overflow-x visible on the
 * root, that transform can push a transient horizontal scrollbar on narrow
 * viewports before the animation settles.
 *
 * `clip` rather than `hidden`: hidden would make the root a scroll container and
 * break position:sticky. clip contains the paint without that side effect, and
 * only ever suppresses overflow that is already a bug.
 */
html {
    overflow-x: clip;
}

/* ---------------------------------------------------------------- focus ---
 * Focus rings were defined ad hoc on a few components, so keyboard users lost
 * the indicator entirely on most CTAs. One rule, applied consistently, using
 * :focus-visible so pointer users never see it.
 */
.v2-button:focus-visible,
.af-button:focus-visible,
.af-footer-links a:focus-visible,
.af-site-nav .nav-link:focus-visible,
.af-site-nav .dropdown-item:focus-visible,
.af-skip-link:focus-visible,
.v2-shop-card a:focus-visible,
.af-leader-card a:focus-visible,
.af-catalog-switch a:focus-visible {
    outline: 3px solid var(--aleafiaa-blue, #2a3484);
    outline-offset: 3px;
    border-radius: .35rem;
}

/* On saturated backgrounds the blue ring disappears; invert it there. */
.v2-button-light:focus-visible,
.af-footer a:focus-visible {
    outline-color: #fff;
}

/* Bootstrap's default focus shadow fights the outline above. */
.af-site-nav .nav-link:focus,
.af-site-nav .dropdown-item:focus,
.navbar-toggler:focus {
    box-shadow: none;
}

/* ------------------------------------------------------------ nav menus ---
 * The Products menu carries two destinations that are easy to confuse, so each
 * item states what it is rather than relying on the label alone.
 */
.af-menu-title {
    display: block;
    font-weight: 700;
    line-height: 1.3;
}

.af-menu-hint {
    color: var(--v2-muted, #5c6675);
    display: block;
    font-size: .78rem;
    font-weight: 500;
    line-height: 1.35;
    margin-top: .1rem;
}

.af-site-nav .dropdown-item:hover .af-menu-hint,
.af-site-nav .dropdown-item:focus .af-menu-hint {
    color: inherit;
}

.af-site-nav .dropdown-menu {
    min-width: 16rem;
}

/* Comfortable tap targets on touch devices. */
@media (hover: none) and (pointer: coarse) {
    .af-site-nav .nav-link,
    .af-site-nav .dropdown-item {
        min-height: 44px;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }
}

/* ----------------------------------------------------- catalogue switch ---
 * Reciprocal link between the two catalogues. The distinction between what is
 * purchasable and what is prescription-only matters, so the panel explains it
 * rather than offering a bare link.
 */
.af-catalog-switch {
    align-items: center;
    background: #fff;
    border: 1px solid var(--v2-line, #e0e6ef);
    border-radius: 20px;
    box-shadow: 0 10px 28px rgba(24, 46, 90, .07);
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    justify-content: space-between;
    margin-top: 3rem;
    padding: 1.5rem 1.65rem;
}

.af-catalog-switch > div {
    flex: 1 1 20rem;
    min-width: 0;
}

.af-catalog-switch-eyebrow {
    color: var(--v2-ink, #182e5a);
    font-size: 1.02rem;
    font-weight: 800;
    letter-spacing: -.02em;
    margin: 0 0 .35rem;
}

.af-catalog-switch-copy {
    color: var(--v2-muted, #5c6675);
    font-size: .88rem;
    line-height: 1.55;
    margin: 0;
    max-width: 58ch;
}

.af-catalog-switch .v2-button {
    flex: 0 0 auto;
}

@media (max-width: 575.98px) {
    .af-catalog-switch {
        margin-top: 2.25rem;
        padding: 1.25rem;
    }

    .af-catalog-switch .v2-button {
        width: 100%;
    }
}

/* ------------------------------------------------- unified product cards ---
 * One grid holds two kinds of product. The channel has to read at a glance,
 * because confusing a purchasable supplement with a prescription formulation is
 * the one mistake this page must not invite.
 */
.v2-shop-card-image {
    position: relative;
}

.af-product-badge {
    backdrop-filter: saturate(180%) blur(6px);
    border-radius: 999px;
    font-size: .68rem;
    font-weight: 850;
    left: .85rem;
    letter-spacing: .04em;
    padding: .3rem .6rem;
    position: absolute;
    text-transform: uppercase;
    top: .85rem;
}

.af-product-badge-nutraceutical {
    background: rgba(12, 112, 91, .12);
    color: #0a5b4a;
}

.af-product-badge-pharmaceutical {
    background: rgba(42, 52, 132, .12);
    color: var(--aleafiaa-blue, #2a3484);
}

/* Prescription products replace the price block, so the two card types keep
   the same vertical rhythm and the grid rows stay aligned. */
.af-product-rx {
    align-items: center;
    color: var(--aleafiaa-blue, #2a3484);
    display: flex;
    font-size: 1rem;
    font-weight: 850;
    gap: .45rem;
    margin: 0;
}

.af-product-rx-note {
    color: var(--v2-muted, #5c6675);
    font-size: .78rem;
    font-weight: 650;
    margin: .3rem 0 0;
}

.af-filter-count {
    font-size: .74rem;
    font-weight: 700;
    opacity: .6;
    margin-left: .3rem;
}

.v2-filter-list a[aria-current="page"] .af-filter-count {
    opacity: .85;
}

.af-catalog-note {
    background: #f4f7fd;
}

/* ------------------------------------------------------- corporate page ---
 * Long regulatory copy contains tables and unbroken chemical names, either of
 * which can push a narrow viewport into horizontal scroll.
 */
.af-product-body table {
    display: block;
    overflow-x: auto;
    width: 100%;
}

.af-product-body :is(p, li, h2, h3, h4) {
    overflow-wrap: break-word;
}

/* --------------------------------------------------- reduced motion ------
 * The hover lift and menu transitions are decorative; honour the preference
 * without disabling the focus ring, which is an accessibility affordance.
 */
@media (prefers-reduced-motion: reduce) {
    .v2-button,
    .af-button,
    .v2-shop-card,
    .af-leader-card,
    .af-catalog-switch {
        transition: none !important;
    }

    .v2-button:hover,
    .af-button:hover,
    .v2-shop-card:hover {
        transform: none !important;
    }
}
