/* Cards you can use right now (handplay.js; the server's usable list).
   "play": the card's own ability — a warm gold edge that runs round the
   card, a soft breathing halo and a small lift (Talisman DE style).
   "number": a Power card's number standing in for a die — a quiet dashed
   line, since any Power card can do that whenever a die is due.
   Reduced motion: a static gold outline, no lift. */

@property --use-ang {
    syntax: "<angle>";
    inherits: false;
    initial-value: 0deg;
}

:root {
    --use-edge: #fff0bf;
    --use-glow: #f5c04a;
    --use-halo: rgba(245, 180, 60, 0.55);
    --use-halo-far: rgba(255, 150, 40, 0.22);
    --use-tag-bg: #f5c04a;
    --use-tag-ink: #2a1c02;
    --use-number: rgba(242, 201, 76, 0.8);
}

@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) {
        --use-edge: #ffe08a;
        --use-glow: #c98410;
        --use-halo: rgba(201, 132, 16, 0.5);
        --use-halo-far: rgba(214, 120, 10, 0.2);
        --use-tag-bg: #b8740a;
        --use-tag-ink: #fff8e8;
        --use-number: rgba(150, 100, 10, 0.85);
    }
}

:root[data-theme="light"] {
    --use-edge: #ffe08a;
    --use-glow: #c98410;
    --use-halo: rgba(201, 132, 16, 0.5);
    --use-halo-far: rgba(214, 120, 10, 0.2);
    --use-tag-bg: #b8740a;
    --use-tag-ink: #fff8e8;
    --use-number: rgba(150, 100, 10, 0.85);
}

/* --- Ability: glowing --- */

.choice-card.is-usable,
.choice-option.is-usable,
.choice-extra.is-usable,
.combat-opt.is-usable { position: relative; }

/* Character abilities (no card) are buttons that glow the same way. */
.hud .hud-card.is-usable--play,
.combat-card.is-usable--play,
.combat-opt.is-usable--play,
.choice-card.is-usable--play,
.choice-option.is-usable--play,
.choice-extra.is-usable--play {
    border-color: var(--use-glow);
    animation: use-breathe 2.4s ease-in-out infinite;
    transform: translateY(-0.125rem);
}

/* The running edge: a conic gradient masked to a 2 px ring. */
.hud .hud-card.is-usable--play::before,
.combat-card.is-usable--play::before,
.combat-opt.is-usable--play::before,
.choice-card.is-usable--play::before,
.choice-option.is-usable--play::before,
.choice-extra.is-usable--play::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 4;
    padding: 2px;
    border-radius: inherit;
    background: conic-gradient(from var(--use-ang),
        var(--use-edge) 0deg, var(--use-glow) 50deg, rgba(245, 192, 74, 0.25) 130deg,
        rgba(245, 192, 74, 0.25) 230deg, var(--use-glow) 310deg, var(--use-edge) 360deg);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    mask-composite: exclude;
    pointer-events: none;
    animation: use-run 3.2s linear infinite;
}

@keyframes use-run { to { --use-ang: 360deg; } }

@keyframes use-breathe {
    0%, 100% { box-shadow: 0 0 0 1px var(--use-glow), 0 0 0.375rem var(--use-halo), 0 0 0.875rem var(--use-halo-far); }
    50% { box-shadow: 0 0 0 1px var(--use-edge), 0 0 0.625rem var(--use-halo), 0 0 1.5rem var(--use-halo-far); }
}

.hud .hud-card.is-usable--play:hover,
.hud .hud-card.is-usable--play:focus-visible,
.combat-card.is-usable--play:hover,
.combat-card.is-usable--play:focus-visible {
    transform: translateY(-0.25rem);
}

/* A small tag says what a click does (the panel's thumbnails only). */
.hud .hud-card.is-usable--play::after {
    content: attr(data-usable-tag);
    position: absolute;
    left: 50%;
    bottom: 0.1875rem;
    transform: translateX(-50%);
    z-index: 5;
    padding: 0 0.3rem;
    border-radius: 0.5rem;
    background: var(--use-tag-bg);
    color: var(--use-tag-ink);
    font-size: 0.55rem;
    font-weight: 800;
    line-height: 1.45;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    box-shadow: 0 1px 0.25rem rgba(0, 0, 0, 0.45);
    pointer-events: none;
}
/* Charge pips sit at the foot: the tag goes above them. */
.hud .hud-card.is-usable--play:has(.hud-charges)::after { bottom: 0.875rem; }

/* Face-up Corruption cards are chips in the panel. */
.hud .hud-chip.is-usable--play {
    cursor: pointer;
    border-color: var(--use-glow);
    animation: use-breathe 2.4s ease-in-out infinite;
}

/* The slim bar's counters say a card in that row can be used. */
.hud .is-usable-count { border-radius: 0.375rem; animation: use-breathe 2.4s ease-in-out infinite; }

/* --- Number: quiet --- */

.hud .hud-card.is-usable--number,
.combat-card.is-usable--number,
.choice-card.is-usable--number {
    outline: 1px dashed var(--use-number);
    outline-offset: -0.1875rem;
}

/* A card with several uses: its options are pointed at. */
.is-pointed { animation: use-bump 0.5s ease 2; }
@keyframes use-bump { 50% { transform: translateY(-0.375rem); } }

@media (prefers-reduced-motion: reduce) {
    .hud .hud-card.is-usable--play,
    .combat-card.is-usable--play,
    .combat-opt.is-usable--play,
    .choice-card.is-usable--play,
    .choice-option.is-usable--play,
    .choice-extra.is-usable--play,
    .hud .hud-chip.is-usable--play,
    .hud .is-usable-count {
        animation: none;
        transform: none;
        box-shadow: 0 0 0 2px var(--use-glow), 0 0 0.5rem var(--use-halo);
    }
    .hud .hud-card.is-usable--play::before,
    .combat-card.is-usable--play::before,
    .combat-opt.is-usable--play::before,
    .choice-card.is-usable--play::before,
    .choice-option.is-usable--play::before,
    .choice-extra.is-usable--play::before {
        animation: none;
        background: var(--use-edge);
    }
    .is-pointed { animation: none; outline: 2px solid var(--use-glow); }
}
