/* ==========================================================================
   Gabarit Atelier — chrome du shell (pilote smart_reframe + lot G1 d'outils
   simples). Chargé seulement sur les pages des outils du gabarit (link injecté
   par main.py d'après _ATELIER_TOOL_TYPES).
   Tout passe par les jetons existants (--primary, --text-*, --border, --shadow-*) :
   aucune couleur en dur, aucun composant nouveau non validé.
   ========================================================================== */

.klat-shell[x-cloak] { display: none; }

/* --- Barre d'atelier : état seulement, jamais d'action de téléchargement dupliquée.
   Sticky sous l'en-tête réel (66px). --- */
.klat-bar {
    position: sticky;
    top: 66px;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 56px;
    padding: 8px 16px;
    margin: 0 0 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.klat-bar-ic {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(37, 99, 235, .1);
    color: var(--primary);
    flex-shrink: 0;
}
.klat-bar-ic svg { width: 18px; height: 18px; }
.klat-bar-meta { flex: 1; min-width: 0; }
.klat-bar-tool {
    margin: 0;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-3);
    line-height: 1.1;
}
.klat-bar-file {
    margin: 2px 0 0;
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.klat-state {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 30px;
    padding: 0 12px;
    border-radius: 99px;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-muted);
}
.klat-state.is-live { background: rgba(37, 99, 235, .1); border-color: transparent; color: var(--primary); }
.klat-state.is-done { background: rgba(22, 163, 74, .1); border-color: transparent; color: var(--success); }
.klat-state-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex-shrink: 0; }

/* --- Fil d'étapes : numéro/✓ + libellé (second signal, jamais la couleur seule) --- */
.klat-steps {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin: 0 0 22px;
}
.klat-step {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 34px;
    padding: 0 13px 0 9px;
    border-radius: 99px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-3);
    background: transparent;
}
.klat-step.is-done { color: var(--text-muted); }
.klat-step.is-active { color: var(--primary); background: rgba(37, 99, 235, .1); }
.klat-step-n {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 800;
    background: var(--surface-2);
    color: var(--text-3);
    border: 1px solid var(--border);
}
.klat-step-n svg { width: 12px; height: 12px; }
.klat-step.is-active .klat-step-n { background: var(--primary); color: #fff; border-color: transparent; }
.klat-step.is-done .klat-step-n { background: rgba(37, 99, 235, .15); color: var(--primary); border-color: transparent; }
.klat-step-bar { width: 16px; height: 2px; border-radius: 2px; background: var(--border); flex-shrink: 0; }

/* ==========================================================================
   Mode PLEIN ÉCRAN atelier — activé par body.atelier-active (posé par Alpine
   x-effect, uniquement pour smart_reframe hors étape « upload »). Sans JS le
   corps garde tout son contenu SEO (rendu serveur intact, indexable).
   ========================================================================== */
body.atelier-active main > *:not(.tool-hero) { display: none; }   /* fil d'Ariane + tout le bloc SEO */
body.atelier-active .klx-footer { display: none; }
body.atelier-active .feature-hero.tool-hero { padding-top: 18px; }
/* En atelier, la barre remplace le titre/sous-titre héros (encore montrés à
   l'étape « options » par leur x-show) : on les masque au profit de la barre. */
body.atelier-active .feature-hero.tool-hero .feature-hero-title,
body.atelier-active .feature-hero.tool-hero .feature-hero-subtitle,
body.atelier-active .feature-hero.tool-hero .tool-compat-notice { display: none; }

/* Au MOMENT résultat (smart_reframe), le bandeau d'essai du haut doublonne l'offre
   « sans logo — Pass vidéo » du corps → masqué à ce seul moment (scopé au pilote via
   la classe posée par x-effect ; le fragment partagé shell-haut reste intact). */
body.atelier-result .premium-trial-banner { display: none; }

/* Moment 1 : lien texte Pro discret sous le bouton Pass (jamais un 2e bouton). */
.rfr-offer-prolink {
    display: inline-block;
    margin-top: 10px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    text-decoration: underline;
    text-underline-offset: 3px;
}

@media (max-width: 640px) {
    /* La barre reste DANS le conteneur (pas de débord à marges négatives fixes :
       le padding mobile du conteneur n'est pas 24px → un -24px provoquait un
       scroll horizontal du body de 8px). Carte arrondie, jamais de débord. */
    .klat-bar { top: 0; }
    .klat-steps { margin-bottom: 16px; }
    /* Le shell prenait sa largeur MAX-CONTENU (fil d'étapes non replié) dans un
       conteneur flex align-items:center → centré et débordant de ~27px. On le
       borne au conteneur : le fil d'étapes se replie, le nom de fichier s'élide. */
    .klat-shell { max-width: 100%; }
}

/* ==========================================================================
   PLEINE LARGEUR en mode atelier (ordinateur ≥ 900px). En vitrine la largeur
   éditoriale (--max-w, SEO) est conservée ; sur mobile tout reste empilé.
   Cause d'origine du confinement : .tool-hero .container est en flex-column
   align-items:center (largeur ajustée au contenu) → les grilles ne s'étirent
   jamais. On l'étire et on élargit le conteneur, uniquement en atelier.
   ========================================================================== */
@media (min-width: 900px) {
    body.atelier-active .feature-hero.tool-hero .container {
        max-width: 1500px;
        align-items: stretch;
    }
    /* Réglages : aperçu large à gauche | panneau réglages 380px collant à droite */
    body.atelier-active .rf-grid { grid-template-columns: minmax(0, 1fr) 380px; }
    body.atelier-active .rf-player { max-width: 100%; }
    body.atelier-active .rf-formats-col { position: sticky; top: 134px; align-self: start; }
    /* Résultat : scène 9:16 | colonne action-offre-parcours, sur toute la largeur */
    body.atelier-active .rfr-grid { grid-template-columns: minmax(0, 360px) 1fr; }
    /* Moment 2 : suggestions en 3 colonnes, carte déplafonnée */
    body.atelier-active .klsa-card,
    body.atelier-active .klsa-card.klsa-wide { max-width: none; }
    body.atelier-active .klsa-tools { grid-template-columns: repeat(3, minmax(0, 1fr)); }

    /* ── Lot G1 — RÉGLAGES pleine largeur, deux colonnes (aperçu large | ~380px) ──
       Directive patron : en atelier, TOUT prend la pleine largeur ; l'écran de
       réglages suit le gabarit du pilote/resize (.rf-grid 898|380). Aucune carte
       660px centrée.

       resize : déjà `is-wide` + .rf-grid (règle ci-dessus). Rien à faire.

       Outils à APERÇU PARTAGÉ (compress, cut, extract_audio, adjust_speed,
       video_to_gif, remove_noise) : le panneau `.atelier-split` a des enfants
       PLATS (badge, titre, aperçu partagé, options, bouton). On le passe en
       grille : l'en-tête coiffe les deux colonnes, l'aperçu tient la colonne
       gauche (collant), les réglages s'empilent dans la colonne droite ~380px. */
    body.atelier-active .tool-options-panel.atelier-split {
        max-width: 100%;
        display: grid;
        grid-template-columns: minmax(0, 1fr) 380px;
        column-gap: 32px;
        align-items: start;
        padding: 22px 30px 28px;
    }
    body.atelier-active .tool-options-panel.atelier-split > .options-file-badge { grid-column: 1 / -1; margin: 0 0 4px; }
    body.atelier-active .tool-options-panel.atelier-split > .tool-preview {
        grid-column: 1; grid-row: 2 / span 50;
        align-self: start; position: sticky; top: 134px; margin: 0;
    }
    body.atelier-active .tool-options-panel.atelier-split > .options-section-title,
    body.atelier-active .tool-options-panel.atelier-split > .options-section-sub,
    body.atelier-active .tool-options-panel.atelier-split > .options-choices,
    body.atelier-active .tool-options-panel.atelier-split > .options-start-btn,
    body.atelier-active .tool-options-panel.atelier-split > .options-hint { grid-column: 2; }
    body.atelier-active .tool-options-panel.atelier-split > .options-choices { padding-left: 0; padding-right: 0; }

    /* rotate : APERÇU PROPRE (la vidéo pivotée .wysiwyg-stage vit DANS ses
       options). On grille le bloc d'options lui-même : aperçu à gauche (collant),
       commandes de rotation à droite ~380px. */
    body.atelier-active .feature-hero.tool-hero[data-tool-type="rotate"] .tool-options-panel { max-width: 100%; }
    body.atelier-active .feature-hero.tool-hero[data-tool-type="rotate"] .options-choices {
        display: grid; grid-template-columns: minmax(0, 1fr) 380px;
        column-gap: 32px; align-items: start; text-align: left;
    }
    body.atelier-active .feature-hero.tool-hero[data-tool-type="rotate"] .options-choices > .options-hint { grid-column: 1 / -1; }
    body.atelier-active .feature-hero.tool-hero[data-tool-type="rotate"] .options-choices > .wysiwyg-stage {
        grid-column: 1; grid-row: 2 / span 20; align-self: start; position: sticky; top: 134px; margin: 0;
    }
    body.atelier-active .feature-hero.tool-hero[data-tool-type="rotate"] .options-choices > .rotate-dirs,
    body.atelier-active .feature-hero.tool-hero[data-tool-type="rotate"] .options-choices > .rotate-result { grid-column: 2; margin: 0; }

    /* Watermark / Logo : éditeur Fabric à son PROPRE deux-colonnes natif (.wm-grid
       = canevas | 372px). Panneau libéré en pleine largeur ; canevas JAMAIS comprimé. */
    body.atelier-active .feature-hero.tool-hero[data-tool-type="add_watermark"] .tool-options-panel,
    body.atelier-active .feature-hero.tool-hero[data-tool-type="logo_overlay"] .tool-options-panel { max-width: 100%; }

    /* Compression : écran résultat dédié (.cr-screen = bilan | aperçu, déjà en
       deux colonnes) — un peu plus large en atelier pour occuper la scène. */
    body.atelier-active .cr-screen { max-width: 1280px; }
}
