/* Tonton Houblon : comptoir de bistrot, étiquettes de bière, capsules colorées */
:root {
  --bg: #efe6d6;
  --bg-grain: #e6dac5;
  --fg: #2b2118;
  --muted: #6e5d4c;
  --rule: #d2c3aa;
  --panel: #fbf5e9;
  --accent: #b8455a;
  --ink: #2b2118;
  --paper: #fbf5e9;
  --display: "Alfa Slab One", "Rockwell", Georgia, serif;
  --body: "Karla", "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #1d1712; --bg-grain: #241c16; --fg: #f1e7d6; --muted: #b3a28c; --rule: #3a2f25; --panel: #2a211a; --accent: #d9677b; color-scheme: dark; }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
html { background: var(--bg); }
body {
  background: var(--bg);
  background-image: repeating-linear-gradient(90deg, var(--bg) 0 46px, var(--bg-grain) 46px 48px);
  color: var(--fg);
  font: 400 15px/1.5 var(--body);
  padding: env(safe-area-inset-top, 0px) 16px calc(env(safe-area-inset-bottom, 0px) + 40px);
  min-height: 100vh;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- barre du haut ---------- */
.topbar { max-width: 1100px; margin: 0 auto; padding-top: 20px; display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; align-items: end; }
.brand { display: grid; }
.brand-name { font: 400 clamp(26px, 5vw, 36px)/1 var(--display); }
.brand-sub { font: 600 11px/1.6 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.counters { display: flex; gap: 18px; margin: 0; }
.counters div { display: grid; text-align: right; }
.counters dt { font: 600 10px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.counters dd { margin: 4px 0 0; font: 600 20px/1 var(--mono); font-variant-numeric: tabular-nums; }
.progress { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--rule); overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .6s ease; }

.tabs { max-width: 1100px; margin: 16px auto 0; display: flex; gap: 8px; }
.tabs button { background: transparent; border: 1.5px solid var(--rule); border-radius: 999px; padding: 8px 16px; cursor: pointer; font-weight: 700; }
.tabs button[aria-current="page"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }

main { max-width: 1100px; margin: 20px auto 0; }
.view-title { font: 400 28px/1.1 var(--display); margin: 0 0 12px; }

/* ---------- scène du carton ---------- */
.stage {
  position: relative; min-height: 440px; border-radius: 18px; border: 3px solid var(--ink);
  background: radial-gradient(ellipse at 50% 110%, #c99a6a 0 40%, transparent 41%), linear-gradient(#e9d3a6 0 70%, #b5835a 70%);
  box-shadow: 0 18px 40px -20px rgba(43,33,24,.6);
  display: grid; place-items: center; padding: 70px 12px 24px; overflow: hidden;
}
.stage.graal { animation: graal 1.2s ease-in-out 3; }
@keyframes graal { 50% { box-shadow: 0 0 0 6px #e0ad38, 0 0 60px 10px rgba(224,173,56,.7); } }
.bubble {
  position: absolute; top: 14px; left: 14px; margin: 0; z-index: 3; max-width: min(36ch, calc(100% - 28px));
  background: #fffaf0; color: #2b2118; border: 2.5px solid #2b2118; border-radius: 14px; padding: 8px 14px;
  font: italic 400 16px/1.35 var(--body); box-shadow: 4px 4px 0 #2b2118;
}
.bubble.pop { animation: pop .3s ease; }
@keyframes pop { from { transform: scale(.85); } to { transform: scale(1); } }

.box { position: relative; width: 220px; height: 170px; border: 0; background: none; padding: 0; cursor: pointer; }
.box-body { position: absolute; inset: 30px 0 0; background: #c8935a; border: 3px solid #2b2118; border-radius: 6px; display: grid; place-items: center; }
.box-tape { position: absolute; top: 0; bottom: 0; left: 50%; width: 34px; transform: translateX(-50%); background: rgba(240,220,170,.75); }
.box-label { position: relative; background: #fffaf0; color: #2b2118; border: 2px solid #2b2118; padding: 6px 10px; font: 400 15px/1.15 var(--display); text-align: center; transform: rotate(-3deg); }
.box-label small { font: 600 10px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; }
.box-lid { position: absolute; left: -8px; right: -8px; top: 12px; height: 30px; background: #b8834c; border: 3px solid #2b2118; border-radius: 6px; transition: transform .45s cubic-bezier(.5,-0.4,.5,1.4), opacity .45s; transform-origin: 20% 100%; }
.box:hover .box-lid { transform: translateY(-4px) rotate(-2deg); }
.box.shake { animation: shake .65s ease-in-out; }
@keyframes shake { 0%,100% { transform: rotate(0); } 20% { transform: rotate(-4deg); } 40% { transform: rotate(4deg); } 60% { transform: rotate(-3deg); } 80% { transform: rotate(2deg); } }
.box.open .box-lid { transform: translate(-60px, -120px) rotate(-50deg); opacity: 0; }
.stage.revealing .box { display: none; }

.reveal { display: none; width: 100%; }
.stage.revealing .reveal { display: grid; justify-items: center; gap: 18px; }
.focus-wrap { display: grid; justify-items: center; gap: 8px; }
.focus-wrap.empty { gap: 0; }
.counter { margin: 0; font: 600 12px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: #6e5d4c; min-height: 12px; }
.hint { margin: 0; font-weight: 700; color: #2b2118; min-height: 1.5em; }
.skip { background: transparent; border: 0; color: #6e5d4c; text-decoration: underline; cursor: pointer; font-size: 13px; padding: 4px; }
.pile { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; min-height: 0; }
.mini { --cw: 112px; width: var(--cw); aspect-ratio: 5 / 7; position: relative; padding: 0; border: 0; background: none; cursor: pointer; animation: toPile .35s ease backwards; }
.mini .card { --cw: 112px; }
.mini .tag { font-size: 9px; padding: 4px 6px; bottom: -9px; }
.mini:hover { transform: translateY(-3px); }
@keyframes toPile { from { transform: translateY(-60px) scale(1.4); opacity: 0; } }
.slot { --cw: 250px; width: var(--cw); aspect-ratio: 5 / 7; padding: 0; border: 0; background: none; cursor: pointer; perspective: 1000px; animation: deal .4s cubic-bezier(.3,1.4,.5,1) backwards; position: relative; }
.slot .card { --cw: 250px; }
.slot:not(.flipped):hover .flip { transform: rotate(-2deg) scale(1.02); }
@keyframes deal { from { transform: translate(-120px, 30px) rotate(-25deg) scale(.6); opacity: 0; } }
.flip { position: relative; width: 100%; height: 100%; transition: transform .55s cubic-bezier(.3,1.4,.5,1); transform-style: preserve-3d; }
.slot.flipped .flip { transform: rotateY(180deg); }
.slot .tag { animation: tagIn .3s ease .45s backwards; }
@keyframes tagIn { from { opacity: 0; transform: scale(.4); } }
.face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.face-front { transform: rotateY(180deg); }
.tag { position: absolute; bottom: -12px; left: 50%; translate: -50% 0; z-index: 2; font: 700 11px/1 var(--mono); letter-spacing: .04em; text-transform: uppercase; padding: 6px 8px; border-radius: 999px; border: 2px solid #2b2118; white-space: nowrap; }
.tag.new { background: #ffd84a; color: #2b2118; rotate: -3deg; }
.tag.dup { background: #fffaf0; color: #6e5d4c; }

.summary { margin-top: 18px; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px; background: #fffaf0; color: #2b2118; border: 2px solid #2b2118; border-radius: 12px; padding: 10px 14px; }
.summary p { margin: 0; font-weight: 700; }

.actions { display: grid; justify-items: center; gap: 8px; margin-top: 18px; text-align: center; }
.note { margin: 0; font-size: 13px; color: var(--muted); max-width: 52ch; }
.btn { background: var(--fg); color: var(--bg); border: 0; border-radius: 10px; padding: 10px 18px; font-weight: 700; cursor: pointer; }
.btn-big { font: 400 20px/1 var(--display); padding: 16px 28px; border-radius: 14px; box-shadow: 4px 4px 0 var(--accent); }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }

/* ---------- carte ---------- */
.card {
  --cw: 196px; width: 100%; height: 100%; font-size: calc(var(--cw) * 15 / 340);
  border-radius: 1.2em; padding: .65em;
  background: linear-gradient(145deg, var(--cap), var(--cap-dark));
  box-shadow: 0 1px 0 rgba(255,255,255,.4) inset, 0 12px 28px -14px rgba(43,33,24,.7);
  position: relative; isolation: isolate; text-align: left;
}
#detail .card { --cw: min(320px, 78vw); width: var(--cw); aspect-ratio: 5 / 7; height: auto; }
.inner { height: 100%; border-radius: .75em; background: var(--paper); color: var(--ink); display: grid; grid-template-rows: auto 1fr auto auto auto; overflow: hidden; border: 1px solid rgba(43,33,24,.25); }
.top { display: flex; align-items: center; justify-content: space-between; gap: .5em; padding: .65em .75em .5em; }
.rar { display: flex; align-items: center; gap: .45em; min-width: 0; }
.cap { width: 2.2em; height: 2.2em; flex: none; filter: drop-shadow(0 1px 1px rgba(0,0,0,.3)); }
.slot.flipped .cap { animation: capPop .5s ease .25s backwards; }
@keyframes capPop { from { transform: translateY(-1.5em) rotate(-200deg) scale(1.4); } }
.rar-name { font: 700 .74em/1.1 var(--body); text-transform: uppercase; letter-spacing: .06em; }
.num { font: 600 .7em/1 var(--mono); color: #6e5d4c; font-variant-numeric: tabular-nums; white-space: nowrap; }
.art { margin: 0 .75em; border-radius: .5em; min-height: 0; overflow: hidden; display: grid; place-items: end center; border: 1px solid rgba(43,33,24,.18);
  background: radial-gradient(circle at 50% 115%, var(--art) 0 38%, transparent 39%), repeating-conic-gradient(from 0deg at 50% 115%, var(--art) 0 6deg, color-mix(in srgb, var(--art) 82%, var(--cap)) 6deg 12deg); }
.art svg { height: 92%; width: auto; display: block; }
.title { padding: .6em .75em .15em; }
.name { font: 400 1.42em/1.05 var(--display); margin: 0; text-wrap: balance; }
.meta { margin: .25em 0 0; font-size: .78em; color: #6e5d4c; }
.stats { display: grid; gap: .28em; padding: .45em .75em; }
.stat { display: grid; grid-template-columns: 6.4em 1fr; align-items: center; gap: .5em; font: 600 .66em/1 var(--mono); text-transform: uppercase; letter-spacing: .04em; color: #6e5d4c; }
.dots { display: flex; gap: .28em; }
.dots i { width: .95em; height: .95em; border-radius: 50%; border: 1.5px solid #2b2118; }
.dots i.on { background: var(--cap); border-color: var(--cap-dark); }
.legend { margin: 0 .75em .75em; padding: .5em .6em; border-radius: .45em; background: #f1e5cc; border: 1px dashed rgba(43,33,24,.4); font: italic 400 .82em/1.3 var(--body); }
.card.r5::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: 2;
  background: linear-gradient(115deg, transparent 30%, rgba(255,255,255,.55) 45%, rgba(255,240,200,.15) 52%, transparent 65%);
  background-size: 250% 100%; mix-blend-mode: soft-light; animation: foil 4.5s ease-in-out infinite; }
@keyframes foil { 0%,100% { background-position: 100% 0; } 50% { background-position: 0 0; } }
.card.back { background: linear-gradient(145deg, #b8455a, #6e2233); }
.card.back .inner { display: grid; place-items: center; background: repeating-linear-gradient(45deg, #7a2b3c 0 10px, #8a3446 10px 20px); border-color: rgba(0,0,0,.3); }
.back-logo { font: 400 2em/1 var(--display); color: #ffd84a; text-align: center; text-shadow: 3px 3px 0 #2b2118; transform: rotate(-8deg); }

/* ---------- La Cave ---------- */
.cave-rarities { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.cave-rarities li { display: flex; align-items: center; gap: 8px; background: var(--panel); border: 1px solid var(--rule); border-radius: 999px; padding: 6px 12px 6px 6px; font-size: 13px; }
.cave-rarities b { font: 600 13px/1 var(--mono); font-variant-numeric: tabular-nums; }
.mini-cap { width: 22px; height: 22px; }
.cave-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.cell { position: relative; min-height: 66px; border-radius: 10px; border: 1.5px dashed var(--rule); padding: 8px; display: grid; align-content: space-between; gap: 4px; text-align: left; color: var(--muted); background: transparent; }
.cell.got { border: 2px solid var(--cap); border-left-width: 6px; background: var(--panel); color: var(--fg); cursor: pointer; }
.cell.got:hover { transform: translateY(-2px); }
.cell-num { font: 600 11px/1 var(--mono); color: var(--muted); }
.cell-name { font-weight: 700; font-size: 13px; line-height: 1.15; }
.cell-count { position: absolute; top: 6px; right: 8px; font: 600 11px/1 var(--mono); }

dialog { border: 0; border-radius: 16px; padding: 18px; background: var(--panel); color: var(--fg); display: none; }
dialog[open] { display: grid; justify-items: center; gap: 12px; }
dialog::backdrop { background: rgba(20,14,10,.6); }
#detail-count { margin: 0; font-weight: 700; }

@media (max-width: 560px) {
  .slot, .slot .card { --cw: 220px; }
  .mini, .mini .card { --cw: 96px; }
  .counters dd { font-size: 17px; }
  .stage { min-height: 420px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
