@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;700;900&family=Fredoka+One&display=swap');

:root {
    --primary-color: #FF5E7E;
    --secondary-color: #43D8C9;
    --accent-color: #FFD166;
    --bg-gradient-1: #90F7EC;
    --bg-gradient-2: #32CCBC;
    --text-color: #2D3436;
    --card-bg: rgba(255, 255, 255, 0.9);
    --shadow: 0 15px 35px rgba(0,0,0,0.1);
    --border-radius: 30px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Cairo', sans-serif;
}

body {
    background: linear-gradient(135deg, var(--bg-gradient-1), var(--bg-gradient-2), #f3a683, #f8a5c2);
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    position: relative;
}

/* Floating Background Bubbles */
body::before, body::after {
    content: '';
    position: absolute;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(255,255,255,0.4) 0%, rgba(255,255,255,0) 70%);
    border-radius: 50%;
    z-index: -1;
    animation: float 8s infinite ease-in-out;
}

body::after {
    width: 200px;
    height: 200px;
    top: 20%;
    right: 10%;
    animation-delay: -4s;
}

body::before {
    bottom: 10%;
    left: 10%;
}

@keyframes float {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-30px) scale(1.1); }
}

@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

#app {
    width: 100%;
    max-width: 1200px;
    min-height: 100vh;
    padding: 2rem;
    position: relative;
    z-index: 1;
}

.screen {
    display: none;
    flex-direction: column;
    align-items: center;
    animation: zoomIn 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.screen.active {
    display: flex;
}

@keyframes zoomIn {
    from { opacity: 0; transform: scale(0.8) translateY(50px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* Start Screen */
#start-screen {
    justify-content: center;
    height: calc(100vh - 4rem);
}

.logo-container {
    text-align: center;
    margin-bottom: 3rem;
    animation: floatingLogo 3s infinite ease-in-out;
}

@keyframes floatingLogo {
    0%, 100% { transform: translateY(0) rotate(-2deg); }
    50% { transform: translateY(-20px) rotate(2deg); }
}

.logo-container h1 {
    font-size: 5rem;
    color: white;
    text-shadow: 4px 6px 0px var(--primary-color), 0 10px 20px rgba(0,0,0,0.2);
    margin-bottom: 1rem;
    font-family: 'Fredoka One', 'Cairo', cursive;
    letter-spacing: 2px;
}

.logo-container p {
    font-size: 1.8rem;
    color: #fff;
    font-weight: 900;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
    background: rgba(0,0,0,0.1);
    padding: 0.5rem 2rem;
    border-radius: 50px;
    display: inline-block;
}

.input-container {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    padding: 3.5rem;
    border-radius: var(--border-radius);
    box-shadow: 0 20px 50px rgba(0,0,0,0.15), inset 0 0 0 2px rgba(255,255,255,0.5);
    text-align: center;
    width: 100%;
    max-width: 550px;
    position: relative;
    overflow: hidden;
}

.input-container::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 10px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color), var(--accent-color));
}

.input-container label {
    display: block;
    font-size: 1.8rem;
    margin-bottom: 1.5rem;
    font-weight: 900;
    color: var(--primary-color);
}

input[type="text"] {
    width: 100%;
    padding: 1.2rem;
    font-size: 1.8rem;
    border: 4px solid #f1f2f6;
    border-radius: 20px;
    margin-bottom: 2.5rem;
    text-align: center;
    font-weight: bold;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    background: rgba(255,255,255,0.8);
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--secondary-color);
    transform: scale(1.05);
    box-shadow: 0 10px 25px rgba(67, 216, 201, 0.3);
}

.btn {
    border: none;
    border-radius: 20px;
    font-size: 1.8rem;
    font-weight: 900;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    font-family: 'Cairo', sans-serif;
    position: relative;
    overflow: hidden;
}

.primary-btn {
    background: linear-gradient(45deg, var(--primary-color), #ff9ff3);
    color: white;
    padding: 1.2rem 3rem;
    width: 100%;
    box-shadow: 0 8px 0 #d63031, 0 15px 20px rgba(255, 94, 126, 0.4);
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

.primary-btn:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 12px 0 #d63031, 0 20px 25px rgba(255, 94, 126, 0.5);
    animation: none;
}

.primary-btn:active {
    transform: translateY(4px);
    box-shadow: 0 4px 0 #d63031;
}

/* Common Header */
.header {
    text-align: center;
    margin-bottom: 3.5rem;
    width: 100%;
    position: relative;
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
}

.header h2 {
    font-size: 3.5rem;
    background: linear-gradient(45deg, var(--primary-color), #8e44ad);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-family: 'Fredoka One', 'Cairo', cursive;
}

.header p {
    font-size: 1.5rem;
    color: #636e72;
    font-weight: bold;
}

/* Back button */
#back-btn {
    position: absolute;
    right: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: var(--accent-color);
    color: #2d3436;
    padding: 0.8rem 1.8rem;
    font-size: 1.2rem;
    box-shadow: 0 6px 0 #e1b12c;
    z-index: 10;
}

#back-btn:hover {
    transform: translateY(calc(-50% - 4px)) scale(1.1);
    box-shadow: 0 10px 0 #e1b12c;
}

#back-btn:active {
    transform: translateY(calc(-50% + 4px));
    box-shadow: 0 2px 0 #e1b12c;
}

/* Grid Layouts */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 2.5rem;
    width: 100%;
    perspective: 1000px;
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    text-align: center;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 4px solid white;
    position: relative;
    transform-style: preserve-3d;
    animation: cardAppear 0.5s ease backwards;
    overflow: hidden;
}

.card-img {
    width: 100%;
    height: 160px;
    background-size: cover;
    background-position: center;
    border-bottom: 4px solid var(--accent-color);
    transition: transform 0.4s ease;
}

.card:hover .card-img {
    transform: scale(1.1);
}

.card-content {
    padding: 1.5rem;
    position: relative;
    z-index: 1;
    background: var(--card-bg);
}

/* Stagger card animations based on nth-child */
.card:nth-child(1) { animation-delay: 0.1s; }
.card:nth-child(2) { animation-delay: 0.2s; }
.card:nth-child(3) { animation-delay: 0.3s; }
.card:nth-child(4) { animation-delay: 0.4s; }
.card:nth-child(5) { animation-delay: 0.5s; }
.card:nth-child(6) { animation-delay: 0.6s; }
.card:nth-child(7) { animation-delay: 0.7s; }
.card:nth-child(8) { animation-delay: 0.8s; }

@keyframes cardAppear {
    from { opacity: 0; transform: translateY(50px) rotateX(10deg); }
    to { opacity: 1; transform: translateY(0) rotateX(0); }
}

.card:hover {
    transform: translateY(-15px) scale(1.08) rotateY(5deg);
    border-color: var(--primary-color);
    box-shadow: -10px 20px 40px rgba(0,0,0,0.2);
    z-index: 2;
}

.card.lesson-card .icon {
    font-size: 5rem;
    margin-bottom: 1.5rem;
    display: inline-block;
    transition: transform 0.3s ease;
}

.card:hover .icon {
    transform: scale(1.2) rotate(10deg);
}

.card.lesson-card h3 {
    font-size: 2rem;
    color: var(--text-color);
    font-weight: 900;
}

/* Word Cards */
.word-card {
    display: flex;
    flex-direction: column;
}

.word-card .card-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2rem 1rem;
    background: linear-gradient(135deg, rgba(255,255,255,0.95), rgba(255,255,255,0.85));
    flex-grow: 1;
}

.word-card .ar-word {
    font-size: 3rem;
    font-weight: 900;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 0px rgba(255, 94, 126, 0.2);
}

.word-card .en-word {
    font-size: 1.8rem;
    color: #636e72;
    font-weight: bold;
    background: #dfe6e9;
    padding: 0.2rem 1.5rem;
    border-radius: 20px;
    margin-top: 1rem;
}

/* Dialect Selector */
.dialect-selector {
    margin-bottom: 3.5rem;
    text-align: center;
    background: var(--card-bg);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    display: inline-block;
    border: 3px dashed var(--secondary-color);
    backdrop-filter: blur(10px);
}

.dialect-selector p {
    font-size: 1.5rem;
    font-weight: 900;
    margin-bottom: 1.5rem;
    color: var(--primary-color);
}

.dialects-container {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

.dialect-btn {
    background: white;
    border: 4px solid #dfe4ea;
    border-radius: 20px;
    padding: 1rem 2rem;
    font-size: 1.4rem;
    cursor: pointer;
    font-family: 'Cairo', sans-serif;
    font-weight: 900;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    gap: 0.8rem;
    color: #2d3436;
    box-shadow: 0 6px 0 #dfe4ea;
}

.dialect-btn:hover {
    background: #fff;
    border-color: var(--accent-color);
    transform: translateY(-5px);
    box-shadow: 0 11px 0 var(--accent-color);
}

.dialect-btn:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 var(--accent-color);
}

.dialect-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: #d63031;
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 11px 0 #d63031, 0 15px 20px rgba(255, 94, 126, 0.4);
}

/* Responsive */
@media (max-width: 768px) {
    .logo-container h1 { font-size: 3.5rem; }
    .header h2 { font-size: 2.5rem; }
    #back-btn { position: static; transform: none; margin-bottom: 1.5rem; display: inline-block; width: 100%; }
    .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1.5rem; }
    .card { padding: 1.5rem; }
    .card.lesson-card .icon { font-size: 3.5rem; }
    .card.lesson-card h3 { font-size: 1.5rem; }
    .word-card .ar-word { font-size: 2.2rem; }
    .word-card .en-word { font-size: 1.2rem; }
    .dialect-btn { font-size: 1.1rem; padding: 0.8rem 1.2rem; }
}
