/* magazine-reader.css — lecteur de journal TomsoFoot (isolé, préfixe .mr / #mr-)
   Direction artistique : bleu nuit, blanc, rouge TomsoFoot, violet en accent. */

:root {
  --mr-ink: #060f22;
  --mr-navy: #0a1b3d;
  --mr-navy-2: #061334;
  --mr-paper: #fbfaf6;
  --mr-red: #ef3340;
--mr-blue: #0a4eb8;
  --mr-purple: #6b4bd6;
  --mr-line: rgba(255, 255, 255, .12);
  --mr-muted: #93a3bd;
  --mr-white: #f4f7fc;
  --mr-bar-h: 64px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
.mr-sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

#mr-root {
  min-height: 100dvh; display: flex; flex-direction: column;
  font-family: Inter, system-ui, Arial, sans-serif; color: var(--mr-white);
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(107, 75, 214, .16), transparent 55%),
    radial-gradient(90% 60% at 50% 120%, rgba(17, 103, 255, .12), transparent 60%),
    linear-gradient(180deg, var(--mr-navy) 0%, var(--mr-ink) 100%);
  -webkit-font-smoothing: antialiased;
}

/* --- Barre du haut ------------------------------------------------------- */
.mr-topbar {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 14px;
  height: var(--mr-bar-h); padding: 0 clamp(12px, 3vw, 26px);
  border-bottom: 1px solid var(--mr-line); background: rgba(6, 15, 34, .6);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.mr-brand { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.mr-logo-mark { height: 28px; width: 28px; border-radius: 7px; object-fit: cover; flex: 0 0 auto; box-shadow: 0 2px 6px rgba(0,0,0,.3); }
.mr-brand .mr-logo { font-family: "Archivo Black", Inter, sans-serif; font-size: clamp(14px, 1.9vw, 19px); letter-spacing: -.04em; white-space: nowrap; }
.mr-brand .mr-logo i { color: var(--mr-blue); font-style: normal; }
.mr-titles { min-width: 0; }
.mr-titles .mr-t { font-weight: 800; font-size: clamp(13px, 1.7vw, 16px); line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46vw; }
.mr-titles .mr-s { font-size: 11px; color: var(--mr-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46vw; }
.mr-actions { display: flex; align-items: center; gap: 8px; }
.mr-btn {
  appearance: none; border: 1px solid var(--mr-line); background: rgba(255, 255, 255, .04);
  color: var(--mr-white); height: 40px; min-width: 40px; padding: 0 12px; border-radius: 9px;
  cursor: pointer; display: inline-grid; grid-auto-flow: column; place-items: center; gap: 7px;
  font-size: 12px; font-weight: 700; letter-spacing: .02em; transition: .16s;
}
.mr-btn:hover { border-color: var(--mr-blue); color: #fff; }
.mr-btn:focus-visible { outline: 3px solid var(--mr-purple); outline-offset: 2px; }
.mr-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; }
.mr-btn--ghost { background: transparent; }
.mr-back { text-transform: uppercase; font-size: 11px; letter-spacing: .12em; }

/* --- Scène / livre ------------------------------------------------------- */
.mr-stage {
  position: relative; flex: 1 1 auto; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  padding: clamp(8px, 2.4vw, 26px) clamp(6px, 3vw, 34px);
  overflow: hidden;
}
.mr-stage.is-zoomed { overflow: auto; align-items: flex-start; justify-content: flex-start; cursor: grab; }
.mr-stage-inner { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; will-change: transform; transition: transform .12s ease-out; }
#mr-stagebook { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }

/* Livre : deux emplacements (double page) + une feuille rigide qui tourne. */
.mr-book { position: relative; perspective: 2600px; --mr-page-w: 520px; --mr-page-h: 680px; }
.mr-sheet { position: relative; display: flex; width: 100%; height: 100%; filter: drop-shadow(0 26px 46px rgba(0, 0, 0, .5)); }
.mr-slot { position: relative; width: var(--mr-page-w); height: var(--mr-page-h); background: var(--mr-paper); overflow: hidden; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .05); }
.mr-book.is-oneup .mr-slot--left { display: none; }
.mr-spine { width: 0; }
/* Reliure centrale subtile */
.mr-slot--left::after { content: ""; position: absolute; top: 0; bottom: 0; right: 0; width: 26px; pointer-events: none; z-index: 3; background: linear-gradient(90deg, transparent, rgba(0, 0, 0, .09)); }
.mr-slot--right::before { content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 26px; pointer-events: none; z-index: 3; background: linear-gradient(270deg, transparent, rgba(0, 0, 0, .09)); }
.mr-slot.is-blank { background: linear-gradient(180deg, #efeadd, #e7e0cf); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .05), inset -18px 0 26px rgba(0, 0, 0, .05); }
.mr-slot.is-blank .mr-canvas-wrap { display: none; }

.mr-canvas-wrap { position: absolute; inset: 0; }
.mr-canvas { position: absolute; inset: 0; display: block; }

/* Feuille qui tourne (rigide, DOM net, aucune rasterisation) */
.mr-turn { position: absolute; top: 0; height: var(--mr-page-h); width: var(--mr-page-w); transform-style: preserve-3d; pointer-events: none; display: none; z-index: 6; will-change: transform; }
.mr-turn.is-on { display: block; }
.mr-face { position: absolute; inset: 0; overflow: hidden; background: var(--mr-paper); backface-visibility: hidden; -webkit-backface-visibility: hidden; box-shadow: 0 0 30px rgba(0, 0, 0, .18); }
.mr-face--back { transform: rotateY(180deg); }
.mr-shade { position: absolute; inset: 0; pointer-events: none; background: linear-gradient(90deg, rgba(0, 0, 0, .16), transparent 30%); opacity: .0; }

/* Zones cliquables discrètes sur les bords */
.mr-edge { position: absolute; top: 0; bottom: 0; width: 12%; max-width: 90px; border: 0; background: transparent; cursor: pointer; z-index: 4; }
.mr-edge--prev { left: 0; } .mr-edge--next { right: 0; }
.mr-book.is-oneup .mr-edge { width: 22%; }

/* Placeholder pendant le rendu */
.mr-ph { position: absolute; inset: 0; display: grid; place-items: center; background: var(--mr-paper); }
.mr-slot.is-rendered .mr-ph, .mr-face.is-rendered .mr-ph { display: none; }
.mr-ph-dot { width: 26px; height: 26px; border-radius: 50%; border: 3px solid rgba(6, 15, 34, .15); border-top-color: var(--mr-blue); animation: mr-spin .8s linear infinite; }
.mr-ph-err { font: 700 11px/1.4 Inter, sans-serif; color: #9a2530; letter-spacing: .08em; text-transform: uppercase; }
@keyframes mr-spin { to { transform: rotate(360deg); } }

/* --- Couche texte PDF.js (sélectionnable, alignée sur le canvas) --------- */
.textLayer {
  position: absolute; inset: 0; overflow: clip; opacity: 1; line-height: 1;
  text-size-adjust: none; forced-color-adjust: none; transform-origin: 0 0; z-index: 2;
  -webkit-user-select: text; user-select: text;
}
.textLayer :is(span, br) { color: transparent; position: absolute; white-space: pre; cursor: text; transform-origin: 0 0; }
.textLayer span.markedContent { top: 0; height: 0; }
.textLayer .endOfContent { position: absolute; inset: 100% 0 0 0; z-index: -1; cursor: default; user-select: none; }
.textLayer .endOfContent.active { top: 0; }
.textLayer ::selection { background: rgba(37, 99, 235, .38); }
.textLayer br::selection { background: transparent; }

/* --- Barre du bas -------------------------------------------------------- */
.mr-bottom { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 10px 14px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--mr-line); background: rgba(6, 15, 34, .6); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.mr-prog { width: min(560px, 78vw); height: 2px; background: var(--mr-line); border-radius: 2px; overflow: hidden; }
.mr-prog span { display: block; height: 100%; width: 0; background: var(--mr-blue); transition: width .4s; }
.mr-row { display: flex; align-items: center; gap: clamp(10px, 2.5vw, 20px); }
.mr-nav { appearance: none; border: 1px solid var(--mr-line); background: rgba(255, 255, 255, .04); color: var(--mr-white); width: 46px; height: 46px; border-radius: 10px; cursor: pointer; display: grid; place-items: center; transition: .16s; }
.mr-nav:hover:not(:disabled) { border-color: var(--mr-blue); color: var(--mr-blue); }
.mr-nav:active:not(:disabled) { transform: scale(.94); }
.mr-nav:disabled { opacity: .3; cursor: default; }
.mr-nav:focus-visible { outline: 3px solid var(--mr-purple); outline-offset: 2px; }
.mr-nav svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.1; }
.mr-count { font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--mr-muted); min-width: 120px; text-align: center; }
.mr-count b { color: var(--mr-white); }
.mr-zoom { display: flex; align-items: center; gap: 6px; }
.mr-zoom .mr-nav { width: 40px; height: 40px; }
.mr-zoom-label { font-size: 11px; font-weight: 700; color: var(--mr-muted); min-width: 44px; text-align: center; }

/* --- Miniatures ---------------------------------------------------------- */
.mr-thumbs-panel { position: fixed; z-index: 20; right: 0; top: var(--mr-bar-h); bottom: 0; width: min(320px, 84vw); transform: translateX(100%); transition: transform .28s ease; background: rgba(6, 15, 34, .96); border-left: 1px solid var(--mr-line); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); display: flex; flex-direction: column; }
.mr-thumbs-panel.is-open { transform: none; }
.mr-thumbs-head { padding: 12px 14px; font: 800 12px/1 Inter, sans-serif; letter-spacing: .14em; text-transform: uppercase; color: var(--mr-muted); border-bottom: 1px solid var(--mr-line); }
.mr-thumbs { overflow-y: auto; padding: 12px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.mr-thumb { position: relative; appearance: none; border: 1px solid var(--mr-line); background: #fff; border-radius: 6px; overflow: hidden; cursor: pointer; aspect-ratio: 540 / 705; padding: 0; }
.mr-thumb.is-active { outline: 2px solid var(--mr-blue); border-color: var(--mr-blue); }
.mr-thumb:focus-visible { outline: 3px solid var(--mr-purple); }
.mr-thumb-c { width: 100%; height: 100%; display: block; object-fit: cover; }
.mr-thumb-n { position: absolute; bottom: 3px; right: 5px; font: 700 9px/1 Inter; color: #061334; background: rgba(255, 255, 255, .8); padding: 1px 4px; border-radius: 3px; }

/* --- Overlays : chargement / erreur / reprise / note -------------------- */
.mr-overlay { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 24px; z-index: 30; background: rgba(6, 15, 34, .55); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.mr-loading .mr-loadwrap { width: min(340px, 82vw); }
.mr-loadttl { font: 800 12px/1 Inter, sans-serif; letter-spacing: .22em; text-transform: uppercase; color: var(--mr-white); margin: 0 0 14px; }
.mr-loadbar { height: 3px; background: var(--mr-line); border-radius: 3px; overflow: hidden; }
.mr-loadbar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--mr-blue), var(--mr-purple)); transition: width .3s; }
.mr-error .mr-errbox { max-width: 460px; }
.mr-errbox h2 { font-size: 20px; margin: 0 0 8px; }
.mr-errbox p { color: var(--mr-muted); font-size: 14px; line-height: 1.6; margin: 0 0 18px; }
.mr-errbox .mr-actions { justify-content: center; }
.mr-resume { position: absolute; left: 50%; bottom: calc(var(--mr-bar-h) + 76px); transform: translateX(-50%); z-index: 25; display: flex; align-items: center; gap: 12px; background: rgba(10, 27, 61, .96); border: 1px solid var(--mr-line); border-radius: 12px; padding: 10px 12px 10px 16px; box-shadow: 0 18px 40px rgba(0, 0, 0, .4); }
.mr-resume p { margin: 0; font-size: 13px; }
.mr-resume .mr-btn { height: 34px; }
.mr-notice { position: absolute; left: 50%; bottom: calc(var(--mr-bar-h) + 20px); transform: translateX(-50%); z-index: 24; max-width: min(560px, 90vw); font-size: 12px; line-height: 1.5; color: #ffdca8; background: rgba(60, 40, 10, .9); border: 1px solid rgba(255, 200, 120, .3); border-radius: 10px; padding: 8px 14px; text-align: center; }
.mr-hint { position: absolute; left: 50%; bottom: calc(var(--mr-bar-h) + 20px); transform: translateX(-50%); z-index: 12; font: 700 10px/1 Inter; letter-spacing: .14em; text-transform: uppercase; color: var(--mr-muted); background: rgba(6, 15, 34, .7); border: 1px solid var(--mr-line); padding: 7px 14px; border-radius: 20px; pointer-events: none; transition: opacity .6s; }
.mr-hint.is-gone { opacity: 0; }

/* --- Responsive : mobile = une seule page, contrôles compacts ----------- */
@media (max-width: 820px) {
  .mr-titles .mr-t, .mr-titles .mr-s { max-width: 40vw; }
  .mr-back span { display: none; }
  .mr-thumbs-panel { top: var(--mr-bar-h); }
}
@media (max-width: 520px) {
  :root { --mr-bar-h: 56px; }
  .mr-brand .mr-titles { display: none; }
  .mr-count { min-width: 92px; font-size: 11px; }
  .mr-nav { width: 44px; height: 44px; }
  .mr-zoom { display: none; } /* zoom au pincement / double-tap sur mobile */
  .mr-book { width: 100%; }
}

/* --- Mouvement réduit ---------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .mr-stage-inner, .mr-prog span, .mr-loadbar span, .mr-thumbs-panel { transition: none !important; }
  .mr-ph-dot { animation: none; border-top-color: rgba(6, 15, 34, .3); }
}
