/* Calculateur de coefficients BTS — la Martellière
   Charte : Open Sans, orange #fba617 / #fdc875, bleu canard #00676c / #008790 */

@font-face {
  font-family: "Open Sans";
  src: url("fonts/open-sans-latin-wght-normal.woff2") format("woff2");
  font-weight: 300 800;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Open Sans";
  src: url("fonts/open-sans-latin-ext-wght-normal.woff2") format("woff2");
  font-weight: 300 800;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --teal: #00676c;
  --teal-2: #008790;
  --teal-wash: #e3f0f0;
  --orange: #fba617;
  --orange-2: #fdc875;
  --orange-wash: #fff3dc;
  --ink: #132a2c;
  --muted: #4f6a6c;
  --paper: #f3f6f6;
  --surface: #ffffff;
  --line: #d3e0e0;
  --line-strong: #a9c2c3;
  --ok: #00676c;
  --warn: #b26a00;
  --bad: #b3261e;
  --focus: #fba617;
  --radius-s: 6px;
  --radius-m: 12px;
  --shadow: 0 1px 0 rgba(19, 42, 44, 0.06), 0 8px 24px -16px rgba(0, 72, 76, 0.35);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --teal: #5fc0c5;
    --teal-2: #3aa7ae;
    --teal-wash: #12393b;
    --orange: #fba617;
    --orange-2: #fdc875;
    --orange-wash: #3a2b10;
    --ink: #e6f0f0;
    --muted: #9db6b7;
    --paper: #0d1b1c;
    --surface: #142829;
    --line: #26413f;
    --line-strong: #3d5d5c;
    --ok: #5fc0c5;
    --warn: #fdc875;
    --bad: #ff8a80;
    --shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 10px 30px -18px rgba(0, 0, 0, 0.8);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --teal: #5fc0c5;
  --teal-2: #3aa7ae;
  --teal-wash: #12393b;
  --orange-wash: #3a2b10;
  --ink: #e6f0f0;
  --muted: #9db6b7;
  --paper: #0d1b1c;
  --surface: #142829;
  --line: #26413f;
  --line-strong: #3d5d5c;
  --ok: #5fc0c5;
  --warn: #fdc875;
  --bad: #ff8a80;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Open Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  font-feature-settings: "kern";
}
.num { font-variant-numeric: tabular-nums lining-nums; }
a { color: var(--teal); text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.wrap { max-width: 1160px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 720px) { .wrap { padding: 0 32px; } }

/* ---------- Bandeau ---------- */
.topbar {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.topbar .wrap {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: 60px;
}
.brand {
  display: flex; align-items: baseline; gap: 10px;
  color: var(--ink); text-decoration: none;
}
.brand-name { font-weight: 800; font-size: 1.05rem; color: var(--teal); letter-spacing: -0.01em; }
.brand-app { color: var(--muted); font-size: 0.92rem; }
.switcher { display: flex; gap: 4px; }
.switcher a {
  padding: 6px 12px; border-radius: 999px;
  color: var(--ink); text-decoration: none; font-weight: 600; font-size: 0.92rem;
}
.switcher a:hover { background: var(--teal-wash); }
.switcher a[aria-current="page"] { background: var(--teal); color: var(--surface); }
@media (max-width: 520px) { .brand-app { display: none; } }

/* ---------- En-tête de page ---------- */
.intro { padding: 40px 0 8px; }
.intro .bts {
  display: inline-block; margin: 0 0 10px;
  font-weight: 800; color: var(--teal); font-size: 1rem;
}
.intro h1 {
  margin: 0 0 12px;
  font-size: clamp(1.9rem, 1.2rem + 2.6vw, 3rem);
  line-height: 1.08; letter-spacing: -0.025em; font-weight: 800;
  max-width: 22ch;
}
.intro p { margin: 0; max-width: 64ch; color: var(--muted); }

/* ---------- Choix du statut ---------- */
.statut {
  margin: 28px 0 0;
  display: grid; gap: 10px;
}
.statut legend { font-weight: 700; padding: 0; margin-bottom: 10px; }
.statut fieldset { border: 0; padding: 0; margin: 0; }
.statut-options { display: grid; gap: 10px; }
@media (min-width: 760px) { .statut-options { grid-template-columns: 1fr 1fr; } }
.statut-option {
  position: relative; display: block; cursor: pointer;
  padding: 14px 16px 14px 46px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m);
}
.statut-option input { position: absolute; opacity: 0; }
.statut-option::before {
  content: ""; position: absolute; left: 16px; top: 17px;
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--line-strong); background: var(--surface);
}
.statut-option:has(input:checked) { border-color: var(--teal); box-shadow: inset 0 0 0 1px var(--teal); }
.statut-option:has(input:checked)::before { border-color: var(--teal); background: radial-gradient(circle, var(--teal) 0 5px, var(--surface) 6px); }
.statut-option:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.statut-option strong { display: block; font-weight: 700; }
.statut-option span { display: block; color: var(--muted); font-size: 0.9rem; }

/* ---------- Graphique des poids ---------- */
.poids {
  margin: 32px 0 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 18px 18px 14px;
  box-shadow: var(--shadow);
}
.poids-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 20px; align-items: baseline; margin-bottom: 14px; }
.poids-head h2 { margin: 0; font-size: 1.05rem; font-weight: 700; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 0; padding: 0; list-style: none; font-size: 0.86rem; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 6px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.swatch.general { background: var(--teal); }
.swatch.pro { background: var(--orange); }
.swatch.vide { background: repeating-linear-gradient(135deg, var(--line-strong) 0 2px, transparent 2px 6px); border: 1px solid var(--line-strong); }

.ribbon {
  position: relative;
  display: flex; gap: 3px;
  height: 168px;
  padding-left: 30px;
}
.ribbon-axis {
  position: absolute; left: 0; top: 0; bottom: 34px; width: 26px;
  font-size: 0.72rem; color: var(--muted);
}
.ribbon-axis span { position: absolute; right: 4px; transform: translateY(-50%); }
.seg {
  position: relative; min-width: 0;
  display: flex; flex-direction: column;
  border: 0; padding: 0; margin: 0; background: none; cursor: pointer; color: inherit; font: inherit; text-align: left;
}
.seg-bar {
  position: relative; flex: 1;
  border-radius: 4px 4px 2px 2px;
  background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--line-strong) 55%, transparent) 0 2px, transparent 2px 7px);
  box-shadow: inset 0 0 0 1px var(--line);
  overflow: hidden;
}
.seg-fill {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 0%;
  background: var(--teal);
  transition: height 0.35s cubic-bezier(.2,.7,.2,1);
}
.seg.pro .seg-fill { background: var(--orange); }
.seg-label {
  height: 34px; padding-top: 6px;
  font-size: 0.74rem; line-height: 1.15; color: var(--muted);
  overflow: hidden;
}
.seg-label b { display: block; color: var(--ink); font-weight: 700; font-size: 0.8rem; }
.seg:hover .seg-bar, .seg.is-active .seg-bar { box-shadow: inset 0 0 0 2px var(--ink); }
.threshold {
  position: absolute; left: 30px; right: 0;
  bottom: calc(34px + (100% - 34px) * 0.5);
  border-top: 2px dashed var(--ink);
  pointer-events: none;
}
.threshold span {
  position: absolute; right: 0; top: -22px;
  font-size: 0.74rem; font-weight: 700; background: var(--surface); padding: 0 4px;
}
.poids-foot { margin: 10px 0 0; font-size: 0.86rem; color: var(--muted); }
@media (max-width: 560px) {
  .seg-label { font-size: 0; }
  .seg-label b { font-size: 0.72rem; }
}

/* ---------- Disposition principale ---------- */
.layout { display: grid; gap: 28px; margin: 32px 0 48px; }
@media (min-width: 980px) {
  .layout { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
}

.section-title { font-size: 1.25rem; font-weight: 800; margin: 0 0 4px; letter-spacing: -0.01em; }
.section-sub { margin: 0 0 16px; color: var(--muted); font-size: 0.94rem; max-width: 64ch; }

/* ---------- Liste des épreuves ---------- */
.epreuves { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.ep {
  border-bottom: 1px solid var(--line);
  padding: 16px 0;
  scroll-margin-top: 16px;
}
.ep.is-active { background: linear-gradient(90deg, var(--teal-wash), transparent 70%); }
.ep-main {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  grid-template-areas: "code titre note" "code mode mode";
  gap: 8px 14px; align-items: start;
}
@media (min-width: 720px) {
  .ep-main {
    grid-template-columns: 64px minmax(0, 1fr) auto 112px;
    grid-template-areas: "code titre mode note";
    align-items: center;
  }
}
.ep-code {
  grid-area: code;
  display: grid; place-items: center;
  height: 48px; border-radius: var(--radius-s);
  font-weight: 800; font-size: 1rem; line-height: 1;
  color: var(--teal); background: var(--teal-wash);
  text-align: center;
}
.ep.pro .ep-code { color: #6b4300; background: var(--orange-wash); }
:root[data-theme="dark"] .ep.pro .ep-code { color: var(--orange-2); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ep.pro .ep-code { color: var(--orange-2); } }
.ep-titre { grid-area: titre; min-width: 0; }
.ep-titre h3 { margin: 0; font-size: 1rem; font-weight: 700; line-height: 1.35; }
.ep-meta { margin: 2px 0 0; font-size: 0.88rem; color: var(--muted); }
.ep-meta .coef { font-weight: 700; color: var(--ink); }

.ep-mode { grid-area: mode; }
.seg-ctrl {
  display: inline-flex; padding: 3px; gap: 2px;
  border-radius: 999px; background: var(--paper); border: 1px solid var(--line);
}
.seg-ctrl label { position: relative; cursor: pointer; }
.seg-ctrl input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg-ctrl span {
  display: block; padding: 5px 12px; border-radius: 999px;
  font-size: 0.85rem; font-weight: 600; color: var(--muted); white-space: nowrap;
}
.seg-ctrl input:checked + span { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.12), inset 0 0 0 1px var(--line-strong); }
.seg-ctrl input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 1px; }
.mode-fixe {
  display: inline-block; padding: 5px 12px; border-radius: 999px;
  font-size: 0.85rem; font-weight: 600; color: var(--muted);
  border: 1px dashed var(--line-strong);
}

.ep-note { grid-area: note; display: flex; align-items: center; gap: 6px; justify-self: end; }
.ep-note input {
  width: 72px; height: 44px; padding: 0 10px;
  font: inherit; font-size: 1.1rem; font-weight: 700; text-align: right;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius-s);
  -moz-appearance: textfield; appearance: textfield;
}
.ep-note input::-webkit-outer-spin-button, .ep-note input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.ep-note input:focus { border-color: var(--teal); outline: 3px solid var(--focus); outline-offset: 1px; }
.ep-note input[aria-invalid="true"] { border-color: var(--bad); }
.ep-note .sur { color: var(--muted); font-size: 0.9rem; }

.ep-more { margin: 10px 0 0 0; }
@media (min-width: 720px) { .ep-more { margin-left: 78px; } }
.ep-more summary {
  cursor: pointer; list-style: none; display: block;
  font-size: 0.9rem; font-weight: 600; color: var(--teal);
}
.ep-more summary::-webkit-details-marker { display: none; }
.ep-more summary::before {
  content: ""; display: inline-block; margin: 0 10px 2px 2px; vertical-align: middle; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(-45deg); transition: transform 0.2s;
}
.ep-more[open] summary::before { transform: rotate(45deg); }
.ep-resume { color: var(--muted); font-weight: 400; }
.ep-detail {
  margin: 10px 0 0; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--teal);
  border-radius: var(--radius-s);
  font-size: 0.93rem; max-width: 70ch;
}
.ep.pro .ep-detail { border-left-color: var(--orange); }
.ep-detail .duree { margin: 0 0 6px; font-weight: 700; }
.ep-detail ul { margin: 0; padding-left: 18px; }
.ep-detail li + li { margin-top: 4px; }
.ep-detail .warn { margin: 8px 0 0; color: var(--warn); font-weight: 600; }
.ep-detail.flash { animation: flash 0.5s ease-out; }
@keyframes flash { from { background: var(--teal-wash); } to { background: var(--surface); } }

.groupe-head {
  margin: 0; padding: 14px 0 0; border-bottom: 0;
  font-size: 0.88rem; color: var(--muted);
}
.groupe-head strong { color: var(--ink); }

/* ---------- Facultatives ---------- */
.facultatives { margin-top: 40px; }
.fac-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.fac {
  display: grid; grid-template-columns: 58px minmax(0, 1fr) auto; gap: 6px 14px; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
@media (min-width: 720px) { .fac { grid-template-columns: 64px minmax(0, 1fr) 112px; } }
.fac .ep-code { grid-area: auto; height: 40px; font-size: 0.9rem; background: transparent; border: 1px solid var(--line-strong); color: var(--muted); }
.fac h3 { margin: 0; font-size: 0.97rem; font-weight: 700; }
.fac p { margin: 2px 0 0; font-size: 0.86rem; color: var(--muted); }
.fac .ep-note { grid-area: auto; }

/* ---------- Résultat ---------- */
.resultat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m);
  box-shadow: var(--shadow); padding: 20px;
}
@media (min-width: 980px) { .resultat { position: sticky; top: 16px; } }
.resultat h2 { margin: 0 0 12px; font-size: 1rem; font-weight: 700; }
.moyenne { display: flex; align-items: baseline; gap: 6px; margin: 0; }
.moyenne-val { font-size: 3.6rem; font-weight: 800; line-height: 1; letter-spacing: -0.04em; }
.moyenne-sur { font-size: 1.2rem; color: var(--muted); font-weight: 600; }
.verdict {
  margin: 12px 0 0; padding: 10px 12px; border-radius: var(--radius-s);
  font-weight: 700; font-size: 0.95rem;
  background: var(--paper); color: var(--muted);
}
.verdict.ok { background: var(--teal-wash); color: var(--ok); }
.verdict.ctrl { background: var(--orange-wash); color: var(--warn); }
.verdict.ko { background: color-mix(in srgb, var(--bad) 12%, var(--surface)); color: var(--bad); }
.verdict small { display: block; font-weight: 400; color: var(--ink); margin-top: 2px; font-size: 0.86rem; }
.stats { margin: 16px 0 0; display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; font-size: 0.92rem; }
.stats dt { color: var(--muted); }
.stats dd { margin: 0; font-weight: 700; text-align: right; }
.besoin {
  margin: 16px 0 0; padding-top: 14px; border-top: 1px solid var(--line);
  font-size: 0.92rem;
}
.besoin strong { font-size: 1.15rem; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 14px; border-radius: 999px;
  font: inherit; font-size: 0.9rem; font-weight: 600; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  text-decoration: none;
}
.btn:hover { border-color: var(--teal); color: var(--teal); }
.btn.primary { background: var(--teal); border-color: var(--teal); color: var(--surface); }
.btn.primary:hover { background: var(--teal-2); color: var(--surface); }

/* Barre compacte mobile */
.mini-result {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--line);
  box-shadow: 0 -8px 24px -18px rgba(0,0,0,.5);
}
.mini-result .val { font-size: 1.5rem; font-weight: 800; }
.mini-result .lbl { font-size: 0.85rem; color: var(--muted); }
@media (min-width: 980px) { .mini-result { display: none; } }
@media (max-width: 979px) { body.calc { padding-bottom: 72px; } }

/* ---------- Notes de bas de page ---------- */
.notes {
  border-top: 1px solid var(--line); padding: 24px 0 40px; color: var(--muted); font-size: 0.86rem;
}
.notes h2 { font-size: 0.95rem; color: var(--ink); margin: 0 0 8px; }
.notes ul { margin: 0 0 12px; padding-left: 18px; max-width: 90ch; }
.notes li + li { margin-top: 4px; }

/* ---------- Accueil ---------- */
.home-intro { padding: 56px 0 12px; }
.home-intro h1 {
  margin: 0 0 14px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.04;
  font-size: clamp(2.2rem, 1.3rem + 3.6vw, 3.8rem); max-width: 16ch;
}
.home-intro p { margin: 0; max-width: 60ch; color: var(--muted); font-size: 1.05rem; }
.choix { display: grid; gap: 18px; margin: 36px 0 56px; }
@media (min-width: 860px) { .choix { grid-template-columns: 1fr 1fr; } }
.choix-item {
  display: block; text-decoration: none; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m);
  padding: 22px; box-shadow: var(--shadow);
  transition: border-color 0.15s;
}
.choix-item:hover { border-color: var(--teal); }
.choix-item .sigle { font-size: 2.6rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1; color: var(--teal); }
.choix-item h2 { margin: 6px 0 4px; font-size: 1.15rem; font-weight: 700; }
.choix-item p { margin: 0; color: var(--muted); font-size: 0.94rem; }
.choix-item .go { margin-top: 16px; font-weight: 700; color: var(--teal); }
.mini-ribbon { display: flex; gap: 3px; height: 54px; margin: 18px 0 6px; align-items: flex-end; }
.mini-ribbon div { border-radius: 3px 3px 1px 1px; background: var(--teal); }
.mini-ribbon div.pro { background: var(--orange); }
.mini-ribbon-labels { display: flex; gap: 3px; font-size: 0.7rem; color: var(--muted); }
.mini-ribbon-labels span { overflow: hidden; white-space: nowrap; text-align: center; }

.home-how { margin: 0 0 56px; display: grid; gap: 18px; }
@media (min-width: 860px) { .home-how { grid-template-columns: repeat(3, 1fr); } }
.home-how h3 { margin: 0 0 4px; font-size: 1rem; }
.home-how p { margin: 0; color: var(--muted); font-size: 0.94rem; }

/* ---------- Impression ---------- */
@media print {
  .topbar .switcher, .statut, .actions, .mini-result, .ep-more summary::before { display: none !important; }
  body { background: #fff; color: #000; }
  .poids, .resultat { box-shadow: none; }
  .ep-more:not([open]) { display: none; }
  .layout { grid-template-columns: 1fr 260px; }
}

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