/**
 * Fiches de révision — Popups SaaS modernes PWA
 * Large, scrollable, compatible light/dark
 */

/* ─────────────────────────────────────────
   MODAL FICHES — Overlay full-screen
   ───────────────────────────────────────── */
.fiches-modal {
    position: fixed;
    inset: 0;
    z-index: 10001;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.25s ease;
    font-family: var(--app-font, 'Inter', -apple-system, sans-serif);
}

.fiches-modal.is-open {
    display: flex;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.fiches-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

body.app-theme-light .fiches-modal__backdrop {
    background: rgba(0, 0, 0, 0.4);
}

/* ─────────────────────────────────────────
   CONTAINER — Large, wide, scrollable
   ───────────────────────────────────────── */
.fiches-modal__container {
    position: relative;
    width: 100%;
    max-width: min(900px, 95vw);
    max-height: min(88vh, 900px);
    display: flex;
    flex-direction: column;
    background: var(--app-surface, #161616);
    border: 1px solid var(--app-border, rgba(255,255,255,0.08));
    border-radius: 16px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    transform: scale(0.96);
    transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

body.app-theme-light .fiches-modal__container {
    background: #ffffff;
    border-color: #e2e8f0;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.15);
}

.fiches-modal.is-open .fiches-modal__container {
    transform: scale(1);
}

/* ─────────────────────────────────────────
   HEADER — Titre + fermer
   ───────────────────────────────────────── */
.fiches-modal__header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--app-border, rgba(255,255,255,0.08));
    background: var(--app-surface-elevated, #1c1c1c);
}

.fiches-modal__back {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.875rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--app-text-muted, #a1a1aa);
    background: var(--app-accent-soft, rgba(255,255,255,0.06));
    border: 1px solid var(--app-border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.fiches-modal__back:hover {
    color: var(--app-text);
    border-color: var(--app-border-strong);
}

body.app-theme-light .fiches-modal__back {
    color: #64748b;
    background: rgba(0, 0, 0, 0.06);
    border-color: #e2e8f0;
}

body.app-theme-light .fiches-modal__back:hover {
    color: #0f172a;
    background: #e2e8f0;
}

body.app-theme-light .fiches-modal__header {
    background: #f8fafc;
    border-color: #e2e8f0;
}

.fiches-modal__title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--app-text, #fafafa);
    margin: 0;
}

body.app-theme-light .fiches-modal__title {
    color: #0f172a;
}

.fiches-modal__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    background: var(--app-accent-soft, rgba(255,255,255,0.06));
    border: 1px solid var(--app-border);
    border-radius: 10px;
    color: var(--app-text-muted, #a1a1aa);
    cursor: pointer;
    font-size: 1.25rem;
    transition: all 0.2s ease;
}

body.app-theme-light .fiches-modal__close {
    background: rgba(0, 0, 0, 0.06);
    color: #64748b;
    border-color: #e2e8f0;
}

.fiches-modal__close:hover {
    color: var(--app-text);
    background: var(--app-border);
}

body.app-theme-light .fiches-modal__close:hover {
    color: #0f172a;
    background: #e2e8f0;
}

/* ─────────────────────────────────────────
   BODY — Scrollable content
   ───────────────────────────────────────── */
.fiches-modal__body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1.75rem 1.5rem;
    -webkit-overflow-scrolling: touch;
}

.fiches-modal__body::-webkit-scrollbar {
    width: 8px;
}

.fiches-modal__body::-webkit-scrollbar-track {
    background: transparent;
}

.fiches-modal__body::-webkit-scrollbar-thumb {
    background: var(--app-border-strong, rgba(255,255,255,0.12));
    border-radius: 4px;
}

body.app-theme-light .fiches-modal__body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
}

/* ─────────────────────────────────────────
   CONTENU FICHE — Typographie (lisibilité augmentée)
   ───────────────────────────────────────── */
.fiche-content {
    color: var(--app-text, #fafafa);
    line-height: 1.8;
    font-size: 1.0625rem;
}

body.app-theme-light .fiche-content {
    color: #0f172a;
}

.fiche-content .fiche-partie,
.fiche-content .fiche-chapitre {
    font-weight: 700;
    font-size: 1.125rem;
    margin: 1.5rem 0 0.75rem;
    color: var(--app-text);
}

body.app-theme-light .fiche-content .fiche-partie,
body.app-theme-light .fiche-content .fiche-chapitre {
    color: #0f172a;
}

.fiche-content .fiche-section {
    font-weight: 600;
    font-size: 1.0625rem;
    margin: 1rem 0 0.5rem;
    color: var(--app-text-muted, #a1a1aa);
}

body.app-theme-light .fiche-content .fiche-section {
    color: #475569;
}

.fiche-content .fiche-texte {
    font-size: 1.0625rem;
    margin: 0 0 1rem;
    color: var(--app-text-muted, #a1a1aa);
}

body.app-theme-light .fiche-content .fiche-texte {
    color: #475569;
}

/* Citations */
.fiche-citations {
    margin: 2rem 0;
}

.fiche-citations__title {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--app-text-muted);
    margin: 0 0 1rem;
}

.fiche-citation {
    margin-bottom: 1.5rem;
    padding: 1rem 1.25rem;
    background: var(--app-accent-soft, rgba(255,255,255,0.06));
    border-left: 4px solid var(--app-border-strong, rgba(255,255,255,0.12));
    border-radius: 0 8px 8px 0;
    font-style: italic;
}

body.app-theme-light .fiche-citation {
    background: #f1f5f9;
    border-left-color: #94a3b8;
}

.fiche-citation__texte {
    font-size: 1.0625rem;
    margin: 0 0 0.5rem;
}

.fiche-citation__source {
    font-size: 0.9375rem;
    color: var(--app-text-subtle, #71717a);
}

body.app-theme-light .fiche-citation__source {
    color: #64748b;
}

/* Points clés / À retenir */
.fiche-points-cles {
    margin: 1.5rem 0;
    padding: 1rem 1.25rem;
    background: rgba(34, 197, 94, 0.08);
    border: 1px solid rgba(34, 197, 94, 0.25);
    border-radius: 12px;
}

body.app-theme-light .fiche-points-cles {
    background: #f0fdf4;
    border-color: #bbf7d0;
}

.fiche-points-cles__title {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--app-text-muted);
    margin: 0 0 0.75rem;
}

.fiche-points-cles ul {
    margin: 0;
    padding-left: 1.25rem;
}

.fiche-points-cles li {
    font-size: 1.0625rem;
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

.fiche-points-cles li:last-child {
    margin-bottom: 0;
}

/* Documents du cours */
.fiche-documents {
    margin: 1.5rem 0;
}

.fiche-documents__title {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--app-text-muted);
    margin: 0 0 0.75rem;
}

.fiche-document {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    background: var(--app-accent-soft, rgba(255,255,255,0.06));
    border: 1px solid var(--app-border);
    border-radius: 10px;
    color: var(--app-text);
    text-decoration: none;
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

body.app-theme-light .fiche-document {
    background: #f8fafc;
    border-color: #e2e8f0;
    color: #1e40af;
}

.fiche-document:hover {
    background: var(--app-border);
}

body.app-theme-light .fiche-document:hover {
    background: #e2e8f0;
}

.fiche-document--placeholder {
    cursor: default;
    opacity: 0.8;
}

.fiche-document--placeholder:hover {
    background: inherit;
}

/* Pièges à éviter */
.fiche-pieges {
    margin: 2rem 0;
}

.fiche-pieges__title {
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--app-text-muted);
    margin: 0 0 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.fiche-piege {
    display: flex;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    margin-bottom: 0.5rem;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 10px;
    font-size: 0.875rem;
}

body.app-theme-light .fiche-piege {
    background: #fef2f2;
    border-color: #fecaca;
}

.fiche-piege::before {
    content: '⚠️';
    flex-shrink: 0;
}

/* Ressources */
.fiche-ressources {
    margin: 2rem 0 0;
}

.fiche-ressources__title {
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--app-text-muted);
    margin: 0 0 1rem;
}

.fiche-ressource {
    display: block;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    background: var(--app-accent-soft, rgba(255,255,255,0.06));
    border: 1px solid var(--app-border);
    border-radius: 10px;
    color: var(--app-text);
    text-decoration: none;
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

body.app-theme-light .fiche-ressource {
    background: #f8fafc;
    border-color: #e2e8f0;
    color: #1e40af;
}

.fiche-ressource:hover {
    background: var(--app-border);
    border-color: var(--app-border-strong);
}

body.app-theme-light .fiche-ressource:hover {
    background: #e2e8f0;
    border-color: #94a3b8;
}

/* ─────────────────────────────────────────
   RETOUR AU MENU — Barre de navigation
   ───────────────────────────────────────── */
.fiche-back-bar {
    flex-shrink: 0;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--app-border, rgba(255,255,255,0.08));
}

body.app-theme-light .fiche-back-bar {
    border-color: #e2e8f0;
}

.fiche-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--app-text-muted, #a1a1aa);
    background: transparent;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.fiche-back-btn:hover {
    color: var(--app-text);
    border-color: var(--app-border-strong);
    background: var(--app-accent-soft);
}

body.app-theme-light .fiche-back-btn {
    color: #64748b;
    border-color: #e2e8f0;
}

body.app-theme-light .fiche-back-btn:hover {
    color: #0f172a;
    background: #f1f5f9;
}

/* ─────────────────────────────────────────
   MENU NOTIONS — Liste des notions (scrollable)
   ───────────────────────────────────────── */
.fiches-menu {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.fiches-menu__item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: var(--app-surface-elevated, #1c1c1c);
    border: 1px solid var(--app-border, rgba(255,255,255,0.08));
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

body.app-theme-light .fiches-menu__item {
    background: #ffffff;
    border-color: #e2e8f0;
}

.fiches-menu__item:hover {
    border-color: var(--app-border-strong);
    background: var(--app-accent-soft);
}

body.app-theme-light .fiches-menu__item:hover {
    border-color: #94a3b8;
    background: #f8fafc;
}

.fiches-menu__item-icon {
    font-size: 1.25rem;
    opacity: 0.9;
}

.fiches-menu__item-title {
    flex: 1;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--app-text);
}

body.app-theme-light .fiches-menu__item-title {
    color: #0f172a;
}

.fiches-menu__item-arrow {
    font-size: 0.875rem;
    color: var(--app-text-muted);
}

body.app-theme-light .fiches-menu__item-arrow {
    color: #64748b;
}

/* ─────────────────────────────────────────
   CARTE FICHE — Clic pour ouvrir menu
   ───────────────────────────────────────── */
.fiche-card {
    cursor: pointer;
}

.fiche-card:focus-visible {
    outline: 2px solid var(--app-border-strong);
    outline-offset: 2px;
}
