/*
 * The Swift Galleries loading mark pulses as one composited element. Keep the SVG's paint
 * properties fixed: animating fill/fill-opacity on every tile causes continuous style and paint
 * work in large photo lists. The HTML wrapper animates opacity only; no forced GPU layers.
 * Colours remain the logo's own colours, or white on coloured surfaces with a pink accent.
 *
 * Markup always comes from one of these helpers (they output the same SVG):
 *   Twig   {% import "@UI/Loaders/spinner.html.twig" as loader %}  {{ loader.spinner({ size: 'md' }) }}
 *   jQuery $.ui.util.spinnerHtml({ size: 'sm', label: false })      (src/Swift/UIBundle/.../js/ui.util.js)
 *   React  <SimpleLoader />                                          (assets/js/Designer/components/Loaders)
 *
 * Sizes follow the font size: the mark is 1em tall and 1.894em wide. Use the modifiers below, or set
 * font-size on the wrapper (or anything around it) yourself:
 *   .sp-wave--sm  15px  inline, next to text and inside buttons
 *   .sp-wave--md  30px  in-app wait cards (the "Working on it" dialog, panels, upload tiles)
 *   .sp-wave--lg  44px  bare full-page loaders (the page preloader)
 *   .sp-wave--xl  56px  full-page loaders with a message (designer, in-person meeting)
 *
 * Loaded on every app page by base.html.twig, and compiled into the designer bundle by
 * assets/css/Designer/components/_spinner.scss (so keep this file plain CSS; rebuild the designer
 * with `npm run build` after editing). Not scoped to html.sg-modern: the designer uses it too.
 * The class names avoid .circular and .path (Material spinners.css animates those globally) and
 * Spectrum's .sp-* names (.sp-hidden, .sp-container...): everything here starts with .sp-wave.
 */

:root {
    /* Lit colour of the left tiles / the tall middle tile / the right tiles (the colour logo). */
    --sp-c1: #97abb7;
    --sp-c2: #59798c;
    --sp-c3: #30586f;
    /* The accent tile (bottom right) lights in brand pink. */
    --sp-accent: #fc4b6c;
    --sp-dur: 1.8s;
    --sp-ease: ease-in-out;
}

/* ------------------------------------------------------------------ the spinner */

.sp-wave {
    display: inline-block;
    flex: none;
    width: 1.894em;
    height: 1em;
    overflow: visible;
    vertical-align: middle;
    animation: sp-pulse var(--sp-dur) var(--sp-ease) infinite;
}
.sp-wave > svg { display: block; width: 100%; height: 100%; }
.sp-wave path { fill: var(--lit); }
.sp-wave path:nth-child(1), .sp-wave path:nth-child(2) { --lit: var(--sp-c1); }
.sp-wave path:nth-child(3) { --lit: var(--sp-c2); }
.sp-wave path:nth-child(4), .sp-wave path:nth-child(5) { --lit: var(--sp-c3); }
.sp-wave path.is-accent { fill: var(--sp-accent); }

@keyframes sp-pulse {
    0%, 100% { opacity: .45; }
    50% { opacity: 1; }
}

/* Removing the animation also releases compositing resources for offscreen loaders. */
.sp-wave.is-paused, .sp-wave.is-still {
    animation: none;
    opacity: 1;
}
@media (prefers-reduced-motion: reduce) {
    :root .sp-wave {
        animation: none !important;
        opacity: 1;
    }
}

/* Sizes. */
.sp-wave--sm { font-size: 15px; }
.sp-wave--md { font-size: 30px; }
.sp-wave--lg { font-size: 44px; }
.sp-wave--xl { font-size: 56px; }

/* Wrapper for a spinner that stands alone: role="status" plus a visually hidden "Loading". */
.sp-wave-status { display: inline-flex; align-items: center; justify-content: center; line-height: 0; }
.sp-wave-label {
    position: absolute !important;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ------------------------------------------------------------------ on coloured surfaces */

/* White tiles stepped like the white logo on all coloured surfaces; the accent stays brand pink
   on dark surfaces and goes full white only inside filled buttons (pink would vanish on pink).
   Keyed off classes, never a fill colour, so it follows any primary colour.
   Add .sp-on-colour (or .on-colour) to any other dark or blue surface; these get it automatically:
   filled primary / destructive buttons, SweetAlert's confirm button, the designer's primary
   buttons and tiles (mixins button-primary / button-cta), the dark upload-tile scrim and the
   designer's zoom backdrop. */
.on-colour,
.sp-on-colour,
.btn-primary,
.btn-info,
.btn-success,
.btn-themecolor,
.btn-danger,
.swal2-styled.swal2-confirm,
.dz-btn.dz-btn-primary,
.dz-btn-primary-like,
.show-colored-designer-button,
.custom-control-button.dz-tile-primary,
.custom-control-button.dz-tile-cta,
.color-apply-button,
.choose-this-upload-button,
.dropzone-spinner-container,
.yarl__container {
    --sp-c1: rgba(255, 255, 255, .5);
    --sp-c2: rgba(255, 255, 255, .8);
    --sp-c3: #fff;
}

.btn-primary,
.btn-info,
.btn-success,
.btn-themecolor,
.btn-danger,
.swal2-styled.swal2-confirm,
.dz-btn.dz-btn-primary,
.dz-btn-primary-like,
.show-colored-designer-button,
.custom-control-button.dz-tile-primary,
.custom-control-button.dz-tile-cta,
.color-apply-button,
.choose-this-upload-button {
    --sp-accent: #fff;
}

/* ------------------------------------------------------------------ where the app uses it */

/* Page preloader (base.html.twig, checkout, onboarding wizard, phone room upload). The wrapper
   stays .preloader: Material custom.min.js fades it out and ui.js waits for it to go. Centred
   absolutely because spinners.css gives .preloader a full-width :before spacer. */
.preloader > .sp-wave-status {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* "Working on it..." ($.ui.util.showLoader): SweetAlert2 hosts it; the mark replaces the info icon
   and SweetAlert's own loading ring (its hidden confirm button). Scoped to .sp-wave-modal, which
   SweetAlert resets on every swal() call, so a dialog that replaces the loader never shows the mark. */
.swal2-modal .sp-wave-swal { display: none; }
.swal2-modal.sp-wave-modal .sp-wave-swal { display: block; margin: 8px auto 18px; line-height: 0; text-align: center; }
.swal2-modal.sp-wave-modal .swal2-buttonswrapper { display: none !important; }
.swal2-modal.sp-wave-modal .swal2-title { margin-bottom: 6px; }

/* Photo upload tiles: "Processing..." over each file while the server works on it. */
.dropzone-spinner-container > .sp-wave {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -70%);
}

/* x-editable inline edits (order custom items) while they save. Its own stylesheet (a loading.gif)
   is never loaded, so this is the only look the saving state has. */
.editableform-loading { display: inline-flex; align-items: center; justify-content: center; min-height: 32px; padding: 0 4px; }

/* PhotoSwipe's preloader slot (turned off in ui.util.photoswipe.js; shown only if it is enabled). */
.pswp__preloader > .sp-wave-status {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}
