/* Page fiche individuelle — styles dédiés (séparés de page.css du portail home). */

/* Aucun lien des pages fiche/bibliothèque ne doit se souligner (boutons stylés). */
.fp-page a,
.fp-page a:hover,
.bp-page a,
.bp-page a:hover {
    text-decoration: none;
}

/* Toolbar fiche : retour + bouton imprimer */
.fp-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.fp-print-btn {
    padding: 6px 14px;
    background: white;
    color: #444;
    border: 1px solid #ccc;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
}

.fp-print-btn:hover {
    background: var(--theme-teal-50, #E6F4F4);
    border-color: var(--theme-teal, #1F9999);
    color: var(--theme-teal-dark, #167878);
}
.fp-print-btn:disabled { opacity: 0.6; cursor: progress; }

/* Liens habillés en boutons — même gabarit que fp-print-btn, pour <a> et <button> */
.fp-btn-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: white;
    color: #444;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
}

.fp-btn-link:hover {
    background: var(--theme-teal-50, #E6F4F4);
    border-color: var(--theme-teal, #1F9999);
    color: var(--theme-teal-dark, #167878);
    text-decoration: none;
}

.fp-btn-link svg { flex: 0 0 14px; }

/* Bandeau « fiche non publiée » (brouillon / à relire / archivée) — admin seul.
   Volontairement conservé à l'impression : évite de confondre un PDF de
   relecture avec la version publiée. */
.fp-statut-banner {
    margin: 0 0 1rem;
    padding: 8px 14px;
    border: 1px solid #f0c36d;
    border-left-width: 4px;
    border-radius: 6px;
    background: #fdf6e3;
    color: #7a5c00;
    font-size: 13px;
    font-weight: 600;
}

.fp-statut-banner--archive {
    border-color: #ccc;
    background: #f5f5f5;
    color: #555;
}

.fp-toolbar__actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ============================================================== */
/* ===== Impression (@media print) ============================== */
/* ============================================================== */

@media print {
    /* Cache les éléments interactifs */
    .no-print,
    .fp-toolbar,
    .fp-print-btn,
    .fp-back,
    .fp-card__actions,
    .fp-aides,
    .fp-footer {
        display: none !important;
    }

    /* Reset des marges/fonds pour impression */
    body {
        background: white !important;
        color: black !important;
        font-size: 11pt;
    }

    .fp-page {
        max-width: none;
        margin: 0;
        padding: 0;
    }

    /* Éviter la coupure malheureuse des sections */
    .fp-app-section,
    .fp-subsection,
    .fp-objectif-group,
    .fp-block {
        page-break-inside: avoid;
        break-inside: avoid;
    }

    /* Header de fiche : compact pour économiser l'espace */
    .fp-header {
        display: block;
        border-bottom: 1px solid #000;
        padding-bottom: 0.5rem;
        margin-bottom: 1rem;
    }
    .fp-header__cover {
        float: right;
        width: 100px;
        margin-left: 1rem;
        margin-bottom: 0.5rem;
    }

    /* Les sections d'app : pas de fond coloré, juste un trait à gauche */
    .fp-app-section {
        background: transparent !important;
        border-left: 2px solid #333 !important;
        padding: 0.5rem 0.75rem;
        margin: 1rem 0;
    }

    /* Cards : compactes, sans liens visibles, juste titre + compétence */
    .fp-cards {
        display: block;
    }
    .fp-card {
        display: block;
        border: none;
        padding: 0.2rem 0;
        break-inside: avoid;
    }
    .fp-card__title {
        font-weight: bold;
        margin: 0.1rem 0;
    }
    .fp-card__competence {
        font-size: 10pt;
        color: #333;
        margin-bottom: 0.3rem;
    }

    /* Lexique sur 2 colonnes pour l'impression */
    .fp-lexique {
        columns: 3;
        font-size: 10pt;
    }
}

.fp-page {
    max-width: 980px;
    margin: 0 auto;
    padding: 1.5rem;
    font-family: system-ui, -apple-system, sans-serif;
    color: #222;
}

.fp-back {
    font-size: 13px;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* ===== Header de la fiche ===== */

.fp-header {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid #eee;
}

.fp-header__cover {
    width: 200px;
    aspect-ratio: 3 / 4;
    background: #f4f4f4;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.fp-header__cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.fp-header__cover--empty {
    color: #bbb;
    font-size: 12px;
}

.fp-header__title {
    margin: 0;
    font-size: 28px;
    font-weight: 700;
    line-height: 1.2;
}

.fp-header__partie {
    margin: 0.25rem 0;
    color: #888;
    font-size: 16px;
}

.fp-header__auteur {
    margin: 0.5rem 0;
    color: #444;
    font-style: italic;
    font-size: 14px;
}

/* Mention de droits affichee sous le titre (facultative) : volontairement
   discrete, elle informe sans concurrencer le titre ni les metadonnees. */
.fp-header__mention {
    margin: 0.35rem 0 0;
    color: #777;
    font-size: 12.5px;
    font-style: normal;
    line-height: 1.45;
}

.fp-header__tableau {
    margin: 0.6rem 0;
}

.fp-header__meta {
    margin: 0.75rem 0 0;
    color: #555;
    font-size: 14px;
}

.fp-header__meta span {
    display: inline-block;
    margin-right: 0.75rem;
}

/* ===== Sections de contenu textuel (scénario, synopsis, lexique) ===== */

.fp-block {
    margin: 1.5rem 0;
}

.fp-block__title {
    font-size: 16px;
    font-weight: 600;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

.fp-block__body {
    font-size: 15px;
    line-height: 1.5;
}

.fp-lexique {
    list-style: disc inside;
    columns: 2;
    column-gap: 2rem;
    padding-left: 0;
}

.fp-lexique li {
    margin: 0.15rem 0;
    font-size: 14px;
    color: #333;
    break-inside: avoid;
}

.fp-ressources {
    list-style: disc inside;
    padding-left: 0;
}

.fp-ressources li {
    margin: 0.25rem 0;
    font-size: 14px;
    color: #333;
}

.fp-ressources a {
    color: var(--primary, #4a90e2);
    text-decoration: underline;
    word-break: break-word;
}

/* ===== Sections par app (Lexique, Syntaxe, etc.) ===== */

.fp-app-section {
    margin: 2.5rem 0;
    padding: 1.25rem;
    border-radius: 8px;
    border-left: 4px solid var(--app-color, #888);
    background: var(--app-soft, #fafafa);
}

.fp-app-section__title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 1rem;
    font-size: 20px;
    font-weight: 700;
    color: var(--app-ink, #222);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ===== Sous-section (transfo/ateliers pour syntaxe, imagiers/flashcards/activités pour vocab) ===== */

.fp-subsection {
    margin: 1.25rem 0;
}

.fp-subsection__title {
    margin: 0 0 0.5rem;
    font-size: 15px;
    font-weight: 600;
    color: #444;
}

/* ===== Groupe par objectif ===== */

.fp-objectif-group {
    margin: 0.75rem 0 1rem;
}

.fp-objectif-header {
    margin: 0 0 0.5rem;
    font-size: 13px;
    font-style: italic;
    color: #666;
    padding-left: 0.5rem;
    border-left: 3px solid #ddd;
}

.fp-objectif-header em {
    font-weight: 600;
    font-style: normal;
    color: #333;
}

/* ===== Card d'activité ===== */

.fp-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.6rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.fp-card {
    display: flex;
    /* wrap : permet à la ligne "Aides pour l'élève" (flex-basis 100%)
       de passer sous le couple body/actions sans changer leur rendu */
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.8rem;
    background: white;
    border: 1px solid #e4e4e4;
    border-radius: 6px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.fp-card:hover {
    border-color: var(--app-color, #999);
    box-shadow: 0 2px 4px rgba(0,0,0,0.04);
}

.fp-card__body {
    flex: 1;
    min-width: 0;
}

.fp-card__title {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #222;
    line-height: 1.3;
}

.fp-card__competence {
    margin: 0.2rem 0 0;
    font-size: 12px;
    color: #777;
    font-style: italic;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.fp-card__actions {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    flex-shrink: 0;
    align-items: stretch;
}

.fp-card__link {
    padding: 0.3rem 0.6rem;
    background: var(--app-color, #555);
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.fp-card__link:hover {
    opacity: 0.9;
}

/* Variante "alt" pour les boutons secondaires (PDF, Word) :
   fond clair, texte coloré, pour les distinguer du bouton principal "Voir". */
.fp-card__link--alt {
    background: white;
    color: var(--app-ink, #333);
    border: 1px solid var(--app-color, #999);
}

.fp-card__link--alt:hover {
    background: var(--app-soft, #f4f4f4);
}

/* ===== Aides pour l'élève (supports complémentaires compr./prod.) ===== */

.fp-aides {
    flex-basis: 100%;
    margin-top: 0.1rem;
    padding-top: 0.4rem;
    border-top: 1px dashed #e8e8e8;
}

.fp-aides__toggle {
    display: block;
    width: 100%;
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    font-size: 12px;
    line-height: 1.5;
    color: #777;
}

.fp-aides__toggle:hover {
    color: var(--app-ink, #333);
}

.fp-aides__label {
    font-weight: 600;
    color: var(--app-ink, #444);
}

.fp-aides__badge {
    white-space: nowrap;
}

.fp-aides__list {
    list-style: none;
    margin: 0.35rem 0 0;
    padding: 0 0 0 1rem;
}

.fp-aides__list li {
    font-size: 12px;
    color: #555;
    margin: 0.2rem 0;
    line-height: 1.4;
}

.fp-aides__list a {
    color: var(--app-ink, #2563eb);
    text-decoration: underline;
}

/* Etat "Copié" : feedback visuel temporaire du bouton "Copier le lien". */
.fp-card__link--copied {
    background: #16a34a;
    color: white;
    border-color: #16a34a;
}
.fp-card__link--copied:hover {
    background: #15803d;
    border-color: #15803d;
    color: white;
}

/* ===== États ===== */

.fp-loading, .fp-error {
    padding: 3rem 1rem;
    text-align: center;
    color: #666;
}

.fp-error h1 {
    color: #b00;
}

.fp-principes-cta {
    display: flex;
    justify-content: center;
    margin-top: 3rem;
    padding: 1.5rem 0;
}
.fp-principes-cta__btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 22px;
    background: var(--theme-teal-50);
    color: var(--theme-teal-dark);
    border: 1px solid var(--border-brand);
    border-radius: 10px;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 14.5px;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.fp-principes-cta__btn:hover {
    background: var(--theme-teal);
    border-color: var(--theme-teal);
    color: #fff;
}
.fp-principes-cta__btn svg { flex: 0 0 18px; }

/* Bloc « Droits d'auteur & autorisations » : allure mentions legales
   (petit, attenue), retours a la ligne de la saisie respectes via pre-line.
   Distinct de .fp-footer, qui lui est masque a l'impression. */
.fp-droits {
    margin-top: 2rem;
    padding-top: 0.9rem;
    border-top: 1px solid #e5e5e5;
}

.fp-droits__title {
    margin: 0 0 0.4rem;
    font-size: 12.5px;
    font-weight: 600;
    color: #777;
}

.fp-droits__body {
    margin: 0;
    font-size: 12px;
    line-height: 1.55;
    color: #888;
    white-space: pre-line;
}

/* A l'impression, les mentions restent lisibles et ne se coupent pas en deux. */
@media print {
    .fp-droits {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .fp-droits__title,
    .fp-droits__body {
        color: #333 !important;
    }
}

.fp-footer {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #ddd;
    font-size: 12px;
    color: #888;
}

/* ============================================================== */
/* ===== Page bibliothèque (bibliotheque.html) ================== */
/* ============================================================== */

.bp-page {
    max-width: 1180px;
    margin: 0 auto;
    padding: 1.5rem;
    font-family: system-ui, -apple-system, sans-serif;
    color: #222;
}

.bp-header h1 {
    margin: 0 0 0.25rem;
    font-size: 30px;
}

.bp-count {
    margin: 0 0 1.5rem;
    color: #666;
    font-size: 14px;
}

/* Toolbar : recherche + filtres */

.bp-toolbar {
    background: #fafafa;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.bp-search {
    width: 100%;
    padding: 0.6rem 0.8rem;
    font-size: 15px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
    margin-bottom: 1rem;
}

.bp-search:focus {
    outline: none;
    border-color: #888;
}

.bp-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    align-items: flex-end;
}

.bp-filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.bp-filter-label {
    font-size: 12px;
    font-weight: 600;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.bp-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.bp-chip {
    padding: 0.3rem 0.6rem;
    font-size: 13px;
    background: white;
    border: 1px solid #ccc;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.15s;
}

.bp-chip:hover {
    border-color: #888;
}

.bp-chip--active {
    background: #333;
    color: white;
    border-color: #333;
}

.bp-select {
    padding: 0.4rem 0.6rem;
    font-size: 14px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: white;
    min-width: 140px;
}

.bp-reset {
    padding: 0.4rem 0.8rem;
    font-size: 13px;
    background: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    color: #555;
}

.bp-reset:hover {
    border-color: #888;
    color: #222;
}

/* Sections par œuvre */

.bp-oeuvre {
    margin-bottom: 2.5rem;
}

.bp-oeuvre__header {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 0.9rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid #e4e4e4;
}

.bp-oeuvre__titre {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    color: #222;
}

.bp-oeuvre__auteur {
    margin: 0;
    font-size: 14px;
    font-style: italic;
    color: #666;
}

/* Grille de tuiles */

.bp-grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.25rem;
}

.bp-tile {
    background: white;
    border: 1px solid #e4e4e4;
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow 0.15s, transform 0.15s;
}

.bp-tile:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    transform: translateY(-2px);
}

.bp-tile__link {
    display: block;
    text-decoration: none;
    color: inherit;
}

.bp-tile__cover {
    aspect-ratio: 3 / 4;
    background: #f4f4f4;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.bp-tile__cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.bp-tile__cover--empty {
    color: #bbb;
    font-size: 12px;
}

.bp-tile__body {
    padding: 0.9rem 1rem 1rem;
}

.bp-tile__title {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    line-height: 1.25;
    color: #222;
}

.bp-tile__partie {
    margin: 0.15rem 0;
    font-size: 13px;
    color: #888;
}

.bp-tile__auteur {
    margin: 0.3rem 0 0.5rem;
    font-size: 13px;
    font-style: italic;
    color: #555;
}

.bp-tile__niveaux {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem;
    margin-bottom: 0.5rem;
}

.bp-tile__niveau {
    padding: 0.1rem 0.4rem;
    font-size: 11px;
    background: #eef;
    color: #335;
    border-radius: 3px;
    font-weight: 600;
}

.bp-tile__excerpt {
    margin: 0.4rem 0 0;
    font-size: 13px;
    line-height: 1.4;
    color: #444;
}

/* ===== Responsive ===== */

@media (max-width: 720px) {
    .fp-header {
        grid-template-columns: 1fr;
    }
    .fp-header__cover {
        width: 100%;
        max-width: 200px;
        margin: 0 auto;
    }
    .fp-lexique {
        columns: 1;
    }
    .fp-cards {
        grid-template-columns: 1fr;
    }
}
