/* ==========================================================================
   Layout: site header, page header, sections, call to action and site footer.
   ========================================================================== */

/* Site header
   ========================================================================== */

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

.site-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    height: var(--header-height);
}

.site-logo img {
    display: block;
    width: auto;
    height: 34px;
}

/* On desktop the menu and the buttons sit directly in the header row.
   On mobile this wrapper becomes the drop-down panel (see below). */
.site-nav {
    display: contents;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Main menu
   ========================================================================== */

.main-menu,
.main-menu .sub-menu {
    margin: 0;
    padding: 0;
    list-style: none;
}

.main-menu {
    display: flex;
    align-items: center;
    gap: 2px;
}

.main-menu > li {
    position: relative;
}

.main-menu > li > a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: var(--radius-pill);
    color: var(--color-deep-blue);
    font-size: 17px;
    font-weight: 500;
}

.main-menu > li > a:hover,
.main-menu > li.open > a,
.main-menu > li:hover > a {
    background: var(--color-magnolia);
}

/* The small arrow beside a menu item that has a drop-down */
.main-menu > .menu-item-has-children > a::after {
    content: "";
    width: 8px;
    height: 8px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg) translateY(-2px);
    transition: transform .15s;
}

.main-menu > .menu-item-has-children.open > a::after,
.main-menu > .menu-item-has-children:hover > a::after {
    transform: rotate(225deg) translateY(-2px);
}

/* Drop-down panel */
.main-menu .sub-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 60;
    flex-direction: column;
    gap: 2px;
    min-width: 300px;
    margin-top: 10px;
    padding: 16px;
    border: 1px solid var(--color-grey);
    border-radius: var(--radius-medium);
    background: var(--color-white);
    box-shadow: var(--shadow-panel);
}

/* Keeps the drop-down open while the pointer crosses the gap below the menu item */
.main-menu > .menu-item-has-children::after {
    content: "";
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    height: 14px;
}

.main-menu > li.open > .sub-menu,
.main-menu > li:hover > .sub-menu,
.main-menu > li:focus-within > .sub-menu {
    display: flex;
}

.main-menu .sub-menu a {
    display: block;
    padding: 9px 12px;
    border-radius: var(--radius-small);
    color: var(--color-deep-blue);
    font-size: 16px;
    font-weight: 500;
}

.main-menu .sub-menu a:hover {
    background: var(--color-magnolia);
}

/* Give a menu item the CSS class "menu-view-all" for a "View all" link */
.main-menu .sub-menu .menu-view-all {
    margin-top: 6px;
    border-top: 1px solid var(--color-grey);
}

.main-menu .sub-menu .menu-view-all a {
    padding-top: 12px;
    border-radius: 0;
    color: var(--color-funding-blue);
}

/* Mobile menu button */
.menu-toggle {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    border: 0;
    background: none;
    cursor: pointer;
}

.menu-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    border-radius: 2px;
    background: var(--color-deep-blue);
}

/* Page header
   ========================================================================== */

.page-header {
    position: relative;
    overflow: hidden;
    padding: var(--section-space) 0;
    background: var(--color-magnolia);
}

.page-header-inner {
    position: relative;
}

.page-header-inner.has-media {
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    gap: 56px;
    align-items: center;
}

.page-header-media {
    position: relative;
}

.page-header-centred .page-header-copy {
    max-width: 720px;
    margin: 0 auto;
    text-align: center;
}

.page-header.page-header-centred h1 {
    max-width: none;
}

.page-header-centred .lead {
    margin-right: auto;
    margin-left: auto;
}

/* Statement page header: text only, in one wide column */
.page-header-statement .page-header-copy {
    max-width: 820px;
}

.page-header.page-header-statement h1 {
    max-width: none;
}

.page-header-statement .lead {
    max-width: 56ch;
}

.page-header-statement .motion-line-top-right {
    top: -200px;
    right: -240px;
    width: 900px;
}

/* Tiles and a caption beneath a centred page header */
.page-header-tiles {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin: 48px 0 0;
    padding: 0;
    list-style: none;
}

.page-header-tiles li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 20px;
    border-radius: var(--radius-medium);
    background: var(--color-white);
    box-shadow: 0 8px 24px rgba(14, 27, 100, .06);
    font-size: 16px;
    font-weight: 600;
}

.page-header-tiles strong {
    font-weight: 600;
}

.tile-icon {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--color-lavender-pale);
    --icon-accent: var(--color-lavender);
}

/* On a Magnolia Blue or lighter header the tile colours repeat in fours: lavender, salmon, pistachio, pink */
.page-header:not(.theme-white, .theme-dark) .page-header-tiles li:nth-child(4n+2) .tile-icon { background: var(--color-salmon-pale); --icon-accent: var(--color-salmon); }
.page-header:not(.theme-white, .theme-dark) .page-header-tiles li:nth-child(4n+3) .tile-icon { background: var(--color-pistachio-pale); --icon-accent: var(--color-pistachio); }
.page-header:not(.theme-white, .theme-dark) .page-header-tiles li:nth-child(4n) .tile-icon { background: var(--color-pink-pale); --icon-accent: var(--color-pink); }

.tile-icon .icon {
    width: 22px;
    height: 22px;
}

/* On a dark header the tiles are larger translucent cards, three across,
   each with a small note and a status label */
.theme-dark .page-header-tiles {
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-top: 56px;
}

.theme-dark .page-header-tiles li {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 24px 26px;
    border: 1px solid rgba(255, 255, 255, .14);
    border-radius: 20px;
    background: rgba(255, 255, 255, .08);
    box-shadow: none;
}

.theme-dark .tile-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 10px;
    background: var(--color-white);
    --icon-accent: var(--color-funding-blue);
}

.theme-dark .tile-icon .icon {
    width: 24px;
    height: 24px;
}

.theme-dark .page-header-tiles strong {
    font-size: 20px;
}

.tile-note {
    color: rgba(255, 255, 255, .7);
    font-size: var(--text-x-small);
    font-weight: 400;
}

.tile-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 14px;
    padding: 6px 12px;
    border-radius: var(--radius-pill);
    background: var(--color-pistachio-pale);
    color: var(--color-deep-blue);
    font-size: 13px;
    font-style: normal;
    font-weight: 600;
    --icon-accent: var(--color-pistachio);
}

.tile-status .icon {
    width: 14px;
    height: 14px;
}

.page-header-caption {
    margin-top: 22px;
    color: var(--color-text-muted);
    font-size: var(--text-small);
    text-align: center;
}

.page-header-centred .buttons,
.page-header-centred .trust-list {
    justify-content: center;
}

/* White page header */
.page-header.theme-white {
    border-bottom: 1px solid var(--color-grey);
    background: var(--color-white);
    --icon-accent: var(--color-funding-blue);
}

.theme-white .motion-line {
    opacity: .08;
}

/* The lighter page headers: the same pale backgrounds a Section can have.
   The motion lines and the icons take the colour the background is a tint of. */
.page-header.theme-grey {
    background: var(--color-grey);
    --motion-line-color: var(--color-deep-blue);
    --icon-accent: var(--color-funding-blue);
}

.page-header.theme-lavender {
    background: var(--color-lavender-pale);
    --motion-line-color: var(--color-lavender);
    --icon-accent: var(--color-lavender);
}

.page-header.theme-salmon {
    background: var(--color-salmon-pale);
    --motion-line-color: var(--color-salmon);
    --icon-accent: var(--color-salmon);
}

.page-header.theme-pistachio {
    background: var(--color-pistachio-pale);
    --motion-line-color: var(--color-pistachio);
    --icon-accent: var(--color-pistachio);
}

.page-header.theme-pink {
    background: var(--color-pink-pale);
    --motion-line-color: var(--color-pink);
    --icon-accent: var(--color-pink);
}

/* Dark page header */
.page-header.theme-dark {
    background: var(--color-deep-blue);
    color: var(--color-white);
}

.theme-dark .eyebrow {
    color: var(--color-sky);
}

.theme-dark .lead {
    color: rgba(255, 255, 255, .8);
}

.theme-dark .page-header-media {
    padding: 28px 0;
}

/* Trust line: small icon-and-text items under the introduction */
.trust-list {
    display: flex;
    flex-wrap: wrap;
    gap: 22px;
    margin: 24px 0 0;
    padding: 0;
    list-style: none;
}

.trust-list li {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 600;
}

.trust-list .icon {
    width: 18px;
    height: 18px;
}

.theme-dark .trust-list li {
    color: var(--color-white);
}

.trust-list .icon {
    --icon-accent: var(--color-sky);
}

.theme-dark .trust-list .icon {
    color: var(--color-white);
}

/* A single trust item is shown larger, as the page's key point */
.trust-list li:only-child {
    gap: 12px;
    font-size: 21px;
    font-weight: 600;
}

.trust-list li:only-child .icon {
    width: 26px;
    height: 26px;
    color: var(--color-funding-blue);
}

.trust-list + .buttons {
    margin-top: 24px;
}

/* Motion lines: the decorative brand lines behind page headers and calls to action.
   A line is Funding Blue at one tenth strength unless its background sets --motion-line-color. */
.motion-line {
    position: absolute;
    max-width: none;
    height: auto;
    opacity: .1;
    pointer-events: none;
}

.motion-line path {
    stroke: var(--motion-line-color, var(--color-funding-blue));
}

.page-header .motion-line-top-right {
    top: -60px;
    right: -180px;
    width: 820px;
}

.page-header .motion-line-bottom-left {
    bottom: -160px;
    left: -160px;
    width: 560px;
}

.theme-dark .motion-line {
    opacity: .16;
}

/* Animated motion lines (Site settings > Motion): each line draws itself on
   the first time it scrolls into view. js/main.js adds "in-view". */
.motion-line-animated path {
    stroke-dasharray: 1 2;
    stroke-dashoffset: 1.01;
}

.motion-line-animated.in-view path {
    animation: motion-line-draw 2.4s cubic-bezier(.33, 0, .67, 1) forwards;
}

@keyframes motion-line-draw {
    to { stroke-dashoffset: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .motion-line-animated path {
        stroke-dashoffset: 0;
        animation: none;
    }
}

/* Sections
   ========================================================================== */

.section {
    padding: var(--section-space) 0;
}

/* A tight section is a small aside: half the usual space */
.section-tight {
    padding: calc(var(--section-space) / 2) 0;
}

/* Two sections of the same colour in a row read as one band,
   so the second drops its top space and the gap between them stays even */
.bg-white + .section.bg-white,
.bg-grey + .section.bg-grey,
.bg-magnolia + .section.bg-magnolia,
.bg-lavender + .section.bg-lavender,
.bg-salmon + .section.bg-salmon,
.bg-pistachio + .section.bg-pistachio,
.bg-pink + .section.bg-pink {
    padding-top: 0;
}

/* A narrow section holds everything in it to a comfortable reading width.
   The content sits on the left, or in the middle when the section is centred. */
.section-narrow > .container > * {
    max-width: var(--measure-width);
}

.section-narrow.section-centred > .container > * {
    margin-right: auto;
    margin-left: auto;
}

/* A tight section is a small aside, so its heading is smaller */
.section-tight :is(h2:not(.heading-small, .item-title, .stopwatch-title), .heading-large) {
    font-size: var(--text-subheading);
}

.section-head {
    display: flex;
    flex-direction: column;
    margin-bottom: 36px;
}

.section-head-text {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.section-intro {
    max-width: 66ch;
    color: var(--color-text-muted);
    font-size: var(--text-lead);
}

/* A heading with a link or carousel arrows on its right */
.section-head-row {
    flex-direction: row;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
}

.section-head-row .section-head-text {
    gap: 0;
}

/* Deep blue section: white text, with the brand motion lines behind */
.section.bg-deep-blue {
    position: relative;
    overflow: hidden;
}

.bg-deep-blue > .container {
    position: relative;
}

.bg-deep-blue .section-intro {
    color: rgba(255, 255, 255, .78);
}

.bg-deep-blue .lead {
    color: rgba(255, 255, 255, .82);
}

/* Centred section */
.section-centred {
    text-align: center;
}

.section-centred .section-head {
    align-items: center;
    margin-bottom: 32px;
}

.section-centred .section-head-text {
    align-items: center;
    gap: 16px;
}

.section-centred .section-intro {
    max-width: 58ch;
}

/* Call to action
   ========================================================================== */

.call-to-action {
    position: relative;
    overflow: hidden;
    padding: var(--section-space) 0;
    border-radius: var(--band-radius) var(--band-radius) 0 0;
    background: var(--color-deep-blue);
    color: var(--color-white);
}

.call-to-action-inner {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
}

.call-to-action-mark {
    width: 56px;
    height: 56px;
    margin-bottom: 16px;
}

.call-to-action p {
    max-width: 48ch;
    margin-top: 14px;
    color: rgba(255, 255, 255, .82);
    font-size: var(--text-lead);
}

.call-to-action .buttons {
    margin-top: 20px;
}

.call-to-action .motion-line,
.bg-deep-blue > .motion-line {
    opacity: .12;
}

.call-to-action .motion-line-top-right,
.bg-deep-blue > .motion-line-top-right {
    top: -80px;
    right: -120px;
    width: 760px;
}

.call-to-action .motion-line-bottom-left,
.bg-deep-blue > .motion-line-bottom-left {
    bottom: -120px;
    left: -100px;
    width: 520px;
}

/* When a call to action ends the page it runs straight into the footer, which
   is the same colour. Its motion lines carry on over the top of the footer, so
   they are not cut off where the two meet. (Not in landing page mode, where the
   footer is too short to hold them.) */
body:not(.landing-page) main > .call-to-action:last-child {
    z-index: 1;
    overflow-x: clip;
    overflow-y: visible;
    clip-path: inset(0 0 -400px 0 round var(--band-radius) var(--band-radius) 0 0);
}

/* The call to action's rounded top corners show the colour of the section above,
   not the page behind. The band is pulled up over the foot of that section, which
   is made taller by the same amount, so the space between the two is unchanged. */
.section:not(.bg-deep-blue):has(+ .call-to-action)::after {
    content: "";
    display: block;
    height: var(--band-radius);
}

.section:not(.bg-deep-blue) + .call-to-action {
    margin-top: calc(-1 * var(--band-radius));
}

/* After a Deep Blue section the call to action is the same colour, so the two
   read as one band: its top corners are square, it drops its top space, and
   its top motion line is left out (the section above already has one). */
.section.bg-deep-blue + .call-to-action {
    /* Overlap the section above by a pixel, so no hairline of the page shows between the two */
    margin-top: -1px;
    padding-top: 1px;
    border-radius: 0;
}

body:not(.landing-page) main > .section.bg-deep-blue + .call-to-action:last-child {
    clip-path: inset(0 0 -400px 0);
}

.section.bg-deep-blue + .call-to-action .motion-line-top-right {
    display: none;
}

body:not(.landing-page) .site-footer > .container {
    position: relative;
    z-index: 2;
}

/* Site footer
   ========================================================================== */

.site-footer {
    padding: 64px 0 28px;
    background: var(--color-deep-blue);
    color: var(--color-white);
}

.footer-columns {
    display: grid;
    grid-template-columns: 1.6fr 1fr 1fr;
    gap: 48px;
    margin-bottom: 36px;
}

.footer-brand img {
    display: block;
    width: auto;
    height: 30px;
}

.footer-brand p {
    max-width: 30ch;
    margin-top: 23px;
    color: rgba(255, 255, 255, .78);
    font-size: var(--text-small);
}

.footer-brand a {
    color: var(--color-white);
    text-decoration: underline;
}

.footer-heading {
    max-width: none;
    margin-bottom: 12px;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.1;
}

.footer-menu ul,
.legal-menu {
    margin: 0;
    padding: 0;
    list-style: none;
}

.footer-menu a {
    display: block;
    padding: 4px 0;
    color: rgba(255, 255, 255, .78);
    font-size: 16px;
}

.footer-menu a:hover {
    color: var(--color-white);
}

.footer-legal {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 16px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, .18);
    color: rgba(255, 255, 255, .6);
    font-size: 13px;
}

.legal-menu {
    display: flex;
    flex-wrap: wrap;
    gap: 0 18px;
}

/* Padding makes each link tall enough to tap comfortably when the links wrap onto several lines */
.legal-menu a {
    display: block;
    padding: 4px 0;
    color: rgba(255, 255, 255, .6);
}

/* Tablet
   ========================================================================== */

@media (max-width: 1024px) {
    .footer-columns,
    .page-header-tiles {
        grid-template-columns: 1fr 1fr;
    }
}

/* Mobile
   ========================================================================== */

@media (max-width: 820px) {
    .menu-toggle {
        display: flex;
    }

    /* The menu and buttons become a panel that drops down below the header */
    .site-nav {
        display: none;
        position: absolute;
        top: 100%;
        right: 0;
        left: 0;
        flex-direction: column;
        gap: 6px;
        max-height: calc(100vh - var(--header-height));
        padding: 12px 24px 24px;
        overflow-y: auto;
        border-top: 1px solid var(--color-grey);
        border-bottom: 1px solid var(--color-grey);
        background: var(--color-white);
    }

    .site-header.menu-open .site-nav {
        display: flex;
    }

    .main-menu {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }

    .main-menu > li > a {
        display: flex;
        justify-content: space-between;
        padding: 12px 8px;
        border-radius: 0;
        font-size: 18px;
    }

    .main-menu > li > a:hover,
    .main-menu > li.open > a,
    .main-menu > li:hover > a {
        background: none;
    }

    /* Drop-downs open in place, on tap only */
    .main-menu .sub-menu,
    .main-menu > li:hover > .sub-menu,
    .main-menu > li:focus-within > .sub-menu {
        display: none;
        position: static;
        gap: 0;
        min-width: 0;
        margin: 0;
        padding: 0;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .main-menu > li.open > .sub-menu {
        display: flex;
    }

    .main-menu > .menu-item-has-children::after {
        display: none;
    }

    /* On mobile the arrow only turns when the drop-down has been tapped open */
    .main-menu > .menu-item-has-children:not(.open):hover > a::after {
        transform: rotate(45deg) translateY(-2px);
    }

    .main-menu .sub-menu a {
        padding: 12px 8px 12px 24px;
        font-size: 17px;
        font-weight: 400;
    }

    .main-menu .sub-menu .menu-view-all {
        margin-top: 0;
        border-top: 0;
    }

    .header-actions {
        margin-top: 12px;
    }

    .header-actions .button {
        min-height: 48px;
        padding: 14px 28px;
        font-size: 17px;
    }

    /* The design leaves the log-in button out of the mobile menu */
    .header-login {
        display: none;
    }

    /* Landing page mode has no menu, so its single button stays in the header row */
    .landing-page .header-actions {
        margin-top: 0;
    }

    .footer-columns {
        grid-template-columns: 1fr;
    }

    .theme-dark .page-header-tiles {
        grid-template-columns: 1fr;
    }

    .page-header-inner.has-media {
        grid-template-columns: 1fr;
    }

    .section-head-row {
        flex-direction: column;
        align-items: flex-start;
    }

}
