/* ============================================================
   players.css: seats around the table, avatars, revolvers
   ============================================================ */

.seat {
    /* how the plate hangs off its ring point. Every transform below goes
       through this so the anchor stays consistent through the animations. */
    --anchor-y: -50%;

    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    /*
     * Sized from the table, not from the viewport. A fixed width looks right
     * on a big board and enormous on a small one, and once a plate is wide
     * relative to the table the diagonal seats start clipping the suit
     * medallion. cqw resolves against #seats, which is the table's box.
     */
    width: clamp(112px, 30cqw, 202px);
    transform: translate(-50%, var(--anchor-y));
    pointer-events: auto;
    animation: seatIn .4s var(--ease-out) backwards;
    animation-delay: var(--seat-delay, 0ms);
    transition: opacity var(--t-slow), filter var(--t-slow);
}

/* the seat at the head of the table sits fully above its point, so it cannot
   hang down onto the suit medallion however tall the plate or small the table */
.seat--anchor-top {
    --anchor-y: -100%;
}

/*
 * A crowded ring needs narrower plates. Seven opponents at the full 202px
 * would collide with each other along the top of the table, so the plates
 * step down and the mini card fans drop away at the top end, where they are
 * the first thing you stop being able to read anyway.
 */
#seats[data-count="5"] .seat,
#seats[data-count="6"] .seat {
    width: clamp(104px, 25cqw, 168px);
}

#seats[data-count="7"] .seat {
    width: clamp(96px, 22cqw, 150px);
}

#seats[data-count="6"] .seat__avatar,
#seats[data-count="7"] .seat__avatar {
    width: 32px;
    height: 32px;
    font-size: 16px;
}

#seats[data-count="7"] .seat__cards {
    display: none;
}

/* keeps the -50%/-50% centring intact while fading in */
@keyframes seatIn {
    from {
        opacity: 0;
        transform: translate(-50%, calc(var(--anchor-y) + 14px));
    }
}

/* ---------------- Mini card fan ---------------- */

.seat__cards {
    position: relative;
    display: flex;
    justify-content: center;
    height: var(--card-h-mini);
    width: 100%;
}

.seat__cards .card {
    position: absolute;
    top: 0;
    left: 50%;
    transform-origin: 50% 130%;
    transition: transform var(--t-med) var(--ease-back), opacity var(--t-med);
    /* fade only: the fan position lives in an inline transform */
    animation: fadeIn .3s var(--ease-out) backwards;
}

.seat__cards--empty::after {
    content: 'no cards';
    display: grid;
    place-items: center;
    width: 100%;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--text-faint);
    opacity: .6;
}

/* ---------------- Name plate ---------------- */

/* A nameplate cut into the plate: flat field, ruled edge, hard offset. */
.seat__plate {
    position: relative;
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 7px 12px 7px 7px;
    background-color: var(--ink-850);
    background-image: var(--hatch-fine);
    border: 1px solid var(--rule);
    border-radius: var(--r-sm);
    box-shadow: var(--sh-2);
    transition: border-color var(--t-med), background-color var(--t-med);
}

/* Monogram struck into an inked tile. */
.seat__avatar {
    position: relative;
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    flex: none;
    font-family: var(--font-engraved);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: .04em;
    color: #0a0908;
    background: var(--seat-color, var(--gold));
    border-radius: 0;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .35);
}

.seat__host-mark {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 13px;
    height: 13px;
    color: var(--gold-hot);
}

.seat__meta {
    min-width: 0;
    flex: 1;
    text-align: left;
}

.seat__name {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------------- Revolver chambers ---------------- */

.revolver {
    display: flex;
    align-items: center;
    gap: 3px;
    margin-top: 3px;
}

.chamber {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: transparent;
    box-shadow: inset 0 0 0 1px var(--rule);
    transition: background var(--t-med), box-shadow var(--t-med);
}

/* a loaded chamber is filled in; a spent one is struck through and empty */
.chamber.is-loaded {
    background: var(--gold);
    box-shadow: inset 0 0 0 1px var(--gold-deep);
}

.chamber.is-spent {
    background: transparent;
    box-shadow: inset 0 0 0 1px var(--rule-faint);
    opacity: .5;
}

.revolver__count {
    margin-left: 5px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-faint);
}

/* ---------------- Active turn state ---------------- */

.seat.is-turn .seat__plate {
    background-color: var(--ink-700);
    border-color: var(--seat-color, var(--gold));
    box-shadow: var(--sh-2);
    animation: plateSweep 2.4s var(--ease-in-out) infinite;
}

/*
 * The active seat gets a rule that travels along the bottom of the plate. It
 * was a soft gradient sweep; it is now a solid cut bar that slides, which is
 * both hard-edged and cheaper (transform instead of background-position).
 */
/*
 * The active plate is marked by its border alone, which is the only way to
 * guarantee the same weight on all four sides.
 *
 * There used to be a bar travelling along the bottom edge to carry the motion.
 * Whatever its height, it sat on one edge and not the other three, so the
 * rectangle never read as evenly ruled. The pulse now runs on border-color, so
 * the whole frame brightens together and the thickness never changes at all.
 * Do not reintroduce an edge-specific pseudo-element here.
 */
@keyframes plateSweep {

    0%,
    100% {
        border-color: color-mix(in srgb, var(--seat-color, var(--gold)) 55%, transparent);
    }

    50% {
        border-color: var(--seat-color, var(--gold));
    }
}

.seat.is-turn .seat__name {
    color: var(--seat-color, var(--gold));
}

/* ---------------- Eliminated ---------------- */

.seat.is-out {
    opacity: .32;
    filter: grayscale(1);
}

.seat.is-out .seat__plate::after {
    content: 'OUT';
    margin-left: auto;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .14em;
    color: var(--oxblood-hot);
}

.seat.is-dying {
    animation: seatDie .8s var(--ease-out) both;
}

@keyframes seatDie {
    0% {
        filter: brightness(1);
    }

    18% {
        filter: brightness(2.4) saturate(0);
        transform: translate(-50%, var(--anchor-y)) scale(1.06);
    }

    100% {
        filter: grayscale(1) brightness(.7);
        opacity: .32;
    }
}

/* ---------------- Self plate (your own status, in the dock) ---------------- */

.self-plate {
    position: absolute;
    left: var(--sp-5);
    bottom: max(var(--sp-5), env(safe-area-inset-bottom));
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px 8px 8px;
    background-color: var(--ink-850);
    background-image: var(--hatch-fine);
    border: 1px solid var(--rule);
    border-radius: var(--r-sm);
    box-shadow: var(--sh-2);
    z-index: 26;
    transition: border-color var(--t-med), background-color var(--t-med);
}

.self-plate.is-turn {
    border-color: var(--rule-strong);
    background-color: var(--ink-700);
}

/*
 * Your own plate is dimmed rather than gutted. The seats can drop to .32 and
 * grey out because they are only a tally of who is left; this one still has to
 * be read, so it keeps its contrast and takes the oxblood edge instead.
 */
.self-plate.is-out {
    border-color: var(--oxblood-hot);
    filter: grayscale(1);
    opacity: .66;
}

.self-plate.is-dying {
    animation: selfPlateDie .8s var(--ease-out) both;
}

@keyframes selfPlateDie {
    0% {
        filter: brightness(1);
    }

    18% {
        filter: brightness(2.4) saturate(0);
        transform: translateY(-3px) scale(1.04);
    }

    100% {
        filter: grayscale(1) brightness(.7);
        opacity: .66;
    }
}

.self-plate .seat__avatar {
    width: 42px;
    height: 42px;
    font-size: 23px;
}

.self-plate__name {
    font-size: 15px;
    font-weight: 700;
}

.self-plate__label {
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--text-faint);
}

/* ---------------- Tooltips ---------------- */

.has-tip {
    position: relative;
}

.has-tip::after {
    content: attr(data-tip);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 8px);
    transform: translateX(-50%) translateY(4px);
    padding: 6px 11px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    color: var(--text);
    background: var(--ink-800);
    border: 1px solid var(--rule);
    border-radius: 0;
    box-shadow: var(--sh-2);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--t-fast), transform var(--t-fast);
    z-index: 60;
}

.has-tip:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

@media (hover: none) {
    .has-tip::after {
        display: none;
    }
}

/* ---------------- Out of contact ---------------- */

/*
 * Away is not out. The seat is still theirs, the hand is still dealt, and the
 * game will wait: what this has to say is "nothing is happening here yet",
 * without borrowing any of the marks that mean eliminated. So it dims and it
 * hatches — no grayscale, no struck rule, no OUT — and the label spells the
 * rest out rather than leaving the table to guess at a stalled turn.
 */
.seat.is-away .seat__plate {
    opacity: .55;
    background-image: var(--hatch-fine);
}

.seat.is-away .seat__cards {
    opacity: .4;
}

.seat__away {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--text-dim);
}

/* an away player is still on the clock, but their turn ring shouldn't read as
   attention: it is waiting on a phone, not on a decision */
.seat.is-away.is-turn .seat__plate {
    border-color: var(--rule-faint);
}
