/* ========================================
   CSS Variables & Reset
======================================== */
:root {
    --sidebar-bg: rgba(255, 255, 255, 0.95);
    --primary-color: #4CAF50;
    --primary-hover: #45a049;
    --accent-color: #FF9800;
    --text-color: #333;
    --text-light: #666;
    --border-radius: 12px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    --glow-color: rgba(255, 215, 0, 0.8);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    font-family: 'Tajawal', sans-serif;
    overflow: hidden;
    width: 100%;
    height: 100%;
    position: relative;
    touch-action: none;
}

/* ========================================
   World Container
======================================== */
#world {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Sky is pure CSS gradient - takes top 20% */
    background: linear-gradient(to bottom,
        #87CEEB 0%,
        #B0E0E6 30%,
        #E0F7FA 60%,
        #F0F8FF 100%
    );
    /* Default cursor for sky area */
    cursor: default;
    overflow: hidden;
}

/* ========================================
   Sky Title
======================================== */
#sky-title {
    position: absolute;
    top: 8vh;
    left: 0;
    right: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    z-index: 2;
    pointer-events: none;
}

#sky-title h1 {
    font-family: 'Press Start 2P', cursive;
    font-size: 2rem;
    color: #2E7D32;
    text-shadow:
        3px 3px 0px #81C784,
        -1px -1px 0px #fff,
        1px -1px 0px #fff,
        -1px 1px 0px #fff;
    margin-bottom: 15px;
    letter-spacing: 2px;
    animation: titleFloat 3s ease-in-out infinite;
}

#sky-title p {
    font-family: 'Press Start 2P', cursive;
    font-size: 0.65rem;
    color: #4CAF50;
    text-shadow:
        2px 2px 0px #C8E6C9,
        -1px -1px 0px #fff;
    line-height: 1.8;
    max-width: 500px;
    margin: 0 auto;
}

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

/* Responsive Sky Title */
@media (max-width: 768px) {
    #sky-title h1 {
        font-size: 1rem;
    }

    #sky-title p {
        font-size: 0.45rem;
        padding: 0 15px;
    }
}

/* ========================================
   Clouds Layer
======================================== */
#clouds-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 20vh;
    pointer-events: none;
    overflow: visible;
    z-index: 1;
}

/* Cloud Base Style - Pure CSS fluffy clouds */
.cloud {
    position: absolute;
    background: #fff;
    border-radius: 50%;
    box-shadow:
        0 8px 20px rgba(0, 0, 0, 0.05),
        inset 0 -5px 15px rgba(0, 0, 0, 0.02);
}

.cloud::before,
.cloud::after {
    content: '';
    position: absolute;
    background: inherit;
    border-radius: inherit;
    box-shadow: inherit;
}

/* Cloud 1 - Large fluffy cloud */
.cloud-1 {
    width: 120px;
    height: 50px;
    top: 20px;
    left: 0;
    animation: cloud-drift 50s linear infinite;
    animation-delay: -5s;
}
.cloud-1::before {
    width: 70px;
    height: 70px;
    top: -35px;
    left: 15px;
}
.cloud-1::after {
    width: 90px;
    height: 90px;
    top: -45px;
    left: 45px;
}

/* Cloud 2 - Medium cloud */
.cloud-2 {
    width: 80px;
    height: 35px;
    top: 40px;
    left: 0;
    opacity: 0.9;
    animation: cloud-drift 65s linear infinite;
    animation-delay: -20s;
}
.cloud-2::before {
    width: 50px;
    height: 50px;
    top: -25px;
    left: 10px;
}
.cloud-2::after {
    width: 60px;
    height: 60px;
    top: -30px;
    left: 35px;
}

/* Cloud 3 - Small distant cloud */
.cloud-3 {
    width: 60px;
    height: 25px;
    top: 15px;
    left: 0;
    opacity: 0.7;
    animation: cloud-drift 80s linear infinite;
    animation-delay: -35s;
}
.cloud-3::before {
    width: 35px;
    height: 35px;
    top: -18px;
    left: 8px;
}
.cloud-3::after {
    width: 45px;
    height: 45px;
    top: -22px;
    left: 25px;
}

/* Cloud 4 - Large cloud */
.cloud-4 {
    width: 140px;
    height: 55px;
    top: 50px;
    left: 0;
    animation: cloud-drift 45s linear infinite;
    animation-delay: -40s;
}
.cloud-4::before {
    width: 80px;
    height: 80px;
    top: -40px;
    left: 20px;
}
.cloud-4::after {
    width: 100px;
    height: 100px;
    top: -50px;
    left: 55px;
}

/* Cloud 5 - Tiny accent cloud */
.cloud-5 {
    width: 50px;
    height: 20px;
    top: 30px;
    left: 0;
    opacity: 0.6;
    animation: cloud-drift 95s linear infinite;
    animation-delay: -10s;
}
.cloud-5::before {
    width: 30px;
    height: 30px;
    top: -15px;
    left: 5px;
}
.cloud-5::after {
    width: 35px;
    height: 35px;
    top: -17px;
    left: 20px;
}

/* Cloud 6 - Medium fluffy */
.cloud-6 {
    width: 100px;
    height: 40px;
    top: 60px;
    left: 0;
    opacity: 0.85;
    animation: cloud-drift 55s linear infinite;
    animation-delay: -25s;
}
.cloud-6::before {
    width: 60px;
    height: 60px;
    top: -30px;
    left: 12px;
}
.cloud-6::after {
    width: 70px;
    height: 70px;
    top: -35px;
    left: 40px;
}

/* Cloud 7 - Small cloud */
.cloud-7 {
    width: 70px;
    height: 30px;
    top: 10px;
    left: 0;
    opacity: 0.75;
    animation: cloud-drift 70s linear infinite;
    animation-delay: -50s;
}
.cloud-7::before {
    width: 40px;
    height: 40px;
    top: -20px;
    left: 10px;
}
.cloud-7::after {
    width: 50px;
    height: 50px;
    top: -25px;
    left: 30px;
}

/* Cloud 8 - Large background cloud */
.cloud-8 {
    width: 110px;
    height: 45px;
    top: 45px;
    left: 0;
    opacity: 0.8;
    animation: cloud-drift 60s linear infinite;
    animation-delay: -55s;
}
.cloud-8::before {
    width: 65px;
    height: 65px;
    top: -32px;
    left: 15px;
}
.cloud-8::after {
    width: 75px;
    height: 75px;
    top: -38px;
    left: 45px;
}

/* Cloud Animation - Smooth infinite drift from left to right */
@keyframes cloud-drift {
    0% {
        transform: translateX(-200px);
    }
    100% {
        transform: translateX(calc(100vw + 200px));
    }
}

/* Ground Layer - Takes 80% of screen height */
#ground-layer {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 80vh;
    overflow: hidden;
    /* Shovel cursor only in ground area */
    cursor: url("/garden/assets/other/shovel-cursor.png") 0 32, crosshair;
    -ms-overflow-style: none;
    scrollbar-width: none;
    pointer-events: auto;
    /* Ground background image */
    background-image: url('/garden/assets/bg/background.png');
    background-size: cover;
    background-position: center top;
    background-repeat: no-repeat;
}

#ground-layer::-webkit-scrollbar {
    display: none;
}

#ground-layer::-webkit-scrollbar-thumb {
    display: none;
}

/* Garden Canvas - Dynamically sized for infinite world */
#garden-canvas {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    will-change: transform;
}

/* ========================================
   Fixed UI Layer
======================================== */
#ui-layer {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 15px 25px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    z-index: 50;
    pointer-events: none;
}

#ui-layer > * {
    pointer-events: auto;
}

/* Garden Nav - Back to center + Minimap */
#garden-nav {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 45;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}

[dir="rtl"] #garden-nav {
    right: auto;
    left: 20px;
    align-items: flex-start;
}

#back-to-center-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border: none;
    border-radius: 25px;
    background: rgba(255, 255, 255, 0.95);
    color: var(--primary-color);
    font-family: inherit;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
    transition: transform 0.2s, box-shadow 0.2s;
}

#back-to-center-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 20px rgba(76, 175, 80, 0.3);
}

#back-to-center-btn iconify-icon {
    font-size: 1.2rem;
}

#minimap-container {
    background: rgba(255, 255, 255, 0.92);
    border-radius: 12px;
    padding: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

#minimap {
    position: relative;
    width: 140px;
    height: 28px;
    background: linear-gradient(to bottom, #C8E6C9 0%, #A5D6A7 100%);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
}

#minimap-viewport {
    position: absolute;
    top: 0;
    bottom: 0;
    background: rgba(76, 175, 80, 0.4);
    border: 2px solid var(--primary-color);
    border-radius: 4px;
    pointer-events: none;
}

.minimap-dot {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 4px;
    height: 4px;
    background: #2E7D32;
    border-radius: 50%;
    pointer-events: none;
}

#minimap-home {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 10px;
    color: rgba(46, 125, 50, 0.7);
    pointer-events: none;
}

/* Garden Stats - planted count & remaining slots (bottom-left to avoid overlap with top UI) */
#garden-stats {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.92);
    border-radius: 25px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-color);
}

[dir="ltr"] #garden-stats {
    left: 20px;
    right: auto;
}

[dir="rtl"] #garden-stats {
    left: auto;
    right: 20px;
}

#garden-stats.hidden {
    display: none !important;
}

#stats-divider {
    color: var(--text-light);
    font-weight: 400;
}

#stats-planted {
    color: var(--primary-color);
}

#stats-remaining {
    color: #2196F3;
}

#back-to-site {
    position: fixed;
    top: 15px;
    right: 80px;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    text-decoration: none;
    z-index: 50;
}

#back-to-site:hover {
    transform: scale(1.1);
    background: white;
}

#back-to-site iconify-icon {
    font-size: 22px;
}

[dir="ltr"] #back-to-site {
    right: auto;
    left: 80px;
}

/* Sun */
#sun-container {
    cursor: pointer;
    transition: transform 0.3s ease;
}

#sun-container:hover {
    transform: scale(1.1);
}

#sun {
    width: 80px;
    height: 80px;
    object-fit: contain;
    filter: drop-shadow(0 0 15px rgba(255, 200, 0, 0.5));
    transition: filter 0.3s ease, transform 0.3s ease;
}

/* Music Button */
#music-btn {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.9);
    color: var(--primary-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
}

#music-btn:hover {
    transform: scale(1.1);
    background: white;
}

#music-btn svg {
    width: 22px;
    height: 22px;
}

#music-btn #music-icon {
    display: none;
}

#music-btn #muted-icon {
    display: block;
}

#music-btn:not(.muted) #music-icon {
    display: block;
}

#music-btn:not(.muted) #muted-icon {
    display: none;
}

#music-btn:not(.muted) {
    background: var(--primary-color);
    color: white;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(76, 175, 80, 0); }
}

/* ========================================
   Dirt Spot - Uses world units via JS
======================================== */
.dirt-spot {
    position: absolute;
    z-index: 5;
    pointer-events: none;
    transform: translate(-50%, -50%);
}

.dirt-spot img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* ========================================
   Planted Flower - Uses world units via JS
======================================== */
.planted-flower {
    position: absolute;
    z-index: 10;
    cursor: pointer;
    transition: transform 0.3s ease, filter 0.3s ease;
    transform: translate(-50%, -100%);
}

.planted-flower:hover {
    transform: translate(-50%, -100%) scale(1.15);
    z-index: 15;
}

.planted-flower img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

/* Glow Effect */
.planted-flower.glowing {
    animation: flowerGlow 0.5s ease-in-out infinite alternate;
    z-index: 20;
}

@keyframes flowerGlow {
    from {
        filter: drop-shadow(0 0 15px var(--glow-color))
                drop-shadow(0 0 25px rgba(255, 215, 0, 0.6));
    }
    to {
        filter: drop-shadow(0 0 35px var(--glow-color))
                drop-shadow(0 0 60px rgba(255, 215, 0, 0.8));
    }
}

/* Flower appear animation */
.planted-flower.appear {
    animation: flowerAppear 0.5s ease-out forwards;
}

@keyframes flowerAppear {
    from {
        transform: translate(-50%, -100%) scale(0);
        opacity: 0;
    }
    to {
        transform: translate(-50%, -100%) scale(1);
        opacity: 1;
    }
}

/* ========================================
   Sidebar
======================================== */
#sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 320px;
    height: 100vh;
    background: var(--sidebar-bg);
    box-shadow: -5px 0 30px rgba(0, 0, 0, 0.2);
    z-index: 100;
    display: flex;
    flex-direction: column;
    transform: translateX(0);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
}

#sidebar.hidden {
    transform: translateX(100%);
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    background: linear-gradient(135deg, var(--primary-color), #81C784);
    color: white;
}

.sidebar-header h2 {
    font-size: 1.3rem;
    font-weight: 700;
}

#close-sidebar {
    width: 34px;
    height: 34px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 22px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

#close-sidebar:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.sidebar-content {
    padding: 18px;
    overflow-y: auto;
    flex: 1;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--text-color);
    font-size: 0.95rem;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: var(--border-radius);
    font-family: inherit;
    font-size: 0.95rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
}

.form-group textarea {
    min-height: 70px;
    resize: vertical;
}

/* Flower Grid */
#flower-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.flower-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 4px;
    border: 2px solid #e0e0e0;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
}

.flower-option:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.flower-option.selected {
    border-color: var(--primary-color);
    background: rgba(76, 175, 80, 0.1);
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.2);
}

.flower-option img {
    width: 40px;
    height: 50px;
    object-fit: contain;
    margin-bottom: 4px;
}

.flower-option span {
    font-size: 0.75rem;
    color: var(--text-color);
    text-align: center;
}

/* Plant Button */
#plant-btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: var(--border-radius);
    background: linear-gradient(135deg, var(--primary-color), #81C784);
    color: white;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 8px;
}

#plant-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
}

#plant-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* ========================================
   Flower Modal
======================================== */
#flower-modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.3s ease;
}

#flower-modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
}

.modal-content {
    position: relative;
    background: white;
    border-radius: 20px;
    padding: 25px;
    max-width: 360px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(1);
    transition: transform 0.3s ease;
}

#flower-modal.hidden .modal-content {
    transform: scale(0.8);
}

#close-modal {
    position: absolute;
    top: 12px;
    left: 12px;
    width: 32px;
    height: 32px;
    border: none;
    background: #f0f0f0;
    color: var(--text-color);
    font-size: 20px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

#close-modal:hover {
    background: #e0e0e0;
    transform: rotate(90deg);
}

.modal-flower {
    margin-bottom: 15px;
}

.modal-flower img {
    width: 120px;
    height: 150px;
    object-fit: contain;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.2));
}

.modal-details h3 {
    color: var(--primary-color);
    margin-bottom: 12px;
    font-size: 1.1rem;
}

.modal-details p {
    color: var(--text-color);
    font-size: 1rem;
    line-height: 1.5;
    margin-bottom: 12px;
    padding: 12px;
    background: #f9f9f9;
    border-radius: var(--border-radius);
    border-right: 4px solid var(--primary-color);
}

.modal-details span {
    color: var(--text-light);
    font-size: 0.85rem;
}

/* Modal actions (share + delete) */
.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.modal-actions #share-btn {
    flex: 1;
    min-width: 120px;
}

.modal-actions #delete-flower-btn {
    flex: 0 0 auto;
}

#delete-flower-btn.hidden {
    display: none !important;
}

/* Share Button */
#share-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: var(--border-radius);
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

#share-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

#share-btn:active {
    transform: translateY(0);
}

#share-btn svg {
    width: 20px;
    height: 20px;
}

/* Delete Flower Button */
#delete-flower-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border: none;
    border-radius: var(--border-radius);
    background: linear-gradient(135deg, #e53935, #c62828);
    color: white;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

#delete-flower-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(229, 57, 53, 0.4);
}

#delete-flower-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

#delete-flower-btn svg {
    width: 18px;
    height: 18px;
}

/* Share success animation */
#share-btn.copied {
    background: linear-gradient(135deg, var(--primary-color), #81C784);
}

/* Modal entrance animation for shared flowers */
.modal-content.shared-entrance {
    animation: sharedModalEntrance 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes sharedModalEntrance {
    0% {
        transform: scale(0.3) rotate(-10deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.1) rotate(2deg);
    }
    100% {
        transform: scale(1) rotate(0);
        opacity: 1;
    }
}

/* Highlighted flower glow effect */
.planted-flower.highlighted {
    animation: highlightedGlow 0.8s ease-in-out infinite alternate;
    z-index: 100;
}

@keyframes highlightedGlow {
    from {
        filter: drop-shadow(0 0 20px rgba(102, 126, 234, 0.8))
                drop-shadow(0 0 40px rgba(102, 126, 234, 0.6));
        transform: translate(-50%, -100%) scale(1.1);
    }
    to {
        filter: drop-shadow(0 0 40px rgba(102, 126, 234, 1))
                drop-shadow(0 0 80px rgba(102, 126, 234, 0.8));
        transform: translate(-50%, -100%) scale(1.2);
    }
}

/* ========================================
   Responsive Design
======================================== */
@media (max-width: 768px) {
    #sidebar {
        width: 100%;
    }

    #sun {
        width: 50px;
        height: 50px;
    }

    #music-btn {
        width: 36px;
        height: 36px;
    }

    #flower-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    #ui-layer {
        padding: 8px 12px;
    }
}

