/* ============================================================
   Wordle Global — modern theme
   Light + dark mode via prefers-color-scheme.
   Tailwind (CDN) provides utilities; this file layers the
   theme colors, game colors and all animations on top.
   ============================================================ */

:root {
    --bg: #fafaf9;
    --bg-accent-1: rgba(6, 182, 212, 0.08);
    --bg-accent-2: rgba(59, 130, 246, 0.08);
    --text: #18181b;
    --text-muted: #71717a;
    --surface: #ffffff;
    --surface-border: #e4e4e7;
    --tile-border: #c8cbd0;
    --tile-border-filled: #a1a1aa;
    --key-bg: #e2e4e9;
    --key-bg-hover: #d3d6dc;
    --key-text: #27272a;
    --correct: #43a047;
    --semicorrect: #cf9f02;
    --incorrect: #75797e;
    --shadow-color: rgba(24, 24, 27, 0.10);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #101012;
        --bg-accent-1: rgba(6, 182, 212, 0.07);
        --bg-accent-2: rgba(99, 102, 241, 0.07);
        --text: #ececee;
        --text-muted: #a1a1aa;
        --surface: #1b1b1f;
        --surface-border: #303036;
        --tile-border: #3a3a3f;
        --tile-border-filled: #57575e;
        --key-bg: #6e7178;
        --key-bg-hover: #7d8087;
        --key-text: #ffffff;
        --correct: #4a9d4e;
        --semicorrect: #c0940a;
        --incorrect: #47484c;
        --shadow-color: rgba(0, 0, 0, 0.5);
    }
}

/* ------------------------------------------------------------
   Base
   ------------------------------------------------------------ */

html,
body {
    background-color: var(--bg);
    color: var(--text);
    -webkit-tap-highlight-color: transparent;
}

body {
    background-image:
        radial-gradient(ellipse 80% 50% at 20% -10%, var(--bg-accent-1), transparent),
        radial-gradient(ellipse 80% 50% at 80% -10%, var(--bg-accent-2), transparent);
    background-repeat: no-repeat;
}

/* Make the Tailwind utility colors used in the markup theme-aware. */
.bg-white {
    background-color: var(--surface) !important;
}

.border-neutral-300,
.border-slate-200,
.border-gray-300,
.border-gray-400 {
    border-color: var(--surface-border) !important;
}

.text-gray-600,
.text-gray-700,
.text-neutral-400,
.text-neutral-500 {
    color: var(--text-muted) !important;
}

.text-gray-900 {
    color: var(--text) !important;
}

/* separators inside modals (tailwind's default border color is light gray,
   which glows in dark mode) */
.border-t,
.border-r,
.border-b,
.sm\:border-r {
    border-color: var(--surface-border);
}

.hover\:bg-neutral-200:hover {
    background-color: transparent !important;
}

/* hides vue elements initially */
[v-cloak] {
    display: none;
}

/* ------------------------------------------------------------
   Game colors
   ------------------------------------------------------------ */

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

.semicorrect {
    background-color: var(--semicorrect) !important;
    border-color: var(--semicorrect) !important;
    color: white;
}

.incorrect {
    background-color: var(--incorrect) !important;
    border-color: var(--incorrect) !important;
    color: white;
}

/* ------------------------------------------------------------
   Board tiles
   ------------------------------------------------------------ */

.tile {
    border-radius: 0.375rem;
    transition: border-color 0.15s ease, transform 0.1s ease;
    border-color: var(--tile-border);
}

/* empty tiles need a clearly visible outline (the generic
   .border-neutral-300 override above is too subtle for the board) */
.tile.border-neutral-300 {
    border-color: var(--tile-border) !important;
}

.tile.border-neutral-500,
.tile.border-neutral-300.filled {
    border-color: var(--tile-border-filled) !important;
}

/* letter typed in: quick pop */
.pop {
    animation: pop 0.12s ease-in-out;
    border-color: var(--tile-border-filled) !important;
}

@keyframes pop {
    0% {
        transform: scale(0.8);
    }

    50% {
        transform: scale(1.12);
    }

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

/* word submitted: staggered flip reveal */
.flip {
    animation: flip-in 0.45s ease both;
    backface-visibility: hidden;
}

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

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

.flip.d0 { animation-delay: 0.00s; }
.flip.d1 { animation-delay: 0.15s; }
.flip.d2 { animation-delay: 0.30s; }
.flip.d3 { animation-delay: 0.45s; }
.flip.d4 { animation-delay: 0.60s; }

/* invalid word: shake the whole row */
.shake {
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    15% { transform: translateX(-6px); }
    30% { transform: translateX(6px); }
    45% { transform: translateX(-5px); }
    60% { transform: translateX(5px); }
    75% { transform: translateX(-3px); }
    90% { transform: translateX(3px); }
}

/* winning row: staggered bounce (runs together with the flip reveal,
   which is why the animation shorthand lists both) */
.dance {
    animation: dance 0.7s ease both;
}

.flip.dance {
    animation: flip-in 0.45s ease both, dance 0.7s ease both;
}

@keyframes dance {
    0%, 100% { transform: translateY(0); }
    30% { transform: translateY(-45%); }
    50% { transform: translateY(8%); }
    70% { transform: translateY(-18%); }
    85% { transform: translateY(4%); }
}

.flip.dance.d0 { animation-delay: 0.00s, 0.90s; }
.flip.dance.d1 { animation-delay: 0.15s, 1.00s; }
.flip.dance.d2 { animation-delay: 0.30s, 1.10s; }
.flip.dance.d3 { animation-delay: 0.45s, 1.20s; }
.flip.dance.d4 { animation-delay: 0.60s, 1.30s; }

/* ------------------------------------------------------------
   Keyboard
   ------------------------------------------------------------ */

.key {
    background-color: var(--key-bg);
    color: var(--key-text);
    border-radius: 0.375rem;
    transition: background-color 0.15s ease, transform 0.06s ease, color 0.3s ease;
    user-select: none;
    touch-action: manipulation;
}

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

.key:active {
    transform: scale(0.92);
}

.key.correct,
.key.semicorrect,
.key.incorrect {
    transition: background-color 0.3s ease 1.1s, color 0.3s ease 1.1s, transform 0.06s ease;
}

/* ------------------------------------------------------------
   Modals, cards & notifications
   ------------------------------------------------------------ */

.modal-backdrop {
    background-color: rgba(0, 0, 0, 0.45) !important;
    opacity: 1 !important;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    animation: fade-in 0.2s ease both;
}

.modal-card {
    background-color: var(--surface);
    border-color: var(--surface-border) !important;
    box-shadow: 0 20px 50px -12px var(--shadow-color);
    animation: modal-in 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}

@keyframes modal-in {
    0% {
        opacity: 0;
        transform: translateY(18px) scale(0.96);
    }

    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes fade-in {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

/* toast notification */
.toast {
    background-color: var(--text) !important;
    color: var(--bg) !important;
    box-shadow: 0 10px 30px -8px var(--shadow-color);
    animation: toast-in 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}

.toast p {
    color: var(--bg) !important;
}

@keyframes toast-in {
    0% {
        opacity: 0;
        transform: translateY(-16px) scale(0.95);
    }

    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ------------------------------------------------------------
   Landing page
   ------------------------------------------------------------ */

.hero-title {
    background-image: linear-gradient(90deg, #06b6d4, #3b82f6, #8b5cf6);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.hero-globe {
    display: inline-block;
    animation: float 5s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0) rotate(-3deg); }
    50% { transform: translateY(-7px) rotate(3deg); }
}

.search-input {
    background-color: var(--surface);
    color: var(--text);
    border: 1px solid var(--surface-border);
    border-radius: 9999px;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
    box-shadow: 0 4px 14px -4px var(--shadow-color);
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-input:focus {
    outline: none;
    border-color: #06b6d4;
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.25), 0 4px 14px -4px var(--shadow-color);
}

.lang-card {
    background-color: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: 0.75rem;
    box-shadow: 0 2px 8px -2px var(--shadow-color);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
    animation: card-in 0.4s ease both;
}

.lang-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 28px -8px var(--shadow-color);
    border-color: #06b6d4;
}

.lang-card:active {
    transform: translateY(-1px) scale(0.99);
}

@keyframes card-in {
    0% {
        opacity: 0;
        transform: translateY(14px);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.lang-card-native {
    font-weight: 600;
    color: var(--text);
}

.lang-card-name {
    font-size: 0.85rem;
    font-style: italic;
    color: var(--text-muted);
}

/* staggered entrance for the first few cards; the rest share the last delay */
.stagger > .lang-card { animation-delay: 0.36s; }
.stagger > .lang-card:nth-child(1) { animation-delay: 0.03s; }
.stagger > .lang-card:nth-child(2) { animation-delay: 0.06s; }
.stagger > .lang-card:nth-child(3) { animation-delay: 0.09s; }
.stagger > .lang-card:nth-child(4) { animation-delay: 0.12s; }
.stagger > .lang-card:nth-child(5) { animation-delay: 0.15s; }
.stagger > .lang-card:nth-child(6) { animation-delay: 0.18s; }
.stagger > .lang-card:nth-child(7) { animation-delay: 0.21s; }
.stagger > .lang-card:nth-child(8) { animation-delay: 0.24s; }
.stagger > .lang-card:nth-child(9) { animation-delay: 0.27s; }
.stagger > .lang-card:nth-child(10) { animation-delay: 0.30s; }
.stagger > .lang-card:nth-child(11) { animation-delay: 0.33s; }
.stagger > .lang-card:nth-child(12) { animation-delay: 0.36s; }

/* ------------------------------------------------------------
   Header
   ------------------------------------------------------------ */

.app-header {
    border-color: var(--surface-border) !important;
}

.icon-btn {
    color: var(--text-muted);
    border-radius: 0.5rem;
    padding: 0.25rem;
    transition: color 0.15s ease, background-color 0.15s ease, transform 0.1s ease;
}

.icon-btn:hover {
    color: var(--text);
    background-color: var(--bg-accent-2);
}

.icon-btn:active {
    transform: scale(0.9);
}

/* ------------------------------------------------------------
   Accessibility
   ------------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-delay: 0s !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        transition-delay: 0s !important;
    }
}
