/* The exam screen, built like exam software: questions on the left, subject in the middle, answer on the right.
   Portrait tablets and phones: the questions become a strip on top, the answer a bar at the bottom.
   « Aa » enlarges every text of the exam (class .big). */
.exam { --fs: 18px; position: fixed; top: 0; right: 0; bottom: 0; left: 0; display: flex; flex-direction: column; background: var(--bg); -webkit-user-select: none; user-select: none; }
.exam.big { --fs: 21px; }
.training { background: #8a5a00; color: #fff; text-align: center; font-weight: 600; font-size: 14px; padding: 4px 8px; }

/* Header */
.xhead { display: flex; align-items: center; gap: 10px; padding: 0 14px; min-height: 58px; background: var(--head); color: #fff; flex: none; }
.xhead .who { line-height: 1.25; font-size: 14px; min-width: 0; }
.xhead .who b { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.xhead .who span { color: #b8c5d2; }
.xhead .paper { flex: 1; text-align: center; font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.xhead .btn { min-height: 40px; background: transparent; color: #fff; border-color: rgba(255, 255, 255, .35); font-size: 15px; padding: 0 12px; }
.xhead .btn:hover { border-color: #fff; }
.xhead .btn.finish { background: #fff; color: var(--head); border-color: #fff; }
.xhead .btn.fsbtn { border-color: #8fb7dc; }
.state { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; white-space: nowrap; color: #cfe0d6; }
.state.off { color: #ffd38a; }
.state.wait { color: #c9d4df; }
.timer { font-variant-numeric: tabular-nums; font-size: 22px; font-weight: 700; padding: 2px 12px; border: 1px solid rgba(255, 255, 255, .35); border-radius: var(--radius); min-width: 92px; text-align: center; }
.timer.soon { background: #a66300; border-color: #a66300; }
.timer.last { background: var(--bad); border-color: var(--bad); }

/* Body */
.xbody { flex: 1; display: grid; grid-template-columns: 236px minmax(0, 1fr) 300px; min-height: 0; }
.xnav { background: var(--surface); border-right: 1px solid var(--line); overflow: auto; -webkit-overflow-scrolling: touch; padding: 14px 12px; display: flex; flex-direction: column; gap: 10px; }
.navtitle { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.navpart { font-size: 13px; font-weight: 600; color: var(--ink-2); margin-top: 4px; }
.navgrid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.sq { min-height: 40px; border-radius: 4px; border: 1px solid var(--line-strong); background: #fff; font-weight: 700; font-size: 15px; color: var(--ink-2); cursor: pointer; font-variant-numeric: tabular-nums; padding: 0; }
.sq.done { background: var(--primary); border-color: var(--primary); color: #fff; }
.sq.seen { border-color: #d39a3a; background: #fff6e8; color: #8a5200; }
.sq.off { background: var(--surface-2); color: #a2abb6; text-decoration: line-through; }
.sq.cur { outline: 3px solid #5b9bd5; outline-offset: 1px; }
.legend { display: grid; gap: 4px; font-size: 13px; color: var(--ink-2); padding-top: 8px; border-top: 1px solid var(--line); }
.legend i { display: inline-block; width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--line-strong); vertical-align: -2px; margin-right: 6px; background: #fff; }
.legend i.done { background: var(--primary); border-color: var(--primary); }
.legend i.seen { background: #fff6e8; border-color: #d39a3a; }
.xnav .btn { margin-top: auto; }

.xmain { overflow: auto; -webkit-overflow-scrolling: touch; padding: 22px 26px 30px; }
.qcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; max-width: 900px; margin: 0 auto; }
.crumb { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 6px; }
.qtitle { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.qtitle h2 { margin: 0; font-size: calc(var(--fs) + 4px); }
.qtype { font-size: 14px; font-weight: 600; color: var(--primary); }
.qtype.off { color: var(--bad); }
.stem { font-size: var(--fs); line-height: 1.6; }
.props { list-style: none; margin: 18px 0 0; padding: 0; display: grid; gap: 8px; }
.prop { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); font-size: var(--fs); line-height: 1.5; cursor: pointer; background: #fff; }
.prop .let { flex: none; width: 30px; height: 30px; border-radius: 4px; border: 1px solid var(--line-strong); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; margin-top: 1px; }
.prop.on { border-color: var(--primary); background: var(--primary-soft); box-shadow: inset 4px 0 0 var(--primary); }
.prop.on .let { background: var(--primary); border-color: var(--primary); color: #fff; }
.prop.locked { cursor: default; }
.moves { display: flex; justify-content: space-between; gap: 12px; max-width: 900px; margin: 16px auto 0; }

/* The document of a group of questions: shown above each of its questions, can be folded */
.doc { border: 1px solid #c9d6e3; background: #f4f8fc; border-radius: var(--radius); margin-bottom: 18px; }
.doc-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; padding: 10px 14px; background: transparent; border: 0; cursor: pointer; text-align: left; font-weight: 700; font-size: 15px; color: var(--primary-dark); min-height: 46px; }
.doc-head .t { display: flex; align-items: center; gap: 8px; }
.doc-head .act { font-weight: 600; font-size: 14px; color: var(--primary); white-space: nowrap; }
.doc-body { padding: 0 14px 14px; font-size: calc(var(--fs) - 1px); line-height: 1.6; }
.doc.folded .doc-body { display: none; }

/* Answer panel */
.xpad { background: var(--surface); border-left: 1px solid var(--line); padding: 16px 14px; display: flex; flex-direction: column; gap: 10px; overflow: auto; }
.padtitle { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.hint { font-size: 15px; color: var(--ink-2); margin: 0; }
.letters { display: grid; gap: 8px; }
.lbtn { display: flex; align-items: center; gap: 12px; min-height: 58px; padding: 0 14px; border-radius: var(--radius); border: 2px solid var(--line-strong); background: #fff; cursor: pointer; font-size: 17px; font-weight: 600; text-align: left; }
.lbtn .l { width: 34px; height: 34px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--line-strong); display: inline-flex; align-items: center; justify-content: center; font-weight: 800; flex: none; }
.lbtn.on { border-color: var(--primary); background: var(--primary-soft); }
.lbtn.on .l { background: var(--primary); border-color: var(--primary); color: #fff; }
.yours { font-size: 15px; margin: 2px 0 0; }
.linkbtn { background: none; border: 0; color: var(--primary); font-weight: 600; cursor: pointer; padding: 6px 0; text-align: left; font-size: 15px; }
.xpad .next { margin-top: auto; }

/* Récapitulatif before handing in */
.recap { max-width: 900px; margin: 0 auto; }
.recap .stats { display: flex; gap: 10px; flex-wrap: wrap; margin: 6px 0 16px; }
.recap .stat { flex: 1 1 140px; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; background: var(--surface-2); }
.recap .stat b { display: block; font-size: 26px; font-variant-numeric: tabular-nums; }
.recap-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.ritem { border: 1px solid var(--line-strong); border-radius: var(--radius); background: #fff; padding: 8px 10px; text-align: left; cursor: pointer; min-height: 56px; }
.ritem b { display: block; font-size: 14px; color: var(--muted); }
.ritem span { font-weight: 700; font-size: 17px; }
.ritem.empty { border-color: #d39a3a; background: #fff6e8; }
.ritem.empty span { color: #8a5200; font-size: 14px; }
.ritem.off { background: var(--surface-2); color: #a2abb6; }
.recap .actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 20px; }
.recap .actions .btn { flex: 1 1 220px; }

/* Waiting room, end, alerts */
.screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.screen .card { max-width: 640px; width: 100%; }
.idtable { width: 100%; border-collapse: collapse; margin: 12px 0 16px; }
.idtable th, .idtable td { text-align: left; padding: 9px 0; border-bottom: 1px solid var(--line); }
.idtable th { color: var(--muted); font-weight: 500; width: 40%; }
.steps { margin: 0; padding-left: 20px; }
.steps li { margin: 6px 0; }
.waitline { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 14px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line); font-weight: 600; margin-top: 16px; }
.spin { width: 18px; height: 18px; border: 3px solid #c8d3de; border-top-color: var(--primary); border-radius: 50%; animation: spin 1s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.big-ico { width: 56px; height: 56px; }
.alert-back { position: fixed; top: 0; right: 0; bottom: 0; left: 0; background: rgba(120, 22, 16, .94); color: #fff; display: flex; align-items: center; justify-content: center; text-align: center; padding: 24px; z-index: 85; }
.alert-back .box { max-width: 520px; }
.alert-back h2 { font-size: 26px; margin: 0 0 12px; }
.alert-back .btn { background: #fff; color: var(--bad); border-color: #fff; margin-top: 18px; }

/* Medium screens: short labels in the header so the épreuve name stays readable */
@media (max-width: 1100px) {
  .xhead .state .txt, .xhead .aa .txt, .xhead .fsbtn .txt { display: none; }
}
/* Portrait tablets and phones */
@media (max-width: 899px) {
  .xbody { display: flex; flex-direction: column; }
  .xnav { flex-direction: row; align-items: center; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px; overflow-x: auto; overflow-y: hidden; flex: none; gap: 8px; }
  .navtitle, .navpart, .legend { display: none; }
  .navgrid { display: flex; gap: 6px; }
  .sq { min-width: 46px; flex: none; min-height: 44px; }
  .xnav .btn { margin: 0; flex: none; }
  .xmain { flex: 1; padding: 12px; }
  .qcard { padding: 16px; }
  .xpad { flex: none; border-left: 0; border-top: 1px solid var(--line); padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); gap: 8px; }
  .padtitle, .xpad .hint { display: none; }
  .letters { display: flex; gap: 8px; }
  .lbtn { flex: 1 1 0; justify-content: center; min-height: 54px; padding: 0; }
  .lbtn .txt { display: none; }
  .yours, .linkbtn { display: none; }
  .xpad .next { margin: 0; }
  .moves { display: none; }
}
@media (max-width: 600px) {
  .xhead { padding: 0 8px; gap: 6px; min-height: 52px; }
  .xhead .who, .xhead .state .txt, .xhead .fsbtn .txt, .xhead .aa .txt { display: none; }
  .xhead .paper { font-size: 14px; text-align: left; }
  .timer { font-size: 18px; min-width: 70px; padding: 2px 6px; }
  .xhead .btn { padding: 0 9px; font-size: 14px; }
}
