/* Collection Hot Wheels de rpmn0ise
   Idée : un panneau à crochets (pegboard) où chaque voiture est accrochée
   sur sa carte blister. Une seule chose mémorable : la carte et son numéro de série. */

:root {
  --board: #cdd6de;
  --hole: #a9b6c1;
  --paper: #ffffff;
  --paper-2: #f2f5f8;
  --ink: #0b2a5b;
  --ink-soft: #44546b;
  --line: #b4c0cb;
  --track: #f26a1b;
  --track-text: #b4410a;
  --focus: #0b2a5b;
  --display: "Big Shoulders Display", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  --text: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--text);
  font-size: 1rem;
  line-height: 1.5;
  background-color: var(--board);
  background-image: radial-gradient(circle at center, var(--hole) 0 2.2px, transparent 2.8px);
  background-size: 28px 28px;
  min-height: 100vh;
}

a { color: inherit; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  border-radius: 4px;
}

[hidden] { display: none !important; }

/* Bandeau en forme de piste orange */
.track {
  height: 12px;
  background-color: var(--track);
  background-image: repeating-linear-gradient(90deg, transparent 0 22px, rgba(255, 255, 255, .6) 22px 26px);
}

.top {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 20px 8px;
}

.back {
  display: inline-block;
  font-size: .9rem;
  font-weight: 500;
  color: var(--ink-soft);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.back:hover { color: var(--ink); }

h1 {
  margin: 14px 0 10px;
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(3rem, 11vw, 6.4rem);
  line-height: .88;
  letter-spacing: .005em;
}

.lead {
  max-width: 46ch;
  margin: 0;
  color: var(--ink-soft);
  font-size: 1.05rem;
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 20px 48px;
}

/* Panneau de recherche */
.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 2px 4px 0 rgba(11, 42, 91, .14);
}

.row { display: grid; gap: 12px; }
.row + .row { margin-top: 12px; }

.row-search { grid-template-columns: 1fr; }
.row-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }

@media (min-width: 640px) {
  .row-search { grid-template-columns: minmax(0, 1fr) 260px; }
  .row-filters { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { font-size: .85rem; font-weight: 600; color: var(--ink-soft); }

input[type="search"], select {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  font: inherit;
  color: var(--ink);
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}
select { padding-right: 8px; text-overflow: ellipsis; }
input[type="search"]::placeholder { color: #66758a; }

.row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  font-size: .95rem;
  cursor: pointer;
}
.check input { width: 20px; height: 20px; accent-color: var(--ink); }

.summary {
  margin: 0;
  flex: 1 1 auto;
  font-weight: 600;
}

.btn {
  min-height: 44px;
  padding: 8px 16px;
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 8px;
  cursor: pointer;
}
.btn:hover { background: #12397a; }
.btn.btn-quiet { color: var(--ink); background: transparent; border-color: var(--line); }
.btn.btn-quiet:hover { background: var(--paper-2); }

/* Statistiques */
.stats { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 8px; }
.stats > summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  font-weight: 600;
  cursor: pointer;
}
.stats-body { display: grid; gap: 20px; padding: 8px 0 4px; }
@media (min-width: 760px) { .stats-body { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.totals { display: flex; flex-wrap: wrap; gap: 8px 28px; margin: 0; grid-column: 1 / -1; }
.totals div { min-width: 90px; }
.totals dt { font-size: .85rem; color: var(--ink-soft); }
.totals dd { margin: 0; font-family: var(--display); font-weight: 800; font-size: 2.2rem; line-height: 1; }

.stats-body h3 { margin: 0 0 6px; font-size: 1rem; }
.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.bar-btn {
  display: grid;
  grid-template-columns: minmax(70px, 38%) 1fr 2ch;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 36px;
  padding: 2px 4px;
  font: inherit;
  font-size: .92rem;
  text-align: left;
  color: var(--ink);
  background: none;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}
.bar-btn:hover { background: var(--paper-2); }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 8px; background: var(--paper-2); border-radius: 4px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--track); border-radius: 4px; }
.bar-n { font-weight: 600; text-align: right; }
.bars-more { margin: 4px 4px 0; font-size: .85rem; color: var(--ink-soft); }

.notice {
  margin: 16px 0 0;
  padding: 10px 14px;
  background: #fff4e8;
  border: 1px solid #f1c59d;
  border-radius: 8px;
  font-size: .95rem;
}

/* Grille de cartes */
.grid {
  list-style: none;
  margin: 24px 0 0;
  padding: 0;
  display: grid;
  gap: 22px 18px;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
}
@media (min-width: 720px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(214px, 1fr)); gap: 28px 22px; }
}

.slot { min-width: 0; }

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 34px 10px 10px;
  color: var(--ink);
  text-decoration: none;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px 10px 8px 8px;
  box-shadow: 2px 4px 0 rgba(11, 42, 91, .16);
  transition: transform .15s ease, box-shadow .15s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: 2px 7px 0 rgba(11, 42, 91, .18); }

/* Trou d'accroche de la carte blister */
.card::before {
  content: "";
  position: absolute;
  top: 11px;
  left: 50%;
  width: 22px;
  height: 11px;
  margin-left: -11px;
  border-radius: 6px;
  background: var(--board);
  box-shadow: inset 0 2px 3px rgba(11, 42, 91, .35);
}

.photo {
  position: relative;
  display: block;
  aspect-ratio: 2 / 3;
  background: var(--paper-2);
  border-radius: 6px;
  overflow: hidden;
}
.photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.nophoto {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 100%;
  padding: 12px;
  color: var(--ink-soft);
  font-size: .85rem;
  text-align: center;
  border: 2px dashed var(--line);
  border-radius: 6px;
}
.nophoto svg { width: 64%; max-width: 110px; height: auto; }

.tags { position: absolute; top: 6px; left: 6px; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.tag {
  padding: 1px 8px;
  font-size: .75rem;
  font-weight: 600;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
}
.tag-dup { background: #fde3cf; border-color: #f1b98d; }

.info { display: flex; flex-direction: column; gap: 2px; padding: 10px 2px 0; flex: 1; }
.name {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.35rem;
  line-height: 1.02;
  overflow-wrap: anywhere;
}
.sub { margin: 0; font-size: .88rem; color: var(--ink-soft); }

.foot-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  padding-top: 10px;
}
.year { font-weight: 600; font-size: .92rem; }
.num {
  font-family: var(--display);
  font-weight: 900;
  font-size: 1.7rem;
  line-height: 1;
  color: var(--track-text);
}

.dot {
  display: inline-block;
  width: .8em;
  height: .8em;
  margin-right: .4em;
  vertical-align: -.05em;
  border: 1px solid rgba(11, 42, 91, .45);
  border-radius: 50%;
}

/* Un seul moment animé : les cartes se posent sur le panneau au chargement */
@keyframes hang {
  from { opacity: 0; transform: translateY(-14px) rotate(-1.5deg); }
  to { opacity: 1; transform: none; }
}
.card.enter { animation: hang .45s cubic-bezier(.2, .8, .3, 1) both; animation-delay: calc(var(--i, 0) * 28ms); }

.state {
  margin: 28px auto;
  max-width: 52ch;
  padding: 16px;
  text-align: center;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.state .btn { margin-top: 10px; }

.foot {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px 36px;
  color: var(--ink-soft);
  font-size: .9rem;
}
.foot p { max-width: 62ch; margin: 0; }

/* Fiche détaillée */
dialog {
  width: min(900px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  margin: auto;
  padding: 0;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: auto;
}
dialog::backdrop { background: rgba(11, 42, 91, .55); }

.d-wrap { display: grid; gap: 0; }
@media (min-width: 720px) { .d-wrap { grid-template-columns: 5fr 6fr; } }

.d-photo { padding: 18px; background: var(--paper-2); }
.d-photo .photo { aspect-ratio: 2 / 3; max-height: 70vh; margin: 0 auto; background: #fff; }
@media (min-width: 720px) { .d-photo { display: flex; align-items: center; } .d-photo .photo { width: 100%; } }

.d-body { padding: 22px 22px 20px; display: flex; flex-direction: column; gap: 10px; }
.d-id { margin: 0; font-size: .9rem; font-weight: 600; color: var(--ink-soft); }
.d-body h2 {
  margin: 0;
  padding-right: 44px;
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(2rem, 6vw, 3rem);
  line-height: .95;
  overflow-wrap: anywhere;
}
.d-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.d-tags .tag { font-size: .8rem; }

.facts { margin: 6px 0 0; display: grid; gap: 0; }
.facts div { display: grid; grid-template-columns: 11.5rem 1fr; gap: 12px; padding: 8px 0; border-top: 1px solid #dfe5ea; }
.facts dt { font-size: .9rem; color: var(--ink-soft); }
.facts dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.facts .empty { font-weight: 400; color: #66758a; }
@media (max-width: 480px) { .facts div { grid-template-columns: 1fr; gap: 0; } }

.d-nav { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 14px; }
.d-nav .btn { flex: 1 1 auto; }
.d-nav .btn[disabled] { opacity: .4; cursor: default; }

.d-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 44px;
  height: 44px;
  font: inherit;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
}
.d-close:hover { background: var(--paper-2); }

@media (prefers-reduced-motion: reduce) {
  .card, .card:hover { transition: none; }
  .card.enter { animation: none; }
}
