/* THE AMPERSAND - Crossword Design System (Tailwind Component Overrides) */

:root {
    --font-headline: 'Newsreader', serif;
    --font-body: 'Noto Serif', serif;
    --font-label: 'Public Sans', sans-serif;
}

.crossword-grid {
    display: grid;
    /* Grid columns set dynamically by JS based on puzzle size */
    background-color: #2f342e; /* Border color */
    gap: 1px;
    border: 1px solid #2f342e;
}

.crossword-cell {
    position: relative;
    background: #ffffff;
    transition: all 0.2s ease;
    cursor: pointer;
    user-select: none;
    aspect-ratio: 1 / 1;
}

.crossword-cell.black {
    background-color: #2f342e;
    cursor: default;
}

.crossword-cell.selected {
    background-color: #d0ecff !important; /* tertiary-container */
}

.crossword-cell.active-word {
    background-color: #f4faff; /* on-tertiary */
}

/* Cell Content */
.cell-number {
    position: absolute;
    top: 2px;
    left: 4px;
    font-size: 0.65rem;
    font-family: var(--font-label);
    color: #2f342e;
    z-index: 5;
    pointer-events: none;
}

.crossword-cell .val {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-family: var(--font-label);
    font-weight: 700;
    font-size: 1.25rem;
    text-transform: uppercase;
    color: #2f342e;
}

/* Mobile specific font sizing */
@media (max-width: 640px) {
    .crossword-cell .val {
        font-size: 1rem;
    }
    .cell-number {
        font-size: 0.5rem;
        top: 1px;
        left: 2px;
    }
}

/* Animations & States */
.crossword-cell.wrong {
    background-color: #fe8983 !important; /* error-container */
    animation: shake 0.4s ease-in-out;
}

.crossword-cell.correct {
    background-color: #e8f5e9 !important;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-2px); }
    75% { transform: translateX(2px); }
}

/* Clue Items */
.clue-item {
    display: flex;
    gap: 12px;
    padding: 8px 12px;
    cursor: pointer;
    transition: all 0.2s;
    border-radius: 0;
    margin: 0 -8px;
}

.clue-item:hover {
    background-color: #f4f4ef;
}

.clue-item.active {
    background-color: #e5e2e1; /* primary-container */
}

.clue-item .clue-num {
    font-family: var(--font-label);
    font-weight: 700;
    color: #486272;
    min-width: 20px;
}

.clue-item .clue-text {
    font-size: 0.95rem;
    line-height: 1.5;
    color: #2f342e;
}

.clue-item.active .clue-text {
    font-weight: 600;
}

/* Custom Scrollbar for Clue Container */
#clue-lists-container::-webkit-scrollbar {
    width: 4px;
}
#clue-lists-container::-webkit-scrollbar-track {
    background: transparent;
}
#clue-lists-container::-webkit-scrollbar-thumb {
    background: #afb3ac;
    border-radius: 10px;
}

/* Overlay transitions */
#completion-modal {
    transition: opacity 0.5s ease;
}

#completion-modal.active {
    display: flex;
    opacity: 1;
}

/* Leaderboard List */
.lb-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 16px;
    align-items: center;
}

.lb-row.highlight {
    background-color: #f4faff;
    font-weight: bold;
}

.lb-rank {
    font-family: var(--font-label);
    font-weight: 700;
    width: 30px;
}

.lb-nickname {
    flex-grow: 1;
    font-family: var(--font-body);
    font-weight: 500;
}

.lb-score {
    text-align: right;
    font-family: var(--font-label);
    font-size: 0.85rem;
    color: #486272;
}

#nickname-input::placeholder {
    font-style: italic;
    opacity: 0.5;
}

#nickname-form-container.hidden {
    display: none;
}

#leaderboard-container.hidden {
    display: none;
}

/* Virtual Keyboard */
.vk-key {
    width: 32px;
    height: 42px;
    background: #ffffff;
    border: 1px solid #d6d4d4;
    border-radius: 4px;
    font-family: var(--font-label);
    font-weight: bold;
    font-size: 14px;
    color: #2f342e;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    transition: all 0.1s;
}

.vk-key:active {
    background: #e5e2e1;
    transform: translateY(1px);
}

.vk-wide {
    width: 48px;
}

@media (max-width: 400px) {
    .vk-key { 
        width: 28px; 
        height: 40px; 
        font-size: 12px; 
    }
    .vk-wide { 
        width: 44px; 
    }
}
