/* Car Remote — thème « matin de givre » : bleu glacier au repos, ambre quand ça chauffe. */

@font-face { font-family: "Barlow"; src: url("/fonts/barlow-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Barlow"; src: url("/fonts/barlow-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Barlow"; src: url("/fonts/barlow-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Barlow Condensed"; src: url("/fonts/barlow-condensed-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Barlow Condensed"; src: url("/fonts/barlow-condensed-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }

:root {
  --bg: #E9F0F4;
  --surface: #F8FBFC;
  --surface-2: #DFE8EE;
  --ink: #18303F;
  --muted: #5F7684;
  --line: #CCD9E1;
  --cold: #2F7FA8;
  --cold-soft: #D3E6F1;
  --heat: #E8902E;
  --heat-deep: #B9561A;
  --heat-soft: #FBE5CC;
  --ok: #2E7D5E;
  --warn: #B8441C;

  --r-hero: 28px;
  --r-panel: 18px;
  --r-btn: 14px;

  --f-body: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-num: "Barlow Condensed", "Barlow", system-ui, sans-serif;

  --pad: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14222C;
    --surface: #1C2E3A;
    --surface-2: #233846;
    --ink: #E6EEF2;
    --muted: #93A8B5;
    --line: #2C4352;
    --cold: #6FB6DA;
    --cold-soft: #1F4256;
    --heat: #F3A54A;
    --heat-deep: #F7BE78;
    --heat-soft: #4A3420;
    --ok: #6CC79E;
    --warn: #F08A64;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 400 17px/1.45 var(--f-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--cold); outline-offset: 2px; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.muted { color: var(--muted); }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 20px;
  border: 0; border-radius: var(--r-btn);
  font-weight: 600; font-size: 17px;
  transition: background-color .15s, transform .08s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn-block { width: 100%; }
.btn-primary { background: var(--cold); color: #fff; }
.btn-quiet { background: var(--surface-2); color: var(--ink); }
.btn-quiet small { font-weight: 400; color: var(--muted); margin-left: 4px; }
.btn-heat { background: var(--ink); color: var(--surface); min-height: 60px; font-size: 18px; position: relative; }
.climate.is-on .btn-heat { background: var(--heat-deep); color: #fff; }
@media (prefers-color-scheme: dark) { .climate.is-on .btn-heat { background: var(--heat); color: #241306; } }
.btn-link {
  background: none; border: 0; padding: 8px 0; color: var(--cold);
  font-weight: 500; text-decoration: underline; text-underline-offset: 3px;
}

.icon-btn {
  width: 44px; height: 44px; display: grid; place-items: center;
  background: transparent; border: 0; border-radius: 50%; color: var(--ink);
}
.icon-btn svg { width: 24px; height: 24px; }
.icon-btn:active { background: var(--surface-2); }
.icon-btn.is-busy svg { animation: spin 1s linear infinite; }

/* ---------- Écrans d'accès ---------- */
.gate { min-height: 100dvh; display: grid; place-items: center; padding: calc(var(--pad) + var(--safe-top)) var(--pad) calc(var(--pad) + var(--safe-bottom)); }
.gate-card { width: 100%; max-width: 380px; display: grid; gap: 14px; }
.gate-mark { width: 52px; height: 52px; color: var(--cold); }
.gate-title { margin: 0; font: 600 34px/1.05 var(--f-num); letter-spacing: .005em; }
.gate-lede { margin: 0 0 6px; color: var(--muted); }
.gate-note { margin: 0; font-size: 15px; color: var(--muted); }
.field { display: grid; gap: 6px; }
.field span { font-size: 15px; font-weight: 500; color: var(--muted); }
.field input {
  min-height: 52px; padding: 0 14px;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r-btn);
  font-size: 18px;
}
.field input:focus { border-color: var(--cold); outline: none; }
.form-error { margin: 0; color: var(--warn); font-weight: 500; }
.otp-methods { display: grid; gap: 10px; }

/* ---------- Télécommande ---------- */
.remote {
  max-width: 520px; margin: 0 auto;
  padding: calc(8px + var(--safe-top)) var(--pad) calc(28px + var(--safe-bottom));
  display: grid; gap: 14px;
}

.topbar { display: flex; align-items: center; gap: 4px; position: relative; }
.topbar-id { flex: 1; min-width: 0; }
.car-name { margin: 0; font: 600 30px/1.1 var(--f-num); }
.car-sub { margin: 0; font-size: 14px; color: var(--muted); display: flex; flex-wrap: wrap; column-gap: 10px; }
.menu {
  position: absolute; right: 0; top: 48px; z-index: 5;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-btn);
  padding: 6px; min-width: 180px;
  box-shadow: 0 12px 30px -12px rgba(24, 48, 63, .35);
}
.menu button { width: 100%; text-align: left; background: none; border: 0; padding: 12px; border-radius: 10px; }
.menu button:active { background: var(--surface-2); }

/* Batterie : bande sobre, lisible d'un coup d'œil */
.battery { display: grid; gap: 8px; padding: 4px 2px 0; }
.battery-figure { display: flex; align-items: baseline; justify-content: space-between; }
.battery-pct { font: 600 46px/1 var(--f-num); font-variant-numeric: tabular-nums; }
.battery-pct small { font-size: 24px; margin-left: 2px; color: var(--muted); }
.battery-range { font: 500 24px/1 var(--f-num); color: var(--muted); }
.battery-bar { position: relative; height: 10px; border-radius: 5px; background: var(--surface-2); overflow: visible; }
.battery-fill { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 5px; background: var(--cold); transition: width .6s ease; }
.battery-fill.is-low { background: var(--warn); }
.battery-fill.is-charging { background-image: repeating-linear-gradient(115deg, transparent 0 8px, rgba(255,255,255,.28) 8px 16px); background-size: 200% 100%; animation: flow 1.2s linear infinite; }
.battery-limit { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--ink); opacity: .5; left: 100%; }
.battery-state { margin: 0; font-size: 15px; color: var(--muted); }

/* Climatisation : la pièce maîtresse */
.climate {
  position: relative; overflow: hidden; isolation: isolate;
  background: var(--surface);
  border-radius: var(--r-hero);
  padding: 20px var(--pad) var(--pad);
  display: grid; gap: 16px;
  border: 1px solid var(--line);
  transition: border-color .4s;
}
.climate-glow {
  position: absolute; z-index: -1; left: 50%; top: 34%;
  width: 150%; aspect-ratio: 1; translate: -50% -50%;
  background: radial-gradient(closest-side, var(--heat-soft), transparent 72%);
  opacity: 0; scale: .6;
  transition: opacity .9s ease, scale 1.2s cubic-bezier(.2,.8,.2,1);
}
.climate.is-on { border-color: color-mix(in srgb, var(--heat) 45%, var(--line)); }
.climate.is-on .climate-glow { opacity: 1; scale: 1; animation: breathe 5s ease-in-out 1.2s infinite; }
.climate-status { margin: 0; text-align: center; font-weight: 500; color: var(--muted); }
.climate.is-on .climate-status { color: var(--heat-deep); }

.dial { display: grid; grid-template-columns: 64px 1fr 64px; align-items: center; }
.dial-step {
  width: 64px; height: 64px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-2); border: 0; color: var(--ink);
}
.dial-step svg { width: 26px; height: 26px; }
.dial-step:active { background: var(--line); }
.dial-value {
  text-align: center;
  font: 600 96px/0.9 var(--f-num);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
  transition: color .6s;
}
.dial-value span { font-size: .45em; letter-spacing: 0; }
.dial-value sup { font-size: .26em; font-weight: 500; vertical-align: top; position: relative; top: .5em; margin-left: 2px; color: var(--muted); }
.climate.is-on .dial-value { color: var(--heat-deep); }

.chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 4px; background: var(--surface-2); border-radius: 999px; }
.chip { min-height: 40px; border: 0; border-radius: 999px; background: transparent; font-weight: 500; font-size: 15px; color: var(--muted); }
.chip[aria-checked="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(24,48,63,.15); }

.toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.toggle {
  display: flex; align-items: center; gap: 8px;
  min-height: 52px; padding: 0 12px;
  background: transparent; border: 1.5px solid var(--line); border-radius: var(--r-btn);
  font-weight: 500; font-size: 15px; text-align: left;
}
.toggle svg { width: 22px; height: 22px; flex: none; color: var(--muted); }
.toggle[aria-pressed="true"], .toggle.seat:not([data-level="0"]) { border-color: var(--heat); background: var(--heat-soft); }
.toggle[aria-pressed="true"] svg, .toggle.seat:not([data-level="0"]) svg { color: var(--heat-deep); }
.seat-dots { margin-left: auto; display: flex; gap: 3px; }
.seat-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--line); }
.toggle.seat[data-level="1"] .seat-dots i:nth-child(-n+1),
.toggle.seat[data-level="2"] .seat-dots i:nth-child(-n+2),
.toggle.seat[data-level="3"] .seat-dots i { background: var(--heat-deep); }

/* Portes : deux grosses touches, comme une clé */
.locks { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.lock-btn {
  display: grid; justify-items: center; gap: 6px;
  padding: 18px 8px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel);
  font-weight: 600;
}
.lock-btn svg { width: 30px; height: 30px; }
.lock-btn:active { background: var(--surface-2); }
.lock-btn.is-current { border-color: var(--cold); box-shadow: inset 0 0 0 1px var(--cold); }
#btn-unlock.is-current { border-color: var(--warn); box-shadow: inset 0 0 0 1px var(--warn); color: var(--warn); }
.lock-state { grid-column: 1 / -1; margin: -2px 0 0; text-align: center; font-size: 15px; color: var(--muted); }

/* Panneaux secondaires */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); padding: var(--pad); display: grid; gap: 14px; }
.panel-title { margin: 0; font: 600 22px/1.1 var(--f-num); }
.charge-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.charge-actions .btn { font-size: 15px; padding: 0 10px; }
.limits { display: grid; gap: 14px; }
.limit { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: baseline; }
.limit span { font-size: 15px; color: var(--muted); }
.limit output { font: 600 22px/1 var(--f-num); }
.limit input { grid-column: 1 / -1; width: 100%; accent-color: var(--cold); height: 28px; }

.details { margin: 0; display: grid; grid-template-columns: 1fr auto; }
.details dt, .details dd { margin: 0; padding: 10px 0; border-top: 1px solid var(--line); }
.details dt { color: var(--muted); }
.details dd { text-align: right; font-weight: 500; }
.details dd.is-alert { color: var(--warn); }
.details dt:first-of-type, .details dd:first-of-type { border-top: 0; }

.footnote { margin: 4px 0 0; font-size: 13px; color: var(--muted); text-align: center; }

/* Confirmation */
.confirm {
  border: 0; border-radius: var(--r-panel); padding: 20px; max-width: 340px; width: calc(100% - 32px);
  background: var(--surface); color: var(--ink);
}
.confirm::backdrop { background: rgba(10, 22, 30, .5); }
.confirm p { margin: 0 0 18px; font-size: 18px; }
.confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* Suivi de commande */
.toast {
  position: fixed; left: 50%; bottom: calc(18px + var(--safe-bottom)); translate: -50% 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  max-width: calc(100% - 32px); padding: 12px 18px;
  background: var(--ink); color: var(--surface);
  border-radius: 999px; font-weight: 500; font-size: 15px;
  box-shadow: 0 10px 30px -10px rgba(10, 22, 30, .5);
}
.toast.is-error { background: var(--warn); color: #fff; }
.toast.is-success { background: var(--ok); color: #fff; }
.toast-spinner { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
.toast:not(.is-pending) .toast-spinner { display: none; }

.boot { position: fixed; inset: 0; background: var(--bg); z-index: 20; }

@keyframes spin { to { rotate: 360deg; } }
@keyframes flow { to { background-position: -64px 0; } }
@keyframes breathe { 50% { scale: 1.06; } }

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

@media (min-width: 420px) {
  .dial-value { font-size: 112px; }
}
