﻿/* ========================================
   COIN TOSS STYLES
   coin-toss.css
   ======================================== */

/* ========================================
   COIN CONTAINER & LAYOUT
   ======================================== */
.coin-display-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 320px;
    padding: 30px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 15px;
    border: 1px solid #dee2e6;
}

.coin-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.3s ease;
}

/* ========================================
   CANVAS COIN STYLES
   ======================================== */
.coin-canvas {
    cursor: pointer;
    transition: transform 0.15s ease, filter 0.15s ease;
    filter: drop-shadow(0 15px 25px rgba(0, 0, 0, 0.3));
}

    .coin-canvas:hover:not(.flipping) {
        transform: scale(1.05) translateY(-5px);
        filter: drop-shadow(0 20px 35px rgba(0, 0, 0, 0.35));
    }

    .coin-canvas.flipping {
        cursor: not-allowed;
    }

/* ========================================
   CSS FALLBACK COIN STYLES
   ======================================== */
.css-coin-container {
    perspective: 1000px;
    padding: 20px;
}

.css-coin {
    width: 180px;
    height: 180px;
    position: relative;
    transform-style: preserve-3d;
    cursor: pointer;
    transition: transform 0.15s ease;
}

    .css-coin:hover:not(.flipping) {
        transform: scale(1.05) translateY(-5px);
    }

.coin-face {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    backface-visibility: hidden;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.35), inset 0 3px 15px rgba(255, 255, 255, 0.6), inset 0 -5px 15px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

/* Silver coin styling */
.coin-heads {
    background: linear-gradient( 145deg, #f5f5f5 0%, #e8e8e8 20%, #d4d4d4 40%, #c0c0c0 60%, #a8a8a8 80%, #909090 100% );
    border: 5px solid #888;
}

.coin-tails {
    background: linear-gradient( 145deg, #f5f5f5 0%, #e8e8e8 20%, #d4d4d4 40%, #c0c0c0 60%, #a8a8a8 80%, #909090 100% );
    border: 5px solid #888;
    transform: rotateY(180deg);
}

/* Inner ring detail */
.coin-face::before {
    content: '';
    position: absolute;
    width: calc(100% - 20px);
    height: calc(100% - 20px);
    border-radius: 50%;
    border: 2px solid rgba(0, 0, 0, 0.15);
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.1);
}

/* Coin imagery */
.coin-image {
    font-size: 5rem;
    line-height: 1;
    filter: drop-shadow(1px 1px 2px rgba(0, 0, 0, 0.3));
    color: #555;
    z-index: 1;
}

/* Edge detail shimmer */
.coin-face::after {
    content: '';
    position: absolute;
    top: 5%;
    left: 10%;
    width: 30%;
    height: 20%;
    background: linear-gradient( 135deg, rgba(255, 255, 255, 0.4) 0%, rgba(255, 255, 255, 0) 100% );
    border-radius: 50%;
    transform: rotate(-30deg);
}

/* CSS Coin states */
.css-coin[data-value="heads"]:not(.flipping) {
    transform: rotateY(0deg);
}

.css-coin[data-value="tails"]:not(.flipping) {
    transform: rotateY(180deg);
}

/* Flip animations */
.css-coin.flip-to-heads {
    animation: coinFlipToHeads 1.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.css-coin.flip-to-tails {
    animation: coinFlipToTails 1.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes coinFlipToHeads {
    0% {
        transform: rotateY(0deg) translateY(0) scale(1);
    }

    15% {
        transform: rotateY(540deg) translateY(-80px) scale(1.1);
    }

    30% {
        transform: rotateY(1080deg) translateY(-120px) scale(1.15);
    }

    50% {
        transform: rotateY(1800deg) translateY(-100px) scale(1.12);
    }

    70% {
        transform: rotateY(2520deg) translateY(-50px) scale(1.05);
    }

    85% {
        transform: rotateY(3240deg) translateY(-15px) scale(1.02);
    }

    100% {
        transform: rotateY(3600deg) translateY(0) scale(1);
    }
}

@keyframes coinFlipToTails {
    0% {
        transform: rotateY(0deg) translateY(0) scale(1);
    }

    15% {
        transform: rotateY(540deg) translateY(-80px) scale(1.1);
    }

    30% {
        transform: rotateY(1080deg) translateY(-120px) scale(1.15);
    }

    50% {
        transform: rotateY(1800deg) translateY(-100px) scale(1.12);
    }

    70% {
        transform: rotateY(2520deg) translateY(-50px) scale(1.05);
    }

    85% {
        transform: rotateY(3240deg) translateY(-15px) scale(1.02);
    }

    100% {
        transform: rotateY(3780deg) translateY(0) scale(1);
    }
}

/* ========================================
   RESULT DISPLAY
   ======================================== */
.coin-result-display {
    font-size: 3.5rem;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    line-height: 1;
    font-family: 'Segoe UI', system-ui, sans-serif;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

    .coin-result-display.heads {
        color: #5a6268;
    }

    .coin-result-display.tails {
        color: #6c757d;
    }

    .coin-result-display.flipping {
        animation: resultPulse 0.3s infinite;
        color: #adb5bd;
    }

@keyframes resultPulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.6;
        transform: scale(0.98);
    }
}

/* Result icon */
.result-icon {
    font-size: 2.5rem;
}

/* ========================================
   FLIP BUTTON
   ======================================== */
.btn-flip {
    font-size: 1.4rem;
    padding: 15px 60px;
    border-radius: 50px;
    transition: all 0.3s ease;
    font-weight: 600;
    letter-spacing: 1px;
    background: linear-gradient(145deg, #c0c0c0, #a0a0a0);
    border: 2px solid #888;
    color: #333;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

    .btn-flip:hover:not(:disabled) {
        transform: translateY(-4px);
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
        background: linear-gradient(145deg, #d0d0d0, #b0b0b0);
        color: #222;
    }

    .btn-flip:active:not(:disabled) {
        transform: translateY(-2px);
    }

    .btn-flip:disabled {
        cursor: not-allowed;
        opacity: 0.7;
        background: linear-gradient(145deg, #999, #777);
        color: #555;
    }

/* ========================================
   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;
        margin-bottom: 0;
    }

        .stat-card h5.heads-color {
            color: #5a6268;
        }

        .stat-card h5.tails-color {
            color: #6c757d;
        }

        .stat-card h5.neutral-color {
            color: #198754;
        }

    .stat-card small {
        color: #6c757d;
        font-size: 0.8rem;
    }

/* ========================================
   HISTORY LOG
   ======================================== */
.flip-history {
    max-height: 300px;
    overflow-y: auto;
}

    .flip-history::-webkit-scrollbar {
        width: 8px;
    }

    .flip-history::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 4px;
    }

    .flip-history::-webkit-scrollbar-thumb {
        background: #c1c1c1;
        border-radius: 4px;
    }

        .flip-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;
    transition: background 0.15s ease;
}

    .history-entry:hover {
        background: #f8f9fa;
    }

    .history-entry:last-child {
        border-bottom: none;
    }

    .history-entry .flip-number {
        color: #6c757d;
        font-size: 0.85rem;
        min-width: 45px;
        font-family: 'Consolas', 'Monaco', monospace;
    }

    .history-entry .flip-result {
        font-weight: bold;
        padding: 4px 14px;
        border-radius: 20px;
        font-size: 0.85rem;
        display: flex;
        align-items: center;
        gap: 6px;
    }

        .history-entry .flip-result.heads {
            background: linear-gradient(145deg, #e8e8e8, #d0d0d0);
            color: #444;
            border: 1px solid #bbb;
        }

        .history-entry .flip-result.tails {
            background: linear-gradient(145deg, #d8d8d8, #c0c0c0);
            color: #444;
            border: 1px solid #aaa;
        }

        .history-entry .flip-result .history-icon {
            font-size: 1rem;
        }

    /* New entry highlight */
    .history-entry.new-entry {
        animation: highlightNew 1s ease;
    }

@keyframes highlightNew {
    0% {
        background: #e9ecef;
    }

    100% {
        background: transparent;
    }
}

/* ========================================
   DISTRIBUTION DISPLAY
   ======================================== */
.distribution-bar {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
}

    .distribution-bar .dist-label {
        width: 60px;
        font-weight: 600;
        font-size: 0.9rem;
        display: flex;
        align-items: center;
        gap: 5px;
    }

        .distribution-bar .dist-label.heads {
            color: #5a6268;
        }

        .distribution-bar .dist-label.tails {
            color: #6c757d;
        }

    .distribution-bar .dist-icon {
        font-size: 1.1rem;
    }

    .distribution-bar .progress {
        flex-grow: 1;
        height: 28px;
        background: #e9ecef;
        border-radius: 6px;
        margin: 0 10px;
        overflow: hidden;
    }

    .distribution-bar .progress-bar {
        transition: width 0.4s ease;
        font-weight: bold;
        font-size: 0.85rem;
        display: flex;
        align-items: center;
        justify-content: center;
    }

        .distribution-bar .progress-bar.bg-heads {
            background: linear-gradient(90deg, #d0d0d0, #b8b8b8) !important;
            color: #444;
        }

        .distribution-bar .progress-bar.bg-tails {
            background: linear-gradient(90deg, #c0c0c0, #a0a0a0) !important;
            color: #444;
        }

    .distribution-bar .dist-count {
        min-width: 40px;
        text-align: right;
        font-weight: bold;
        font-size: 0.95rem;
    }

/* Percentage display */
.distribution-percentage {
    text-align: center;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #dee2e6;
}

.percentage-display {
    display: inline-flex;
    align-items: center;
    gap: 20px;
    font-size: 1.1rem;
}

    .percentage-display .heads-pct {
        color: #5a6268;
        font-weight: bold;
    }

    .percentage-display .tails-pct {
        color: #6c757d;
        font-weight: bold;
    }

/* ========================================
   STREAK DISPLAY
   ======================================== */
.streak-display {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.streak-item {
    text-align: center;
    padding: 10px 15px;
    background: #f8f9fa;
    border-radius: 10px;
    min-width: 100px;
    border: 1px solid #e9ecef;
}

    .streak-item .streak-value {
        font-size: 1.4rem;
        font-weight: bold;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 5px;
    }

        .streak-item .streak-value.heads {
            color: #5a6268;
        }

        .streak-item .streak-value.tails {
            color: #6c757d;
        }

    .streak-item .streak-icon {
        font-size: 1.2rem;
    }

    .streak-item .streak-label {
        font-size: 0.75rem;
        color: #6c757d;
        text-transform: uppercase;
        margin-top: 3px;
    }

/* ========================================
   OPTIONS BAR
   ======================================== */
.options-bar {
    display: flex;
    justify-content: flex-end;
    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;
    }

/* ========================================
   KEYBOARD HINTS
   ======================================== */
.keyboard-hints kbd {
    background: #212529;
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85rem;
}

/* ========================================
   LOADING STATE
   ======================================== */
.coin-loading {
    opacity: 0.6;
    pointer-events: none;
}

/* ========================================
   RESPONSIVE ADJUSTMENTS
   ======================================== */
@media (max-width: 576px) {
    .coin-display-area {
        padding: 20px;
        min-height: 280px;
    }

    .coin-canvas {
        width: 160px !important;
        height: 160px !important;
    }

    .css-coin {
        width: 140px;
        height: 140px;
    }

    .coin-image {
        font-size: 4rem;
    }

    .coin-result-display {
        font-size: 2.5rem;
    }

    .result-icon {
        font-size: 2rem;
    }

    .btn-flip {
        font-size: 1.2rem;
        padding: 12px 40px;
    }

    .stat-card h5 {
        font-size: 1.2rem;
    }

    .percentage-display {
        font-size: 1rem;
        flex-direction: column;
        gap: 5px;
    }

        .percentage-display .text-muted {
            display: none;
        }

    .streak-display {
        gap: 10px;
    }

    .streak-item {
        min-width: 90px;
        padding: 8px 12px;
    }

        .streak-item .streak-value {
            font-size: 1.2rem;
        }
}

@media (min-width: 577px) and (max-width: 768px) {
    .coin-canvas {
        width: 180px !important;
        height: 180px !important;
    }

    .css-coin {
        width: 160px;
        height: 160px;
    }

    .coin-result-display {
        font-size: 3rem;
    }
}
