/* ==========================================================
   SigilBound · UI kit checkpoint 2
   Skeleton, stati vuoti/errore, tooltip, onboarding, card art,
   filtri, deck builder, accessibilità e responsive 390px
   ========================================================== */

/* ---------- Accessibilità: focus sempre visibile ---------- */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 6px;
}
.skip-link {
  position: absolute; left: -9999px; top: 8px; z-index: 999;
  background: var(--raised); color: var(--gold); padding: 10px 16px;
  border-radius: var(--r); border: 1px solid rgba(232,203,148,.35);
}
.skip-link:focus { left: 16px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Skeleton di caricamento ---------- */
.sk { display: grid; gap: 10px; }
.sk-row, .sk-card {
  background: linear-gradient(90deg, #1B1512 25%, #241C18 37%, #1B1512 63%);
  background-size: 400% 100%;
  animation: skShine 1.4s ease-in-out infinite;
  border-radius: var(--r);
}
.sk-row { height: 44px; }
.sk-card { height: 150px; }
.sk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
@keyframes skShine { 0% { background-position: 100% 0 } 100% { background-position: 0 0 } }
@media (prefers-reduced-motion: reduce) { .sk-row, .sk-card { animation: none } }

/* ---------- Stati vuoti / errore ---------- */
.state {
  text-align: center; padding: 38px 20px; border: 1px dashed rgba(232,203,148,.22);
  border-radius: var(--r-lg); background: rgba(255,255,255,.015);
}
.state .ico { font-size: 34px; display: block; margin-bottom: 10px; }
.state h4 { margin: 0 0 6px; color: var(--gold); font-size: 16px; }
.state p { margin: 0 auto 14px; max-width: 46ch; color: #A69C93; font-size: 13.5px; line-height: 1.6; }
.state.error { border-color: rgba(229,100,88,.4); }
.state.error h4 { color: var(--blood); }

/* ---------- Tooltip ---------- */
.tip { position: relative; }
.tip::after {
  content: attr(data-tip);
  position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%) translateY(4px);
  background: #0E0B09; color: #E7DDD0; border: 1px solid rgba(232,203,148,.28);
  padding: 7px 10px; border-radius: 8px; font-size: 12px; line-height: 1.4;
  white-space: nowrap; opacity: 0; pointer-events: none; transition: .16s ease; z-index: 40;
  box-shadow: 0 10px 24px rgba(0,0,0,.5);
}
.tip:hover::after, .tip:focus-visible::after { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Toolbar filtri ---------- */
.toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px solid rgba(255,255,255,.06);
}
.toolbar input[type="search"], .toolbar select {
  background: #140F0D; border: 1px solid rgba(255,255,255,.1); color: #EFE7DC;
  padding: 9px 12px; border-radius: var(--r); font: inherit; font-size: 13.5px;
}
.toolbar input[type="search"] { flex: 1 1 200px; min-width: 150px; }
.count-pill {
  margin-left: auto; font-size: 12.5px; color: #A69C93;
  background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.08);
  padding: 6px 12px; border-radius: 999px; white-space: nowrap;
}

/* ---------- Griglia carte ---------- */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 14px; }
.gcard {
  position: relative; text-align: left; cursor: pointer;
  background: linear-gradient(180deg, #1D1714, #15100E);
  border: 1px solid rgba(232,203,148,.16); border-radius: 14px; overflow: hidden;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.gcard:hover, .gcard:focus-visible { transform: translateY(-4px); border-color: rgba(232,203,148,.45); box-shadow: 0 14px 30px rgba(0,0,0,.45); }
.gcard .art {
  height: 96px; display: grid; place-items: center; font-size: 34px;
  background: radial-gradient(90% 100% at 50% 0%, rgba(228,135,58,.28), transparent 70%), #120D0B;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.gcard .art img { width: 100%; height: 100%; object-fit: cover; }
.gcard .body { padding: 10px 12px 12px; }
.gcard h5 { margin: 0 0 4px; font-size: 13.5px; color: #F2E9DC; line-height: 1.3; }
.gcard .meta { font-size: 11.5px; color: #9A9089; display: flex; gap: 8px; flex-wrap: wrap; }
.gcard .stats { margin-top: 8px; display: flex; gap: 8px; font-size: 12px; color: #D7C9B4; }
.gcard .add {
  position: absolute; top: 8px; right: 8px; width: 26px; height: 26px; border-radius: 50%;
  border: 1px solid rgba(232,203,148,.4); background: rgba(10,8,7,.8); color: var(--gold);
  display: grid; place-items: center; font-size: 15px; cursor: pointer;
}
.rar { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 10.5px; border: 1px solid; }
.rar.comune { color: #A9A29A; border-color: rgba(169,162,154,.4); }
.rar.rara { color: var(--blue); border-color: rgba(94,159,232,.45); }
.rar.epica { color: #B98BE0; border-color: rgba(185,139,224,.45); }
.rar.leggendaria { color: var(--ember); border-color: rgba(228,135,58,.5); }

/* ---------- Deck builder ---------- */
.deck-layout { display: grid; grid-template-columns: 1.4fr .9fr; gap: 18px; align-items: start; }
.deck-side {
  position: sticky; top: 8px; background: rgba(255,255,255,.02);
  border: 1px solid rgba(255,255,255,.08); border-radius: var(--r-lg); padding: 16px;
}
.deck-side h4 { margin: 0 0 12px; color: var(--gold); font-size: 15px; }
.req { display: grid; gap: 10px; margin-bottom: 14px; }
.req-row { display: grid; gap: 5px; }
.req-row .lbl { display: flex; justify-content: space-between; font-size: 12.5px; color: #B7ADA3; }
.req-row .lbl b { color: #EFE7DC; }
.req-row.ok .lbl b { color: var(--green); }
.meter { height: 6px; background: rgba(255,255,255,.07); border-radius: 999px; overflow: hidden; }
.meter i { display: block; height: 100%; background: linear-gradient(90deg, var(--ember), var(--gold)); transition: width .25s ease; }
.req-row.ok .meter i { background: var(--green); }
.deck-list { max-height: 260px; overflow: auto; display: grid; gap: 6px; margin-bottom: 12px; }
.deck-item {
  display: flex; align-items: center; gap: 8px; font-size: 12.5px;
  background: rgba(255,255,255,.03); border: 1px solid rgba(255,255,255,.06);
  border-radius: 8px; padding: 7px 10px;
}
.deck-item span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deck-item button {
  background: none; border: 1px solid rgba(229,100,88,.4); color: var(--blood);
  border-radius: 6px; width: 22px; height: 22px; cursor: pointer; line-height: 1;
}
.valid-msg { font-size: 12.5px; padding: 9px 11px; border-radius: 8px; margin-bottom: 12px; }
.valid-msg.ko { color: #F0B3AC; background: rgba(229,100,88,.12); border: 1px solid rgba(229,100,88,.3); }
.valid-msg.ok { color: #A8E0C0; background: rgba(114,188,143,.12); border: 1px solid rgba(114,188,143,.3); }

/* ---------- Onboarding ---------- */
.onb {
  position: fixed; inset: 0; z-index: 90; display: grid; place-items: center;
  background: rgba(6,5,4,.78); backdrop-filter: blur(6px); padding: 20px;
}
.onb-card {
  max-width: 520px; width: 100%; background: linear-gradient(180deg, #1B1512, #130E0C);
  border: 1px solid rgba(232,203,148,.25); border-radius: var(--r-lg); padding: 28px; text-align: center;
  box-shadow: 0 30px 70px rgba(0,0,0,.6);
}
.onb-card .ico { font-size: 40px; }
.onb-card h3 { margin: 12px 0 8px; color: var(--gold); font-size: 20px; }
.onb-card p { color: #B7ADA3; font-size: 14px; line-height: 1.65; margin: 0 0 20px; }
.onb-dots { display: flex; gap: 6px; justify-content: center; margin-bottom: 18px; }
.onb-dots i { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,.2); }
.onb-dots i.on { background: var(--gold); }
.onb-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .deck-layout { grid-template-columns: 1fr; }
  .deck-side { position: static; }
}
@media (max-width: 460px) {
  .cards-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  .toolbar { gap: 8px; }
  .count-pill { margin-left: 0; width: 100%; text-align: center; }
  .onb-card { padding: 22px 18px; }
  .tip::after { display: none; }
}

/* ==========================================================
   Risorse grafiche di gioco (logo, cornici, icone, dorsi)
   ========================================================== */
.brand-logo {
  display: block;
  height: 40px;
  width: auto;
  border-radius: 8px;
  image-rendering: auto;
}
.brand-logo.big {
  height: auto;
  max-width: min(320px, 78%);
  margin: 0 auto 10px;
  filter: drop-shadow(0 10px 26px rgba(0, 0, 0, .65));
}
.chip-btn {
  cursor: pointer;
  border: 0;
  font: inherit;
  transition: transform .15s ease, filter .15s ease;
}
.chip-btn:hover { transform: translateY(-1px); }
.chip-btn.on { box-shadow: 0 0 0 1px rgba(232, 203, 148, .55) inset; filter: saturate(1.3); }
.chip-btn:not(.on) { opacity: .6; }

/* Icone risorsa inline */
.rico {
  width: 1.15em;
  height: 1.15em;
  object-fit: contain;
  vertical-align: -.22em;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .6));
}

/* Cornice reale della carta attorno all'illustrazione */
.gcard .art.framed {
  position: relative;
  width: 100%;
  height: auto;
  aspect-ratio: 5 / 7;
  background-image: var(--frame);
  background-size: 100% 100%;
  background-color: #120d0a;
  border-bottom: 0;
  overflow: hidden;
}
/* Finestra interna della cornice in cui compare l'illustrazione */
.gcard .art.framed .illu,
.gcard .art.framed .illu-ph {
  position: absolute;
  top: 10%;
  left: 11%;
  width: 78%;
  height: 57%;
  border-radius: 4px;
}
.gcard .art.framed .illu { object-fit: cover; }
.gcard .art.framed .illu-ph {
  display: grid;
  place-items: center;
  font-size: clamp(26px, 6vw, 40px);
  opacity: .8;
}

.gcard .art.back img { width: 100%; display: block; }

@media (prefers-reduced-motion: no-preference) {
  .gcard:hover .art.framed .illu { transform: scale(1.03); transition: transform .3s ease; }
}

/* ==========================================================
   Checkpoint 5 · statistiche, missioni, draft, tabellone
   ========================================================== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}
.stat {
  background: linear-gradient(180deg, #1D1714, #15100E);
  border: 1px solid rgba(232, 203, 148, .18);
  border-radius: 14px;
  padding: 14px 16px;
  text-align: center;
}
.stat b { display: block; font-size: 26px; color: var(--gold); line-height: 1.1; }
.stat span { font-size: 12px; color: #9A8F84; }

.pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  border: 1px solid transparent;
}
.pill.win { color: #8FD9A8; background: rgba(114, 188, 143, .12); border-color: rgba(114, 188, 143, .4); }
.pill.loss { color: #E9A2A2; background: rgba(190, 74, 74, .12); border-color: rgba(190, 74, 74, .4); }

.pbar.big { height: 12px; }
.quest.ready { border-color: rgba(228, 135, 58, .6); box-shadow: 0 0 0 1px rgba(228, 135, 58, .22) inset; }
.sk-quest { min-height: 132px; background: rgba(255, 255, 255, .03); animation: skpulse 1.2s ease-in-out infinite; }
@keyframes skpulse { 0%, 100% { opacity: .45 } 50% { opacity: .8 } }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }

/* Draft della Modalità Eventi */
.draft-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.draft-cell { position: relative; cursor: pointer; border-radius: 14px; transition: transform .15s ease, box-shadow .15s ease; }
.draft-cell:hover { transform: translateY(-3px); }
.draft-cell.picked { box-shadow: 0 0 0 2px var(--gold), 0 10px 22px rgba(0, 0, 0, .5); }
.draft-cell.picked::after {
  content: "\2713";
  position: absolute;
  top: 8px; right: 8px;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--gold);
  color: #17110D;
  font-weight: 700;
}
.board-actions.sticky {
  position: sticky;
  bottom: -1px;
  z-index: 3;
  background: rgba(17, 13, 11, .96);
  backdrop-filter: blur(6px);
  border-top: 1px solid rgba(232, 203, 148, .18);
  padding: 12px 4px;
  margin: 14px -4px -4px;
  border-radius: 12px 12px 0 0;
}

/* Candele della Modalità Eventi */
.candles-bar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 8px 14px; margin-bottom: 12px;
  border: 1px solid rgba(232, 203, 148, .22);
  border-radius: 12px;
  background: rgba(255, 255, 255, .03);
  font-size: 13px;
}
.candles-bar .cd { color: #C9BCA9; }
.candle { font-size: 17px; }
.candle.out { filter: grayscale(1); opacity: .45; }

/* Tabellone del torneo */
.bracket { display: flex; gap: 22px; overflow-x: auto; padding: 10px 2px 16px; align-items: stretch; }
.bracket-round { min-width: 180px; display: flex; flex-direction: column; }
.bracket-col { flex: 1; display: flex; flex-direction: column; justify-content: space-around; gap: 14px; }
.bracket-round h5 { margin: 0 0 4px; color: var(--gold); font-size: 12.5px; text-transform: uppercase; letter-spacing: .08em; }
.bk-match {
  display: grid; gap: 4px;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 12px;
  padding: 8px;
  background: rgba(255, 255, 255, .02);
}
.bk-slot {
  text-align: left;
  font: inherit;
  font-size: 12.5px;
  color: #EFE7DC;
  background: rgba(255, 255, 255, .04);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 6px 9px;
}
button.bk-slot { cursor: pointer; }
button.bk-slot:hover { border-color: rgba(232, 203, 148, .5); }
.bk-slot.win { border-color: rgba(114, 188, 143, .55); color: #8FD9A8; }
.bk-slot.bye { opacity: .45; }

.coin img { width: 72px; height: 72px; object-fit: contain; animation: coinspin 1.1s ease-in-out; }
@keyframes coinspin { from { transform: rotateY(0) scale(.7) } to { transform: rotateY(1080deg) scale(1) } }
@media (prefers-reduced-motion: reduce) { .coin img { animation: none } }

/* Slider coerenti con il tema (volume audio e musica) */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--ember, #E4873A), var(--gold, #E8CB94));
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .35);
}
input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, #E4873A, #E8CB94);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -6px;
  border-radius: 50%;
  background: #1D1714;
  border: 2px solid var(--gold, #E8CB94);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .6);
}
input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #1D1714;
  border: 2px solid #E8CB94;
}
input[type="range"]:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--gold, #E8CB94); outline-offset: 2px; }

/* Stato del battito anti-pausa (pannello amministratore) */
.hb-ok { color: var(--green, #72BC8F); }
.hb-warn { color: var(--ember, #E4873A); }
