/* components.css - Shared UI Components */

/* Chessboard Styles */
.chessboard-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.chessboard {
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 8px var(--shadow-color);
    cursor: pointer;
    background: var(--light-square-color);
    transition: box-shadow 0.2s ease;
}

.chessboard:hover {
    box-shadow: 0 6px 12px var(--shadow-color);
}

/* Control Buttons */
.control-buttons {
    display: flex;
    justify-content: center;
    gap: 16px;
    padding: 20px;
    flex-wrap: wrap;
}

.control-btn {
    width: 48px;
    height: 48px;
    border-radius: 24px;
    background-color: var(--button-grey);
    color: var(--text-primary);
    border: none;
    font-size: 22px;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    min-height: 44px;
    min-width: 44px;
    position: relative;
    overflow: hidden;
}

.control-btn:before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.3s ease, height 0.3s ease;
}

.control-btn:hover:before {
    width: 100%;
    height: 100%;
}

.control-btn:hover {
    transform: scale(1.05);
    filter: brightness(1.2);
}

.control-btn:active {
    transform: scale(0.95);
    filter: brightness(0.9);
}

.control-btn:disabled {
    background-color: var(--button-disabled);
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    filter: none;
}

.control-btn:disabled:before {
    display: none;
}

/* Puzzle Preview Cells - FIXED VERSION */
.puzzle-preview {
    background-color: var(--card-background-color);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 4px var(--shadow-light);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.puzzle-preview:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px var(--shadow-color);
    border-color: var(--accent-color);
}

.puzzle-preview:active {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px var(--shadow-color);
}

.puzzle-preview.active {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(247, 148, 89, 0.3);
    transform: translateY(-1px);
}

.puzzle-preview.solved {
    border-color: var(--success-color);
}

/* Single solved indicator - only CSS ::after pseudo-element */
.puzzle-preview.solved::after {
    content: '';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 16px;
    height: 16px;
    background-color: var(--success-color);
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    z-index: 10;
}

.puzzle-preview-board {
    width: 100%;
    aspect-ratio: 1;
    position: relative;
    flex-shrink: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Remove any padding that might cause gaps */
    padding: 0;
    margin: 0;
}

.puzzle-preview-board canvas {
    display: block;
    /* Center the canvas */
    margin: auto;
    padding: 0;
    /* Let the JavaScript handle exact sizing */
    max-width: 100%;
    max-height: 100%;
}

.puzzle-preview-info {
    background: rgba(0, 0, 0, 0.4);
    text-align: center;
    padding: 8px;
    flex-shrink: 0;
    /* No border radius since parent container handles it */
}

.puzzle-preview-rating {
    color: rgb(247, 148, 89);
    font-size: 13px;
    font-weight: 700;
    margin: 0;
    line-height: 1.3;
}

/* Back Button */
.back-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 18px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-radius: 8px;
    transition: all 0.2s ease;
    min-height: 44px;
}

.back-btn:hover {
    color: var(--text-primary);
    background-color: var(--hover-overlay);
}

.back-btn:active {
    background-color: var(--active-overlay);
}

.back-icon {
    font-size: 24px;
    line-height: 1;
}

.back-text {
    font-size: 16px;
    font-weight: 400;
}

/* Navigation Buttons */
.nav-btn {
    background-color: var(--button-grey);
    color: var(--text-primary);
    border: none;
    border-radius: 20px;
    width: 40px;
    height: 40px;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    min-height: 44px;
    min-width: 44px;
}

.nav-btn:hover {
    transform: scale(1.1);
    filter: brightness(1.2);
}

.nav-btn:active {
    transform: scale(0.95);
}

.nav-btn:disabled {
    background-color: var(--button-disabled);
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    filter: none;
}

/* Header Styles */
.header-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    padding: 12px;
    border-radius: 12px;
    transition: background-color 0.2s ease;
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-btn:hover {
    background-color: var(--hover-overlay);
}

.header-btn:active {
    background-color: var(--active-overlay);
}

/* Date Display */
.date-display {
    color: var(--text-secondary);
    font-size: 16px;
    font-weight: 500;
    text-align: center;
}

/* Puzzle Info */
.puzzle-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
}

.puzzle-counter {
    color: var(--text-secondary);
    font-size: 18px;
    font-weight: 600;
}

.puzzle-rating {
    color: var(--text-secondary);
    font-size: 16px;
    font-weight: 500;
}

/* Color indicator container - groups playing as section and move indicator */
.color-indicator-container {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px; /* Same gap as puzzle-info (between counter and rating) */
}

/* Playing as row - label and circle inline */
.playing-as-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Playing as label - same size as rating */
.playing-as-label {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Move Indicator - simple text, no box */
.move-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 16px;
    font-weight: 500;
    white-space: nowrap;
    justify-content: flex-end;
    padding: 4px 8px;
    border-radius: 6px;
    background-color: transparent;
    transition: background-color 0.15s ease;
}

.move-indicator.success .move-status-icon,
.move-indicator.success .move-text {
    color: var(--success-color);
}

.move-indicator.error .move-status-icon,
.move-indicator.error .move-text {
    color: var(--error-color);
}

/* Flash animation for Good/Wrong - single flash */
@keyframes flashSuccess {
    0% {
        background-color: transparent;
    }
    15% {
        background-color: rgba(76, 217, 102, 0.25);
    }
    100% {
        background-color: transparent;
    }
}

@keyframes flashError {
    0% {
        background-color: transparent;
    }
    15% {
        background-color: rgba(230, 77, 77, 0.25);
    }
    100% {
        background-color: transparent;
    }
}

/* Pulse animation for Solved - double pulse */
@keyframes pulseSolved {
    0% {
        background-color: transparent;
        transform: scale(1);
    }
    10% {
        background-color: rgba(76, 217, 102, 0.3);
        transform: scale(1.05);
    }
    20% {
        background-color: transparent;
        transform: scale(1);
    }
    35% {
        background-color: rgba(76, 217, 102, 0.35);
        transform: scale(1.08);
    }
    50% {
        background-color: transparent;
        transform: scale(1);
    }
    100% {
        background-color: transparent;
        transform: scale(1);
    }
}

/* Apply animations */
.move-indicator.success.flash {
    animation: flashSuccess 0.6s ease-out;
}

.move-indicator.error.flash {
    animation: flashError 0.6s ease-out;
}

.move-indicator.success.pulse {
    animation: pulseSolved 1.2s ease-in-out;
}

.move-status-icon {
    font-size: 16px;
    font-weight: bold;
}

.move-status-icon.success {
    color: var(--success-color);
}

.move-status-icon.error {
    color: var(--error-color);
}

.move-text {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Animation for move indicator appearance */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Promotion UI */
.promotion-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease;
}

.promotion-container {
    background-color: var(--card-background-color);
    border-radius: 16px;
    border: 2px solid var(--accent-color);
    box-shadow: 0 8px 32px var(--shadow-heavy);
    padding: 24px;
    max-width: 360px;
    width: 90%;
    animation: scaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.promotion-title {
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 20px;
}

.promotion-pieces {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.promotion-piece {
    width: 64px;
    height: 64px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    background-color: var(--card-background);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    position: relative;
    overflow: hidden;
}

.promotion-piece:before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, transparent, rgba(255, 255, 255, 0.1));
    opacity: 0;
    transition: opacity 0.2s ease;
}

.promotion-piece:hover:before {
    opacity: 1;
}

.promotion-piece:hover {
    transform: scale(1.1);
    border-color: var(--accent-color);
    box-shadow: 0 4px 16px rgba(247, 148, 89, 0.3);
}

.promotion-piece:active {
    transform: scale(1.05);
}

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--card-background-color);
    color: var(--text-primary);
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: 0 8px 24px var(--shadow-color);
    z-index: 1000;
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
    max-width: 90%;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.success {
    border-left: 4px solid var(--success-color);
}

.toast.error {
    border-left: 4px solid var(--error-color);
}

.toast.warning {
    border-left: 4px solid var(--warning-color);
}

/* Loading States */
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--button-disabled);
    border-top: 4px solid var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Animations */
@keyframes fadeIn {
    from { 
        opacity: 0; 
    }
    to { 
        opacity: 1; 
    }
}

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

@keyframes scaleIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.scale-in {
    animation: scaleIn 0.2s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.slide-in {
    animation: slideIn 0.3s ease-out;
}

/* Pulse animation for active states */
@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(247, 148, 89, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(247, 148, 89, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(247, 148, 89, 0);
    }
}

.pulse {
    animation: pulse 2s infinite;
}

/* Focus indicators */
.focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .control-btn {
        width: 44px;
        height: 44px;
        font-size: 20px;
    }
    
    .control-buttons {
        gap: 12px;
        padding: 16px;
    }
    
    .promotion-container {
        padding: 20px;
        max-width: 320px;
    }
    
    .promotion-piece {
        width: 56px;
        height: 56px;
        font-size: 32px;
    }
    
    .toast {
        bottom: 20px;
        padding: 12px 20px;
        font-size: 14px;
    }
    
    .playing-as-label {
        font-size: 14px;
    }
    
    .move-indicator {
        font-size: 14px;
    }
    
    .move-status-icon {
        font-size: 14px;
    }
    
    .move-text {
        font-size: 13px;
    }
    
    /* Mobile puzzle preview adjustments */
    .puzzle-preview.solved::after {
        width: 14px;
        height: 14px;
        top: 6px;
        right: 6px;
    }
}

@media (max-width: 375px) {
    .control-btn {
        width: 40px;
        height: 40px;
        font-size: 18px;
        gap: 8px;
    }
    
    .control-buttons {
        gap: 8px;
        padding: 12px;
    }
    
    .puzzle-preview {
        padding: 8px;
        border-radius: 8px;
    }
    
    .promotion-piece {
        width: 48px;
        height: 48px;
        font-size: 28px;
        gap: 8px;
    }
    
    .toast {
        bottom: 16px;
        padding: 10px 16px;
        font-size: 13px;
    }
    
    .playing-as-label {
        font-size: 13px;
    }
    
    .move-indicator {
        font-size: 13px;
    }
    
    .move-status-icon {
        font-size: 13px;
    }
    
    .move-text {
        font-size: 12px;
    }
    
    .puzzle-preview.solved::after {
        width: 12px;
        height: 12px;
        top: 4px;
        right: 4px;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .puzzle-preview:hover {
        border-color: var(--text-primary);
    }
    
    .control-btn {
        border: 1px solid var(--border-color);
    }
    
    .promotion-piece {
        border-width: 3px;
    }
    
    .move-indicator {
        border-width: 3px;
    }
    
    .color-indicator {
        border-width: 4px;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .move-indicator.flash,
    .move-indicator.pulse {
        animation: none;
    }
    
    .move-indicator {
        transition: none;
    }
}

/* Print styles */
@media print {
    .control-buttons,
    .promotion-overlay,
    .toast {
        display: none;
    }
}
/* Skeleton Loader */
.skeleton-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--background-color);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.skeleton-loader.visible {
    opacity: 1;
}

.skeleton-loader.hiding {
    opacity: 0;
}

.skeleton-chessboard {
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    position: relative;
    overflow: hidden;
}

/* Shimmer effect */
.skeleton-chessboard::after {
    content: '';
    position: absolute;
    top: 0;
    left: var(--shimmer-position, -100px);
    width: 100px;
    height: 100%;
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.3) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    pointer-events: none;
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100px);
    }
    100% {
        transform: translateX(500px);
    }
}

/* Responsive skeleton */
@media (max-width: 768px) {
    .skeleton-chessboard {
        width: calc(100vw - 80px) !important;
        height: calc(100vw - 80px) !important;
        max-width: 320px;
        max-height: 320px;
    }
}


