/* ---------------------------------------------------------------
   Contrepoint — style.css
   Esthétique : papier / encre / clef d'ut. Sobre, sérif, feutrée.
   --------------------------------------------------------------- */

:root {
    --ink:        #2b2820;
    --ink-soft:   #3a3527;
    --paper:      #f2f1f0;
    --paper-2:    rgba(254,254,254,.9);
    --paper-3:    rgba(254,254,254,.9);
    --rule:       #ccc;
    --rule-2:     #ccc;
    --muted:      #6e6757;
    --accent:     #a88c5a;
    --voie-A:     #a8624a;
    --voie-IA:    #3a4a5c;
    --voie-B:     #6f7d4a;
    --error:      #8b3a2e;

    --serif: "IBM Plex Serif", Georgia, "Times New Roman", serif;
    --sans:  "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--sans);
    font-weight: 300;
    line-height: 1.6;
  
  min-height: 90vh; 
    display: grid; 
    grid-template-rows: auto 1fr auto;
  }

::selection { background: var(--accent); color: var(--paper); }


.lien-discret {
    position: relative;
    justify-self: end; /* Parfait pour s'aligner à droite dans ta grille */
    width: fit-content; /* Empêche le bug de débordement sur mobile */
    margin-top: 20px;
    margin-right: 30px; /* Légèrement réduit pour les petits écrans */
    margin-left: auto;
    display: flex;
    gap: 1rem;
    font-family: var(--sans);
    font-weight: 400;
    font-size: 1rem;
    z-index: 1000;
    letter-spacing: 0rem;
    color: #000;
    text-decoration: none;
    opacity: 1;
    transition: color .1s ease;
}
	  
	  
	  .lien-discret:hover {
		color: #000      ;
		transition: color .1s ease;
	  }




/* En-tête ----------------------------------------------------- */

.entete {
    text-align: center;
    padding: 2.4rem 1.5rem 2.4rem;
    border-bottom: 0px dashed var(--rule);
}

.entete h1 {
    font-family: var(--sans);
    font-weight: 400;
      font-style: normal;
    font-size: clamp(1.5rem, 2vw, 2rem);
    margin: 30px 0 20px;
    letter-spacing: 0em;
    opacity: 0.9;
}

.baseline {
    color: var(--ink);
    font-family: var(--serif);
    font-style: normal;
    font-size: 1.1rem;
    margin: 0.5rem 0 0;
}
.discret { color: var(--ink); }

/* Mise en page ------------------------------------------------ */

main {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: 2.4rem 1.5rem 2.4rem;

    /* AJOUTE CES 3 LIGNES : */
    display: flex;
    flex-direction: column;
    justify-content: center; /* Centre le contenu verticalement */
}

/* Saisie ------------------------------------------------------ */

.saisie {
    transition: max-height 0.55s ease, opacity 0.4s ease, margin 0.4s ease;
    overflow: hidden;
    max-height: 1200px;
}
.saisie.replie {
    max-height: 0;
    opacity: 0;
    pointer-events: none;
    margin: 0 0 1rem 0;
}

#form-contrepoint {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.6rem 1.8rem;
    align-items: start;
}

.champ { display: flex; flex-direction: column; min-width: 0; }

label {
    font-family: var(--sans);
    font-size: 1.25rem;
    margin-bottom: 0.45rem;
    color: var(--ink);
    letter-spacing: 0.01em;
}

textarea {
    background: var(--paper-2);
    border: 0px solid var(--accent);
    border-radius: 0px;
    padding: 20px 20px;
    color: var(--ink);
    resize: vertical;
    min-height: 200px;
    font-family: var(--serif);
    font-size: 1.06rem;
      font-weight: 200;
    line-height: 1.55;
    transition: background 0.15s, border-color 0.15s;
    width: 100%;
}
textarea::placeholder {
    color: var(--muted);
    font-style: normal;
  opacity: 0.7;
}
textarea:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--paper-3);
}

.meta-champ {
    display: flex;
    justify-content: flex-end;
    margin-top: 0.35rem;
}
.compteur {
    font-size: 0.82rem;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}
.compteur.warn { color: var(--error); }

.actions {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 1.4rem;
    flex-wrap: wrap;
    margin-top: 0.4rem;
}

button {
    font-family: var(--sans);
    font-size: .9rem;
    background: var(--ink);
    color: var(--paper);
    font-weight: 500;
    border: none;
    padding: 15px 30px;
    border-radius: 50%;
aspect-ratio: 1 / 1;
    cursor: pointer;
    letter-spacing: 0em;
    transition: background 0.18s ease, transform 0.05s ease;
}

button:not(.lien):hover:not(:disabled) {
    background: var(--ink-soft); 
}

button:not(.lien):active:not(:disabled) {
    transform: translateY(1px);
}

button:disabled {
    opacity: 0.55;
    cursor: progress;
}

.lien {
    background: none;
    color: var(--muted);
    padding: 0;
    font-size: 0.95rem;
    text-decoration: underline;
    text-underline-offset: 3px;
    letter-spacing: 0;
}

.lien:hover {
    color: var(--ink);
    background: #e6e0d8;
}
.statut {
    color: var(--muted);
    font-style: normal;
    font-family: var(--serif);
    font-size: 1.05rem;
}
.statut.erreur { color: var(--error); font-style: normal; }

/* Partition --------------------------------------------------- */

.partition {
    margin-top: 2.8rem;
    animation: arriver 0.6s ease;
}
@keyframes arriver {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: none; }
}

.entete-partition {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 1.2rem;
    gap: 1rem;
    flex-wrap: wrap;
}
.entete-partition h2 {
    font-family: var(--sans);
    font-weight: 400;
    font-size: 1.7rem;
    margin: 0;
    letter-spacing: 0.01em;
}
.horodatage {
    font-family: var(--sans);
    font-size: 1.05rem;
    font-style: normal;
    font-weight: 400;
    margin-left: 0.4rem;
}
.actions-partition {
    display: flex;
    gap: 1.4rem;
    align-items: baseline;
}

/* Vue imprimable : ordre flex différent à l'écran et au print --- */
.vue-imprimable {
    display: flex;
    flex-direction: column;
    gap: 0;
}
.graphique     { order: 1; }
.detail-voies  { order: 2; margin-top: 2.4rem; }
.textes-source { order: 3; margin-top: 2rem; }

/* Détail des voies ------------------------------------------- */
.detail-voies h3 {
    font-family: var(--sans);
    font-weight: 400;
    font-size: 1.45rem;
    margin: 0 0 1.1rem;
    color: var(--ink);
    letter-spacing: 0.01em;
}
.grille-mesures {
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}
.mesure {
    border: 1px solid var(--rule);
    background: var(--paper-2);
    border-radius: 0px;
    padding: 1rem 1.2rem;
}
.mesure > header {
    display: flex;
    align-items: baseline;
    gap: 0.7rem;
    margin-bottom: 0.8rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px dashed var(--rule);
    font-family: var(--sans);
}
.mes-numero {
    font-style: normal;
    font-size: 1.5rem;
    color: var(--accent);
    line-height: 1;
}
.mes-titre {
    font-size: 1.1rem;
    color: var(--muted);
}
.voix {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.2rem;
}
.voix > div { font-family: var(--serif); min-width: 0; }
.voix h4 {
  font-family: var(--sans);
    font-weight: 400;
    font-size: 1.02rem;
    margin: 0 0 0.25rem;
    letter-spacing: 0.02em;
}
.voix-A  h4 { color: var(--voie-A);  }
.voix-IA h4 { color: var(--voie-IA); }
.voix-B  h4 { color: var(--voie-B);  }
.voix .txt-y {
    margin: 0 0 0.35rem;
    color: var(--muted);
    font-size: 0.83rem;
    font-family: var(--sans);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.01em;
}
.voix .txt-corps {
    margin: 0;
    font-size: 1rem;
    line-height: 1.55;
    color: var(--ink);
}

/* Textes source ---------------------------------------------- */
.textes-source details {
    border-top: 1px dashed var(--rule);
    padding-top: 0.6rem;
}
.textes-source summary {
    cursor: pointer;
    font-family: var(--serif);
    font-size: 1.1rem;
    color: var(--muted);
    padding: 0.4rem 0;
    list-style: none;
    user-select: none;
}
.textes-source summary::-webkit-details-marker { display: none; }
.textes-source summary::before {
    content: "▸ ";
    color: var(--accent);
    margin-right: 0.2rem;
    display: inline-block;
    transition: transform 0.15s ease;
}
.textes-source details[open] > summary::before {
    content: "▾ ";
}
.textes-source details[open] > summary { color: var(--ink); }
.textes-grille {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.2rem;
    margin-top: 0.8rem;
}
.textes-grille h4 {
    font-family: var(--sans);
    font-weight: 400;
    font-size: 1.1rem;
    margin: 0 0 0.4rem;
    color: var(--ink);
}
.archive-txt {
    font-family: var(--serif);
    background: var(--paper-2);
    border: 1px solid var(--rule);
    padding: 0.85rem 1rem;
    margin: 0;
    white-space: pre-wrap;
    font-size: 0.98rem;
    line-height: 1.55;
    color: var(--ink);
}

.svg-host {
    position: relative;
    width: 100%;
    background: var(--paper-2);
    border: 1px solid var(--rule);
    border-radius: 0px;
    padding: 0.5rem 0.5rem 0.2rem;
}
.svg-host svg {
    width: 100%;
    height: auto;
    display: block;
}

/* SVG : interactions sur les nœuds */
.noeud { cursor: pointer; }
.noeud ellipse {
    transition: stroke-width 0.15s ease;
}
.noeud:hover ellipse,
.noeud:focus ellipse {
    stroke-width: 4;
}
.noeud:focus { outline: none; }

.legende {
    margin: 1.1rem 0 0;
    padding: 0;
    list-style: none;
    display: flex;
    gap: 1.8rem;
    flex-wrap: wrap;
    font-family: var(--sans);
    color: var(--muted);
    font-size: 1.05rem;
}
.leg { display: inline-flex; align-items: center; gap: 0.5rem; }
.leg::before {
    content: "";
    width: 22px; height: 2px;
    background: currentColor;
    display: inline-block;
    border-radius: 0px;
}
.leg-A  { color: var(--voie-A); }
.leg-IA { color: var(--voie-IA); }
.leg-B  { color: var(--voie-B); }

.aide {
    color: var(--muted);
    font-family: var(--sans);
    font-style: normal;
    font-size: 0.98rem;
    margin: 0.6rem 0 0;
}

/* Tooltip ----------------------------------------------------- */

.tooltip-svg {
    position: absolute;
    background: var(--ink);
    color: var(--paper);
    padding: 0.6rem 0.8rem;
    border-radius: 0px;
    border-left: 3px solid var(--accent);
    font-size: 0.92rem;
    line-height: 1.45;
    max-width: 300px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 10;
    font-family: var(--serif);
    white-space: pre-line;
    box-shadow: 0 6px 20px rgba(43, 40, 32, 0.18);
}
.tooltip-svg.show { opacity: 1; }
.tooltip-svg .tt-titre {
    display: block;
    font-weight: 400;
  font-family: var(--sans);
    font-style: italic;
    opacity: 0.8;
    margin-bottom: 0.25rem;
    font-size: 0.85rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/* Pied de page ----------------------------------------------- */

footer {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--muted);
    font-style: normal;
    border-top: 0px dashed var(--rule);
    font-family: var(--sans);
    font-size: 0.8rem;
      font-weight: 300;
    margin-top: 0rem;
}
footer p { margin: 0.2rem 0; }



/* Responsive -------------------------------------------------- */

@media (max-width: 760px) {
    #form-contrepoint { grid-template-columns: 1fr; }
    .entete { padding-top: 2.4rem; }
    main { padding: 1.6rem 1rem 3rem; }
    textarea { min-height: 160px; }
    .voix { grid-template-columns: 1fr; gap: 0.7rem; }
    .textes-grille { grid-template-columns: 1fr; }
    .entete-partition { flex-direction: column; align-items: flex-start; }
}

/* ------------------------------------------------------------
   Impression
   ------------------------------------------------------------ */
@media print {
    @page { margin: 1.4cm; }

    body {
        background: white;
        color: black;
        font-size: 10.5pt;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    /* On masque tout sauf la partition */
    .entete, footer, .saisie, #statut, .ecran-seul,
    .actions-partition, .aide { display: none !important; }

    main { max-width: none; padding: 0; margin: 0; }
    .partition { margin-top: 0; animation: none; }

    .entete-partition {
        margin-bottom: 0.6rem;
        border-bottom: 1px solid #333;
        padding-bottom: 0.3rem;
    }
    .entete-partition h2 { font-size: 16pt; color: #111; }
    .horodatage { color: #444; }

    /* Réordonnancement pour l'impression :
       textes en tête, puis graphique, puis détail des voies. */
    .vue-imprimable { display: flex; flex-direction: column; }
    .textes-source { order: 1; margin-top: 0; }
    .graphique     { order: 2; margin-top: 0.6rem; }
    .detail-voies  { order: 3; margin-top: 0.8rem; }

    /* Textes source : toujours déployés, présentation sobre */
    .textes-source summary { display: none !important; }
    .textes-source details,
    .textes-source details > * { display: block !important; }
    .textes-source details[open] { padding-top: 0; border-top: none; }
    .archive-txt {
        background: none !important;
        border: 1px solid #999;
        padding: 0.6rem 0.8rem;
        font-size: 10pt;
    }
    .textes-grille h4 { color: #111; }

    /* Graphique : pleine largeur, transparent */
    .svg-host {
        background: none !important;
        border: none !important;
        padding: 0 !important;
        page-break-inside: avoid;
        break-inside: avoid;
    }
    .svg-host svg { width: 100% !important; height: auto !important; }
    .tooltip-svg { display: none !important; }

    .legende { color: #333; margin-top: 0.4rem; }
    .legende .leg { color: #333 !important; }
    .legende .leg-A::before  { background: var(--voie-A);  }
    .legende .leg-IA::before { background: var(--voie-IA); }
    .legende .leg-B::before  { background: var(--voie-B);  }

    /* Détail des voies : éviter les coupures laides */
    .detail-voies h3 { font-size: 13pt; margin: 0.4rem 0 0.5rem; }
    .mesure {
        background: none !important;
        border: 1px solid #999;
        padding: 0.55rem 0.75rem;
        page-break-inside: avoid;
        break-inside: avoid;
        margin-bottom: 0.5rem;
    }
    .mesure > header { margin-bottom: 0.4rem; padding-bottom: 0.3rem; }
    .mes-numero { color: var(--accent); }
    .mes-titre  { color: #444; }
    .voix { gap: 0.7rem; }
    .voix .txt-y { color: #555; }
    .voix .txt-corps { color: #111; font-size: 10pt; line-height: 1.45; }
}
