/* ==========================================================================
   Remi - only what the tarok styles have no shape for
   ==========================================================================
   Every remi page reuses the tarok markup (.tk, .tk-table, .tk-seat, .tk-card,
   .tk-prompt, .tk-result, .tk-sheet, .tarok-landing__*, .tk-board ...), so
   web/css/tarok.css does the styling and a tarok restyle reaches remi as well.
   This file adds the remi-only furniture - the stock and discard piles, the
   melds on the table, the staging tray, the move log - using the same --tk-*
   tokens so the felt colour, card size and dark mode all follow.
   ========================================================================== */

/* The remi faces are 300x420 (poker ratio 0.714), not the 0.593 tarok scans. Derive the
   width from the S/M/L height the reader picked, exactly like the tarok rule does. Must
   come after tarok.css's [data-card-size] rules - same specificity, so load order decides. */
.tk[data-card-art="remi"] {
    --tk-card-w-base: calc(var(--tk-card-h-base) * 0.714);
}

/* ----- Felt centre ------------------------------------------------------ */

.rm-center {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    color: #fff;
}

.rm-center__top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 1.25rem 2rem;
}

.rm-piles {
    display: flex;
    gap: 1rem;
}

.rm-pile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    background: none;
    border: 0;
    padding: 0.35rem;
    border-radius: 0.6rem;
    color: rgba(255, 255, 255, 0.85);
}

.rm-pile:disabled { cursor: default; }

.rm-pile__label {
    font-size: 0.75rem;
    white-space: nowrap;
}

.rm-pile--live { cursor: pointer; }

.rm-pile--live .tk-card {
    box-shadow: 0 0 0 3px var(--tk-tarok), 0 6px 14px rgba(0, 0, 0, 0.4);
}

@media (hover: hover) {
    .rm-pile--live:hover .tk-card { transform: translateY(-0.4rem); }
}

.rm-card-empty {
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.7);
    background: transparent;
    border: 2px dashed rgba(255, 255, 255, 0.35);
    box-shadow: none;
}

.rm-turn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    max-width: 24rem;
    text-align: center;
}

.rm-turn__round {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.rm-turn__hint {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.8);
}

/* ----- Move log ---------------------------------------------------------- */

.rm-log {
    text-align: center;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.65);
}

.rm-log__line--last {
    color: #fff;
    font-weight: 600;
}

/* ----- Melds on the table ------------------------------------------------ */

.rm-melds {
    align-self: stretch;
    background: rgba(0, 0, 0, 0.14);
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
}

/* Below the felt (finished round) the melds sit on the page, not the felt. */
.tk-felt-wrap > #tk-root > .rm-melds {
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
}

.rm-melds__title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    opacity: 0.8;
    margin-bottom: 0.5rem;
}

.rm-melds__empty { font-size: 0.85rem; opacity: 0.75; }
.rm-melds__group + .rm-melds__group { margin-top: 0.6rem; }
.rm-melds__owner { font-size: 0.8rem; opacity: 0.85; margin-bottom: 0.25rem; }

.rm-melds__row,
.rm-staged {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.rm-meld {
    display: inline-flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.12);
    border: 2px solid transparent;
    border-radius: 0.5rem;
    padding: 0.3rem;
    color: inherit;
}

.rm-meld .tk-card + .tk-card { margin-left: calc(var(--tk-card-w) * -0.45); }
.rm-meld:disabled { cursor: default; }

.rm-meld--target {
    cursor: pointer;
    border-color: rgba(212, 175, 55, 0.55);
}

.rm-meld--target:hover {
    border-color: var(--tk-tarok);
    background: rgba(212, 175, 55, 0.15);
}

.rm-meld__pts {
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 0.5rem;
    white-space: nowrap;
}

/* ----- Staging tray (inside the tarok prompt panel) ----------------------- */

.rm-prompt {
    align-self: center;
    max-width: 100%;
    color: var(--text-primary);
}
.rm-staged { margin-bottom: 0.75rem; }

.rm-meld--staged {
    cursor: pointer;
    background: var(--bg-primary);
    border-color: var(--border-default);
}

.rm-meld--bad { border-color: var(--color-danger-500, #dc3545); }

/* ----- Hand ------------------------------------------------------------- */

/* The just-taken discard, so it is easy to spot in the fan. */
.rm-card--taken { outline: 3px solid var(--tk-tarok); outline-offset: 1px; }
.rm-card--dragging { opacity: 0.4; }

.rm-hand-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.25rem 0.75rem;
}

.rm-hand-tools .btn-link { padding: 0; font-size: 0.8rem; }

/* ----- Result ------------------------------------------------------------ */

.rm-result__hands {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin: 0.75rem 0;
}

.rm-result__row {
    display: grid;
    grid-template-columns: minmax(7rem, 10rem) 1fr auto;
    align-items: center;
    gap: 0.75rem;
    padding: 0.35rem 0.5rem;
    border-radius: 0.5rem;
}

.rm-result__row--winner { background: rgba(22, 163, 74, 0.1); }

.rm-result__who {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 600;
    min-width: 0;
}

.rm-result__cards {
    display: flex;
    flex-wrap: wrap;
}

.rm-result__cards .tk-card + .tk-card { margin-left: calc(var(--tk-card-w) * -0.5); }

.rm-result__pen {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

@media (max-width: 575.98px) {
    .rm-result__row { grid-template-columns: 1fr auto; }
    .rm-result__cards { grid-column: 1 / -1; order: 3; }
}

/* ----- Landing hero fan --------------------------------------------------- */

.rm-hero-fan {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
}

.rm-hero-fan img {
    width: 4.5rem;
    border-radius: 0.45rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    margin: 0 -0.75rem;
}

.rm-hero-fan img:nth-child(1) { transform: rotate(-16deg) translateY(10px); }
.rm-hero-fan img:nth-child(2) { transform: rotate(-8deg) translateY(2px); }
.rm-hero-fan img:nth-child(4) { transform: rotate(8deg) translateY(2px); }
.rm-hero-fan img:nth-child(5) { transform: rotate(16deg) translateY(10px); }

/* Six quick-start tiles (2, 3 and 4 players) - three columns instead of tarok's two. The
   tarok rule drops to one column on a phone, and that still wins below 576px. */
@media (min-width: 576px) {
    .tarok-quickstart--three {
        grid-template-columns: repeat(3, 1fr);
        max-width: 42rem;
    }
}

/* The between-rounds card sits centred on the felt, as the tarok result does. */
.rm-center > .tk-result {
    align-self: center;
    width: 100%;
    max-width: 40rem;
}
