/* css/dice.css */

:root {
    /* Size of the dice */
    --dice-size: 100px;
    /* Radius of the outer shell */
    --dice-radius: 18px; 
    
    /* Light Theme Colors */
    --dice-bg: #eeeeee;
    --dice-gradient: linear-gradient(145deg, #ffffff, #e0e0e0);
    --dot-color: #333333;
    --dice-border-color: #cccccc;
    --dice-core-color: #d0d0d0; 
    --dice-shadow: inset 0 3px 10px rgba(0,0,0,0.1);
}

@media (max-width: 576px) {
    :root {
        --dice-size: 70px;
        --dice-radius: 14px;
    }
    .dice-platform { gap: 30px !important; }
    .scene-container { height: 250px !important; }
}

body.dark-theme {
    /* Dark Theme Colors */
    --dice-bg: #34495e;
    --dice-gradient: linear-gradient(145deg, #4b6584, #34495e); 
    --dot-color: #ecf0f1;
    --dice-border-color: #2c3e50;
    --dice-core-color: #2c3e50; 
    --dice-shadow: inset 0 3px 15px rgba(0,0,0,0.4);
}

.scene-container {
    width: 100%;
    max-width: 500px; 
    margin: 0 auto;   
    height: 300px;
    display: flex;
    justify-content: center;
    align-items: center;
    perspective: 1000px;
    background-color: var(--section-alt-bg);
    border-radius: 1rem;
    border: 1px solid var(--card-border);
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
    touch-action: none; 
    cursor: grab;
    position: relative;
    z-index: 10;
}

.scene-container:active { cursor: grabbing; }

.dice-platform {
    display: flex;
    gap: 60px;
    transform-style: preserve-3d;
    align-items: center;
    justify-content: center;
}

.die {
    width: var(--dice-size);
    height: var(--dice-size);
    position: relative;
    transform-style: preserve-3d;
    transition: transform 1.5s cubic-bezier(0.15, 0.45, 0.15, 1.15);
}

/* --- COMMON STYLES --- */
.die-face, .die-face-core {
    position: absolute;
    transform-style: preserve-3d;
}

/* --- OUTER FACES (The Skin) --- */
.die-face {
    width: 100%;
    height: 100%;
    background: var(--dice-gradient);
    border: 1px solid var(--dice-border-color);
    border-radius: var(--dice-radius);
    display: grid;
    grid-template: repeat(3, 1fr) / repeat(3, 1fr);
    padding: 8px;
    box-shadow: var(--dice-shadow);
    backface-visibility: hidden;
    z-index: 2;
}

/* --- INNER CORE FACES (The Filling) --- */
.die-face-core {
    background-color: var(--dice-core-color);
    
    /* Shrink the core slightly so corners don't poke out */
    width: 96%;
    height: 96%;
    left: 2%;
    top: 2%;
    
    /* Smaller radius helps fill the inner corner gap */
    border-radius: 10px; 
    
    /* Solid block effect */
    backface-visibility: visible; 
    z-index: 1;
    
    /* Small shadow for blending, but not large enough to create dirt artifacts */
    box-shadow: 0 0 2px 1px var(--dice-core-color); 
}

/* --- TRANSFORMS --- */

/* Outer Faces */
.face-1 { transform: translateZ(calc(var(--dice-size) / 2)); }
.face-6 { transform: rotateY(180deg) translateZ(calc(var(--dice-size) / 2)); }
.face-2 { transform: rotateY(90deg) translateZ(calc(var(--dice-size) / 2)); }
.face-5 { transform: rotateY(-90deg) translateZ(calc(var(--dice-size) / 2)); }
.face-3 { transform: rotateX(90deg) translateZ(calc(var(--dice-size) / 2)); }
.face-4 { transform: rotateX(-90deg) translateZ(calc(var(--dice-size) / 2)); }

/* 
   Inner Core Faces: 
   Pushed deeper inside (minus 2px) to avoid fighting with edges.
*/
.core-face-1 { transform: translateZ(calc((var(--dice-size) / 2) - 2px)); }
.core-face-6 { transform: rotateY(180deg) translateZ(calc((var(--dice-size) / 2) - 2px)); }
.core-face-2 { transform: rotateY(90deg) translateZ(calc((var(--dice-size) / 2) - 2px)); }
.core-face-5 { transform: rotateY(-90deg) translateZ(calc((var(--dice-size) / 2) - 2px)); }
.core-face-3 { transform: rotateX(90deg) translateZ(calc((var(--dice-size) / 2) - 2px)); }
.core-face-4 { transform: rotateX(-90deg) translateZ(calc((var(--dice-size) / 2) - 2px)); }

/* --- DOTS --- */
.dot {
    background-color: var(--dot-color);
    border-radius: 50%;
    align-self: center;
    justify-self: center;
    width: calc(var(--dice-size) * 0.18);
    height: calc(var(--dice-size) * 0.18);
    box-shadow: inset 0 2px 3px rgba(0,0,0,0.2);
}

/* Grid Positioning */
.face-1 .dot:nth-child(1) { grid-area: 2 / 2; }
.face-2 .dot:nth-child(1) { grid-area: 1 / 3; } .face-2 .dot:nth-child(2) { grid-area: 3 / 1; }
.face-3 .dot:nth-child(1) { grid-area: 1 / 3; } .face-3 .dot:nth-child(2) { grid-area: 2 / 2; } .face-3 .dot:nth-child(3) { grid-area: 3 / 1; }
.face-4 .dot:nth-child(1) { grid-area: 1 / 1; } .face-4 .dot:nth-child(2) { grid-area: 1 / 3; } .face-4 .dot:nth-child(3) { grid-area: 3 / 1; } .face-4 .dot:nth-child(4) { grid-area: 3 / 3; }
.face-5 .dot:nth-child(1) { grid-area: 1 / 1; } .face-5 .dot:nth-child(2) { grid-area: 1 / 3; } .face-5 .dot:nth-child(3) { grid-area: 2 / 2; } .face-5 .dot:nth-child(4) { grid-area: 3 / 1; } .face-5 .dot:nth-child(5) { grid-area: 3 / 3; }
.face-6 .dot:nth-child(1) { grid-area: 1 / 1; } .face-6 .dot:nth-child(2) { grid-area: 1 / 3; } .face-6 .dot:nth-child(3) { grid-area: 2 / 1; } .face-6 .dot:nth-child(4) { grid-area: 2 / 3; } .face-6 .dot:nth-child(5) { grid-area: 3 / 1; } .face-6 .dot:nth-child(6) { grid-area: 3 / 3; }

/* Animation */
.die.rolling { animation: shake 0.5s infinite; }
@keyframes shake {
    0% { transform: translate(1px, 1px) rotate(0deg); }
    10% { transform: translate(-1px, -2px) rotate(-1deg); }
    20% { transform: translate(-3px, 0px) rotate(1deg); }
    30% { transform: translate(3px, 2px) rotate(0deg); }
    40% { transform: translate(1px, -1px) rotate(1deg); }
    50% { transform: translate(-1px, 2px) rotate(-1deg); }
    60% { transform: translate(-3px, 1px) rotate(0deg); }
    70% { transform: translate(3px, 1px) rotate(-1deg); }
    80% { transform: translate(-1px, -1px) rotate(1deg); }
    90% { transform: translate(1px, 2px) rotate(0deg); }
    100% { transform: translate(1px, -2px) rotate(-1deg); }
}