/* ===========================================================
   Tesla Stream — design "cockpit / instrument de bord"
   Graphite profond, typo technique (Rajdhani), lueur braise
   (écho au moteur thermique). Rouge = zone rouge / direct.
   =========================================================== */

@font-face { font-family: 'Rajdhani'; src: url('/vendor/fonts/rajdhani-500.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Rajdhani'; src: url('/vendor/fonts/rajdhani-600.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Rajdhani'; src: url('/vendor/fonts/rajdhani-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --bg: #12141a;
  --bg-deep: #0c0e13;
  --surface: #1a1d26;
  --surface-2: #232733;
  --line: #2c3140;
  --text: #eef1f6;
  --muted: #868d9f;
  --ember: #ff8a3d;
  --ember-soft: #ffb066;
  --redline: #ff3b30;
  --ice: #8fd0ff;
  --radius: 14px;
  --radius-lg: 22px;
  --display: 'Rajdhani', system-ui, sans-serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-tap-highlight-color: transparent;
}
body {
  background:
    radial-gradient(130% 90% at 50% -20%, #1d2230 0%, var(--bg) 55%, var(--bg-deep) 100%);
  background-attachment: fixed;
}
.hidden { display: none !important; }
::selection { background: var(--ember); color: #1a1205; }

h1, h2, h3 { font-family: var(--display); font-weight: 600; letter-spacing: .01em; }

/* ===================== Écrans plein cadre ===================== */
.screen {
  position: fixed; inset: 0; z-index: 10;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background:
    radial-gradient(120% 80% at 50% 0%, #1b2030 0%, var(--bg) 60%, var(--bg-deep) 100%);
}

/* ===================== PIN ===================== */
.pin-box { text-align: center; width: min(92vw, 380px); }
.pin-box h1 {
  font-size: 2.6rem; margin: 0 0 .15rem; font-weight: 700;
  letter-spacing: .04em;
}
.pin-sub { color: var(--muted); margin: 0 0 1.75rem; font-size: 1.05rem; }
.pin-dots { display: flex; gap: 20px; justify-content: center; margin-bottom: 1rem; }
.pin-dots span {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--line); transition: all .15s ease;
}
.pin-dots span.on {
  background: var(--ember); border-color: var(--ember);
  box-shadow: 0 0 14px rgba(255,138,61,.6);
}
.pin-error { color: var(--redline); min-height: 1.4em; margin-bottom: .5rem; font-weight: 500; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.keypad button {
  font-family: var(--display); font-weight: 600; font-size: 2rem;
  padding: 1rem; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--text); cursor: pointer; min-height: 74px;
  transition: background .12s, border-color .12s, transform .05s;
}
.keypad button:active { background: var(--ember); border-color: var(--ember); color: #1a1205; transform: scale(.97); }
.keypad .k-alt { background: transparent; color: var(--muted); font-size: 1.5rem; }

/* ===================== Barre supérieure ===================== */
.topbar {
  display: flex; align-items: center; gap: 1.5rem;
  padding: 1rem 1.5rem;
  background: linear-gradient(180deg, rgba(26,29,38,.9), rgba(18,20,26,.75));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 5;
}
.brand {
  display: flex; align-items: center; gap: .55rem;
  font-family: var(--display); font-weight: 700; font-size: 1.5rem; letter-spacing: .04em;
  white-space: nowrap;
}
.brand-dot {
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--ember); box-shadow: 0 0 12px rgba(255,138,61,.8);
}
.tabs { display: flex; gap: .25rem; margin-left: auto; }
.tab {
  font-family: var(--display); font-weight: 600; font-size: 1.1rem; letter-spacing: .02em;
  padding: .55rem 1.1rem; border: none; background: transparent; color: var(--muted);
  cursor: pointer; border-radius: 10px; position: relative; transition: color .15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); }
.tab.active::after {
  content: ''; position: absolute; left: 1.1rem; right: 1.1rem; bottom: -2px; height: 3px;
  background: var(--ember); border-radius: 3px; box-shadow: 0 0 10px rgba(255,138,61,.7);
}

.view { padding: 1.75rem 1.5rem 3rem; max-width: 1400px; margin: 0 auto; }

/* ===================== Recherche ===================== */
.search { display: flex; gap: .6rem; margin-bottom: 1.5rem; }
.search input {
  flex: 1; font-size: 1.15rem; padding: .95rem 1.2rem; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.search input::placeholder { color: var(--muted); }
.search input:focus {
  outline: none; border-color: var(--ember);
  box-shadow: 0 0 0 3px rgba(255,138,61,.18);
}
.search button {
  font-family: var(--display); font-weight: 600; font-size: 1.1rem; letter-spacing: .02em;
  padding: .95rem 1.6rem; border: none; border-radius: var(--radius);
  background: var(--ember); color: #1a1205; cursor: pointer;
}
.search button:active { background: var(--ember-soft); }

/* ===================== État d'accueil / vide ===================== */
.empty-state { text-align: center; padding: 4rem 1rem 2rem; color: var(--muted); }
.empty-state h2 { font-size: 1.8rem; color: var(--text); margin: 0 0 .5rem; }
.empty-state p { margin: 0 0 1.75rem; font-size: 1.05rem; }
.chips { display: flex; flex-wrap: wrap; gap: .6rem; justify-content: center; }
.chip {
  font-size: 1rem; padding: .6rem 1.1rem; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer;
  transition: border-color .15s, color .15s;
}
.chip:hover { border-color: var(--ember); }
.chip:active { background: var(--ember); color: #1a1205; border-color: var(--ember); }

.status { color: var(--muted); padding: .75rem 0; font-size: 1.05rem; }

/* ===================== Grille / cartes ===================== */
.grid {
  display: grid; gap: 1.25rem;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}
.card {
  position: relative; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; cursor: pointer;
  transition: border-color .15s, transform .08s;
}
.card:hover { border-color: #3a4152; }
.card:active { transform: scale(.985); border-color: var(--ember); }
.card img.thumb,
.card div.thumb {
  width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block;
  background: var(--surface-2); background-size: cover; background-position: center;
}
.card div.thumb { display: flex; align-items: center; justify-content: center; }
.card .thumb.noimg { background: var(--surface-2); }
.card .folder { font-size: 2.6rem; opacity: .6; }
.card .meta { padding: .8rem .9rem 1rem; }
.card .title {
  font-size: 1.05rem; line-height: 1.3; margin: 0 0 .35rem; font-weight: 500;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card .sub { color: var(--muted); font-size: .9rem; }
.card .progress { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(0,0,0,.4); }
.card .progress > div { height: 100%; background: var(--ember); box-shadow: 0 0 8px rgba(255,138,61,.6); }

/* ===================== Fil d'Ariane ===================== */
.breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-bottom: 1.25rem; }
.breadcrumb .crumb {
  font-family: var(--display); font-weight: 500; font-size: 1.05rem;
  background: var(--surface); color: var(--text); border: 1px solid var(--line); cursor: pointer;
  padding: .45rem 1rem; border-radius: 999px;
}
.breadcrumb .crumb:active { border-color: var(--ember); }
.breadcrumb .sep { color: var(--muted); }

.section-h { font-size: 1.5rem; margin: .25rem 0 1rem; }
.section-h + .grid { margin-bottom: 2.5rem; }

/* ===================== Formulaire Paramètres ===================== */
.settings-form { max-width: 460px; display: flex; flex-direction: column; gap: 1.1rem; }
.settings-form h2 { margin: 0; font-size: 1.6rem; }
.settings-form label { display: flex; flex-direction: column; gap: .4rem; color: var(--muted); font-size: .95rem; }
.settings-form input {
  font-size: 1.05rem; padding: .85rem 1rem; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
}
.settings-form input:focus { outline: none; border-color: var(--ember); box-shadow: 0 0 0 3px rgba(255,138,61,.18); }
.settings-form button {
  font-family: var(--display); font-weight: 600; font-size: 1.1rem;
  padding: .9rem 1.5rem; border: none; border-radius: var(--radius);
  background: var(--ember); color: #1a1205; cursor: pointer; align-self: flex-start;
}

/* ===================== Vue Moteur — tachymètre ===================== */
.engine-wrap {
  max-width: 440px; margin: 1rem auto 0; display: flex; flex-direction: column;
  align-items: center; gap: 1.5rem; text-align: center;
}
.tacho { position: relative; width: min(86vw, 360px); aspect-ratio: 1; }
.tacho-svg { width: 100%; height: 100%; display: block; }
.tacho-track { fill: none; stroke: var(--surface-2); stroke-width: 14; stroke-linecap: round; }
.tacho-fill {
  fill: none; stroke: var(--ember); stroke-width: 14; stroke-linecap: round;
  filter: drop-shadow(0 0 6px rgba(255,138,61,.55));
}
.tacho-redline { fill: none; stroke: var(--redline); stroke-width: 14; stroke-linecap: round; }
.tacho-tick { stroke: var(--line); stroke-width: 2; }
.tacho-hub { fill: var(--surface-2); stroke: var(--line); stroke-width: 2; }
#tacho-needle line { stroke: var(--text); stroke-width: 4; stroke-linecap: round; transition: none; }
.tacho-center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; pointer-events: none;
}
.tacho-center .rpm {
  font-family: var(--display); font-weight: 700; font-size: 4rem; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.tacho-center .rpm-unit {
  font-family: var(--display); font-weight: 600; font-size: .9rem; letter-spacing: .25em;
  color: var(--muted); margin-top: .25rem;
}
.speed-line { font-family: var(--display); font-weight: 600; font-size: 1.8rem; font-variant-numeric: tabular-nums; }
.speed-line .unit { color: var(--muted); font-size: 1.2rem; }
.tag {
  font-size: .8rem; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line);
  padding: .15rem .65rem; border-radius: 999px; vertical-align: middle; margin-left: .4rem;
}
.big-btn {
  font-family: var(--display); font-weight: 700; font-size: 1.3rem; letter-spacing: .03em;
  padding: 1.05rem 2.6rem; border: none; border-radius: 999px;
  background: var(--ember); color: #1a1205; cursor: pointer;
  box-shadow: 0 0 24px rgba(255,138,61,.35);
}
.big-btn.running { background: transparent; color: var(--text); border: 2px solid var(--line); box-shadow: none; }
.manual { display: flex; flex-direction: column; gap: .5rem; width: 100%; color: var(--muted); }
.manual input[type="range"] { width: 100%; height: 36px; accent-color: var(--ember); }
.hint { color: var(--muted); font-size: .9rem; line-height: 1.45; max-width: 420px; }

/* ===================== Lecteur ===================== */
#player-screen { background: #000; z-index: 20; }
.player-back, .player-fav {
  position: absolute; top: 1.1rem; z-index: 2; border: none; cursor: pointer;
  background: rgba(20,22,30,.7); color: #fff; backdrop-filter: blur(8px);
  border-radius: 999px;
}
.player-back { left: 1.1rem; font-family: var(--display); font-weight: 600; font-size: 1.05rem; padding: .65rem 1.3rem; }
.player-fav { right: 1.1rem; font-size: 1.5rem; line-height: 1; padding: .5rem .8rem; }
.player-fav.on { color: var(--ember); }
.player-title {
  position: absolute; top: 1.25rem; left: 50%; transform: translateX(-50%);
  max-width: 52vw; text-align: center; color: #fff; opacity: .92;
  font-family: var(--display); font-weight: 600; font-size: 1.15rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* La vidéo décode (audio + images) mais reste invisible : Tesla ne « voit » pas de
   surface vidéo affichée en roulant. L'image est repeinte dans le canvas. */
#video {
  position: absolute; left: 0; bottom: 0; width: 2px; height: 2px;
  opacity: .01; pointer-events: none; z-index: 0;
}
#player-canvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain; background: #000; z-index: 1;
}
.player-status {
  position: absolute; bottom: 5rem; left: 50%; transform: translateX(-50%); color: var(--muted); z-index: 2;
}
.player-controls {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
  display: flex; align-items: center; gap: 1rem; padding: 1rem 1.5rem;
  background: linear-gradient(0deg, rgba(0,0,0,.75), rgba(0,0,0,0));
}
.pc-btn {
  border: none; cursor: pointer; background: rgba(20,22,30,.7); color: #fff;
  backdrop-filter: blur(8px); border-radius: 999px; width: 48px; height: 48px;
  font-size: 1.1rem; line-height: 1; flex: none;
}
.pc-time { font-family: var(--display); font-weight: 600; font-variant-numeric: tabular-nums; color: #fff; min-width: 3.2em; text-align: center; }
.pc-seek { flex: 1; height: 36px; accent-color: var(--ember); cursor: pointer; }

@media (max-width: 640px) {
  .topbar { gap: .75rem; padding: .8rem 1rem; }
  .brand { font-size: 1.25rem; }
  .tab { padding: .5rem .7rem; font-size: 1rem; }
  .view { padding: 1.25rem 1rem 2.5rem; }
}
