/* =====================================================================
   Chrono d'examen — styles propres à l'outil
   S'appuie sur otoolia.css (variables --ot-*, .ot-btn, .ot-panel, .ot-chip…).
   Tout est préfixé .ex pour ne jamais toucher à l'en-tête ni au pied de page.
   ===================================================================== */

.ex {
  --ex-orange: #d97706;
  --ex-red: #dc2626;
  --ex-read: #0891b2;
  --ex-done: var(--ot-text-soft);
  position: relative;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ex { --ex-orange: #fbbf24; --ex-red: #f87171; --ex-read: #22d3ee; }
}
:root[data-theme="dark"] .ex { --ex-orange: #fbbf24; --ex-red: #f87171; --ex-read: #22d3ee; }

.ex-head h1 { font-size: clamp(1.5rem, 3.4vw, 2.1rem); margin-bottom: .25em; }
.ex-head p { margin-bottom: var(--ot-space); }

/* ---------- Onglets ---------- */
.ex-tabs { display: flex; gap: 8px; margin-bottom: 12px; }

/* ---------- Mise en page ---------- */
.ex-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: var(--ot-space); align-items: start; }
.ex-layout > * { min-width: 0; overflow-wrap: break-word; }
.ex-stage { padding: var(--ot-space); display: flex; flex-direction: column; min-width: 0; }
.ex-side {
  position: sticky; top: 76px;              /* sous l'en-tête Otoolia (60 px) */
  max-height: calc(100vh - 92px); overflow-y: auto;
  padding: 6px var(--ot-space) var(--ot-space);
}
@media (max-width: 900px) {
  .ex-layout { grid-template-columns: 1fr; }
  .ex-side { position: static; max-height: none; overflow: visible; }
}
.ex-controls { justify-content: center; margin-top: 14px; }
.ex-controls .ot-btn--ghost[aria-pressed="true"] { background: var(--ot-brand); color: var(--ot-brand-ink); border-color: var(--ot-brand); }
.ex-theme-btn { display: none; }
.ex.ex-standalone .ex-theme-btn, .ex.is-fs .ex-theme-btn { display: inline-flex; }
.ex-hint { font-size: .8rem; color: var(--ot-text-soft); margin: 0; }
.ex-center { text-align: center; margin-top: 10px; }
.ex kbd { background: var(--ot-surface-2); border: 1px solid var(--ot-border); border-radius: 4px;
  padding: 0 5px; font: inherit; font-size: .9em; }

/* ---------- Tableau d'affichage ---------- */
.ex-board { --ex-scale: 1; display: flex; flex-direction: column; gap: calc(14px * var(--ex-scale)); }
.ex-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.ex-now { display: flex; align-items: center; gap: calc(16px * var(--ex-scale)); }
.ex-now__time { font-size: calc(clamp(2.4rem, 6vw, 4.2rem) * var(--ex-scale)); font-weight: 800; line-height: 1;
  font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.ex-now__date { color: var(--ot-text-soft); font-size: calc(.95rem * var(--ex-scale)); margin-top: 4px; }
.ex-place { font-size: calc(1.05rem * var(--ex-scale)); font-weight: 700; text-align: right; color: var(--ot-text-soft); }
.ex-analog { width: calc(clamp(120px, 17vw, 240px) * var(--ex-scale)); height: auto; flex: none; }
.ex-face { fill: var(--ot-surface); stroke: var(--ot-text); stroke-width: 2.5; }
.ex-tick { stroke: var(--ot-text-soft); stroke-width: .8; }
.ex-tick--h { stroke: var(--ot-text); stroke-width: 2; }
.ex-hand { stroke: var(--ot-text); stroke-linecap: round; }
.ex-hand--h { stroke-width: 4.5; }
.ex-hand--m { stroke-width: 3; }
.ex-hand--s { stroke: var(--ex-red); stroke-width: 1.2; }
.ex-pin { fill: var(--ex-red); }

.ex-message { padding: calc(10px * var(--ex-scale)) calc(14px * var(--ex-scale)); border-radius: var(--ot-radius-s);
  background: var(--ot-surface-2); border-left: 4px solid var(--ot-brand);
  font-size: calc(clamp(1.05rem, 1.8vw, 1.35rem) * var(--ex-scale)); white-space: pre-line; }
.ex-empty { text-align: center; color: var(--ot-text-soft); padding: 40px 0; }

.ex-exam { display: flex; flex-direction: column; gap: 8px; }
.ex-exam + .ex-exam { border-top: 1px solid var(--ot-border); padding-top: calc(12px * var(--ex-scale)); }
.ex-exam__head { display: flex; align-items: baseline; gap: 6px 14px; flex-wrap: wrap; }
.ex-exam__head h3 { margin: 0; font-size: calc(1.25rem * var(--ex-scale)); }
/* Informations de l'épreuve (repère, intitulé…) : grandes et contrastées, lisibles au fond de la salle */
.ex-exam__info { font-size: calc(clamp(1.35rem, 2.8vw, 2.2rem) * var(--ex-scale)); font-weight: 700; line-height: 1.25;
  white-space: pre-line; overflow-wrap: anywhere; color: var(--ot-text);
  padding: calc(10px * var(--ex-scale)) calc(16px * var(--ex-scale)); border-radius: var(--ot-radius-s);
  background: var(--ot-surface-2); border-left: calc(6px * var(--ex-scale)) solid var(--ot-brand); }
.ex-exam__info[hidden] { display: none; }
.ex-row-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.ex-exam__meta { color: var(--ot-text-soft); font-size: calc(.9rem * var(--ex-scale)); }
.ex-exam__rules { font-size: calc(.9rem * var(--ex-scale)); font-weight: 600; color: var(--ot-text-soft); white-space: pre-wrap; }

.ex-grid { display: grid; gap: calc(12px * var(--ex-scale));
  grid-template-columns: repeat(auto-fit, minmax(min(100%, calc(240px * var(--ex-scale))), 1fr)); }
.ex-card {
  --ex-c: var(--ot-brand);
  position: relative; border: 2px solid color-mix(in srgb, var(--ex-c) 45%, var(--ot-border));
  background: color-mix(in srgb, var(--ex-c) 6%, var(--ot-surface));
  border-radius: var(--ot-radius); padding: calc(12px * var(--ex-scale)) calc(16px * var(--ex-scale));
  display: flex; flex-direction: column; gap: 2px; min-width: 0; transition: border-color .3s, background .3s;
  container-type: inline-size;
}
.ex-card__head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ex-card__label { font-weight: 800; font-size: calc(1.1rem * var(--ex-scale)); overflow-wrap: anywhere; }
.ex-badge { font-size: calc(.75rem * var(--ex-scale)); font-weight: 800; padding: 2px 9px; border-radius: 999px;
  background: var(--ex-c); color: #fff; white-space: nowrap; }
:root[data-theme="dark"] .ex-badge { color: #0f0f17; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ex-badge { color: #0f0f17; } }
.ex-card__phase { font-size: calc(.75rem * var(--ex-scale)); text-transform: uppercase; letter-spacing: .1em;
  font-weight: 700; color: var(--ex-c); margin-top: 4px; }
/* La taille du compte à rebours suit la largeur de la carte (« 1:24:30 » doit tenir sur une ligne) */
.ex-card__big { --ex-big: clamp(2.4rem, 6vw, 4.2rem);
  font-size: min(calc(var(--ex-big) * var(--ex-scale)), 21cqi); font-weight: 800; line-height: 1.05;
  font-variant-numeric: tabular-nums; letter-spacing: -.02em; color: var(--ot-text); white-space: nowrap; }
.ex-board .ex-card__big.is-text { font-size: min(calc(clamp(1.3rem, 3vw, 2.2rem) * var(--ex-scale)), 9cqi);
  letter-spacing: 0; padding: .3em 0; white-space: normal; }
.ex-card__end { font-size: calc(1.15rem * var(--ex-scale)); font-weight: 700; }
.ex-card__sub { font-size: calc(.85rem * var(--ex-scale)); color: var(--ot-text-soft); min-height: 1.2em; }
.ex-bar { height: calc(8px * var(--ex-scale)); background: var(--ot-surface-2); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.ex-bar i { display: block; height: 100%; width: 0; background: var(--ex-c); border-radius: inherit; transition: width .3s linear; }

/* Taille du compte à rebours selon le nombre de lignes affichées */
.ex-board[data-size="xl"] .ex-card__big { --ex-big: clamp(3.4rem, 13vw, 10rem); }
.ex-board[data-size="xl"] .ex-card { padding: calc(20px * var(--ex-scale)) calc(26px * var(--ex-scale)); }
.ex-board[data-size="l"] .ex-card__big { --ex-big: clamp(2.8rem, 7.5vw, 7rem); }

.ex-card.is-idle { --ex-c: var(--ot-text-soft); }
.ex-card.is-reading { --ex-c: var(--ex-read); }
.ex-card.is-orange { --ex-c: var(--ex-orange); }
.ex-card.is-red { --ex-c: var(--ex-red); }
.ex-card.is-red .ex-card__big { color: var(--ex-red); }
.ex-card.is-done { --ex-c: var(--ex-done); }
.ex-card.is-paused { --ex-c: var(--ex-orange); border-style: dashed; }
.ex-card.is-paused .ex-card__big { opacity: .55; }
.ex-card.is-flash { animation: ex-flash 1s ease-in-out infinite; }
@keyframes ex-flash {
  50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--ex-c) 45%, transparent); background: color-mix(in srgb, var(--ex-c) 22%, var(--ot-surface)); }
}

/* ---------- Panneau de commande ---------- */
.ex-sec { border-top: 1px solid var(--ot-border); padding: 4px 0; }
.ex-sec:first-child { border-top: 0; }
.ex-sec > summary {
  list-style: none; cursor: pointer; user-select: none; display: flex; align-items: center; gap: 8px;
  padding: 8px 0; font-weight: 700; font-size: .92rem;
}
.ex-sec > summary::-webkit-details-marker { display: none; }
.ex-sec > summary::before { content: "▸"; color: var(--ot-text-soft); transition: transform .15s; }
.ex-sec[open] > summary::before { transform: rotate(90deg); }
.ex-sec > summary:hover { color: var(--ot-brand); }
.ex-sec__body { padding-bottom: 10px; display: flex; flex-direction: column; gap: 10px; }
.ex-field { display: flex; flex-direction: column; gap: 4px; font-size: .8rem; font-weight: 600; color: var(--ot-text-soft); min-width: 0; }
.ex-field > .ot-input, .ex-field > .ot-textarea, .ex-field > .ot-select { color: var(--ot-text); font-weight: 400; }
.ex .ot-input, .ex .ot-select { padding: 6px 10px; font-size: .9rem; min-height: 36px; }
.ex .ot-textarea { min-height: 80px; font-size: .9rem; }
.ex-two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; }
.ex-two .ex-num { width: 100%; text-align: left; }
.ex-dur { display: flex; align-items: center; gap: 4px; font-weight: 400; color: var(--ot-text-soft); }
.ex-num { width: 62px; text-align: right; }
.ex-time { width: 100%; }
.ex-check { display: flex; align-items: flex-start; gap: 8px; font-size: .88rem; cursor: pointer; }
.ex-check input { accent-color: var(--ot-brand); width: 16px; height: 16px; margin-top: 3px; flex: none; }
.ex-range input { accent-color: var(--ot-brand); width: 100%; }
.ex-btn-s { min-height: 34px; padding: 5px 14px; font-size: .85rem; }
.ex-full { width: 100%; }
.ex-danger { color: var(--ot-danger); }
.ex-warn-btn { background: var(--ex-orange); color: #1b1b29; }
.ex-big { font-size: 1.1rem; padding: 10px 36px; min-height: 48px; }
.ex-sec__body > .ex-btn-s { align-self: flex-start; }

.ex-exams { display: flex; flex-direction: column; gap: 12px; }
.ex-ed { border: 1px solid var(--ot-border); border-radius: var(--ot-radius); padding: 12px; display: flex; flex-direction: column; gap: 10px;
  background: var(--ot-surface); }
.ex-ed > .ex-btn-s { align-self: flex-start; }
.ex-preset { color: var(--ot-text-soft); }
.ex-rows { display: flex; flex-direction: column; gap: 8px; }
.ex-row { border: 1px solid var(--ot-border); border-radius: var(--ot-radius-s); padding: 8px; background: var(--ot-surface-2);
  display: flex; flex-direction: column; gap: 6px; }
.ex-row__top, .ex-row__opts, .ex-row__bottom { display: flex; align-items: center; gap: 6px; }
.ex-row__top .ot-input { flex: 1; min-width: 0; }
.ex-row__opts .ot-select { flex: 1; min-width: 0; }
.ex-val { display: inline-flex; align-items: center; gap: 4px; font-size: .85rem; color: var(--ot-text-soft); }
.ex-row__bottom { flex-wrap: wrap; }
.ex-total { font-size: .82rem; font-weight: 700; color: var(--ot-text); margin-right: auto; }
.ex-adj { display: inline-flex; align-items: center; gap: 4px; font-size: .75rem; color: var(--ot-text-soft); }
.ex-adj .ex-num { width: 56px; }
.ex-row-pause[aria-pressed="true"] { background: var(--ex-orange); color: #1b1b29; border-color: var(--ex-orange); }
.ex-del { width: 28px; height: 28px; flex: none; display: grid; place-items: center; border-radius: 50%; cursor: pointer;
  font: 700 16px/1 var(--ot-font); background: transparent; color: var(--ot-text-soft); border: 1px solid var(--ot-border); }
.ex-del:hover { color: #fff; background: var(--ot-danger); border-color: var(--ot-danger); }
.ex-ed__actions { gap: 8px; }

.ex-log { max-height: 220px; overflow-y: auto; border: 1px solid var(--ot-border); border-radius: var(--ot-radius-s); }
.ex-log__item { display: flex; gap: 8px; padding: 6px 10px; font-size: .8rem; border-bottom: 1px solid var(--ot-border); }
.ex-log__item:last-child { border-bottom: 0; }
.ex-log__item span { color: var(--ot-text-soft); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ex-log__item b { font-weight: 600; overflow-wrap: anywhere; }
.ex-log__empty { padding: 12px; text-align: center; font-size: .8rem; color: var(--ot-text-soft); }

/* ---------- Chronomètre ---------- */
.ex-chrono .ex-stage { align-items: center; padding: calc(var(--ot-space) * 2) var(--ot-space); }
.ex-sw { font-size: clamp(3rem, 14vw, 9rem); font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums;
  letter-spacing: -.03em; text-align: center; }
.ex-sw small { font-size: .45em; color: var(--ot-text-soft); }
.ex-laps { width: 100%; max-width: 520px; margin-top: 16px; max-height: 320px; overflow-y: auto; }

/* ---------- Tableaux (tours, texte d'aide) ---------- */
.ex-table { width: 100%; border-collapse: collapse; font-size: .9rem; font-variant-numeric: tabular-nums; }
.ex-table th, .ex-table td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--ot-border); }
.ex-table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ot-text-soft); }
.ex-laps__table tr.is-best td { color: var(--ot-success); font-weight: 700; }
.ex-laps__table tr.is-worst td { color: var(--ex-red); }
.ex-about .ex-table { margin: 0 0 1em; display: block; overflow-x: auto; }

/* ---------- Message temporaire ---------- */
.ex-toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); z-index: 90; opacity: 0; pointer-events: none;
  max-width: min(92vw, 640px); padding: 12px 20px; border-radius: var(--ot-radius); text-align: center;
  background: var(--ot-text); color: var(--ot-bg); font-weight: 700; box-shadow: var(--ot-shadow-h); transition: opacity .25s, transform .25s; }
.ex-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Plein écran et fenêtre de projection : seul le tableau est affiché ---------- */
.ex.is-fs, .ex.is-fakefs { background: var(--ot-bg); color: var(--ot-text); padding: calc(var(--ot-space) * 1.5); overflow: auto; }
.ex.is-fakefs { position: fixed; inset: 0; z-index: 50; }
.ex.is-fs .ex-tabs, .ex.is-fs .ex-side, .ex.is-fs .ex-hint, .ex.is-fs #ex-popup { display: none; }
.ex.is-fs .ex-layout { display: block; height: 100%; }
.ex.is-fs .ex-stage, .ex.is-fs .ex-chrono .ex-stage { border: 0; box-shadow: none; background: transparent; padding: 0; min-height: 100%; justify-content: center; }
.ex.is-fs .ex-chrono { height: 100%; }
.ex.is-fs .ex-controls { opacity: .25; transition: opacity .2s; }
.ex.is-fs .ex-controls:hover, .ex.is-fs .ex-controls:focus-within { opacity: 1; }
.ex.is-fs .ex-sw { font-size: clamp(4rem, 18vw, 16rem); }
.ex.is-fs .ex-board[data-size="xl"] .ex-card__big, html.ex-viewonly .ex-board[data-size="xl"] .ex-card__big { --ex-big: clamp(4rem, 17vw, 16rem); }
.ex.is-fs .ex-board[data-size="l"] .ex-card__big, html.ex-viewonly .ex-board[data-size="l"] .ex-card__big { --ex-big: clamp(3rem, 10vw, 10rem); }

html.ex-viewonly #ot-header, html.ex-viewonly #ot-footer, html.ex-viewonly .ex-head, html.ex-viewonly .ex-about,
html.ex-viewonly .ex-tabs, html.ex-viewonly .ex-side, html.ex-viewonly .ex-hint, html.ex-viewonly #ex-popup { display: none !important; }
html.ex-viewonly #ot-main { max-width: none; padding: var(--ot-space); }
html.ex-viewonly .ex-layout { display: block; }
html.ex-viewonly .ex-stage { border: 0; box-shadow: none; background: transparent; padding: 0; }
html.ex-viewonly .ex-controls { opacity: .3; }
html.ex-viewonly .ex-controls:hover { opacity: 1; }

/* ---------- Texte d'aide sous l'outil ---------- */
.ex-about { margin-top: calc(var(--ot-space) * 2.5); }

@media (max-width: 480px) {
  .ex-stage { padding: 10px; }
  .ex-place { text-align: left; }
  .ex-big { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .ex-card.is-flash { animation: none; outline: 4px solid var(--ex-c); }
  .ex-bar i { transition: none; }
}
