/* ══════════════════════════════════════════
   Quick Reference Tables — Styles
   ══════════════════════════════════════════ */

/* ── Table Card ── */
.tbl-card {
    margin-bottom: 0.75rem;
    cursor: default;
    transition: border-color var(--transition-fast);
}

.tbl-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.tbl-card-header>div:first-child {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tbl-icon {
    font-size: 1.25rem;
}

.tbl-name {
    font-family: var(--font-display);
    font-size: 1rem;
    color: var(--text-primary);
}

.tbl-desc-text {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    line-height: 1.5;
}

.tbl-ref-badge {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    background: var(--bg-deep);
    padding: 0.3rem 0.75rem;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* ── Roll Area ── */
.tbl-roll-area {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
}

.tbl-modifier-group {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

/* Compact modifier input — more specific than .form-input to avoid !important */
.tbl-roll-area .tbl-modifier-input {
    width: 56px;
    text-align: center;
    padding: 0.4rem 0.3rem;
    font-size: 0.85rem;
}

.tbl-roll-btn {
    white-space: nowrap;
    transition:
        background var(--transition-fast),
        box-shadow var(--transition-fast),
        transform 120ms cubic-bezier(0.16, 1, 0.3, 1);
}

.tbl-roll-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px color-mix(in srgb, var(--gold) 25%, transparent);
}

.tbl-roll-btn:active {
    transform: scale(0.93) translateY(1px);
}

/* Applied via JS during roll animation */
.tbl-roll-animate {
    animation: rollPress 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes rollPress {
    0% {
        transform: scale(1);
    }

    20% {
        transform: scale(0.88);
    }

    60% {
        transform: rotate(-6deg) scale(0.94);
    }

    80% {
        transform: rotate(4deg) scale(0.97);
    }

    100% {
        transform: scale(1) rotate(0deg);
    }
}

/* ── Result Display — HERO MOMENT ── */
.tbl-result {
    padding: 0;
    background: none;
    border: none;
    border-radius: 0;
    margin-bottom: 0.75rem;
    animation: resultFade 0.3s ease;
}

@keyframes resultFade {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tbl-result-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    background: var(--tbl-color-bg, rgba(212, 160, 23, 0.07));
    border: 2px solid var(--tbl-color, var(--gold));
    border-radius: var(--radius);
    padding: 1.25rem 1rem 1rem;
    margin-bottom: 0.5rem;
}

.tbl-hero-dice {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
}

.tbl-hero-total {
    font-family: var(--font-display);
    font-size: 3.5rem;
    font-weight: 900;
    line-height: 1;
    color: var(--tbl-color, var(--gold-light));
    animation:
        heroNumber 0.4s cubic-bezier(0.16, 1, 0.3, 1),
        heroGlow 0.6s 0.35s ease forwards;
    margin-bottom: 0.5rem;
}

@keyframes heroNumber {
    from {
        transform: scale(0.5);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes heroGlow {
    0% {
        text-shadow: 0 0 0 transparent;
    }

    40% {
        text-shadow: 0 0 24px var(--tbl-color, var(--gold));
    }

    100% {
        text-shadow: 0 0 0 transparent;
    }
}

.tbl-hero-label {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--tbl-color, var(--gold-light));
    margin-bottom: 0.3rem;
}

.tbl-hero-desc {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.5;
    max-width: 55ch;
}

.tbl-result-dice {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.tbl-die {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    background: var(--bg-deep);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    font-weight: 900;
    font-size: 1.1rem;
    color: var(--text-primary);
    font-family: var(--font-display);
    animation: diePop 0.3s ease backwards;
}

.tbl-die:nth-child(3) {
    animation-delay: 0.08s;
}

.tbl-die-total {
    background: var(--tbl-color-bg, var(--tool-accent-bg));
    border-color: var(--tbl-color, var(--tool-accent));
    color: var(--tbl-color, var(--tool-accent));
    font-size: 1.3rem;
    width: 44px;
    height: 44px;
}

@keyframes diePop {
    from {
        opacity: 0;
        transform: scale(0.7) rotate(-15deg);
    }

    to {
        opacity: 1;
        transform: scale(1) rotate(0);
    }
}

.tbl-die-plus,
.tbl-die-equals {
    font-weight: 700;
    color: var(--text-muted);
    font-size: 1rem;
}

.tbl-result-entry {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.tbl-result-label {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--tbl-color, var(--gold-light));
}

.tbl-result-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ── Table ── */
.tbl-table-wrap {
    overflow-x: auto;
    margin: 0 -0.5rem;
    padding: 0 0.5rem;
}

.tbl-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.tbl-table thead tr {
    border-bottom: 2px solid rgba(255, 255, 255, 0.06);
}

.tbl-table th {
    text-align: left;
    padding: 0.5rem 0.75rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.tbl-th-range {
    width: 70px;
}

.tbl-th-label {
    width: 140px;
}

.tbl-row {
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    transition: background var(--transition-fast);
}

.tbl-row:hover {
    background: rgba(255, 255, 255, 0.02);
}

.tbl-row td {
    padding: 0.6rem 0.75rem;
    vertical-align: top;
}

.tbl-range {
    font-weight: 700;
    color: var(--text-secondary);
    font-family: var(--font-display);
    font-size: 0.9rem;
    white-space: nowrap;
}

.tbl-label {
    font-weight: 600;
    color: var(--text-primary);
}

.tbl-desc {
    color: var(--text-secondary);
    line-height: 1.4;
}

/* ── Highlighted Row ── */
.tbl-row-highlight {
    background: var(--tbl-color-bg, var(--tool-accent-bg));
    border-left: 2px solid var(--tbl-color, var(--tool-accent));
}

.tbl-row-highlight .tbl-range {
    color: var(--tbl-color, var(--gold-light));
}

.tbl-row-highlight .tbl-label {
    color: var(--tbl-color, var(--gold-light));
}

/* ── Result Area ── */
.tbl-result-area {
    min-height: 0;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .tbl-card {
        padding: 1rem;
    }

    .tbl-card-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .tbl-name {
        font-size: 1rem;
    }

    /* Convertir tabla en cards apiladas en mobile */
    .tbl-table-wrap {
        overflow-x: visible;
        margin: 0;
        padding: 0;
    }

    .tbl-table,
    .tbl-table tbody,
    .tbl-table tr,
    .tbl-table td {
        display: block;
        width: 100%;
    }

    /* Ocultar cabeceras en mobile (se sustituyen por data-label) */
    .tbl-table thead {
        display: none;
    }

    .tbl-row {
        padding: 0.6rem 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    }

    .tbl-row td {
        padding: 0.15rem 0;
        border: none;
    }

    /* Rango: pequeño y con color de acento */
    .tbl-range {
        font-size: 0.75rem;
        color: var(--text-muted);
        margin-bottom: 0.1rem;
    }

    /* Nombre del resultado: destacado */
    .tbl-label {
        font-size: 0.9rem;
        margin-bottom: 0.25rem;
    }

    /* Descripción: texto normal */
    .tbl-desc {
        font-size: 0.8rem;
        color: var(--text-secondary);
        line-height: 1.4;
    }
}