﻿/* ========================================
   DICE ROLLER STYLES
   dice-roller.css
   ======================================== */

/* ========================================
   DICE CONTAINER & LAYOUT
   ======================================== */
.dice-display-area {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    gap: 15px;
    min-height: 200px;
    padding: 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 15px;
    border: 1px solid #dee2e6;
}

.die-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.3s ease;
}

    .die-wrapper.hidden {
        display: none !important;
    }

/* ========================================
   CANVAS DICE STYLES
   ======================================== */
.dice-canvas {
    border-radius: 15px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

    .dice-canvas:hover:not(.rolling) {
        transform: scale(1.08) translateY(-3px);
        box-shadow: 0 12px 35px rgba(0, 0, 0, 0.35);
    }

    .dice-canvas.rolling {
        cursor: not-allowed;
    }

/* ========================================
   CSS FALLBACK DICE STYLES
   ======================================== */
.css-dice {
    width: 100px;
    height: 100px;
    background: linear-gradient(145deg, #ffffff, #e6e6e6);
    border-radius: 15px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3), inset 0 2px 10px rgba(255, 255, 255, 0.8);
    position: relative;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

    .css-dice:hover:not(.shaking) {
        transform: scale(1.08) translateY(-3px);
        box-shadow: 0 12px 35px rgba(0, 0, 0, 0.35), inset 0 2px 10px rgba(255, 255, 255, 0.8);
    }

    .css-dice .pip {
        width: 16px;
        height: 16px;
        background: radial-gradient(circle at 30% 30%, #4a4a4a, #1a1a1a);
        border-radius: 50%;
        box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
        position: absolute;
    }

    /* Pip positions for each value */
    .css-dice[data-value="1"] .pip:nth-child(1) {
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
    }

    .css-dice[data-value="2"] .pip:nth-child(1) {
        top: 22%;
        right: 22%;
    }

    .css-dice[data-value="2"] .pip:nth-child(2) {
        bottom: 22%;
        left: 22%;
    }

    .css-dice[data-value="3"] .pip:nth-child(1) {
        top: 22%;
        right: 22%;
    }

    .css-dice[data-value="3"] .pip:nth-child(2) {
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
    }

    .css-dice[data-value="3"] .pip:nth-child(3) {
        bottom: 22%;
        left: 22%;
    }

    .css-dice[data-value="4"] .pip:nth-child(1) {
        top: 22%;
        left: 22%;
    }

    .css-dice[data-value="4"] .pip:nth-child(2) {
        top: 22%;
        right: 22%;
    }

    .css-dice[data-value="4"] .pip:nth-child(3) {
        bottom: 22%;
        left: 22%;
    }

    .css-dice[data-value="4"] .pip:nth-child(4) {
        bottom: 22%;
        right: 22%;
    }

    .css-dice[data-value="5"] .pip:nth-child(1) {
        top: 22%;
        left: 22%;
    }

    .css-dice[data-value="5"] .pip:nth-child(2) {
        top: 22%;
        right: 22%;
    }

    .css-dice[data-value="5"] .pip:nth-child(3) {
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
    }

    .css-dice[data-value="5"] .pip:nth-child(4) {
        bottom: 22%;
        left: 22%;
    }

    .css-dice[data-value="5"] .pip:nth-child(5) {
        bottom: 22%;
        right: 22%;
    }

    .css-dice[data-value="6"] .pip:nth-child(1) {
        top: 22%;
        left: 22%;
    }

    .css-dice[data-value="6"] .pip:nth-child(2) {
        top: 22%;
        right: 22%;
    }

    .css-dice[data-value="6"] .pip:nth-child(3) {
        top: 50%;
        left: 22%;
        transform: translateY(-50%);
    }

    .css-dice[data-value="6"] .pip:nth-child(4) {
        top: 50%;
        right: 22%;
        transform: translateY(-50%);
    }

    .css-dice[data-value="6"] .pip:nth-child(5) {
        bottom: 22%;
        left: 22%;
    }

    .css-dice[data-value="6"] .pip:nth-child(6) {
        bottom: 22%;
        right: 22%;
    }

    /* Shake animation for CSS dice */
    .css-dice.shaking {
        animation: diceShake 0.1s infinite;
    }

@keyframes diceShake {
    0%, 100% {
        transform: translateX(0) rotate(0deg);
    }

    25% {
        transform: translateX(-5px) rotate(-5deg);
    }

    75% {
        transform: translateX(5px) rotate(5deg);
    }
}

/* ========================================
   RESULT DISPLAY
   ======================================== */
.total-result-display {
    font-size: 5rem;
    font-weight: bold;
    color: #198754;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    line-height: 1;
    font-family: 'Segoe UI', system-ui, sans-serif;
}

    .total-result-display.rolling {
        animation: resultPulse 0.3s infinite;
    }

.result-breakdown {
    font-size: 1.3rem;
    color: #6c757d;
    font-family: 'Consolas', 'Monaco', monospace;
    letter-spacing: 2px;
}

@keyframes resultPulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.6;
        transform: scale(0.98);
    }
}

/* Individual die result badges */
.die-result .badge {
    min-width: 35px;
    font-size: 1rem;
    font-weight: bold;
}

/* ========================================
   ROLL BUTTON
   ======================================== */
.btn-roll {
    font-size: 1.4rem;
    padding: 15px 60px;
    border-radius: 50px;
    transition: all 0.3s ease;
    font-weight: 600;
    letter-spacing: 1px;
}

    .btn-roll:hover:not(:disabled) {
        transform: translateY(-4px);
        box-shadow: 0 8px 25px rgba(25, 135, 84, 0.45);
    }

    .btn-roll:active:not(:disabled) {
        transform: translateY(-2px);
    }

    .btn-roll:disabled {
        cursor: not-allowed;
        opacity: 0.7;
    }

/* ========================================
   DICE COUNT SELECTOR
   ======================================== */
.dice-count-selector {
    display: flex;
    align-items: center;
    gap: 12px;
}

    .dice-count-selector .form-select {
        width: auto;
        font-size: 1.1rem;
        font-weight: 500;
        min-width: 120px;
    }

/* ========================================
   OPTIONS BAR
   ======================================== */
.options-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
    margin-bottom: 20px;
}

.mode-switch {
    display: flex;
    align-items: center;
    gap: 8px;
}

    .mode-switch .form-check-input {
        width: 3em;
        height: 1.5em;
    }

/* ========================================
   STATS CARDS
   ======================================== */
.stat-card {
    border: 1px solid #dee2e6;
    border-radius: 10px;
    padding: 12px;
    text-align: center;
    background: #fff;
    transition: box-shadow 0.2s ease;
}

    .stat-card:hover {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    }

    .stat-card h5 {
        font-size: 1.5rem;
        font-weight: bold;
        color: #198754;
        margin-bottom: 0;
    }

    .stat-card small {
        color: #6c757d;
        font-size: 0.8rem;
    }

/* ========================================
   HISTORY LOG
   ======================================== */
.roll-history {
    max-height: 300px;
    overflow-y: auto;
}

    .roll-history::-webkit-scrollbar {
        width: 8px;
    }

    .roll-history::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 4px;
    }

    .roll-history::-webkit-scrollbar-thumb {
        background: #c1c1c1;
        border-radius: 4px;
    }

        .roll-history::-webkit-scrollbar-thumb:hover {
            background: #a1a1a1;
        }

.history-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    border-bottom: 1px solid #eee;
    font-family: 'Consolas', 'Monaco', monospace;
    transition: background 0.15s ease;
}

    .history-entry:hover {
        background: #f8f9fa;
    }

    .history-entry:last-child {
        border-bottom: none;
    }

    .history-entry .roll-number {
        color: #6c757d;
        font-size: 0.85rem;
        min-width: 45px;
    }

    .history-entry .roll-values {
        color: #333;
        flex-grow: 1;
        text-align: center;
    }

    .history-entry .roll-sum {
        font-weight: bold;
        color: #198754;
        min-width: 50px;
        text-align: right;
    }

    /* New roll highlight */
    .history-entry.new-entry {
        animation: highlightNew 1s ease;
    }

@keyframes highlightNew {
    0% {
        background: #d4edda;
    }

    100% {
        background: transparent;
    }
}

/* ========================================
   DISTRIBUTION CHART
   ======================================== */
.distribution-row {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
}

    .distribution-row .dist-label {
        width: 30px;
        text-align: right;
        margin-right: 8px;
        font-size: 0.85rem;
        font-weight: 500;
        color: #495057;
    }

    .distribution-row .progress {
        flex-grow: 1;
        height: 18px;
        background: #e9ecef;
        border-radius: 4px;
    }

    .distribution-row .progress-bar {
        transition: width 0.4s ease;
        font-size: 0.75rem;
        font-weight: bold;
    }

/* ========================================
   RESPONSIVE ADJUSTMENTS
   ======================================== */
@media (max-width: 576px) {
    .dice-display-area {
        gap: 10px;
        padding: 15px;
    }

    .dice-canvas {
        width: 80px !important;
        height: 80px !important;
    }

    .css-dice {
        width: 70px;
        height: 70px;
    }

        .css-dice .pip {
            width: 12px;
            height: 12px;
        }

    .total-result-display {
        font-size: 3.5rem;
    }

    .result-breakdown {
        font-size: 1rem;
    }

    .btn-roll {
        font-size: 1.2rem;
        padding: 12px 40px;
    }

    .options-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .dice-count-selector {
        justify-content: center;
    }

    .mode-switch {
        justify-content: center;
    }

    .stat-card h5 {
        font-size: 1.2rem;
    }
}

@media (min-width: 577px) and (max-width: 768px) {
    .dice-canvas {
        width: 100px !important;
        height: 100px !important;
    }

    .css-dice {
        width: 85px;
        height: 85px;
    }

    .total-result-display {
        font-size: 4rem;
    }
}

/* ========================================
   KEYBOARD HINT STYLES
   ======================================== */
.keyboard-hints kbd {
    background: #212529;
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85rem;
}

/* ========================================
   GAME PRESETS (Quick Select)
   ======================================== */
.game-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

    .game-presets .btn {
        font-size: 0.85rem;
    }

/* ========================================
   LOADING STATE
   ======================================== */
.dice-loading {
    opacity: 0.6;
    pointer-events: none;
}
