/* Viseo — POC d'application mobile. Codes visuels iOS : police système, fond groupé, onglets en bas.
   Le cuivre (raccords laiton, cuivre) est réservé aux actions ; le viseur est noir, plein écran. */
:root {
  --accent: #a3521c; --accent-press: #843f13; --accent-soft: #f7ece3;
  --ink: #15181f; --muted: #7c828d; --bg: #f2f2f7; --surface: #fff; --line: #e3e3e8;
  --ok: #1f8a4c;
  --tab-h: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", Roboto, "Segoe UI", system-ui, sans-serif;
  color: var(--ink); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: #000; overscroll-behavior: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
:focus-visible { outline: 3px solid #e7b48d; outline-offset: 2px; }

/* sur ordinateur : l'app tient dans un cadre de téléphone */
.device { position: relative; height: 100dvh; overflow: hidden; background: var(--bg); }
@media (min-width: 600px) {
  body { display: grid; place-items: center; background: #d9dbe0; }
  .device { width: 400px; height: min(860px, 94dvh); border-radius: 44px; border: 10px solid #15181f;
            box-shadow: 0 30px 80px rgba(21, 24, 31, .35); --safe-t: 14px; }
}

/* ---------- lancement ---------- */
.splash { position: absolute; inset: 0; z-index: 50; background: var(--accent); color: #fff; display: grid;
          place-content: center; text-align: center; transition: opacity .35s ease .1s, visibility .35s .1s; }
.splash.out { opacity: 0; visibility: hidden; }
.splash-mark { font-size: 58px; font-weight: 800; letter-spacing: -2px; line-height: 1; display: flex; align-items: center; justify-content: center; gap: .2em; }
.splash-name { font-size: 18px; font-weight: 500; opacity: .85; margin-top: 8px; }


/* ---------- écrans ---------- */
.screen { position: absolute; inset: 0; bottom: calc(var(--tab-h) + var(--safe-b)); }
.page { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: calc(var(--safe-t) + 8px) 0 24px; background: var(--bg); }
.large-title { display: flex; align-items: baseline; gap: 10px; padding: 18px 20px 10px; }
.large-title h1 { margin: 0; font-size: 34px; font-weight: 700; letter-spacing: -.5px; }
.count { color: var(--muted); font-size: 17px; }

/* ---------- scanner ---------- */
.scan { background: #000; color: #fff; overflow: hidden; }
.viewport { position: absolute; inset: 0; touch-action: none; user-select: none; -webkit-user-select: none; }
.viewport video, .viewport img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.viewport img.contain { object-fit: contain; }
.shade { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.shade path { fill: rgba(0, 0, 0, .55); fill-rule: evenodd; }

/* le cadre en équerre : guide de visée en direct, puis zone de recherche ajustable */
.frame { position: absolute; pointer-events: none; transition: left .25s, top .25s, width .25s, height .25s; }
.frame.dragging { transition: none; }
.frame .c { position: absolute; width: 34px; height: 34px; border: 0 solid #fff; filter: drop-shadow(0 0 3px rgba(0,0,0,.5)); }
.frame .nw { left: 0; top: 0; border-width: 5px 0 0 5px; border-top-left-radius: 18px; }
.frame .ne { right: 0; top: 0; border-width: 5px 5px 0 0; border-top-right-radius: 18px; }
.frame .sw { left: 0; bottom: 0; border-width: 0 0 5px 5px; border-bottom-left-radius: 18px; }
.frame .se { right: 0; bottom: 0; border-width: 0 5px 5px 0; border-bottom-right-radius: 18px; }
.scanline { position: absolute; height: 3px; border-radius: 3px; pointer-events: none;
            background: linear-gradient(90deg, transparent, #fff, transparent); box-shadow: 0 0 14px #fff;
            animation: scan 1.3s ease-in-out infinite alternate; }
@keyframes scan { from { transform: translateY(0); } to { transform: translateY(var(--travel, 200px)); } }

.scan-top { position: absolute; top: 0; left: 0; right: 0; padding: calc(var(--safe-t) + 10px) 16px 30px;
            display: flex; justify-content: space-between; align-items: center;
            background: linear-gradient(rgba(0,0,0,.55), transparent); }
.brand { font-size: 20px; font-weight: 700; letter-spacing: -.4px; display: flex; align-items: center; gap: 8px; }
/* logo « D. » de Dixital (identité de dixital.fr) devant le nom de l'app : il garde son propre fond noir,
   lisible sur le cuivre du lancement comme sur l'image de la caméra */
.dx-mark { width: 1.15em; height: 1.15em; border-radius: .25em; flex: none; }
.pill { position: absolute; left: 50%; transform: translateX(-50%); top: calc(var(--safe-t) + 66px);
        background: rgba(0, 0, 0, .6); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
        padding: 8px 16px; border-radius: 20px; font-size: 15px; white-space: nowrap; transition: opacity .2s; }
.pill.hide { opacity: 0; }

.scan-controls { position: absolute; left: 0; right: 0; bottom: 26px; display: flex; justify-content: space-around;
                 align-items: center; transition: opacity .2s, transform .25s; }
.scan-controls.away { opacity: 0; transform: translateY(30px); pointer-events: none; }
.round { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; }
.round.ghost { background: rgba(255, 255, 255, .18); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); color: #fff; font-size: 18px; }
.round.placeholder { visibility: hidden; }
.shutter { width: 78px; height: 78px; border-radius: 50%; border: 5px solid #fff; display: grid; place-items: center; }
.shutter span { width: 60px; height: 60px; border-radius: 50%; background: #fff; transition: transform .12s, background .12s; }
.shutter:active span { transform: scale(.88); background: #e8e8e8; }

.camera-error { position: absolute; inset: 30% 30px auto; text-align: center; }
.camera-error p { font-size: 17px; line-height: 1.4; color: #ddd; }

/* ---------- panneau de résultats ---------- */
.sheet { position: absolute; left: 0; right: 0; bottom: 0; height: 88%; z-index: 5; background: var(--bg); color: var(--ink);
         border-radius: 16px 16px 0 0; box-shadow: 0 -8px 30px rgba(0, 0, 0, .3); display: flex; flex-direction: column;
         transform: translateY(var(--y, 100%)); transition: transform .32s cubic-bezier(.2, .8, .2, 1); }
.sheet.dragging { transition: none; }
.grab { padding: 8px 0 4px; display: grid; place-items: center; cursor: grab; touch-action: none; }
.grab span { width: 38px; height: 5px; border-radius: 3px; background: #c7c7cc; }
.sheet-head { padding: 4px 20px 10px; touch-action: none; }
.sheet-head h2 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.3px; }
.sheet-head p { margin: 3px 0 0; color: var(--muted); font-size: 14px; }
.results { list-style: none; margin: 0; padding: 4px 16px 20px; overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }
.results.busy { opacity: .45; }

/* lignes de liste (résultats, historique, ma liste) */
.row { display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; background: var(--surface);
       padding: 10px 12px; border-radius: 12px; margin-bottom: 8px; }
.row:active { background: #e9e9ee; }
.thumb { flex: none; width: 64px; height: 64px; border-radius: 10px; background: #fff; border: 1px solid var(--line);
         object-fit: contain; }
.row .txt { flex: 1; min-width: 0; display: block; }
.row .meta { display: block; }
.row .name { font-size: 15px; font-weight: 600; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2;
             -webkit-box-orient: vertical; overflow: hidden; text-transform: lowercase; }
.row .name::first-letter { text-transform: uppercase; }
.row .meta { font-size: 13px; color: var(--muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .chev { flex: none; color: #c4c4c9; font-size: 22px; }
/* bordure (dans la carte) et non box-shadow (hors de la carte) : la liste défilante rogne ce qui dépasse */
.best { background: var(--surface); border-radius: 14px; padding: 10px; margin-bottom: 14px; border: 2px solid var(--accent); }
.best .row { padding: 0; margin: 0; background: none; }
.best .thumb { width: 92px; height: 92px; }
.best-label { font-size: 13px; font-weight: 600; color: var(--accent); margin-bottom: 8px; }
.section-label { font-size: 13px; color: var(--muted); margin: 4px 4px 8px; }

.list { list-style: none; margin: 0; padding: 0 16px; }
.list .row { margin-bottom: 8px; }
.remove { flex: none; color: var(--muted); font-size: 20px; padding: 6px; }

.empty { text-align: center; padding: 50px 36px; color: var(--muted); }
.empty p { font-size: 16px; line-height: 1.45; margin: 0 0 18px; }
.list-actions { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 16px; }

/* ---------- boutons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 50px; padding: 0 22px; border-radius: 13px;
       font-size: 17px; font-weight: 600; text-decoration: none; width: 100%; max-width: 360px; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:active { background: var(--accent-press); }
.btn.secondary { background: var(--accent-soft); color: var(--accent); }
.btn.done { background: #e6f4ec; color: var(--ok); }
.text-btn { color: var(--accent); font-size: 16px; padding: 10px; display: block; margin: 8px auto; }
.text-btn.danger { color: #d1243a; }

/* ---------- fiche produit ---------- */
.detail { position: absolute; inset: 0; bottom: calc(var(--tab-h) + var(--safe-b)); z-index: 20; background: var(--bg); display: flex; flex-direction: column;
          animation: push .3s cubic-bezier(.2, .8, .2, 1); }
@keyframes push { from { transform: translateX(100%); } }
.detail.leaving { transform: translateX(100%); transition: transform .25s ease-in; }
.nav { display: flex; justify-content: space-between; align-items: center; padding: calc(var(--safe-t) + 8px) 12px 8px; background: var(--bg); }
.back { display: flex; align-items: center; gap: 6px; color: var(--accent); font-size: 17px; padding: 6px; }
.nav-action { color: var(--accent); padding: 6px; }
.detail-body { flex: 1; overflow-y: auto; padding-bottom: calc(24px + var(--safe-b)); }
.detail-img { background: #fff; margin: 0 16px; border-radius: 18px; aspect-ratio: 1; display: grid; place-items: center; }
.detail-img img { width: 86%; height: 86%; object-fit: contain; }
.detail-info { padding: 18px 20px 6px; }
.family { margin: 0; font-size: 14px; color: var(--accent); font-weight: 600; }
.detail-info h1 { margin: 6px 0 8px; font-size: 23px; line-height: 1.2; letter-spacing: -.3px; text-transform: lowercase; }
.detail-info h1::first-letter { text-transform: uppercase; }
.ref { margin: 0; font-size: 16px; color: var(--muted); } .ref b { color: var(--ink); font-variant-numeric: tabular-nums; }
.match { margin: 10px 0 0; font-size: 14px; color: var(--muted); }
.detail-actions { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 16px; }

/* ---------- onglets ---------- */
.tabbar { position: absolute; left: 0; right: 0; bottom: 0; z-index: 10; height: calc(var(--tab-h) + var(--safe-b));
          padding-bottom: var(--safe-b); display: flex; background: rgba(249, 249, 251, .94);
          backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-top: .5px solid #c9c9ce; }
.tab { position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
       gap: 2px; font-size: 11px; font-weight: 500; color: #8e8e93; }
.tab.active { color: var(--accent); }
.badge { position: absolute; top: 4px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
         background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }

.toast { position: absolute; left: 50%; bottom: calc(var(--tab-h) + var(--safe-b) + 18px); z-index: 30;
         transform: translate(-50%, 20px); opacity: 0; pointer-events: none; background: rgba(21, 24, 31, .92); color: #fff;
         padding: 11px 18px; border-radius: 22px; font-size: 15px; white-space: nowrap; transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
