/* calcul.pro — une feuille de cahier à petits carreaux, avec sa marge rouge,
   et le résultat imprimé comme le ticket d'une calculatrice. */
:root {
  --papier: #fcfcfa;
  --carreau: #e6ebf3;
  --ligne-cahier: #d3dbe8;
  --encre: #1e2b58;
  --encre-claire: #e8ecf6;
  --marge: #d83a3a;
  --texte: #1f2430;
  --doux: #5a6275;
  --ticket: #ffffff;
  --titres: Bahnschrift, "DIN Alternate", "DIN Next", "Roboto Condensed", "Arial Narrow", system-ui, sans-serif;
  /* Noms gardés pour l'admin et le tableau des statistiques */
  --fond: var(--papier);
  --carte: #ffffff;
  --trait: var(--ligne-cahier);
  --accent: var(--encre);
  --accent-clair: var(--encre-claire);
  --erreur: #b3261e;
  --rayon: 4px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  color: var(--texte);
  background-color: var(--papier);
  background-image:
    linear-gradient(var(--carreau) 1px, transparent 1px),
    linear-gradient(90deg, var(--carreau) 1px, transparent 1px);
  background-size: 22px 22px;
  font: 17px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--encre); text-underline-offset: 2px; }
a:hover { color: var(--marge); }
:focus-visible { outline: 2px solid var(--marge); outline-offset: 2px; }

h1, h2, h3 { font-family: var(--titres); color: var(--encre); font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 2.15rem; line-height: 1.15; margin: .5em 0 .35em; }
h2 { font-size: 1.4rem; line-height: 1.25; margin: 1.9em 0 .5em; }
h3 { font-size: 1.1rem; margin: 1.4em 0 .3em; }
.cadre { max-width: 880px; margin: 0 auto; padding: 0 16px; }
.chapeau { font-size: 1.1rem; color: var(--doux); margin-top: 0; max-width: 62ch; }
p, li { max-width: 72ch; }

/* En-tête : la bande d'encre */
.haut { background: var(--encre); color: #fff; }
.haut .cadre { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 26px; padding-top: 12px; padding-bottom: 12px; }
.logo { color: #fff; text-decoration: none; font-family: var(--titres); font-weight: 600; font-size: 1.45rem; display: flex; align-items: center; gap: 9px; }
.logo:hover { color: #fff; }
.logo-ext { opacity: .65; font-weight: 400; }
.logo-signe { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 3px; background: #fff; color: var(--encre); font-size: 1.3rem; line-height: 1; box-shadow: 3px 3px 0 var(--marge); }
.menu { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 18px; }
.menu a { color: #fff; text-decoration: none; font-size: .95rem; opacity: .88; }
.menu a:hover { opacity: 1; color: #fff; text-decoration: underline; text-decoration-color: var(--marge); text-decoration-thickness: 2px; }

/* La page : la marge rouge du cahier court le long du contenu */
main.cadre { border-left: 2px solid rgba(216, 58, 58, .55); padding-left: 26px; padding-bottom: 8px; background: rgba(252, 252, 250, .55); }
.ariane { font-size: .85rem; color: var(--doux); margin: 0; padding-top: 16px; }
.ariane a { color: var(--doux); }

/* Le formulaire : une fiche posée sur le cahier */
.calc {
  background: #f1f4f9;
  border: 1px solid var(--ligne-cahier);
  border-radius: var(--rayon);
  padding: 20px;
  margin: 22px 0 10px;
}
.champs { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px 18px; }
.champ label, .champ .etiquette { display: block; font-weight: 600; font-size: .95rem; margin-bottom: 4px; }
.champ small { display: block; color: var(--doux); font-size: .8rem; margin-top: 3px; }
.saisie { display: flex; align-items: stretch; }
.saisie input, .saisie select, .champ > select, .champ > input, .champ textarea {
  width: 100%;
  font: inherit;
  font-variant-numeric: tabular-nums;
  padding: 9px 11px;
  border: 1px solid #aeb8c9;
  border-radius: 3px;
  background: #fff;
  color: var(--texte);
  min-width: 0;
}
.champ textarea { resize: vertical; }
.saisie input:focus, .champ select:focus, .champ input:focus, .champ textarea:focus { outline: 2px solid var(--encre); outline-offset: 0; border-color: var(--encre); }
.saisie .unite { display: grid; place-items: center; padding: 0 10px; background: var(--encre-claire); border: 1px solid #aeb8c9; border-left: 0; border-radius: 0 3px 3px 0; color: var(--encre); font-weight: 600; font-size: .9rem; white-space: nowrap; }
.saisie:has(.unite) input { border-radius: 3px 0 0 3px; }
.choix { display: flex; flex-wrap: wrap; gap: 6px; }
.choix label { font-weight: 400; display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border: 1px solid #aeb8c9; border-radius: 3px; cursor: pointer; margin: 0; background: #fff; }
.choix label:has(input:checked) { border-color: var(--encre); background: var(--encre); color: #fff; font-weight: 600; }
.choix input { margin: 0; accent-color: var(--marge); }
.bouton { font: inherit; font-weight: 600; padding: 10px 20px; border: 0; border-radius: 3px; background: var(--encre); color: #fff; cursor: pointer; box-shadow: 3px 3px 0 var(--marge); }
.bouton:hover, .bouton:focus-visible { background: var(--encre-claire); color: var(--encre); }
a.bouton { display: inline-block; text-decoration: none; }
.bouton:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--marge); }

/* Le résultat : le ticket de la calculatrice, bord dentelé en bas */
.resultat {
  display: block;
  position: relative;
  margin: 20px 0 22px;
  padding: 16px 18px 14px;
  background: var(--ticket);
  border-top: 2px dashed var(--ligne-cahier);
  filter: drop-shadow(0 1px 1.5px rgba(30, 43, 88, .22));
  font-variant-numeric: tabular-nums;
}
.resultat::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -10px;
  height: 10px;
  background:
    linear-gradient(135deg, var(--ticket) 50%, transparent 50%) 0 0 / 16px 10px repeat-x,
    linear-gradient(225deg, var(--ticket) 50%, transparent 50%) 0 0 / 16px 10px repeat-x;
}
.resultat:empty { display: none; }
.resultat .grand { font-family: var(--titres); font-size: 1.9rem; font-weight: 600; line-height: 1.2; color: var(--encre); margin-bottom: 6px; }
.resultat .ligne { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 5px 0; border-top: 1px dotted #b9c3d4; }
.resultat .ligne b { white-space: nowrap; color: var(--encre); }
.resultat .note { color: var(--doux); font-size: .9rem; margin: 8px 0 0; }
.resultat.erreur { color: var(--erreur); border-top-color: var(--marge); }
.resultat table { margin: 6px 0; }

/* Contenu */
.formule { background: #fff; border-left: 3px solid var(--encre); padding: 10px 14px; border-radius: 0 3px 3px 0; font-family: var(--titres); font-size: 1.02rem; font-variant-numeric: tabular-nums; overflow-x: auto; }
table { border-collapse: collapse; width: 100%; background: #fff; font-size: .95rem; margin: 10px 0; font-variant-numeric: tabular-nums; }
th, td { border: 1px solid var(--ligne-cahier); padding: 7px 10px; text-align: left; }
th { background: var(--encre-claire); color: var(--encre); font-weight: 600; }
.tableau { overflow-x: auto; }
details { background: #fff; border: 1px solid var(--ligne-cahier); border-radius: 3px; padding: 10px 14px; margin: 8px 0; }
summary { font-weight: 600; cursor: pointer; color: var(--encre); }
details[open] summary { margin-bottom: 4px; }
details p:last-child { margin-bottom: 0; }

/* Les listes de calculs : des lignes de cahier, un pictogramme en marge */
.picto { width: 28px; height: 28px; flex: none; color: var(--encre); }
.picto.grand { width: 34px; height: 34px; }
.avec-picto { display: flex; align-items: center; gap: 12px; }
.avec-picto a { color: inherit; text-decoration: none; }
.avec-picto a:hover { color: var(--marge); }
.liste-calculs { list-style: none; padding: 0; margin: 12px 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); column-gap: 28px; border-top: 1px solid var(--ligne-cahier); }
.liste-calculs li { max-width: none; border-bottom: 1px solid var(--ligne-cahier); }
.liste-calculs a { display: flex; gap: 14px; align-items: flex-start; padding: 12px 4px; text-decoration: none; color: var(--texte); background: rgba(252, 252, 250, .9); }
.liste-calculs .picto { margin-top: 2px; }
.liste-calculs strong { display: block; font-family: var(--titres); font-weight: 600; font-size: 1.08rem; color: var(--encre); line-height: 1.3; }
.liste-calculs .texte > span { display: block; font-size: .87rem; color: var(--doux); line-height: 1.45; margin-top: 2px; }
.liste-calculs a:hover strong { text-decoration: underline; text-decoration-color: var(--marge); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.liste-calculs a:hover .picto { color: var(--marge); }
.rubrique h2 { margin-top: 1.6em; }

.maj { color: var(--doux); font-size: .85rem; margin-top: 28px; }
.voisines { border-top: 2px solid var(--encre); margin-top: 28px; }
.voisines h2 { margin-top: 16px; font-size: 1.2rem; }

/* Emplacements publicitaires : invisibles tant qu'ils sont vides */
.pub:empty { display: none; }
.pub { margin: 20px 0; text-align: center; }
/* Place réservée d'avance : la page ne saute pas quand l'annonce arrive (CLS) */
.pub:not(:empty) { min-height: 100px; }
.pub[data-emplacement="milieu"]:not(:empty) { min-height: 280px; margin: 28px 0; }
.pub:not(:empty)::before { content: "Publicité"; display: block; font-size: .7rem; color: var(--doux); margin-bottom: 4px; }

.bas { margin-top: 0; border-top: 3px double var(--ligne-cahier); color: var(--doux); font-size: .85rem; background: var(--papier); }
.bas .cadre { padding-top: 10px; padding-bottom: 14px; }
.bas a { color: var(--doux); }
.bas .version { opacity: .6; white-space: nowrap; }
.bas p { max-width: none; }

@media (max-width: 560px) {
  body { font-size: 16px; background-size: 18px 18px; }
  h1 { font-size: 1.6rem; }
  main.cadre { padding-left: 14px; margin-left: 8px; }
  .calc { padding: 14px; }
  .resultat .grand { font-size: 1.45rem; }
  .resultat { padding-left: 12px; padding-right: 12px; }
  .resultat table { font-size: .8rem; }
  .resultat th, .resultat td { padding: 5px 6px; white-space: nowrap; }
  .liste-calculs { grid-template-columns: 1fr; }
}

/* Clavier de la calculatrice et bouton secondaire */
.clavier { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 12px; }
.touche, .bouton {
  font: 600 1.05rem/1 var(--titres); color: var(--encre); background: #fff;
  border: 1px solid #aeb8c9; border-radius: 3px; padding: 12px 4px; cursor: pointer; min-height: 44px;
}
.touche:hover, .bouton:hover { border-color: var(--encre); }
.touche:active { background: var(--encre-claire); }
.touche.fonction { font-size: .92rem; color: var(--doux); }
.touche.egal { background: var(--encre); color: #fff; border-color: var(--encre); }
.touche.effacer { color: var(--marge); }
.bouton { padding: 10px 16px; margin-top: 12px; }
.calc .ecran { font: 600 1.35rem/1.3 var(--titres); text-align: right; font-variant-numeric: tabular-nums; }

/* Recherche dans l'en-tête */
.haut nav { flex-basis: 100%; }
.recherche { position: relative; flex: 1 1 220px; max-width: 380px; margin: 0; }
.recherche input {
  width: 100%; font: inherit; font-size: .95rem; padding: 7px 12px; border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, .35); background: rgba(255, 255, 255, .1); color: #fff;
}
.recherche input::placeholder { color: rgba(255, 255, 255, .7); }
.recherche input:focus { outline: 2px solid var(--marge); outline-offset: 1px; background: #fff; color: var(--texte); }
.suggestions {
  position: absolute; z-index: 10; top: calc(100% + 4px); left: 0; right: 0; margin: 0; padding: 4px 0;
  list-style: none; background: #fff; border: 1px solid var(--ligne-cahier); border-radius: 3px;
  box-shadow: 4px 4px 0 rgba(30, 43, 88, .18); max-width: none;
}
.suggestions li { max-width: none; }
.suggestions a { display: block; padding: 7px 12px; color: var(--encre); text-decoration: none; line-height: 1.3; }
.suggestions a span { display: block; font-size: .78rem; color: var(--doux); }
.suggestions a:hover, .suggestions a.actif { background: var(--encre-claire); }
.suggestions .vide { padding: 8px 12px; font-size: .9rem; color: var(--doux); }
.suggestions .vide a { display: inline; padding: 0; }

/* Partage et intégration */
.partager { display: block; }
details.integrer { margin: 18px 0; font-size: .92rem; }
details.integrer summary { cursor: pointer; color: var(--doux); }
details.integrer textarea { width: 100%; font: .82rem/1.4 ui-monospace, Consolas, monospace; padding: 8px; border: 1px solid #aeb8c9; border-radius: 3px; margin-top: 6px; }

/* Page intégrée sur un autre site : la fiche de calcul seule */
body.integre { background: #fff; }
body.integre .calc { margin: 0; }
body.integre .fourni { font-size: .82rem; color: var(--doux); margin: 8px 2px 0; }

/* Sur téléphone, le menu tient sur une ligne qui défile du doigt */
@media (max-width: 560px) {
  .haut .cadre { gap: 8px 14px; padding-top: 10px; padding-bottom: 8px; }
  .haut nav { min-width: 0; max-width: 100%; }
  .menu { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; scrollbar-width: none; white-space: nowrap; gap: 16px; padding: 4px 0 6px; -webkit-overflow-scrolling: touch; }
  .menu::-webkit-scrollbar { display: none; }
  .recherche { max-width: none; }
}

/* Boutons sous le résultat, et « Vos calculs » sur l'accueil */
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.actions .bouton { margin-top: 0; }
.favori[aria-pressed="true"] { color: var(--marge); border-color: var(--marge); }
#mes-calculs { background: #fff; border: 1px solid var(--ligne-cahier); border-radius: var(--rayon); padding: 4px 18px 10px; margin: 18px 0; }
#mes-calculs h2 { margin-top: .6em; }
#mes-calculs li span { color: var(--doux); font-size: .9rem; }
.lien-bouton { background: none; border: 0; padding: 0; font: inherit; color: var(--encre); text-decoration: underline; cursor: pointer; }

/* Calendrier annuel */
.calendrier { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 14px; margin: 18px 0; }
table.mois { width: 100%; font-size: .85rem; text-align: center; margin: 0; }
table.mois caption { font-family: var(--titres); font-weight: 600; color: var(--encre); padding: 4px 0; text-align: left; }
table.mois th, table.mois td { padding: 3px 0; }
table.mois .sem { color: var(--doux); font-size: .72rem; background: #f6f8fb; }
table.mois .we { color: var(--doux); background: #f6f8fb; }
table.mois .ferie { color: #fff; background: var(--marge); font-weight: 600; }

/* Impression : le calcul seul, sans le décor du site */
@media print {
  body { background: #fff; font-size: 11pt; }
  .haut, .bas, .pub, .ariane, .voisines, details.integrer, .actions, .bouton, .maj, #mes-calculs { display: none !important; }
  main.cadre { border: 0; padding: 0; max-width: none; background: none; }
  .calc { break-inside: avoid; background: #fff; }
  a { color: inherit; text-decoration: none; }
  .calendrier { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  table.mois { font-size: 8pt; break-inside: avoid; }
  table.mois .ferie { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* Encart partenaire (rubrique Commerce) */
.encart { background: #fff; border: 1px solid var(--ligne-cahier); border-left: 3px solid var(--marge); border-radius: 0 var(--rayon) var(--rayon) 0; padding: 6px 18px 12px; margin: 26px 0 10px; }
.encart h2 { margin-top: .3em; font-size: 1.2rem; }
.etiquette-encart { font-size: .75rem; color: var(--doux); margin: 6px 0 0; }

/* Saisie en tableau (une ligne par jour) */
.saisie-tableau td, .saisie-tableau th { padding: 5px 6px; }
.saisie-tableau input { width: 100%; min-width: 0; font: inherit; font-variant-numeric: tabular-nums; padding: 6px 7px; border: 1px solid #aeb8c9; border-radius: 3px; background: #fff; }
.saisie-tableau input:focus { outline: 2px solid var(--encre); outline-offset: 0; }
@media (max-width: 560px) { .saisie-tableau td, .saisie-tableau th { padding: 4px 3px; font-size: .85rem; } .saisie-tableau input { padding: 5px 3px; } }
