:root {
    --sand: #f3ede4;
    --sand-deep: #e6dccd;
    --teal: #2f6f6a;
    --teal-deep: #24544f;
    --sage: #a9c3b6;
    --mist: #dfeae4;
    --paper: #fffdf9;
    --ink: #26302e;
    --ink-soft: #5e6b67;
    --line: rgba(47, 111, 106, 0.22);
    --title: 'Fraunces', Georgia, serif;
    --sans: 'Nunito', system-ui, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    min-height: 100vh;
    min-height: 100svh;
    font-family: var(--sans);
    font-size: 17px;
    color: var(--ink);
    background-color: var(--sand);
    background-image:
        radial-gradient(ellipse at 15% 10%, rgba(169, 195, 182, 0.55) 0%, transparent 50%),
        radial-gradient(ellipse at 90% 95%, rgba(230, 220, 205, 0.9) 0%, transparent 55%);
    background-attachment: fixed;
    overflow-x: hidden;
}

button {
    font: inherit;
    color: inherit;
}

/* ---------- Bulles ---------- */

.bubbles {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.bubbles span {
    position: absolute;
    bottom: -10%;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.9), rgba(169, 195, 182, 0.55));
    animation-name: rise, drift;
    animation-timing-function: linear, ease-in-out;
    animation-iteration-count: infinite, infinite;
    animation-direction: normal, alternate;
}

@keyframes rise {
    to { bottom: 110%; }
}

@keyframes drift {
    from { transform: translateX(-18px); }
    to { transform: translateX(18px); }
}

/* ---------- Scènes ---------- */

main {
    position: relative;
    z-index: 1;
}

.scene {
    display: none;
    min-height: 100vh;
    min-height: 100svh;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
    text-align: center;
}

.scene.active {
    display: flex;
    animation: appear 0.9s ease both;
}

@keyframes appear {
    from { opacity: 0; }
    to { opacity: 1; }
}

.card {
    position: relative;
    width: 100%;
    max-width: 460px;
    padding: 36px 26px 30px;
    background: var(--paper);
    border-radius: 22px;
    box-shadow: 0 24px 50px rgba(38, 48, 46, 0.12), 0 0 0 1px var(--line);
}

.card-wide {
    max-width: 520px;
}

.kicker {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--ink-soft);
    letter-spacing: 0.02em;
}

#scene-letter .kicker {
    color: var(--teal-deep);
    font-family: var(--title);
    font-weight: 500;
    font-size: 1.6rem;
    margin-bottom: 36px;
}

h1 {
    font-family: var(--title);
    font-weight: 600;
    font-size: 2.3rem;
    line-height: 1.15;
    margin: 10px 0 8px;
}

h2 {
    font-family: var(--title);
    font-weight: 600;
    font-size: 1.5rem;
    margin-top: 26px;
}

h3 {
    font-weight: 700;
    font-size: 1.1rem;
    margin: 24px 0 10px;
}

.title-big {
    font-family: var(--title);
    font-weight: 600;
    font-size: 2.6rem;
    line-height: 1.1;
    color: var(--teal);
}

.lead {
    font-size: 1.12rem;
    line-height: 1.55;
    color: var(--ink-soft);
    margin-top: 8px;
}

.lead-tight {
    margin: 0 0 14px;
}

.small {
    font-size: 0.98rem;
    color: var(--ink-soft);
    margin: 4px 0 16px;
}

.hint {
    margin-top: 30px;
    color: var(--teal);
    font-size: 1rem;
    animation: breathe 2.4s ease-in-out infinite;
}

@keyframes breathe {
    0%, 100% { opacity: 0.45; }
    50% { opacity: 1; }
}

/* ---------- Enveloppe ---------- */

.envelope {
    position: relative;
    width: 300px;
    height: 200px;
    border: none;
    background: none;
    cursor: pointer;
    perspective: 900px;
    filter: drop-shadow(0 18px 26px rgba(38, 48, 46, 0.22));
    animation: float 4s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.envelope > span {
    position: absolute;
    left: 0;
    width: 100%;
}

.env-back {
    top: 0;
    height: 100%;
    background: #c9b9a2;
    border-radius: 6px;
    z-index: 1;
}

.env-paper {
    top: 10px;
    left: 16px !important;
    width: calc(100% - 32px) !important;
    height: calc(100% - 20px);
    background: var(--paper);
    border-radius: 4px;
    z-index: 2;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 22px;
    font-family: var(--title);
    font-size: 1.6rem;
    color: var(--teal);
    transition: transform 0.9s ease 0.45s;
}

.env-front {
    top: 0;
    height: 100%;
    background: linear-gradient(160deg, #eadfce, #ddcfba);
    clip-path: polygon(0 0, 50% 56%, 100% 0, 100% 100%, 0 100%);
    border-radius: 6px;
    z-index: 3;
}

.env-flap {
    top: 0;
    height: 58%;
    background: linear-gradient(180deg, #d9c9b1, #c9b9a2);
    clip-path: polygon(0 0, 100% 0, 50% 100%);
    transform-origin: top center;
    transition: transform 0.6s ease, z-index 0s linear 0.3s;
    z-index: 4;
}

.seal {
    top: 44% !important;
    left: 50% !important;
    width: 54px !important;
    height: 54px;
    margin-left: -27px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #3f8a83, var(--teal-deep));
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25), inset 0 0 0 3px rgba(255, 255, 255, 0.1);
    color: var(--paper);
    font-size: 1.4rem;
    line-height: 54px;
    z-index: 5;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.envelope:hover .seal {
    transform: scale(1.08);
}

.envelope.open {
    animation: none;
}

.envelope.open .seal {
    opacity: 0;
    transform: scale(0.6);
}

.envelope.open .env-flap {
    transform: rotateX(180deg);
    z-index: 0;
}

.envelope.open .env-paper {
    transform: translateY(-62%);
}

/* ---------- Question ---------- */

.frame {
    width: 170px;
    height: 170px;
    margin: 6px auto 4px;
    border-radius: 50%;
    background: radial-gradient(circle, #fff 0%, var(--mist) 100%);
    box-shadow: inset 0 0 0 1px var(--line);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.frame img {
    width: 78%;
    height: 78%;
    object-fit: contain;
    transition: opacity 0.2s ease;
}

.frame-small {
    width: 120px;
    height: 120px;
}

.frame-emoji {
    font-size: 3.6rem;
    line-height: 1;
}

.buttons {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: center;
    align-items: center;
    margin-top: 26px;
}

.btn {
    border: none;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 700;
    letter-spacing: 0.02em;
    transition: transform 0.15s ease, box-shadow 0.15s ease, font-size 0.25s ease, padding 0.25s ease;
}

.btn-yes {
    font-size: 1.2rem;
    padding: 14px 40px;
    color: var(--paper);
    background: linear-gradient(135deg, var(--teal), var(--teal-deep));
    box-shadow: 0 8px 20px rgba(36, 84, 79, 0.3);
}

.btn-yes:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 12px 26px rgba(36, 84, 79, 0.38);
}

.btn-yes:disabled {
    opacity: 0.7;
    cursor: wait;
}

.btn-no {
    font-size: 1rem;
    padding: 11px 26px;
    color: var(--ink-soft);
    background: transparent;
    box-shadow: inset 0 0 0 1px rgba(94, 107, 103, 0.45);
}

.btn-no.runaway {
    position: fixed;
    z-index: 50;
    background: var(--paper);
    transition: left 0.25s ease, top 0.25s ease, font-size 0.25s ease;
}

/* Au 5e refus, le Non se pose au milieu du Oui */
.btn-no.on-yes {
    position: absolute;
    left: 50%;
    top: 80%;
    z-index: 2;
    font-size: 0.9rem;
    background: var(--paper);
    transform: translate(-50%, -50%);
    animation: land 0.45s ease both;
}

@keyframes land {
    from { opacity: 0; transform: translate(-50%, -160%) scale(0.6); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.btn-block {
    display: block;
    width: 100%;
    margin-top: 22px;
    text-align: center;
    text-decoration: none;
}

.btn-wa {
    font-size: 1.1rem;
    padding: 14px 24px;
    color: #fff;
    background: linear-gradient(135deg, #2e8b62, #1f6b4b);
    box-shadow: 0 8px 22px rgba(31, 107, 75, 0.3);
}

.btn-wa[hidden] {
    display: none;
}

/* ---------- Calendrier ---------- */

#date-form {
    text-align: left;
}

#date-form h2,
#date-form .small {
    text-align: center;
}

.calendar {
    border-radius: 16px;
    background: #fff;
    box-shadow: inset 0 0 0 1px var(--line);
    padding: 14px 12px 12px;
}

.cal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 1.15rem;
    font-weight: 700;
}

.cal-nav {
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 50%;
    background: var(--mist);
    color: var(--teal-deep);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
}

.cal-nav:disabled {
    opacity: 0.3;
    cursor: default;
}

.cal-days,
.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    text-align: center;
}

.cal-days span {
    font-size: 0.8rem;
    color: var(--ink-soft);
    padding-bottom: 4px;
}

.cal-day {
    aspect-ratio: 1;
    border: none;
    border-radius: 50%;
    background: transparent;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.cal-day:hover:not(:disabled):not(.selected) {
    background: var(--mist);
}

.cal-day.today {
    box-shadow: inset 0 0 0 1.5px var(--sage);
}

.cal-day.selected {
    background: var(--teal);
    color: var(--paper);
}

.cal-day:disabled {
    opacity: 0.25;
    cursor: default;
}

.slots {
    list-style: none;
    margin-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.slots li {
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(223, 234, 228, 0.6);
    animation: appear 0.35s ease both;
}

.slot-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
    font-size: 1.02rem;
    margin-bottom: 8px;
}

.slot-head span::first-letter {
    text-transform: uppercase;
}

.slot-remove {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--ink-soft);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
}

.slot-remove:hover {
    background: rgba(255, 255, 255, 0.8);
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chip {
    border: none;
    border-radius: 999px;
    padding: 8px 16px;
    background: #fff;
    box-shadow: inset 0 0 0 1px rgba(94, 107, 103, 0.3);
    font-size: 0.98rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.chip:hover:not(.selected) {
    box-shadow: inset 0 0 0 1px var(--teal);
}

.chip.selected {
    background: var(--teal-deep);
    color: var(--paper);
    box-shadow: none;
}

.chips-small .chip {
    padding: 6px 13px;
    font-size: 0.92rem;
}

textarea {
    display: block;
    width: 100%;
    margin-top: 22px;
    padding: 12px 14px;
    border: none;
    border-radius: 14px;
    background: #fff;
    box-shadow: inset 0 0 0 1px rgba(94, 107, 103, 0.3);
    font-family: var(--sans);
    font-size: 1rem;
    color: var(--ink);
    resize: none;
    outline: none;
}

textarea:focus {
    box-shadow: inset 0 0 0 1.5px var(--teal);
}

.form-error {
    margin-top: 12px;
    text-align: center;
    color: #b0442f;
}

.form-error[hidden] {
    display: none;
}

/* ---------- Fin ---------- */

.recap {
    list-style: none;
    margin: 20px 0 4px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 1.05rem;
    font-weight: 600;
}

.recap li::before {
    content: '✓';
    color: var(--teal);
    margin-right: 8px;
}

.recap .recap-idea {
    font-style: italic;
    font-weight: 400;
    color: var(--ink-soft);
}

.signature {
    margin-top: 26px;
    font-family: var(--title);
    font-size: 1.6rem;
    color: var(--teal);
    text-align: right;
    padding-right: 10px;
}

/* ---------- Musique ---------- */

.music-toggle {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 100;
    width: 46px;
    height: 46px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 253, 249, 0.7);
    box-shadow: inset 0 0 0 1px var(--line);
    color: var(--teal);
    font-size: 1.3rem;
    cursor: pointer;
    backdrop-filter: blur(6px);
}

.music-toggle.off {
    opacity: 0.45;
    text-decoration: line-through;
}

.music-toggle[hidden] {
    display: none;
}

/* ---------- Mobile ---------- */

@media (max-width: 480px) {
    body { font-size: 16px; }
    h1 { font-size: 1.95rem; }
    .card { padding: 30px 18px 24px; }
    .title-big { font-size: 2.2rem; }
    .envelope { width: 270px; height: 180px; }
    .frame { width: 150px; height: 150px; }
    .frame-small { width: 104px; height: 104px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}
