/* ==========================================================================
   PandaCodeur : fiches d'exercices corriges
   Le corrige se deplie au clic. Le depliage repose sur <details>, donc il
   fonctionne sans JavaScript : le texte reste accessible et indexable.
   ========================================================================== */

:root {
  --pc-ex-accent: #e2571e;
  --pc-ex-ok: #1b7e3c;
  --pc-ex-bord: rgba(0, 0, 0, .13);
  --pc-ex-code: #16222e;
}

/* ------------------------------------------------------------- en-tete */
.pc-fiche-intro {
  padding: 18px 20px;
  margin: 0 0 26px;
  border-left: 4px solid var(--pc-ex-accent);
  border-radius: 0 9px 9px 0;
  background: rgba(226, 87, 30, .06);
  font-size: 1rem;
  line-height: 1.7;
}

.pc-fiche-intro p { margin: 0 0 10px; }
.pc-fiche-intro p:last-child { margin: 0; }

.pc-fiche-barre {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 0 0 24px;
}

.pc-fiche-compte {
  font-size: .8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
  opacity: .6;
  margin-right: auto;
}

.pc-fiche-tout {
  font-size: .84rem;
  font-weight: 700;
  padding: 8px 16px;
  border: 1px solid var(--pc-ex-bord);
  border-radius: 7px;
  background: #fff;
  color: inherit;
  cursor: pointer;
}

.pc-fiche-tout:hover { border-color: var(--pc-ex-accent); color: var(--pc-ex-accent); }

/* ------------------------------------------------------- titre de partie */
.pc-partie {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 40px 0 18px !important;
  padding: 0 0 10px !important;
  border-bottom: 2px solid rgba(226, 87, 30, .3) !important;
  font-size: 1.3rem !important;
  font-weight: 800 !important;
}

.pc-partie-n {
  flex: 0 0 auto;
  font-size: .72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--pc-ex-accent);
}

/* ---------------------------------------------------------- un exercice */
.pc-exo {
  margin: 0 0 18px;
  border: 1px solid var(--pc-ex-bord);
  border-radius: 11px;
  background: #fff;
  overflow: hidden;
}

.pc-exo-tete {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  padding: 17px 20px 0;
}

.pc-exo-num {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--pc-ex-accent);
  color: #fff;
  font-size: .92rem;
  font-weight: 800;
}

.pc-exo-titre {
  margin: 4px 0 0 !important;
  font-size: 1.06rem !important;
  font-weight: 700 !important;
  line-height: 1.4 !important;
}

.pc-exo-enonce {
  padding: 12px 20px 17px;
  font-size: .97rem;
  line-height: 1.7;
}

.pc-exo-enonce p { margin: 0 0 10px; }
.pc-exo-enonce p:last-child { margin: 0; }

/* ---------------------------------------------------- bouton du corrige */
.pc-sol { border-top: 1px solid var(--pc-ex-bord); }

.pc-sol > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 20px;
  cursor: pointer;
  font-size: .92rem;
  font-weight: 700;
  color: var(--pc-ex-ok);
  background: rgba(27, 126, 60, .05);
  list-style: none;
  user-select: none;
  transition: background-color .15s ease;
}

.pc-sol > summary::-webkit-details-marker { display: none; }
.pc-sol > summary:hover { background: rgba(27, 126, 60, .1); }
.pc-sol > summary:focus-visible { outline: 2px solid var(--pc-ex-ok); outline-offset: -2px; }

/* chevron, dessine en CSS */
.pc-sol-fleche {
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform .2s ease;
}

.pc-sol[open] .pc-sol-fleche { transform: rotate(-135deg) translate(-2px, -2px); }

/* un seul des deux libelles s'affiche */
.pc-sol[open] .pc-sol-voir,
.pc-sol:not([open]) .pc-sol-masquer { display: none; }

.pc-sol-corps {
  padding: 18px 20px 20px;
  border-top: 1px solid rgba(27, 126, 60, .18);
  font-size: .95rem;
  line-height: 1.7;
}

.pc-sol-corps > p { margin: 0 0 11px; }
.pc-sol-corps > p:last-child { margin: 0; }

.pc-sol-titre {
  font-size: .71rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--pc-ex-ok);
  margin: 0 0 10px !important;
}

/* ------------------------------------------------------------- le code */
.pc-code {
  margin: 0 0 16px;
  padding: 16px 18px;
  border-radius: 9px;
  background: var(--pc-ex-code);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.pc-code code {
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas,
               "DejaVu Sans Mono", monospace;
  font-size: .845rem;
  line-height: 1.62;
  color: #e6edf3;
  white-space: pre;
  background: none;
  padding: 0;
  border: 0;
}

/* code court au fil du texte */
.pc-exo-enonce code,
.pc-sol-corps > p code,
.pc-fiche-intro code {
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, .06);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .88em;
  color: inherit;
}

/* --------------------------------------------------------- rappel final */
.pc-fiche-suite {
  margin: 36px 0 10px;
  padding: 20px 22px;
  border: 2px solid var(--pc-ex-bord);
  border-radius: 12px;
}

.pc-fiche-suite h2 {
  font-size: 1.18rem !important;
  font-weight: 800 !important;
  margin: 0 0 14px !important;
  padding: 0 !important;
  border: 0 !important;
}

.pc-fiche-liens {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  grid-auto-rows: 1fr;
  gap: 13px;
}

.pc-fiche-lien {
  display: flex;
  flex-direction: column;
  padding: 14px 16px;
  border: 1px solid var(--pc-ex-bord);
  border-radius: 9px;
  text-decoration: none;
  color: inherit;
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.pc-fiche-lien:hover {
  border-color: var(--pc-ex-accent);
  box-shadow: 0 8px 20px rgba(0, 0, 0, .09);
  transform: translateY(-3px);
  color: inherit;
  text-decoration: none;
}

.pc-fiche-lien-t { font-weight: 700; font-size: .96rem; margin-bottom: 4px; }
.pc-fiche-lien-d { font-size: .83rem; line-height: 1.5; opacity: .76; flex: 1; }

/* ---------------------------------------------------------- responsive */
@media (max-width: 575.98px) {
  .pc-exo-tete { padding: 14px 14px 0; gap: 10px; }
  .pc-exo-enonce { padding: 10px 14px 14px; font-size: .93rem; }
  .pc-sol > summary { padding: 12px 14px; }
  .pc-sol-corps { padding: 15px 14px 16px; }
  .pc-code { padding: 13px 13px; }
  .pc-code code { font-size: .78rem; }
  .pc-partie { font-size: 1.12rem !important; }
  .pc-fiche-suite { padding: 16px 15px; }
  .pc-fiche-liens { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .pc-sol-fleche, .pc-fiche-lien, .pc-sol > summary { transition: none !important; }
}

/* Le titre du theme est tres grand : sur un ecran etroit, un mot long
   comme « enregistrements » depasse la colonne. On autorise la coupure
   et on reduit la taille sous 576 px. */
.pc-fiche h1 {
  overflow-wrap: break-word;
  word-wrap: break-word;
  hyphens: auto;
}

@media (max-width: 575.98px) {
  .pc-fiche h1 { font-size: 1.6rem !important; line-height: 1.25 !important; }
}

/* l'impression deplie tout : une fiche imprimee doit etre complete */
@media print {
  .pc-sol-corps { display: block !important; }
  .pc-fiche-tout, .pc-sol-fleche { display: none !important; }
  .pc-code { background: #f4f4f4; }
  .pc-code code { color: #111; }
}

/* ==========================================================================
   Fiches existantes
   Les pages d'exercices deja en ligne gardent leur balisage : on ne fait
   que l'habiller, pour qu'elles adoptent la meme presentation que les
   fiches recentes. Rien n'est deplace, rien n'est reecrit.
   ========================================================================== */

.pc-fiche .col-content { font-size: .98rem; line-height: 1.72; }

.pc-fiche .col-content p { margin: 0 0 12px; }

/* titres de section : les h2 « row-title » du theme */
.pc-fiche h2.row-title {
  font-size: 1.22rem !important;
  font-weight: 800 !important;
  margin: 0 0 14px !important;
  padding: 0 0 9px !important;
  border-bottom: 2px solid rgba(226, 87, 30, .28) !important;
}

.pc-fiche h3 { font-size: 1.06rem !important; font-weight: 700 !important; }

/* blocs de code deja presents dans ces pages */
.pc-fiche pre {
  margin: 0 0 16px;
  padding: 16px 18px;
  border: 0;
  border-radius: 9px;
  background: var(--pc-ex-code);
  color: #e6edf3;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas,
               "DejaVu Sans Mono", monospace;
  font-size: .845rem;
  line-height: 1.62;
  white-space: pre;
}

.pc-fiche pre code,
.pc-fiche pre * {
  background: none !important;
  color: inherit !important;
  font-family: inherit;
  font-size: inherit;
  padding: 0;
  border: 0;
}

/* code court au fil du texte */
.pc-fiche :not(pre) > code {
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, .06);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .88em;
  color: inherit;
}

/* les tableaux colles depuis un traitement de texte debordent sur mobile */
.pc-fiche table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-collapse: collapse;
}

.pc-fiche table tbody { display: table; width: 100%; }
.pc-fiche table td,
.pc-fiche table th { border: 1px solid var(--pc-ex-bord); padding: 7px 10px; }

.pc-fiche img { max-width: 100%; height: auto; border-radius: 8px; }

/* ------------------------------- le corrige, replie par defaut ---------- */
.pc-sol-fiche {
  margin: 26px 0 18px;
  border: 1px solid var(--pc-ex-bord);
  border-radius: 11px;
  background: #fff;
  overflow: hidden;
}

.pc-sol-fiche > summary { border-radius: 0; }

/* a l'interieur du corrige, les row-container du theme perdent leur
   marge : le cadre du corrige fournit deja l'espacement */
.pc-sol-fiche .pc-sol-corps > .row-container { padding: 0 !important; }
.pc-sol-fiche .pc-sol-corps > .row-container > .row-content { padding: 0 !important; }
.pc-sol-fiche .pc-sol-corps > .row-container:not(:last-child) { margin-bottom: 18px; }

/* Les blocs de correction portaient les fonds du theme (row-highlighted,
   row-separated). Dans le cadre du corrige, ce fond fait doublon et
   donnait ce vert etrange derriere le code. */
.pc-sol-corps .row-container,
.pc-sol-corps .row-content {
  background: none !important;
  background-color: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

.pc-sol-corps h2.row-title { margin-top: 0 !important; }

/* Le theme peint en vert les blocs marques « row-highlighted ». Sur une
   fiche, ce fond tombait derriere un enonce ou un corrige au hasard de la
   mise en page d'origine, sans rien signifier. On le neutralise : la
   hierarchie de la page vient desormais du cadre des corriges et des
   blocs de code. */
.pc-fiche .row-highlighted:not(.container),
.pc-fiche .row-highlighted.container > .row-content,
.pc-fiche .row-separated:not(.container),
.pc-fiche .row-separated.container > .row-content {
  background: none !important;
  background-color: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  color: inherit !important;
}

.pc-fiche .row-highlighted h1,
.pc-fiche .row-highlighted h2,
.pc-fiche .row-highlighted h3 { color: inherit !important; }

/* ------------------------------------------------- rappel de cours (TD) --
   Encadre court place entre l'enonce et le corrige : la notion a connaitre
   pour traiter l'exercice. Classe additive, aucune page existante ne
   l'utilise. */
.pc-rappel {
  margin: 12px 0 14px;
  padding: 12px 16px;
  border-radius: 8px;
  background: rgba(27, 126, 60, .06);
  border: 1px solid rgba(27, 126, 60, .22);
  border-left: 4px solid #1b7e3c;
  font-size: .95rem;
}
.pc-rappel-t {
  margin: 0 0 7px;
  font-weight: 700;
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #15682f;
}
.pc-rappel p { margin: 0 0 9px; }
.pc-rappel p:last-child,
.pc-rappel ul:last-child,
.pc-rappel pre:last-child { margin-bottom: 0; }
.pc-rappel ul { margin: 0 0 9px; padding-left: 22px; }
.pc-rappel li { margin-bottom: 5px; }
.pc-rappel li:last-child { margin-bottom: 0; }
.pc-rappel .pc-code { margin: 9px 0; font-size: .82rem; }

@media (max-width: 575.98px) {
  .pc-rappel { padding: 10px 13px; font-size: .9rem; }
}


/* ------------------------------------------------------------------
   Enonces numerotes, resultats encadres et formules centrees.
   Ajoute pour la fiche de TD sur le codage des nombres ; sert aussi
   aux fiches deja en ligne qui employaient ces classes sans style.
   ------------------------------------------------------------------ */
.pc-enonce-liste { margin: 0 0 14px; padding-left: 26px; }
.pc-enonce-liste li { margin-bottom: 7px; }
.pc-enonce-liste li:last-child { margin-bottom: 0; }

.pc-resultat {
  margin: 16px 0;
  padding: 12px 16px;
  border-radius: 8px;
  background: rgba(27, 126, 60, .08);
  border: 1px solid rgba(27, 126, 60, .28);
  border-left: 4px solid var(--pc-ex-ok, #1b7e3c);
}
.pc-resultat:first-child { margin-top: 0; }
.pc-resultat:last-child { margin-bottom: 0; }

.pc-formule {
  margin: 16px 0;
  padding: 12px 16px;
  border-radius: 8px;
  text-align: center;
  background: rgba(0, 0, 0, .05);
  border: 1px solid rgba(0, 0, 0, .1);
  font-size: 1.01rem;
}
.pc-formule:last-child { margin-bottom: 0; }

.pc-partie-chapeau {
  margin: -6px 0 18px;
  font-size: .93rem;
  line-height: 1.6;
  opacity: .82;
}

@media (max-width: 575.98px) {
  .pc-formule { font-size: .92rem; padding: 10px 12px; }
  .pc-resultat { padding: 10px 13px; font-size: .93rem; }
}
