/* ==========================================================================
   Une page, un écran
   ==========================================================================

   L'accueil et les outils tiennent dans la fenêtre, sans défilement de
   page, sur un écran d'ordinateur. C'est la règle du site : un outil qui
   fait ce qu'il dit n'a pas besoin qu'on le cherche.

   Cette feuille se charge en dernier, sur les seules pages qui portent
   « ecran » sur <body>. Elle tient le cadre et les outils ; la composition
   de l'accueil est dans styles/accueil.css.

   Le seuil est repris tel quel dans scripts/trame.js, scripts/page-effects.js,
   scripts/outil-papier.js et test/layout-test.js : tous doivent rester
   identiques. Sous ce seuil, la page défile comme avant.

   Quand un contenu ne tient plus, il ne pousse pas la page : un résultat
   sans borne, celui d'une conversion par exemple, défile dans son propre
   panneau.
   ========================================================================== */

@media (min-width: 1100px) and (min-height: 600px) {

    body.ecran {
        height: 100vh;
        height: 100dvh;
        overflow: hidden;
    }

    /* ----------------------------------------------------------------------
       La barre
       ----------------------------------------------------------------------
       La pastille flottante du bas occupait la hauteur, la seule dimension
       comptée ici. Elle se réduit à un groupe discret en haut à droite : le
       logo, qui ramène à l'accueil, la langue et le thème. */

    body.ecran .navbar {
        top: 0.9rem;
        right: 1.5rem;
        bottom: auto;
        left: auto;
        width: auto;
        min-width: 0;
        max-width: none;
        height: 40px;
        transform: none;
        gap: 0.35rem;
        padding: 0;
        background: none;
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        visibility: visible;
        overflow: visible;
        transition: none;
    }
    /* Le thème sombre de shared.css redonne à la barre son fond dépoli,
       par une règle plus lourde que celle d'au-dessus : sur l'accueil, où
       la barre court d'un bord à l'autre, cela posait une bande sombre en
       haut de l'écran. La reprise se fait au même poids. */
    :root[data-theme="dark"] body.ecran .navbar {
        background: none;
        border: 0;
    }
    body.ecran .nav-sep { display: none; }
    body.ecran .nav-logo { padding: 0 0.4rem 0 0 !important; }

    /* ----------------------------------------------------------------------
       Les outils
       ----------------------------------------------------------------------
       Le retour, le titre et l'aide tiennent sur une ligne ; les deux
       colonnes prennent ce qui reste de l'écran. Si l'une déborde, c'est
       elle qui défile, jamais la page. */

    body.ecran .main-wrapper {
        width: 100%;
        max-width: none;
        height: 100vh;
        height: 100dvh;
        padding: 1rem 2rem 1.5rem;
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        grid-template-rows: auto minmax(0, 1fr);
        column-gap: 0.9rem;
        row-gap: 1.25rem;
        align-items: center;
    }

    /* Le retour se réduit à sa flèche : elle ramène à l'accueil, où sont
       tous les outils. */
    body.ecran .back-link {
        grid-column: 1;
        margin: 0;
        width: 36px;
        height: 36px;
        justify-content: center;
        border: 1.5px solid var(--filet);
        border-radius: 50%;
        background: var(--bg);
        transition: border-color 0.2s ease, color 0.2s ease;
    }
    body.ecran .back-link:hover,
    body.ecran .back-link:focus-visible { border-color: var(--accent-ink); }
    body.ecran .back-link span {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
    }

    body.ecran .header-container {
        grid-column: 2;
        margin: 0;
        min-width: 0;
    }
    body.ecran .header-container h1 { font-size: 2rem; white-space: nowrap; }

    body.ecran .main-grid {
        grid-column: 1 / -1;
        height: 100%;
        min-height: 0;
        grid-template-columns: 450px minmax(0, 1fr);
        grid-template-rows: minmax(0, 1fr);
        gap: 2rem;
        align-items: stretch;
    }

    body.ecran .left-col,
    body.ecran .right-col {
        min-height: 0;
        overflow-y: auto;
        overscroll-behavior: contain;
        scrollbar-width: thin;
        scrollbar-color: var(--filet) transparent;
    }

    body.ecran .preview-panel { min-height: 0; }
    body.ecran .status-container { min-height: 0; }

    /* Un champ de saisie libre prend la hauteur qui reste dans sa colonne,
       au lieu d'une hauteur fixe qui poussait les commandes hors de l'écran. */
    body.ecran .left-col:has(> .control-row > textarea) {
        display: flex;
        flex-direction: column;
    }
    body.ecran .left-col:has(> .control-row > textarea) > * { flex-shrink: 0; }
    body.ecran .left-col > .control-row:has(> textarea) {
        flex: 1 1 0;
        min-height: 7.5rem;
    }
    body.ecran .left-col > .control-row > textarea {
        flex: 1;
        height: auto;
        min-height: 4rem;
    }

    /* La palette : les couleurs se partagent la hauteur du panneau. */
    body.ecran .pal-swatches { flex: 1; min-height: 0; }
    body.ecran .pal-swatch {
        flex: 1 1 0;
        height: auto;
        min-height: 2.75rem;
        max-height: 82px;
    }

    /* L'analyseur de contraste : le verdict est ce qu'on vient lire, il ne
       doit pas passer sous le bas de l'écran. Le bloc d'arrière-plan tient
       donc sur une ligne, la couleur à gauche et l'image à droite. */
    body.ecran .bg-group {
        flex-direction: row;
        align-items: center;
        flex-wrap: wrap;
        gap: 0.6rem;
        padding: 0.7rem;
    }
    body.ecran .bg-group > .color-input-row { flex: 1 1 11rem; }
    body.ecran .bg-group > .bg-group-divider { flex: 0 0 auto; gap: 0; }
    body.ecran .bg-group > .bg-group-divider::before,
    body.ecran .bg-group > .bg-group-divider::after { display: none; }
    body.ecran .bg-group > button.secondary {
        flex: 0 0 auto;
        width: auto;
        padding: 0 1em;
    }
    body.ecran .bg-group > .bg-image-note { flex: 1 1 100%; }
}

/* ==========================================================================
   Sur un écran bas
   ==========================================================================
   Un portable en 1366 × 768 laisse 650 px à la page. Les commandes se
   resserrent d'un cran pour que rien ne passe sous le bord. */

@media (min-width: 1100px) and (min-height: 600px) and (max-height: 800px) {

    body.ecran .main-wrapper { row-gap: 0.9rem; padding-bottom: 1.1rem; }
    body.ecran .control-row { gap: 0.5rem; margin-bottom: 1rem; }
    body.ecran .control-label { font-size: 0.98rem; }
    body.ecran .left-col .input-field:not(textarea),
    body.ecran .left-col button.secondary,
    body.ecran .left-col button.primary,
    body.ecran .left-col .segmented-control,
    body.ecran .color-input-row .input-field { height: 44px; }
    body.ecran .left-col .color-swatch,
    body.ecran .left-col .color-field-swatch { width: 44px; height: 44px; }
    body.ecran .actions-grid { gap: 0.6rem; }

    body.ecran .contrast-result { padding: 1rem 1.1rem; gap: 0.75rem; }
    body.ecran .ratio-value { font-size: 2.6rem; }
    body.ecran .size-row { padding: 0.6rem 0.8rem; gap: 6px; }
}
