/* ============================================================
   404CTF writeups - Styles des widgets d'article
   ============================================================ */

/* ---- Barre de progression de lecture (haut de page) ---- */
.read-progress {
  position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 80;
  background: transparent; pointer-events: none; display: none;
}
.read-progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .12s linear; }

/* ---- Fiche épreuve ---- */
.challenge-card {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px; margin: 0 0 28px; border-radius: var(--r-md); overflow: hidden;
  background: var(--border); border: 1px solid var(--border);
}
.cc-cell { background: var(--surface); padding: 14px 16px; display: flex; flex-direction: column; gap: 3px; }
.cc-cell .cc-k { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); }
.cc-cell .cc-v { font-family: var(--font-mono); font-size: 14px; font-weight: 600; color: var(--ink); }
.cc-cell .cc-v.ok { color: var(--accent-ink); display: inline-flex; align-items: center; gap: 6px; }
.cc-cell .cc-v.ok svg { width: 14px; height: 14px; }
.cc-cell .cc-v.file { color: var(--accent-ink); word-break: break-all; font-size: 12.5px; }

/* ---- Visualisation des amplitudes ---- */
.amp-viz {
  margin: 26px 0; padding: 20px 22px 18px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--border);
}
.amp-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.amp-title { font-family: var(--font-display); font-size: 18px; font-weight: 700; }
.amp-sub { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.amp-fid { font-family: var(--font-mono); font-size: 13px; color: var(--muted); white-space: nowrap; }
.amp-fid b { font-size: 17px; color: var(--ink); font-variant-numeric: tabular-nums; }

.amp-chart { display: flex; gap: 14px; align-items: flex-end; padding: 4px 0; }
.amp-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 7px; min-width: 0; }
.amp-amp { font-family: var(--font-mono); font-size: 12.5px; font-weight: 600; color: var(--accent-ink); font-variant-numeric: tabular-nums; }
.amp-track {
  position: relative; width: 100%; max-width: 60px; height: 150px;
  background: var(--surface-2); border-radius: 7px 7px 0 0; overflow: hidden;
  border-bottom: 2px solid var(--border-strong);
}
.amp-target {
  position: absolute; left: 6px; right: 6px; bottom: 0;
  border: 1.5px dashed color-mix(in srgb, var(--accent) 55%, transparent);
  border-bottom: 0; border-radius: 4px 4px 0 0; background: var(--accent-12);
}
.amp-bar {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent) 75%, #000));
  border-radius: 6px 6px 0 0; transition: height .12s linear;
}
[data-theme="dark"] .amp-bar { background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent) 70%, #000)); }
.amp-ket { font-family: var(--font-mono); font-size: 13px; color: var(--ink); }
.amp-prob { font-family: var(--font-mono); font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

.amp-controls { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.amp-slider {
  flex: 1; -webkit-appearance: none; appearance: none; height: 4px; border-radius: 999px;
  background: var(--border-strong); outline: none;
}
.amp-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 17px; height: 17px; border-radius: 50%; background: var(--accent); cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,.25); }
.amp-slider::-moz-range-thumb { width: 17px; height: 17px; border: 0; border-radius: 50%; background: var(--accent); cursor: pointer; }
.amp-btn {
  font-family: var(--font-mono); font-size: 12.5px; font-weight: 600; cursor: pointer;
  padding: 8px 14px; border-radius: var(--r-sm); border: 1px solid var(--accent);
  background: var(--accent); color: var(--on-accent); transition: transform .12s, filter .15s; white-space: nowrap;
}
.amp-btn:hover { filter: brightness(1.05); transform: translateY(-1px); }
.amp-btn.ghost { background: transparent; color: var(--accent-ink); }
.amp-btn.ghost:hover { background: var(--accent-12); }
.amp-legend { display: flex; gap: 18px; margin-top: 12px; font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.amp-legend span { display: inline-flex; align-items: center; gap: 7px; }
.amp-legend .lg-now::before { content: ""; width: 14px; height: 9px; border-radius: 2px; background: var(--accent); }
.amp-legend .lg-tgt::before { content: ""; width: 14px; height: 9px; border-radius: 2px; border: 1.5px dashed color-mix(in srgb, var(--accent) 55%, transparent); }

/* ---- Matrice U ---- */
.umx-wrap { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; margin: 6px 0; }
.umx { position: relative; padding: 6px 18px; border-collapse: separate; border-spacing: 6px 3px; }
.umx::before, .umx::after { content: ""; position: absolute; top: 0; bottom: 0; width: 9px; border: 2px solid var(--ink-2); }
.umx::before { left: 0; border-right: 0; border-radius: 4px 0 0 4px; }
.umx::after { right: 0; border-left: 0; border-radius: 0 4px 4px 0; }
.umx td { font-family: var(--font-mono); font-size: 14px; text-align: right; min-width: 52px; padding: 2px 6px; font-variant-numeric: tabular-nums; }
.umx td.pos { color: var(--ink); }
.umx td.neg { color: #d6455b; }
[data-theme="dark"] .umx td.neg { color: #ff7a87; }
.umx td.zero { color: var(--faint); }
.umx-side { flex: 1; min-width: 200px; }
.umx-cap { font-family: var(--font-mono); font-size: 13px; color: var(--ink); margin-bottom: 5px; }
.umx-cap b { color: var(--accent-ink); font-size: 16px; }
.umx-note { font-size: 14px; color: var(--ink-2); margin: 0; line-height: 1.55; }

/* ---- Équations : outils + numéro ---- */
.eq { position: relative; overflow: visible !important; }
.eq-scroll { overflow-x: auto; overflow-y: hidden; }
.eq-tools { position: absolute; top: 6px; right: 8px; display: flex; align-items: center; gap: 8px; opacity: 0; transition: opacity .15s; }
.eq:hover .eq-tools { opacity: 1; }
.eq-tag { font-family: var(--font-mono); font-size: 11px; color: var(--faint); }
.eq-copy {
  display: grid; place-items: center; width: 24px; height: 24px; cursor: pointer;
  border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface); color: var(--muted);
  transition: color .15s, border-color .15s;
}
.eq-copy:hover { color: var(--accent-ink); border-color: var(--accent-28); }
.eq-copy svg { width: 13px; height: 13px; }

/* ---- Citations inline ---- */
.cite-link {
  font-family: var(--font-mono); font-size: .72em; font-weight: 600; color: var(--accent-ink);
  cursor: pointer; vertical-align: super; line-height: 0; padding: 0 1px;
}
.cite-link:hover { text-decoration: underline; }
.refs li.ref-flash { box-shadow: 0 0 0 2px var(--accent); transition: box-shadow .2s; }

/* ---- Navigation prev / next ---- */
.wu-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 44px 0 0; max-width: 100% !important; }
.wu-nav-card {
  display: flex; flex-direction: column; gap: 5px; padding: 16px 18px; cursor: pointer;
  border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--border);
  transition: transform .18s, box-shadow .18s, border-color .18s;
}
.wu-nav-card[data-id]:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.wu-nav-card.next { text-align: right; align-items: flex-end; }
.wu-nav-card.disabled { cursor: default; opacity: .6; }
.wu-nav-dir { font-family: var(--font-mono); font-size: 11px; color: var(--accent-ink); letter-spacing: .03em; }
.wu-nav-title { font-family: var(--font-display); font-size: 17px; font-weight: 700; line-height: 1.2; }
.wu-nav-cat { font-family: var(--font-mono); font-size: 11.5px; }

@media (max-width: 560px) {
  .amp-track { height: 120px; }
  .amp-controls { flex-wrap: wrap; }
  .wu-nav { grid-template-columns: 1fr; }
  .umx-wrap { gap: 14px; }
}
