/* Import Google Font */
@import url('https://fonts.googleapis.com/css2?family=Lato:wght@300;400;700&family=Quicksand:wght@400;500;600;700&display=swap');

/* Define CSS Variables for Ghibli theme */
:root {
    --primary-color: #5c9ead;
    --primary-light: #8fbbc8;
    --primary-dark: #3c7d8b;
    --accent-color: #f4a261;
    --background-light: #f1f7ed;
    --background-color: #edf6f9;
    --background-gradient: linear-gradient(135deg, #edf6f9 0%, #f8f9fa 100%);
    --card-background: linear-gradient(120deg, #ffffff 0%, #f1faee 100%);
    --text-dark: #2c3e50;
    --text-light: #546a7b;
    --shadow-color: rgba(0, 0, 0, 0.08);
    --shadow-hover-color: rgba(0, 0, 0, 0.15);
    --font-family: 'Quicksand', sans-serif;
    --content-font: 'Lato', sans-serif;
}

body {
    font-family: var(--font-family);
    line-height: 1.7;
    margin: 0;
    padding: 20px;
    background: var(--background-gradient);
    color: var(--text-dark);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
    /* Ghibli-inspired subtle cloud pattern */
    background-image: 
        url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M30,50 Q40,30 50,50 Q60,30 70,50' stroke='%238fbbc8' stroke-width='1' fill='none' opacity='0.3' /%3E%3C/svg%3E");
    background-size: 300px;
}

.container {
    background-color: rgba(255, 255, 255, 0.9);
    padding: 35px 40px;
    border-radius: 20px;
    box-shadow: 0 8px 25px var(--shadow-color);
    width: 90%;
    max-width: 750px;
    text-align: center;
    margin: 40px auto;
    z-index: 1;
    position: relative;
    transition: transform 0.3s ease-in-out;
    /* Ghibli-inspired hand-drawn border */
    border: 2px solid #5c9ead;
    border-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0,0 C30,10 70,10 100,0 C90,30 90,70 100,100 C70,90 30,90 0,100 C10,70 10,30 0,0 Z' stroke='%235c9ead' stroke-width='3' fill='none' /%3E%3C/svg%3E") 1;
}

/* Style the header and category title */
.category-header {
    color: var(--primary-dark);
    margin-bottom: 35px;
    font-size: 2em;
    font-weight: 600;
    padding-bottom: 10px;
    position: relative;
    display: inline-block;
}

.category-header::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background-image: linear-gradient(90deg, transparent, var(--primary-color), transparent);
}

#category-title {
    color: var(--primary-color);
    font-weight: 700;
    transition: color 0.3s ease;
    position: relative;
}

#category-title::after {
    content: "";
    position: absolute;
    width: 25px;
    height: 25px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath d='M12,3 C7.58,3 4,6.58 4,11 C4,12.85 4.63,14.55 5.68,15.9 L5.23,16.07 C4.95,16.17 4.7,16.31 4.46,16.46 C3.56,17 3,18 3,19.13 C3,20.73 4.27,22 5.87,22 C6.16,22 6.44,21.95 6.7,21.86 L11.29,20.13 C11.52,20.04 11.75,20 12,20 C16.42,20 20,16.42 20,12 C20,7.58 16.42,4 12,4 Z' fill='%23f4a261'/%3E%3C/svg%3E");
    background-size: contain;
    right: -30px;
    top: -15px;
    opacity: 0.7;
}

#sentence-cards-container {
    margin-top: 30px;
    margin-bottom: 40px;
    text-align: left;
    perspective: 1000px;
}

/* Keyframes for card entrance animation */
@keyframes cardEnter {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes floatAnimation {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-5px);
    }
}

.sentence-card {
    background: var(--card-background);
    border: none;
    border-radius: 15px;
    padding: 22px 28px;
    margin-bottom: 25px;
    box-shadow: 0 5px 15px var(--shadow-color);
    opacity: 0;
    animation: cardEnter 0.6s ease-out forwards;
    animation-delay: var(--animation-delay, 0s);
    transition: all 0.3s ease-in-out;
    font-family: var(--content-font);
    position: relative;
    overflow: hidden;
}

.sentence-card::before {
    content: "";
    position: absolute;
    width: 7px;
    height: 100%;
    background: var(--accent-color);
    left: 0;
    top: 0;
    border-radius: 15px 0 0 15px;
}

.sentence-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px var(--shadow-hover-color);
    background: linear-gradient(120deg, #ffffff 0%, #e3f6fc 100%);
}

.sentence-card p {
    margin: 10px 0;
}

.english-sentence {
    font-weight: 600;
    color: var(--text-dark);
    font-size: 1.2em;
    position: relative;
    padding-left: 10px;
}

.english-sentence::before {
    content: "•";
    position: absolute;
    left: 0;
    color: var(--accent-color);
}

.chinese-translation {
    color: var(--text-light);
    font-size: 1.05em;
    font-style: italic;
    padding-left: 20px;
    position: relative;
}

.chinese-translation::before {
    content: "⟹";
    position: absolute;
    left: 0;
    color: var(--primary-light);
    opacity: 0.7;
}

/* --- Navigation Buttons Styling --- */

.nav-button {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    font-size: 1.5em;
    cursor: pointer;
    box-shadow: 0 4px 10px var(--shadow-hover-color);
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    line-height: 1;
    padding: 0;
    /* Ghibli-inspired hand-drawn effect */
    background-image: 
        radial-gradient(circle at 30% 30%, rgba(255,255,255,0.3) 0%, transparent 20%),
        radial-gradient(circle at 70% 70%, rgba(0,0,0,0.1) 0%, transparent 20%);
}

.nav-button::after {
    content: "";
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    border: 2px dashed rgba(255,255,255,0.5);
    border-radius: 50%;
    animation: floatAnimation 3s ease-in-out infinite;
}

.nav-button:hover {
    background: var(--primary-dark);
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 8px 20px var(--shadow-hover-color);
}

.nav-button:active {
    transform: translateY(-50%) scale(1.05);
    box-shadow: 0 3px 8px var(--shadow-hover-color);
}

.nav-button:disabled {
    background: #cccccc;
    cursor: not-allowed;
    opacity: 0.5;
    box-shadow: none;
    transform: translateY(-50%) scale(1);
}

.nav-button:disabled::after {
    animation: none;
    opacity: 0.3;
}

#prev-button {
    left: 25px;
}

#next-button {
    right: 25px;
}

.sentence-card {
    cursor: pointer;
    transition: all 0.3s ease-in-out;
    position: relative;
}
  
.sentence-card:hover,
.sentence-card:focus {
    background: linear-gradient(120deg, #ffffff 0%, #e3f6fc 100%);
    box-shadow: 0 8px 20px var(--shadow-hover-color);
    outline: none;
}

.sentence-card:focus {
    border: 2px solid var(--primary-color);
}
  
.sentence-card:active {
    transform: scale(0.98);
    background: linear-gradient(120deg, #f8f9fa 0%, #d9f2fa 100%);
}

/* Add animation for when a card is clicked for speech */
.sentence-card.speaking {
    animation: none;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(92, 158, 173, 0.4);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(92, 158, 173, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(92, 158, 173, 0);
    }
}

/* Add a visual indicator for speaking state */
.sentence-card.speaking::after {
    content: none;
}

@keyframes bounce {
    from { transform: translateY(0); }
    to { transform: translateY(-3px); }
}

/* Ghibli-specific themed elements */
.ghibli-clouds {
    position: absolute;
    top: -40px;
    left: 0;
    right: 0;
    height: 60px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='60' viewBox='0 0 400 60'%3E%3Cpath d='M20,40 Q40,20 60,40 Q80,20 100,40 Q120,20 140,40 Q160,20 180,40 Q200,20 220,40 Q240,20 260,40 Q280,20 300,40 Q320,20 340,40 Q360,20 380,40' stroke='%23ffffff' stroke-width='3' fill='none' /%3E%3C/svg%3E");
    background-repeat: repeat-x;
    opacity: 0.7;
    z-index: 0;
}

.totoro-icon {
    position: absolute;
    top: -15px;
    right: 20px;
    width: 70px;
    height: 70px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M50,10 C30,10 15,30 15,55 C15,75 30,90 50,90 C70,90 85,75 85,55 C85,30 70,10 50,10 Z' fill='%23555555'/%3E%3Ccircle cx='35' cy='40' r='5' fill='white'/%3E%3Ccircle cx='65' cy='40' r='5' fill='white'/%3E%3Cpath d='M40,55 C45,65 55,65 60,55' stroke='white' stroke-width='2' fill='none'/%3E%3Cpath d='M30,20 L40,10 M70,20 L60,10' stroke='%23555555' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    opacity: 0.9;
    transition: transform 0.3s ease;
}

.totoro-icon:hover {
    transform: scale(1.1) rotate(5deg);
}

.ghibli-footer {
    position: relative;
    height: 40px;
    margin-top: 30px;
    overflow: hidden;
}

.footer-grass {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 30px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='30' viewBox='0 0 300 30'%3E%3Cpath d='M0,30 C10,25 15,5 20,30 C25,25 30,10 35,30 C40,25 45,15 50,30 C55,25 60,5 65,30 C70,25 75,10 80,30 C85,25 90,15 95,30 C100,25 105,5 110,30 C115,25 120,10 125,30 C130,25 135,15 140,30 C145,25 150,5 155,30 C160,25 165,10 170,30 C175,25 180,15 185,30 C190,25 195,5 200,30 C205,25 210,10 215,30 C220,25 225,15 230,30 C235,25 240,5 245,30 C250,25 255,10 260,30 C265,25 270,15 275,30 C280,25 285,5 290,30 C295,25 300,10 305,30' stroke='%235c9ead' stroke-width='2' fill='%238fbbc8' fill-opacity='0.2'/%3E%3C/svg%3E");
    background-repeat: repeat-x;
    opacity: 0.7;
}

/* Adjust existing elements to fit the Ghibli theme */
header {
    position: relative;
    margin-bottom: 40px;
}

.category-header {
    position: relative;
    z-index: 2;
}

/* Add responsive styles for smaller screens */
@media (max-width: 768px) {
    .container {
        width: 95%;
        padding: 25px 20px;
    }
    
    .nav-button {
        width: 50px;
        height: 50px;
    }
    
    .totoro-icon {
        width: 50px;
        height: 50px;
        top: -10px;
        right: 10px;
    }
    
    .category-header {
        font-size: 1.6em;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }
    
    .container {
        padding: 20px 15px;
    }
    
    .sentence-card {
        padding: 18px 20px;
    }
    
    .nav-button {
        width: 45px;
        height: 45px;
    }
    
    #prev-button {
        left: 10px;
    }
    
    #next-button {
        right: 10px;
    }
}