/* ==========================================================================
   revision.tn — suite d'outils (hub + 3 outils). Se charge après site.css.
   ========================================================================== */

/* En-tête de page (même gabarit que l'atelier) */
.tools-page { padding-bottom: clamp(48px, 8vw, 96px); }
.page-head { display: grid; gap: 16px 48px; align-items: end; margin-block: clamp(32px, 5vw, 64px) clamp(24px, 4vw, 40px); }
@media (min-width: 900px) { .page-head { grid-template-columns: minmax(0, 1fr) minmax(0, 0.8fr); } }
.page-head h1 { font-size: clamp(2.5rem, 5.4vw, 5rem); line-height: 0.98; letter-spacing: -0.04em; }
.page-head p { font-size: 1.0625rem; line-height: 1.55; color: var(--text-2); max-width: 32rem; }

/* ---- Hub ---- */
.tool-list { display: grid; gap: 16px; }
@media (min-width: 900px) { .tool-list { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.tool-list > li { display: grid; }
.tool-card { display: grid; grid-template-rows: auto auto 1fr auto; gap: 12px; padding: clamp(20px, 2.4vw, 28px); transition: border-color var(--t-fast), transform var(--t-fast); }
.tool-card:hover { border-color: var(--text-3); transform: translate3d(0, -2px, 0); }
.tool-card .no { font-family: var(--serif); font-size: 1.125rem; color: var(--red); }
.tool-card h2 { font-size: clamp(1.5rem, 2.2vw, 1.875rem); }
.tool-card p { font-size: 0.9375rem; line-height: 1.55; color: var(--text-2); }
.tool-card .tags { display: flex; flex-wrap: wrap; gap: 6px 8px; margin-top: 4px; }
.tag-chip { font-size: 0.75rem; line-height: 1; padding: 5px 8px; border: 1px solid var(--border-strong); color: var(--text-2); }
.tool-card .go { display: inline-flex; align-items: center; gap: 8px; margin-top: 8px; font-weight: 500; font-size: 0.9375rem; }
.tool-card .go svg { width: 16px; height: 16px; transition: transform var(--t-fast); }
.tool-card:hover .go svg { transform: translate3d(3px, 0, 0); }
.local-strip { display: flex; flex-wrap: wrap; gap: 8px 40px; margin-top: clamp(32px, 5vw, 56px); padding-top: 16px; border-top: 2px solid var(--text); }
.local-strip li { font-size: 0.9375rem; color: var(--text-2); }
.local-strip b { color: var(--text); font-weight: 500; }

/* ---- Outil : mise en page ---- */
.tool-back { display: inline-flex; align-items: center; gap: 6px; }
.workbench { display: grid; gap: 16px; align-items: start; }
.panel-title { font-size: 1.125rem; letter-spacing: -0.01em; margin-bottom: 4px; }
.note { font-size: 0.875rem; line-height: 1.5; color: var(--text-3); }
.note a { color: var(--text-2); text-decoration: underline; text-underline-offset: 3px; }
.stack { display: grid; gap: 16px; }

/* Zone de dépôt */
.dz { position: relative; display: grid; place-items: center; gap: 4px; text-align: center; padding: clamp(28px, 5vw, 56px) 16px; border: 2px dashed var(--border-strong); background: var(--bg); cursor: pointer; transition: border-color var(--t-fast), background-color var(--t-fast); }
.dz:hover, .dz.is-over, .dz:focus-within { border-color: var(--accent); background: var(--accent-bg); }
.dz input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.dz-title { font-family: var(--serif); font-size: clamp(1.25rem, 2vw, 1.5rem); letter-spacing: -0.02em; }
.dz-sub { font-size: 0.875rem; color: var(--text-3); }
.dz.is-compact { padding: 16px; grid-auto-flow: column; justify-content: center; gap: 12px; }
.dz.is-compact .dz-title { font-size: 1rem; }

/* Barre d'outils au-dessus des résultats */
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.bar .grow { flex: 1 1 12rem; min-width: 0; }
.bar .file-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-ghost { background: transparent; border-color: var(--border-strong); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-ghost svg { width: 16px; height: 16px; }
.btn-quiet { background: none; border: 0; padding: 0 4px; height: auto; color: var(--text-2); text-decoration: underline; text-underline-offset: 3px; font-size: 0.875rem; }
.btn-quiet:hover { color: var(--text); }
.foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 16px; padding: 12px 16px; border-top: 1px solid var(--border); }

/* Onglets (Boîte PDF) */
.tabs { display: flex; flex-wrap: wrap; border: 1px solid var(--border-strong); background: var(--surface); }
.tab { flex: 1 1 8rem; min-height: 44px; padding: 0 16px; border: 0; background: transparent; color: var(--text-2); font-weight: 500; font-size: 0.9375rem; transition: color var(--t-fast), background-color var(--t-fast); }
.tab + .tab { border-left: 1px solid var(--border-strong); }
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { background: var(--text); color: var(--on-btn); }
.tab:focus-visible { outline-offset: -2px; }
.tabpanel[hidden] { display: none; }

/* Pages d'un PDF : grille de tuiles */
.pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: 12px; padding: 16px; list-style: none; margin: 0; }
.tile { position: relative; display: grid; grid-template-rows: auto auto; gap: 6px; padding: 8px; background: var(--surface-2); border: 1px solid var(--border); transition: border-color var(--t-fast), opacity var(--t-fast); min-width: 0; }
.tile .thumb { position: relative; display: grid; place-items: center; height: 10.5rem; background: var(--paper); border: 1px solid var(--border); overflow: hidden; }
.tile .thumb canvas { max-width: 100%; max-height: 100%; display: block; }
.tile .thumb .ph { width: 40%; height: 70%; background: var(--rule-fine); border: 1px dashed var(--border-strong); }
.tile .meta-row { display: flex; align-items: center; justify-content: space-between; gap: 4px; min-height: 32px; }
.tile .num { font-family: var(--serif); font-size: 1rem; color: var(--text-2); font-variant-numeric: tabular-nums; padding-left: 4px; }
.tile .tools { display: flex; gap: 2px; }
.tile-btn { width: 32px; height: 32px; display: inline-grid; place-items: center; border: 0; background: transparent; color: var(--text-2); transition: color var(--t-fast), background-color var(--t-fast); }
.tile-btn:hover { color: var(--text); background: var(--surface); }
.tile-btn svg { width: 16px; height: 16px; }
.grip { position: absolute; top: 12px; left: 12px; z-index: 2; width: 32px; height: 32px; display: grid; place-items: center; border: 1px solid var(--border-strong); background: color-mix(in srgb, var(--bg) 88%, transparent); color: var(--text-2); cursor: grab; touch-action: none; -webkit-user-select: none; user-select: none; }
.grip:hover { color: var(--text); }
.grip:active { cursor: grabbing; }
.tile.is-dragging { opacity: 0.3; }
.tile.is-ghost { opacity: 0.92; box-shadow: 0 18px 30px -12px var(--shadow-ink); border-color: var(--accent); }
.tile.is-removed .thumb { opacity: 0.25; }
.tile.is-removed .num { text-decoration: line-through; }
.tile.is-removed::after { content: "Supprimée"; position: absolute; left: 8px; right: 8px; top: calc(8px + 5.25rem - 10px); text-align: center; font-size: 0.8125rem; font-weight: 600; color: var(--red); pointer-events: none; }
.tile.is-picked { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.tile.is-picked .num::after { content: " ✓"; color: var(--accent); }
.tile.selectable { cursor: pointer; }
.drop-line { position: absolute; width: 3px; background: var(--accent); pointer-events: none; z-index: 5; }
.drop-line[data-axis="y"] { height: 3px; width: auto; }

/* Liste de fichiers (fusion, conversion) */
.rows { display: grid; list-style: none; margin: 0; padding: 0; }
.row { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px 12px; align-items: center; padding: 10px 16px; background: var(--surface); }
.row + .row { border-top: 1px solid var(--border); }
.row .grip { position: static; }
.row .thumb { width: 3rem; height: 4rem; display: grid; place-items: center; background: var(--paper); border: 1px solid var(--border); overflow: hidden; }
.row .thumb canvas { max-width: 100%; max-height: 100%; }
.row .thumb svg { width: 20px; height: 20px; color: var(--text-3); }
.row .info { min-width: 0; }
.row .info .name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .acts { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.row.is-dragging { opacity: 0.3; }
.row.is-ghost { opacity: 0.95; box-shadow: 0 18px 30px -12px var(--shadow-ink); border: 1px solid var(--accent); }
.row-lead { display: flex; align-items: center; gap: 12px; min-width: 0; }
.row-lead .info { flex: 1; }
@media (max-width: 560px) {
  .row { grid-template-columns: auto minmax(0, 1fr); }
  .row .acts { grid-column: 1 / -1; justify-content: flex-start; }
}

/* Champs des outils */
.select, .num-input { height: 40px; padding: 0 10px; border: 1px solid var(--border-strong); background: var(--bg); color: var(--text); }
.select { max-width: 100%; }
.num-input { width: 5rem; font-variant-numeric: tabular-nums; }
.select:focus, .num-input:focus { outline: none; border-color: var(--accent); }
.opts { display: grid; gap: 12px 24px; padding: 16px; border-top: 1px solid var(--border); }
@media (min-width: 700px) { .opts { grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); } }
.opt label { display: block; margin-bottom: 6px; font-size: 0.875rem; font-weight: 500; color: var(--text-2); }
.opt input[type="range"] { width: 100%; accent-color: var(--accent); }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: 0.9375rem; color: var(--text-2); cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent); flex: none; }
.radios { display: grid; gap: 8px; }
.radios .check { padding: 10px 12px; border: 1px solid var(--border); background: var(--bg); }
.radios .check:has(input:checked) { border-color: var(--accent); background: var(--accent-bg); color: var(--text); }
.pick-actions { display: flex; flex-wrap: wrap; gap: 4px 12px; }

/* Progression */
.progress { height: 6px; background: var(--border); overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 160ms linear; }
.progress[hidden] { display: none; }

/* Résultats */
.result { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding: 12px 16px; background: var(--accent-bg); border-top: 1px solid var(--border); }
.result[hidden] { display: none; }
.result b { font-weight: 500; }

/* OCR */
.ocr-grid { display: grid; gap: 16px; }
@media (min-width: 960px) { .ocr-grid { grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); } }
.ocr-text { width: 100%; min-height: 22rem; padding: 16px; border: 0; border-bottom: 1px solid var(--border); background: var(--paper); font-family: var(--serif); font-size: 1.0625rem; line-height: 1.6; color: var(--text); resize: vertical; }
.ocr-text:focus { outline: 2px solid var(--accent); outline-offset: -2px; }
.shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(5rem, 1fr)); gap: 8px; padding: 12px 16px; list-style: none; margin: 0; }
.shot { position: relative; border: 1px solid var(--border); background: var(--paper); aspect-ratio: 3 / 4; display: grid; place-items: center; overflow: hidden; }
.shot img, .shot canvas { max-width: 100%; max-height: 100%; display: block; }
.shot .state { position: absolute; left: 0; right: 0; bottom: 0; padding: 2px 4px; font-size: 0.6875rem; text-align: center; background: color-mix(in srgb, var(--bg) 85%, transparent); color: var(--text-2); }
.shot.is-ok .state { color: var(--ok); }
.shot.is-bad .state { color: var(--warn); }

/* L'attribut hidden doit toujours gagner sur les display des boutons et des grilles */
.tools-page [hidden] { display: none !important; }

/* Annonces et accessibilité */
.live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
@media (hover: none) { .tool-card:hover { transform: none; } }
@media (prefers-reduced-motion: reduce) { .tool-card, .progress > i { transition: none; } }
