/*
 * Primary action button: the only place its look lives.
 * Use class="button" (any element); <button class="submit"> gets the same style.
 * The running light is drawn by ::before alone, so no inner markup is needed
 * (the older .dots_border / .text_button children still work).
 */

.button,
button.submit {
    position: relative;
    cursor: pointer;
    border: none;
    background: var(--primary-color);
    color: var(--text-color);
    transition: transform .3s ease-in-out, color .3s ease-in-out, background-color .3s ease-in-out;
}

/* button.submit keeps the size and corners its page already gives it. */
.button {
    padding: 1rem 2rem;
    border-radius: 7px;
}

/* Any other clickable element already painted in the primary colour gets the same ring; :where() keeps its own positioning in charge. */
:where(a[href], button, [onclick]):where([style*="background:var(--primary-color)"], [style*="background: var(--primary-color)"], [class*="bg-[var(--primary-color)]"], .clock-menu *) {
    position: relative;
}

/* Light in the primary colour on a 2px ring hugging the button: a box-shadow spread, so its corners are exactly concentric with the button's. The SVG mask's dashes travel the perimeter at a constant speed. */
.button::before,
button.submit::before,
:where(a[href], button, [onclick]):where([style*="background:var(--primary-color)"], [style*="background: var(--primary-color)"], [class*="bg-[var(--primary-color)]"], .clock-menu *)::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    box-shadow: 0 0 0 2px var(--primary-solid, var(--primary-color));
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3Cstyle%3Erect%7Banimation:m 3s linear infinite%7D@keyframes m%7Bto%7Bstroke-dashoffset:-1%7D%7D%3C/style%3E%3Cfilter id='b'%3E%3CfeGaussianBlur stdDeviation='3'/%3E%3C/filter%3E%3Cg fill='none' stroke='%23000' stroke-width='20' filter='url(%23b)'%3E%3Crect width='100%25' height='100%25' rx='8' pathLength='1' stroke-dasharray='.3 .7' stroke-opacity='.3'/%3E%3Crect width='100%25' height='100%25' rx='8' pathLength='1' stroke-dasharray='.2 .8' stroke-opacity='.4' style='animation-delay:-.3s'/%3E%3Crect width='100%25' height='100%25' rx='8' pathLength='1' stroke-dasharray='.1 .9' style='animation-delay:-.6s'/%3E%3C/g%3E%3C/svg%3E") -2px -2px / calc(100% + 4px) calc(100% + 4px) no-repeat no-clip;
    pointer-events: none;
}

/* Hover swaps to the page background; the label turns primary, pulled toward the theme's text colour so it stays readable on light and dark pages. */
.button:hover:not(:disabled),
.button:focus-visible,
button.submit:hover:not(:disabled),
button.submit:focus-visible {
    background: var(--background-color);
    color: var(--primary-solid, var(--primary-color));
    color: color-mix(in srgb, var(--primary-solid, var(--primary-color)) 60%, var(--background-color-text));
}

.button:active:not(:disabled),
button.submit:active:not(:disabled) {
    transform: scale(.97);
}

.button:disabled,
button.submit:disabled {
    background: rgba(140, 140, 140, .18);
    color: var(--background-color-text);
    opacity: .7;
    cursor: not-allowed;
}

.button:disabled::before,
button.submit:disabled::before,
:where(a[href], button, [onclick]):where([style*="background:var(--primary-color)"], [style*="background: var(--primary-color)"], [class*="bg-[var(--primary-color)]"], .clock-menu *):disabled::before {
    display: none;
}

.button .dots_border {
    display: none;
}

.button .text_button {
    position: relative;
    color: inherit;
}

@media (prefers-reduced-motion: reduce) {
    .button::before,
    button.submit::before,
    :where(a[href], button, [onclick]):where([style*="background:var(--primary-color)"], [style*="background: var(--primary-color)"], [class*="bg-[var(--primary-color)]"], .clock-menu *)::before {
        display: none;
    }
}
