@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Oswald:wght@500;600;700&display=swap');

/* ==============================
   1. Variables & base
   ============================== */
:root {
  --ink: #242321;
  --muted: #77736d;
  --paper: lightgray;
  --orange: #f3a33b;
  --line: #e6dfd4;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'DM Sans', Arial, sans-serif;
  padding-bottom: 430px; /* élargi pour le grand catalogue sectionné */
}

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

/* ==============================
   2. En-tête du site
   ============================== */
.site-header {
  display: flex;
  gap: 18px;
  align-items: center;
  padding: 26px clamp(18px, 4vw, 60px);
  background: #242321;
  color: #fff;
  border-bottom: 5px solid var(--orange);
}

.brand-logo {
  width: 62px;
  height: 62px;
  display: block;
  object-fit: cover;
  border: 2px solid var(--orange);
  border-radius: 50%;
}

.eyebrow {
  font-size: 10px;
  letter-spacing: 2.4px;
  font-weight: 700;
  color: #b87524;
  margin: 0 0 5px;
}

.site-header .eyebrow {
  color: var(--orange);
}

h1 {
  font: 600 clamp(25px, 4vw, 39px) Oswald, sans-serif;
  letter-spacing: .2px;
  margin-bottom: 4px;
}

.subtitle {
  margin: 0;
  color: #d1ccc3;
  font-size: 13px;
}

/* ==============================
   3. Zone principale
   ============================== */
main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 22px clamp(14px, 3vw, 42px) 30px;
}

/* ==============================
   4. Barre d'outils (personnes)
   ============================== */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 14px;
  margin-bottom: 25px;
  box-shadow: 0 4px 16px #3c2d1508;
}

.person-control {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  font-weight: 700;
}

.person-control select,
.add-person-form input,
.catalog-tools input {
  border: 1px solid #ddd4c8;
  border-radius: 8px;
  background: #fff;
  padding: 10px 12px;
  font: inherit;
  color: var(--ink);
  min-width: 0;
}
.person-control select{
      background: brown;
      color: snow;
}
.add-person-form {
  display: flex;
  gap: 7px;
  flex: 1;
  min-width: 220px;
}

.add-person-form input {
  flex: 1;
}

.button {
  border: 0;
  border-radius: 8px;
  padding: 10px 13px;
  font: 700 12px 'DM Sans';
  cursor: pointer;
  white-space: nowrap;
}

.button-dark {
  background: var(--ink);
  color: white;
}

.button-light {
  background: brown;
  color: lightgray;
}

.button:hover {
  filter: brightness(.95);
}

#saveStatus {
  margin-left: auto;
  color: #7b766e;
  font-size: 11px;
}

/* ==============================
   5. Plateau de classement
   ============================== */
.board-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  margin-bottom: 15px;
}

.board-heading h2,
.drawer-top h2 {
  font: 600 27px Oswald, sans-serif;
  margin: 0;
}

.instruction {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
}

.tiers {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.tier {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 13px;
  overflow: hidden;
  min-height: 235px;
}

.tier-label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.medal {
  font-size: 24px;
}

.tier-label h3 {
  font: 600 18px Oswald;
  margin: 0 0 2px;
}

.tier-label p {
  font-size: 11px;
  color: var(--muted);
  margin: 0;
}

.tier-count {
  margin-left: auto;
  border-radius: 20px;
  background: #f3eee5;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 700;
}

.tier-top .tier-label    { border-top: 4px solid #d5a13c; }
.tier-middle .tier-label { border-top: 4px solid #9da5ac; }
.tier-bottom .tier-label { border-top: 4px solid #bd8065; }
.tier-untried .tier-label { border-top: 4px solid #729b87; }

/* ==============================
   6. Zones de dépôt
   ============================== */
.dropzone {
  min-height: 165px;
  padding: 12px;
  display: flex;
  align-content: flex-start;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 8px;
}

.dropzone.drag-over {
  background: #fff7e9;
  outline: 2px dashed #e6a344;
  outline-offset: -5px;
}

.empty-hint {
  font-size: 12px;
  color: #aaa49b;
  width: 100%;
  text-align: center;
  padding: 30px 5px;
}

.dropzone:not(:empty) .empty-hint {
  display: none;
}

/* ==============================
   7. Tiroir du bas : la réserve
   ============================== */
.chip-drawer {
  position: fixed;
  z-index: 10;
  bottom: 0;
  left: 0;
  right: 0;
  height: 410px; /* élargi pour le grand catalogue sectionné */
  background: white;
  border-top: 1px solid #dcd2c4;
  box-shadow: 0 -8px 28px #33271614;
  display: flex;
  flex-direction: column;
  padding: 14px clamp(14px, 3vw, 42px) 9px;
}

.drawer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 10px;
}

.drawer-top h2 {
  font-size: 22px;
}

.catalog-tools {
  display: flex;
  align-items: center;
  gap: 12px;
}

.catalog-tools input {
  width: min(280px, 36vw);
  padding: 8px 11px;
  font-size: 12px;
}

.catalog-tools span {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

/* ==============================
   8. Catalogue horizontal par sections
   ============================== */
.tray-scroller {
  display: flex;
  align-items: stretch;
  gap: 8px;
  flex: 1;
  min-height: 0;
  min-width: 0;
}

.chip-tray {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 24px;
  min-height: 0;
  min-width: 0;
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 2px 12px;
  scrollbar-width: auto;
  scrollbar-color: #a99b86 #eee8df;
}

.chip-tray::-webkit-scrollbar {
  height: 12px;
}

.chip-tray::-webkit-scrollbar-track {
  background: #eee8df;
  border-radius: 8px;
}

.chip-tray::-webkit-scrollbar-thumb {
  background: #a99b86;
  border: 2px solid #eee8df;
  border-radius: 8px;
}

/* Une section = une catégorie, avec son titre au-dessus de ses paquets */
.chip-section,
.chip-group {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  width: max-content;
  min-width: max-content;
  max-width: none;
  padding: 4px 2px 0;
  border-right: 1px solid var(--line);
  padding-right: 20px;
}

.chip-section-title,
.group-title {
  font: 600 15px Oswald, sans-serif;
  color: #8d5319;
  margin: 0 0 8px;
  white-space: nowrap;
}

.chip-section-cards,
.group-zone {
  display: flex;
  flex: 0 0 auto;
  align-items: flex-start;
  gap: 13px;
  width: max-content;
  min-width: max-content;
}

/* Flèches de navigation gauche/droite (optionnelles) */
.tray-nav {
  flex: 0 0 32px;
  align-self: center;
  width: 32px;
  height: 42px;
  border: 1px solid #dfd5c7;
  border-radius: 10px;
  background: #f5efe6;
  color: #6d4a29;
  font-size: 27px;
  line-height: 1;
  cursor: pointer;
}

.tray-nav:hover {
  background: #eee3d3;
}

/* ==============================
   9. Paquets de chips
   ============================== */
.chip-card {
  flex: 0 0 116px;
  min-width: 116px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  cursor: grab;
  user-select: none;
}

.chip-card:active {
  cursor: grabbing;
}

.chip-card.dragging {
  opacity: .35;
}

.bag {
  height: 155px;
  width: 94px;
  border-radius: 10px 10px 13px 13px;
  background: linear-gradient(135deg, hsl(var(--bag-hue), 75%, 38%), hsl(var(--bag-hue), 75%, 25%));
  color: white;
  box-shadow: inset 0 0 0 2px #ffffff30, 0 4px 7px #0002;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 8px 6px 6px;
  overflow: hidden;
  transform: rotate(-1deg);
  clip-path: polygon(5% 0, 95% 0, 100% 8%, 97% 94%, 89% 100%, 11% 100%, 3% 94%, 0 8%);
}

.bag:before,
.bag:after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 5px;
  background: #ffffff40;
}

.bag:before { top: 4px; }
.bag:after  { bottom: 4px; }

.bag-brand {
  font: 700 15px Oswald;
  letter-spacing: .5px;
  text-shadow: 1px 1px #0004;
  margin-top: 7px;
  border-bottom: 1px solid #ffffff9c;
  padding-bottom: 4px;
  width: 100%;
}

.bag-flavour {
  font: 600 11px Oswald;
  line-height: 1.15;
  margin: auto 0;
  text-shadow: 1px 1px #0005;
  z-index: 1;
}

.bag-wave {
  font-size: 22px;
  line-height: 12px;
  color: #ffffffa8;
}

.chip-name {
  font-size: 14px;
  line-height: 1.2;
  text-align: center;
  color: #514b43;
  max-width: 114px;
}

/* Support des vraies photos à la place des illustrations CSS */
.bag-photo {
  background: none;
  box-shadow: none;
  clip-path: none;
  border-radius: 0;
  padding: 0;
  overflow: visible;
  transform: none;
}

.bag-photo:before,
.bag-photo:after {
  display: none;
}

.bag-image {
  display: block;

  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 4px 4px #0002);
}

/* Paquets réduits dans les zones de classement */
.dropzone .chip-card {
  flex-basis: 76px;
  min-width: 76px;
  gap: 3px;
}

.dropzone .bag {
  width: 59px;
  height: 122px;
  border-radius: 7px;
  padding: 5px 4px;
}

.dropzone .bag-brand {
  font-size: 10px;
  margin-top: 5px;
  padding-bottom: 2px;
}

.dropzone .bag-flavour { font-size: 8px; }
.dropzone .bag-wave    { font-size: 15px; }

.dropzone .chip-name {
  font-size: 9px;
  max-width: 76px;
}

.all-rankings {
  margin-top: 28px;
}

.all-rankings-heading h2 {
  font: 600 27px Oswald, sans-serif;
  margin: 0 0 14px;
}

.saved-ranking {
  margin-bottom: 12px;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 13px;
}

.saved-ranking > h3 {
  margin: 0 0 12px;
  font: 600 20px Oswald, sans-serif;
}

.saved-ranking-tiers {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.saved-ranking-tier {
  padding: 12px;
  background: #faf8f4;
  border-radius: 9px;
}

.saved-ranking-tier h4 {
  margin: 0 0 8px;
  font-size: 12px;
}

.saved-ranking-tier ul {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 12px;
}

.saved-ranking-tier li + li {
  margin-top: 4px;
}

.saved-ranking-tier li {
  display: flex;
  align-items: center;
}

.saved-chip-image {
  width: 42px;
  height: 42px;
  object-fit: contain;
  vertical-align: middle;
  margin-right: 7px;
}

.saved-ranking-empty {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

/* ==============================
   10. Pied du tiroir
   ============================== */
.drawer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid #eee7dc;
  padding-top: 7px;
  font-size: 10px;
  color: #827b71;
}

/* ==============================
   11. Responsive
   ============================== */
@media (max-width: 800px) {
  body { padding-bottom: 375px; }

  .site-header { padding: 20px; }
  .brand-logo { width: 48px; height: 48px; }

  .tiers { grid-template-columns: 1fr; gap: 10px; }
  .saved-ranking-tiers { grid-template-columns: 1fr; gap: 8px; }
  .tier { min-height: 0; }
  .dropzone { min-height: 100px; }

  .board-heading { align-items: start; flex-direction: column; gap: 6px; }
  .tier-label { padding: 10px; }
  .toolbar { gap: 8px; }
  #saveStatus { width: 100%; margin: 0; }

  .chip-drawer { height: 360px; padding: 12px 14px 7px; }
  .drawer-top { align-items: start; flex-direction: column; gap: 8px; }
  .drawer-top h2 { font-size: 19px; }
  .catalog-tools { width: 100%; }
  .catalog-tools input { width: 100%; }

  .chip-tray { gap: 18px; }
  .chip-section,
  .chip-group { padding-right: 14px; }
  .chip-section-title,
  .group-title { font-size: 14px; }
  .chip-section-cards,
  .group-zone { gap: 10px; }

  .chip-card { flex-basis: 100px; min-width: 100px; }
  .bag { height: 110px; width: 86px; }
  .chip-name { max-width: 98px; }

  .drawer-footer span { max-width: 58%; }
}

@media (max-width: 430px) {
  .person-control { width: 100%; justify-content: space-between; }
  .person-control select { flex: 1; max-width: 65%; }
  .add-person-form { min-width: 100%; }
  .toolbar > .button { width: 100%; }
  .drawer-footer { font-size: 9px; }
  .drawer-footer .button { padding: 8px; font-size: 10px; }
}
