/* --- chest_style.css --- */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;700&display=swap');

:root {
    --primary-color: #0f2027; 
    --secondary-color: #ffc107;
    --background-gradient : linear-gradient(135deg, #0f2027, #203a43, #2c5364);
    --text-color: #333; 
    --ramadan-red: #c0392b;
}

body {
    font-family: 'Cairo', sans-serif;
    
    /* 1. UNIFIED GRADIENT BACKGROUND */
    /* This color shows through where the image fades out */
    background: radial-gradient(circle at center, #ffffff 0%, #eaeeda 100%);
    
    color: #0a0c00; 
    
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;
    margin: 0;
}

header {
    flex-shrink: 0;
    width: 100%;
    z-index: 10;
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 5%;
    max-width: 400px;
    margin: 0 auto;
}

.logo img, 
.logo-40 img { 
    width: 80px; 
    height: auto;
    display: block;
    margin-left: auto;
}

.animation-container { position: fixed; inset: 0; pointer-events: none; z-index: 9999; }

/* --- FORM WRAPPER --- */
.form-wrapper {
    flex :1;
    position: relative;
    z-index: 1;
    width: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    max-width: 600px;
}

.container h1 {
    text-align: center;  /* h1 text itself is centered */
}

.form-wrapper .container {
    background: rgba(255, 255, 255, 0.45);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 24px;
    padding: 25px;
    
    /* Big Size */
    width: 50%;
    max-width: 300px;
    min-width: 250px;
    height: auto;
    
    filter: drop-shadow(0 25px 40px rgba(0,0,0,0.2));
    display: block;
    cursor: pointer;
}

/* --- MAIN CONTAINER (MOBILE FIT) --- */

main {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 0;
    min-height: 85vh;
    min-width: max-content;

}

/* BACKGROUND IMAGE WITH MELTING EDGES */
main::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    
    background-image: url('../images/1000003465.webp');
    background-position: center top;
    background-repeat: no-repeat;
    /* 'contain' keeps the whole portrait visible */
    background-size: contain; 
    z-index: -1; 
    aspect-ratio: 9 / 16;

    
    /* THE FIX:
       1. 'closest-side': Ensures the gradient respects the narrow width of a portrait image.
       2. 'black 75%': Keeps the inner 75% of the image TOTALLY SOLID (No blur/fade).
       3. 'transparent 100%': Fades to invisible only in the last 25% of space.
    
    -webkit-mask-image: radial-gradient(ellipse closest-side at center, black 95%, transparent 100%);
    mask-image: radial-gradient(ellipse closest-side at center, black 95%, transparent 100%);*/
    
    /* Optional: Adds a very slight real blur to the pixels if supported, 
       but creates a softer 'dreamy' edge combined with the mask */
    filter: blur(0px); 
    
    pointer-events: none;
}


/* --- TEXT & SECTIONS --- */
h1 { color: var(--primary-color); margin-bottom: 12px; font-size: 20px; }
.error-msg { color: var(--ramadan-red); font-size: 13px; font-weight: bold; min-height: 18px; margin-right: 6px;}
.section { display: none; }
.section.active { display: block; animation: fadeIn .4s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* --- FORM --- */
.form-group { margin-bottom: 10px; text-align: right; }
label { display: block; margin-bottom: 2px; font-weight: 600; color: var(--primary-color); font-size: 14px; margin-right: 6px; padding-right: 5px; padding-left: 5px;}
input { width: 100%; padding: 10px 12px; font-size: 15px; border: 1px solid #ccc; border-radius: 8px; box-sizing: border-box; text-align: right;}
input:focus { border-color: var(--secondary-color); outline: none; }

/* --- BUTTONS --- */
button {
    background-color: #f77118;
    color: white;
    border: none;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 700;
    width: 100%;
    margin-top: 12px;
    cursor: pointer;
    border-bottom: 4px solid #d8b261;
    transition: .25s;
}
button:hover:not(:disabled) { background-color: #eca451; }
button:disabled { background-color: #ccc; border-bottom: none; }

/* --- LOADER --- */
.loader {
    border: 6px solid #f3f3f3;
    border-top: 6px solid var(--secondary-color);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    animation: spin 1.2s linear infinite;
    margin: 16px auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
/* --- SPÉCIFIQUE COFFRES --- */
.chests-container {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 10px; /* Reduced gap for mobile */
    margin-top: 20px;
    height: 140px; /* Reduced height */
}
.chest-wrapper {
    cursor: pointer;
    transition: transform 0.3s, filter 0.5s;
    position: relative;
    width: 32%; /* Fit 3 in row */
}
.chest-wrapper:hover { transform: scale(1.05); }
.chest-img {
    width: 100%;
    height: auto;
    filter: drop-shadow(0 5px 5px rgba(0,0,0,0.3));
    transition: filter 0.3s;
}
.chest-wrapper.opened { cursor: default; filter: grayscale(0.8); opacity: 0.7; }
.chest-wrapper.winner { transform: scale(1.1); cursor: default; }
.chest-wrapper.winner .chest-img { filter: drop-shadow(0 0 20px var(--secondary-color)); }
.glow {
    position: absolute; top: 50%; left: 50%; width: 0; height: 0;
    background: radial-gradient(circle, var(--secondary-color) 0%, transparent 70%);
    border-radius: 50%; transform: translate(-50%, -50%); transition: all 0.5s ease-out; z-index: -1; opacity: 0;
}
.chest-wrapper.winner .glow { width: 150px; height: 150px; opacity: 0.8; }

/* Animation Shake */
.chest-wrapper.shaking { animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both; }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-6px); }
  40%, 60% { transform: translateX(6px); }
}

#result-section {
    /* Remove display: none; so it uses the .section logic */
    text-align: center;
}
/* --- RESULT --- */
.prize-text {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--ramadan-red);
    margin: 15px 0;
    animation: pulse 1.5s infinite;
}
@keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.05); } 100% { transform: scale(1); } }

.back-btn {
    display: inline-block;
    margin-top: 20px;
    padding: 12px 25px;
    background-color: #f77118;
    border-bottom: #d8b261;
    color: white;
    border: none;
    border-radius: 8px;
    text-decoration: none;
    font-weight: bold;
    font-size: 15px;
    transition: all 0.3s ease;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
.back-btn:hover { background-color: #eca451; transform: translateY(-2px); }


.terms-container {
    display: flex;
    align-items: center;
    justify-content: flex-end; /* pushes content to the right */
    gap: 8px;
}

.terms-text {
    direction: rtl;     /* keep Arabic readable */
    text-align: right;
}

.terms-container input {
    order: 1; /* ensure checkbox stays after text visually */
    width: 20px;
    height: 20px;
}

.floating-element {
    position: absolute;
    bottom: -5vh;
    pointer-events: none;
    animation: floatUp ease-in-out forwards;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

@keyframes floatUp {
    0% {
        transform: translateX(0) translateY(0);
        opacity: 0;  /* semi-transparent start */
    }
    20% {
        opacity: 0;    /* fully opaque early */
    }
    30% {
        opacity: 0.4;    /* fully opaque early */
    }
    50% {
        opacity: 1;    /* fully opaque early */
    }
    60% {
        opacity: 0.8;    /* fully opaque early */
    }
    80% {
        opacity: 0.4;    /* stay opaque while floating */
    }
    90% {
        opacity: 0;    /* stay opaque while floating */
    }
    100% {
        transform: translateX(var(--x-drift)) translateY(-80vh);
        opacity: 0;    /* fade out at top */
    }
}

/* Slow, calm spin */
.floating-element img {
    display: block;
    animation: spinSlow 12s linear infinite;
}

@keyframes spinSlow {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}


/* --- FOOTER --- */
footer {
    flex-shrink: 0;
    text-align: center;
    z-index: 2;
    width: 100%;
}

.foot {
    background: transparent;
    font-size: 12px;
    color: #0a0c00;
}

.social {
    margin: 0;
}
.social span {
    display: block;
    font-weight: 700;
    letter-spacing: 2px;
    font-size: 14px;
}

.social-items {
    list-style: none;
    padding: 0;
    display: flex;
    justify-content: center;
    gap: 30px;
    margin: 0;
}

.social-items img {
    width: 32px;
    transition: transform 0.3s ease;
}

.social-items a:hover img {
    transform: translateY(-5px);
}