/**
 * Dice Roller Styles
 * Roll virtual dice for board games, RPGs, and tabletop gaming
 */

/* ============================================
   DICE ROLLER DEMO
   ============================================ */

.dice-roller-demo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
    padding: 1.5rem;
    padding-top: 3.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 1.5rem;
    width: 100%;
    max-width: 420px;
    position: relative;
}

.dice-roller-demo.fullscreen {
    position: fixed;
    inset: 0;
    max-width: none;
    border-radius: 0;
    z-index: 9999;
    padding: 2rem;
    padding-top: 4rem;
    justify-content: center;
}

.dice-roller-demo.fullscreen .dice-container {
    min-height: 200px;
}

.dice-roller-demo.fullscreen .dice-cube {
    width: 100px;
    height: 100px;
}

.dice-roller-demo.fullscreen .cube-face {
    width: 100px;
    height: 100px;
    font-size: 2.5rem;
}

.dice-roller-demo.fullscreen .cube-face.front  { transform: translateZ(50px); }
.dice-roller-demo.fullscreen .cube-face.back   { transform: rotateY(180deg) translateZ(50px); }
.dice-roller-demo.fullscreen .cube-face.right  { transform: rotateY(90deg) translateZ(50px); }
.dice-roller-demo.fullscreen .cube-face.left   { transform: rotateY(-90deg) translateZ(50px); }
.dice-roller-demo.fullscreen .cube-face.top    { transform: rotateX(90deg) translateZ(50px); }
.dice-roller-demo.fullscreen .cube-face.bottom { transform: rotateX(-90deg) translateZ(50px); }

.dice-roller-demo.fullscreen .total-value {
    font-size: 3rem;
}

/* ============================================
   TOP CONTROLS
   ============================================ */

.dice-top-controls {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: flex;
    gap: 0.5rem;
}

.icon-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
    border-color: var(--primary-color);
}

/* ============================================
   SETTINGS MODAL
   ============================================ */

.settings-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.settings-modal-overlay.open {
    display: flex;
}

.settings-modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    width: 100%;
    max-width: 360px;
    overflow: hidden;
}

.settings-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.settings-modal-header h3 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-radius: 0.25rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.modal-close-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.settings-modal-body {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.setting-label {
    font-size: 0.9375rem;
    color: var(--text-primary);
}

.setting-select,
.setting-input {
    width: 120px;
    padding: 0.625rem 0.75rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: 0.5rem;
}

.setting-select {
    padding-right: 2rem;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236b7280' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
}

.setting-input {
    text-align: center;
}

.setting-select:focus,
.setting-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.settings-modal-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-color);
}

.apply-settings-btn {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    background: var(--primary-color);
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.apply-settings-btn:hover {
    filter: brightness(1.1);
}

/* ============================================
   DICE CONTAINER
   ============================================ */

.dice-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    min-height: 120px;
    padding: 1.5rem;
    perspective: 800px;
}

/* ============================================
   3D CUBE DICE
   ============================================ */

.dice-cube {
    width: 60px;
    height: 60px;
    position: relative;
    transform-style: preserve-3d;
    transform: rotateX(-20deg) rotateY(20deg);
    transition: transform 0.3s ease-out;
}

.dice-cube.rolling {
    animation: cube-roll 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes cube-roll {
    0% { transform: rotateX(-20deg) rotateY(20deg); }
    25% { transform: rotateX(200deg) rotateY(100deg) rotateZ(50deg); }
    50% { transform: rotateX(400deg) rotateY(200deg) rotateZ(-30deg); }
    75% { transform: rotateX(600deg) rotateY(300deg) rotateZ(60deg); }
    100% { transform: rotateX(700deg) rotateY(380deg) rotateZ(0deg); }
}

.cube-face {
    position: absolute;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 800;
    color: white;
    background: linear-gradient(145deg, #6366f1, #4f46e5);
    border: 2px solid rgba(255, 255, 255, 0.2);
    backface-visibility: visible;
    user-select: none;
}

.cube-face.front  { transform: translateZ(30px); border-radius: 8px; }
.cube-face.back   { transform: rotateY(180deg) translateZ(30px); border-radius: 8px; }
.cube-face.right  { transform: rotateY(90deg) translateZ(30px); border-radius: 8px; }
.cube-face.left   { transform: rotateY(-90deg) translateZ(30px); border-radius: 8px; }
.cube-face.top    { transform: rotateX(90deg) translateZ(30px); border-radius: 8px; }
.cube-face.bottom { transform: rotateX(-90deg) translateZ(30px); border-radius: 8px; }

/* Result shown on front face after roll */
.dice-cube.rolled {
    transform: rotateX(0deg) rotateY(0deg);
}

.dice-cube.crit-success .cube-face {
    background: linear-gradient(145deg, #22c55e, #16a34a);
}

.dice-cube.crit-success.rolled {
    animation: crit-bounce 0.4s ease-out;
}

.dice-cube.crit-fail .cube-face {
    background: linear-gradient(145deg, #ef4444, #dc2626);
}

@keyframes crit-bounce {
    0%, 100% { transform: rotateX(0deg) rotateY(0deg) scale(1); }
    50% { transform: rotateX(0deg) rotateY(0deg) scale(1.15); }
}

/* ============================================
   TOTAL DISPLAY
   ============================================ */

.dice-total {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1.25rem;
    background: var(--bg-tertiary);
    border-radius: 2rem;
}

.total-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-tertiary);
}

.total-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    min-width: 2ch;
    text-align: center;
}

/* ============================================
   CONFIG
   ============================================ */

.dice-config {
    width: 100%;
}

.config-row-inline {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
}

.config-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.config-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-primary);
}

.config-select {
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: 0.5rem;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236b7280' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
}

.config-select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* ============================================
   DICE COUNT SELECTOR
   ============================================ */

.dice-count-selector {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.125rem;
}

.count-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.count-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.count-display {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    min-width: 1.5rem;
    text-align: center;
}

/* ============================================
   ROLL BUTTON
   ============================================ */

.roll-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    padding: 1rem 2rem;
    font-size: 1.125rem;
    font-weight: 700;
    color: white;
    background: linear-gradient(135deg, var(--primary-color), #0077dd);
    border: none;
    border-radius: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(var(--primary-rgb), 0.3);
}

.roll-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(var(--primary-rgb), 0.4);
}

.roll-btn:active {
    transform: translateY(0);
}

.roll-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* ============================================
   ROLL HISTORY CHIPS
   ============================================ */

.roll-history-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.375rem;
    min-height: 28px;
}

.history-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    border-radius: 1rem;
    font-variant-numeric: tabular-nums;
}

.history-chip .chip-dice {
    color: var(--text-tertiary);
}

.history-chip .chip-result {
    font-weight: 700;
    color: var(--text-primary);
}
