/*
 * Épicentrix — styles
 * SPDX-License-Identifier: AGPL-3.0-or-later
 *
 * Mise en page : panneau de réglages à gauche, aperçu des feuilles A4
 * à droite sur un fond de papier millimétré (comme un enregistreur).
 * Les feuilles gardent toujours des couleurs « papier » fixes ;
 * seule l'interface suit le thème clair / sombre.
 */

:root {
  --fond: #e7eaee;
  --quadrillage: rgba(120, 132, 148, 0.16);
  --panneau: #f7f8fa;
  --encre: #1b2129;
  --doux: #5a6573;
  --trait: #cdd3db;
  --accent: #b3261e;
  --accent-encre: #ffffff;
  --champ: #ffffff;
  --focus: #1f4fc4;
  --police-titre: 'Charter', 'Bitstream Charter', 'Sitka Text', Cambria, 'Georgia', serif;
  --police-ui: system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans', sans-serif;
  --police-feuille: 'Liberation Sans', Arial, Helvetica, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --fond: #13171c;
    --quadrillage: rgba(150, 165, 185, 0.08);
    --panneau: #1b2027;
    --encre: #e4e8ed;
    --doux: #9aa5b2;
    --trait: #2e3640;
    --accent: #e8695d;
    --accent-encre: #1b0f0e;
    --champ: #12161b;
    --focus: #7aa2ff;
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --fond: #13171c;
  --quadrillage: rgba(150, 165, 185, 0.08);
  --panneau: #1b2027;
  --encre: #e4e8ed;
  --doux: #9aa5b2;
  --trait: #2e3640;
  --accent: #e8695d;
  --accent-encre: #1b0f0e;
  --champ: #12161b;
  --focus: #7aa2ff;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
html,
body {
  margin: 0;
  height: 100%;
}
body {
  background: var(--fond);
  color: var(--encre);
  font: 14px/1.45 var(--police-ui);
}
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.appli {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  height: 100%;
}

/* ---------- Panneau ---------- */

.panneau {
  background: var(--panneau);
  border-right: 1px solid var(--trait);
  overflow-y: auto;
  padding: 20px 20px 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.marque {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.marque h1 {
  margin: 0;
  font: 600 26px/1.1 var(--police-titre);
  letter-spacing: -0.01em;
}
.marque h1 img {
  display: block;
  flex: none;
}
.marque h1 {
  display: flex;
  align-items: center;
  gap: 10px;
}
.marque svg {
  width: 100%;
  height: 22px;
  display: block;
}
.marque p {
  margin: 0;
  color: var(--doux);
  font-size: 13px;
}

.groupe {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-top: 1px solid var(--trait);
  padding-top: 14px;
}
.groupe > h2 {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--doux);
}
.reglage {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.reglage > label,
.reglage > .etiquette {
  font-weight: 600;
  font-size: 13px;
}
.aide {
  color: var(--doux);
  font-size: 12px;
  margin: 0;
}
input[type='text'],
select {
  font: inherit;
  color: var(--encre);
  background: var(--champ);
  border: 1px solid var(--trait);
  border-radius: 6px;
  padding: 7px 9px;
  width: 100%;
}
.ligne-code {
  display: flex;
  gap: 6px;
}
.ligne-code input {
  font-family: ui-monospace, 'DejaVu Sans Mono', Menlo, Consolas, monospace;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
}
button {
  font: inherit;
  cursor: pointer;
}
.bouton {
  border: 1px solid var(--trait);
  background: var(--champ);
  color: var(--encre);
  border-radius: 6px;
  padding: 7px 11px;
  white-space: nowrap;
}
.bouton:hover {
  border-color: var(--doux);
}
.bouton-principal {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-encre);
  font-weight: 600;
  padding: 10px 14px;
}
.bouton-principal:hover {
  filter: brightness(1.06);
  border-color: var(--accent);
}

.segments {
  display: flex;
  border: 1px solid var(--trait);
  border-radius: 6px;
  overflow: hidden;
}
.segments label {
  flex: 1;
  text-align: center;
  padding: 6px 4px;
  cursor: pointer;
  border-left: 1px solid var(--trait);
  font-size: 13px;
  background: var(--champ);
}
.segments label:first-child {
  border-left: 0;
}
.segments label {
  position: relative; /* garde le bouton radio masqué à l'intérieur du panneau */
}
.segments input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}
.segments label:has(input:checked) {
  background: var(--encre);
  color: var(--panneau);
  font-weight: 600;
}
.segments label:has(input:focus-visible) {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}

.cases {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.cases label {
  display: flex;
  gap: 8px;
  align-items: baseline;
  font-size: 13px;
  cursor: pointer;
}
.cases input {
  accent-color: var(--accent);
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.retour {
  min-height: 1.2em;
  font-size: 12px;
  color: var(--doux);
  margin: 0;
}
.pied {
  margin-top: auto;
  font-size: 12px;
  color: var(--doux);
}
.pied a {
  color: inherit;
}

/* ---------- Aperçu ---------- */

.apercu {
  overflow: auto;
  padding: 24px;
  background-color: var(--fond);
  background-image: linear-gradient(var(--quadrillage) 1px, transparent 1px),
    linear-gradient(90deg, var(--quadrillage) 1px, transparent 1px);
  background-size: 8px 8px;
}
.resume {
  max-width: 210mm;
  margin: 0 auto 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  align-items: baseline;
  color: var(--doux);
  font-size: 13px;
}
.resume strong {
  color: var(--encre);
  font-family: ui-monospace, 'DejaVu Sans Mono', Menlo, Consolas, monospace;
  letter-spacing: 0.08em;
}
.erreur {
  max-width: 210mm;
  margin: 0 auto;
  padding: 14px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--panneau);
}
.separateur {
  max-width: 210mm;
  margin: 8px auto 14px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--doux);
}

/* ---------- Feuilles (couleurs papier fixes) ---------- */

.feuille {
  width: 210mm;
  min-height: 297mm;
  margin: 0 auto 24px;
  padding: 12mm 13mm;
  background: #ffffff;
  color: #111111;
  font: 10pt/1.35 var(--police-feuille);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), 0 6px 20px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  gap: 2.6mm;
}
.feuille h1 {
  margin: 0;
  font-size: 16pt;
  line-height: 1.2;
}
.feuille h2 {
  margin: 1mm 0 0;
  font-size: 11pt;
}
.feuille p {
  margin: 0;
}
.feuille [contenteditable='true']:hover {
  outline: 1px dashed #9db3d8;
  outline-offset: 2px;
}
.feuille [contenteditable='true']:focus {
  outline: 1px solid #1f4fc4;
  outline-offset: 2px;
}

.entete-eleve {
  display: flex;
  gap: 5mm;
  align-items: baseline;
  font-size: 10pt;
}
.entete-eleve .champ {
  display: flex;
  gap: 2mm;
  flex: 1;
  align-items: baseline;
}
.entete-eleve .champ:last-of-type {
  flex: 0.6;
}
.entete-eleve .ligne {
  flex: 1;
  border-bottom: 1px dotted #555555;
  min-width: 10mm;
}
.pastille-version {
  border: 1.5px solid #111111;
  border-radius: 1mm;
  padding: 0.6mm 2.5mm;
  font-weight: 700;
  white-space: nowrap;
}
.bandeau-corrige {
  color: #b3261e;
  font-weight: 700;
  font-size: 15pt;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1.5mm;
}
.figure figcaption {
  font-weight: 700;
  font-size: 10pt;
}
.figure-cadre {
  display: flex;
  justify-content: center;
}
.sismo-svg {
  width: 100%;
  height: auto;
  display: block;
}
.carte-svg {
  width: 160mm;
  max-width: 100%;
  height: auto;
  display: block;
}
.graphe-svg {
  max-width: 100%;
  height: auto;
  display: block;
}
.legende-doc {
  font-weight: 700;
  font-size: 10pt;
}
.tableau-etroit {
  max-width: 130mm;
}
.tables-mesures {
  display: flex;
  flex-wrap: wrap;
  gap: 6mm;
  align-items: flex-start;
}
.tables-mesures > .tableau-cadre {
  flex: 1;
  min-width: 0;
}
.tableau-mesures {
  font-size: 9pt;
}
.tableau-mesures th,
.tableau-mesures td {
  padding-block: 0.6mm;
}
.tableau-mesures thead th {
  font-size: 8pt;
}
.legende-tableau {
  font-weight: 700;
  font-size: 9.5pt;
  padding-bottom: 1mm;
  text-align: left;
}
.tableau-echelle {
  font-size: 9.5pt;
}
.tableau-resultats.tableau-echelle td {
  text-align: left;
}
.tableau-resultats.tableau-echelle tbody th {
  width: 18mm;
}
.tableau-roches {
  font-size: 9pt;
}
.tableau-horizontal th[scope='row'] {
  width: auto;
  text-align: left;
  font-size: 9pt;
  white-space: nowrap;
}
.tableau-horizontal td {
  min-width: 9mm;
}
.tableau-horizontal td.a-remplir {
  height: 9mm;
}
.options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.figure-export {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
  font: 12px var(--police-ui);
  color: #5a6573;
}
.figure-export button {
  border: 1px solid #cdd3db;
  background: #ffffff;
  color: #1b2129;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 12px;
}
.figure-export button:hover {
  border-color: #5a6573;
}

.rappel {
  border: 1px solid #b9c6d8;
  background: #f1f5fb;
  padding: 2mm 3mm;
  font-size: 9.5pt;
  border-radius: 1mm;
}

.tableau-cadre {
  overflow-x: auto;
}
.tableau-resultats {
  width: 100%;
  border-collapse: collapse;
  font-size: 10pt;
  font-variant-numeric: tabular-nums;
}
.tableau-resultats th,
.tableau-resultats td {
  border: 1px solid #333333;
  padding: 1.2mm 1.5mm;
  text-align: center;
  vertical-align: middle;
}
.tableau-resultats thead th {
  background: #e9eef5;
  font-size: 9pt;
  font-weight: 700;
}
.tableau-resultats tbody th {
  font-weight: 700;
  width: 16%;
}
.tableau-resultats td.a-remplir {
  height: 8mm;
}
.tableau-resultats.compact td.a-remplir {
  height: 6.8mm;
}
.tableau-resultats.compact th,
.tableau-resultats.compact td {
  padding-block: 0.8mm;
}
.tableau-resultats tr.ligne-exemple td {
  background: #f3f5f8;
  font-style: italic;
  color: #333333;
}
.note-exemple {
  font-size: 9.5pt;
  font-style: italic;
  color: #333333;
}
.drapeau-p,
.drapeau-s {
  display: inline-block;
  color: #ffffff;
  font-size: 8.5pt;
  line-height: 1;
  padding: 0.5mm 1mm;
  border-radius: 0.6mm;
}
.drapeau-p {
  background: #d32f2f;
}
.drapeau-s {
  background: #1f4fc4;
}
.tableau-resultats td.reponse {
  color: #1f4fc4;
  font-weight: 700;
}

/* Répartition mondiale : extrait du fichier vu dans un tableur, fiche méthode. */
.tableau-resultats.tableau-extrait {
  font-size: 8.5pt;
}
.tableau-extrait th,
.tableau-extrait td {
  padding: 0.6mm 1.2mm;
}
.tableau-resultats.tableau-extrait .colonne-tableur {
  background: #eef0f3;
  color: #555555;
  font-weight: 400;
  width: 7mm;
  text-align: center;
}
.tableau-extrait .titre-col {
  font-weight: 700;
  background: #e9eef5;
}
.aide-feuille {
  font-size: 9pt;
  font-style: italic;
}
.fiche-methode .titre-fiche {
  font-weight: 700;
  margin-bottom: 1mm;
}
.fiche-methode ol {
  margin: 0;
  padding-left: 5mm;
  display: flex;
  flex-direction: column;
  gap: 0.6mm;
}

.questions {
  margin: 0;
  padding-left: 6mm;
  display: flex;
  flex-direction: column;
  gap: 1.4mm;
}
.questions li::marker {
  font-weight: 700;
}
.questions.reponses li::marker {
  color: #b3261e;
}
.questions .reponse + .reponse {
  margin-top: 0.6mm;
}
.vigilance {
  margin: 0;
  padding-left: 5mm;
  font-size: 9pt;
  display: flex;
  flex-direction: column;
  gap: 0.8mm;
}
.sources-compactes {
  margin: 2mm 0 0;
  font-size: 7.5pt;
  line-height: 1.3;
  color: #444;
}
.liste-cercles {
  margin: 0 auto;
  width: 160mm;
  max-width: 100%;
  padding-left: 5mm;
  font-variant-numeric: tabular-nums;
}

/* Grand écran : seuls le panneau et l'aperçu défilent, jamais la page entière. */
@media screen and (min-width: 861px) {
  html,
  body {
    overflow: hidden;
  }
}

/* ---------- Petits écrans ---------- */

@media (max-width: 860px) {
  .appli {
    display: block;
    height: auto;
  }
  .panneau {
    border-right: 0;
    border-bottom: 1px solid var(--trait);
    overflow: visible;
    padding-inline: 16px;
  }
  .apercu {
    padding: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

/* ---------- Impression ---------- */

@page {
  size: A4;
  margin: 10mm 12mm;
}
@media print {
  html,
  body {
    height: auto;
    background: #ffffff;
  }
  .appli {
    display: block;
    height: auto;
  }
  .panneau,
  .ecran-seul,
  .resume,
  .separateur {
    display: none !important;
  }
  .apercu {
    overflow: visible;
    padding: 0;
    background: none;
  }
  .drapeau-p,
  .drapeau-s {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
  .feuille {
    width: auto;
    min-height: 0;
    margin: 0;
    padding: 0;
    box-shadow: none;
    break-after: page;
  }
  .feuille:last-child {
    break-after: auto;
  }
  .figure {
    break-inside: avoid;
  }
  .graphe-svg {
    max-width: none;
  }
  .carte-svg {
    width: 160mm !important;
    height: 120mm !important;
    max-width: none;
  }
  .feuille [contenteditable='true']:hover,
  .feuille [contenteditable='true']:focus {
    outline: none;
  }
}
/* Tableau horizontal à nombreuses colonnes (zone d'ombre, 11–12 stations) */
.tableau-horizontal.serre th,
.tableau-horizontal.serre td {
  font-size: 8.5pt;
  padding-inline: 0.6mm;
}
.tableau-horizontal.serre td {
  min-width: 7mm;
}
/* Tableau en deux blocs (foyers de la zone de subduction) */
.tableau-horizontal tr.bloc-suivant th,
.tableau-horizontal tr.bloc-suivant td {
  border-top: 2px solid #555555;
}
.tableau-horizontal td.vide {
  background: #f4f4f4;
}
/* Boutons d'action et listes déroulantes : jamais plus larges que le panneau */
.actions .bouton {
  white-space: normal;
  text-align: center;
  line-height: 1.25;
}
.panneau select {
  width: 100%;
  max-width: 100%;
  text-overflow: ellipsis;
}

/* ---------- Exercice en ligne (panneau et relevé des copies) ---------- */

.ligne-mdp {
  display: flex;
  gap: 8px;
  align-items: center;
}
input[type='password'] {
  font: inherit;
  color: var(--encre);
  background: var(--champ);
  border: 1px solid var(--trait);
  border-radius: 6px;
  padding: 7px 9px;
  width: 100%;
}
.ligne-mdp input {
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
}
.voir-mdp {
  flex: none;
  display: inline-flex;
  gap: 4px;
  align-items: center;
  font-size: 12px;
  white-space: nowrap;
}
.avertissement {
  margin: 0;
  font-size: 12px;
  border-left: 3px solid var(--accent);
  padding: 4px 8px;
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}
#lien-eleve {
  font-family: ui-monospace, 'DejaVu Sans Mono', Menlo, Consolas, monospace;
  font-size: 11px;
}
.actions-ligne {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}
.pastille-enligne {
  background: #1f4fc4;
  color: #ffffff;
  border-radius: 10px;
  padding: 0 8px;
}
.visuellement-cache {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
body.releve-ouvert {
  overflow: hidden;
}
.releve {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(10, 14, 20, 0.55);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 24px 16px;
  overflow: auto;
}
.releve-boite {
  background: var(--panneau);
  color: var(--encre);
  border-radius: 8px;
  width: min(1200px, 100%);
  padding: 16px 20px 20px;
  display: grid;
  gap: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}
.releve-tete {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.releve-tete h2 {
  margin: 0;
  font: 700 20px var(--police-titre);
}
.depot {
  display: block;
  border: 2px dashed var(--trait);
  border-radius: 8px;
  padding: 22px 16px;
  text-align: center;
  cursor: pointer;
}
.depot.survol,
.depot:focus-within,
.depot:hover {
  border-color: var(--focus);
  background: color-mix(in srgb, var(--focus) 6%, transparent);
}
.saisie-code {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.saisie-code .etiquette {
  width: 100%;
  font-weight: 600;
  font-size: 13px;
}
.saisie-code input {
  width: auto;
  flex: 1 1 220px;
}
.saisie-code input.code {
  flex: 0 1 150px;
  font-family: ui-monospace, 'DejaVu Sans Mono', Menlo, Consolas, monospace;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.releve-tableau {
  overflow-x: auto;
}
.table-releve {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
}
.table-releve th,
.table-releve td {
  border: 1px solid var(--trait);
  padding: 4px 6px;
  text-align: center;
  vertical-align: middle;
}
.table-releve thead th {
  background: color-mix(in srgb, var(--trait) 45%, transparent);
}
.table-releve tbody th {
  text-align: left;
}
.table-releve td.aides,
.table-releve td.controle {
  text-align: left;
  font-size: 12px;
  color: var(--doux);
  max-width: 220px;
}
.table-releve tr.a-verifier td.controle {
  color: var(--accent);
}
.table-releve td.note {
  font-weight: 700;
}
.table-releve select {
  width: auto;
  padding: 3px 4px;
  color: #111111;
}
.table-releve select.niveau-0 {
  background: #f8d7d3;
}
.table-releve select.niveau-1 {
  background: #fbe7c6;
}
.table-releve select.niveau-2 {
  background: #e3f0cf;
}
.table-releve select.niveau-3 {
  background: #c9e6c3;
}
.table-releve select.modifie {
  outline: 2px solid var(--focus);
}
.bouton.petit {
  padding: 2px 8px;
}
@media print {
  .releve {
    display: none !important;
  }
}
