/* ===== Chess v2.2 — Feature CSS + UX Improvements ===== */

/* API badge in setup */
.chess-api-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 8px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    border-radius: 10px;
    vertical-align: middle;
    margin-left: 6px;
    letter-spacing: 0.3px;
}

/* Progressive indicator during game */
.chess-progressive-indicator {
    text-align: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: #f97316;
    padding: 4px 12px;
    background: rgba(249, 115, 22, 0.08);
    border-radius: 20px;
    margin: 4px auto;
    width: fit-content;
    transition: all 0.3s ease;
}

.chess-progressive-indicator.level-up {
    transform: scale(1.15);
    color: #ef4444;
    background: rgba(239, 68, 68, 0.12);
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.2);
}

/* ELO tag in player bar */
.chess-elo-tag {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 1px 6px;
    background: rgba(108, 99, 255, 0.15);
    color: var(--accent, #6c63ff);
    border-radius: 8px;
    margin-left: 4px;
    vertical-align: middle;
}

/* Board area with eval bar */
.chess-board-area {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.chess-board-area .chess-board-wrapper {
    flex: 1;
    min-width: 0;
}

.chess-board-wrapper {
    position: relative;
}

/* Eval bar */
.chess-eval-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 28px;
    flex-shrink: 0;
}

.chess-eval-bar {
    flex: 1;
    width: 20px;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: #333;
    border: 1px solid var(--border-color, #444);
    min-height: 200px;
}

.chess-eval-bar .eval-black {
    background: #333;
    transition: height 0.5s ease;
    height: 50%;
}

.chess-eval-bar .eval-white {
    background: #f0f0f0;
    transition: height 0.5s ease;
    height: 50%;
}

.chess-eval-label {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-secondary, #888);
    text-align: center;
    min-width: 28px;
}

.chess-eval-label.white-adv {
    color: #f0f0f0;
}

.chess-eval-label.black-adv {
    color: #666;
}

/* Toggle buttons */
.chess-btn-toggle {
    font-size: 0.85rem;
    padding: 6px 10px;
    opacity: 0.5;
    transition: all 0.2s;
}

.chess-btn-toggle.active {
    opacity: 1;
    background: rgba(108, 99, 255, 0.15);
    border-color: var(--accent, #6c63ff);
}

.chess-btn-toggle:hover {
    opacity: 0.8;
}

/* === TASK-46: Commentary below board === */
.chess-commentary-area {
    min-height: 0;
    margin: 8px 0;
    position: relative;
}

.chess-commentary {
    /* Normal flow element inside commentary-area (not absolute) */
    position: relative;
    bottom: auto;
    left: auto;
    transform: none;
    background: var(--bg-secondary, rgba(26, 26, 46, 0.95));
    border: 1px solid var(--border-color, #333);
    border-radius: 12px;
    padding: 10px 16px;
    max-width: 100%;
    font-size: 0.82rem;
    color: var(--text-primary);
    line-height: 1.4;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    pointer-events: none;
    text-align: center;
}

.chess-commentary.historical {
    border-color: rgba(108, 99, 255, 0.3);
    background: var(--bg-secondary, rgba(26, 26, 46, 0.97));
}

.chess-commentary .commentary-sub {
    font-size: 0.75rem;
    color: var(--text-secondary, #888);
    display: block;
    margin-top: 2px;
}

/* Fix commentary animations for below-board positioning */
.chess-commentary.fade-in {
    animation: commentary-slide-in 0.4s ease-out;
}

.chess-commentary.fade-out {
    animation: commentary-slide-out 0.5s ease-in forwards;
}

@keyframes commentary-slide-in {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes commentary-slide-out {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(8px); }
}

/* === TASK-46: Larger Pieces === */
.chess-piece {
    font-size: clamp(26px, 7vw, 38px) !important;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

/* === TASK-46: Desktop Board 30% Bigger === */
@media (min-width: 769px) {
    .chess-game {
        max-width: 560px !important;
    }
    .chess-piece {
        font-size: 42px !important;
    }
}

/* === TASK-46: "¡Te gano igual!" Mode === */
.chess-elo-value.challenge-mode {
    font-size: 2rem;
    color: #f97316;
    text-shadow: 0 0 10px rgba(249, 115, 22, 0.3);
}

.chess-handicap-section {
    margin: 12px 0;
    padding: 14px;
    background: rgba(239, 68, 68, 0.06);
    border-radius: 12px;
    border: 1px solid rgba(239, 68, 68, 0.15);
}

.chess-handicap-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.chess-handicap-desc {
    font-size: 0.75rem;
    color: var(--text-secondary, #888);
    margin-bottom: 10px;
}

.chess-handicap-options {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chess-handicap-opt {
    padding: 6px 12px;
    border-radius: 8px;
    background: var(--bg-secondary, rgba(30, 30, 50, 0.8));
    border: 1px solid var(--border-color, #333);
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-primary);
    transition: all 0.2s;
    user-select: none;
}

.chess-handicap-opt:hover {
    border-color: var(--accent, #6c63ff);
}

.chess-handicap-opt.selected {
    background: rgba(108, 99, 255, 0.15);
    border-color: var(--accent, #6c63ff);
    color: var(--accent, #6c63ff);
    font-weight: 600;
}

.chess-elo-tag.challenge {
    background: rgba(249, 115, 22, 0.15);
    color: #f97316;
    font-weight: 700;
}

/* BUG 3 ENHANCEMENT: Ensure white outlined pieces have visible stroke on dark squares */
.chess-square.dark .white-piece {
    text-shadow: 0 0 2px rgba(255, 255, 255, 0.5);
}

/* Light mode adjustments */
[data-theme="light"] .chess-eval-bar .eval-black {
    background: #444;
}

[data-theme="light"] .chess-eval-bar .eval-white {
    background: #f5f5f5;
}

[data-theme="light"] .chess-commentary {
    background: rgba(255, 255, 255, 0.97);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .chess-commentary.historical {
    border-color: rgba(108, 99, 255, 0.2);
}

/* Light mode: white outlined pieces need dark fill */
[data-theme="light"] .chess-square .white-piece {
    text-shadow: none;
}

/* Mobile adjustments */
@media (max-width: 480px) {
    .chess-eval-container {
        width: 22px;
    }
    .chess-eval-bar {
        width: 16px;
    }
    .chess-eval-label {
        font-size: 0.6rem;
    }
    .chess-commentary {
        font-size: 0.75rem;
        padding: 8px 12px;
        max-width: 95%;
    }
    .chess-elo-tag {
        font-size: 0.6rem;
    }
}
