:root {
    --header-height: 120px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Georgia, serif;
    line-height: 1.6;
    color: #333;
    background: #fff;
}

:where(.years-list button) {
    font: inherit;
    color: inherit;
    background: none;
    border: none;
    cursor: pointer;
}


/* Mise en page : table des matières, texte, notes */

.main-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    display: grid;
    grid-template-columns: 250px 1fr 200px;
    gap: 2rem;
    min-height: calc(100vh - 160px);
    transition: grid-template-columns 0.3s ease;
}

.main-container:has(.left-panel.collapsed) {
    grid-template-columns: 40px 1fr 200px;
}


/* En-tête */

.header-top {
    background: #fff;
    color: #2c3e50;
    padding: 2rem 2rem 1.5rem;
    border-bottom: 2px solid #2c3e50;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.header-left {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.header-top h1 {
    font-size: 2rem;
    font-weight: 300;
    letter-spacing: 3px;
    text-transform: uppercase;
}

.header-actions {
    display: flex;
    gap: 2rem;
    align-items: center;
    padding-left: 0.5rem;
    border-left: 1px solid #d0d0d0;
}

.header-link {
    position: relative;
    color: #555;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 300;
    cursor: pointer;
    transition: color 0.3s;
}

.header-link::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 0;
    width: 0;
    height: 1px;
    background: #3498db;
    transition: width 0.3s;
}

.header-link:hover {
    color: #3498db;
}

.header-link:hover::after {
    width: 100%;
}

.publications-dropdown {
    position: relative;
}

.publications-menu {
    display: none;
    position: absolute;
    top: calc(100% + 1rem);
    left: 0;
    min-width: 300px;
    background: #fff;
    border: 1px solid #d0d0d0;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.08);
    z-index: 1000;
}

.publications-dropdown:hover .publications-menu,
.publications-dropdown:focus-within .publications-menu {
    display: block;
}

.publications-menu a {
    display: block;
    padding: 1rem 1.25rem;
    color: #555;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 300;
    border-bottom: 1px solid #f0f0f0;
    transition: all 0.2s;
}

.publications-menu a:last-child {
    border-bottom: none;
}

.publications-menu a[href]:hover {
    color: #3498db;
    padding-left: 1.5rem;
    background: #fafafa;
}

.publications-menu a:not([href]) {
    color: #767676;
}


/* Menu collé : exemplaires et options */

.header-menu {
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 0.75rem 2rem;
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
}

.menu-years {
    position: relative;
    max-width: 1400px;
    min-height: 36px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.current-edition-display {
    font-size: 0.8rem;
    font-weight: 300;
    color: #666;
    white-space: nowrap;
}

.years-list {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.header-logos {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.header-logos a {
    line-height: 0;
}

.header-logos img {
    height: 24px;
    width: auto;
    opacity: 0.5;
    transition: opacity 0.3s;
}

.header-logos img:hover {
    opacity: 0.8;
}

.year-dropdown {
    position: relative;
}

.year-link {
    display: inline-flex;
    align-items: center;
    font-size: 0.85rem;
    font-weight: 300;
    color: #666;
    cursor: pointer;
    transition: color 0.2s;
}

.year-link:hover {
    color: #333;
}

.dropdown-activator {
    margin-left: 0.2rem;
    font-size: 0.6rem;
    opacity: 0.4;
}

.dropdown-content {
    display: none;
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 50%;
    transform: translateX(-50%);
    min-width: 240px;
    background: #fff;
    border: 1px solid #e0e0e0;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    z-index: 200;
}

.dropdown-content.show {
    display: block;
}

.edition-item {
    display: block;
    width: 100%;
    padding: 0.6rem 1rem;
    text-align: left;
    font-size: 0.8rem;
    font-weight: 300;
    color: #666;
    border-bottom: 1px solid #f5f5f5;
    transition: all 0.2s;
}

.edition-item:last-child {
    border-bottom: none;
}

.edition-item:hover {
    color: #333;
    background: #fafafa;
}

.edition-item.selected {
    color: #333;
    font-weight: 400;
}

.menu-options {
    max-width: 1400px;
    margin: 0.5rem auto 0;
    padding: 0.5rem 1rem;
    border-top: 1px solid #f0f0f0;
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 2rem;
    align-items: start;
}

.menu-options > label:first-child {
    grid-column: 1;
    justify-self: start;
}

.options-group {
    grid-column: 2;
    display: flex;
    justify-content: center;
    gap: 2.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.menu-options label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    color: #666;
    font-size: 0.75rem;
    font-weight: 300;
}

.menu-options input[type="checkbox"] {
    appearance: none;
    position: relative;
    width: 14px;
    height: 14px;
    border: 1px solid #ccc;
    cursor: pointer;
}

.menu-options input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    top: -2px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 10px;
    color: #333;
}

.menu-options select {
    padding: 0.2rem 0.5rem;
    border: none;
    border-bottom: 1px solid #e0e0e0;
    background: transparent;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 300;
    color: #666;
    cursor: pointer;
}

.jump-to-remark {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.jump-to-remark select {
    max-width: 200px;
}

.jump-to-remark input {
    width: 40px;
    padding: 0.2rem 0.4rem;
    border: none;
    border-bottom: 1px solid #e0e0e0;
    background: transparent;
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    text-align: center;
    color: #666;
}

.menu-options select:focus,
.jump-to-remark input:focus {
    border-bottom-color: #999;
}

.jump-to-remark button {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #ccc;
    background: transparent;
    font-size: 0.9rem;
    color: #666;
    cursor: pointer;
    transition: all 0.2s;
}

.jump-to-remark button:hover {
    border-color: #999;
    color: #333;
}


/* Colonnes latérales */

.left-panel {
    position: sticky;
    top: calc(var(--header-height) + 2rem);
    max-height: calc(100vh - var(--header-height) - 4rem);
    padding: 1rem 1rem 1rem 0;
    overflow: hidden;
    background: #fff;
    border-right: 1px solid #e0e0e0;
    transition: all 0.3s;
    z-index: 50;
}

.left-panel.collapsed {
    width: 40px;
    padding: 1.5rem 0;
}

.left-panel.collapsed .panel-content {
    display: none;
}

.toggle-btn {
    position: absolute;
    right: -5px;
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    background: #fff;
    border: 1px solid #e0e0e0;
    cursor: pointer;
    transition: all 0.3s;
    z-index: 10;
}

.toggle-btn:hover {
    border-color: #999;
    color: #2c3e50;
}

.panel-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

.panel-content h3,
.notes-area h3 {
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    font-size: 0.85rem;
    font-weight: 400;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid #e0e0e0;
}

.notes-area {
    position: relative;
    min-height: 400px;
    padding: 1rem 0 1rem 1.5rem;
    background: #fff;
    border-left: 1px solid #e0e0e0;
}


/* Texte */

.viewport {
    position: relative;
    min-height: 600px;
    padding: 3rem;
    overflow-x: hidden;
    background: #fff;
}

.text-container {
    max-width: 700px;
    margin: 0 auto;
    text-align: justify;
    transition: transform 0.4s ease-out, opacity 0.3s ease-out;
}

h2 {
    margin: 56pt 50px 6pt 20px;
    padding: 0 0 4px 5px;
    font-family: 'Garamond';
    font-size: 20pt;
    text-align: left;
    border-bottom: 1px solid black;
}

.paragraph {
    position: relative;
    padding: 0.5rem 0.5rem 0.5rem 1.5rem;
    font-family: 'Garamond';
    font-size: 14pt;
    border-left: 2px solid transparent;
    cursor: pointer;
    transition: all 0.3s ease;
}

.remark .paragraph + .paragraph {
    padding-top: 0;
}

.paragraph.active {
    border-color: #2c3e50;
    background: rgba(74, 144, 226, 0.1);
}

.paragraph:hover::before {
    content: attr(data-num);
    position: absolute;
    left: -1rem;
    top: 1em;
    font-family: 'Courier New', monospace;
    font-size: 0.7rem;
    color: #555;
    pointer-events: none;
}

.italic {
    font-style: italic;
}

.small_caps {
    font-variant: small-caps;
}

.page_nb {
    font-size: 0.8rem;
    color: #767676;
}

.paragraph-marker-moved,
.paragraph-marker-appeared {
    display: none;
}

.show-markers .paragraph-marker-moved,
.show-markers .paragraph-marker-appeared {
    display: inline;
    position: absolute;
    left: -2px;
}

.show-markers .paragraph-marker-moved {
    color: #e67e22;
    font-size: 0.9em;
    vertical-align: middle;
}

.show-markers .paragraph-marker-appeared {
    color: #2c3e50;
    font-size: 0.8em;
    vertical-align: super;
}

.message {
    position: fixed;
    top: 6rem;
    left: 2rem;
    padding: 0.6rem 1rem;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    color: white;
    background: #2c3e50;
    border-left: 3px solid #e74c3c;
    z-index: 1001;
    animation: fadeInOut 3s ease-in-out;
}

@keyframes fadeInOut {
    0% { opacity: 0; transform: translateY(-10px); }
    10% { opacity: 1; transform: translateY(0); }
    90% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-10px); }
}


/* Variantes : soulignées dans le paragraphe actif, menu au survol */

.variant {
    position: relative;
}

.paragraph.active .variant-edition,
.paragraph.active .variant-copy {
    padding: 0 0.1rem;
    cursor: help;
    transition: all 0.2s ease;
}

.paragraph.active .variant-edition {
    background: linear-gradient(to bottom, transparent 60%, rgba(74, 144, 226, 0.2) 60%);
    border-bottom: 1px solid rgba(74, 144, 226, 0.4);
}

.paragraph.active .variant-edition:hover {
    background: rgba(74, 144, 226, 0.25);
}

.paragraph.active .variant-copy {
    background: linear-gradient(to bottom, transparent 60%, rgba(230, 126, 34, 0.2) 60%);
    border-bottom: 1px solid rgba(230, 126, 34, 0.4);
}

.paragraph.active .variant-copy:hover {
    background: rgba(230, 126, 34, 0.25);
}

.variant-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 200px;
    margin-top: 0.25rem;
    padding: 0.5rem;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
}

.paragraph.active .variant:hover .variant-menu {
    display: block;
}

.variant-option {
    display: block;
    padding: 0.4rem 0.5rem;
    font-size: 0.85rem;
    border-bottom: 1px solid #f0f0f0;
}

.variant-option:last-child {
    border-bottom: none;
}

.variant-source {
    display: inline-block;
    min-width: 80px;
    margin-right: 0.5rem;
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    color: #666;
}

.variant-text {
    color: #333;
}

.variant-text em {
    color: #767676;
}


/* Table des matières : une barre de carrés proportionnelle au texte */

.toc-container {
    position: relative;
    flex: 1;
    min-height: 0;
    height: 100%;
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
    padding: 1rem 0 0 0.5rem;
}

.toc-titles-column {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
}

.toc-track {
    position: relative;
    flex: 0 0 4px;
    width: 4px;
    margin: 0 30px 10px 0;
    background: #e0e0e0;
    border-radius: 2px;
}

.toc-unit {
    position: relative;
    height: 4px;
    background: #d0d0d0;
    border-bottom: 1px solid #fff;
    cursor: pointer;
    transition: background 0.2s;
}

.toc-unit::before {
    content: '';
    position: absolute;
    inset: -2px -10px;
}

.toc-unit:hover {
    background: #4a90e2;
}

.toc-chapter {
    position: absolute;
    left: 0;
    width: 100%;
    transform: translateY(-50%);
    cursor: pointer;
    z-index: 10;
}

.toc-chapter-title {
    padding: 0.2rem 0;
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.3;
    text-align: right;
    color: #333;
    word-wrap: break-word;
    transition: all 0.2s;
}

.toc-chapter:hover .toc-chapter-title {
    color: #000;
    font-weight: 600;
}

.toc-chapter.active .toc-chapter-title {
    color: #000;
    font-weight: bold;
}

.toc-scroll-indicator {
    position: absolute;
    left: -2px;
    width: 8px;
    height: 20px;
    background: #2c3e50;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: top 0.1s ease-out;
    pointer-events: none;
    z-index: 5;
}


/* Signalement : bande colorée à gauche du paragraphe, point dans la table */

.paragraph.signale::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 2px;
    background: var(--signal);
    opacity: 0.6;
    z-index: 1;
}

.toc-unit.signale::after {
    content: '';
    position: absolute;
    right: -10px;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    background: var(--signal);
    border: 1px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 0 1px var(--signal);
    transition: transform 0.2s;
}

.toc-unit.signale:hover::after {
    transform: translateY(-50%) scale(1.3);
}


/* Notes : appels dans le texte, notes dans la colonne de droite */

.note-ref {
    position: relative;
    cursor: help;
}

.note-ref-print {
    margin: 0 0.1em;
    font-size: 0.75em;
    font-weight: bold;
    vertical-align: super;
    color: #c0392b;
}

.paragraph-notes {
    display: none;
}

.notes-group {
    position: absolute;
    left: 0;
    right: 0;
    margin-bottom: 1.5rem;
    transition: top 0.2s ease-out;
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

.note {
    margin-bottom: 0.75rem;
    padding: 0.5rem;
    font-size: 0.85rem;
    line-height: 1.5;
    border-radius: 4px;
}

.note-print {
    background: #fff8f0;
    border-left: 3px solid #c0392b;
}

.note-sign {
    display: inline-block;
    margin-right: 0.4rem;
    font-size: 0.9em;
    font-weight: bold;
    color: #c0392b;
}

.note-text {
    color: #333;
}

.note-hand {
    display: none;
    font-family: 'Courier New', monospace;
    font-style: italic;
    background: #f0f8ff;
    border-left: 3px solid #3498db;
}

.show-hand-notes .note-hand {
    display: block;
}

.note-highlighted {
    background: #fff3cd !important;
    border-left-width: 5px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.2s ease;
}


/* Écrans étroits */

@media (max-width: 1024px) {
    .main-container {
        grid-template-columns: 200px 1fr;
        gap: 1.5rem;
    }

    .notes-area {
        display: none;
    }

    .paragraph-notes {
        display: block;
        margin: 0 0 1rem 1.5rem;
    }

    .header-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .header-actions {
        flex-wrap: wrap;
        padding: 0.75rem 0 0;
        border-left: none;
        border-top: 1px solid #d0d0d0;
    }

    .menu-years {
        flex-direction: column;
        gap: 0.75rem;
        align-items: center;
    }

    .years-list {
        position: static;
        transform: none;
    }

    .menu-options {
        grid-template-columns: 1fr;
    }

    .menu-options > label:first-child {
        justify-self: center;
    }

    .options-group {
        grid-column: 1;
        flex-direction: column;
        gap: 0.75rem;
    }
}

@media (max-width: 768px) {
    .main-container {
        grid-template-columns: 1fr;
        padding: 1rem;
    }

    .left-panel {
        display: none;
    }

    .viewport {
        padding: 1.5rem;
    }

    .header-left {
        align-items: center;
    }

    .header-top h1 {
        font-size: 1.5rem;
    }

    .years-list {
        flex-wrap: wrap;
        justify-content: center;
    }
}
