/* =========================================
   CALENDRIER NRV — style carte à gratter
   + Shimmer animé + Case du jour dorée pulsante
   Compatible : Chrome / Firefox / Safari
   Responsive : mobile / tablette / desktop
   ========================================= */

/* =========================================
   GRILLE
   ========================================= */
.calendar {
    display: grid;
    width: 96%;
    max-width: 960px;
    margin: 2% auto;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}
@media (min-width: 500px) {
    .calendar { grid-template-columns: repeat(4, 1fr); gap: 16px; }
}
@media (min-width: 768px) {
    .calendar { grid-template-columns: repeat(6, 1fr); gap: 18px; }
}

/* =========================================
   TILE WRAPPER
   ========================================= */
.calendar > div {
    position: relative;
    isolation: isolate;
}

/* =========================================
   LABEL
   ========================================= */
.calendar > div label {
    position: relative;
    display: block;
    width: 100%;
    height: 100px;
    cursor: pointer;
    perspective: 900px;
    -webkit-perspective: 900px;
    user-select: none;
    -webkit-user-select: none;
}
@media (min-width: 500px) { .calendar > div label { height: 110px; } }
@media (min-width: 768px) { .calendar > div label { height: 120px; } }

/* =========================================
   CHECKBOX cachée
   ========================================= */
.calendar input[type="checkbox"] { display: none; }

/* =========================================
   DOOR
   ========================================= */
.door {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 12px;
    transform-style: preserve-3d;
    -webkit-transform-style: preserve-3d;
    transition: transform 420ms cubic-bezier(0.4, 0.2, 0.2, 1);
    will-change: transform;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

/* =========================================
   FACES communes
   ========================================= */
.door .front,
.door .back,
.door form.front {
    position: absolute;
    inset: 0;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    font-family: 'Kalam', cursive;
    font-size: 1.8em;
    font-weight: 700;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}
@media (min-width: 768px) {
    .door .front, .door .back, .door form.front { font-size: 2em; }
}

/* =========================================
   KEYFRAMES
   ========================================= */

/* Shimmer argenté */
@keyframes shimmer {
    0%   { transform: translateX(-120%) skewX(-15deg); }
    18%  { transform: translateX(220%)  skewX(-15deg); }
    100% { transform: translateX(220%)  skewX(-15deg); }
}

/* Glow doré pulsant */
@keyframes goldPulse {
    0%   { box-shadow: 0 0 0 2px #f5c518, 0 0 8px  4px rgba(245,197,24,0.4),  0 0 18px 6px  rgba(245,197,24,0.15); }
    50%  { box-shadow: 0 0 0 2px #f5c518, 0 0 18px 8px rgba(245,197,24,0.65), 0 0 38px 12px rgba(245,197,24,0.25); }
    100% { box-shadow: 0 0 0 2px #f5c518, 0 0 8px  4px rgba(245,197,24,0.4),  0 0 18px 6px  rgba(245,197,24,0.15); }
}

/* Scale pulsant */
@keyframes goldScalePulse {
    0%   { transform: translateZ(0) scale(1.00); }
    50%  { transform: translateZ(0) scale(1.04); }
    100% { transform: translateZ(0) scale(1.00); }
}

/* =========================================
   FACE AVANT — carte à gratter argentée
   ========================================= */
.door .front,
.door form.front {
    transform: rotateY(0deg) translateZ(1px);
    -webkit-transform: rotateY(0deg) translateZ(1px);

    color: #1e1e1e;
    text-shadow:
        0 1px 0 rgba(255,255,255,0.85),
        0 -1px 0 rgba(0,0,0,0.15);

    background:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 4px,
            rgba(0,0,0,0.025) 4px,
            rgba(0,0,0,0.025) 5px
        ),
        linear-gradient(
            135deg,
            #f0f0f0 0%,
            #ffffff 8%,
            #e2e2e2 16%,
            #ffffff 26%,
            #f8f8f8 36%,
            #e8e8e8 46%,
            #ffffff 56%,
            #ececec 66%,
            #ffffff 76%,
            #e5e5e5 86%,
            #ffffff 100%
        );

    box-shadow:
        inset 0 2px 1px rgba(255,255,255,1),
        inset 0 -2px 1px rgba(0,0,0,0.20),
        inset 2px 0 1px rgba(255,255,255,0.9),
        inset -2px 0 1px rgba(0,0,0,0.14),
        0 6px 18px rgba(0,0,0,0.6),
        0 2px 4px rgba(0,0,0,0.45);

    border: 1px solid rgba(240,240,240,1);
    opacity: 1;
}

/* Shimmer pseudo-élément */
.door .front::before,
.door form.front::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 55%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255,255,255,0.0) 15%,
        rgba(255,255,255,0.90) 50%,
        rgba(255,255,255,0.0) 85%,
        transparent 100%
    );
    pointer-events: none;
    z-index: 2;
    border-radius: 11px;
    animation: shimmer 3.2s ease-in-out infinite;
}

/* Décalages shimmer case par case */
.calendar > div:nth-child(1)  .door .front::before, .calendar > div:nth-child(1)  .door form.front::before { animation-delay: 0.0s; }
.calendar > div:nth-child(2)  .door .front::before, .calendar > div:nth-child(2)  .door form.front::before { animation-delay: 0.2s; }
.calendar > div:nth-child(3)  .door .front::before, .calendar > div:nth-child(3)  .door form.front::before { animation-delay: 0.4s; }
.calendar > div:nth-child(4)  .door .front::before, .calendar > div:nth-child(4)  .door form.front::before { animation-delay: 0.6s; }
.calendar > div:nth-child(5)  .door .front::before, .calendar > div:nth-child(5)  .door form.front::before { animation-delay: 0.8s; }
.calendar > div:nth-child(6)  .door .front::before, .calendar > div:nth-child(6)  .door form.front::before { animation-delay: 1.0s; }
.calendar > div:nth-child(7)  .door .front::before, .calendar > div:nth-child(7)  .door form.front::before { animation-delay: 1.2s; }
.calendar > div:nth-child(8)  .door .front::before, .calendar > div:nth-child(8)  .door form.front::before { animation-delay: 1.4s; }
.calendar > div:nth-child(9)  .door .front::before, .calendar > div:nth-child(9)  .door form.front::before { animation-delay: 1.6s; }
.calendar > div:nth-child(10) .door .front::before, .calendar > div:nth-child(10) .door form.front::before { animation-delay: 1.8s; }
.calendar > div:nth-child(11) .door .front::before, .calendar > div:nth-child(11) .door form.front::before { animation-delay: 2.0s; }
.calendar > div:nth-child(12) .door .front::before, .calendar > div:nth-child(12) .door form.front::before { animation-delay: 2.2s; }
.calendar > div:nth-child(13) .door .front::before, .calendar > div:nth-child(13) .door form.front::before { animation-delay: 2.4s; }
.calendar > div:nth-child(14) .door .front::before, .calendar > div:nth-child(14) .door form.front::before { animation-delay: 2.6s; }
.calendar > div:nth-child(15) .door .front::before, .calendar > div:nth-child(15) .door form.front::before { animation-delay: 2.8s; }
.calendar > div:nth-child(16) .door .front::before, .calendar > div:nth-child(16) .door form.front::before { animation-delay: 0.1s; }
.calendar > div:nth-child(17) .door .front::before, .calendar > div:nth-child(17) .door form.front::before { animation-delay: 0.3s; }
.calendar > div:nth-child(18) .door .front::before, .calendar > div:nth-child(18) .door form.front::before { animation-delay: 0.5s; }
.calendar > div:nth-child(19) .door .front::before, .calendar > div:nth-child(19) .door form.front::before { animation-delay: 0.7s; }
.calendar > div:nth-child(20) .door .front::before, .calendar > div:nth-child(20) .door form.front::before { animation-delay: 0.9s; }
.calendar > div:nth-child(21) .door .front::before, .calendar > div:nth-child(21) .door form.front::before { animation-delay: 1.1s; }
.calendar > div:nth-child(22) .door .front::before, .calendar > div:nth-child(22) .door form.front::before { animation-delay: 1.3s; }
.calendar > div:nth-child(23) .door .front::before, .calendar > div:nth-child(23) .door form.front::before { animation-delay: 1.5s; }
.calendar > div:nth-child(24) .door .front::before, .calendar > div:nth-child(24) .door form.front::before { animation-delay: 1.7s; }
.calendar > div:nth-child(25) .door .front::before, .calendar > div:nth-child(25) .door form.front::before { animation-delay: 1.9s; }
.calendar > div:nth-child(26) .door .front::before, .calendar > div:nth-child(26) .door form.front::before { animation-delay: 2.1s; }
.calendar > div:nth-child(27) .door .front::before, .calendar > div:nth-child(27) .door form.front::before { animation-delay: 2.3s; }
.calendar > div:nth-child(28) .door .front::before, .calendar > div:nth-child(28) .door form.front::before { animation-delay: 2.5s; }
.calendar > div:nth-child(29) .door .front::before, .calendar > div:nth-child(29) .door form.front::before { animation-delay: 2.7s; }
.calendar > div:nth-child(30) .door .front::before, .calendar > div:nth-child(30) .door form.front::before { animation-delay: 2.9s; }
.calendar > div:nth-child(31) .door .front::before, .calendar > div:nth-child(31) .door form.front::before { animation-delay: 0.15s; }

/* Stoppe le shimmer sur opened / locked */
.calendar > div.opened .door .front::before,
.calendar > div.opened .door form.front::before,
.calendar > div.locked .door .front::before,
.calendar > div.locked .door form.front::before {
    animation: none;
}

/* Bouton dans form */
.door form.front button {
    width: 100%;
    height: 100%;
    background: transparent;
    color: #1e1e1e;
    border: none;
    padding: 0;
    font-family: 'Kalam', cursive;
    font-weight: 700;
    font-size: 1em;
    text-shadow: 0 1px 0 rgba(255,255,255,0.85), 0 -1px 0 rgba(0,0,0,0.15);
    cursor: pointer;
    outline: none;
    position: relative;
    z-index: 3;
}

/* =========================================
   FACE ARRIÈRE
   ========================================= */
.door .back {
    transform: rotateY(180deg) translateZ(1px);
    -webkit-transform: rotateY(180deg) translateZ(1px);
    color: #ffffff;
    text-shadow: 0 1px 4px rgba(0,0,0,0.4);
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.12), inset 0 -1px 0 rgba(0,0,0,0.2), 0 2px 6px rgba(0,0,0,0.35);
    border: 1px solid rgba(255,255,255,0.08);
}

.calendar > div:nth-child(12n+1)  .back { background-color: #e84d2a; }
.calendar > div:nth-child(12n+2)  .back { background-color: #a8a010; }
.calendar > div:nth-child(12n+3)  .back { background-color: #3aada8; }
.calendar > div:nth-child(12n+4)  .back { background-color: #9a7e10; }
.calendar > div:nth-child(12n+5)  .back { background-color: #d07820; }
.calendar > div:nth-child(12n+6)  .back { background-color: #6a3535; }
.calendar > div:nth-child(12n+7)  .back { background-color: #0f8a70; }
.calendar > div:nth-child(12n+8)  .back { background-color: #0fa84a; }
.calendar > div:nth-child(12n+9)  .back { background-color: #5a2a6a; }
.calendar > div:nth-child(12n+10) .back { background-color: #b87840; }
.calendar > div:nth-child(12n+11) .back { background-color: #c04800; }
.calendar > div:nth-child(12n)    .back { background-color: #c02818; }

/* =========================================
   FLIP — checkbox cochée
   ========================================= */
.calendar input[type="checkbox"]:checked + .door {
    transform: rotateY(180deg);
    -webkit-transform: rotateY(180deg);
}

/* =========================================
   HOVER — exclut opened, locked, today
   ========================================= */
.calendar > div:not(.opened):not(.locked):not(.today):hover .door {
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
    transform: translateZ(0) translateY(-2px);
    -webkit-transform: translateZ(0) translateY(-2px);
}

/* =========================================
   CASE DU JOUR (.today)
   ========================================= */
.calendar > div.today label {
    cursor: pointer;
}

/* Glow doré pulsant + léger scale */
.calendar > div.today .door {
    animation:
        goldPulse      2s ease-in-out infinite,
        goldScalePulse 2s ease-in-out infinite;
}

/* Shimmer doré plus rapide */
.calendar > div.today .door .front::before,
.calendar > div.today .door form.front::before {
    animation-duration: 1.6s !important;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255,215,0,0.0) 20%,
        rgba(255,215,0,0.85) 50%,
        rgba(255,215,0,0.0) 80%,
        transparent 100%
    ) !important;
}

/* Badge AUJOURD'HUI */
.calendar > div.today::after {
    content: "AUJOURD'HUI";
    position: absolute;
    bottom: 7px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 30;
    pointer-events: none;
    font-size: 8px;
    font-weight: 900;
    letter-spacing: 0.6px;
    font-family: sans-serif;
    white-space: nowrap;
    color: #1a1200;
    background: linear-gradient(135deg, #f5c518, #f0a500);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 999px;
    padding: 3px 7px;
    box-shadow: 0 2px 8px rgba(245,197,24,0.5);
}

/* =========================================
   CASES VERROUILLÉES (.locked)
   ========================================= */
.calendar > div.locked label { cursor: not-allowed; }

.calendar > div.locked .door {
    opacity: 0.65;
    filter: grayscale(0.15);
}

.calendar > div.locked .front::after {
    content: "";
    position: absolute;
    bottom: 7px;
    right: 7px;
    z-index: 4;
    pointer-events: none;
    width: 14px;
    height: 14px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='3' y='11' width='18' height='13' rx='2.5' ry='2.5' fill='%23f5c518' stroke='%23c89a00' stroke-width='1.2'/%3E%3Cpath d='M7 11V7a5 5 0 0 1 10 0v4' fill='none' stroke='%23c89a00' stroke-width='2.2' stroke-linecap='round'/%3E%3Ccircle cx='12' cy='16' r='1.8' fill='%23a07000'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
}

/* =========================================
   ÉTAT OPENED (.opened)
   ========================================= */
.calendar > div.opened label { cursor: default; }

.calendar > div.opened .door {
    transform: rotateY(180deg) !important;
    -webkit-transform: rotateY(180deg) !important;
    animation: none !important;
    box-shadow:
        0 0 0 2px rgba(46,204,113,0.65),
        0 0 0 5px rgba(46,204,113,0.12),
        0 6px 22px rgba(46,204,113,0.22);
}

.calendar > div.opened .front,
.calendar > div.opened form.front {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

.calendar > div.opened .back {
    opacity: 1 !important;
    visibility: visible !important;
}

/* Badge ✓ */
.calendar > div.opened::before {
    content: "✓";
    position: absolute;
    top: 7px;
    right: 7px;
    z-index: 30;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 900;
    font-family: sans-serif;
    color: #ffffff;
    background: linear-gradient(180deg, #2ecc71, #1fa858);
    box-shadow: 0 0 0 2px rgba(255,255,255,0.2), 0 3px 10px rgba(46,204,113,0.45);
    pointer-events: none;
}

/* Badge OUVERTE */
.calendar > div.opened::after {
    content: "OUVERTE";
    position: absolute;
    bottom: 7px;
    right: 7px;
    left: auto;
    transform: none;
    z-index: 30;
    pointer-events: none;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.5px;
    font-family: sans-serif;
    white-space: nowrap;
    color: #ffffff;
    background: rgba(10,15,25,0.88);
    border: 1px solid rgba(46,204,113,0.65);
    border-radius: 999px;
    padding: 3px 7px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* =========================================
   ACCESSIBILITÉ
   ========================================= */
@media (prefers-reduced-motion: reduce) {
    .door { transition: none; }
    .door .front::before,
    .door form.front::before { animation: none; }
    .calendar > div.today .door { animation: none; }
}
