/* Page d'accueil Pure Drive — mêmes jetons que CRM, Inbox et Parc (tokens.css). */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--black); color: var(--ink); font-family: var(--font);
  -webkit-font-smoothing: antialiased; overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- Accueil ---------- */
.home {
  min-height: 100%; display: flex; flex-direction: column; background: var(--bg);
}
.hero {
  position: relative; flex: 0 0 auto; min-height: calc(230px + env(safe-area-inset-top));
  padding: calc(env(safe-area-inset-top) + 14px) 20px 18px;
  display: flex; flex-direction: column; justify-content: space-between;
  background: #2B2722; color: var(--on-black); overflow: hidden;
}
.hero-bg { position: absolute; inset: 0; background-size: cover; background-position: center; }
.hero-bg.empty { background-image: none; }
.hero-bg.empty::after, .tile .pic.empty::after {
  /* Pas encore de photo : silhouette de roadster */
  content: ''; position: absolute; right: -30px; bottom: 6px; width: 340px; height: 114px; opacity: .22;
  background: no-repeat center / contain url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 66 22' fill='none' stroke='%23fff' stroke-width='.6'%3E%3Cpath d='M15 16.5c0-2.6 2-3.6 5-3.9l7.5-.8c2.4-3 5.4-4.4 9-4.4 3.2 0 5.5 1.5 7 3.6l9.5.9c4 .4 6.5 1.9 6.5 4.6v1H15z'/%3E%3Ccircle cx='24' cy='17.5' r='3.6'/%3E%3Ccircle cx='53' cy='17.5' r='3.6'/%3E%3C/svg%3E");
}
.hero::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(to bottom, rgba(0,0,0,.45), rgba(0,0,0,0) 40%, rgba(0,0,0,0) 45%, rgba(0,0,0,.6));
}
.hero-top, .hero-text { position: relative; z-index: 1; }
.hero-top { display: flex; justify-content: space-between; align-items: center; }
.brand { display: flex; align-items: center; gap: 10px; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.brand span { font-size: 22px; font-weight: 700; letter-spacing: 3px; }
.brand img { display: block; }
.round-btn {
  width: 44px; height: 44px; border-radius: 22px; border: 0; padding: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.18); color: var(--on-black);
}
.today { font-size: var(--fs-text); opacity: .9; }
.hello { font-size: 28px; font-weight: 700; margin-top: 2px; }

.tiles {
  flex: 1 1 auto; display: flex; flex-direction: column; gap: 12px;
  padding: 14px 16px 6px;
}
.tile {
  position: relative; flex: 1 1 0; min-height: 150px; border: 0; border-radius: 18px; overflow: hidden;
  background: #3A342C; color: var(--on-black); text-align: left; padding: 16px;
  display: flex; flex-direction: column; justify-content: flex-end;
}
.tile:active { transform: scale(.985); }
.tile .pic { position: absolute; inset: 0; background-size: cover; background-position: center; }
.tile .pic.empty::after { right: -10px; top: 8px; bottom: auto; width: 220px; height: 74px; }
.tile::after { content: ''; position: absolute; inset: 0; background: linear-gradient(to top, rgba(0,0,0,.72), rgba(0,0,0,.05) 75%); }
.tile-body { position: relative; z-index: 1; display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; }
.tile-name { font-size: 26px; font-weight: 700; line-height: 1.1; }
.tile-sub { font-size: var(--fs-sec); opacity: .88; margin-top: 3px; }
.counts { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }
.count {
  font-size: var(--fs-label); font-weight: 600; padding: 5px 10px; border-radius: 12px;
  background: rgba(255,255,255,.92); color: var(--ink); white-space: nowrap;
}
.count.strong { background: var(--gold); color: var(--ink); font-weight: 700; }
.count.muted { background: rgba(255,255,255,.2); color: var(--on-black); font-weight: 500; }
.codes-link {
  border: 0; background: none; color: var(--ink-muted); font-size: var(--fs-label);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); min-height: 44px;
}

/* ---------- Appli ouverte ---------- */
.appview {
  position: fixed; inset: 0; z-index: 10; background: var(--surface);
  display: flex; flex-direction: column;
  visibility: hidden; pointer-events: none;
}
.appview.on { visibility: visible; pointer-events: auto; }
.appbar {
  flex: 0 0 auto; display: flex; align-items: center; gap: 8px; background: var(--black); color: var(--on-black);
  padding: calc(env(safe-area-inset-top) + 4px) 10px 6px;
}
.back-pill {
  display: flex; align-items: center; gap: 2px; min-height: 40px; padding: 0 12px 0 6px;
  border: 0; border-radius: 20px; background: rgba(255,255,255,.14); color: var(--on-black);
  font-size: var(--fs-text); font-weight: 600; flex-shrink: 0;
}
.switch { flex: 1 1 auto; display: flex; justify-content: flex-end; gap: 6px; }
.switch button {
  border: 0; border-radius: 16px; min-height: 36px; padding: 0 12px;
  background: rgba(255,255,255,.14); color: var(--on-black); font-size: var(--fs-label); font-weight: 600;
}
.switch button.on { background: var(--gold); color: var(--ink); font-weight: 700; }
.frames {
  position: relative; flex: 1 1 auto;
  /* Bande blanche sous l'appli, à la place de la barre d'accueil de l'iPhone */
  margin-bottom: env(safe-area-inset-bottom);
}
.frames iframe {
  position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: var(--bg);
  visibility: hidden;
}
.appview.on .frames iframe.on { visibility: visible; }

/* ---------- Feuilles (codes, photos) ---------- */
.sheet {
  position: fixed; inset: 0; z-index: 20; background: var(--bg); overflow-y: auto; -webkit-overflow-scrolling: touch;
  border-top: env(safe-area-inset-top) solid var(--black);
}
.sheet-body { max-width: 560px; margin: 0 auto; padding: 8px var(--gutter) calc(28px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; }
.sheet-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; min-height: 48px; }
.sheet-head h2 { margin: 0; font-size: var(--fs-row); font-weight: 600; }
.sheet-head > :last-child { justify-self: end; }
.text-btn { border: 0; background: none; color: var(--ink); font-size: var(--fs-row); min-height: 44px; padding: 0 4px; text-decoration: underline; text-underline-offset: 3px; }
.text-btn.center { align-self: center; }
.setup-logo { display: flex; justify-content: center; }
.hint { margin: 0; color: var(--ink-muted); font-size: var(--fs-text); line-height: 1.4; text-align: center; }
.hint.small { font-size: var(--fs-label); }
.card { background: var(--surface); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: var(--fs-label); font-weight: 600; color: var(--ink-muted); }
.field-row { display: flex; align-items: center; gap: 10px; }
.input {
  flex: 1 1 auto; min-width: 0; min-height: 44px; border: 1px solid var(--outline); border-radius: 10px;
  padding: 0 12px; font: inherit; font-size: 16px; background: var(--surface); color: var(--ink);
}
.state { font-size: var(--fs-label); font-weight: 600; min-width: 74px; text-align: right; color: var(--ink-muted); }
.state:empty { display: none; }
.state.ok { color: var(--ok-ink); }
.state.err { color: var(--redline); }
.url-btn { align-self: flex-start; border: 0; background: none; color: var(--ink-muted); font-size: var(--fs-label); text-decoration: underline; padding: 4px 0; min-height: 32px; }
.btn-primary {
  min-height: 50px; border: 0; border-radius: 14px; background: var(--black); color: var(--on-black);
  font-size: var(--fs-row); font-weight: 600;
}
.btn-primary:disabled { opacity: .5; }

.slots { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.slots button {
  min-height: 40px; border: 1px solid var(--outline); border-radius: 20px; background: var(--surface);
  font-size: var(--fs-label); font-weight: 600; color: var(--ink);
}
.slots button.on { background: var(--black); border-color: var(--black); color: var(--on-black); }
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.grid button {
  position: relative; aspect-ratio: 4 / 3; border: 0; border-radius: 10px; overflow: hidden; padding: 0;
  background: var(--track) center / cover no-repeat;
}
.grid button.on { outline: 3px solid var(--gold); outline-offset: 2px; }
.grid button span {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 6px 4px; font-size: 11px; font-weight: 600; text-align: left;
  color: #fff; background: linear-gradient(to top, rgba(0,0,0,.7), rgba(0,0,0,0));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.grid .none { background: var(--surface); border: 1px dashed var(--outline); color: var(--ink-muted); font-size: var(--fs-label); }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30;
  background: var(--black); color: var(--on-black); padding: 10px 16px; border-radius: 12px; font-size: var(--fs-text);
  max-width: calc(100% - 32px); text-align: center;
}
.toast.err { background: var(--redline); }
