/* ==========================================================================
   Highline Payments 2.0 — components
   Buttons, network host, loaders, modal, back-to-top, media treatments.
   ========================================================================== */

/* --- Buttons ---------------------------------------------------------------
   Three levels of emphasis, and the hierarchy is the point (§28):

     primary    one per view. High contrast, filled, carries a signal sweep.
     secondary  outlined, low emphasis. Sits beside the primary without
                competing with it.
     tertiary   text plus a directional arrow. For "keep reading" moves.

   Every button acknowledges a click immediately: :active applies instantly, and
   the .is-loading state (Level 1 loading) is applied by loader.js on the very
   same tick the click is handled — never after the network responds. That is
   the fix for the previous site's "did my click register?" problem.

   Interaction is meaningful, not decorative: a 1px lift and a shadow, plus a
   light sweep across the primary that reads as a signal passing through the
   control. Nothing bounces (§28: "no excessive bouncing"). */
.hl-btn {
    --hl-btn-bg: var(--hl-primary, #2a2d7c);
    --hl-btn-fg: #fff;
    --hl-btn-border: transparent;

    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--hl-space-2xs, 0.5rem);
    padding: 0.85rem 1.6rem;
    background: var(--hl-btn-bg);
    color: var(--hl-btn-fg);
    border: 1px solid var(--hl-btn-border);
    border-radius: var(--hl-radius-pill, 999px);
    font-size: var(--hl-size-body, 1rem);
    font-weight: var(--hl-weight-semibold, 600);
    line-height: 1.2;
    letter-spacing: -0.005em;
    text-decoration: none;
    white-space: nowrap;
    /* Minimum comfortable touch target on every device (§26). */
    min-height: 2.875rem;
    isolation: isolate;
    overflow: hidden;
    transition: var(--hl-transition);
}
.hl-btn:hover { color: var(--hl-btn-fg); transform: translateY(-1px); box-shadow: var(--hl-shadow-md); }
.hl-btn:active { transform: translateY(0) scale(0.99); box-shadow: none; }

/* The signal sweep. Pure transform on a pseudo-element, so it is GPU-friendly
   and cannot affect layout. */
.hl-btn--primary::after,
.hl-btn--accent::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: linear-gradient(100deg,
                transparent 20%,
                rgba(255, 255, 255, 0.22) 48%,
                transparent 76%);
    transform: translateX(-110%);
    transition: transform var(--hl-duration-slow, 560ms) var(--hl-ease-out, ease);
}
.hl-btn--primary:hover::after,
.hl-btn--accent:hover::after { transform: translateX(110%); }

.hl-btn--primary { --hl-btn-bg: var(--hl-primary, #2a2d7c); }
.hl-btn--primary:hover { --hl-btn-bg: var(--hl-primary-light, #3d40a0); }

.hl-btn--accent { --hl-btn-bg: var(--hl-accent, #cf2927); }
.hl-btn--accent:hover { --hl-btn-bg: var(--hl-accent-dark, #a31f1d); }

.hl-btn--outline {
    --hl-btn-bg: transparent;
    --hl-btn-fg: var(--hl-primary, #2a2d7c);
    --hl-btn-border: currentColor;
}
.hl-btn--outline:hover { --hl-btn-bg: var(--hl-primary, #2a2d7c); --hl-btn-fg: #fff; }

/* On a dark environment an outline button must brighten rather than fill with
   navy, which would vanish into the background. */
.hl-on-dark .hl-btn--outline {
    --hl-btn-fg: var(--hl-text-on-dark, #f5f6fb);
    --hl-btn-border: var(--hl-hairline-on-dark-strong, rgba(245, 246, 251, 0.22));
}
.hl-on-dark .hl-btn--outline:hover {
    --hl-btn-bg: rgba(var(--hl-text-on-dark-rgb, 245, 246, 251), 0.1);
    --hl-btn-fg: var(--hl-text-on-dark, #f5f6fb);
    --hl-btn-border: var(--hl-text-on-dark, #f5f6fb);
}

.hl-btn--ghost {
    --hl-btn-bg: transparent;
    --hl-btn-fg: currentColor;
    --hl-btn-border: var(--hl-border, rgba(128, 128, 128, 0.35));
}
.hl-btn--ghost:hover { --hl-btn-bg: rgba(var(--hl-text-rgb, 18, 20, 46), 0.06); }

.hl-btn--sm { padding: 0.6rem 1.15rem; font-size: var(--hl-size-body-sm, 0.9375rem); min-height: 2.5rem; }
.hl-btn--lg { padding: 1.05rem 2.15rem; font-size: var(--hl-size-body-lg, 1.0625rem); min-height: 3.375rem; }
.hl-btn--block { width: 100%; }

/* Tertiary: a text link that moves. The arrow is the affordance, so it must
   respond — but only the arrow moves, not the label, or the text reflows. */
.hl-link-arrow {
    display: inline-flex;
    align-items: center;
    gap: var(--hl-space-2xs, 0.5rem);
    font-weight: var(--hl-weight-semibold, 600);
    color: var(--hl-primary, #2a2d7c);
    text-decoration: none;
    transition: color var(--hl-duration-fast, 180ms) var(--hl-ease-out, ease);
}
.hl-link-arrow__icon {
    width: 1.05em;
    height: 1.05em;
    flex: 0 0 auto;
    transition: transform var(--hl-duration-base, 300ms) var(--hl-ease-out, ease);
}
.hl-link-arrow:hover { color: var(--hl-accent, #cf2927); }
.hl-link-arrow:hover .hl-link-arrow__icon { transform: translateX(0.25em); }
.hl-on-dark .hl-link-arrow { color: var(--hl-text-on-dark, #f5f6fb); }
.hl-on-dark .hl-link-arrow:hover { color: var(--hl-accent-light, #e24543); }

/* A row of CTAs. Wraps rather than overflowing, and on a narrow phone the
   buttons go full width in priority order (§26: clear CTA hierarchy). */
.hl-cta-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--hl-space-xs, 0.75rem);
}

@media (max-width: 30rem) {
    .hl-cta-row { flex-direction: column; align-items: stretch; }
    .hl-cta-row > .hl-btn { width: 100%; }
    .hl-cta-row > .hl-link-arrow { justify-content: center; padding-block: var(--hl-space-2xs, 0.5rem); }
}

/* Level 1 — button loading. The label stays in place (so the button does not
   resize and shift the layout) and is faded behind a spinner. */
.hl-btn.is-loading {
    pointer-events: none;
    color: transparent !important;
}
.hl-btn.is-loading::before {
    content: "";
    position: absolute;
    inset: 50% auto auto 50%;
    width: 1.1em; height: 1.1em;
    margin: -0.55em 0 0 -0.55em;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    color: var(--hl-btn-fg);
    animation: hl-spin 700ms linear infinite;
}
.hl-btn[disabled] { opacity: 0.55; pointer-events: none; }

@keyframes hl-spin { to { transform: rotate(360deg); } }

/* --- Payment-network host --------------------------------------------------
   The canvas is injected by modules/network.js. This positions and masks it;
   the drawing itself is entirely in JS.

   Always behind content and never interactive unless explicitly asked for —
   a decorative canvas must not intercept a click meant for a button. */
.hl-network {
    position: absolute;
    inset: 0;
    z-index: var(--hl-z-behind, -1);
    overflow: hidden;
    pointer-events: none;
    /* Fade the edges so the composition dissolves into the section instead of
       ending at a hard rectangle. */
    -webkit-mask-image: radial-gradient(120% 120% at 50% 50%, #000 55%, transparent 100%);
            mask-image: radial-gradient(120% 120% at 50% 50%, #000 55%, transparent 100%);
}
.hl-network--inline { position: relative; inset: auto; z-index: var(--hl-z-base, 1); }
.hl-network--interactive { pointer-events: auto; }
.hl-network--unmasked { -webkit-mask-image: none; mask-image: none; }

/* Softens the field so it never competes with the copy over it (§20). */
.hl-network--faint { opacity: 0.5; }

.hl-network__canvas { display: block; width: 100%; height: 100%; }


/* Level 2 — section / component loading. Applied to any container while a
   partial request is in flight; content stays readable underneath. */
.hl-loading {
    position: relative;
    min-height: 6rem;
    pointer-events: none;
}
.hl-loading::before {
    content: "";
    position: absolute;
    inset: 0;
    background: rgb(255 255 255 / 55%);
    backdrop-filter: blur(1px);
    border-radius: inherit;
    z-index: 2;
}
.hl-loading::after {
    content: "";
    position: absolute;
    top: 50%; left: 50%;
    width: 1.75rem; height: 1.75rem;
    margin: -0.875rem 0 0 -0.875rem;
    border: 2px solid var(--hl-primary, #2a2d7c);
    border-top-color: transparent;
    border-radius: 50%;
    animation: hl-spin 700ms linear infinite;
    z-index: 3;
}

/* --- Level 3: full-screen branded loader -----------------------------------
   Presets animate the Highline mark's own geometry. `fill` sweeps the brand
   colour up through the bars; `stroke` draws them; `pulse` is the reduced-
   motion-safe fallback. */
.hl-loader {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: grid;
    place-items: center;
    background: var(--hl-loader-bg, #0a0b1f);
    transition: opacity 420ms cubic-bezier(0.16, 1, 0.3, 1), visibility 420ms;
}
.hl-loader[hidden] { display: none; }
.hl-loader.is-leaving { opacity: 0; visibility: hidden; }

.hl-loader__inner { display: grid; justify-items: center; gap: 1.5rem; }

.hl-loader__mark { width: clamp(64px, 12vw, 104px); height: auto; overflow: visible; }
.hl-loader__base .hl-loader__bar { fill: var(--hl-mark-base, #fff); }

/* The fill layer is masked to the mark in the SVG itself (mask="#hl-loader-mask"),
   so the colour can only ever appear inside the logo geometry. */
.hl-loader__fill-rect {
    fill: var(--hl-mark-fill, #cf2927);
    transform-box: fill-box;
    transform-origin: bottom;
    transform: scaleY(0);
}

.hl-loader[data-preset="fill"] .hl-loader__fill-rect {
    animation: hl-loader-fill 1.6s cubic-bezier(0.65, 0, 0.35, 1) infinite;
}
.hl-loader[data-preset="sweep"] .hl-loader__fill-rect {
    fill: url(#hl-loader-sweep);
    animation: hl-loader-fill 1.4s ease-in-out infinite alternate;
}
.hl-loader[data-preset="stroke"] .hl-loader__base .hl-loader__bar {
    fill: none;
    stroke: var(--hl-mark-base, #fff);
    stroke-width: 6;
    stroke-dasharray: 2400;
    stroke-dashoffset: 2400;
    animation: hl-loader-draw 2s ease-in-out infinite;
}
.hl-loader[data-preset="pulse"] .hl-loader__base .hl-loader__bar {
    animation: hl-loader-pulse 1.4s ease-in-out infinite;
}
.hl-loader[data-preset="pulse"] .hl-loader__bar:nth-child(2) { animation-delay: 0.1s; }
.hl-loader[data-preset="pulse"] .hl-loader__bar:nth-child(3) { animation-delay: 0.2s; }
.hl-loader[data-preset="pulse"] .hl-loader__bar:nth-child(4) { animation-delay: 0.3s; }
.hl-loader[data-preset="pulse"] .hl-loader__bar:nth-child(5) { animation-delay: 0.4s; }

@keyframes hl-loader-fill {
    0%   { transform: scaleY(0); }
    55%  { transform: scaleY(1); }
    100% { transform: scaleY(1); opacity: 0; }
}
@keyframes hl-loader-draw {
    0%   { stroke-dashoffset: 2400; }
    60%  { stroke-dashoffset: 0; }
    100% { stroke-dashoffset: -2400; }
}
@keyframes hl-loader-pulse {
    0%, 100% { opacity: 0.35; }
    50%      { opacity: 1; }
}

.hl-loader__label {
    margin: 0;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: rgb(255 255 255 / 45%);
}

@media (prefers-reduced-motion: reduce) {
    /* Still branded, just static. */
    .hl-loader .hl-loader__fill-rect,
    .hl-loader .hl-loader__bar { animation: none !important; }
    .hl-loader__fill-rect { transform: scaleY(1); opacity: 0.85; }
}

/* --- Modal ----------------------------------------------------------------- */
.hl-modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: grid;
    place-items: center;
    padding: clamp(1rem, 4vw, 2.5rem);
}
.hl-modal[hidden] { display: none; }

.hl-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgb(10 11 31 / 72%);
    backdrop-filter: blur(3px);
    opacity: 0;
    transition: opacity 260ms ease;
}
.hl-modal.is-open .hl-modal__backdrop { opacity: 1; }

.hl-modal__dialog {
    position: relative;
    width: 100%;
    max-height: calc(100dvh - 4rem);
    overflow-y: auto;
    background: var(--hl-surface, #fff);
    border-radius: var(--hl-radius-lg, 24px);
    box-shadow: var(--hl-shadow-lg);
    opacity: 0;
    transform: translateY(12px) scale(0.98);
    transition: opacity 260ms cubic-bezier(0.16, 1, 0.3, 1), transform 260ms cubic-bezier(0.16, 1, 0.3, 1);
}
.hl-modal.is-open .hl-modal__dialog { opacity: 1; transform: none; }

.hl-modal__dialog--small  { max-width: 26rem; }
.hl-modal__dialog--medium { max-width: 36rem; }
.hl-modal__dialog--large  { max-width: 52rem; }
.hl-modal__dialog--full   { max-width: 72rem; }

.hl-modal__close {
    position: absolute;
    top: 0.75rem; right: 0.75rem;
    z-index: 2;
    display: grid;
    place-items: center;
    width: 2.25rem; height: 2.25rem;
    background: var(--hl-surface, #fff);
    border: 1px solid var(--hl-border, #e3e5f0);
    border-radius: 50%;
    color: var(--hl-text, #12142e);
}
.hl-modal__close:hover { background: var(--hl-bg-alt, #f6f7fc); }

.hl-modal__link { display: block; color: inherit; text-decoration: none; }
.hl-modal__image { width: 100%; border-radius: var(--hl-radius-lg, 24px) var(--hl-radius-lg, 24px) 0 0; }
.hl-modal__dialog > .hl-modal__image:only-child,
.hl-modal__link > .hl-modal__image:only-child { border-radius: var(--hl-radius-lg, 24px); }
.hl-modal__video video { width: 100%; display: block; }
.hl-modal__body { padding: clamp(1.25rem, 3vw, 2rem); display: grid; gap: 1rem; justify-items: start; }
.hl-modal__heading { margin: 0; font-size: 1.5rem; }

/* --- Back to top ----------------------------------------------------------- */
.hl-to-top {
    position: fixed;
    right: clamp(1rem, 3vw, 2rem);
    bottom: clamp(1rem, 3vw, 2rem);
    z-index: 80;
    display: grid;
    place-items: center;
    width: 2.75rem; height: 2.75rem;
    background: var(--hl-primary, #2a2d7c);
    color: #fff;
    border: 0;
    border-radius: 50%;
    box-shadow: var(--hl-shadow-md);
    opacity: 0;
    transform: translateY(0.75rem) scale(0.9);
    transition: opacity 240ms ease, transform 240ms cubic-bezier(0.16, 1, 0.3, 1), background-color 200ms ease;
}
.hl-to-top[hidden] { display: none; }
.hl-to-top.is-visible { opacity: 1; transform: none; }
.hl-to-top:hover { background: var(--hl-accent, #cf2927); }

.hl-to-top__progress {
    position: absolute;
    inset: -3px;
    width: calc(100% + 6px);
    height: calc(100% + 6px);
    transform: rotate(-90deg);
    pointer-events: none;
}
.hl-to-top__track { stroke: rgb(255 255 255 / 22%); }
.hl-to-top__bar {
    stroke: var(--hl-accent, #cf2927);
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
    transition: stroke-dashoffset 120ms linear;
}

@media (min-width: 48rem) {
    .hl-to-top { width: 3rem; height: 3rem; }
}

/* --- Media treatments ------------------------------------------------------
   Product and illustration artwork is composed, not boxed: shaped backdrops,
   circular masks, curved containers and images that break their bounds. */
.hl-media__stage {
    position: relative;
    display: grid;
    place-items: center;
    isolation: isolate;
}
.hl-media__shape {
    position: absolute;
    inset: 8%;
    z-index: -1;
    background: var(--hl-gradient-brand);
    opacity: 0.12;
}
.hl-media__image { position: relative; width: 100%; }

.hl-media--panel .hl-media__shape { border-radius: var(--hl-radius-lg, 24px); }
.hl-media--panel .hl-media__image { border-radius: var(--hl-radius-lg, 24px); }

.hl-media--circle .hl-media__shape { inset: 0; border-radius: 50%; opacity: 0.16; }
.hl-media--circle .hl-media__image { border-radius: 50%; }
/* A cut-out asset is allowed to extend past its mask — the device reads as
   part of the artwork rather than an image sitting inside a circle. */
.hl-media--circle .hl-media__image--cutout {
    border-radius: 0;
    width: 116%;
    max-width: 116%;
    filter: drop-shadow(0 24px 40px rgb(10 11 31 / 28%));
}

.hl-media--arc .hl-media__shape {
    inset: 12% 0 0;
    border-radius: 45% 45% var(--hl-radius-lg, 24px) var(--hl-radius-lg, 24px);
}
.hl-media--arc .hl-media__image { border-radius: var(--hl-radius-lg, 24px); }

.hl-media--bleed .hl-media__shape { display: none; }
.hl-media--bleed .hl-media__image {
    width: 118%;
    max-width: 118%;
    filter: drop-shadow(0 28px 48px rgb(10 11 31 / 26%));
}

.hl-media--plain .hl-media__shape { display: none; }

.hl-media__video { width: 100%; border-radius: var(--hl-radius-lg, 24px); }

/* --- Small shared pieces --------------------------------------------------- */
.hl-badge {
    display: inline-block;
    padding: 0.15em 0.5em;
    background: var(--hl-accent, #cf2927);
    color: #fff;
    border-radius: var(--hl-radius-pill, 999px);
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.hl-checklist { margin: 1.5rem 0 0; padding: 0; list-style: none; display: grid; gap: 0.65rem; }
.hl-checklist__item { display: flex; align-items: flex-start; gap: 0.65rem; }
.hl-checklist__icon {
    flex: 0 0 auto;
    width: 1.1rem; height: 1.1rem;
    margin-top: 0.25rem;
    color: var(--hl-accent, #cf2927);
}

.hl-placeholder {
    display: grid;
    gap: 0.35rem;
    padding: clamp(2rem, 5vw, 3.5rem);
    border: 1px dashed var(--hl-border, #e3e5f0);
    border-radius: var(--hl-radius-lg, 24px);
    background: var(--hl-bg-alt, #f6f7fc);
    text-align: center;
}
.hl-placeholder__label { margin: 0; font-weight: 700; }
.hl-placeholder__note { margin: 0; font-size: 0.875rem; color: var(--hl-text-muted, #5a5f7a); }

/* --- Carousel controls ----------------------------------------------------- */
.hl-carousel__controls { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1.5rem; }
.hl-carousel__btn {
    display: grid;
    place-items: center;
    width: 2.5rem; height: 2.5rem;
    background: var(--hl-surface, #fff);
    border: 1px solid var(--hl-border, #e3e5f0);
    border-radius: 50%;
    color: var(--hl-text, #12142e);
    transition: background-color 180ms ease, transform 180ms ease;
}
.hl-carousel__btn:hover { background: var(--hl-primary, #2a2d7c); color: #fff; transform: translateY(-1px); }
.hl-carousel__btn[disabled] { opacity: 0.4; pointer-events: none; }
