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

body {
    font-family: 'Indie Flower', cursive;
    color: #333;
    line-height: 1.6;
    overflow-x: hidden;
    position: relative;
    transition: background 0.5s ease;
}

/* Day Mode */
body.day-mode {
    background: #87CEEB; /* Sky blue background */
}

/* Night Mode */
body.night-mode {
    background: #0a1128; /* Dark blue night sky */
    color: #f0f0f0;
}

/* Day: Sky and Ground */
body.day-mode::before {
    content: '';
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40vh;
    background: #7CCC7C; /* Grass green */
    z-index: -1;
    transition: background 0.5s ease;
}

/* Night: Sky and Ground */
body.night-mode::before {
    content: '';
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40vh;
    background: #17341B; /* Dark grass */
    z-index: -1;
}

/* Day: Sun */
body.day-mode::after {
    content: '';
    position: fixed;
    top: 30px;
    right: 50px;
    width: 80px;
    height: 80px;
    background: #FFD700; /* Gold for the sun */
    border-radius: 50%;
    box-shadow: 0 0 30px 10px rgba(255, 215, 0, 0.5);
    z-index: -1;
    transition: all 0.5s ease;
}

/* Night: Moon */
body.night-mode::after {
    content: '';
    position: fixed;
    top: 30px;
    right: 50px;
    width: 60px;
    height: 60px;
    background: #E6E6FA; /* Lavender color for moon */
    border-radius: 50%;
    box-shadow: 0 0 30px 10px rgba(230, 230, 250, 0.3);
    z-index: -1;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Controls */
.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding: 0.5rem 1rem;
    border-radius: 15px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(5px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* Dark Mode Toggle */
.switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 30px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #87CEEB;
    transition: .4s;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 5px;
}

.night-mode .slider {
    background-color: #0a1128;
}

.slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    z-index: 1;
}

input:checked + .slider:before {
    transform: translateX(30px);
}

.slider.round {
    border-radius: 30px;
}

.slider.round:before {
    border-radius: 50%;
}

.icon {
    z-index: 0;
    font-size: 16px;
    line-height: 1;
}

.moon-icon {
    margin-left: auto;
}

/* Language Selector */
.language-selector {
    display: flex;
    gap: 5px;
}

.lang-btn {
    background: rgba(255, 255, 255, 0.5);
    border: none;
    padding: 5px 10px;
    border-radius: 15px;
    cursor: pointer;
    font-family: 'Indie Flower', cursive;
    font-weight: bold;
    transition: all 0.3s ease;
}

.lang-btn:hover {
    background: rgba(255, 255, 255, 0.8);
}

.lang-btn.active {
    background: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Night mode language buttons */
body.night-mode .lang-btn {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

body.night-mode .lang-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

body.night-mode .lang-btn.active {
    background: rgba(255, 255, 255, 0.5);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

/* Language specific content */
.lang-en, .lang-es, .lang-ru {
    display: none;
}

html[lang="en"] .lang-en {
    display: block;
}

html[lang="es"] .lang-es {
    display: block;
}

html[lang="ru"] .lang-ru {
    display: block;
}

/* For spans inside links */
a .lang-en, a .lang-es, a .lang-ru {
    display: none;
}

html[lang="en"] a .lang-en {
    display: inline;
}

html[lang="es"] a .lang-es {
    display: inline;
}

html[lang="ru"] a .lang-ru {
    display: inline;
}

header {
    text-align: center;
    margin-bottom: 2rem;
    padding-top: 1rem;
    content-visibility: auto; /* Performance optimization */
}

h1 {
    font-size: 3rem;
    margin-bottom: 1rem;
    text-shadow: 2px 2px 0px #fff;
    animation: wobble 2s ease-in-out infinite;
    will-change: transform; /* Performance optimization */
}

/* Night mode heading shadow */
body.night-mode h1 {
    text-shadow: 2px 2px 0px #0a1128;
}

@keyframes wobble {
    0%, 100% { transform: rotate(-2deg); }
    50% { transform: rotate(2deg); }
}

header p {
    font-size: 1.5rem;
    text-shadow: 1px 1px 0px #fff;
}

/* Night mode paragraph shadow */
body.night-mode header p {
    text-shadow: 1px 1px 0px #0a1128;
}

.basket-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem 0;
    content-visibility: auto; /* Performance optimization */
}

.basket {
    background: #D2B48C; /* Tan color for basket */
    border-radius: 50% 50% 10% 10% / 80% 80% 20% 20%;
    padding: 2rem;
    box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
    position: relative;
    transform-style: preserve-3d;
    perspective: 1000px;
    max-width: 100%;
    transition: background 0.5s ease, box-shadow 0.5s ease;
}

/* Night mode basket */
body.night-mode .basket {
    background: #8B7355; /* Darker basket color */
    box-shadow: 0 10px 15px rgba(0, 0, 0, 0.4);
}

/* Basket handle */
.basket::before {
    content: '';
    position: absolute;
    top: -30px;
    left: 20%;
    right: 20%;
    height: 60px;
    border: 5px solid #A67C52;
    border-bottom: none;
    border-radius: 50% 50% 0 0;
    z-index: -1;
    transition: border-color 0.5s ease;
}

/* Night mode basket handle */
body.night-mode .basket::before {
    border-color: #6F4E37; /* Darker handle color */
}

.veg-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 2rem;
    padding: 1rem;
}

.veg-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: #333;
    transition: transform 0.3s ease, color 0.5s ease;
    position: relative;
    border: none;
    outline: none;
    -webkit-tap-highlight-color: transparent; /* Removes tap highlight on mobile */
}

/* Night mode link color */
body.night-mode .veg-link {
    color: #f0f0f0;
}

.veg-link:hover {
    transform: scale(1.05);
    outline: none;
    border: none;
}

.veg-link:focus {
    outline: none;
    border: none;
    -webkit-tap-highlight-color: transparent;
}

.veg-link:active {
    outline: none;
    border: none;
}

.veg-link:visited {
    outline: none;
    border: none;
}

/* Better shadows for vegetable images */
.veg-image {
    width: 100px;
    height: 100px;
    margin-bottom: 0.5rem;
    transition: transform 0.3s ease, filter 0.5s ease;
    object-fit: contain;
    /* Enhanced shadow that follows the image contour */
    filter: drop-shadow(2px 3px 3px rgba(0, 0, 0, 0.2));
    border: none !important;
    outline: none !important;
    background-color: transparent !important;
    box-shadow: none !important;
    /* Better transparency handling */
    image-rendering: -webkit-optimize-contrast; /* Improves image clarity */
    -webkit-backface-visibility: hidden; /* Fixes rendering issues */
    backface-visibility: hidden;
    will-change: transform, filter; /* Performance optimization for animations */
}

.veg-link:hover .veg-image {
    transform: scale(1.15);
    /* Enhanced shadow on hover */
    filter: drop-shadow(3px 4px 4px rgba(0, 0, 0, 0.25));
    outline: none;
    border: none;
}

/* Night mode image shadows */
body.night-mode .veg-image {
    /* Stronger, more pronounced shadow for night mode */
    filter: drop-shadow(2px 3px 4px rgba(0, 0, 0, 0.5)) brightness(0.85);
}

body.night-mode .veg-link:hover .veg-image {
    filter: drop-shadow(3px 4px 5px rgba(0, 0, 0, 0.6)) brightness(0.85);
}

/* Individual Vegetable Styles */
/* Tomato */
.tomato .veg-image {
    transform-origin: center bottom;
    animation: gentle-bounce 6s ease-in-out infinite alternate;
    will-change: transform; /* Performance optimization */
}

/* Night mode tomato */
body.night-mode .tomato .veg-image {
    animation-duration: 8s; /* Slower animation at night */
}

/* Bell Pepper */
.pepper .veg-image {
    transform: rotate(-10deg);
    transition: transform 0.3s ease;
    will-change: transform; /* Performance optimization */
}

.pepper:hover .veg-image {
    transform: rotate(0deg) scale(1.15);
}

/* Night mode pepper */
body.night-mode .pepper .veg-image {
    transform: rotate(-5deg);
}

body.night-mode .pepper:hover .veg-image {
    transform: rotate(0deg) scale(1.15);
}

/* Cucumber */
.cucumber .veg-image {
    transform-origin: center;
    transition: transform 0.3s ease-out;
    will-change: transform; /* Performance optimization */
}

.cucumber:hover .veg-image {
    transform: scale(1.15);
}

/* Night mode cucumber */
body.night-mode .cucumber .veg-image {
    transform: rotate(5deg);
}

body.night-mode .cucumber:hover .veg-image {
    transform: rotate(0deg) scale(1.15);
}

/* Carrot */
.carrot .veg-image {
    height: 120px;
    transform-origin: center top;
    animation: sway 4s ease-in-out infinite alternate;
    transition: transform 0.3s ease, filter 0.3s ease;
    will-change: transform; /* Performance optimization */
}

.carrot:hover .veg-image {
    animation-play-state: paused;
    transform: scale(1.15);
}

/* Night mode carrot */
body.night-mode .carrot .veg-image {
    animation-duration: 6s; /* Slower animation at night */
}

body.night-mode .carrot:hover .veg-image {
    animation-play-state: paused;
    transform: scale(1.15);
}

/* Broccoli */
.broccoli .veg-image {
    transition: filter 0.3s ease, transform 0.3s ease;
    will-change: transform, filter; /* Performance optimization */
}

.broccoli:hover .veg-image {
    filter: saturate(1.2) brightness(1.1);
    transform: scale(1.15);
}

/* Night mode broccoli */
body.night-mode .broccoli .veg-image {
    transform: rotate(-5deg);
}

body.night-mode .broccoli:hover .veg-image {
    transform: rotate(0deg) scale(1.15);
}

/* Vegetable Animation Keyframes */
@keyframes gentle-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

@keyframes sway {
    0%, 100% { transform: rotate(-3deg); }
    50% { transform: rotate(3deg); }
}

.veg-link span {
    font-size: 1.2rem;
    font-weight: bold;
    margin-top: 0.5rem;
    text-shadow: 1px 1px 0px #fff;
    transition: text-shadow 0.5s ease;
}

/* Night mode veggie name */
body.night-mode .veg-link span {
    text-shadow: 1px 1px 0px #0a1128;
}

/* Coming soon indicator */
.veg-link[aria-label*="Soon"]::after {
    content: 'Soon';
    position: absolute;
    top: -10px;
    right: -10px;
    background: #FF6347;
    color: white;
    font-size: 0.8rem;
    padding: 2px 6px;
    border-radius: 10px;
    transform: rotate(10deg);
}

/* Language-specific coming soon text */
html[lang="es"] .veg-link[aria-label*="Soon"]::after {
    content: 'Próximamente';
}

html[lang="ru"] .veg-link[aria-label*="Soon"]::after {
    content: 'Скоро';
}

/* Night mode coming soon tag */
body.night-mode .veg-link[aria-label*="Soon"]::after {
    background: #CC5039;
}

footer {
    text-align: center;
    margin-top: auto;
    padding: 1rem;
    font-size: 1.1rem;
    text-shadow: 1px 1px 0px #fff;
    transition: text-shadow 0.5s ease;
    content-visibility: auto; /* Performance optimization */
}

/* Night mode footer */
body.night-mode footer {
    text-shadow: 1px 1px 0px #0a1128;
}

/* Night mode specific elements */
.night-elements {
    display: none;
}

body.night-mode .night-elements {
    display: block;
}

/* Mosquito style */
.mosquito {
    position: fixed;
    width: 15px;
    height: 15px;
    background: transparent;
    border-radius: 50%;
    pointer-events: none;
    z-index: 10;
    will-change: transform; /* Performance optimization */
}

.mosquito::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
}

.mosquito::after {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 1px;
    height: 10px;
    background: rgba(0, 0, 0, 0.6);
}

.mosquito .wing {
    position: absolute;
    top: 3px;
    width: 8px;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    animation: wing-flutter 0.1s infinite alternate;
    will-change: transform; /* Performance optimization */
}

.mosquito .wing.left {
    left: -3px;
    transform: rotate(-20deg);
}

.mosquito .wing.right {
    right: -3px;
    transform: rotate(20deg);
}

@keyframes wing-flutter {
    from { transform: rotate(-20deg) scaleY(1); }
    to { transform: rotate(-20deg) scaleY(0.8); }
}

@keyframes wing-flutter-right {
    from { transform: rotate(20deg) scaleY(1); }
    to { transform: rotate(20deg) scaleY(0.8); }
}

/* Stars */
.star {
    position: fixed;
    background: #fff;
    border-radius: 50%;
    opacity: 0.8;
    animation: twinkle 2s infinite alternate;
    contain: layout style paint; /* Performance optimization */
}

@keyframes twinkle {
    from { opacity: 0.4; }
    to { opacity: 0.8; }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .veg-links {
        gap: 1.5rem;
    }
    
    .veg-image {
        width: 80px;
        height: 80px; /* Override individual vegetable heights */
    }
    
    .carrot .veg-image {
        height: 100px !important; /* Special case for carrot */
    }
    
    h1 {
        font-size: 2.5rem;
    }
    
    header p {
        font-size: 1.2rem;
    }
    
    .controls {
        flex-direction: column;
        gap: 10px;
    }
}

@media (max-width: 480px) {
    .veg-links {
        gap: 1rem;
    }
    
    .veg-image {
        width: 60px;
        height: 60px !important; /* Override individual vegetable heights */
    }
    
    .carrot .veg-image {
        height: 80px !important; /* Special case for carrot */
    }
    
    h1 {
        font-size: 2rem;
    }
    
    header p {
        font-size: 1rem;
    }
    
    .basket {
        padding: 1rem;
    }
}

/* Print media query to optimize printing */
@media print {
    .night-elements, 
    .controls,
    .mode-toggle,
    .tap-counter {
        display: none !important;
    }
    
    body, body.day-mode, body.night-mode {
        background: #fff !important;
        color: #000 !important;
    }
    
    body::before,
    body::after,
    body.day-mode::before,
    body.day-mode::after,
    body.night-mode::before,
    body.night-mode::after {
        display: none !important;
    }
    
    h1, header p, footer, .veg-link span {
        text-shadow: none !important;
        color: #000 !important;
    }
    
    .basket {
        box-shadow: none !important;
        border: 1px solid #ccc !important;
    }
    
    .veg-image {
        filter: none !important;
    }
}

/* Russian language specific font */
.lang-ru {
    font-family: 'Neucha', cursive;
    letter-spacing: 0.5px;
}

/* For spans inside links */
a .lang-ru {
    font-family: 'Neucha', cursive;
    letter-spacing: 0.5px;
}

/* Special styling for Russian language elements */
html[lang="ru"] h1,
html[lang="ru"] p,
html[lang="ru"] .lang-btn,
html[lang="ru"] footer {
    font-family: 'Neucha', cursive;
}

/* Slightly increase font size for Russian text as it tends to appear smaller */
html[lang="ru"] .veg-link span {
    font-size: 1.3rem;
}

html[lang="ru"] .veg-link[aria-label*="Soon"]::after {
    font-family: 'Neucha', cursive;
    font-size: 0.9rem;
}

/* Fix for all browsers to remove the box effect */
a {
    -webkit-touch-callout: none; /* Prevents callout to copy image, etc when tap to hold */
    -webkit-user-select: none; /* Safari */
    -khtml-user-select: none; /* Konqueror HTML */
    -moz-user-select: none; /* Firefox */
    -ms-user-select: none; /* Internet Explorer/Edge */
    user-select: none; /* Non-prefixed version */
}

/* Load content efficiently with content-visibility */
.basket-container {
    content-visibility: auto;
    contain-intrinsic-size: 400px;
}

.night-elements {
    content-visibility: auto;
    contain-intrinsic-size: 200px;
}

/* Pepe Animation Styles */
/* Style for the link that contains pepe */
a.pepe-link {
    position: fixed;
    display: block;
    z-index: 10000;
    text-decoration: none;
    cursor: pointer;
    will-change: left, top;
}

.dancing-pepe {
    position: relative; /* Changed from fixed to relative */
    width: 80px;
    height: 80px;
    background-image: url('pepe-pepedj.gif');
    background-size: contain;
    background-repeat: no-repeat;
    cursor: pointer;
    filter: drop-shadow(0 0 3px rgba(0, 255, 0, 0.5)); /* Reduced shadow intensity */
    will-change: transform, opacity;
    pointer-events: auto; /* Changed from 'none' to make it clickable */
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.25, 0.1, 0.25, 1), filter 0.3s ease;
}

.dancing-pepe.active {
    pointer-events: auto;
    opacity: 0.85; /* Slightly reduced opacity for less visual obtrusiveness */
    transition: opacity 1s ease-in;
}

.dancing-pepe:hover {
    transform: scale(1.1) rotate(5deg); /* Reduced scale and rotation */
    filter: drop-shadow(0 0 5px rgba(0, 255, 0, 0.7)); /* Subtle glow increase on hover */
}

.dancing-pepe.teasing {
    animation: pepe-tease 2s cubic-bezier(0.25, 0.1, 0.25, 1);
}

@keyframes pepe-tease {
    0% {
        transform: scale(1) rotate(0deg);
    }
    20% {
        transform: scale(1.15) rotate(-5deg); /* Reduced intensity */
    }
    40% {
        transform: scale(1.05) rotate(8deg); /* Reduced intensity */
    }
    60% {
        transform: scale(1.2) rotate(-3deg); /* Reduced intensity */
    }
    80% {
        transform: scale(1.1) rotate(5deg); /* Reduced intensity */
    }
    100% {
        transform: scale(1) rotate(0deg);
    }
}

@media (max-width: 768px) {
    .veg-links {
        gap: 1.5rem;
    }
    
    .veg-image {
        width: 80px;
        height: 80px; /* Override individual vegetable heights */
    }
    
    .carrot .veg-image {
        height: 100px !important; /* Special case for carrot */
    }
    
    h1 {
        font-size: 2.5rem;
    }
    
    header p {
        font-size: 1.2rem;
    }
    
    .controls {
        flex-direction: column;
        gap: 10px;
    }
}

@media (max-width: 480px) {
    .veg-links {
        gap: 1rem;
    }
    
    .veg-image {
        width: 60px;
        height: 60px !important; /* Override individual vegetable heights */
    }
    
    .carrot .veg-image {
        height: 80px !important; /* Special case for carrot */
    }
    
    h1 {
        font-size: 2rem;
    }
    
    header p {
        font-size: 1rem;
    }
    
    .basket {
        padding: 1rem;
    }
}

/* Telegram Login Styles */
.telegram-login-container {
    margin-left: 15px;
    display: flex;
    align-items: center;
    min-width: 200px; /* Ensure container has enough width */
}

#telegram-login-button {
    display: inline-block;
    min-height: 32px; /* Match the height of the language buttons */
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    font-size: 14px;
    min-width: 200px; /* Match container width */
}

.logout-btn {
    background: none;
    border: 1px solid currentColor;
    padding: 2px 8px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s ease;
}

.logout-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Night mode adjustments */
.night-mode .user-info {
    background: rgba(255, 255, 255, 0.05);
}

.night-mode .logout-btn {
    color: #fff;
}

/* Responsive adjustments for Telegram login */
@media (max-width: 768px) {
    .controls {
        flex-direction: column;
        gap: 10px;
    }
    
    .telegram-login-container {
        margin-left: 0;
        margin-top: 10px;
        width: 100%;
        justify-content: center;
    }
    
    #telegram-login-button {
        width: 100%;
        display: flex;
        justify-content: center;
    }
} 