:root {
    --concho-blue: #29C3FF;
    --eli-pink: #FFD1DC;
    --text-dark: #3a2e22; /* Marrón oscuro para mejor contraste con la madera */
    
    /* Variables de Madera / Bambú */
    --wood-light: #d6b382;
    --wood-medium: #c29962;
    --wood-dark: #8c6332;
    --table-color: #3b4249; /* Fondo oscuro (mesa) para resaltar la caja */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Nunito', sans-serif;
    /* Fondo oscuro simulando una superficie o mesa */
    background: radial-gradient(circle at center, #535e68 0%, #2f353a 100%);
    color: var(--text-dark);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

/* --- WRAPPER DE LA CAJA DE MADERA --- */
.wooden-box-wrapper {
    width: 100%;
    max-width: 1050px;
    padding: 20px;
    perspective: 1200px;
}

.wooden-box {
    position: relative;
    width: 100%;
    /* Textura base exterior de la caja de bambú */
    background: linear-gradient(90deg, var(--wood-medium) 0%, var(--wood-light) 50%, var(--wood-medium) 100%);
    border-radius: 24px;
    /* Sombras para darle el grosor de una caja física posada en la mesa */
    box-shadow: 
        0 30px 60px rgba(0,0,0,0.5), 
        inset 0 0 0 12px var(--wood-dark), /* Borde grueso externo (pared de la caja) */
        inset 0 5px 15px rgba(0,0,0,0.6);
    padding: 20px;
    min-height: 500px;
}

/* --- TAPA DE LA CAJA (BOX LID) --- */
.wooden-box-lid {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Textura de la tapa: madera de bambú pulida */
    background: repeating-linear-gradient(to right, var(--wood-medium) 0%, var(--wood-light) 10%, var(--wood-medium) 20%);
    border-radius: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 15px 35px rgba(0,0,0,0.6), inset 0 0 0 4px rgba(255,255,255,0.2);
    border: 2px solid var(--wood-dark);
    /* Transición de apertura: se desliza hacia arriba, sale y se desvanece un poco */
    transition: transform 1.2s cubic-bezier(0.77, 0, 0.175, 1), opacity 1.2s ease, visibility 1.2s;
    transform-origin: top;
}

.lid-engraving {
    text-align: center;
    /* Efecto de tallado a fuego en la madera */
    color: #4a2e12;
    text-shadow: 1px 1px 2px rgba(255,255,255,0.4), -1px -1px 2px rgba(0,0,0,0.6);
}

.lid-engraving h1 {
    font-family: 'Caveat', cursive;
    font-size: 5rem;
    margin-bottom: 10px;
}

.lid-engraving p {
    font-size: 1.3rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    animation: pulseText 2s infinite;
}

.wooden-box-lid.open {
    transform: translateY(-50px) rotateX(25deg) scale(1.05);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

@keyframes pulseText {
    0% { opacity: 0.5; }
    50% { opacity: 1; }
    100% { opacity: 0.5; }
}


/* --- CONTENEDOR BENTO (EL INTERIOR DE LA CAJA) --- */
.bento-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: minmax(140px, auto);
    gap: 15px; /* Madera entre compartimentos */
    width: 100%;
    /* El contenido interior solo será visible si la tapa está "open", manejamos opacidad con JS o CSS padre */
    opacity: 0;
    transform: translateY(10px) scale(0.98);
    transition: opacity 1s ease 0.6s, transform 1s ease 0.6s;
}

body.opened .bento-container {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* COMPARTIMENTOS HUECOS DE MADERA */
.bento-box {
    /* Fondo del fondo de la caja, textura de madera más oscura o sombreada */
    background: linear-gradient(135deg, #a67c4b, #8c6332);
    border-radius: 12px;
    /* Sombra interior muy fuerte para que parezcan huecos tallados */
    box-shadow: inset 5px 5px 15px rgba(0,0,0,0.5), inset -2px -2px 5px rgba(255,255,255,0.1);
    overflow: hidden;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* CAJA 1: Polaroid Principal */
.box-main-polaroid {
    grid-column: span 2;
    grid-row: span 3;
    padding: 20px;
}

/* El objeto Polaroid reposando en el hueco */
.polaroid-wrapper {
    background: #fff;
    padding: 15px 15px 60px 15px;
    border-radius: 4px;
    width: 90%;
    height: 95%;
    display: flex;
    flex-direction: column;
    /* Sombra para que parezca un papel físico tirado en el hueco */
    box-shadow: 2px 5px 15px rgba(0,0,0,0.6), 0 0 40px rgba(0,0,0,0.2) inset;
    transform: rotate(-2deg); /* Un poco chueco para realismo */
    position: relative;
}

.polaroid-img-container {
    width: 100%;
    height: 100%;
    position: relative;
    background-color: #222;
    overflow: hidden;
    border: 1px solid #ddd;
}

.polaroid-img-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
}

#scratchCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    cursor: crosshair;
    touch-action: none;
}

.polaroid-text {
    font-family: 'Caveat', cursive;
    font-size: 2.5rem;
    color: #333;
    position: absolute;
    bottom: 5px;
    left: 0;
    width: 100%;
    text-align: center;
}

/* CAJAS STACK (Pilas de fotos y notas) */
.box-photo-stack {
    grid-column: span 2;
    grid-row: span 3;
    padding: 20px;
}

.box-name-stack {
    grid-column: span 1;
    grid-row: span 1;
    padding: 10px;
}

.stack-container {
    position: relative;
    width: 85%;
    height: 85%;
}

.stack-item {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    background: #fff;
    padding: 8px 8px 35px 8px; /* Estilo polaroid mini */
    /* Sombra realista de papel físico */
    box-shadow: 2px 4px 10px rgba(0,0,0,0.4);
    border-radius: 2px;
    transition: transform 0.5s ease, opacity 0.5s ease;
    user-select: none;
    cursor: pointer;
}

.stack-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 2px;
}

/* Notas de papel texturizado para apodos */
.note-item {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    text-align: center;
    font-family: 'Caveat', cursive;
    font-size: 1.6rem;
    color: var(--concho-blue);
    background: #fdf5e6; /* Color pergamino/papel antiguo */
    box-shadow: 2px 4px 10px rgba(0,0,0,0.3), inset 0 0 10px rgba(0,0,0,0.05);
}

/* CAJA 3: Spotify */
.box-music {
    grid-column: span 2;
    grid-row: span 1;
    padding: 15px;
}

.box-music iframe {
    border-radius: 12px;
    width: 95%;
    height: 90%;
    /* Integrarlo en el hueco como si fuera una placa */
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    background: #000;
}

/* CAJA 5: Dije de Corazón */
.box-pendant {
    grid-column: span 1;
    grid-row: span 1;
    padding: 15px;
}

.pendant-cord {
    position: absolute;
    top: -10px;
    width: 4px;
    height: 60%;
    background: #5c432c; /* Cuero oscuro */
    box-shadow: 1px 1px 3px rgba(0,0,0,0.5);
    z-index: 1;
}

.pendant-svg {
    width: 70%;
    height: auto;
    filter: drop-shadow(3px 8px 6px rgba(0,0,0,0.5)); /* Sombra fuerte proyectada en el hueco */
    z-index: 2;
    transform: rotate(10deg);
}


/* --- RESPONSIVIDAD --- */
@media (max-width: 768px) {
    body {
        align-items: flex-start;
        padding: 5vh 0;
    }
    .wooden-box-lid {
        display: block;
    }
    .lid-engraving {
        position: sticky;
        top: 50vh;
        transform: translateY(-50%);
        margin: 0;
    }
    .wooden-box {
        padding: 15px;
        box-shadow: inset 0 0 0 8px var(--wood-dark), inset 0 3px 10px rgba(0,0,0,0.6);
    }
    .bento-container {
        grid-template-columns: 1fr; 
        gap: 15px;
    }
    .box-main-polaroid, .box-photo-stack, .box-music {
        grid-column: span 1; 
    }
    .box-main-polaroid, .box-photo-stack {
        grid-row: span 1;
        height: 450px; 
    }
    .lid-engraving h1 {
        font-size: 4rem;
    }
    .wooden-box-lid.open {
        transform: translateY(-20px) rotateX(15deg) scale(1.02);
    }
}

/* --- TAPE BOTON (WASHI TAPE) --- */
.washi-tape {
    position: absolute;
    top: -12px;
    right: -15px;
    width: 70px;
    height: 30px;
    /* Color cinta semitransparente tipo masking tape */
    background-color: rgba(245, 235, 210, 0.9);
    box-shadow: 1px 2px 4px rgba(0,0,0,0.3);
    transform: rotate(20deg);
    z-index: 100;
    cursor: zoom-in;
    /* Bordes irregulares imitando cinta cortada */
    border-left: 2px dashed rgba(200, 180, 150, 0.8);
    border-right: 2px dashed rgba(200, 180, 150, 0.8);
    transition: transform 0.2s ease, background-color 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

.washi-tape::after {
    /* Un pequeño ícono sutil de lupa para dar a entender que se puede ampliar */
    content: "🔍";
    font-size: 0.9rem;
    opacity: 0.5;
    transform: rotate(-20deg);
}

.washi-tape:hover {
    background-color: rgba(255, 248, 225, 1);
    transform: rotate(20deg) scale(1.1);
}

/* Ajuste del z-index para que la cinta no quede por debajo del canvas raspar */
.polaroid-wrapper .washi-tape {
    z-index: 20;
}

/* --- MODAL LIGHTBOX --- */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s;
    backdrop-filter: blur(5px);
}

.modal-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.modal-polaroid {
    background: #fff;
    padding: 20px 20px 80px 20px;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.8);
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    transform: scale(0.8) translateY(50px);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-backdrop.active .modal-polaroid {
    transform: scale(1) translateY(0);
}

.modal-polaroid img {
    max-width: 100%;
    max-height: calc(90vh - 150px);
    object-fit: contain;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.modal-text {
    position: absolute;
    bottom: 15px;
    left: 0;
    width: 100%;
    text-align: center;
    font-family: 'Caveat', cursive;
    font-size: 3rem;
    color: #333;
}

.modal-close {
    position: absolute;
    top: -15px;
    right: -15px;
    width: 40px;
    height: 40px;
    background: var(--eli-pink);
    border: 2px solid #fff;
    color: #333;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    transition: transform 0.2s;
    z-index: 10;
}

.modal-close:hover {
    transform: scale(1.1) rotate(90deg);
}
