/* --- RESET --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: #2c2c2c;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
    font-family: 'Patrick Hand', cursive;
}

/* --- CONTAINER --- */
.envelope-container {
    position: relative;
    width: 90vw;
    max-width: 600px;
    aspect-ratio: 3/2;
    margin: auto;
}

/* --- HIDDEN INPUTS --- */
#envelope-toggle {
    display: none;
}

/* Animation Driver */
#file-upload {
    display: none;
}

/* File Picker */
/*#mode-toggle { display: none; }     !* NEW: Read/Write Mode *!*/

/* --- ENVELOPE WRAPPER --- */
.envelope-wrapper {
    width: 100%;
    height: 100%;
    background-color: #d4af37;
    position: relative;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

/* --- FLAPS --- */
.flap {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
}

.pocket {
    z-index: 3;
    background-color: #e6c86e;
    pointer-events: none;
    clip-path: polygon(0 0, 50% 50%, 100% 0, 100% 100%, 0 100%);
}

.lid {
    z-index: 4;
    background-color: #f3d472;
    transform-origin: top;
    transition: transform 0.6s ease-in-out, z-index 0.6s;
    clip-path: polygon(0 0, 100% 0, 50% 50%);
}

/* --- THE CARD --- */
.card-inside {
    position: absolute;
    bottom: 0;
    left: 5%;
    width: 90%;
    height: 90%;
    background: #fff;
    padding: 10px;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1;
    transition: transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    justify-content: center;
    align-items: center;
}

#card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 2px;
}

/* --- WAX SEAL (Trigger) --- */
.wax-seal {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    width: 80px;
    height: 80px;
    background-color: #b93b21;
    border-radius: 50%;
    border: 2px dashed rgba(0, 0, 0, 0.2);
    box-shadow: 2px 4px 6px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.2s;
}

.wax-seal:hover {
    transform: translate(-50%, -50%) scale(1.1);
}

.seal-icon {
    font-size: 2rem;
}

/* --- NEW: THE MODE SWITCH (Read/Write) --- */
/*.mode-switch-wrapper {*/
/*    position: absolute;*/
/*    top: 90%; !* Located at 90% of height *!*/
/*    left: 50%;*/
/*    transform: translate(-50%, -50%);*/
/*    z-index: 20; !* Must be higher than flaps (z-index 4) *!*/
/*    */
/*    display: flex;*/
/*    align-items: center;*/
/*    background: rgba(0, 0, 0, 0.6);*/
/*    padding: 4px;*/
/*    border-radius: 30px;*/
/*    backdrop-filter: blur(4px);*/
/*    box-shadow: 0 4px 10px rgba(0,0,0,0.3);*/
/*}*/

/*.switch-label {*/
/*    cursor: pointer;*/
/*    padding: 5px 15px;*/
/*    border-radius: 20px;*/
/*    color: #ccc;*/
/*    font-family: sans-serif;*/
/*    font-size: 0.8rem;*/
/*    font-weight: bold;*/
/*    text-transform: uppercase;*/
/*    transition: all 0.3s;*/
/*    user-select: none;*/
/*}*/

/*!* Logic: Toggle Visuals based on #mode-toggle state *!*/
/*!* Default (Unchecked) = WRITE is Active *!*/
/*#mode-toggle:not(:checked) ~ .envelope-container .mode-write {*/
/*    background-color: #fff;*/
/*    color: #333;*/
/*    box-shadow: 0 2px 5px rgba(0,0,0,0.2);*/
/*}*/

/*!* Checked = READ is Active *!*/
/*#mode-toggle:checked ~ .envelope-container .mode-read {*/
/*    background-color: #fff;*/
/*    color: #333;*/
/*    box-shadow: 0 2px 5px rgba(0,0,0,0.2);*/
/*}*/

/* --- ENHANCED MODE SWITCH (Read/Write) --- */
.mode-switch-wrapper {
    position: absolute;
    top: 90%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 20;

    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.6);
    padding: 6px; /* Slightly thicker pill */
    border-radius: 40px;
    backdrop-filter: blur(4px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    gap: 5px; /* Small space between the icons */
}

.switch-label {
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

/* Style the anchor tags as big icon buttons */
.switch-label a {
    text-decoration: none; /* Remove blue underline */
    color: #aaaaaa; /* Dimmed out when inactive */
    font-size: 1.4rem; /* CHARMING, BIGGER ICONS */
    padding: 8px 20px; /* Generous click area */
    border-radius: 30px; /* Pill shape for the active background */
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    line-height: 1; /* Keeps characters perfectly centered */
    display: inline-block;
}

/* Subtle hover pop for inactive icons */
.switch-label a:hover:not(.active) {
    color: #ffffff;
    transform: scale(1.1);
}

/* HIGHLIGHT THE ACTIVE ITEM */
.switch-label a.active {
    background-color: #d4af37; /* Matches your envelope gold */
    color: #2c2c2c; /* Dark contrast for the icon */
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    transform: scale(1.05); /* Slight physical pop */
}


/* --- ANIMATION --- */
#envelope-toggle:checked ~ .envelope-wrapper .lid {
    transform: rotateX(180deg);
    z-index: 0;
}

#envelope-toggle:checked ~ .envelope-wrapper .card-inside {
    transform: translateY(-50%);
    z-index: 5;
    transition-delay: 0.2s;
}

#envelope-toggle:checked ~ .wax-seal {
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -50%) scale(1.5);
    transition: 0.3s;
}

/* Hide switch when opening? Optional. For now we keep it visible. */
#envelope-toggle:checked ~ .mode-switch-wrapper {
    opacity: 0;
    pointer-events: none;
    transition: 0.3s;
}