/*
 * Boutons de lancement uniquement : adaptation de « Shiny call-to-action button ».
 * https://codepen.io/hexagoncircle/pen/MWMqXbK
 *
 * The MIT License (MIT)
 * Copyright (c) 2026 Ryan Mulligan (https://codepen.io/hexagoncircle/pen/MWMqXbK)
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

@property --biw-launch-angle {
  syntax: "<angle>";
  initial-value: 0deg;
  inherits: true;
}

@property --biw-launch-offset {
  syntax: "<angle>";
  initial-value: 0deg;
  inherits: false;
}

@property --biw-launch-percent {
  syntax: "<percentage>";
  initial-value: 5%;
  inherits: false;
}

@media screen {
  /* La classe explicite et l'identifiant excluent les autres actions primaires. */
  html[data-seo-style] body[class]:not(.page-admin) > main[class] #runBtn.primary.app-launch-button {
    --biw-launch-bg: #090c18;
    --biw-launch-highlight: var(--suite-style-accent, #8484ff);
    --biw-launch-offset: 0deg;
    --biw-launch-percent: 5%;
    isolation: isolate;
    position: relative;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    min-width: 0;
    min-height: 46px;
    max-width: 100%;
    padding: 0.9rem 1.6rem;
    border: 1px solid transparent;
    border-radius: 999px;
    color: #fff;
    background: linear-gradient(var(--biw-launch-bg), var(--biw-launch-bg)) padding-box,
      conic-gradient(from calc(var(--biw-launch-angle) - var(--biw-launch-offset)),
        #34384c, var(--biw-launch-highlight) var(--biw-launch-percent),
        #fff calc(var(--biw-launch-percent) * 2),
        var(--biw-launch-highlight) calc(var(--biw-launch-percent) * 3),
        #34384c calc(var(--biw-launch-percent) * 4)) border-box;
    box-shadow: inset 0 0 0 1px #1a2032;
    font-family: inherit;
    line-height: 1.4;
    text-align: center;
    text-shadow: none;
    white-space: normal;
    overflow-wrap: anywhere;
    transform: none;
    filter: none;
    outline-offset: 4px;
    animation: biw-launch-angle 3s linear infinite;
    transition: --biw-launch-offset 800ms cubic-bezier(0.25, 1, 0.5, 1),
      --biw-launch-percent 800ms cubic-bezier(0.25, 1, 0.5, 1), box-shadow 250ms ease;
  }

  html[data-seo-style] body[class]:not(.page-admin) > main[class] #runBtn.primary.app-launch-button > * {
    position: relative;
    z-index: 1;
    min-width: 0;
    color: inherit;
  }

  html[data-seo-style] body[class]:not(.page-admin) > main[class] #runBtn.primary.app-launch-button::before,
  html[data-seo-style] body[class]:not(.page-admin) > main[class] #runBtn.primary.app-launch-button::after {
    all: unset;
    content: "";
    box-sizing: border-box;
    pointer-events: none;
    position: absolute;
    left: 50%;
    top: 50%;
    translate: -50% -50%;
    z-index: -1;
  }

  html[data-seo-style] body[class]:not(.page-admin) > main[class] #runBtn.primary.app-launch-button::before {
    width: calc(100% - 6px);
    height: calc(100% - 6px);
    background: radial-gradient(circle at 2px 2px, #fff 0.5px, transparent 0) 0 0 / 4px 4px;
    mask-image: conic-gradient(from calc(var(--biw-launch-angle) + 45deg), #000, transparent 10% 90%, #000);
    border-radius: inherit;
    opacity: 0.4;
  }

  html[data-seo-style] body[class]:not(.page-admin) > main[class] #runBtn.primary.app-launch-button::after {
    width: 100%;
    aspect-ratio: 1;
    background: linear-gradient(-50deg, transparent, var(--biw-launch-highlight), transparent);
    mask-image: radial-gradient(circle at bottom, transparent 40%, #000);
    opacity: 0.35;
    animation: biw-launch-shimmer 3s linear infinite;
  }

  html[data-seo-style] body[class]:not(.page-admin) > main[class] #runBtn.primary.app-launch-button:where(:not(:disabled, [aria-disabled="true"], [aria-busy="true"])):is(:hover, :focus-visible) {
    --biw-launch-offset: 95deg;
    --biw-launch-percent: 20%;
    box-shadow: inset 0 0 24px -12px var(--biw-launch-highlight), 0 4px 18px #090c1833;
  }

  html[data-seo-style] body[class]:not(.page-admin) > main[class] #runBtn.primary.app-launch-button:focus-visible {
    outline: 3px solid var(--biw-launch-highlight);
  }

  /* Audit et crawl remplacent leur texte pendant le traitement : garder leur loupe CSS. */
  html[data-seo-style] body:is(.app-one-page, .app-crawl):not(.page-admin) > main[class] #runBtn.primary.app-launch-button::before {
    position: static;
    flex-shrink: 0;
    width: 0.82rem;
    height: 0.82rem;
    border: 2px solid currentColor;
    border-radius: 50%;
    background: none;
    mask-image: none;
    box-shadow: 0.33rem 0.33rem 0 -0.24rem currentColor;
    opacity: 1;
    translate: none;
    z-index: 1;
  }

  html[data-seo-style] body[class]:not(.page-admin) > main[class] #runBtn.primary.app-launch-button:is(:disabled, [aria-disabled="true"], [aria-busy="true"]) {
    color: #d4d8e4;
    border-color: #50556b;
    background: #171c2c;
    box-shadow: none;
    opacity: 0.8;
    cursor: not-allowed;
    animation: none;
    transition: none;
  }

  html[data-seo-style] body[class]:not(.page-admin) > main[class] #runBtn.primary.app-launch-button:is(:disabled, [aria-disabled="true"], [aria-busy="true"])::before,
  html[data-seo-style] body[class]:not(.page-admin) > main[class] #runBtn.primary.app-launch-button:is(:disabled, [aria-disabled="true"], [aria-busy="true"])::after {
    content: none;
    animation: none;
  }
}

@keyframes biw-launch-angle {
  to { --biw-launch-angle: 360deg; }
}

@keyframes biw-launch-shimmer {
  to { rotate: 360deg; }
}

@media screen and (prefers-reduced-motion: reduce) {
  html[data-seo-style] body[class]:not(.page-admin) > main[class] #runBtn.primary.app-launch-button,
  html[data-seo-style] body[class]:not(.page-admin) > main[class] #runBtn.primary.app-launch-button::before,
  html[data-seo-style] body[class]:not(.page-admin) > main[class] #runBtn.primary.app-launch-button::after {
    animation: none !important;
    transition: none !important;
  }
}

@media screen and (forced-colors: active) {
  html[data-seo-style] body[class]:not(.page-admin) > main[class] #runBtn.primary.app-launch-button {
    border-color: ButtonText;
    color: ButtonText;
    background: ButtonFace;
    animation: none;
  }

  html[data-seo-style] body[class]:not(.page-admin) > main[class] #runBtn.primary.app-launch-button:focus-visible {
    outline-color: Highlight;
  }

  html[data-seo-style] body[class]:not(.page-admin) > main[class] #runBtn.primary.app-launch-button::before,
  html[data-seo-style] body[class]:not(.page-admin) > main[class] #runBtn.primary.app-launch-button::after {
    content: none;
    animation: none;
  }
}
