﻿
/* ── Register the animatable custom property ── */
@property --border-angle {
    syntax: "<angle>";
    inherits: false;
    initial-value: 0turn;
}

/* ────────────────────────────────────────────
   Auto-contrast tints derived from body-bg.
   Light theme  → slightly darker grey tint
   Dark  theme  → slightly lighter grey tint
   We use color-mix() against the Bootstrap
   body-bg variable so it adapts automatically.
──────────────────────────────────────────── */
:root,
[data-bs-theme="light"] {
    --clay-btn-bg: color-mix(in srgb, var(--bs-body-bg) 85%, #000 15%);
    --clay-btn-border: color-mix(in srgb, var(--bs-body-bg) 70%, #000 30%);
    --clay-btn-text: color-mix(in srgb, var(--bs-body-bg) 5%, #000 95%);
    /* silver sweep stops */
    --sweep-dim: color-mix(in srgb, var(--bs-body-bg) 40%, #000 60%);
    --sweep-mid: color-mix(in srgb, var(--bs-body-bg) 20%, #888 80%);
    --sweep-peak: #ffffff;
}

[data-bs-theme="dark"] {
    --clay-btn-bg: color-mix(in srgb, var(--bs-body-bg) 85%, #fff 15%);
    --clay-btn-bg: color-mix(in srgb, var(--bs-body-bg) 85%, #ffffff60 15%);
    --clay-btn-border: color-mix(in srgb, var(--bs-body-bg) 60%, #fff 40%);
    --clay-btn-text: color-mix(in srgb, var(--bs-body-bg) 5%, #fff 95%);
    --sweep-dim: color-mix(in srgb, var(--bs-body-bg) 40%, #fff 60%);
    --sweep-mid: color-mix(in srgb, var(--bs-body-bg) 10%, #aaa 90%);
    --sweep-peak: #ffffff;
}

/* ── Base button reset ── */
.btn-clay {
    --border-size: 2px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45em;
    padding: .5rem 1.25rem;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    font-size: .9rem;
    font-weight: 500;
    letter-spacing: .02em;
    color: var(--clay-btn-text);
    text-decoration: none;
    position: relative;
    transition: box-shadow .2s ease, color .2s ease;
    /* ── Neumorphic shadow (light/dark aware) ── */
    box-shadow: 3px 3px 7px color-mix(in srgb, var(--bs-body-bg) 55%, #000 45%), -3px -3px 7px color-mix(in srgb, var(--bs-body-bg) 55%, #fff 45%);
    /* ── Two-layer background:
       top  → solid tinted fill (inset by border-size)
       bottom → conic sweep that forms the border ring ── */
    background-image: conic-gradient(from var(--border-angle), var(--clay-btn-bg) 0%, var(--clay-btn-bg) 100% ), conic-gradient(from var(--border-angle), transparent 70%, transparent 72%, var(--sweep-dim) 80%, var(--sweep-mid) 88%, var(--sweep-peak)93%, var(--sweep-mid) 98%, transparent 100% );
    background-size: calc(100% - var(--border-size) * 2) calc(100% - var(--border-size) * 2), cover;
    background-position: center center;
    background-repeat: no-repeat;
    animation: clay-sweep 5s linear infinite;
}

    .btn-clay:hover,
    .btn-clay:focus-visible {
        color: var(--clay-btn-text);
        box-shadow: 4px 4px 10px color-mix(in srgb, var(--bs-body-bg) 50%, #000 50%), -4px -4px 10px color-mix(in srgb, var(--bs-body-bg) 50%, #fff 50%);
        animation-play-state: paused;
        outline: none;
    }

    .btn-clay:active {
        box-shadow: 1px 1px 3px color-mix(in srgb, var(--bs-body-bg) 55%, #000 45%), -1px -1px 3px color-mix(in srgb, var(--bs-body-bg) 55%, #fff 45%);
    }

/* ── Sweep keyframes: full spin in first 18%, idle rest of 5s ── */
@keyframes clay-sweep {
    0% {
        --border-angle: 0turn;
    }

    18% {
        --border-angle: 1turn;
    }

    18.01% {
        --border-angle: 0turn;
    }

    100% {
        --border-angle: 0turn;
    }
}

/* ── Size variants ── */
.btn-clay.btn-sm {
    padding: .35rem .9rem;
    font-size: .8rem;
    border-radius: 10px;
}

.btn-clay.btn-lg {
    padding: .7rem 1.8rem;
    font-size: 1rem;
    border-radius: 16px;
}

/* ── Stagger helpers so groups don't all pulse together ── */
.btn-clay:nth-child(2) {
    animation-delay: -1.5s;
}

.btn-clay:nth-child(3) {
    animation-delay: -3s;
}

.btn-clay:nth-child(4) {
    animation-delay: -4s;
}



.theme-toggle {
    position: fixed;
    top: 1rem;
    right: 1rem;
    font-size: .75rem;
}

.section-label {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .1em;
    opacity: .45;
    margin-bottom: .75rem;
}
