/* Kids Learning - Main Stylesheet - MOBILE OPTIMIZED */

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

/* Header Styles */
.kids-header,
.category-header {
    text-align: center;
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 3px solid #667eea;
}

.kids-header h1,
.category-header h1 {
    font-size: 2.5em;
    color: #667eea;
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1.2em;
    color: #666;
}

.logo a,
.back-button {
    display: inline-block;
    color: #667eea;
    text-decoration: none;
    font-weight: bold;
    padding: 10px 20px;
    border-radius: 10px;
    background: #f0f0f0;
    transition: all 0.3s;
    margin-bottom: 20px;
}

.logo a:hover,
.back-button:hover {
    background: #667eea;
    color: white;
    transform: translateX(-5px);
}

.logo a:active,
.back-button:active {
    transform: translateX(-5px) scale(0.95);
}

/* Categories Grid - FIT 3 PER ROW */
.categories-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 25px;
    margin-bottom: 40px;
}

.category-card {
    position: relative;
    border-radius: 15px;
    padding: 0;
    text-decoration: none;
    color: white;
    transition: all 0.3s;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 300px;
    overflow: hidden;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.category-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 1;
}

.category-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.3);
}

.category-card:active {
    transform: translateY(-5px);
}

.category-card:hover::before {
    background: rgba(0, 0, 0, 0.2);
}

.category-icon {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.category-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.category-icon.no-icon {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.category-icon.no-icon span {
    font-size: 5em;
    z-index: 2;
}

.category-info {
    position: relative;
    z-index: 2;
    margin-top: auto;
    margin-bottom: 20px;
    background: rgba(255, 255, 255, 0.9);
    padding: 15px 25px;
    border-radius: 10px;
    backdrop-filter: blur(10px);
}

.category-info h3 {
    font-size: 1.5em;
    margin-bottom: 5px;
    text-align: center;
    color: #2d3748;
}

.item-count {
    font-size: 0.9em;
    text-align: center;
    color: #4a5568;
}

.category-languages {
    position: relative;
    z-index: 2;
    display: flex;
    gap: 5px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.lang-badge {
    background: rgba(255, 255, 255, 0.9);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.8em;
    font-weight: 600;
    color: #2d3748;
    backdrop-filter: blur(10px);
}

/* Language Selector */
.language-selector {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.lang-btn {
    padding: 12px 24px;
    border: 2px solid #667eea;
    background: white;
    color: #667eea;
    border-radius: 25px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

.lang-btn:hover {
    background: #f0f0f0;
    transform: scale(1.05);
}

.lang-btn:active {
    transform: scale(0.95);
}

.lang-btn.active {
    background: #667eea;
    color: white;
}

/* Learning Items Grid - FILL ROWS PROPERLY */
.items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.learning-card {
    background: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    transition: all 0.3s;
    cursor: pointer;
    border: 3px solid transparent;
}

.learning-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    border-color: #667eea;
}

.learning-card:active {
    transform: translateY(-2px);
}

.item-image {
    width: 100%;
    height: 150px;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 15px;
    background: #f0f0f0;
}

.item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.item-content {
    text-align: center;
}

.item-word {
    font-size: 1.3em;
    color: #333;
    margin-bottom: 10px;
    transition: opacity 0.15s ease-in-out;
}

.play-audio-btn {
    background: #667eea;
    color: white;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 1.5em;
    cursor: pointer;
    transition: all 0.3s;
}

.play-audio-btn:hover {
    background: #764ba2;
    transform: scale(1.1);
}

.play-audio-btn:active {
    transform: scale(0.95);
}

/* AdSense Container - ONLY AT BOTTOM */
.adsense-container {
    width: 100%;
    min-height: 100px;
    background: #f9f9f9;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed #ddd;
    margin-top: 30px;
}

.ad-placeholder {
    color: #999;
    font-style: italic;
}

/* Action Buttons */
.action-buttons {
    text-align: center;
    margin: 30px 0;
}

.quiz-btn {
    display: inline-block;
    padding: 15px 40px;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    text-decoration: none;
    border-radius: 30px;
    font-size: 1.2em;
    font-weight: bold;
    transition: all 0.3s;
    box-shadow: 0 5px 15px rgba(245, 87, 108, 0.3);
}

.quiz-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 25px rgba(245, 87, 108, 0.4);
}

.quiz-btn:active {
    transform: scale(0.98);
}

/* Footer */
.kids-footer {
    text-align: center;
    padding: 20px 0;
    margin-top: 40px;
    border-top: 2px solid #f0f0f0;
    color: #666;
}

.kids-footer a {
    color: #667eea;
    text-decoration: none;
    margin: 0 10px;
}

.kids-footer a:hover {
    text-decoration: underline;
}

/* Empty States */
.no-categories,
.no-items {
    text-align: center;
    padding: 60px 20px;
    color: #999;
    font-size: 1.2em;
}

/* No image placeholder */
.no-image-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
}

/* Loading Animation */
.loading {
    text-align: center;
    padding: 40px;
}

.loading::after {
    content: "Loading...";
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {

    0%,
    20% {
        content: "Loading";
    }

    40% {
        content: "Loading.";
    }

    60% {
        content: "Loading..";
    }

    80%,
    100% {
        content: "Loading...";
    }
}

/* ============================================
   MOBILE RESPONSIVE IMPROVEMENTS
   ============================================ */

/* Tablet and below */
@media (max-width: 900px) {
    .categories-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }

    .category-card {
        min-height: 250px;
    }

    .category-info h3 {
        font-size: 1.3em;
    }
}

/* Mobile Landscape and Portrait */
@media (max-width: 768px) {
    body {
        padding: 15px;
    }

    .container {
        padding: 20px;
        border-radius: 15px;
    }

    .kids-header h1,
    .category-header h1 {
        font-size: 2em;
    }

    .subtitle {
        font-size: 1em;
    }

    .categories-container {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .category-card {
        min-height: 220px;
    }

    .items-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 15px;
    }

    .learning-card {
        padding: 15px;
    }

    .item-image {
        height: 120px;
    }

    .item-word {
        font-size: 1.1em;
    }

    .play-audio-btn {
        width: 45px;
        height: 45px;
        font-size: 1.3em;
    }

    .language-selector {
        gap: 10px;
    }

    .lang-btn {
        padding: 10px 18px;
        font-size: 0.9em;
    }

    .quiz-btn {
        padding: 12px 30px;
        font-size: 1.1em;
    }

    .kids-footer {
        font-size: 0.9em;
    }

    .kids-footer a {
        display: inline-block;
        margin: 5px;
    }
}

/* Small Mobile Devices */
@media (max-width: 480px) {
    body {
        padding: 10px;
    }

    .container {
        padding: 15px;
    }

    .kids-header h1,
    .category-header h1 {
        font-size: 1.6em;
    }

    .subtitle {
        font-size: 0.9em;
    }

    .logo a,
    .back-button {
        padding: 8px 15px;
        font-size: 0.9em;
    }

    .items-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .learning-card {
        padding: 12px;
    }

    .item-image {
        height: 100px;
    }

    .item-word {
        font-size: 1em;
    }

    .play-audio-btn {
        width: 40px;
        height: 40px;
        font-size: 1.2em;
    }

    .lang-btn {
        padding: 8px 12px;
        font-size: 0.85em;
    }

    .category-card {
        min-height: 200px;
    }

    .category-icon.no-icon span {
        font-size: 3.5em;
    }

    .category-info {
        padding: 12px 15px;
    }

    .category-info h3 {
        font-size: 1.2em;
    }

    .quiz-btn {
        padding: 10px 25px;
        font-size: 1em;
    }
}

/* Extra Small Mobile */
@media (max-width: 360px) {

    .kids-header h1,
    .category-header h1 {
        font-size: 1.4em;
    }

    .items-grid {
        gap: 10px;
    }

    .item-image {
        height: 90px;
    }

    .lang-btn {
        padding: 6px 10px;
        font-size: 0.8em;
    }
}

/* Prevent text selection on mobile */
@media (max-width: 768px) {

    .category-card,
    .learning-card,
    .lang-btn,
    .quiz-btn {
        -webkit-user-select: none;
        user-select: none;
    }
}

/* Fix for iOS Safari bottom bar */
@supports (-webkit-touch-callout: none) {
    body {
        min-height: -webkit-fill-available;
    }
}