/* ===========================================
   CSS VARIABLES
   =========================================== */

:root {
    /* Couleurs principales */
    --color-primary: rgba(122, 0, 200, 0.85);
    --color-primary-light: rgba(122, 0, 200, 0.55);
    --color-accent: rgba(255, 47, 160, 0.8);
    --color-accent-light: rgba(255, 47, 160, 0.35);
    --color-accent-bg: rgba(255, 47, 160, 0.10);
    --color-cta: rgba(255, 140, 58, 0.88);
    --color-cta-hover: rgba(255, 181, 90, 0.88);

    /* Texte */
    --color-text: #21002c;
    --color-text-light: rgba(33, 0, 44, 0.95);
    --color-text-muted: #4b4460;

    /* Fond */
    --color-bg: #f9f6fb;
    --color-card: #ffffff;
    --color-abstract: rgba(243, 230, 255, 0.65);
    --color-ref-bg: #f7f2fa;
    --color-ref-border: #d7c1ef;

    /* Liens */
    --color-link: var(--color-primary);
    --color-link-hover: var(--color-accent);
    --color-link-visited: rgba(90, 0, 126, 0.75);

    /* UI */
    --color-border: rgba(209, 213, 219, 0.7);
    --color-menu-bg: #F7F6FA;
    --color-menu-active: rgba(51, 54, 63, 0.92);
    --color-footer: rgba(33, 0, 44, 0.95);

    /* Rayons */
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 18px;
    --radius-pill: 30px;

    /* Ombres */
    --shadow-card: 0 4px 14px rgba(0, 0, 0, 0.04);
    --shadow-card-hover: 0 8px 22px rgba(0, 0, 0, 0.08);
    --shadow-cover: 0 0 7px rgba(0, 0, 0, 0.35);

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.5s ease;

    /* Typographie */
    --font-body: 'Albert Sans', sans-serif;
    --font-heading: 'Albert Sans', sans-serif;
    --font-logo: 'Alegreya', serif;
    --font-dyslexic: 'OpenDyslexic', sans-serif;
}

/* ===========================================
   FONTS
   =========================================== */

@font-face {
    font-family: 'OpenDyslexic';
    src: url('../assets/fonts/OpenDyslexic-Regular.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
}

/* ===========================================
   RESET / BASE
   =========================================== */

body {
    margin: 0;
    font-family: var(--font-body);
    background: var(--color-bg);
    color: var(--color-text);
}

h1, h2, h3 {
    font-family: var(--font-heading);
    color: var(--color-text-light);
}

a {
    color: var(--color-link);
    text-decoration: none;
    font-weight: 600;
    transition: color var(--transition-normal), border-bottom var(--transition-normal);
}

a:hover {
    color: var(--color-link-hover);
    border-bottom: 2px solid var(--color-accent-light);
}

a:active {
    color: rgba(33, 0, 44, 0.75);
}

a:visited {
    color: var(--color-link-visited);
}

/* ===========================================
   LAYOUT
   =========================================== */

.container {
    width: 90%;
    max-width: 1100px;
    margin: auto;
}

/* ===========================================
   TRANSITIONS / ANIMATIONS
   =========================================== */

.fade {
    opacity: 0;
    transition: opacity var(--transition-slow);
}

.fade.loaded {
    opacity: 1;
}

body.no-fade {
    transition: none !important;
    opacity: 1 !important;
}

/* Animation couverture */
@keyframes bookFloat {
    0%   { transform: rotate(-0.6deg) scale(1);    box-shadow: var(--shadow-cover); }
    50%  { transform: rotate(0.6deg) scale(1.01);  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.30); }
    100% { transform: rotate(-0.6deg) scale(1);    box-shadow: var(--shadow-cover); }
}

img.cover {
    float: left;
    margin-right: 30px;
    max-height: 300px;
    box-shadow: var(--shadow-cover);
    animation: bookFloat 5.5s ease-in-out infinite;
    transform-origin: center bottom;
}

/* Animation tags */
@keyframes floatTag {
    0%   { transform: translateY(0px); }
    50%  { transform: translateY(-3px); }
    100% { transform: translateY(0px); }
}

/* ===========================================
   HEADER
   =========================================== */

.book-header {
    background: var(--color-card);
    border-bottom: 1px solid #E5E7EB;
    padding: 12px 0 4px 0;
}

.topnav {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-family: var(--font-logo);
    font-size: 1.35rem;
    font-weight: 700;
    color: #33363F;
    line-height: 1.25;
}

.logo:hover {
    border-bottom: none !important;
}

.logo-sub {
    font-size: 1.05rem;
    font-weight: 400;
    color: #60646C;
}

/* Bandeau éditorial */
.editorial-bar {
    margin-top: 6px;
    padding: 6px 2px 0 2px;
    font-family: 'Inter', sans-serif;
    font-size: 0.82rem;
    line-height: 1.25;
    display: flex;
    flex-direction: column;
    gap: 2px;
    color: #555B63;
}

.editorial-label {
    color: #9AA3B1;
    font-weight: 600;
}

.editorial-name {
    color: #33363F;
    font-weight: 700;
}

.editorial-and {
    color: #666;
}

/* ===========================================
   NAVIGATION
   =========================================== */

nav .menu {
    display: flex;
    gap: 12px;
}

nav .menu a {
    padding: 8px 16px;
    background: var(--color-menu-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-pill);
    color: rgba(51, 54, 63, 0.85);
    font-size: 0.8rem;
    transition: all var(--transition-normal);
}

nav .menu a:hover {
    background: #EEEAF4;
    border-color: rgba(193, 198, 207, 0.7);
    transform: translateY(-2px);
}

nav .menu a.active {
    background: var(--color-menu-active);
    color: #fff !important;
    border-color: var(--color-menu-active);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

/* ===========================================
   ACCESSIBILITÉ - TOGGLE DYSLEXIE
   =========================================== */

.accessibility-tools {
    margin-left: 10px;
    display: flex;
    align-items: center;
}

.dys-switch {
    position: relative;
    width: 42px;
    height: 22px;
}

.dys-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    background: #D1D5DB;
    border-radius: 22px;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    cursor: pointer;
    transition: var(--transition-normal);
}

.slider:before {
    content: "";
    position: absolute;
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: var(--transition-normal);
}

input:checked + .slider {
    background: #7a00c8;
}

input:checked + .slider:before {
    transform: translateX(20px);
}

.accessibility-note {
    font-size: 0.68rem;
    color: #6b6b7a;
    margin-top: 2px;
    margin-left: 4px;
    opacity: 0.75;
}

/* Mode dyslexique */
body.dyslexic-mode {
    font-family: var(--font-dyslexic) !important;
}

body.dyslexic-mode h1,
body.dyslexic-mode h2,
body.dyslexic-mode h3,
body.dyslexic-mode .logo {
    font-family: var(--font-dyslexic) !important;
}

/* ===========================================
   COMPOSANTS - BOUTONS
   =========================================== */

.btn {
    display: inline-block;
    background: var(--color-cta);
    color: var(--color-text);
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-weight: bold;
    border: none;
    cursor: pointer;
    transition: background var(--transition-normal);
}

.btn:hover {
    background: var(--color-cta-hover);
    border-bottom: none;
}

.btn.small {
    padding: 6px 14px;
}

/* ===========================================
   COMPOSANTS - TAGS
   =========================================== */

.tag {
    display: inline-block;
    padding: 6px 12px;
    background: var(--color-accent-bg);
    border: 1px solid rgba(255, 47, 160, 0.28);
    border-radius: var(--radius-sm);
    color: var(--color-text);
    font-weight: 600;
    font-size: 0.8rem;
    margin: 4px;
    transition: background var(--transition-normal), border var(--transition-normal);
}

.tag:hover {
    background: rgba(255, 47, 160, 0.22);
    border-color: rgba(255, 47, 160, 0.40);
    border-bottom: 1px solid rgba(255, 47, 160, 0.40);
}

/* Tags dans le nuage de mots */
.wordcloud {
    margin-top: 30px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.wordcloud .tag {
    position: relative;
    animation: floatTag 3.5s ease-in-out infinite;
}

.wordcloud .tag:nth-child(odd) {
    animation-duration: 2.4s;
    animation-delay: 0.15s;
}

.wordcloud .tag:nth-child(3n) {
    animation-duration: 1.8s;
    animation-delay: 0.25s;
}

.wordcloud .tag:nth-child(5n) {
    animation-duration: 2.1s;
    animation-delay: 0.05s;
}

/* ===========================================
   COMPOSANTS - CARTES
   =========================================== */

.chapter-card {
    background: var(--color-card);
    padding: 22px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    border-left: 6px solid var(--color-primary-light);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.chapter-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-card-hover);
}

.chapter-card h2 {
    font-size: 1.25rem;
    margin: 0;
    color: rgba(33, 0, 44, 0.9);
}

.chapter-card .authors {
    margin-top: 10px;
    font-weight: 600;
    color: var(--color-accent);
}

.chapter-card .pages {
    margin-top: 8px;
    color: var(--color-text-muted);
}

.chapter-card .keywords,
.chapter-card .tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    margin-top: 12px;
}

.chapter-card .tag {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    font-size: 0.78rem;
    line-height: 1.2;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
}

/* ===========================================
   GRILLES
   =========================================== */

.chapters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
    gap: 25px;
    margin-top: 30px;
}

.authors-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 28px;
    margin: 40px 0;
}

/* ===========================================
   PAGE CHAPITRE
   =========================================== */

.chapter-page {
    background: var(--color-card);
    padding: 40px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
}

.chapter-header {
    border-bottom: 1px solid rgba(0, 0, 0, 0.10);
    margin-bottom: 25px;
    padding-bottom: 15px;
}

.chapter-header h1 {
    font-size: 2rem;
    margin-bottom: 12px;
}

.chapter-header .subtitle {
    font-size: 1.25rem;
    margin-bottom: 10px;
    color: rgba(122, 0, 200, 0.75);
}

.chapter-header .authors {
    font-weight: 600;
    color: var(--color-accent);
}

.chapter-page .keywords,
.chapter-page .tags {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.chapter-page .tag {
    white-space: nowrap;
}

/* Boîte résumé */
.abstract-box {
    background: var(--color-abstract);
    padding: 15px;
    border-radius: var(--radius-md);
    border-left: 4px solid var(--color-primary-light);
    margin: 25px 0;
}

/* Boutons chapitre */
.chapter-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin: 20px 0;
}

/* Référence APA */
.refbox {
    width: 100%;
    height: 80px;
    margin-top: 20px;
    padding: 10px;
    background: var(--color-ref-bg);
    border: 1px solid var(--color-ref-border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    resize: vertical;
}

.copy-btn {
    background: #e4d2f7;
    margin-top: 10px;
}

.copy-btn:hover {
    background: #d4b8f5;
}

.copy-btn.copied {
    background: #4ade80;
    color: white;
}

/* ===========================================
   PAGE AUTEURS
   =========================================== */

.author-card {
    background: var(--color-card);
    padding: 22px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    border-left: 6px solid var(--color-primary-light);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), border var(--transition-fast);
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.author-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-card-hover);
    border-left-color: var(--color-accent);
}

.author-card img {
    width: 140px;
    height: 140px;
    object-fit: cover;
    border-radius: 50%;
    border: 3px solid var(--color-primary-light);
    box-shadow: 0 0 0 3px rgba(251, 227, 255, 0.5);
    margin: 0 auto 14px;
}

.author-card h2 {
    font-size: 1.15rem;
    margin: 8px 0 4px;
    color: var(--color-primary);
}

.author-card .email a {
    color: var(--color-accent);
}

.author-card .email a:hover {
    text-decoration: underline;
}

.author-card .bio {
    font-size: 0.78rem;
    line-height: 1.35;
    max-height: 120px;
    overflow: hidden;
    position: relative;
}

.author-card .bio::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 35px;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0), var(--color-card));
}

.author-card .more-btn {
    margin-top: 12px;
    padding: 8px 14px;
    font-size: 0.82rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    background: var(--color-cta);
    color: var(--color-text);
    border: none;
    cursor: pointer;
    transition: background var(--transition-normal), transform var(--transition-fast);
}

.author-card .more-btn:hover {
    background: var(--color-cta-hover);
    transform: translateY(-2px);
    border-bottom: none;
}

/* ===========================================
   MODAL AUTEUR
   =========================================== */

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    justify-content: center;
    align-items: start;
    padding-top: 60px;
    z-index: 9999;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--color-card);
    padding: 28px;
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 700px;
    position: relative;
    animation: modalPop 0.25s ease;
    border-top: 5px solid rgba(226, 71, 134, 0.35);
}

@keyframes modalPop {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-content img {
    width: 160px;
    height: 160px;
    float: right;
    object-fit: cover;
    border-radius: 50%;
    border: 4px solid var(--color-primary-light);
    box-shadow: 0 0 0 4px rgba(251, 227, 255, 0.5);
    margin-left: 22px;
}

.modal .close {
    position: absolute;
    top: 12px;
    right: 18px;
    cursor: pointer;
    color: #777;
    font-size: 1.8rem;
    transition: var(--transition-normal);
}

.modal .close:hover {
    color: rgba(226, 71, 134, 0.7);
}

/* ===========================================
   FOOTER
   =========================================== */

footer {
    margin-top: 50px;
    background: var(--color-footer);
    color: var(--color-bg);
    padding: 25px;
    text-align: center;
    font-size: 0.9rem;
    border-top: 1px solid rgba(255, 255, 255, 0.10);
}

.partners-block {
    margin-top: 25px;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.20);
}

.partners-title {
    font-size: 0.85rem;
    color: rgba(233, 228, 240, 0.95);
    margin-bottom: 12px;
}

.partners-logos {
    display: flex;
    gap: 28px;
    justify-content: center;
    flex-wrap: wrap;
}

.partners-logos img {
    max-height: 50px;
    max-width: 200px;
    filter: brightness(97%) contrast(103%);
    transition: var(--transition-normal);
}

.partners-logos img:hover {
    transform: scale(1.05);
    filter: brightness(100%) contrast(110%);
}

.footer-credits {
    margin-top: 20px;
    padding-top: 15px;
    text-align: center;
}

/* ===========================================
   PAGE ERREUR
   =========================================== */

.error-page {
    text-align: center;
    padding: 60px 20px;
}

.error-page h1 {
    font-size: 2.5rem;
    color: var(--color-primary);
}

/* ===========================================
   PAGE MOTS-CLÉS - TOGGLE VUE
   =========================================== */

.view-toggle {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.view-toggle button {
    padding: 8px 16px;
    border: 1px solid var(--color-border);
    background: var(--color-menu-bg);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all var(--transition-fast);
}

.view-toggle button:hover {
    background: #EEEAF4;
}

.view-toggle button.active {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

.view-hidden {
    display: none !important;
}

.view-active {
    display: flex;
}

/* ===========================================
   PAGE MOTS-CLÉS - RÉSEAU
   =========================================== */

#network-graph {
    width: 100%;
    height: 600px;
    background: var(--color-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}

#network-graph svg {
    width: 100%;
    height: 100%;
    cursor: grab;
}

#network-graph svg:active {
    cursor: grabbing;
}

/* Nœuds */
.network-node {
    fill: var(--color-primary);
    stroke: var(--color-card);
    stroke-width: 2px;
    cursor: pointer;
    transition: fill 0.15s;
}

.network-node:hover,
.network-node.highlighted {
    fill: var(--color-accent);
}

.network-node.dimmed {
    fill: #ccc;
    opacity: 0.4;
}

/* Liens */
.network-link {
    stroke: rgba(122, 0, 200, 0.3);
    stroke-linecap: round;
}

.network-link.highlighted {
    stroke: var(--color-accent);
    stroke-opacity: 1;
}

.network-link.dimmed {
    stroke-opacity: 0.1;
}

/* Labels */
.network-label {
    font-size: 11px;
    font-weight: 600;
    fill: var(--color-text);
    pointer-events: none;
    text-anchor: middle;
    dominant-baseline: middle;
}

.network-label.hidden {
    opacity: 0;
}

.network-label.visible {
    opacity: 1;
}

.network-label.hover-visible {
    opacity: 1;
    font-weight: 700;
    fill: var(--color-primary);
}

/* Tooltip */
.graph-tooltip {
    position: fixed;
    padding: 8px 12px;
    background: var(--color-text);
    color: var(--color-bg);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 1000;
    max-width: 250px;
}

.graph-tooltip.visible {
    opacity: 1;
}

.graph-tooltip .kw-name {
    font-weight: 700;
}

.graph-tooltip .kw-count {
    opacity: 0.8;
    font-size: 0.8rem;
}

/* Légende */
.network-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 15px;
    padding: 10px 15px;
    background: var(--color-card);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.network-legend span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.legend-node {
    display: inline-block;
    border-radius: 50%;
    background: var(--color-primary);
}

.legend-node.small {
    width: 10px;
    height: 10px;
}

.legend-node.large {
    width: 20px;
    height: 20px;
}

.legend-link {
    display: inline-block;
    width: 25px;
    background: rgba(122, 0, 200, 0.4);
}

.legend-link.thin {
    height: 2px;
}

.legend-link.thick {
    height: 5px;
}

/* ===========================================
   PAGE CONTACT
   =========================================== */

.contact-options {
    margin-top: 25px;
    line-height: 1.6;
}

.contact-options h3 {
    margin-top: 30px;
    margin-bottom: 10px;
}

.contact-options p {
    margin-bottom: 15px;
}

/* ===========================================
   RESPONSIVE
   =========================================== */

@media (max-width: 768px) {
    .topnav {
        flex-direction: column;
        gap: 12px;
    }

    nav .menu {
        flex-wrap: wrap;
        justify-content: center;
    }

    .chapter-page {
        padding: 20px;
    }

    img.cover {
        float: none;
        display: block;
        margin: 0 auto 20px;
    }

    .hero {
        text-align: center;
    }
}
