/* The favourites (/gardees, src/app/garage/): the cars kept, in 3D and as compact cards, and one act, "Comparer",
   which opens their comparison (src/app/compare/). Two cars are no longer fixed here.

   Built on public/app/app.css and src/app/DESIGN.md: it adds no token and writes no colour. */

.cmp { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 var(--pad); }

/* ── The garage ──────────────────────────────────────────────────────────────────────────────────────── */

/* The visitor's own garage needs scripts (the device keeps it): it shows once the page knows it has cars
   (`data-kept`, view.ts). A list a link carries is in the page. */
/* Its head is always there: its name, how many, and "Comparer". */
.garage { margin-top: 10px; }
.garage-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; min-height: 44px; margin-bottom: 8px; }
/* Its name, and how many under it (beside it with room). */
.garage-h { display: grid; gap: 3px; min-width: 0; font: 800 1.5rem/1.1 var(--display); letter-spacing: -0.025em; white-space: nowrap; }
.garage-acts { display: flex; align-items: center; gap: 10px; }
.garage-go .ic { width: 18px; height: 18px; }
/* More favourites than a comparison holds: the line that names the five "Comparer" takes, on a line of its own under
   the head. Its room is kept before the first paint (`data-kept-many`, view.ts), so that nothing moves when it comes. */
.garage-five { flex: 1 0 100%; margin: 0; color: var(--soft); text-wrap: pretty; }
.garage-five:empty { display: none; }
:root[data-kept-many] .garage:not(.is-sent) .garage-five { display: block; min-height: 3lh; }
@media (min-width: 760px) {
  :root[data-kept-many] .garage:not(.is-sent) .garage-five { min-height: 2lh; }
}
/* The visitor's own favourites need scripts (the device keeps them): "Comparer", their 3D and cards show once the page
   knows there are some (`data-kept`, view.ts). A list a link carries is in the page. */
:root:not([data-kept]) .garage:not(.is-sent) :is(.garage-acts, .gk-list, .garage-foot),
:root[data-kept="0"] .garage:not(.is-sent) :is(.garage-acts, .gk-list, .garage-foot) { display: none; }
.garage-n { font: 500 0.71875rem/1 var(--label); letter-spacing: 0.01em; color: var(--soft); white-space: nowrap; font-variant-numeric: tabular-nums; }
.garage-n:empty::before { content: "\a0"; }

/* Nothing kept: one line says what the heart does, one link leads to the cars. */
.cmp-none { display: none; }
:root[data-kept="0"] .cmp-none {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 8px; margin-top: 8px; padding: 16px 12px;
  border-top: 1px solid var(--line); font: 500 0.875rem/1.4 var(--body); color: var(--soft); text-align: center; text-wrap: balance;
}
.cmp-none .ic { width: 17px; height: 17px; color: var(--ink); }
.cmp-none a { position: relative; color: var(--ink); font-weight: 650; }
.cmp-none a::after { content: ""; position: absolute; inset: -12px -6px; }

/* ── The 3D ──────────────────────────────────────────────────────────────────────────────────────────── */

/* Its room is given before the first paint where the device kept cars and can draw it (`data-garage`). On a phone
   it bleeds to the screen's edges; with room it is a rounded window. */
.garage-view { display: none; }
:root[data-garage] .garage:not(.is-sent) .garage-view {
  position: relative; display: block; overflow: hidden; isolation: isolate; margin: 0 calc(var(--pad) * -1);
  height: clamp(250px, 42svh, 380px); container: garage / inline-size;
  /* The room before the 3D is there: a wall over a floor, in the page's own colours. */
  background:
    radial-gradient(70% 34% at 50% 66%, color-mix(in srgb, var(--card) 70%, transparent), transparent 100%),
    linear-gradient(to bottom, color-mix(in srgb, var(--card) 55%, var(--paper)) 0%, var(--paper) 60%, color-mix(in srgb, var(--road) 90%, var(--ink)) 61%, var(--road) 100%);
}

/* The flat garage: the cars side by side from the side, at one scale, standing on the floor. */
.garage-poster { position: absolute; inset: 0; transition: opacity 0.35s ease-out 0.15s, visibility 0s; }
.garage-row {
  /* The scale: the row fits the width, a car is never drawn larger than on a street. */
  --mm: min(0.11px, calc((100cqw - 2 * var(--pad) - 16px) / var(--row)));
  position: absolute; left: 50%; top: 61%; translate: -50% -100%;
  display: flex; align-items: flex-end; gap: calc(var(--gap) * var(--mm));
}
.garage-flat { display: block; }

/* The 3D, over the flat garage: it fades in once its first frame is drawn, and the flat garage goes. */
.garage-canvas {
  position: absolute; inset: 0; z-index: 0; display: block; width: 100%; height: 100%; opacity: 0; transition: opacity 0.4s ease-out;
  touch-action: pan-y; cursor: grab; outline: none; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none;
}
.garage-canvas.is-held { cursor: grabbing; }
.garage-canvas:focus-visible { outline: 2.5px solid var(--ink); outline-offset: -4px; }
.garage[data-state="live"] .garage-canvas { opacity: 1; }
.garage[data-state="live"] .garage-poster { opacity: 0; visibility: hidden; transition: opacity 0.3s ease-out 0.25s, visibility 0s 0.6s; }

/* Which cars stand there, when it parks fewer than are kept: at its top. */
.garage-sub { position: absolute; z-index: 2; left: 0; top: 0; max-width: 100%; padding: 10px var(--pad) 0; pointer-events: none; }

/* What a tap does: said at its bottom, until the first car is chosen or the garage turned. */
.garage-hint {
  position: absolute; z-index: 2; left: 50%; bottom: 10px; translate: -50% 0; max-width: calc(100% - 24px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; pointer-events: none;
  padding: 4px 12px; border-radius: var(--r-pill); background: color-mix(in srgb, var(--card) 88%, transparent); box-shadow: 0 0 0 1px var(--line);
  font: 550 0.75rem/1.4 var(--body); color: var(--ink); opacity: 0; transition: opacity 0.4s ease-out;
}
.garage[data-state="live"] .garage-hint:not(.is-gone):not(:empty) { opacity: 1; }
.garage-wake { position: absolute; z-index: 3; left: 50%; bottom: 14px; translate: -50% 0; }

/* The signs over the cars: each a link to its car's page, its price against the car held under its name. */
.garage-signs { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.garage-sign {
  position: absolute; left: 0; top: 0; display: inline-grid; grid-template-columns: auto auto; justify-items: center; align-items: center; column-gap: 6px; row-gap: 1px; max-width: 46vw; padding: 3px 10px 4px;
  border: 1px solid var(--line); border-radius: 12px; background: color-mix(in srgb, var(--card) 90%, transparent); box-shadow: var(--lift-1);
  font: 700 0.78rem/1.15 var(--display); letter-spacing: -0.008em; color: var(--ink); text-decoration: none; white-space: nowrap; pointer-events: auto; will-change: transform;
  /* As on the canvas: a finger moving sideways from a sign turns the garage, up or down it scrolls the page. */
  touch-action: pan-y;
  transition: opacity 0.2s ease-out, visibility 0s, background-color var(--quick), border-color var(--quick);
}
.garage-sign b { grid-column: 1 / -1; max-width: 100%; overflow: hidden; text-overflow: ellipsis; font-weight: inherit; }
.garage-sign small { grid-column: 1 / -1; font: 600 0.65625rem/1.1 var(--label); color: var(--soft); font-variant-numeric: tabular-nums; }
/* The thumb's room around a sign. */
.garage-sign::after { content: ""; position: absolute; inset: -9px -4px; }
/* A sign with no place, and every sign before the 3D: gone, and out of the keyboard's way. */
.garage-sign.is-off, .garage:not([data-state="live"]) .garage-sign { opacity: 0; visibility: hidden; pointer-events: none; transition: opacity 0.2s ease-out, visibility 0s 0.2s; }
/* On a phone the row is dense: a long name goes on two short lines, so that every sign finds its place. */
@container garage (max-width: 600px) {
  .garage-sign { max-width: 104px; white-space: normal; text-align: center; text-wrap: balance; font-size: 0.75rem; padding: 3px 8px 4px; }
}

/* ── The cards: every car of the garage, compact (the 3D above is the picture) ───────────────────────── */

/* On a phone a column of rows; with room, tiles in a grid. Its picture and its name lead to its page; its heart takes
   it out of the favourites. */
.gk-list { display: grid; grid-template-columns: minmax(0, 1fr); margin-top: 6px; border-top: 1px solid var(--line); }
:root[data-kept] .gk-list:empty { min-height: calc(var(--kept, 0) * 73px); }
.gk {
  position: relative; display: grid; grid-template-columns: 84px minmax(0, 1fr) auto; grid-template-rows: auto auto; align-items: center; column-gap: 12px;
  min-height: 72px; padding: 8px 0; border-bottom: 1px solid var(--line);
}
.gk-go { grid-column: 1; grid-row: 1 / span 2; display: grid; place-items: end center; width: 84px; min-height: 40px; padding: 0 0 2px; color: inherit; -webkit-tap-highlight-color: transparent; }
.gk-pic { --mm: 0.0165px; display: grid; place-items: end center; min-height: 34px; }
.gk-id { grid-column: 2; grid-row: 1; display: grid; justify-items: start; min-width: 0; align-self: end; }
.gk-make { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.59375rem; line-height: 14px; }
/* A long name takes two lines rather than lose its end. Its target reaches 24 px and more, moving nothing. */
.gk-name {
  position: relative; z-index: 1; display: -webkit-box; min-width: 24px; max-width: 100%; margin: -3px 0; padding: 3px 0; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
  font: 700 1rem/1.2 var(--display); letter-spacing: -0.013em; text-decoration: none; overflow-wrap: anywhere;
}
.gk-price { grid-column: 2; grid-row: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; min-width: 0; align-self: start; }
.gk-price .gap { min-height: 22px; padding: 1px 8px; font-size: 0.75rem; }
/* Out of the favourites: its heart, filled, as it is one. */
.gk-out {
  grid-column: 3; grid-row: 1 / span 2; position: relative; z-index: 1; display: grid; place-items: center; width: 44px; height: 44px; margin-right: -8px;
  border: 0; border-radius: 50%; background: none; color: var(--ink); transition: background-color var(--quick), scale var(--quick);
}
.gk-out .ic { width: 19px; height: 19px; --ic-in: var(--paint); }
.gk-out:active { scale: 0.92; background: var(--line); }

/* Under the garage: whose pictures, in a few words that stay in sight, the rest one tap away by the quiet "ⓘ";
   and what can be done with the whole list. */
.garage-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; margin-top: 6px; }
.garage-note { flex: 1 1 260px; min-width: 0; line-height: 1.45; text-wrap: pretty; }
.garage-note > summary { display: flex; align-items: center; gap: 8px; min-height: 44px; list-style: none; cursor: pointer; }
.garage-note > summary::-webkit-details-marker { display: none; }
.garage-i { font: 500 0.9375rem/1 var(--body); color: var(--soft); }
.garage-note[open] .garage-i { color: var(--ink); }
.garage-note > p { padding-bottom: 8px; }
.garage-send .ic { width: 17px; height: 17px; }

/* ── Proches de vos favoris: the cars the industry map sets beside them (src/app/garage/near.ts) ───────────
   The card's own line (app.css, "A relative's line"), each with its heart. Six at most: a phone shows the first
   three, one a favourite; with room, two rows of three. The visitor's own come once the script knows them: their room
   is kept before the first paint (`data-kept`, view.ts), given back when the map proposes nothing. */

.near { margin-top: 20px; }
.near-h { margin: 0 0 4px; font: 800 1.1875rem/1.2 var(--display); letter-spacing: -0.017em; outline: none; }
.near-list > li { container-type: inline-size; border-top: 1px solid var(--line); }
.near-list > li:last-child { border-bottom: 1px solid var(--line); }
.near-how { margin-top: 2px; }
.near-how > p { padding-bottom: 8px; }
:root[data-kept]:not([data-kept="0"]) .near-slot[data-own]:not([data-near]) { min-height: 470px; }
@media (max-width: 759px) {
  .near-list > li:nth-child(n + 4) { display: none; }
  .near-list > li:nth-child(3) { border-bottom: 1px solid var(--line); }
}

/* ── With room ───────────────────────────────────────────────────────────────────────────────────────── */

@media (min-width: 760px) {
  .near { margin-top: 28px; }
  .near-h { font-size: 1.375rem; }
  .near-list { grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); column-gap: 28px; }
  .near-list > li:last-child { border-bottom: 0; }
  :root[data-kept]:not([data-kept="0"]) .near-slot[data-own]:not([data-near]) { min-height: 360px; }
  .garage { margin-top: 22px; }
  .garage-h { display: flex; align-items: baseline; gap: 10px; font-size: 2.125rem; }
  :root[data-garage] .garage:not(.is-sent) .garage-view { margin: 0; height: clamp(300px, 48svh, 500px); border-radius: var(--r-l); box-shadow: inset 0 0 0 1px var(--line); }
  .garage-sub { padding: 14px 18px 0; }

  .gk-list { grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 8px; margin-top: 12px; border: 0; }
  :root[data-kept] .gk-list:empty { min-height: calc(round(up, var(--kept, 0) / 4, 1) * 80px); }
  .gk { min-height: 74px; padding: 9px 10px 9px 6px; border: 0; border-radius: var(--r-m); background: var(--card); box-shadow: inset 0 0 0 1px var(--line); transition: box-shadow var(--quick); }
  .gk-out { margin-right: -4px; }
  .garage-foot { margin-top: 10px; }
}

@media (hover: hover) {
  .garage-sign:hover { background: var(--card); border-color: var(--edge); }
  .gk-name:hover { text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 4px; }
  .gk-out:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); }
}
@media (min-width: 760px) and (hover: hover) {
  .gk:hover { box-shadow: inset 0 0 0 1px var(--edge); }
}

@media (prefers-reduced-motion: reduce) {
  .garage-canvas, .garage-poster, .garage-hint, .garage-sign, .gk { transition: none; }
}

