/* =========================================================
   RESET
========================================================= */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100vh;

    background: #071722;
    color: #ffffff;

    font-family:
        Arial,
        Helvetica,
        sans-serif;

    overflow-x: hidden;

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


/* =========================================================
   GENERATOR
========================================================= */

.generator {
    width: min(100% - 30px, 650px);
    margin: 0 auto;
    padding: 25px 0 40px;
}


/* =========================================================
   HEADER
========================================================= */

.header {
    width: 100%;
    text-align: center;
    margin-bottom: 22px;
}

.header h1 {
    margin: 0 0 8px;

    font-size: clamp(25px, 6vw, 40px);
    font-weight: 800;

    line-height: 1.15;

    overflow-wrap: break-word;
}

.header p {
    margin: 0;

    font-size: clamp(14px, 3.5vw, 18px);
    font-weight: 600;

    line-height: 1.4;

    overflow-wrap: break-word;
}

.header small {
    display: block;

    max-width: 550px;
    margin: 8px auto 0;

    color: #b8c5cc;

    line-height: 1.5;
}


/* =========================================================
   GENERATOR CONTENT
========================================================= */

.generator-content {
    width: 100%;
}


/* =========================================================
   POSTER
========================================================= */

.poster {
    position: relative;

    width: 100%;

    /*
       Important :
       on laisse le ratio de l'image déterminer
       automatiquement la hauteur.
    */

    overflow: hidden;

    border-radius: 18px;

    background: #111111;

    user-select: none;
    -webkit-user-select: none;

    touch-action: none;

    box-shadow:
        0 15px 40px rgba(0, 0, 0, 0.30);
}


/* =========================================================
   BACKGROUND
========================================================= */

.background {
    display: block;

    width: 100%;
    height: auto;

    position: relative;

    z-index: 1;

    pointer-events: none;

    user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: none;
}


/* =========================================================
   PHOTO ZONE
========================================================= */

.photo-zone {
    position: absolute;

    /*
       Position proportionnelle au poster.
    */

    left: 56.92%;
    top: 22%;

    width: 38%;
    height: 56%;

    overflow: hidden;

    z-index: 2;

    cursor: grab;

    touch-action: none;

    user-select: none;
    -webkit-user-select: none;

    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

.photo-zone:active {
    cursor: grabbing;
}


/* =========================================================
   USER PHOTO
========================================================= */

.user-photo {
    position: absolute;

    left: 50%;
    top: 50%;

    display: block;

    width: 100%;
    height: 100%;

    object-fit: cover;

    z-index: 3;

    transform:
        translate(-50%, -50%)
        scale(1)
        rotate(0deg);

    transform-origin: center center;

    pointer-events: none;

    user-select: none;
    -webkit-user-select: none;

    -webkit-user-drag: none;
    -webkit-touch-callout: none;
}


/* =========================================================
   CONTROLS
========================================================= */

.controls {
    width: 100%;

    margin-top: 20px;
    padding: 20px;

    background: #102838;

    border-radius: 20px;

    box-shadow:
        0 10px 30px rgba(0, 0, 0, 0.20);
}


/* =========================================================
   UPLOAD BUTTON
========================================================= */

.upload-btn {
    display: flex;

    width: 100%;
    min-height: 54px;

    align-items: center;
    justify-content: center;

    padding: 15px 20px;

    background: #38a9ff;
    color: #071722;

    text-align: center;

    font-size: 17px;
    font-weight: 700;

    border-radius: 50px;

    cursor: pointer;

    transition:
        transform 0.15s ease,
        opacity 0.15s ease;

    -webkit-tap-highlight-color: transparent;
}

.upload-btn:hover {
    transform: translateY(-1px);
}

.upload-btn:active {
    transform: scale(0.98);
}


/* =========================================================
   STATUS
========================================================= */

.status-message {
    margin: 16px 0;

    color: #b8c5cc;

    text-align: center;

    font-size: 14px;

    line-height: 1.5;
}


/* =========================================================
   CONTROLS
========================================================= */

.control {
    width: 100%;
    margin-top: 20px;
}

.control-title {
    display: flex;

    justify-content: space-between;
    align-items: center;

    gap: 15px;

    margin-bottom: 9px;

    font-size: 15px;
}

.control-title strong {
    color: #38a9ff;

    white-space: nowrap;
}


/* =========================================================
   RANGE
========================================================= */

.control input[type="range"] {
    display: block;

    width: 100%;

    height: 35px;

    margin: 0;

    cursor: pointer;

    accent-color: #38a9ff;

    touch-action: manipulation;
}


/* =========================================================
   BUTTONS
========================================================= */

.buttons {
    display: flex;
    flex-direction: row;
    gap: 10px;
    margin-top: 20px;
    width: 100%;
}

.buttons button {
       flex: 1;
    min-height: 44px;
    padding: 10px 14px;

    border: none;
    border-radius: 30px;

    font-size: 14px;
    font-weight: 700;

    cursor: pointer;

    transition:
        transform 0.15s ease,
        opacity 0.15s ease;

    -webkit-tap-highlight-color: transparent;
}

#resetBtn {
    background: #294252;
    color: #ffffff;
}

#downloadBtn {
    background: #38a9ff;
    color: #071722;
}

.buttons button:hover:not(:disabled) {
    transform: translateY(-2px);
}

.buttons button:active:not(:disabled) {
    transform: scale(0.98);
}

.buttons button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}


/* =========================================================
   MES REALISATIONS
========================================================= */

.realisations {
    width: 100%;
    margin-top: 45px;
}

.realisations-header {
    text-align: center;
    margin-bottom: 20px;
}

.realisations-header h2 {
    margin: 0 0 8px;

    font-size: clamp(24px, 5vw, 32px);
}

.realisations-header p {
    margin: 0;

    color: #b8c5cc;

    font-size: 15px;
    line-height: 1.5;
}

.realisations-grid {
    display: grid;

    grid-template-columns: repeat(2, minmax(0, 1fr));

    gap: 15px;

    width: 100%;
}

.realisation-card {
    width: 100%;

    overflow: hidden;

    border-radius: 15px;

    background: #102838;
}

.realisation-card img {
    display: block;

    width: 100%;
    height: auto;

    aspect-ratio: 4 / 5;

    object-fit: cover;

    user-select: none;
    -webkit-user-select: none;

    transition: transform 0.25s ease;
}

.realisation-card:hover img {
    transform: scale(1.03);
}


/* =========================================================
   CONTACT
========================================================= */

.contact {
    margin-top: 45px;

    padding: 25px 20px;

    text-align: center;

    background: #102838;

    border-radius: 20px;
}

.contact h2 {
    margin: 0 0 10px;

    font-size: clamp(22px, 5vw, 30px);
}

.contact p {
    margin: 0;

    color: #b8c5cc;

    line-height: 1.6;
}

.contact strong {
    color: #38a9ff;
}


/* =========================================================
   TABLETTES
========================================================= */

@media (max-width: 700px) {

    .generator {
        width: min(100% - 24px, 650px);
        padding-top: 20px;
    }

    .poster {
        border-radius: 15px;
    }

    .controls {
        padding: 18px;
    }
}


/* =========================================================
   SMARTPHONES
========================================================= */

@media (max-width: 600px) {

    body {
        width: 100%;
    }

    .generator {
        width: calc(100% - 20px);
        max-width: none;

        padding-top: 15px;
        padding-bottom: 30px;
    }


    /* HEADER */

    .header {
        margin-bottom: 15px;
    }

    .header h1 {
        font-size: clamp(22px, 7vw, 30px);
        line-height: 1.15;
    }

    .header p {
        font-size: 15px;
        line-height: 1.4;
    }

    .header small {
        font-size: 12px;
    }


    /* POSTER */

    .poster {
        width: 100%;

        border-radius: 12px;

        /*
           Important pour les téléphones :
           aucun déplacement horizontal
           de la page.
        */

        touch-action: none;
    }


    /*
       On conserve la position proportionnelle
       de la photo.
    */

    .photo-zone {
        left: 56.92%;
        top: 22%;

        width: 38%;
        height: 56%;
    }


    /* CONTROLS */

    .controls {
        margin-top: 15px;

        padding: 15px;

        border-radius: 16px;
    }


    /* UPLOAD */

    .upload-btn {
        min-height: 52px;

        padding: 14px;

        font-size: 16px;
    }


    /* STATUS */

    .status-message {
        margin: 14px 0;

        font-size: 13px;
    }


    /* RANGE */

    .control {
        margin-top: 18px;
    }

    .control-title {
        font-size: 14px;
    }

    .control input[type="range"] {
        height: 40px;
    }


    /* BUTTONS — TOUJOURS SUR UNE SEULE LIGNE */

    .buttons {
        display: flex;
        flex-direction: row;
        align-items: stretch;
        gap: 8px;
        width: 100%;
        margin-top: 20px;
    }

    .buttons button {
        flex: 1 1 0;
        width: auto;
        min-width: 0;
        min-height: 42px;

        padding: 9px 10px;

        font-size: 13px;
        line-height: 1.2;
        white-space: nowrap;

        border-radius: 25px;
    }


    /* REALISATIONS */

    .realisations {
        margin-top: 35px;
    }

    .realisations-grid {
        grid-template-columns: 1fr;

        gap: 12px;
    }

    .realisation-card {
        border-radius: 12px;
    }


    /* CONTACT */

    .contact {
        margin-top: 35px;

        padding: 22px 15px;

        border-radius: 16px;
    }

    .contact p {
        font-size: 14px;
    }
}


/* =========================================================
   PETITS SMARTPHONES
========================================================= */

@media (max-width: 400px) {

    .generator {
        width: calc(100% - 16px);

        padding-top: 10px;
    }


    .header h1 {
        font-size: 22px;
    }

    .header p {
        font-size: 14px;
    }


    .poster {
        border-radius: 10px;
    }


    .controls {
        padding: 12px;

        border-radius: 14px;
    }


    .upload-btn {
        min-height: 50px;

        font-size: 15px;
    }


    .control-title {
        font-size: 13px;
    }


    .buttons button {
        min-height: 50px;

        font-size: 15px;
    }


    .realisations-header h2 {
        font-size: 23px;
    }

    .realisations-header p {
        font-size: 13px;
    }
}


/* =========================================================
   TRÈS PETITS ÉCRANS
========================================================= */

@media (max-width: 350px) {

    .generator {
        width: calc(100% - 12px);
    }

    .header h1 {
        font-size: 20px;
    }

    .header p {
        font-size: 13px;
    }

    .controls {
        padding: 10px;
    }

    .buttons {
        gap: 7px;
    }

    .buttons button {
        min-height: 40px;
        padding: 8px 7px;
        font-size: 12px;
    }
}


/* =========================================================
   ÉCRANS LARGES
========================================================= */

@media (min-width: 651px) {

    .generator {
        max-width: 650px;
    }

    .photo-zone {
        left: 56.92%;
        top: 22%;

        width: 38%;
        height: 56%;
    }
}


/* =========================================================
   ACCESSIBILITÉ
========================================================= */

button:focus-visible,
label:focus-visible,
input:focus-visible {
    outline: 3px solid #ffffff;
    outline-offset: 3px;
}


/* =========================================================
   ÉVITER LES ANIMATIONS POUR LES UTILISATEURS
   QUI LES ONT DÉSACTIVÉES
========================================================= */

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition: none !important;
        animation: none !important;
    }
}