/*
 * Header and footer for the crowdfunding theme.
 *
 * Loaded on every page, unlike crowdfunding-home.css which is homepage-only.
 * Colour comes from the same tokens as the rest of the theme, so the accent
 * follows color.php and a HYIPLAB skin never loads any of this.
 */

/* ============================== Top utility bar ========================== */

.cfx-topbar {
    background: hsl(var(--base-two));
    color: hsl(var(--white) / 0.72);
    font-size: 0.8rem;
}

.cfx-topbar__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding-block: 0.55rem;
}

.cfx-topbar__list {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex-wrap: wrap;
    list-style: none;
    margin: 0;
    padding: 0;
}

.cfx-topbar a {
    color: hsl(var(--white) / 0.72);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: color 0.18s ease;
}

.cfx-topbar a:hover { color: hsl(var(--white)); }
.cfx-topbar i { color: hsl(var(--base-l-200)); }

.cfx-topbar__social {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.cfx-topbar__social a {
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    background: hsl(var(--white) / 0.1);
    justify-content: center;
}

.cfx-topbar__social a:hover { background: hsl(var(--base)); }

@media (max-width: 767.98px) {
    /* The contact strip is the first thing to go; the nav below matters more. */
    .cfx-topbar { display: none; }
}

/* ================================= Header ================================ */

.cfx-header {
    position: sticky;
    top: 0;
    z-index: 1030;
    background: hsl(var(--white));
    border-bottom: 1px solid hsl(var(--border-color));
}

.cfx-header__inner {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-block: 0.85rem;
}

.cfx-header__logo img {
    max-height: 42px;
    width: auto;
}

.cfx-nav {
    display: none;
    align-items: center;
    gap: 0.25rem;
    list-style: none;
    margin: 0 auto 0 1.5rem;
    padding: 0;
}

@media (min-width: 1200px) { .cfx-nav { display: flex; } }

.cfx-nav__link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.6rem 0.85rem;
    border-radius: 8px;
    font-size: 0.93rem;
    font-weight: 500;
    color: hsl(var(--heading-color));
    text-decoration: none;
    white-space: nowrap;
    transition: color 0.18s ease, background-color 0.18s ease;
}

.cfx-nav__link:hover,
.cfx-nav__item--on > .cfx-nav__link {
    color: hsl(var(--base));
    background: hsl(var(--base) / 0.07);
}

.cfx-nav__item { position: relative; }

/* ---- Dropdown ---- */

.cfx-drop {
    position: absolute;
    top: calc(100% + 0.4rem);
    left: 0;
    min-width: 15rem;
    background: hsl(var(--white));
    border: 1px solid hsl(var(--border-color));
    border-radius: 12px;
    box-shadow: 0 12px 32px hsl(var(--black) / 0.09);
    padding: 0.45rem;
    list-style: none;
    margin: 0;

    opacity: 0;
    visibility: hidden;
    transform: translateY(6px);
    transition: opacity 0.16s ease, transform 0.16s ease, visibility 0.16s;
}

.cfx-nav__item:hover > .cfx-drop,
.cfx-nav__item:focus-within > .cfx-drop {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.cfx-drop a {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    font-size: 0.9rem;
    color: hsl(var(--heading-color));
    text-decoration: none;
}

.cfx-drop a:hover {
    background: hsl(var(--base) / 0.08);
    color: hsl(var(--base));
}

.cfx-drop i { color: hsl(var(--base)); width: 1.1rem; text-align: center; }

.cfx-header__actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-left: auto;
}

@media (min-width: 1200px) { .cfx-header__actions { margin-left: 0; } }

.cfx-header__signin {
    display: none;
    font-size: 0.92rem;
    font-weight: 600;
    color: hsl(var(--heading-color));
    text-decoration: none;
    padding: 0.5rem 0.35rem;
}

@media (min-width: 576px) { .cfx-header__signin { display: inline-flex; } }
.cfx-header__signin:hover { color: hsl(var(--base)); }

.cfx-header__cta { display: none; }
@media (min-width: 768px) { .cfx-header__cta { display: inline-flex; } }

.cfx-burger {
    display: inline-grid;
    place-items: center;
    width: 2.6rem;
    height: 2.6rem;
    border-radius: 10px;
    border: 1px solid hsl(var(--border-color));
    background: hsl(var(--white));
    color: hsl(var(--heading-color));
    font-size: 1.2rem;
    cursor: pointer;
}

@media (min-width: 1200px) { .cfx-burger { display: none; } }
.cfx-burger:hover { border-color: hsl(var(--base)); color: hsl(var(--base)); }

/* ---- Offcanvas ---- */

.cfx-canvas { background: hsl(var(--white)); }

.cfx-canvas .offcanvas-header {
    border-bottom: 1px solid hsl(var(--border-color));
}

.cfx-canvas__list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.cfx-canvas__list a {
    display: block;
    padding: 0.8rem 0.25rem;
    color: hsl(var(--heading-color));
    text-decoration: none;
    font-weight: 500;
    border-bottom: 1px solid hsl(var(--border-color) / 0.6);
}

.cfx-canvas__list a:hover { color: hsl(var(--base)); }

.cfx-canvas__group {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: hsl(var(--base));
    padding-top: 1.1rem;
    padding-bottom: 0.35rem;
}

/* ================================= Footer ================================ */

.cfx-footer {
    background: hsl(var(--base-two));
    color: hsl(var(--white) / 0.68);
    padding-block: clamp(3rem, 6vw, 4.5rem) 0;
}

.cfx-footer__grid {
    display: grid;
    gap: clamp(1.75rem, 4vw, 3rem);
    grid-template-columns: 1fr;
}

@media (min-width: 576px) { .cfx-footer__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

@media (min-width: 992px) {
    /*
     | Flex, not grid, because the number of columns is not fixed: Contact
     | renders only when the site has contact details, and Account's contents
     | differ for a guest.
     |
     | repeat(auto-fit, ...) was tried first and got it wrong — mixed with a
     | leading 1.6fr brand track it created five slots regardless, leaving
     | Account stranded on a second row underneath the brand text. Flex sizes
     | from the items that actually exist, so a column added or removed
     | redistributes instead of orphaning one.
     */
    .cfx-footer__grid {
        display: flex;
        flex-wrap: wrap;
    }

    /*
     | The bases have to add up. With six link columns the previous figures
     | (15rem + 6 × 8.5rem, plus six 3rem gaps) came to roughly 1344px inside a
     | 1320px container — over by about 24px, which is all it takes for the
     | last column to wrap and strand Account on its own row. These leave room:
     | 13 + 6 × 7.5 = 58rem of basis against 82.5rem of container.
     */
    .cfx-footer__brand { flex: 1 1 13rem; max-width: 24rem; }

    .cfx-footer__grid > .cfx-footer__col--fold { flex: 1 1 7.5rem; min-width: 0; }

    /*
     | Contact takes roughly two columns' worth. It holds an address and an
     | email; at a link column's width the address stacked onto three lines and
     | the email broke mid-word into "demo@exampl / e.com".
     */
    .cfx-footer__grid > .cfx-footer__col--wide { flex: 1.9 1 11rem; }

    /* A tighter gap here buys each column back about 16px of usable width. */
    .cfx-footer__grid { gap: 1.75rem 2rem; }
}

.cfx-footer__brand img { max-height: 44px; width: auto; margin-bottom: 1.1rem; }

.cfx-footer__about {
    font-size: 0.9rem;
    line-height: 1.7;
    max-width: 38ch;
    margin-bottom: 1.35rem;
}

.cfx-footer__title {
    font-family: var(--heading-font);
    font-size: 0.95rem;
    color: hsl(var(--white));
    margin: 0 0 1rem;
}

.cfx-footer__links {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.6rem;
}

.cfx-footer__links a {
    color: hsl(var(--white) / 0.68);
    text-decoration: none;
    font-size: 0.88rem;
    transition: color 0.18s ease, padding-left 0.18s ease;
}

.cfx-footer__links a:hover {
    color: hsl(var(--base-l-200));
    padding-left: 4px;
}

.cfx-social {
    display: flex;
    gap: 0.5rem;
    list-style: none;
    margin: 0;
    padding: 0;
    flex-wrap: wrap;
}

.cfx-social a {
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: hsl(var(--white) / 0.09);
    color: hsl(var(--white));
    text-decoration: none;
    transition: background-color 0.18s ease;
}

.cfx-social a:hover { background: hsl(var(--base)); }

.cfx-footer__bottom {
    margin-top: clamp(2.25rem, 5vw, 3.25rem);
    border-top: 1px solid hsl(var(--white) / 0.1);
    padding-block: 1.35rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    font-size: 0.83rem;
}

.cfx-footer__bottom a { color: hsl(var(--white) / 0.68); text-decoration: none; }
.cfx-footer__bottom a:hover { color: hsl(var(--white)); }

/*
 | On phones each footer column becomes a disclosure, so the footer is a few
 | taps rather than several screens of scrolling. The brand column is never
 | collapsed -- it is the one thing worth seeing without opening anything.
 */
@media (max-width: 575.98px) {
    .cfx-footer__col--fold .cfx-footer__title {
        display: flex;
        align-items: center;
        justify-content: space-between;
        cursor: pointer;
        list-style: none;
        margin-bottom: 0;
        padding-block: 0.75rem;
        border-bottom: 1px solid hsl(var(--white) / 0.1);
    }

    .cfx-footer__col--fold .cfx-footer__title::-webkit-details-marker { display: none; }
    .cfx-footer__col--fold .cfx-footer__title::after {
        content: "\f107";
        font-family: "Line Awesome Free";
        font-weight: 900;
        transition: transform 0.2s ease;
    }

    .cfx-footer__col--fold[open] .cfx-footer__title::after { transform: rotate(180deg); }
    .cfx-footer__col--fold .cfx-footer__links { padding-block: 0.85rem; }
}

@media (min-width: 576px) {
    /* Above phones the disclosure is inert: always open, never clickable. */
    .cfx-footer__col--fold .cfx-footer__title { pointer-events: none; }
}

.cfx-footer, .cfx-header, .cfx-topbar { overflow-x: clip; }

/* ===================== Footer: wave, newsletter, contact ================== */

/*
 | The §4.3 additions. All three collapse rather than reserve space: the
 | newsletter's message line is hidden while empty, and the contact column is
 | not rendered at all unless the site actually has contact details set.
 */

/* --------------------------------- Wave ---------------------------------- */

/*
 | The footer needs to be a positioning context and to sit above nothing, so
 | the wave can hang off its top edge without adding scroll.
 */
.cfx-footer {
    position: relative;
}

.cfx-footer__wave {
    position: absolute;
    left: 0;
    right: 0;
    /* Sits directly on top of the footer, overlapping the section above it. */
    bottom: 100%;
    line-height: 0;
    pointer-events: none;
    /* Never a source of horizontal scroll on a narrow screen. */
    overflow: hidden;
}

.cfx-footer__wave svg {
    display: block;
    width: 100%;
    /* Shorter on phones, where a tall curve eats the screen. */
    height: clamp(2.5rem, 6vw, 5.5rem);
}

/*
 | Filled from the footer's own background token, so the curve and the footer
 | are the same colour by construction and cannot drift apart when the site
 | accent changes.
 */
.cfx-footer__wave path {
    fill: hsl(var(--base-two));
}

/* ------------------------------ Newsletter ------------------------------- */

.cfx-news {
    display: grid;
    grid-template-columns: 1fr;
    gap: clamp(1.25rem, 3vw, 2.5rem);
    align-items: center;
    padding-bottom: clamp(2rem, 4vw, 3rem);
    margin-bottom: clamp(2rem, 4vw, 3rem);
    border-bottom: 1px solid hsl(var(--white) / 0.12);
}

@media (min-width: 992px) {
    .cfx-news { grid-template-columns: minmax(0, 1fr) minmax(20rem, 0.9fr); }
}

/*
 | The copy half of the newsletter row. min-width: 0 because it is a grid item
 | and would otherwise be sized by its longest unbreakable word, squeezing the
 | form beside it.
 */
.cfx-news__copy { min-width: 0; }

.cfx-news__title {
    margin: 0 0 0.4rem;
    font-family: var(--heading-font);
    font-size: clamp(1.25rem, 2.5vw, 1.75rem);
    line-height: 1.2;
    color: hsl(var(--white));
    text-wrap: balance;
}

.cfx-news__sub {
    margin: 0;
    font-size: 0.925rem;
    line-height: 1.6;
    color: hsl(var(--white) / 0.7);
    max-width: 52ch;
}

/* Visible label rather than a placeholder alone, which vanishes on focus. */
.cfx-news__label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: hsl(var(--white) / 0.6);
}

.cfx-news__row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.cfx-news__input {
    flex: 1 1 12rem;
    min-width: 0;
    padding: 0.75rem 1rem;
    border-radius: 999px;
    border: 1px solid hsl(var(--white) / 0.18);
    background: hsl(var(--white) / 0.06);
    color: hsl(var(--white));
    font-size: 0.95rem;
}

.cfx-news__input::placeholder { color: hsl(var(--white) / 0.45); }

.cfx-news__input:focus {
    outline: none;
    border-color: hsl(var(--base));
    background: hsl(var(--white) / 0.1);
}

.cfx-news__form button[disabled] { opacity: 0.7; cursor: progress; }

/*
 | The result line. Empty until the form has been used, and collapsed while
 | empty so it holds no space open under the field.
 */
.cfx-news__msg {
    margin: 0.6rem 0 0;
    font-size: 0.85rem;
    line-height: 1.5;
}

.cfx-news__msg:empty { display: none; }

.cfx-news__msg.is-ok  { color: hsl(var(--base-l-200, var(--base))); }
.cfx-news__msg.is-bad { color: hsl(var(--danger)); }

/* -------------------------------- Contact -------------------------------- */

/*
 | The contact list itself. Its rows are two lines tall where a link list's are
 | one, so they need more breathing room than cfx-footer__links gives.
 */
.cfx-contact { display: flex; flex-direction: column; gap: 0.85rem; }

.cfx-contact__item {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    line-height: 1.55;
}

.cfx-contact__item .cfx-contact__icon {
    color: hsl(var(--base));
    flex-shrink: 0;
    margin-top: 0.2rem;
}

/* A long address wraps; an email never splits mid-word into nonsense. */
/*
 | break-word, not anywhere. `anywhere` broke a long email at whatever
 | character hit the edge -- "demo@example.co" then a lone "m" on the next
 | line. break-word only splits a word that genuinely cannot fit, so an
 | address wraps at its natural end and a long one still does not overflow.
 */
.cfx-contact__item span,
.cfx-contact__item a { overflow-wrap: break-word; }
