/* Styles de base. Les composants (tuiles, boutons, barre d'onglets) arrivent écran par écran. */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.4;
}

a { color: var(--primary); }
a:hover { color: var(--primary-hover); }
input::placeholder { color: var(--placeholder); }

p, h1, h2, h3 { margin: 0; }

.screen {
  max-width: 480px;
  margin: 0 auto;
  padding: 22px var(--gutter) 110px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.screen-title {
  font-weight: 800;
  font-size: 28px;
  letter-spacing: -0.5px;
  line-height: 1.1;
}

.text-secondary { color: var(--text-secondary); font-size: 13px; }

.label {
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--primary);
}

.big-number {
  font-weight: 800;
  font-size: 40px;
  line-height: 1.1;
}

.tile {
  background: var(--surface);
  border-radius: var(--radius-tile);
  padding: 16px;
}

/* ---------- Composants communs (DESIGN.md) ---------- */
.small { font-size: 12px; }
.icon { flex-shrink: 0; }
.screen { padding-bottom: calc(110px + env(safe-area-inset-bottom)); }

.label-success { color: var(--success); }

.tile-link { text-decoration: none; color: var(--text); display: flex; flex-direction: column; gap: 8px; }
.tile-link:hover { color: var(--text); }
.tile { padding: 14px; display: flex; flex-direction: column; gap: 6px; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tile-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.grid-2 .big-number { font-size: 34px; line-height: 1; }

.pill, .tag { display: inline-block; font-size: 11px; font-weight: 700; white-space: nowrap; }
.pill { border-radius: var(--radius-pill); padding: 4px 10px; color: #FFFFFF; font-size: 12px; }
.pill-primary { background: var(--primary); }
.pill-danger { background: var(--danger); }
.tag { border-radius: var(--radius-tag); padding: 3px 8px; background: var(--bg); color: var(--text-secondary); }
.tag-primary { background: var(--primary-tint); color: var(--primary-hover); }

/* Barre d'onglets flottante */
.tabbar {
  position: fixed;
  left: max(var(--gutter), calc(50% - 240px + var(--gutter)));
  right: max(var(--gutter), calc(50% - 240px + var(--gutter)));
  bottom: calc(18px + env(safe-area-inset-bottom));
  height: 66px;
  background: var(--surface);
  border-radius: 22px;
  box-shadow: var(--shadow-tabbar);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 10;
}
.tab {
  text-decoration: none;
  color: var(--text-secondary);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11px; font-weight: 600;
  min-width: 60px; min-height: 44px; justify-content: center;
}
.tab.is-active, .tab:hover { color: var(--primary); }
.tab-analyse {
  width: 52px; height: 52px; border-radius: 18px;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
}
.tab-analyse:hover { background: var(--primary-hover); }

/* Accueil */
.home-header { display: flex; justify-content: space-between; align-items: center; }
.avatar {
  width: 44px; height: 44px; border-radius: 22px;
  background: var(--primary); color: #FFFFFF; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

.search { display: flex; flex-direction: column; gap: 8px; }
.search-field {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border-radius: 14px; padding: 0 14px; height: 48px;
  box-shadow: var(--shadow-soft);
}
.search-field input {
  flex-grow: 1; min-width: 0; border: 0; outline: none; background: transparent;
  font-family: var(--font); font-size: 16px; color: var(--text); /* 16 px : pas de zoom sur iPhone */
}
.search-field:focus-within { box-shadow: 0 0 0 2px var(--primary); }

.results { list-style: none; margin: 0; gap: 4px; }
.results.tile { padding: 6px 14px; }

.card-row {
  text-decoration: none; color: var(--text);
  display: flex; align-items: center; gap: 12px; min-height: 61px; padding: 4px 0;
}
.card-row:hover { color: var(--text); }
.card-row-text { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; }
.card-row-text strong { font-size: 15px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thumb {
  width: 38px; height: 53px; border-radius: 5px; flex-shrink: 0; object-fit: contain; /* boîtier gradé entier */
  background: var(--card-placeholder); border: 1px solid var(--border);
}
.thumb-large { width: 120px; height: 168px; border-radius: 8px; display: block; }

.cta {
  text-decoration: none; color: #FFFFFF; background: var(--primary);
  border-radius: 20px; padding: 18px; display: flex; align-items: center; gap: 14px;
}
.cta:hover { color: #FFFFFF; background: var(--primary-hover); }
.cta-icon {
  width: 48px; height: 48px; border-radius: 14px; background: rgba(255, 255, 255, 0.18);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.cta-text { flex-grow: 1; display: flex; flex-direction: column; font-size: 13px; }
.cta-text strong { font-size: 18px; font-weight: 700; }
.cta-text span { opacity: 0.9; }

.myc-ring {
  width: 52px; height: 52px; border-radius: 26px; flex-shrink: 0;
  background: conic-gradient(var(--myc) 0 var(--share, 0%), var(--card-placeholder) var(--share, 0%) 100%);
  display: flex; align-items: center; justify-content: center;
}
.myc-ring span {
  width: 38px; height: 38px; border-radius: 19px; background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: var(--myc);
}

.list-tile { gap: 10px; }

/* Écrans à venir */
.back-link {
  display: inline-flex; align-items: center; gap: 4px; min-height: 44px;
  text-decoration: none; font-weight: 600; font-size: 14px;
}
.card-preview { flex-direction: row; align-items: center; gap: 16px; }
.card-preview img { border-radius: 8px; object-fit: contain; background: var(--card-placeholder); }
.card-name { font-weight: 800; font-size: 22px; line-height: 1.2; }

/* ---------- Fiche carte ---------- */
.screen-detail { padding-top: 0; padding-left: 0; padding-right: 0; gap: 0; background: var(--primary-tint); min-height: 100vh; }
.card-hero {
  height: 270px; position: relative;
  display: flex; align-items: center; justify-content: center;
}
.round-back {
  position: absolute; top: calc(16px + env(safe-area-inset-top)); left: 16px;
  width: 44px; height: 44px; border-radius: 22px; background: rgba(255, 255, 255, 0.8);
  display: flex; align-items: center; justify-content: center; color: var(--text);
}
.round-back:hover { color: var(--text); background: var(--surface); }
.card-hero-photo {
  width: 150px; height: 210px; margin-top: 12px; border-radius: 10px; object-fit: contain;
  background: var(--card-placeholder);
  box-shadow: 0 18px 34px rgba(14, 17, 22, 0.22);
}
.card-hero-empty {
  border: 1px solid var(--border); display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--text-secondary);
}
.sheet {
  flex-grow: 1; background: var(--bg); border-radius: 26px 26px 0 0;
  padding: 18px var(--gutter) calc(110px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 14px;
}
.card-title { font-weight: 800; font-size: 32px; letter-spacing: -0.5px; line-height: 1.15; }

.pill-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip {
  font-size: 13px; font-weight: 600; border-radius: var(--radius-pill); padding: 6px 14px;
  min-height: 32px; display: inline-flex; align-items: center; text-decoration: none;
  background: var(--surface); color: var(--text);
}
.chip.is-active { background: var(--primary); color: #FFFFFF; }
.chip-myc { background: var(--myc); color: #FFFFFF; }

/* Variante reverse : fond irisé derrière la photo, badge sur la photo, pastille irisée */
.fiche { display: flex; flex-direction: column; flex-grow: 1; }
.fiche.is-reverse { background: var(--reverse-tint); }
.reverse-badge {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
  background: var(--reverse); color: var(--reverse-text); border: 2px solid var(--surface);
  border-radius: var(--radius-pill); padding: 3px 12px;
  font-size: 11px; font-weight: 800; letter-spacing: 0.8px; text-transform: uppercase;
  box-shadow: 0 4px 12px rgba(14, 17, 22, 0.18); pointer-events: none;
}
.chip.is-active.chip-reverse { background: var(--reverse); color: var(--reverse-text); font-weight: 700; }
.tag-reverse { background: var(--reverse); color: var(--reverse-text); }
.photo-reverse {
  position: absolute; left: 5px; bottom: 5px; z-index: 1;
  background: var(--reverse); color: var(--reverse-text); border: 1.5px solid var(--surface);
  border-radius: var(--radius-pill); padding: 1px 7px;
  font-size: 9px; font-weight: 800; letter-spacing: 0.5px; text-transform: uppercase;
}

.prices { display: flex; flex-direction: column; gap: 8px; }
.prices-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.label-muted { color: var(--text-secondary); font-size: 12px; flex-shrink: 0; }
.segmented {
  display: flex; gap: 4px; background: var(--surface); border-radius: 10px; padding: 3px;
  overflow-x: auto; scrollbar-width: none; min-width: 0;
}
.segmented::-webkit-scrollbar { display: none; }
.segmented a {
  font-size: 12px; font-weight: 600; color: var(--text-secondary); text-decoration: none;
  border-radius: 8px; padding: 3px 10px; white-space: nowrap;
  min-height: 28px; display: inline-flex; align-items: center;
}
.segmented a.is-active { background: var(--text); color: #FFFFFF; }

.price-tiles { gap: 10px; }
.price-tile { background: var(--surface); border-radius: 16px; padding: 12px 14px; }
.price-tile-head { display: flex; justify-content: space-between; align-items: center; gap: 4px; }
.price-tile-grade { font-weight: 800; font-size: 14px; }
.price-tile-value { font-weight: 700; font-size: 20px; margin-top: 4px; }
.price-tile .tag { font-size: 10px; font-weight: 600; padding: 2px 6px; }
.tag-success { background: var(--success-bg); color: var(--success-text); }

.last-sale { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.last-sale b { color: var(--text); }
.last-sale-source { display: block; color: var(--primary); font-weight: 600; }

.add-button {
  margin-top: auto; display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; border: 1.5px dashed var(--primary); border-radius: 14px;
  font-size: 14px; font-weight: 600; text-decoration: none;
}

/* ---------- Analyser ---------- */
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.topbar { display: flex; align-items: center; justify-content: space-between; }
.round-button {
  width: 44px; height: 44px; border-radius: 22px; background: var(--surface); color: var(--text);
  display: flex; align-items: center; justify-content: center;
}
.round-button:hover { color: var(--text); }

.analyse-form { display: flex; flex-direction: column; gap: 16px; }
.photo-slots { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 0; }
.photo-slot {
  background: var(--surface); border-radius: 16px; padding: 8px; margin: 0;
  display: flex; flex-direction: column; gap: 8px; cursor: pointer; position: relative;
}
.photo-slot.is-optional:not(.is-filled) { background: transparent; border: 1.5px dashed #AEB7C3; color: var(--text-secondary); }
.photo-slot:focus-within { box-shadow: 0 0 0 2px var(--primary); }
.photo-frame {
  height: 120px; border-radius: 8px; background: var(--card-placeholder); position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center; color: var(--text-secondary);
}
.photo-slot.is-optional:not(.is-filled) .photo-frame { background: transparent; }
.photo-slot[data-slot="verso"]:not(.is-filled) .photo-frame { background: var(--text); color: #FFFFFF; }
.photo-preview { width: 100%; height: 100%; object-fit: cover; }
.photo-check {
  position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; border-radius: 11px;
  background: var(--success); display: flex; align-items: center; justify-content: center;
}
.photo-check[hidden], .photo-preview[hidden], .photo-placeholder[hidden] { display: none; }
.photo-label { font-size: 12px; font-weight: 700; text-align: center; }

.hint {
  font-size: 12px; color: var(--text-secondary); background: var(--surface);
  border-radius: 14px; padding: 10px 12px; display: flex; gap: 8px; align-items: flex-start;
}
.alert { border-radius: 14px; padding: 10px 12px; font-size: 13px; font-weight: 600; }
.alert-danger { background: var(--danger-bg); color: var(--danger-text); }

.chosen-card { flex-direction: row; align-items: center; gap: 12px; }
.chosen-card-text { flex-grow: 1; min-width: 0; }
.chosen-card-name { font-weight: 700; font-size: 15px; }
.small-button {
  border: 0; background: var(--bg); border-radius: 10px; font-size: 12px; font-weight: 600;
  padding: 0 12px; min-height: 36px; display: inline-flex; align-items: center;
  text-decoration: none; color: var(--text); flex-shrink: 0;
}
.small-button:hover { color: var(--text); background: var(--card-placeholder); }
.small-link { font-size: 13px; font-weight: 600; text-decoration: none; min-height: 32px; display: inline-flex; align-items: center; }
.card-picker { gap: 8px; }
.search-field-flat { box-shadow: none; background: var(--bg); }

.variant-choice { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.variant-choice legend { margin-bottom: 6px; padding: 0; }
.chip-radio input { position: absolute; opacity: 0; }
.chip-radio span {
  font-size: 13px; font-weight: 600; border-radius: var(--radius-pill); padding: 6px 14px;
  background: var(--surface); display: inline-flex; min-height: 32px; align-items: center; cursor: pointer;
}
.chip-radio input:checked + span { background: var(--primary); color: #FFFFFF; }
.chip-radio input:focus-visible + span { box-shadow: 0 0 0 2px var(--primary-hover); }

.price-field { display: flex; flex-direction: column; gap: 6px; }
.price-input {
  display: flex; align-items: center; background: var(--surface); border-radius: 14px;
  padding: 0 16px; height: 54px; font-weight: 700; font-size: 20px; color: var(--text-secondary);
}
.price-input input {
  flex-grow: 1; min-width: 0; border: 0; outline: none; background: transparent;
  font-family: var(--font); font-weight: 700; font-size: 20px; color: var(--text);
}
.price-input:focus-within { box-shadow: 0 0 0 2px var(--primary); }

.primary-button {
  display: flex; align-items: center; justify-content: center; height: 54px; border: 0; width: 100%;
  border-radius: var(--radius-button); background: var(--primary); color: #FFFFFF;
  font-family: var(--font); font-weight: 700; font-size: 16px; cursor: pointer;
}
.primary-button:hover { background: var(--primary-hover); }
.primary-button:disabled { opacity: 0.6; cursor: progress; }

/* Analyse : carte redressée */
.detection-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.detection-side { margin: 0; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.detection-side img { width: 100%; height: auto; aspect-ratio: 63 / 88; border-radius: 8px; background: var(--card-placeholder); }
.detection-missing {
  width: 100%; aspect-ratio: 63 / 88; border-radius: 8px; background: var(--danger-bg); color: var(--danger);
  display: flex; align-items: center; justify-content: center;
}
.alert-warning { background: var(--warning-bg); color: #7A4B00; }
.alert.small { font-size: 12px; font-weight: 500; padding: 8px 10px; }
.centering-cap { display: flex; align-items: baseline; gap: 10px; }
.centering-cap .big-number { font-size: 40px; line-height: 1; }
.centering-values { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; margin: 0; width: 100%; font-size: 12px; }
.centering-values dt { color: var(--text-secondary); }
.centering-values dd { margin: 0; font-weight: 700; text-align: right; }

/* Analyse : état de la carte (vision Claude) */
.vision { gap: 10px; }
.vision-summary { font-size: 14px; }
.criteria { width: 100%; border-collapse: collapse; font-size: 13px; }
.criteria th, .criteria td { padding: 6px 4px; text-align: left; }
.criteria thead th { font-size: 11px; color: var(--text-secondary); font-weight: 700; text-transform: uppercase; }
.criteria tbody tr + tr { border-top: 1px solid var(--bg); }
.tag-warning { background: var(--warning-bg); color: #7A4B00; }
.tag-danger { background: var(--danger-bg); color: var(--danger-text); }
.tag-muted { background: var(--bg); color: var(--text-secondary); }
.defects { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.defects li { display: flex; gap: 8px; align-items: flex-start; }
.defects .tag { flex-shrink: 0; margin-top: 2px; }
.usage { font-size: 11px; }
.spinner {
  display: inline-block; width: 12px; height: 12px; margin-right: 6px; vertical-align: -1px;
  border: 2px solid var(--primary-tint); border-top-color: var(--primary); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

/* Analyse : note probable et valeur si gradée */
.probable { display: flex; align-items: baseline; gap: 10px; }
.probable .big-number { font-size: 48px; line-height: 1; white-space: nowrap; flex-shrink: 0; }
.big-number.is-low { color: var(--danger); }
.grade-bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.grade-bars li { display: grid; grid-template-columns: 24px 1fr 40px; align-items: center; gap: 8px; font-size: 12px; }
.grade-bar-label { font-weight: 700; text-align: right; }
.grade-bar-track { height: 8px; border-radius: 4px; background: var(--bg); overflow: hidden; }
.grade-bar { display: block; height: 100%; border-radius: 4px; background: var(--border); }
.grade-bar.is-probable { background: var(--primary); }
.grade-bar.is-probable.is-low { background: var(--danger); }
.grade-bar-value { text-align: right; color: var(--text-secondary); }
.graded-value { display: flex; flex-direction: column; gap: 6px; padding-top: 6px; border-top: 1px solid var(--bg); }
.value-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.value-table th { text-align: left; font-weight: 600; }
.value-table td { text-align: right; padding: 3px 0; }
.value-table td:nth-child(2) { color: var(--text-secondary); }
.value-table tfoot th { font-weight: 500; color: var(--text-secondary); }
.value-table tfoot tr:first-child th, .value-table tfoot tr:first-child td { border-top: 1px solid var(--bg); padding-top: 6px; }
.value-net th, .value-net td { font-weight: 800; color: var(--text); }
.decision { border-radius: 14px; padding: 10px 12px; font-size: 14px; display: flex; flex-direction: column; gap: 2px; }
.decision-danger { background: var(--danger-bg); color: var(--danger-text); }
.decision-success { background: var(--success-bg); color: var(--success-text); }

/* ---------- Écran Résultat ---------- */
.screen-result { gap: 14px; padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
.result { display: flex; flex-direction: column; gap: 14px; }
.result-header { display: flex; align-items: center; gap: 12px; }
.result-header .round-button { width: 40px; height: 40px; border-radius: 20px; flex-shrink: 0; }
.result-header-text { min-width: 0; }
.result-header .screen-title { font-size: 24px; }
.title-link { color: var(--text); text-decoration: none; }
.title-link:hover { color: var(--primary); }
.label-danger { color: var(--danger); }

.result-grade { flex-direction: row; align-items: center; gap: 16px; }
.result-grade-main { display: flex; flex-direction: column; flex-shrink: 0; }
.result-grade-main .big-number { font-size: 56px; line-height: 1; letter-spacing: -2px; white-space: nowrap; }
.result-grade .grade-bars { flex-grow: 1; min-width: 0; }
.grade-bars li.is-probable { font-weight: 700; }
.grade-bars li.is-probable .grade-bar-value { color: var(--text); }

.result-block { display: flex; flex-direction: column; gap: 8px; }
.defect-list { list-style: none; margin: 0; padding: 4px 14px; gap: 0; }
.defect-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; }
.defect-list li + li { border-top: 1px solid var(--bg); }
.defect-text { display: flex; flex-direction: column; min-width: 0; font-size: 14px; }
.defect-text b { font-weight: 500; }

.identify .results { padding: 0; }
.identify-row { display: flex; align-items: center; gap: 8px; }
.identify-row .card-row { flex-grow: 1; min-width: 0; }
.identify-row form { margin: 0; }

.decision { border-radius: 16px; padding: 12px 14px; }
.decision-title { font-weight: 800; font-size: 16px; }
.decision p { color: var(--text); opacity: 0.85; }
.decision-primary { background: var(--primary-tint); color: var(--primary-hover); }
.decision-warning { background: var(--warning-bg); color: #7A4B00; }
.decision-muted { background: var(--surface); color: var(--text); }

.details { gap: 10px; }
.details summary { font-weight: 600; font-size: 14px; cursor: pointer; min-height: 32px; display: flex; align-items: center; }
.details[open] summary { margin-bottom: 4px; }

.alert-success { background: var(--success-bg); color: var(--success-text); }
.alert-muted { background: var(--surface); color: var(--text-secondary); }

.action-bar {
  position: fixed;
  left: max(var(--gutter), calc(50% - 240px + var(--gutter)));
  right: max(var(--gutter), calc(50% - 240px + var(--gutter)));
  bottom: calc(18px + env(safe-area-inset-bottom));
  display: flex; gap: 10px; z-index: 10;
}
.action-bar-secondary { flex: 1 1 0; margin: 0; display: flex; }
.action-bar-primary { flex: 2 1 0; text-decoration: none; box-shadow: var(--shadow-tabbar); }
.action-bar-primary:hover, .action-bar .primary-button:hover { color: #FFFFFF; }
.action-bar > .primary-button { text-decoration: none; box-shadow: var(--shadow-tabbar); }
.secondary-button {
  width: 100%; height: 54px; border: 0; border-radius: var(--radius-button);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-tabbar);
  font-family: var(--font); font-weight: 600; font-size: 15px; cursor: pointer;
}
.secondary-button:hover { background: var(--card-placeholder); }

/* ---------- Écran Collection ---------- */
.small-button-light { background: var(--surface); }
.collection-summary { flex-direction: row; align-items: center; gap: 14px; }
.collection-summary-text { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.collection-count { display: flex; align-items: baseline; gap: 8px; }
.collection-count .big-number { font-size: 36px; line-height: 1; }
.summary-list { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; margin: 0; font-size: 13px; }
.summary-list dt { color: var(--text-secondary); }
.summary-list dd { margin: 0; font-weight: 700; text-align: right; }
.myc-ring-large { width: 74px; height: 74px; border-radius: 37px; }
.myc-ring-large span { width: 56px; height: 56px; border-radius: 28px; font-size: 12px; }
.filter-chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--gutter)); padding: 0 var(--gutter); }
.filter-chips::-webkit-scrollbar { display: none; }
.filter-chips a {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px;
  border-radius: var(--radius-pill); background: var(--surface); color: var(--text);
  font-size: 13px; font-weight: 500; text-decoration: none; white-space: nowrap;
}
.filter-chips a.is-active { background: var(--text); color: #FFFFFF; font-weight: 600; }
.filter-count { font-size: 11px; opacity: 0.7; }
.collection-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 10px; }
.collection-card { text-decoration: none; color: var(--text); display: flex; flex-direction: column; gap: 2px; }
.collection-card:hover { color: var(--text); }
.collection-photo {
  position: relative; display: block; aspect-ratio: 63 / 88; border-radius: 8px; overflow: hidden;
  background: var(--card-placeholder); border: 1px solid var(--border); margin-bottom: 4px;
}
.collection-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.collection-photo-empty {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 6px; font-size: 11px; color: var(--text-secondary);
}
.grade-badge {
  position: absolute; top: 6px; right: 6px; min-width: 26px; height: 26px; border-radius: 13px;
  background: var(--surface); color: var(--text); font-weight: 700; font-size: 11px;
  display: flex; align-items: center; justify-content: center; padding: 0 6px;
  box-shadow: 0 2px 6px rgba(14, 17, 22, 0.15); white-space: nowrap;
}
.grade-badge-myc { color: var(--myc); font-size: 12px; }
.collection-name { font-size: 12px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.collection-number { font-size: 11px; color: var(--text-secondary); }
.empty-cta { margin-top: 10px; text-decoration: none; }
.empty-cta:hover { color: #FFFFFF; }

/* ---------- Carte de ma collection ---------- */
.item-back { width: 40px; height: 40px; border-radius: 20px; }
.item-photos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.item-photo {
  margin: 0; position: relative; aspect-ratio: 63 / 88; border-radius: 10px; overflow: hidden;
  background: var(--card-placeholder); border: 1px solid var(--border);
}
.item-photo.is-back { background: #D3DBF0; border-color: #C2CBE3; }
.item-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.item-photo figcaption {
  position: absolute; left: 0; right: 0; bottom: 8px; text-align: center; font-size: 11px;
  color: var(--text-secondary);
}
.item-photo img + figcaption { color: #FFFFFF; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6); }
.item-section { display: flex; flex-direction: column; gap: 8px; }
.grade-path { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.grade-step { background: var(--surface); border-radius: 16px; padding: 10px 12px; min-width: 0; }
.grade-step.is-empty { background: transparent; border: 1.5px dashed #AEB7C3; }
.grade-step-label { font-size: 11px; font-weight: 700; color: var(--primary); }
.grade-step-myc .grade-step-label { color: var(--myc); }
.grade-step-official .grade-step-label, .grade-step.is-empty .grade-step-label { color: var(--text-secondary); }
.grade-step-value { font-weight: 800; font-size: 30px; line-height: 1.1; white-space: nowrap; }
.grade-step.is-empty .grade-step-value { color: #AEB7C3; }
.grade-step-grader { font-size: 14px; font-weight: 700; }
.grade-form summary { list-style: none; cursor: pointer; }
.grade-form summary::-webkit-details-marker { display: none; }
.grade-form[open] summary { margin-bottom: 12px; }
.grade-form-myc summary {
  height: 50px; border: 1.5px dashed var(--myc); border-radius: 14px; color: var(--myc);
  font-weight: 600; font-size: 14px; display: flex; align-items: center; justify-content: center;
}
.primary-button-myc { background: var(--myc); }
.primary-button-myc:hover { background: #B8306E; }
.price-input select {
  border: 0; background: transparent; font-family: var(--font); font-size: 16px; font-weight: 600;
  width: 100%; color: var(--text); min-height: 44px;
}
.check-field { display: flex; align-items: center; gap: 10px; font-size: 14px; min-height: 44px; }
.check-field input { width: 20px; height: 20px; accent-color: var(--myc); }
.grade-history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.grade-history li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; }
.grade-history li + li { border-top: 1px solid var(--bg); }
.grade-history li > span { display: flex; flex-direction: column; }
.grade-history form { margin: 0; }
.danger-link {
  border: 0; background: none; padding: 0; min-height: 44px; color: var(--danger-text);
  font-family: var(--font); font-size: 13px; font-weight: 600; cursor: pointer;
}

/* ---------- Conversion MYC → note pro ---------- */
.grader-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.grader-tile { padding: 10px 12px; }
.grader-name { font-size: 11px; font-weight: 700; }
.grader-psa { color: var(--primary); }
.grader-ccc { color: #0E9F6E; }
.grader-pca { color: var(--myc); }
.grader-offset { font-weight: 800; font-size: 20px; }
.conversion-table {
  width: 100%; border-collapse: collapse; background: var(--surface);
  border-radius: var(--radius-tile); overflow: hidden; table-layout: fixed;
}
.conversion-table th, .conversion-table td { padding: 9px 14px; border-bottom: 1px solid var(--bg); text-align: center; }
.conversion-table thead th { font-size: 11px; font-weight: 700; color: var(--text-secondary); letter-spacing: 0.5px; }
.conversion-table th:first-child { width: 70px; text-align: left; }
.conversion-table tbody th { font-weight: 800; font-size: 18px; color: var(--myc); }
.conversion-table td b { display: block; font-weight: 700; font-size: 16px; }
.conversion-table td span { font-size: 10px; color: var(--text-secondary); }
.conversion-table tbody tr:last-child > * { border-bottom: 0; }
.conversion-legend { margin-top: -6px; }
.tile-title { font-weight: 700; font-size: 14px; }
.tile-tint { background: var(--primary-tint); }

/* ---------- Photo GCC recadrée « hors boîtier » (cote_ex.crops) ---------- */
/* Cadre au format carte, coins arrondis mesurés ; l'image d'origine y est replacée en CSS. */
.card-crop {
  position: relative; display: block; overflow: hidden; aspect-ratio: 63 / 88;
  border-radius: var(--crop-rx) / var(--crop-ry);
  background: var(--card-placeholder);
}
.card-crop > img {
  position: absolute !important; left: 0 !important; top: 0 !important;
  width: var(--crop-w) !important; height: auto !important; max-width: none !important;
  object-fit: fill !important; border: 0 !important; border-radius: 0 !important; box-shadow: none !important;
  transform-origin: 0 0; transform: var(--crop-t);
}
.thumb.card-crop { border: 0; background: none; }
.card-hero-photo.card-crop { background: none; }
.collection-photo .card-crop, .item-photo .card-crop { width: 100%; height: 100%; aspect-ratio: auto; }
.collection-photo:has(> .card-crop) { background: none; border: 0; border-radius: 0; overflow: visible; }
.card-preview .card-crop { width: 120px; height: 168px; flex-shrink: 0; }

/* ---------- Explorer le bloc EX ---------- */
.explore-link {
  flex-direction: row; align-items: center; justify-content: space-between; gap: 10px;
  text-decoration: none; color: var(--text);
}
.explore-link > span { display: flex; flex-direction: column; gap: 2px; }
.explore-link:hover { color: var(--text); }
.set-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.set-row { flex-direction: row; align-items: center; gap: 12px; text-decoration: none; color: var(--text); padding: 12px 14px; }
.set-row:hover { color: var(--text); }
.set-year {
  flex-shrink: 0; width: 46px; height: 46px; border-radius: 12px; background: var(--primary-tint);
  color: var(--primary); font-weight: 800; font-size: 13px; display: flex; align-items: center; justify-content: center;
}
.set-row-text { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.set-row-text strong { font-size: 15px; }
.text-myc { color: var(--myc); font-weight: 600; }
.set-link { color: inherit; text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 3px; }
.collection-grid li:target .collection-photo { outline: 3px solid var(--primary); outline-offset: 2px; }

/* ---------- Vue plein écran d'une carte (static/js/viewer.js) ---------- */
.viewer-open {
  border: 0; padding: 0; margin: 0; background: none; cursor: zoom-in; display: block;
  font: inherit; color: inherit; border-radius: 10px;
}
.item-photo .viewer-open { width: 100%; height: 100%; }
.viewer-open:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }
.viewer-is-open, .viewer-is-open body { overflow: hidden; }
dialog.viewer {
  border: 0; padding: 0; margin: 0; width: 100vw; height: 100dvh; max-width: none; max-height: none;
  background: rgba(10, 12, 18, 0.94); color: #FFFFFF; overflow: hidden;
}
dialog.viewer::backdrop { background: rgba(10, 12, 18, 0.94); }
dialog.viewer[open] { display: flex; animation: viewer-in 180ms ease-out; }
@keyframes viewer-in { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: none; } }
.viewer-close {
  position: absolute; z-index: 2; top: calc(14px + env(safe-area-inset-top)); right: 14px;
  width: 44px; height: 44px; border-radius: 22px; border: 0; background: rgba(255, 255, 255, 0.14);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.viewer-stage {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: calc(64px + env(safe-area-inset-top)) 20px calc(28px + env(safe-area-inset-bottom));
  perspective: 900px; cursor: zoom-out;
}
.viewer-card {
  position: relative; width: min(88vw, calc((100dvh - 120px) * 63 / 88), 520px);
  transform-style: preserve-3d; transition: transform 120ms linear; cursor: default;
  filter: drop-shadow(0 24px 40px rgba(0, 0, 0, 0.55));
}
.viewer-card .card-crop.viewer-img { width: 100%; }
.viewer-card img.viewer-img { display: block; width: 100%; height: auto; max-height: calc(100dvh - 120px); object-fit: contain; border-radius: 12px; }
.viewer-card.is-photo { width: min(92vw, 640px); }
/* Effet 3D (static/js/tilt.js) : reflet qui glisse selon l'inclinaison, découpé aux coins de la carte */
.viewer-card.is-tilting { transition: none; will-change: transform; }
.viewer-glare {
  display: none; position: absolute; inset: 0; pointer-events: none; border-radius: 12px;
  background: radial-gradient(circle at var(--glare-x, 50%) var(--glare-y, 50%),
              rgba(255, 255, 255, 0.85) 0%, rgba(255, 255, 255, 0.25) 22%, rgba(255, 255, 255, 0) 55%);
  mix-blend-mode: soft-light; opacity: var(--glare-o, 0.15);
}
.viewer-card.is-tilting .viewer-glare { display: block; }
@media (prefers-reduced-motion: reduce) {
  dialog.viewer[open] { animation: none; }
  .viewer-glare { display: none !important; }
}

/* ---------- Suivi des ventes GCC ---------- */
.watch-run { display: flex; gap: 10px; align-items: flex-start; }
.watch-run-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.watch-dot { width: 10px; height: 10px; border-radius: 5px; margin-top: 6px; flex-shrink: 0; background: var(--success); }
.watch-dot.watch-incomplet { background: var(--warning); }
.watch-dot.watch-refus { background: var(--danger); }
.text-danger { color: var(--danger-text); }

/* ---------- Alertes de mise en vente ---------- */
.alert-list { display: flex; flex-direction: column; gap: 10px; }
.alert-card { gap: 8px; }
.alert-head { display: flex; gap: 12px; align-items: center; }
.alert-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.alert-title { font-weight: 700; font-size: 15px; color: var(--text); text-decoration: none; }
.alert-prices { display: flex; justify-content: space-between; gap: 8px; font-weight: 700; font-size: 14px; }
.alert-prices .label { display: block; font-size: 11px; }
.alert-advice { background: var(--primary-tint); border-radius: 12px; padding: 10px 12px; font-size: 14px; font-weight: 600; }
.alert-advice.is-unknown { background: var(--bg); color: var(--text-secondary); }

/* ---------- Retours visuels (static/js/ux.js) ---------- */
html { -webkit-tap-highlight-color: transparent; }

/* Barre de progression en haut de l'écran : changement de page, envoi, requête HTMX */
.progress-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000; height: 3px; pointer-events: none;
  background: var(--primary); transform-origin: 0 50%; transform: scaleX(0); opacity: 0;
  margin-top: env(safe-area-inset-top);
}
.progress-bar.is-running {
  opacity: 1; transform: scaleX(0.85);
  transition: transform 6s cubic-bezier(0.1, 0.7, 0.2, 1), opacity 0.15s;   /* avance vite, puis ralentit */
}
.progress-bar.is-done { opacity: 0; transform: scaleX(1); transition: transform 0.2s ease-out, opacity 0.3s 0.15s; }

/* Enfoncement au toucher : on voit tout de suite que l'appui est pris en compte */
.collection-card, .set-row, .tile-link, .round-button, .primary-button, .secondary-button, .small-button,
.chip, .tab, .tab-analyse, .add-button, .explore-link, .danger-link, .viewer-open {
  transition: transform 0.12s ease-out, background-color 0.15s, opacity 0.15s;
}
.collection-card:active, .set-row:active, .tile-link:active, .explore-link:active { transform: scale(0.97); }
.round-button:active, .small-button:active, .chip:active, .tab:active, .tab-analyse:active,
.primary-button:active, .secondary-button:active, .add-button:active { transform: scale(0.95); }

/* Bouton d'envoi en cours : indicateur qui tourne, plus de second appui */
.is-loading { pointer-events: none; opacity: 0.75; }
.is-loading::before {
  content: ""; display: inline-block; vertical-align: -3px; margin-right: 8px;
  width: 16px; height: 16px; box-sizing: border-box; border-radius: 50%; flex-shrink: 0;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.8s linear infinite;
}

/* Photos GCC : l'emplacement scintille, la photo apparaît en fondu une fois chargée */
.js .card-crop > img, .js .collection-photo > img, .js img.thumb, .js img.card-hero-photo {
  opacity: 0; transition: opacity 0.25s ease-out;
}
.js .card-crop > img.is-loaded, .js .collection-photo > img.is-loaded, .js img.thumb.is-loaded,
.js img.card-hero-photo.is-loaded { opacity: 1; }
@keyframes shimmer { from { background-position: 150% 0; } to { background-position: -50% 0; } }
.js .card-crop:has(> img:not(.is-loaded)), .js .collection-photo:has(> img:not(.is-loaded)) {
  background-color: var(--card-placeholder);
  background-image: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, 0.55) 50%, transparent 70%);
  background-size: 200% 100%; animation: shimmer 1.4s ease-in-out infinite;
}

/* Message discret en bas de l'écran (erreurs HTMX) */
.toast {
  position: fixed; z-index: 1000; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  width: max-content; max-width: calc(100% - 2 * var(--gutter));
  background: var(--text); color: #FFFFFF; border-radius: 14px; padding: 10px 14px;
  font-size: 13px; font-weight: 600; box-shadow: var(--shadow-tabbar);
  transition: opacity 0.2s, transform 0.2s;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* Transition en fondu entre deux pages (Safari 18.2+, ignorée ailleurs) ; la barre d'onglets ne bouge pas */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  ::view-transition-old(root), ::view-transition-new(root) { animation-duration: 0.18s; }
  .tabbar { view-transition-name: tabbar; }
}

@media (prefers-reduced-motion: reduce) {
  .progress-bar.is-running { transition: opacity 0.15s; transform: scaleX(0.85); }
  .collection-card:active, .set-row:active, .tile-link:active, .explore-link:active,
  .round-button:active, .small-button:active, .chip:active, .tab:active, .tab-analyse:active,
  .primary-button:active, .secondary-button:active, .add-button:active { transform: none; opacity: 0.7; }
  .is-loading::before { animation: none; }
  .js .card-crop:has(> img:not(.is-loaded)), .js .collection-photo:has(> img:not(.is-loaded)) { animation: none; }
  .js .card-crop > img, .js .collection-photo > img, .js img.thumb, .js img.card-hero-photo { transition: none; }
}
a.primary-button, a.primary-button:hover { text-decoration: none; color: #FFFFFF; }
