/* --- Dado online / Dice Roller --- */

/* --- Seleção do tipo de dado --- */

.dice-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 18px;
}

.dice-chip {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    background: var(--bg);
    color: var(--muted);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 7px 16px;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.dice-chip:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent-text);
}

.dice-chip.is-active,
.dice-chip.is-active:hover:not(:disabled) {
    background: var(--accent);
    border-color: var(--accent);
    color: #FFFFFF;
}

.dice-chip:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* --- Campos --- */

.dice-fields {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 4px;
}

.dice-fields .calc-field input {
    max-width: none;
}

/* --- Palco dos dados --- */

.dice-stage {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 16px;
    min-height: 150px;
    padding: 24px 0 12px;
    --die-size: 88px;
}

.dice-stage[data-count="some"] {
    --die-size: 70px;
    gap: 12px;
}

.dice-stage[data-count="many"] {
    --die-size: 54px;
    gap: 10px;
}

.die {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--die-size);
    height: var(--die-size);
    color: #FFFFFF;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: calc(var(--die-size) * 0.36);
    background: linear-gradient(145deg, var(--accent), var(--accent-hover));
}

.die-number {
    line-height: 1;
    text-shadow: 0 1px 2px rgba(1, 17, 38, 0.45);
}

/* Formas de cada dado. clip-path corta a sombra, então a profundidade vem do gradiente. */

.die-d4 {
    clip-path: polygon(50% 4%, 96% 92%, 4% 92%);
    padding-top: calc(var(--die-size) * 0.2);
    font-size: calc(var(--die-size) * 0.3);
}

.die-d8 {
    clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}

.die-d10 {
    clip-path: polygon(50% 0, 96% 38%, 50% 100%, 4% 38%);
    padding-bottom: calc(var(--die-size) * 0.06);
}

.die-d12 {
    clip-path: polygon(50% 0, 100% 38%, 82% 100%, 18% 100%, 0 38%);
    padding-top: calc(var(--die-size) * 0.05);
}

.die-d20 {
    clip-path: polygon(50% 0, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%);
}

.die-d100 {
    border-radius: 50%;
    font-size: calc(var(--die-size) * 0.3);
}

/* d6 com pontos: um quadrado de cantos arredondados, claro, como um dado de verdade */

.die-d6 {
    background: var(--die-face);
    border: 2px solid var(--die-ink);
    border-radius: calc(var(--die-size) * 0.18);
    box-shadow: 0 5px 12px rgba(1, 17, 38, 0.22);
    padding: calc(var(--die-size) * 0.12);
}

.die-pips {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    width: 100%;
    height: 100%;
}

.die-pips span {
    display: flex;
    align-items: center;
    justify-content: center;
}

.die-pip::after {
    content: '';
    width: 70%;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    background: var(--die-ink);
}

/* --- Animações --- */

@keyframes diceShake {
    0%   { transform: translate(0, 0) rotate(0deg); }
    20%  { transform: translate(-5px, 3px) rotate(-14deg); }
    40%  { transform: translate(5px, -4px) rotate(12deg); }
    60%  { transform: translate(-4px, -3px) rotate(-10deg); }
    80%  { transform: translate(4px, 4px) rotate(9deg); }
    100% { transform: translate(0, 0) rotate(0deg); }
}

@keyframes diceLand {
    0%   { transform: scale(1.25); }
    60%  { transform: scale(0.94); }
    100% { transform: scale(1); }
}

.dice-stage.is-rolling .die {
    animation: diceShake 0.28s linear infinite;
}

.dice-stage.is-rolling .die:nth-child(even) {
    animation-direction: reverse;
    animation-duration: 0.34s;
}

.dice-stage.is-landed .die {
    animation: diceLand 0.35s ease-out;
}

/* --- Ações e resultado --- */

.dice-actions {
    display: flex;
    justify-content: center;
    margin-top: 8px;
}

.dice-actions .calc-submit {
    min-width: 200px;
    padding: 13px 28px;
    font-size: 1rem;
}

.dice-actions .calc-submit:disabled,
.picker-card-head button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.dice-hint {
    font-size: 0.8rem;
    color: var(--muted);
    text-align: center;
    margin: 14px 0 0;
}

.dice-hint kbd {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 1px 6px;
    color: var(--ink);
}

.dice-result {
    margin-top: 18px;
    text-align: center;
    background: var(--accent-soft);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: 16px 12px;
}

.dice-result[hidden] {
    display: none;
}

.dice-result > span {
    display: block;
    font-size: 0.75rem;
    color: var(--accent-deep);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 2px;
}

.dice-result strong {
    display: block;
    font-family: var(--font-display);
    font-size: 2.6rem;
    line-height: 1.15;
    color: var(--accent-deep);
}

.dice-detail,
.dice-note {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: var(--accent-deep);
    margin: 6px 0 0;
    word-break: break-word;
}

.dice-detail:empty,
.dice-note:empty {
    display: none;
}

/* --- Histórico (mesmo padrão das outras ferramentas) --- */

.picker-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.picker-card-head .calc-card-title {
    margin: 0;
}

.winner-number {
    flex-shrink: 0;
    min-width: 26px;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    background: var(--accent-soft);
    color: var(--accent-deep);
    padding: 2px 6px;
    border-radius: 4px;
}

.dice-history-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-mono);
}

@media (max-width: 600px) {
    .dice-fields {
        grid-template-columns: 1fr;
    }
    .dice-stage {
        --die-size: 74px;
    }
    .dice-stage[data-count="some"] {
        --die-size: 58px;
    }
    .dice-stage[data-count="many"] {
        --die-size: 44px;
        gap: 8px;
    }
    .dice-actions .calc-submit {
        width: 100%;
    }
    .dice-result strong {
        font-size: 2.1rem;
    }
    .dice-hint {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .dice-stage.is-rolling .die,
    .dice-stage.is-landed .die {
        animation: none;
    }
}