@font-face {
    font-family: "Playfair Display";
    src: url("font/PlayfairDisplay-Medium.ttf") format("truetype");
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

:root {
    --ink: #302416;
    --brown: #70432d;
    --rust: #273142;
    --cream: #ffffff;
    --paper: #fbf6ec;
    --line: rgba(74, 49, 29, 0.22);
    --shadow: 0 30px 80px rgba(53, 35, 20, 0.18);
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    background: var(--cream);
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background: #ffffff;
    font-family: Arial, Helvetica, sans-serif;
}

button,
input {
    font: inherit;
}

/* L'en-tête et le corps partagent exactement la même largeur et le même
   retrait latéral : le titre s'aligne sur la colonne du formulaire. */
.page-header,
.page-shell {
    width: min(1500px, 100%);
    margin-inline: auto;
    padding-inline: clamp(28px, 5vw, 80px);
}

.page-header {
    padding-block: clamp(28px, 5vw, 72px) 0;
}

.page-shell {
    /* Le retrait du haut est désormais assuré par l'en-tête. */
    padding-block: clamp(18px, 2.5vw, 40px) clamp(28px, 5vw, 80px);
    display: grid;
    grid-template-columns: minmax(300px, 1fr) minmax(360px, 0.8fr);
    gap: clamp(48px, 6vw, 100px);
    /* Les deux colonnes démarrent sur la même ligne haute : le formulaire suit
       le titre au lieu d'être centré face à l'aperçu, bien plus haut que lui. */
    align-items: start;
}

.intro {
    min-width: 0;
    max-width: 510px;
}

.eyebrow,
.preview-kicker {
    margin: 0 0 12px;
    color: var(--rust);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.19em;
    text-transform: uppercase;
}

h1,
h2 {
    font-family: "Playfair Display", Georgia, serif;
    font-weight: 500;
}

h1 {
    margin: 0;
    color: #008c6f;
    font-size: clamp(2.6rem, 4.8vw, 5rem);
    line-height: 0.98;
    letter-spacing: -0.035em;
}

.intro-text {
    max-width: 460px;
    margin: 28px 0 38px;
    color: rgba(48, 36, 22, 0.73);
    font-size: 1rem;
    line-height: 1.7;
}

.invitation-form {
    min-width: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 22px 18px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.email-field,
.companions-field,
.captcha-field,
.seats-counter,
.download-button,
.form-status {
    grid-column: 1 / -1;
}

.captcha-field {
    max-width: 280px;
}

.field-help {
    color: rgba(48, 36, 22, 0.62);
    font-size: 0.75rem;
    line-height: 1.4;
}

.captcha-field.is-valid input {
    border-color: #008c6f;
    box-shadow: 0 0 0 3px rgba(0, 140, 111, 0.12);
}

.honeypot-field {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    clip-path: inset(50%) !important;
    white-space: nowrap !important;
}

label {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

input {
    width: 100%;
    height: 52px;
    padding: 0.375rem 0.75rem;
    color: #495057;
    border: 1px solid #ced4da;
    border-radius: 0.25rem;
    outline: none;
    background-color: #ffffff;
    background-clip: padding-box;
    font-size: 1rem;
    line-height: 1.5;
    transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input::placeholder {
    color: rgba(48, 36, 22, 0.36);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="number"]:focus {
    border-color: var(--rust);
    background-color: #f1f4f8;
    box-shadow: 0 0 0 3px rgba(145, 71, 47, 0.11);
}

.number-control {
    width: 172px;
    height: 52px;
    display: grid;
    grid-template-columns: 48px 1fr 48px;
    overflow: hidden;
    color: #495057;
    border: 1px solid #ced4da;
    border-radius: 0.25rem;
    background-color: #ffffff;
    background-clip: padding-box;
    font-size: 1rem;
    line-height: 1.5;
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

.number-control:focus-within {
    border-color: var(--rust);
    box-shadow: 0 0 0 3px rgba(145, 71, 47, 0.11);
}

.number-control input {
    height: 100%;
    padding: 0;
    color: #495057;
    border: 0;
    border-radius: 0;
    text-align: center;
    background: transparent;
    appearance: textfield;
}

.number-control input::-webkit-inner-spin-button,
.number-control input::-webkit-outer-spin-button {
    margin: 0;
    appearance: none;
}

.number-button {
    padding: 0;
    color: var(--brown);
    border: 0;
    background: transparent;
    cursor: pointer;
    font-size: 1.35rem;
    transition: background 160ms ease;
}

.number-button:hover {
    background-color: #f1f4f8;
}

.number-button:focus-visible,
.download-button:focus-visible {
    outline: 3px solid rgba(145, 71, 47, 0.3);
    outline-offset: 3px;
}

.seats-counter {
    margin: -6px 0 0;
    padding: 11px 14px;
    color: rgba(48, 36, 22, 0.78);
    border-radius: 4px;
    background: #f1f4f8;
    font-size: 0.86rem;
    line-height: 1.4;
}

.seats-counter:empty {
    display: none;
}

.seats-counter strong {
    color: #008c6f;
    font-weight: 700;
}

.seats-counter.is-full {
    color: #8c2f2f;
    background: #fbeeee;
    font-weight: 700;
}

.download-button {
    min-height: 58px;
    margin-top: 4px;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: #ffffff;
    border: 0;
    border-radius: 4px;
    background: #008c6f;
    box-shadow: 0 12px 25px rgba(0, 140, 111, 0.19);
    cursor: pointer;
    font-weight: 700;
    transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.download-button:hover {
    transform: translateY(-2px);
    background: #1865b5;
    box-shadow: 0 16px 30px rgba(24, 101, 181, 0.24);
}

.download-button:disabled {
    cursor: not-allowed;
    opacity: 0.7;
    transform: none;
}

.download-button.is-submitting:disabled {
    cursor: wait;
}

.download-button svg {
    width: 20px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

.form-status {
    min-height: 20px;
    margin: -8px 0 0;
    color: var(--rust);
    font-size: 0.84rem;
}

.preview-panel {
    min-width: 0;
    padding: clamp(22px, 3vw, 40px);
    border: 1px solid rgba(99, 65, 37, 0.14);
    border-radius: 8px;
    background: #f1f4f8;
    box-shadow: var(--shadow);
    backdrop-filter: blur(8px);
}

.preview-header {
    margin-bottom: 22px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
}

.preview-kicker {
    margin-bottom: 5px;
}

h2 {
    margin: 0;
    color: #273142;
    font-size: clamp(1.5rem, 2.3vw, 2.2rem);
}

.format-label {
    padding: 8px 10px;
    color: rgba(48, 36, 22, 0.64);
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
}

.canvas-frame {
    position: relative;
    width: 100%;
    max-width: 460px;
    min-width: 0;
    margin-inline: auto;
    overflow: hidden;
    aspect-ratio: 794 / 1135;
    background: #e72963;
    box-shadow: 0 14px 35px rgba(50, 32, 17, 0.2);
}

canvas {
    width: 100%;
    height: 100%;
    min-width: 0;
    display: block;
}

.loading-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--brown);
    background: rgba(244, 234, 215, 0.9);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    transition: opacity 220ms ease, visibility 220ms ease;
}

.loading-overlay.is-hidden {
    opacity: 0;
    visibility: hidden;
}

.loading-overlay span {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(112, 67, 45, 0.2);
    border-top-color: var(--brown);
    border-radius: 50%;
    animation: spin 700ms linear infinite;
}

.privacy-note {
    margin: 17px 0 0;
    color: rgba(48, 36, 22, 0.56);
    font-size: 0.74rem;
    line-height: 1.5;
    text-align: center;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 1050px) {
    .page-shell {
        grid-template-columns: minmax(0, 1fr);
        align-items: start;
        align-content: start;
    }

    .intro {
        max-width: 680px;
    }
}

@media (max-width: 620px) {
    .page-header,
    .page-shell {
        padding-inline: 16px;
    }

    .page-header {
        padding-block: 24px 0;
    }

    .page-shell {
        padding-block: 16px 40px;
        gap: 38px;
    }

    .invitation-form {
        grid-template-columns: 1fr;
    }

    .field,
    .email-field,
    .companions-field,
    .captcha-field,
    .seats-counter,
    .download-button,
    .form-status {
        grid-column: 1;
    }

    .download-button {
        width: 100%;
        padding-inline: 12px;
        font-size: 0.9rem;
    }

    .preview-panel {
        padding: 14px;
    }

    .preview-header {
        align-items: flex-start;
    }

    .format-label {
        display: none;
    }
}

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