/* Pointage — mobile-first. Designed for one thumb, in a truck, in daylight.
   No build step: plain CSS, custom properties, dark by default with a light
   variant for bright sun (a phone in auto-brightness outdoors picks light). */

/* The office agenda's palette (UNO's AgendaDarkTheme / AgendaLightTheme,
   after Google Agenda), since the app is mostly the technician's agenda:
   Google's greys with its blue as the accent. The phone picks the variant. */
:root {
  --bg:          #202124;
  --surface:     #292a2d;
  --surface-2:   #303134;
  --elevated:    #303134;   /* the sheets that rise over the page */
  --border:      #3c4043;
  --text:        #e8eaed;
  --muted:       #bdc1c6;
  --accent:      #8ab4f8;
  --on-accent:   #202124;
  --accent-soft: #263b5a;
  --accent-text: #a8c7fa;
  --selection:   #334867;
  --ok:          #81c995;
  --warn:        #fdd663;
  --danger:      #f28b82;
  --on-danger:   #202124;
  --shadow:      0 8px 28px #0008, 0 1px 3px #0005;
  --radius:      16px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg:          #ffffff;
    --surface:     #ffffff;
    --surface-2:   #f1f3f4;
    --elevated:    #ffffff;
    --border:      #dadce0;
    --text:        #202124;
    --muted:       #5f6368;
    --accent:      #1a73e8;
    --on-accent:   #ffffff;
    --accent-soft: #e8f0fe;
    --accent-text: #1967d2;
    --selection:   #e8f0fe;
    --ok:          #137333;
    --warn:        #8a5700;
    --danger:      #c5221f;
    --on-danger:   #ffffff;
    --shadow:      0 4px 16px #20212426, 0 1px 3px #2021241a;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  /* No rubber-band scroll behind the app shell — it reads as a broken web page
     rather than an app when the background bounces into view. */
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100svh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}
/* Installed on an iPhone, the status bar (black-translucent) shows whatever
   scrolls under it: a band of the page's colour stays there, and the sticky
   headers stop just below it instead of sliding under the clock. Zero tall
   everywhere else. */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: env(safe-area-inset-top);
  background: var(--bg);
  z-index: 45;
  pointer-events: none;
}

.view { display: flex; flex-direction: column; min-height: 100svh; }
[hidden] { display: none !important; }
.muted { color: var(--muted); font-size: 14px; }
.error {
  color: var(--danger);
  font-size: 14px;
  margin: 4px 0 0;
  line-height: 1.4;
}

/* Bandeau « démonstration ». Volontairement voyant : personne ne doit croire
   qu'il pointe pour de vrai dans une instance de test. */
/* Not sticky: it would cover the top of each screen's own sticky header. */
.demo-strip {
  position: relative;
  z-index: 30;
  padding: 8px 14px;
  text-align: center;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--on-accent);
  background: var(--warn);
}

/* ── Connexion ─────────────────────────────────────────────────────────── */

/* One column centred in the screen, the brand at the top, the action within
   the thumb's reach. The same frame serves the password change and the
   Face ID set-up. */
.login-view, #view-password, #view-passkey { background:
  radial-gradient(120% 60% at 50% -10%, var(--accent-soft), transparent 70%), var(--bg); }

.login {
  margin: auto;
  width: 100%;
  max-width: 380px;
  padding: 32px 24px calc(28px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
}
/* The login itself fills the screen: the brand at the top, the technician in
   the middle, « Changer de compte » at the bottom. */
.login-view .login { margin: 0 auto; flex: 1; padding-top: 22px; }
/* The demo strip sits above the view: on the login, the page is a column so
   the view takes what is left instead of a full screen under the strip. */
body:has(#view-login:not([hidden])) { display: flex; flex-direction: column; min-height: 100svh; }
body:has(#view-login:not([hidden])) .login-view { flex: 1; min-height: 0; }
.login-body { margin: auto 0; display: flex; flex-direction: column; gap: 8px; padding: 24px 0; }
.login h1 { margin: 0; font-size: 28px; line-height: 1.15; text-align: center; letter-spacing: -0.02em; text-wrap: balance; }
.login .muted { text-align: center; margin: 0 0 18px; }
.login-lead {
  margin: 4px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
  text-wrap: pretty;
}

.brand { display: flex; align-items: center; justify-content: center; gap: 10px; }
.brand-logo { border-radius: 10px; box-shadow: var(--shadow); }
.brand-name { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.2; }
.brand-sub { font-size: 12px; color: var(--muted); line-height: 1.2; }
.brand-small { margin-bottom: 26px; }

.login-known { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.login-date {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-text);
}
.login-avatar {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  margin-bottom: 14px;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
  background: var(--known-color, var(--accent));
  box-shadow: 0 0 0 4px var(--bg), 0 0 0 6px var(--known-color, var(--accent));
}

.login-form { display: flex; flex-direction: column; gap: 14px; margin-top: 22px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 500; color: var(--muted); padding-left: 2px; }
.login label { font-size: 13px; color: var(--muted); margin-top: 12px; }
.login .field label { margin-top: 0; }

input[type="text"], input[type="password"] {
  width: 100%;
  /* 16px minimum, otherwise iOS Safari zooms the page on focus. */
  font-size: 16px;
  padding: 14px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  -webkit-appearance: none;
  appearance: none;
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }

.btn-primary {
  margin-top: 20px;
  width: 100%;
  min-height: 52px;
  font-size: 17px;
  font-weight: 600;
  border: none;
  border-radius: 14px;
  background: var(--accent);
  color: var(--on-accent);
  cursor: pointer;
  transition: transform 0.08s ease, opacity 0.15s ease;
}
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.5; }
.login-form .btn-primary { margin-top: 8px; }

.btn-ghost {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 999px;   /* the agenda's rounded buttons */
  padding: 9px 12px;
  font-size: 14px;
  min-height: 40px;
  cursor: pointer;
}

.btn-link {
  background: none;
  border: none;
  padding: 10px 8px;
  min-height: 44px;
  font-size: 14px;
  font-weight: 500;
  color: var(--accent-text);
  cursor: pointer;
}
.login-links { display: flex; flex-direction: column; align-items: center; min-height: 44px; }
.login-error { text-align: center; }

/* ── Connexion par le téléphone (Face ID, empreinte ou NIP) ────────────── */

.btn-unlock {
  margin-top: 28px;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.btn-unlock .ic-finger, .setup-badge .ic-finger { display: none; }
.is-finger .ic-finger { display: block !important; }
.is-finger .ic-face { display: none; }
.btn-unlock svg, .setup-badge svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.setup-badge {
  align-self: center;
  width: 76px;
  height: 76px;
  border-radius: 22px;
  display: grid;
  place-items: center;
  margin-bottom: 14px;
  color: var(--accent-text);
  background: var(--accent-soft);
}
.setup-badge svg { width: 38px; height: 38px; stroke-width: 1.6; }
.passkey-setup .btn-primary { margin-top: 26px; }
.passkey-setup .btn-ghost { margin-top: 10px; width: 100%; min-height: 48px; border-radius: 14px; }

.accounts { width: 100%; max-width: 640px; margin: 0 auto; padding: 16px 16px 40px; display: flex; flex-direction: column; gap: 10px; }
.accounts .muted { margin: 0; }
.account { align-items: center; gap: 10px; }

.banner {
  padding: 11px 16px;
  font-size: 14px;
  line-height: 1.4;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.banner.warn   { color: var(--warn); }
.banner.danger { color: var(--danger); }

/* ── Mes heures ──────────────────────────────────────────────────────── */
/* Two cards: today, its début and its fin and one button; then the week's
   days, each with its début and fin. No timer (user, 2026-11-24). */

.clock {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 12px 12px 110px;
  gap: 12px;
}
.hc-card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
}

.state { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--muted); }
.state-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.state-dot.on { background: var(--ok); }
.state:has(.state-dot.on) { color: var(--ok); }

.hc-today { margin: 4px 0 0; font-size: 13px; }
/* Début and fin, side by side: the two times the day is made of. */
.hc-times { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.hc-time { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-2); }
.hc-time span { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.hc-time strong { font-size: 30px; font-weight: 600; line-height: 1.15; font-variant-numeric: tabular-nums; }

/* The one control that matters. Sized so it is unmissable with a gloved thumb
   and impossible to confuse with anything else on the screen. */
.punch {
  margin: 26px 0 8px;
  width: 100%;
  max-width: 340px;
  min-height: 168px;
  border: none;
  border-radius: 28px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 25px;
  font-weight: 650;
  letter-spacing: -0.01em;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 18px;
  touch-action: manipulation;   /* kills the 300ms double-tap-zoom delay */
  transition: transform 0.08s ease, background 0.15s ease;
}
.punch:active { transform: scale(0.985); }
.punch:disabled { opacity: 0.45; }
.punch.armed { background: var(--danger); color: var(--on-danger); }
.punch.busy  { opacity: 0.7; }
.punch-hint { font-size: 14px; font-weight: 500; opacity: 0.85; }

/* The hours button: large and filled to start; once the day runs, outlined in
   red to end it, filled red on the confirming tap, which runs out in 4 s. */
.punch.hc-punch { max-width: none; min-height: 116px; margin: 16px 0 0; border-radius: 22px; font-size: 22px; }
.punch.hc-punch.is-end { min-height: 60px; background: transparent; color: var(--danger); border: 2px solid var(--danger); font-size: 18px; }
.punch.hc-punch.armed { position: relative; overflow: hidden; min-height: 72px; font-size: 18px; }
.punch.hc-punch.armed::after { content: ""; position: absolute; left: 0; bottom: 0; height: 4px; width: 100%; background: rgba(255,255,255,.7); transform-origin: left; animation: hc-arm 4s linear forwards; }
@keyframes hc-arm { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* The week: ‹ its name ›, then its days. */
.hc-week-head { display: flex; align-items: center; gap: 6px; }
.hc-week-title { flex: 1; display: flex; flex-direction: column; align-items: center; }
.hc-week-title strong { font-size: 15px; }
.hc-days { margin-top: 12px; }
.hc-week-sub { margin: 12px 0 0; text-align: center; font-size: 13px; }

/* ── Historique ────────────────────────────────────────────────────────── */

.history { width: 100%; }
.history-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }

.shift {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.shift-day { font-size: 14px; font-weight: 600; text-transform: capitalize; }
.shift-range { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.shift-times { font-size: 16px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.shift.anomaly { border-color: color-mix(in srgb, var(--warn) 55%, var(--border)); background: color-mix(in srgb, var(--warn) 8%, var(--surface)); }
.shift-flag { font-size: 12px; font-weight: 600; color: var(--warn); display: block; margin-top: 3px; }

/* ── Balayage en direct ────────────────────────────────────────────────── */

.live {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: #000;
}
.live video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Le cadre et les boutons, tenus là où le téléphone les tient. Un iPhone
   tourne l'écran malgré tout (aucune page web ne peut l'en empêcher) :
   scan.js les fait alors tourner en sens inverse (--live-turn), à la taille
   du téléphone en portrait. L'image de la caméra n'a besoin de rien : le
   téléphone la garde droite dans toutes les positions. */
.live-chrome { position: absolute; inset: 0; pointer-events: none; }
.live-chrome .live-bar { pointer-events: auto; }
.live-chrome.is-turned {
  inset: auto;
  left: 50%;
  top: 50%;
  width: 100vh;
  height: 100vw;
  transform: translate(-50%, -50%) rotate(var(--live-turn, 0deg));
}
@supports (height: 100dvh) { .live-chrome.is-turned { width: 100dvh; } }
.live-chrome.is-turned .live-bar {
  padding-bottom: calc(14px + max(env(safe-area-inset-left), env(safe-area-inset-right)));
}

/* Repère de visée : le décodage privilégie cette bande, donc le cadre doit
   correspondre à ce qui est réellement analysé. */
.live-frame {
  position: absolute;
  left: 6%;
  right: 6%;
  top: 50%;
  height: 26%;
  transform: translateY(-50%);
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 12px;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

/* Ligne animée : preuve immédiate que le balayage tourne. Sans elle, un
   lecteur qui cherche et un lecteur mort ont exactement la même apparence. */
.live-scanline {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 0 12px 2px rgba(255, 255, 255, 0.7);
  animation: scanline 1.8s ease-in-out infinite;
}
@keyframes scanline {
  0%, 100% { top: 4%; }
  50%      { top: 94%; }
}
@media (prefers-reduced-motion: reduce) {
  .live-scanline { animation: none; top: 50%; }
}

.live-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(0, 0, 0, 0.85), transparent);
}
.live-bar .btn-ghost {
  border-color: rgba(255, 255, 255, 0.5);
  color: #fff;
  background: rgba(0, 0, 0, 0.35);
}
.live-status {
  color: #fff;
  font-size: 13.5px;
  text-align: center;
  flex: 1;
  min-width: 0;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}

/* ── Bandeau d'installation ────────────────────────────────────────────── */

/* Above the bottom bar, which would otherwise cover it. */
.install-hint {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(84px + env(safe-area-inset-bottom));
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--muted);
  z-index: 20;
}
.install-hint .btn-ghost { flex: none; }

/* ── Feuille du bas (sheet.js) : confirmations ─────────────────────────── */

.sheet {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  overflow: hidden;
}
.sheet::backdrop { background: rgba(0, 0, 0, 0.5); }
.sheet-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-width: 560px;
  max-height: 88svh;
  margin: 0 auto;
  overflow-y: auto;
  padding: 10px 18px calc(18px + env(safe-area-inset-bottom));
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 24px 24px 0 0;
  background: var(--elevated);
  box-shadow: var(--shadow);
  transform: translateY(100%);
  transition: transform 0.2s ease;
}
.sheet.is-open .sheet-panel { transform: none; }
/* The grip that says the panel slides. */
.sheet-panel::before { content: ''; display: block; width: 38px; height: 4px; margin: 0 auto 16px; border-radius: 2px; background: var(--border); }
.sheet-title { margin: 0; font-size: 19px; font-weight: 650; line-height: 1.3; }
.sheet-text { margin: 8px 0 0; font-size: 15px; line-height: 1.5; color: var(--muted); }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }
.sheet-btn {
  min-height: 52px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  font-weight: 700;
}
.sheet-btn.is-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.sheet-btn.is-danger { background: var(--danger); border-color: var(--danger); color: var(--on-danger); }
.sheet-btn:disabled { opacity: 0.45; }
.sheet button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

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

/* An alarm (TerrainSheet.alarm): the wrong car. Red, a big title and mark,
   the two NIV, and the office's call first, full width. */
.sheet-panel.is-alarm { border: 2px solid var(--danger); border-bottom: 0; border-top-width: 8px; background: color-mix(in srgb, var(--danger) 14%, var(--elevated)); }
.sheet-alarm-mark { display: block; width: 56px; height: 56px; margin: 4px auto 10px; fill: none; stroke: var(--danger); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.sheet-panel.is-alarm .sheet-title { font-size: 26px; font-weight: 800; line-height: 1.2; text-align: center; color: var(--danger); }
.sheet-panel.is-alarm .sheet-text { font-size: 16px; text-align: center; color: var(--text); }
.sheet-facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 16px 0 0; padding: 12px 14px; border-radius: 12px; background: var(--elevated); }
.sheet-facts dt { font-size: 13px; font-weight: 700; color: var(--muted); align-self: center; }
.sheet-vin { margin: 0; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 15px; letter-spacing: 0.04em; overflow-wrap: anywhere; }
.sheet-vin span { color: var(--muted); }
.sheet-vin b { font-size: 17px; }
.sheet-panel.is-alarm .sheet-actions { grid-template-columns: 1fr; }
.sheet-panel.is-alarm a.sheet-btn { display: flex; align-items: center; justify-content: center; min-height: 56px; font-size: 17px; text-decoration: none; }
