/* 
 * Veedle - Style 
 * Premium Aesthetic, Dark Mode, Responsive
 */

:root {
    --color-bg: #2c2c2c;
    --color-tone-1: #ffffff;
    --color-tone-2: #818384;
    --color-tone-3: #565758;
    --color-tone-4: #3a3a3c;
    --color-tone-5: #272729;
    --color-tone-6: #1a1a1b;
    --color-tone-7: #121213;

    --color-nav-height: 50px;
    --header-height: 50px;
    --keyboard-height: 200px;

    /* Game Colors */
    --color-present: #b59f3b;
    /* Yellow-ish Gold */
    --color-correct: #538d4e;
    /* Green */
    --color-absent: #3a3a3c;
    /* Dark Gray */

    /* Title Theme (Dark Mode Default) */
    --title-color: #f9e8cc;
    --title-shadow: none;

    /* Animations */
    --animation-speed: 250ms;

    font-family: 'Inter', 'Helvetica Neue', Arial, sans-serif;
}

body.light-mode {
    --color-bg: #f8f0ef;
    --color-tone-1: #121213;
    --color-tone-2: #d3d6da;
    --color-tone-3: #dfdfe0;
    --color-tone-4: #d3d6da;
    /* Inactive borders */
    --color-tone-5: #f0f0f0;
    --color-tone-6: #f0f0f0;
    /* Ad bg */
    --color-tone-7: #ffffff;

    --color-absent: #787c7e;
    --color-present: #c9b458;
    --color-correct: #6aaa64;

    /* Title Theme (Light Mode) */
    --title-color: #d99950;
    /* To create a solid block shadow without gaps, we ideally need steps. 
       However, keeping user's values for now: 2px and 4px layers. */
    --title-shadow:
        2px 2px 0px #43291a,
        4px 4px 0px #43291a;
}

* {
    box-sizing: border-box;
}

body {
    background-color: var(--color-bg);
    color: var(--color-tone-1);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    /* Allow growth */
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    /* Allow specific vertical scrolling */
    transition: background-color 0.3s, color 0.3s;
}

/* Header */
header {
    flex: 0 0 75px;
    /* Fixed user typo 'xpx' back to 75px */
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 100%;
    border-bottom: 2px solid var(--color-tone-4);
    /* Thicker border */
    padding: 10px 20px;
    /* Increased padding */
    margin: 0 auto;
    background-color: var(--color-bg);
}

.header-left,
.header-right {
    width: 80px;
    /* Exact width to balance center */
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.branding {
    width: 80px;
    flex: 0 0 80px;
    justify-content: flex-start;
    padding-left: 0;
}

#Veedle_Logo {
    height: 100%;
    max-height: 60px;
    /* Limit height */
    width: auto;
}

#dark-mode-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-tone-1);
    padding: 0;
}

.title {
    font-weight: 400;
    /* Titan One is bold */
    font-size: 36px;
    /* Larger */
    letter-spacing: 0.05em;
    text-transform: uppercase;
    font-family: 'Titan One', cursive;
    /* Super Joyful */
    color: var(--title-color);
    /* Themed color */
    text-shadow: var(--title-shadow);
    /* Themed shadow */
    flex-grow: 1;
    text-align: center;
    display: flex;
    justify-content: center;
}

/* Game Container */
#game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 500px;
    height: auto;
    /* Let it grow */
    min-height: 100%;
    margin: 0 auto;
    padding: 0;
    /* overflow: hidden; <-- Removed to allow scroll */
}

/* Spacer helpers if needed, or just use margins */

#board-container {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-grow: 1;
    /* Take available space */
    width: 100%;
    overflow: hidden;
    /* Prevent spillover */
    padding: 10px;
}

#board {
    display: grid;
    grid-template-rows: repeat(6, 1fr);
    grid-gap: 5px;
    padding: 10px;
    box-sizing: border-box;
    width: 100%;
    max-width: 350px;
    aspect-ratio: 5 / 6;
    /* Ensure it doesn't get too tall */
    max-height: 420px;
}

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

.tile {
    width: 100%;
    height: 100%;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    line-height: 2rem;
    font-weight: bold;
    vertical-align: middle;
    box-sizing: border-box;
    border: 2px solid var(--color-tone-4);
    text-transform: uppercase;
    user-select: none;
    /* transition: transform 0.6s;  <-- REMOVED to prevent conflict with @keyframes flip-in */
}

/* Tile States - NO ANIMATION HERE explicitly */
.tile[data-state='active'] {
    border-color: var(--color-tone-2);
}

.tile[data-state='tbd'] {
    border-color: var(--color-tone-2);
}

.tile[data-state='correct'] {
    background-color: var(--color-correct);
    border-color: var(--color-correct);
    color: #ffffff;
    /* Force white text for readability */
}

.tile[data-state='present'] {
    background-color: var(--color-present);
    border-color: var(--color-present);
    color: #ffffff;
    /* Force white text */
}

.tile[data-state='absent'] {
    background-color: var(--color-absent);
    border-color: var(--color-absent);
    color: #ffffff;
    /* Force white text */
}

/* Keyboard */
#keyboard-container {
    height: auto;
    width: 100%;
    margin-top: auto;
    /* Push to bottom if space allows, or just separate */
    padding-bottom: 20px;
    /* Space before footer/bottom */
}

#keyboard {
    margin: 0 8px;
    user-select: none;
}

.keyboard-row {
    display: flex;
    width: 100%;
    margin: 0 auto 8px;
    touch-action: manipulation;
}

.key {
    font-family: inherit;
    font-weight: bold;
    border: 0;
    padding: 0;
    margin: 0 6px 0 0;
    height: 58px;
    border-radius: 4px;
    cursor: pointer;
    user-select: none;
    background-color: var(--color-tone-2);
    color: var(--color-tone-1);
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    text-transform: uppercase;
    transition: background-color 0.1s ease;
}

.key:last-of-type {
    margin: 0;
}

.key.wide {
    flex: 1.5;
}

.key[data-state='correct'] {
    background-color: var(--color-correct);
    color: #ffffff;
}

.key[data-state='present'] {
    background-color: var(--color-present);
    color: #ffffff;
}

.key[data-state='absent'] {
    background-color: var(--color-absent);
    color: #ffffff;
}

/* Footer (Ads) */
footer {
    height: 90px;
    /* Specific ad height */
    width: 100%;
    background-color: var(--color-tone-6);
    display: flex;
    justify-content: center;
    align-items: center;
    border-top: 1px solid var(--color-tone-4);
    font-size: 0.8rem;
    color: var(--color-tone-2);
    flex-shrink: 0;
}

/* Animations */
@keyframes pop {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }

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

.pop {
    animation: pop 0.1s;
}

@keyframes shake {

    10%,
    90% {
        transform: translate3d(-1px, 0, 0);
    }

    20%,
    80% {
        transform: translate3d(2px, 0, 0);
    }

    30%,
    50%,
    70% {
        transform: translate3d(-4px, 0, 0);
    }

    40%,
    60% {
        transform: translate3d(4px, 0, 0);
    }
}

.shake {
    animation: shake 0.5s;
}

@keyframes flip-in {
    0% {
        transform: rotateX(0);
    }

    50% {
        transform: rotateX(-90deg);
    }

    100% {
        transform: rotateX(0);
    }
}

.flip {
    animation: flip-in 0.6s ease-in-out;
}

/* Messages */
#message-container {
    position: absolute;
    top: 10%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.message {
    background-color: var(--color-tone-1);
    color: var(--color-tone-7);
    padding: 10px 20px;
    border-radius: 4px;
    margin-bottom: 10px;
    opacity: 1;
    transition: opacity 0.3s;
    font-weight: bold;
}

.message.fade-out {
    opacity: 0;
}

/* Mobile Adjustments */
@media (max-height: 600px) {
    #board {
        height: 350px;
        width: 300px;
    }

    .key {
        height: 48px;
    }

    .title {
        font-size: 24px;
    }
}