/* team_puzzle.css */
/* Grid structure for the puzzle */
.nanny-puzzle-section {
    padding: 80px 0;
    background-color: #FFF0F5; /* brand subtle pink */
    position: relative;
    overflow: visible;
}

.nanny-puzzle-section .section-header {
    text-align: center;
    margin-bottom: 40px;
}

.nanny-puzzle-section .section-header h2 {
    font-family: 'Quicksand', sans-serif; /* playful */
    color: #E81A63;
    font-size: 2.5rem;
}

.puzzle-grid {
    display: grid;
    /* 3 columns on desktop */
    grid-template-columns: repeat(3, 1fr);
    gap: -30px; /* Negative gap to overlap pieces */
    max-width: 800px;
    margin: 0 auto;
    padding: 80px 60px;
    overflow: visible;
}

.puzzle-piece {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: visible;
    cursor: pointer;
    -webkit-mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="-5 -5 110 110"><path d="M 15 15 L 40 15 C 40 -2, 60 -2, 60 15 L 85 15 L 85 40 C 102 40, 102 60, 85 60 L 85 85 L 60 85 C 60 72, 40 72, 40 85 L 15 85 L 15 60 C 28 60, 28 40, 15 40 Z" fill="black"/></svg>');
    mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="-5 -5 110 110"><path d="M 15 15 L 40 15 C 40 -2, 60 -2, 60 15 L 85 15 L 85 40 C 102 40, 102 60, 85 60 L 85 85 L 60 85 C 60 72, 40 72, 40 85 L 15 85 L 15 60 C 28 60, 28 40, 15 40 Z" fill="black"/></svg>');
    -webkit-mask-size: 130%;
    mask-size: 130%;
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    filter: drop-shadow(0 5px 15px rgba(0,0,0,0.2));
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    margin: -5px;
}

.puzzle-piece img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: grayscale(100%) opacity(0.8);
    transition: filter 0.5s ease;
}

.puzzle-piece:hover img, .puzzle-piece.colored img {
    filter: grayscale(0%) opacity(1);
}

.puzzle-piece.colored {
    transform: scale(1.03);
    z-index: 2;
    filter: drop-shadow(0 10px 25px rgba(255, 152, 184, 0.8));
}

/* `.colored-permanent` applied from JS so it stays colored */
.puzzle-piece.colored-permanent img {
    filter: grayscale(0%) opacity(1);
}

.puzzle-hint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255,255,255,0.8);
    color: #E81A63;
    padding: 10px 20px;
    border-radius: 20px;
    font-weight: bold;
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.3s;
    font-family: 'Fredoka One', cursive;
    text-align: center;
}

.puzzle-piece:hover .puzzle-hint, .puzzle-piece.colored .puzzle-hint {
    opacity: 0;
}

/* ========================================
   Modal + Card Flip
   ======================================== */
.nanny-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.6);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    padding: 20px;
}

.nanny-modal.active {
    opacity: 1;
    pointer-events: all;
}

/* Perspective wrapper — holds the flipper + close button */
.nanny-card-flip-container {
    perspective: 1400px;
    max-width: 800px;
    width: 100%;
    position: relative;
    transform: translateY(50px);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.nanny-modal.active .nanny-card-flip-container {
    transform: translateY(0);
}

/* Close button stays outside the flipper so no se voltea */
.close-modal {
    position: absolute;
    top: -16px;
    right: -16px;
    background: white;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.4rem;
    color: #E81A63;
    cursor: pointer;
    z-index: 100;
    border: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    transition: transform 0.2s, box-shadow 0.2s;
}

.close-modal:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 18px rgba(0,0,0,0.25);
}

/* The actual flipper — rotates on Y axis */
.nanny-card-flipper {
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.65s cubic-bezier(0.4, 0.2, 0.2, 1);
    border-radius: 30px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.3);
    cursor: pointer;
}

.nanny-card-flipper.flipped {
    transform: rotateY(180deg);
}

/* Each face — front and back */
.card-face {
    display: flex;
    overflow: hidden;
    border-radius: 30px;
    background: #FFD6E8;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* Back face is flipped 180° and sits on top of the front */
.card-back {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform: rotateY(180deg);
}

/* Left panel — same for front and back */
.card-left {
    flex: 0 0 40%;
    padding: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><text y="50" font-size="20">⭐</text></svg>') repeat;
    background-size: 30px;
}

.card-photo {
    width: 220px;
    height: 220px;
    border-radius: 50%;
    object-fit: cover;
    border: 8px solid white;
    box-shadow: 0 10px 25px rgba(255, 152, 184, 0.6);
}

.card-name {
    margin-top: 20px;
    font-family: 'Fredoka One', cursive;
    color: #73003A;
    font-size: 2.2rem;
    text-align: center;
}

/* Right panel — front */
.card-right {
    flex: 1;
    background: white;
    padding: 36px 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 16px;
    border-top-left-radius: 40px;
    border-bottom-left-radius: 40px;
}

/* Right panel — back (referencias) */
.card-right-refs {
    justify-content: flex-start;
    gap: 14px;
    overflow: hidden;
}

.attribute-row {
    display: flex;
    align-items: flex-start;
    gap: 15px;
}

.attr-icon {
    font-size: 1.6rem;
    color: #FF98B8;
    background: #FFF0F5;
    width: 52px;
    height: 52px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 14px;
    flex-shrink: 0;
}

.attr-text h4 {
    color: #73003A;
    margin-bottom: 4px;
    font-size: 1.1rem;
}

.attr-text p {
    color: #666;
    font-size: 0.92rem;
    line-height: 1.4;
}

/* Flip button */
.flip-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    align-self: flex-end;
    background: #E81A63;
    color: white;
    border: none;
    padding: 10px 22px;
    border-radius: 20px;
    font-size: 0.92rem;
    font-family: 'Quicksand', sans-serif;
    font-weight: 700;
    cursor: pointer;
    margin-top: auto;
    transition: background 0.2s, transform 0.2s;
    letter-spacing: 0.3px;
}

.flip-btn:hover {
    background: #C2004F;
    transform: translateX(5px);
}

.flip-back-btn:hover {
    transform: translateX(-5px);
}

/* Referencias */
.refs-title {
    color: #73003A;
    font-family: 'Quicksand', sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0;
    flex-shrink: 0;
}

.refs-title i {
    color: #E81A63;
}

.refs-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    flex: 1;
    padding-right: 4px;
}

.refs-list::-webkit-scrollbar {
    width: 4px;
}
.refs-list::-webkit-scrollbar-thumb {
    background: #FF98B8;
    border-radius: 4px;
}

.ref-item {
    background: #FFF0F5;
    border-radius: 14px;
    padding: 12px 14px;
    border-left: 4px solid #FF98B8;
}

.ref-family {
    font-weight: 700;
    color: #73003A;
    font-size: 0.88rem;
    margin-bottom: 3px;
}

.ref-stars {
    color: #E81A63;
    font-size: 0.85rem;
    margin-bottom: 5px;
    letter-spacing: 2px;
}

.ref-text {
    color: #555;
    font-size: 0.85rem;
    line-height: 1.5;
    font-style: italic;
    margin: 0;
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 768px) {
    .nanny-card-flip-container {
        max-height: 90vh;
    }

    .card-face {
        flex-direction: column;
    }

    .card-back {
        position: absolute;
        overflow-y: auto;
    }

    .card-left {
        padding: 24px 20px;
        flex: none;
    }

    .card-photo {
        width: 150px;
        height: 150px;
    }

    .card-name {
        font-size: 1.8rem;
    }

    .card-right {
        border-radius: 0;
        border-top-left-radius: 30px;
        border-top-right-radius: 30px;
        padding: 24px 20px;
    }

    .puzzle-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: -20px;
    }

    .puzzle-piece {
        margin: -10px;
    }
}
