/* Custom styles for Word Search Game */

/* Theme cards */
.theme-card {
    transition: transform 0.3s, box-shadow 0.3s, border-color 0.3s, background-color 0.3s;
    cursor: pointer;
    border: 2px solid transparent;
}

.theme-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-color: rgba(13, 110, 253, 0.3);
}

.theme-card.selected {
    border-color: #0d6efd;
    border-width: 3px;
    background-color: #f8f9ff;
    box-shadow: 0 0 20px rgba(13, 110, 253, 0.3), 0 4px 12px rgba(13, 110, 253, 0.2);
    transform: translateY(-3px);
}

.theme-card.selected .card-header {
    background-color: #0d6efd !important;
}

/* Word search grid */
.word-grid {
    border-collapse: collapse;
    margin: 0 auto;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    touch-action: none;
    max-width: 100%;
    table-layout: fixed;
    --grid-cell-size: 40px;
    /* Default desktop size */
}

/* Grid container for responsive scrolling */
.grid-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 auto;
    max-width: 100%;
    position: relative;
}

/* Scroll indicator for mobile */
.grid-container::after {
    content: "← Swipe to see full grid →";
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    color: #6c757d;
    white-space: nowrap;
    opacity: 0.7;
}

@media (min-width: 769px) {
    .grid-container::after {
        display: none;
    }
}

/* Dynamic grid sizing - will be calculated by JavaScript */
.word-grid td {
    width: var(--grid-cell-size) !important;
    height: var(--grid-cell-size) !important;
    font-size: calc(var(--grid-cell-size) * 0.6) !important;
    min-height: var(--grid-cell-size) !important;
    min-width: var(--grid-cell-size) !important;
    padding: calc(var(--grid-cell-size) * 0.05) !important;
    border-width: calc(var(--grid-cell-size) * 0.025) !important;
    text-align: center;
    vertical-align: middle;
    border: 1px solid #dee2e6;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    touch-action: none;
}

/* Mobile-specific improvements */
@media (max-width: 768px) {
    .grid-container {
        max-width: 100vw;
        padding: 0 10px;
    }

    .word-grid {
        min-width: 100%;
        max-width: none;
    }

    /* Reduce card padding on mobile */
    .card-body {
        padding: 8px;
    }

    /* Ensure grid fits in container */
    #gameGrid {
        overflow: visible;
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .card-body {
        padding: 6px;
    }
}

@media (max-width: 360px) {
    .card-body {
        padding: 4px;
    }
}

/* History page mobile improvements */
@media (max-width: 768px) {

    /* Hide table on mobile and show card layout */
    .history-table {
        display: none !important;
    }

    .history-cards {
        display: block !important;
    }

    /* Mobile card layout */
    .history-card {
        margin-bottom: 1rem;
        border: 1px solid #dee2e6;
        border-radius: 8px;
        overflow: hidden;
    }

    .history-card-header {
        background: #f8f9fa;
        padding: 12px 16px;
        border-bottom: 1px solid #dee2e6;
    }

    .history-card-body {
        padding: 16px;
    }

    /* Game info layout */
    .game-info {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        margin-bottom: 0;
    }

    .game-title {
        font-size: 16px;
        font-weight: 600;
        margin: 0 0 8px 0;
        color: #212529;
    }

    .game-meta {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .game-status {
        text-align: right;
    }

    /* Progress section */
    .progress-section {
        margin-bottom: 12px;
    }

    .progress-info {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 8px;
    }

    .progress-text {
        font-size: 14px;
        color: #212529;
        font-weight: 500;
    }

    .progress-bar-mobile {
        height: 8px;
        background-color: #e9ecef;
        border-radius: 4px;
        overflow: hidden;
        margin-bottom: 8px;
    }

    .progress-fill {
        height: 100%;
        background-color: #198754;
        transition: width 0.3s ease;
    }

    .words-found-mobile {
        font-size: 12px;
        color: #6c757d;
    }

    /* Action buttons */
    .game-actions {
        display: flex;
        gap: 8px;
        justify-content: flex-end;
    }

    .btn-mobile {
        padding: 6px 12px;
        font-size: 12px;
        border-radius: 4px;
    }

    /* Header adjustments */
    .history-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .history-title {
        font-size: 24px;
        margin-bottom: 0;
    }
}

/* Show table on desktop, hide cards */
@media (min-width: 769px) {
    .history-table {
        display: block;
    }

    .history-cards {
        display: none !important;
    }
}

@media (max-width: 480px) {
    .game-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .game-status {
        text-align: left;
    }

    .history-card-header {
        padding: 10px 12px;
    }

    .history-card-body {
        padding: 12px;
    }
}

/* Additional mobile touch improvements */
@media (hover: none) and (pointer: coarse) {
    .word-grid td {
        /* Larger touch targets for touch devices */
        min-width: 44px;
        min-height: 44px;
        padding: 8px;
    }

    .word-grid td:hover {
        /* Disable hover effects on touch devices */
        background-color: transparent;
    }
}

/* Base styles moved to dynamic section above */

.word-grid td:hover {
    background-color: #e9ecef;
}

.word-grid td.selected {
    background-color: #198754;
    color: white;
}

.word-grid td.found {
    background-color: #6f42c1;
    color: white;
}

.word-grid td.test-highlight {
    background-color: #ff0000 !important;
    color: white !important;
}

.word-grid td.space-cell {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
}

.word-grid td.hint-highlight {
    background-color: #ffc107 !important;
    color: #212529 !important;
    border: 2px solid #ffca2c !important;
    box-shadow: inset 0 0 0 1px #ffca2c;
    animation: hint-pulse 1s ease-in-out;
}

/* Disabled hint button */
#hintBtn.disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

@keyframes hint-pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
    }
}

/* Word list */
.word-list {
    max-height: 300px;
    overflow-y: auto;
}

.word-item {
    padding: 8px 12px;
    margin: 2px 0;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.word-item:hover {
    background-color: #f8f9fa;
}

.word-item.found {
    background-color: #d4d4d4 !important;
    color: #856404 !important;
    text-decoration: line-through !important;
    font-weight: bold !important;
}

.word-item.verified {
    background-color: #fff3cd;
    color: #856404;
    border-left: 4px solid #ffc107;
    font-weight: 500;
}

/* Game controls */
.game-controls {
    position: sticky;
    top: 20px;
}

/* Timer */
.timer {
    font-size: 2rem;
    font-weight: bold;
    color: #198754;
    text-align: center;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 2px solid #198754;
}

/* Progress bar */
.progress {
    height: 8px;
    border-radius: 4px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .word-grid td {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }

    .timer {
        font-size: 1.5rem;
        padding: 15px;
    }

    .game-controls {
        position: static;
        margin-top: 20px;
    }
}

/* Loading animations */
.loading-spinner {
    animation: spin 1s linear infinite;
}

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

    100% {
        transform: rotate(360deg);
    }
}

/* Success animations */
.success-pulse {
    animation: successPulse 0.6s ease-in-out;
}

@keyframes successPulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
    }
}

/* Custom scrollbar */
.word-list::-webkit-scrollbar {
    width: 6px;
}

.word-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.word-list::-webkit-scrollbar-thumb {
    background: #198754;
    border-radius: 3px;
}

.word-list::-webkit-scrollbar-thumb:hover {
    background: #146c43;
}

/* Modal improvements */
.modal-header {
    border-bottom: 2px solid #198754;
}

.modal-footer {
    border-top: 2px solid #198754;
}

/* Button improvements */
.btn-success {
    box-shadow: 0 2px 4px rgba(25, 135, 84, 0.2);
}

.btn-success:hover {
    box-shadow: 0 4px 8px rgba(25, 135, 84, 0.3);
}

/* Card improvements */
.card {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border: none;
}

.card-header {
    border-bottom: none;
}

/* Form improvements */
.form-control:focus {
    border-color: #198754;
    box-shadow: 0 0 0 0.2rem rgba(25, 135, 84, 0.25);
}

.form-check-input:checked {
    background-color: #198754;
    border-color: #198754;
}

/* Alert improvements */
.alert-warning {
    border-left: 4px solid #ffc107;
}

/* Navigation improvements */
.navbar-brand {
    font-size: 1.5rem;
}

.nav-link {
    font-weight: 500;
}

.nav-link:hover {
    color: #fff !important;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

/* Footer improvements */
footer {
    margin-top: auto;
}

/* Utility classes */
.text-shadow {
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.border-success-subtle {
    border-color: #d1e7dd !important;
}

.bg-success-subtle {
    background-color: #d1e7dd !important;
}

/* Development mode highlighting */
.dev-highlight {
    background-color: #fff3cd;
    /* Light yellow */
    border: 1px solid #ffeaa7;
    box-shadow: inset 0 0 0 1px #fdcb6e;
    color: #302400;
}