/*
 * Geo shipping banner.
 *
 * Two variants with a different contract each:
 *
 *  - Header strip: structural skeleton only. The module ships just enough CSS that the markup
 *    holds together and the reveal works; colours, typography and spacing belong to the active
 *    theme (Netstore: web/css/source/_geo-banner.less). This file is linked between styles-m
 *    and styles-l, so theme rules of equal specificity win over anything declared here.
 *
 *  - In content card (.geo-hero): the country banner designed in the banner-studio project.
 *    It is a finished piece of artwork with its own palette per country, the same in every
 *    theme, so all of it is here. A theme only sets the margin around the card.
 */
.geo-banner,
.geo-banner *,
.geo-banner *::before {
    /* Declared rather than inherited from the theme reset so max-width and padding still add up
       correctly if this module is ever dropped into a theme without one. */
    box-sizing: border-box;
}

.geo-banner {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    position: relative;
    transition: max-height 0.35s cubic-bezier(0.16, 1, 0.3, 1),
                opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.geo-banner--visible {
    max-height: 12rem;
    opacity: 1;
}

.geo-banner__inner {
    align-items: center;
    display: flex;
    justify-content: center;
    position: relative;
}

.geo-banner__content {
    align-items: center;
    display: flex;
    gap: 9px;
    justify-content: center;
    margin: 0;
    text-align: center;
}

.geo-banner__icon {
    flex-shrink: 0;
}

/*
 * Set by geo-banner.js around the country name and any **marked** words of the message.
 *
 * font-size is pinned to inherit because the Netstore themes ship `strong, dt { font-size:
 * 0.85rem }`, which otherwise shrinks the country in the middle of the headline. No nowrap:
 * a marked phrase can be several words long.
 */
.geo-banner__country {
    font-size: inherit;
    line-height: inherit;
}

/* Per-country messages vary from a few words to a full sentence. The strip evens out its
   lines (only ever wraps on a phone). */
.geo-banner--strip .geo-banner__message {
    text-wrap: balance;
}

/*
 * Visitor's flag, placed by the message's %flag% or in front of the country name.
 * Square corners, about a fifth taller than the type, centred on the capitals. Fixed size so
 * it never shifts the text once the SVG arrives. With word spaces either side and the same
 * margin on both, the gap either side of the flag is identical at every font size.
 */
.geo-banner__flag {
    border-radius: 0;
    display: inline-block;
    height: 1.2em;
    margin: 0 0.12em;
    object-fit: cover;
    vertical-align: -0.25em;
    width: 1.6em;
}

/* The flag and the words either side of it, kept on one line (see
   BannerMessage::bindFlags()). The bold runs inside are named too, as a theme may set its
   own white-space on .geo-banner__country. */
.geo-banner__flag-group,
.geo-banner .geo-banner__flag-group > .geo-banner__country {
    white-space: nowrap;
}

/* One icon per strip: the flag takes over from the truck. Once the flag is gone again (file
   missing) :has() stops matching and the truck comes back. */
.geo-banner__content:has(.geo-banner__flag) .geo-banner__icon {
    display: none;
}

/* ── Header strip ───────────────────────────────────────── */

.geo-banner--strip {
    width: 100%;
}

.geo-banner--strip .geo-banner__inner {
    margin: 0 auto;
    /* Mirrors the Netstore container ladder (1280 → 1400 → 1600, see the wide screen media
       queries below) so the close button lands on the topbar's own vertical line. */
    max-width: 1280px;
    min-height: 36px;
    /* Symmetric so the message stays optically centred, and wide enough that a long message
       never runs underneath the absolutely positioned close button. */
    padding: 9px 64px;
}

.geo-banner__close {
    align-items: center;
    background: none;
    border: 0;
    cursor: pointer;
    display: flex;
    height: 26px;
    justify-content: center;
    margin: 0;
    padding: 0;
    position: absolute;
    /* Absolute offsets resolve against the padding box, so the inner's padding does not move
       this: the value has to match the topbar's own 24px gutter explicitly. */
    right: 24px;
    top: 50%;
    transform: translateY(-50%);
    width: 26px;
}

/* ── Narrow screens ─────────────────────────────────────── */

@media (max-width: 767px) {
    .geo-banner--strip .geo-banner__inner {
        padding: 8px 40px;
    }

    .geo-banner__content {
        gap: 7px;
    }

    /* The truck is decoration; on a narrow screen the words need the room. */
    .geo-banner__icon {
        display: none;
    }

    .geo-banner__close {
        height: 24px;
        right: 10px;
        width: 24px;
    }
}

/* ── Wide screens: follow the Netstore container ladder ─── */

@media only screen and (min-width: 1440px) {
    .geo-banner--strip .geo-banner__inner {
        max-width: 1400px;
    }
}

@media only screen and (min-width: 1920px) {
    .geo-banner--strip .geo-banner__inner {
        max-width: 1600px;
    }
}

/* Opened before the first paint from the cached answer (inline script after the shell): no
   slide, or the page still moves. */
.geo-banner.geo-banner--instant {
    transition: none;
}

/* ── In content card: country banner ────────────────────── */

/*
 * Three areas, as in banner-studio: the flag on the left at its own proportions, the message
 * centred, the landmark on the right. Sizes follow the card's own width, not the viewport's
 * (container queries), as the same card sits in a full width page, a category column and the
 * checkout form:
 *
 *   over 850px   desktop   260px tall
 *   500-850px    tablet    233px tall
 *   up to 500px  mobile    no landmark; the flag on top, the message under it, the card as
 *                          tall as the flag plus its top padding and 240px
 *
 * --geo-flag-ratio is the flag's width / height. geo-banner.js sets it from the payload before
 * the flag loads (and the inline script from the cached payload before the first paint), so
 * nothing moves when the image arrives; 1.5 until then.
 */
.geo-banner--inline {
    container-type: inline-size;
    width: 100%;
}

/* The collapsed-to-open transition animates max-height, so it needs a ceiling the card can
   actually reach — the strip's 12rem would clip it. */
.geo-banner--inline.geo-banner--visible {
    max-height: 60rem;
}

.geo-hero {
    --geo-hero-accent: #cfff7b;
    /* Breathing room between the card's edge and the flag / landmark. Small on a full width
       card, where the flag and the landmark should read as large as in the studio. */
    --geo-hero-pad: 12px;
    /* Kept free under the landmark for its caption. On a full width card the caption sits in
       the corner beside the landmark's base instead, as in the studio. */
    --geo-hero-caption-room: var(--geo-hero-pad);
    /* Tallest the flag gets: the card's height less the padding above and below. */
    --geo-flag-height: calc(260px - 2 * var(--geo-hero-pad));

    background: radial-gradient(ellipse at 82% 48%, #263043 0%, #141c2e 32%, #0b1323 66%);
    border-radius: 8px;
    color: #ffffff;
    height: 260px;
    isolation: isolate;
    overflow: hidden;
    position: relative;
    width: 100%;
}

/* Landmark side. The illustration keeps its proportions and is centred in its column, level
   with the flag and the message; the strip at the bottom is left to the caption, so the two
   never overlap. */
.geo-hero__art {
    inset: var(--geo-hero-pad) var(--geo-hero-pad) var(--geo-hero-caption-room) 66%;
    position: absolute;
    z-index: 1;
}

/* Two classes: themes ship `img { height: auto; max-width: 100% }`. */
.geo-banner .geo-hero__landmark {
    animation: geo-hero-reveal 0.55s ease-out;
    height: 100%;
    inset: 0;
    max-width: none;
    object-fit: contain;
    object-position: center;
    position: absolute;
    width: 100%;
    z-index: 2;
}

/* The country's three letter code, barely there behind the landmark. */
.geo-hero__code {
    color: var(--geo-hero-accent);
    font-size: clamp(130px, 19cqw, 290px);
    font-weight: 900;
    inset: 35px 12px auto 0;
    letter-spacing: -0.07em;
    line-height: 1;
    opacity: 0.045;
    position: absolute;
    text-align: center;
    user-select: none;
}

.geo-hero__orbit {
    border: 1px solid color-mix(in srgb, var(--geo-hero-accent) 20%, transparent);
    border-radius: 50%;
    bottom: 13%;
    box-shadow: 0 0 55px color-mix(in srgb, var(--geo-hero-accent) 5%, transparent);
    height: 30%;
    left: 10%;
    position: absolute;
    transform: rotate(-12deg);
    width: 80%;
}

/* Flag side: a box with the flag's own proportions, centred on the card's left edge, so a
   flag is never stretched or cropped. Everything it draws stays inside the box. */
.geo-hero__flag-zone {
    -webkit-mask-image: linear-gradient(90deg, #000 92%, transparent 100%);
    aspect-ratio: var(--geo-flag-ratio, 1.5);
    background: #111936;
    contain: paint;
    left: var(--geo-hero-pad);
    mask-image: linear-gradient(90deg, #000 92%, transparent 100%);
    overflow: hidden;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: min(calc(34% - var(--geo-hero-pad)), calc(var(--geo-flag-height) * var(--geo-flag-ratio, 1.5)));
}

/* Until flag-cloth.js takes over (and if it cannot): the still flag, swaying slightly. */
.geo-hero__flag {
    animation: geo-hero-sway 6s ease-in-out infinite;
    background-position: center;
    background-repeat: no-repeat;
    background-size: 100% 100%;
    inset: 0;
    opacity: 0.95;
    position: absolute;
}

/* Light running over the folds of the still flag. */
.geo-hero__flag::after {
    animation: geo-hero-cloth 6s ease-in-out infinite;
    background: repeating-linear-gradient(106deg, #0000 0%, #fff3 12%, #0007 25%, #ffffff08 38%, #0000 50%);
    background-size: 180% 100%;
    content: '';
    inset: 0;
    mix-blend-mode: hard-light;
    opacity: 0.35;
    position: absolute;
}

/* The message no longer sits on the flag, so this is only a light cloth shading. */
.geo-hero__shade {
    background:
        linear-gradient(0deg, #071121ed 0%, #08132466 50%, #07102210),
        linear-gradient(90deg, #0001, transparent 50%, #0b132380);
    inset: 0;
    opacity: 0.15;
    pointer-events: none;
    position: absolute;
}

/* Waving cloth on a canvas (flag-cloth.js): it draws its own light, shade and soft edges. */
.geo-hero__flag--cloth {
    animation: none;
}

.geo-hero__flag--cloth::after,
.geo-hero__flag-zone:has(.geo-hero__flag--cloth) .geo-hero__shade {
    display: none;
}

.geo-hero__flag-zone:has(.geo-hero__flag--cloth) {
    background: transparent;
}

.geo-hero__flag canvas {
    display: block;
    height: 100%;
    width: 100%;
}

.geo-hero__grain {
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Cpath fill='%23fff' filter='url(%23n)' opacity='.4' d='M0 0h180v180H0z'/%3E%3C/svg%3E");
    inset: 0;
    mix-blend-mode: soft-light;
    opacity: 0.1;
    pointer-events: none;
    position: absolute;
    z-index: 2;
}

/* The message, centred between the flag and the landmark, and vertically like both. Kept a
   padding's width clear of each, so a long name ("the United States") never meets the flag. */
.geo-hero__copy {
    left: calc(34% + var(--geo-hero-pad));
    position: absolute;
    right: calc(34% + var(--geo-hero-pad));
    text-align: center;
    top: 50%;
    transform: translateY(-50%);
    z-index: 3;
}

/* A div, not a p: themes set the size of paragraphs in page content with selectors that
   outrank anything here (Netstore/v3 does on category pages), and geo-banner.js reads this
   size as the starting point for fitting the country name (fitTitle). Two classes on the
   text rules for the same reason: themes style strong and a by element. */
.geo-banner .geo-hero__headline {
    color: #ffffff;
    font-size: clamp(32px, 5cqw, 68px);
    font-weight: 800;
    /* The studio set -0.055em for Inter; the theme's DM Sans is wider and its letters met. */
    letter-spacing: -0.04em;
    line-height: 1.02;
    margin: 0 0 14px;
    max-width: 100%;
    text-shadow: 0 4px 30px #0004;
    text-wrap: balance;
}

/* The small lines above and below the country name. */
.geo-hero__lead {
    color: var(--geo-hero-accent);
    display: block;
    font-size: clamp(14px, 1.6cqw, 20px);
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.2;
    margin-bottom: 0.35em;
}

.geo-hero__tail {
    margin: 0.3em 0 0;
}

.geo-hero__lead:empty {
    display: none;
}

/* Tagline on a line of its own, the call to action centred under it. */
.geo-hero__baseline {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
}

.geo-hero__tagline {
    color: #eff3f0c9;
    font-size: 16px;
    font-weight: 400;
    line-height: 1.5;
    /* Two even lines rather than a word left alone on the second. */
    text-wrap: balance;
    width: 100%;
}

.geo-hero__tagline:empty {
    display: none;
}

.geo-banner .geo-hero__cta {
    -webkit-backdrop-filter: blur(15px);
    align-items: center;
    backdrop-filter: blur(15px);
    background: #ffffff0f;
    border: 1px solid #ffffff3d;
    border-radius: 100px;
    color: #ffffff;
    display: inline-flex;
    font-size: 12px;
    font-weight: 500;
    gap: 18px;
    height: 37px;
    padding: 0 6px 0 16px;
    text-decoration: none;
    transition: background-color 0.2s ease;
    white-space: nowrap;
}

.geo-banner .geo-hero__cta:hover,
.geo-banner .geo-hero__cta:focus {
    background: #ffffff25;
    color: #ffffff;
    text-decoration: none;
}

.geo-banner .geo-hero__cta:focus-visible {
    outline: 2px solid var(--geo-hero-accent);
    outline-offset: 2px;
}

.geo-hero__cta-icon {
    background: var(--geo-hero-accent);
    border-radius: 50%;
    color: #15230e;
    display: grid;
    font-size: 17px;
    height: 25px;
    place-items: center;
    width: 25px;
}

/* Name of the landmark and where it is, under the illustration. On a full width card it
   overlaps the landmark's base, hence the shadow. */
.geo-hero__caption {
    align-items: center;
    text-shadow: 0 1px 6px #000000d9, 0 0 2px #000000b3;
    bottom: 8px;
    display: flex;
    gap: 10px;
    max-width: 29%;
    position: absolute;
    right: 25px;
    z-index: 3;
}

.geo-hero__caption[hidden] {
    display: none;
}

.geo-hero__caption-mark {
    color: var(--geo-hero-accent);
    flex-shrink: 0;
    height: 24px;
    width: 24px;
}

.geo-banner .geo-hero__caption-text strong {
    color: #ffffff;
    display: block;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.3px;
    line-height: 1.2;
}

.geo-hero__caption-text span {
    color: #c0c8c6;
    display: block;
    font-size: 9px;
    letter-spacing: 0.5px;
    line-height: 1.2;
    margin-top: 5px;
}

/* A country without an illustration (or one that failed to load): the message takes the
   landmark's column too. */
.geo-hero--no-art .geo-hero__art {
    display: none;
}

.geo-hero--no-art .geo-hero__copy {
    right: 4%;
}

@keyframes geo-hero-sway {
    0%, 100% { transform: translateX(-1px) skewY(-0.7deg); }
    50% { transform: translateX(1px) skewY(0.7deg); }
}

@keyframes geo-hero-cloth {
    0%, 100% { background-position: 0% 0; }
    50% { background-position: 100% 0; }
}

@keyframes geo-hero-reveal {
    from { opacity: 0; transform: translateY(9px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Card: tablet width ─────────────────────────────────── */

@container (max-width: 850px) {
    .geo-hero {
        --geo-hero-pad: 16px;
        --geo-hero-caption-room: 34px;
        --geo-flag-height: calc(700px / 3 - 2 * var(--geo-hero-pad));

        height: calc(700px / 3);
    }

    .geo-banner .geo-hero__headline {
        font-size: 5cqw;
    }

    .geo-hero__baseline {
        gap: 8px;
    }

    .geo-hero__tagline {
        font-size: 13px;
    }

    .geo-banner .geo-hero__caption-text strong {
        font-size: 10px;
    }

    .geo-hero__caption-text span {
        font-size: 8px;
    }
}

/* Narrow tablet: narrower flag and landmark columns. At 34% / 34% the message had barely
   130px on a 520px card, and the longer lines ("Proudly shipping from") broke in two. */
@container (min-width: 501px) and (max-width: 650px) {
    .geo-hero__flag-zone {
        width: min(calc(28% - var(--geo-hero-pad)), calc(var(--geo-flag-height) * var(--geo-flag-ratio, 1.5)));
    }

    .geo-hero__copy {
        left: calc(28% + var(--geo-hero-pad));
        right: calc(30% + var(--geo-hero-pad));
    }

    .geo-hero__art {
        left: 70%;
    }
}

/* ── Card: mobile width ─────────────────────────────────── */

/* No landmark: the flag sits on top, centred, at its own proportions (at most 260px tall)
   inside the padding, and the message gets the 240px under it. geo-banner.js does not download the illustration
   at this size (ART_MIN_WIDTH). */
@container (max-width: 500px) {
    .geo-hero {
        --geo-hero-pad: 16px;
        --geo-flag-mobile-height: min(260px, calc((100cqw - 2 * var(--geo-hero-pad)) / var(--geo-flag-ratio, 1.5)));

        background: radial-gradient(ellipse at 65% 25%, #263043, #0b1323 65%);
        height: calc(var(--geo-hero-pad) + var(--geo-flag-mobile-height) + 240px);
    }

    .geo-hero__art,
    .geo-hero__caption {
        display: none;
    }

    .geo-hero__flag-zone {
        -webkit-mask-image: none;
        left: 50%;
        mask-image: none;
        top: var(--geo-hero-pad);
        transform: translateX(-50%);
        width: min(calc(100% - 2 * var(--geo-hero-pad)), calc(260px * var(--geo-flag-ratio, 1.5)));
    }

    /* Centred in the space under the flag, so a short message under a tall flag (Nepal,
       Switzerland) does not leave a gap above it. */
    .geo-hero__copy,
    .geo-hero--no-art .geo-hero__copy {
        bottom: 0;
        display: flex;
        flex-direction: column;
        justify-content: center;
        left: 6%;
        right: 6%;
        top: calc(var(--geo-hero-pad) + var(--geo-flag-mobile-height));
        transform: none;
    }

    .geo-banner .geo-hero__headline {
        font-size: 11cqw;
        margin-bottom: 16px;
    }

    .geo-hero__lead {
        font-size: 14px;
    }

    .geo-hero__baseline {
        flex-direction: column;
    }

    .geo-hero__tagline {
        font-size: 12px;
    }

    .geo-banner .geo-hero__cta {
        font-size: 11px;
        gap: 10px;
        height: 35px;
    }
}

/* The slide and the waving flag are decoration, not information. flag-cloth.js draws a
   still flag on its own. */
@media (prefers-reduced-motion: reduce) {
    .geo-banner,
    .geo-banner__close {
        transition: none;
    }

    .geo-hero__flag,
    .geo-hero__flag::after,
    .geo-banner .geo-hero__landmark {
        animation: none;
    }
}
