/* Import shared game components */
@import url('../shared-game-components/common.css');

/* ========================================
   WORDLOCK COLOR OVERRIDES
   ======================================== */

:root {
    /* WordLock uses default Wordle-style green theme */
    /* Keep shared component defaults for primary colors */

    /* WordLock-specific dark theme colors */
    --bg-primary: #121213;
    --bg-secondary: #1a1a1b;
    --border-color: #3a3a3c;
    --border-filled: #565758;

    /* Tile colors (game-specific) */
    --tile-bg: #121213;
    --tile-correct: #538d4e;
    --tile-present: #b59f3b;
    --tile-absent: #3a3a3c;
    --tile-locked: #8b2e2e;

    /* Lock icon colors (darker versions) */
    --lock-correct: #3a6e35;
    --lock-present: #8a7a2a;
    --lock-absent: #2a2a2c;

    /* Button colors for mode selector */
    --btn-mode: #3a3a3c;
    --btn-mode-hover: #4a4a4c;

    /* Keyboard */
    --key-bg: #818384;
    --key-hover: #9a9a9a;
}

[data-theme="light"] {
    /* WordLock-specific light theme colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f5;
    --border-color: #d3d6da;
    --border-filled: #878a8c;

    /* Tile colors */
    --tile-bg: #ffffff;
    --tile-correct: #6aaa64;
    --tile-present: #c9b458;
    --tile-absent: #787c7e;
    --tile-locked: #d85656;

    /* Lock icon colors (darker versions) */
    --lock-correct: #4a7a44;
    --lock-present: #998438;
    --lock-absent: #58595e;

    /* Button colors */
    --btn-primary: #6aaa64;
    --btn-primary-hover: #538d4e;
    --btn-secondary: #878a8c;
    --btn-secondary-hover: #787c7e;
    --btn-mode: #d3d6da;
    --btn-mode-hover: #b3b6ba;

    /* Keyboard */
    --key-bg: #d3d6da;
    --key-hover: #b3b6ba;
}

/* ========================================
   GAME-SPECIFIC COMPONENTS
   ======================================== */

.container {
    max-width: 500px;
    width: 100%;
    padding: 12px;
    padding-bottom: 60px; /* Space for banner ad on mobile */
}

/* Override header margin for tighter spacing */
header {
    margin-bottom: 8px;
}

h1 {
    font-size: 30px;
}

/* ========================================
   MODE SELECTOR (Game-Specific)
   ======================================== */

.mode-selector {
    display: flex;
    justify-content: center;
    gap: 0;
    margin-bottom: 12px;
}

.mode-btn {
    background-color: var(--btn-mode);
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: bold;
    padding: 10px 30px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mode-btn:first-child {
    border-top-left-radius: 4px;
    border-bottom-left-radius: 4px;
}

.mode-btn:last-child {
    border-top-right-radius: 4px;
    border-bottom-right-radius: 4px;
}

.mode-btn.active {
    background-color: var(--btn-primary);
    color: white;
}

.mode-btn:not(.active):hover {
    background-color: var(--btn-mode-hover);
}

.mode-btn.completed:not(.active) {
    background-color: var(--btn-mode-hover);
    color: var(--text-secondary);
}

/* ========================================
   DIFFICULTY TOGGLE (Game-Specific)
   ======================================== */

.difficulty-setting {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.difficulty-toggle-container {
    width: 100%;
}

.difficulty-toggle-btn {
    background-color: var(--btn-secondary);
    border: none;
    border-radius: 20px;
    padding: 4px;
    cursor: pointer;
    display: flex;
    gap: 4px;
    width: 100%;
    transition: background-color 0.2s ease;
}

.difficulty-toggle-btn:hover {
    background-color: var(--btn-secondary-hover);
}

.difficulty-option {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 6px;
    padding: 10px 12px;
    border-radius: 16px;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    transition: all 0.2s ease;
    cursor: pointer;
}

.difficulty-option.active {
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

.difficulty-help {
    width: 100%;
}

.difficulty-description {
    display: none;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
    margin: 0;
}

.difficulty-description.active {
    display: block;
}

/* ========================================
   EXAMPLE TILES (How to Play Modal)
   ======================================== */

.example-tiles {
    margin: 15px 0;
}

.example-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.example-tile {
    width: 55px;
    height: 55px;
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: bold;
    text-transform: uppercase;
    background-color: var(--tile-bg);
    color: white;
    position: relative;
    flex-shrink: 0;
}

.example-tile .letter {
    z-index: 1;
}

.example-tile .lock-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: block;
    pointer-events: none;
    opacity: 1;
}

.example-tile .lock-icon svg {
    display: block;
    width: 36px;
    height: 36px;
}

.example-tile.correct {
    background-color: var(--tile-correct);
    border-color: var(--tile-correct);
}

.example-tile.present {
    background-color: var(--tile-present);
    border-color: var(--tile-present);
}

.example-tile.absent {
    background-color: var(--tile-absent);
    border-color: var(--tile-absent);
}

.example-tile.locked {
    background-color: var(--tile-locked);
    border-color: var(--tile-locked);
}

.example-text {
    flex: 1;
    line-height: 1.5;
    font-size: 14px;
}

.example-text strong {
    display: block;
    margin-bottom: 3px;
    font-size: 14px;
}

/* ========================================
   GAME BOARD & TILES
   ======================================== */

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 8px;
    position: relative;
}

#game-board {
    display: grid;
    grid-template-rows: repeat(8, 1fr);
    gap: 5px;
    margin-bottom: 8px;
}

.row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 5px;
}

.tile {
    width: 62px;
    height: 62px;
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: bold;
    text-transform: uppercase;
    background-color: var(--tile-bg);
    color: var(--text-primary);
    transition: all 0.3s ease;
    position: relative;
}

.tile .lock-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
    pointer-events: none;
    opacity: 1;
}

.tile .lock-icon svg {
    display: block;
    width: 40px;
    height: 40px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

/* Colored lock icons for evaluated tiles */
.tile .lock-icon.lock-correct svg rect {
    fill: var(--lock-correct);
}

.tile .lock-icon.lock-correct svg path {
    stroke: var(--lock-correct);
    fill: none;
}

.tile .lock-icon.lock-present svg rect {
    fill: var(--lock-present);
}

.tile .lock-icon.lock-present svg path {
    stroke: var(--lock-present);
    fill: none;
}

.tile .lock-icon.lock-absent svg rect {
    fill: var(--lock-absent);
}

.tile .lock-icon.lock-absent svg path {
    stroke: var(--lock-absent);
    fill: none;
}

/* Gold/silver animated lock that appears in corner */
.tile .lock-icon-anim {
    position: absolute;
    top: 4px;
    right: 4px;
    display: none;
    pointer-events: none;
    opacity: 0;
    transform: scale(0.5);
    z-index: 10;
}

.tile .lock-icon-anim svg {
    display: block;
    width: 20px;
    height: 20px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}

/* Show and animate the corner lock */
.tile.lock-revealing .lock-icon-anim {
    display: block;
    animation: lockCornerReveal 0.8s ease-out forwards;
}

.tile .letter {
    z-index: 1;
}

.tile.filled {
    border-color: var(--border-filled);
    animation: pop 0.1s ease-in-out;
}

.tile.locked {
    background-color: var(--tile-locked);
    border-color: var(--tile-locked);
    color: white;
}

.tile.correct {
    background-color: var(--tile-correct);
    border-color: var(--tile-correct);
    color: white;
}

.tile.present {
    background-color: var(--tile-present);
    border-color: var(--tile-present);
    color: white;
}

.tile.absent {
    background-color: var(--tile-absent);
    border-color: var(--tile-absent);
    color: white;
}

/* ========================================
   KEYBOARD
   ======================================== */

#keyboard {
    margin-top: 10px;
}

.keyboard-row {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-bottom: 8px;
}

.key {
    background-color: var(--key-bg);
    border: none;
    border-radius: 4px;
    color: white;
    font-size: 14px;
    font-weight: bold;
    padding: 14px;
    min-width: 43px;
    cursor: pointer;
    text-transform: uppercase;
    transition: background-color 0.1s ease;
}

/* Light mode keyboard text */
[data-theme="light"] .key {
    color: var(--text-primary);
}

.key:hover {
    background-color: var(--key-hover);
}

.key.wide {
    min-width: 65px;
    font-size: 12px;
}

/* Backspace key - center SVG icon */
#key-BACK {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 14px;
}

#key-BACK svg {
    width: 24px;
    height: 24px;
}

.key.correct {
    background-color: var(--tile-correct);
}

.key.present {
    background-color: var(--tile-present);
}

.key.absent {
    background-color: var(--tile-absent);
}

/* ========================================
   STATISTICS MODAL (Game-Specific)
   ======================================== */

#guess-distribution {
    margin-top: 15px;
}

.distribution-row {
    display: flex;
    align-items: center;
    margin-bottom: 5px;
}

.distribution-label {
    width: 15px;
    font-size: 14px;
    font-weight: bold;
    margin-right: 5px;
}

.distribution-bar {
    background-color: var(--btn-mode);
    color: white;
    padding: 4px 8px;
    min-width: 20px;
    text-align: center;
    font-size: 14px;
    font-weight: bold;
    transition: width 0.3s ease;
}

.distribution-bar.highlight {
    background-color: var(--tile-correct);
}

#stats-modal #share-btn {
    margin-top: 20px;
    width: 100%;
    background-color: var(--btn-primary);
    border: none;
    border-radius: 4px;
    color: white;
    font-size: 16px;
    font-weight: bold;
    padding: 12px 24px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

#stats-modal #share-btn:hover {
    background-color: var(--btn-primary-hover);
}

/* ========================================
   WORDLOCK-SPECIFIC ANIMATIONS
   ======================================== */

@keyframes pop {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Tile flip animation */
@keyframes flip {
    0% {
        transform: rotateX(0);
    }
    50% {
        transform: rotateX(90deg);
    }
    100% {
        transform: rotateX(0);
    }
}

/* Shake animation for invalid words */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
    20%, 40%, 60%, 80% { transform: translateX(4px); }
}

/* Bounce animation for winning */
@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
        animation-timing-function: ease-in;
    }
    50% {
        transform: translateY(-20px);
        animation-timing-function: ease-out;
    }
}

/* Locked letter reveal animation */
@keyframes lockedReveal {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Pulse animation for lock icons */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.15);
        opacity: 0.8;
    }
}

@keyframes lockCornerReveal {
    0% {
        opacity: 0;
        transform: scale(0.3) rotate(-20deg);
    }
    40% {
        opacity: 1;
        transform: scale(1.2) rotate(5deg);
    }
    60% {
        transform: scale(1) rotate(0deg);
    }
    100% {
        opacity: 0;
        transform: scale(0.8);
    }
}

/* Success pulse for buttons */
@keyframes successPulse {
    0%, 100% {
        transform: scale(1);
    }
    25% {
        transform: scale(0.95);
    }
    50% {
        transform: scale(1.05);
    }
    75% {
        transform: scale(0.98);
    }
}

/* ========================================
   WORDLOCK-SPECIFIC RESPONSIVE DESIGN
   ======================================== */

/* Tablet/medium screens */
@media screen and (max-width: 800px) {
    h1 {
        font-size: 28px;
    }
}

/* Mobile responsive styles */
@media screen and (max-width: 600px) {
    .container {
        padding: 10px;
    }

    h1 {
        font-size: 24px;
    }

    /* Smaller tiles */
    .tile {
        width: 52px;
        height: 52px;
        font-size: 28px;
    }

    .tile .lock-icon svg {
        width: 32px;
        height: 32px;
    }

    /* Keyboard on mobile */
    .key {
        font-size: 13px;
        padding: 14px;
        min-width: 43px;
    }

    .key.wide {
        min-width: 65px;
        font-size: 12px;
    }

    .keyboard-row {
        gap: 6px;
        margin-bottom: 8px;
    }

    /* Smaller mode buttons */
    .mode-btn {
        font-size: 12px;
        padding: 8px 20px;
    }

    .example-tiles {
        margin: 12px 0;
    }

    /* Smaller example tiles on mobile */
    .example-tile {
        width: 45px;
        height: 45px;
        font-size: 22px;
    }

    .example-tile .lock-icon svg {
        width: 28px;
        height: 28px;
    }

    .example-row {
        gap: 10px;
        margin-bottom: 10px;
    }

    .example-text {
        font-size: 13px;
        line-height: 1.4;
    }

    #stats-modal #share-btn {
        font-size: 14px;
        padding: 10px 20px;
    }
}

/* Extra small phones */
@media screen and (max-width: 380px) {
    h1 {
        font-size: 20px;
    }

    .tile {
        width: 46px;
        height: 46px;
        font-size: 24px;
    }

    .tile .lock-icon svg {
        width: 28px;
        height: 28px;
    }

    .key {
        font-size: 13px;
        padding: 0;
        min-width: 32px;
        width: 32px;
        height: 42px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .key.wide {
        min-width: 50px;
        width: auto;
        padding: 0 10px;
        font-size: 11px;
        height: 42px;
    }

    /* Backspace icon size on small phones */
    #key-BACK svg {
        width: 24px;
        height: 24px;
    }

    .keyboard-row {
        gap: 3px;
        width: 100%;
    }

    .example-tile {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }

    .example-tile .lock-icon svg {
        width: 24px;
        height: 24px;
    }

    .example-row {
        gap: 8px;
        margin-bottom: 8px;
    }

    .example-text {
        font-size: 12px;
    }
}
