/* ===== CSS global du site FCM ===== */

:root {
    --primary-blue: #2e4eef;
    --primary-blue-rgb: 46, 78, 239;
    --primary-blue-dark: #243fd1;

    /* ---------- Foundation tokens ---------- */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;
    --space-7: 3rem;

    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-md: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;

    --container-sm: 640px;
    --container-md: 960px;
    --container-lg: 1180px;

    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;

    --shadow-sm: 0 4px 14px rgba(15, 23, 42, 0.08);
    --shadow-md: 0 10px 30px rgba(15, 23, 42, 0.12);
    --shadow-lg: 0 24px 60px rgba(15, 23, 42, 0.2);

    --transition-fast: 150ms ease;
    --transition-base: 220ms ease;
    --transition-slow: 320ms ease;
}

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

/* ---------- Liens : pas de violet visité, pas de soulignement par défaut ---------- */

a {
    text-decoration: none;
    transition: color 0.2s ease;
}

a:visited {
    color: inherit;
}

a:hover {
    text-decoration: none;
}

a:focus {
    outline: none;
}

a:active {
    color: inherit;
}

.link-unstyled {
    color: inherit;
    text-decoration: none;
}

.link-unstyled:visited {
    color: inherit;
}

.link-unstyled:hover {
    color: inherit;
    text-decoration: none;
}

.link-unstyled:focus {
    outline: none;
    text-decoration: none;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #0f172a;
    background: #f8f9fc;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

img,
svg,
video,
canvas {
    max-width: 100%;
    height: auto;
}

/* ---------- Layout primitives ---------- */

.container-base {
    width: min(100% - 2 * var(--space-4), var(--container-md));
    margin-inline: auto;
}

.stack-sm > * + * { margin-top: var(--space-2); }
.stack-md > * + * { margin-top: var(--space-4); }
.stack-lg > * + * { margin-top: var(--space-6); }

/* ---------- Header ---------- */

/* Logo sur fond blanc : éviter tout fond gris (body #f8f9fc ou override d’autres CSS) */
.site-header {
    width: 100%;
    background: #ffffff !important;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 960px;
    margin: 0 auto;
    padding: 0.6rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    background: #ffffff !important;
}

.header-center {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-admin-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
}

.header-admin-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.48rem;
    padding: 0.44rem 0.9rem 0.44rem 0.68rem;
    border-radius: 999px;
    text-decoration: none;
    color: #0f172a;
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.025em;
    border: 1px solid #e5e7eb;
    background: #ffffff;
    transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
    white-space: nowrap;
}

.header-admin-pill:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.06);
    color: #0f172a;
}

.header-admin-pill:visited {
    color: #0f172a;
}

.header-admin-pill.is-active {
    background: #0f172a;
    border-color: #0f172a;
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.14);
}

.header-admin-pill.is-active:visited {
    color: #ffffff;
}

.header-admin-pill-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    color: inherit;
}

.header-admin-pill-icon svg {
    width: 1.05rem;
    height: 1.05rem;
    display: block;
}

.header-admin-pill-label {
    line-height: 1;
}

@media (max-width: 640px) {
    .header-admin-pill {
        padding: 0.4rem 0.65rem 0.4rem 0.55rem;
        font-size: 0.76rem;
        gap: 0.38rem;
    }

    .header-admin-pill-icon svg {
        width: 0.95rem;
        height: 0.95rem;
    }
}

@media (max-width: 480px) {
    .header-admin-pill-label {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }

    .header-admin-pill {
        padding: 0.48rem;
        border-radius: 10px;
    }
}

.header-logo {
    cursor: default;
    pointer-events: none;
    background: #ffffff !important;
}

.header-logo img {
    height: 42px;
    width: auto;
    background: transparent !important;
    display: block;
}

.header-nav {
    display: flex;
    gap: 1.2rem;
}

.header-nav a,
.link-primary {
    color: var(--primary-blue);
}

.header-nav a:hover,
.link-primary:hover {
    color: var(--primary-blue-dark);
}

.header-nav a {
    font-size: 0.92rem;
    font-weight: 500;
    transition: color 0.15s;
}

.header-nav a:visited {
    color: #374151;
}

.header-auth {
    display: flex;
    align-items: center;
}

.header-admin-tools {
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
    margin-right: 0.15rem;
}

.header-shield-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.3rem;
    font-size: 1.1rem;
    line-height: 1;
    opacity: 0.5;
}

.header-shield-btn.is-verified {
    opacity: 1;
}

.header-notif-wrap {
    position: relative;
}

.header-notif-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #334155;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.header-notif-btn:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.header-notif-btn svg {
    width: 1.15rem;
    height: 1.15rem;
    display: block;
}

.header-notif-badge {
    position: absolute;
    top: 0.05rem;
    right: 0.05rem;
    min-width: 1rem;
    height: 1rem;
    padding: 0 0.25rem;
    border-radius: 999px;
    background: #dc2626;
    color: #fff;
    font-size: 0.62rem;
    font-weight: 700;
    line-height: 1rem;
    text-align: center;
    box-shadow: 0 0 0 2px #fff;
}

.header-notif-badge.is-hidden {
    display: none;
}

.header-notif-panel {
    position: absolute;
    top: calc(100% + 0.45rem);
    right: 0;
    width: min(22rem, calc(100vw - 2rem));
    max-height: min(24rem, 70vh);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
    z-index: 200;
}

.header-notif-panel[hidden] {
    display: none !important;
}

.header-notif-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid #f1f5f9;
}

.header-notif-title {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #64748b;
}

.header-notif-mark-all {
    appearance: none;
    border: none;
    background: none;
    padding: 0;
    font: inherit;
    font-size: 0.72rem;
    font-weight: 600;
    color: #2563eb;
    cursor: pointer;
}

.header-notif-mark-all:hover {
    text-decoration: underline;
}

.header-notif-list {
    overflow-y: auto;
    padding: 0.35rem 0;
}

.header-notif-empty {
    margin: 0;
    padding: 1rem 0.85rem;
    font-size: 0.8rem;
    color: #94a3b8;
    text-align: center;
}

.header-notif-item {
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid #f8fafc;
    cursor: default;
}

.header-notif-item.is-unread {
    background: #f8fbff;
    cursor: pointer;
}

.header-notif-item.is-unread:hover {
    background: #eff6ff;
}

.header-notif-item-top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.2rem;
}

.header-notif-item-topic {
    font-size: 0.72rem;
    font-weight: 700;
    color: #0f172a;
}

.header-notif-item-time {
    font-size: 0.68rem;
    color: #94a3b8;
    white-space: nowrap;
}

.header-notif-item-from {
    margin: 0 0 0.25rem;
    font-size: 0.72rem;
    color: #64748b;
}

.header-notif-item-text {
    margin: 0;
    font-size: 0.78rem;
    color: #334155;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}

.header-auth-link {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary-blue);
}

.header-auth-link:hover {
    color: var(--primary-blue-dark);
}

.profile-dropdown {
    position: relative;
    cursor: pointer;
    font-size: 0.9rem;
}

.profile-label {
    font-weight: 600;
    color: #111827;
}

.profile-menu {
    position: absolute;
    top: 120%;
    right: 0;
    background: #ffffff;
    border-radius: 0.75rem;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
    padding: 0.35rem 0;
    display: none;
    min-width: 210px;
    z-index: 150;
    overflow: visible;
}

.profile-menu a,
.profile-menu button {
    display: block;
    width: 100%;
    padding: 0.5rem 1rem;
    text-align: left;
    background: none;
    border: none;
    font-size: 0.86rem;
    cursor: pointer;
    color: #111827;
    font-weight: 500;
}

.profile-menu a:hover,
.profile-menu button:hover {
    background: #f3f4f6;
}

.profile-dropdown.open .profile-menu {
    display: block;
}

/* Admin : ouverture au survol (desktop) — clic conservé sur mobile */
@media (hover: hover) and (pointer: fine) {
    .profile-dropdown--hover-open::after {
        content: "";
        position: absolute;
        left: 0;
        right: 0;
        top: 100%;
        height: 0.75rem;
    }

    .profile-dropdown--hover-open:hover .profile-menu {
        display: block;
    }
}

.profile-menu-item {
    position: relative;
    width: 100%;
}

.profile-menu .profile-menu-item--flyout > .profile-menu-parent {
    display: flex;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
    text-decoration: none;
}

.profile-menu-label {
    flex: 1 1 auto;
    min-width: 0;
}

.profile-menu-chevron {
    flex: 0 0 auto;
    margin-left: auto;
    padding-left: 1.25rem;
    font-size: 0.95rem;
    line-height: 1;
    color: #9ca3af;
    transition: transform 0.15s ease, color 0.15s ease;
}

/* Pont invisible : garde le hover entre la ligne et le sous-menu à droite */
.profile-menu-item--flyout::before {
    content: "";
    position: absolute;
    top: 0;
    left: 100%;
    width: 0.65rem;
    height: 100%;
}

.profile-menu-flyout {
    position: absolute;
    top: 0;
    left: 100%;
    min-width: 9.75rem;
    background: #ffffff;
    border-radius: 0.75rem;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
    padding: 0.35rem 0;
    display: none;
    z-index: 160;
    pointer-events: none;
    opacity: 0;
    transform: translateX(-4px);
    transition: opacity 0.12s ease, transform 0.12s ease;
}

.profile-menu-flyout a {
    display: block;
    width: 100%;
    padding: 0.5rem 1rem;
    text-align: left;
    font-size: 0.86rem;
    font-weight: 500;
    color: #111827;
    text-decoration: none;
    pointer-events: auto;
}

.profile-menu-flyout a:hover {
    background: #f3f4f6;
}

.profile-menu-item--flyout:hover > .profile-menu-flyout,
.profile-menu-item--flyout:focus-within > .profile-menu-flyout {
    display: block;
    pointer-events: auto;
    opacity: 1;
    transform: translateX(0);
}

.profile-menu-item--flyout:hover > .profile-menu-parent,
.profile-menu-item--flyout:focus-within > .profile-menu-parent {
    background: #f3f4f6;
}

.profile-menu-item--flyout:hover > .profile-menu-parent .profile-menu-chevron,
.profile-menu-item--flyout:focus-within > .profile-menu-parent .profile-menu-chevron {
    color: #2563eb;
    transform: translateX(-2px);
}

@media (max-width: 640px) {
    .profile-menu-item--flyout::before {
        display: none;
    }

    .profile-menu-flyout {
        position: static;
        right: auto;
        margin: 0 0.5rem 0.35rem;
        box-shadow: none;
        border: 1px solid #e5e7eb;
        border-radius: 0.5rem;
        opacity: 1;
        transform: none;
        pointer-events: auto;
    }

    .profile-menu-item--flyout:hover > .profile-menu-flyout,
    .profile-menu-item--flyout:focus-within > .profile-menu-flyout {
        display: block;
    }
}

/* ---------- Main ---------- */

.site-main {
    flex: 1;
}

/* ---------- Footer ---------- */

.site-footer {
    background: #f1f3f8;
    border-top: 1px solid #e5e7eb;
}

.footer-inner {
    max-width: 960px;
    margin: 0 auto;
    padding: 1.2rem 1.5rem;
    font-size: 0.82rem;
    color: #9ca3af;
}

.footer-bottom-row {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.footer-legal-nav {
    text-align: center;
}

.footer-meta-row {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 1.85rem;
}

.footer-social-links {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 0.7rem;
}

.footer-meta-row > .footer-copyright {
    margin: 0;
    text-align: center;
}

.footer-social-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #1a1a1a;
    opacity: 1;
    text-decoration: none;
    transition: transform 0.15s ease;
}

.footer-social-link:visited,
.footer-social-link:active,
.footer-social-link:focus,
.footer-social-link:hover {
    color: #1a1a1a;
    opacity: 1;
}

.footer-social-link:hover {
    transform: translateY(-1px);
}

.footer-social-link svg {
    display: block;
    width: 29px;
    height: 29px;
}

@media (max-width: 640px) {
    .footer-meta-row {
        flex-direction: column;
        gap: 0.75rem;
        padding-top: 0.15rem;
    }

    .footer-social-links {
        position: static;
        transform: none;
        justify-content: center;
    }
}

.site-footer .legal-footer-nav {
    margin: 0 0 0.65rem;
    padding: 0;
    border: none;
    font-size: 0.78rem;
    line-height: 1.6;
    color: #9ca3af;
}

.site-footer .legal-footer-nav a {
    color: #6b7280;
    text-decoration: none;
}

.site-footer .legal-footer-nav a:hover {
    color: #2563eb;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.site-footer .legal-sep {
    margin: 0 0.2rem;
    color: #d1d5db;
}

.site-footer .footer-copyright {
    margin: 0;
    font-size: 0.76rem;
    color: #9ca3af;
}

/* ---------- Boutons réutilisables ---------- */

.btn,
a.btn,
.btn-primary,
a.btn-primary {
    color: #ffffff;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.85rem 1.9rem;
    border-radius: 999px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.98rem;
    cursor: pointer;
    transition:
        transform var(--transition-fast),
        box-shadow var(--transition-fast),
        background var(--transition-fast),
        filter var(--transition-fast);
    will-change: transform, box-shadow;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-blue), #5066ff);
    box-shadow: 0 16px 35px rgba(var(--primary-blue-rgb), 0.45);
}

a.btn:visited,
a.btn-primary:visited,
a.btn:hover,
a.btn-primary:hover,
a.btn:active,
a.btn-primary:active {
    color: #ffffff;
}

.btn-primary:hover {
    transform: translateY(-1px) scale(1.01);
    box-shadow: 0 20px 40px rgba(var(--primary-blue-rgb), 0.6);
}

.btn-primary:active {
    transform: translateY(0) scale(0.99);
    box-shadow: 0 10px 22px rgba(var(--primary-blue-rgb), 0.45);
}

/* ---------- Motion policy ---------- */

/* Touch devices: pas de hover artificiel bruyant */
@media (hover: none) {
    .btn:hover,
    .btn-primary:hover {
        transform: none;
        box-shadow: inherit;
        filter: none;
    }
}

/* Accessibilité: réduire le mouvement global */
@media (prefers-reduced-motion: reduce) {
    html:focus-within {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ---------- Mobile baseline ---------- */

@media (max-width: 768px) {
    :root {
        --space-4: 0.9rem;
        --space-5: 1.25rem;
        --space-6: 1.6rem;
        --text-md: 0.95rem;
        --text-lg: 1.05rem;
        --text-xl: 1.16rem;
    }

    .container-base {
        width: min(100% - 2 * var(--space-3), var(--container-md));
    }

    .btn,
    .exam-intro-card,
    .exam-results-card,
    .welcome-card,
    .auth-card {
        animation: none !important;
        transition: opacity 0.15s ease-out !important;
    }

    .exam-results-hero,
    .exam-results-summary,
    .exam-results-actions,
    .exam-results-list-item {
        animation: none !important;
    }

    /* Ensure animated cards remain visible on mobile */
    .auth-card,
    .exam-intro-card,
    .exam-results-card,
    .welcome-card {
        opacity: 1 !important;
        transform: none !important;
    }

    /* Centre parfaitement le texte des CTA sur mobile (résultats + auth) */
    .exam-results-cta,
    .auth-btn,
    .btn-primary {
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
        line-height: 1.3;
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .exam-results-cta span {
        display: inline-block;
        width: 100%;
        text-align: center;
    }
}
