/* ============================================================
   CARDZY — COMPONENT LIBRARY  ("Studs & Sorbet")
   Depends on tokens.css
   ============================================================ */

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

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--ink);
  background: var(--vanilla);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1,h2,h3,h4,h5 { font-family: var(--font-display); font-weight: var(--fw-semibold); margin: 0; letter-spacing: -.01em; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
::selection { background: var(--lemon); color: var(--ink); }

/* utility text-wrap */
.tw-pretty { text-wrap: pretty; }
.tw-balance { text-wrap: balance; }

/* ---------- LABEL (uppercase eyebrow) ---------- */
.lbl {
  font-family: var(--font-body);
  font-size: var(--fs-label);
  font-weight: var(--fw-bold);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* =========================================================
   BUTTONS
   ========================================================= */
.btn {
  --bg: var(--coral); --fg: #fff; --sh: var(--coral-deep);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-body);
  font-weight: var(--fw-bold);
  font-size: var(--fs-base);
  line-height: 1;
  padding: 13px 20px;
  color: var(--fg);
  background: var(--bg);
  border: var(--bw) solid var(--ink);
  border-radius: var(--r-md);
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
  white-space: nowrap;
  user-select: none;
}
.btn:hover { transform: translate(-1px,-1px); box-shadow: 4px 4px 0 var(--ink); }
.btn:active { transform: translate(2px,2px); box-shadow: 1px 1px 0 var(--ink); }
.btn:focus-visible { outline: 3px solid var(--lemon); outline-offset: 2px; }

.btn--secondary { --bg: var(--grass); --fg:#fff; }
.btn--lemon     { --bg: var(--lemon); --fg: var(--ink); }
.btn--grape     { --bg: var(--grape); --fg:#fff; }
.btn--blue      { --bg: var(--blueberry); --fg:#fff; }
.btn--danger    { --bg: var(--danger); --fg:#fff; }
.btn--ghost     { --bg: var(--paper); --fg: var(--ink); }
.btn--ink       { --bg: var(--ink); --fg:#fff; }

.btn--lg { padding: 16px 26px; font-size: var(--fs-lg); border-radius: var(--r-lg); }
.btn--sm { padding: 9px 14px; font-size: var(--fs-sm); box-shadow: 2px 2px 0 var(--ink); }
.btn--block { display: flex; width: 100%; }

.btn[disabled], .btn.is-disabled {
  --bg: #EAE0D4; --fg: var(--ink-faint);
  box-shadow: 3px 3px 0 #CFC4B6; border-color: #CFC4B6;
  cursor: not-allowed; pointer-events: none;
}

/* icon-only round button */
.iconbtn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px;
  background: var(--paper); color: var(--ink);
  border: var(--bw) solid var(--ink);
  border-radius: var(--r-pill);
  box-shadow: 2px 2px 0 var(--ink);
  transition: transform var(--t-fast), box-shadow var(--t-fast);
}
.iconbtn:hover { transform: translate(-1px,-1px); box-shadow: 3px 3px 0 var(--ink); }
.iconbtn:active { transform: translate(1px,1px); box-shadow: 1px 1px 0 var(--ink); }

/* =========================================================
   INPUTS
   ========================================================= */
.field { display: flex; flex-direction: column; gap: 7px; }
.field > .lbl { margin-bottom: 1px; }

.input, .select, .textarea {
  font-family: var(--font-body);
  font-size: var(--fs-base);
  color: var(--ink);
  background: var(--paper);
  border: var(--bw) solid var(--ink);
  border-radius: var(--r-md);
  padding: 12px 14px;
  width: 100%;
  box-shadow: var(--sh-block-xs);
  transition: box-shadow var(--t-fast), border-color var(--t-fast);
}
.input::placeholder, .textarea::placeholder { color: var(--ink-faint); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--coral);
  box-shadow: 2px 2px 0 var(--coral);
}
.textarea { resize: vertical; min-height: 110px; line-height: 1.5; }
.input--err { border-color: var(--danger); box-shadow: 2px 2px 0 var(--danger); }
.field-hint { font-size: var(--fs-xs); color: var(--ink-faint); }
.field-err  { font-size: var(--fs-xs); color: var(--danger); font-weight: var(--fw-semibold); }

/* search input with leading icon */
.search {
  display: flex; align-items: center; gap: 10px;
  background: var(--paper);
  border: var(--bw) solid var(--ink);
  border-radius: var(--r-pill);
  padding: 11px 18px;
  box-shadow: var(--sh-block-xs);
}
.search input { border: none; outline: none; background: none; flex: 1; font-family: var(--font-body); font-size: var(--fs-base); color: var(--ink); }
.search input::placeholder { color: var(--ink-faint); }

/* stepper (qty) */
.stepper { display: inline-flex; align-items: center; border: var(--bw) solid var(--ink); border-radius: var(--r-md); overflow: hidden; box-shadow: var(--sh-block-xs); background: var(--paper); }
.stepper button { width: 40px; height: 42px; border: none; background: var(--paper); font-size: 20px; color: var(--ink); display: grid; place-items: center; }
.stepper button:hover { background: var(--cream); }
.stepper input { width: 48px; height: 42px; text-align: center; border: none; border-inline: var(--bw) solid var(--ink); font-family: var(--font-display); font-weight: 600; font-size: 16px; color: var(--ink); background: var(--paper); }

/* toggle */
.toggle { position: relative; width: 50px; height: 28px; border: var(--bw) solid var(--ink); border-radius: var(--r-pill); background: var(--paper); cursor: pointer; transition: background var(--t-fast); flex: none; }
.toggle::after { content:""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--ink); transition: transform var(--t-spring); }
.toggle.is-on { background: var(--grass); }
.toggle.is-on::after { transform: translateX(22px); background:#fff; }

/* =========================================================
   CHIPS / PILLS / TABS
   ========================================================= */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--fs-sm); font-weight: var(--fw-semibold);
  padding: 7px 13px; border-radius: var(--r-pill);
  background: var(--paper); color: var(--ink);
  border: var(--bw) solid var(--ink);
  box-shadow: var(--sh-block-xs);
  transition: transform var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
  user-select: none;
}
.chip:hover { transform: translate(-1px,-1px); box-shadow: var(--sh-block); }
.chip.is-active { background: var(--ink); color: #fff; }
.chip.is-active.chip--coral { background: var(--coral); color:#fff; }
.chip.is-active.chip--grass { background: var(--grass); color:#fff; }
.chip--soft { border-color: var(--line-soft); box-shadow: none; background: var(--paper); }
.chip--soft:hover { transform: none; box-shadow: var(--sh-block-xs); }

/* pill-tab row */
.tabs { display: inline-flex; gap: 8px; flex-wrap: wrap; }
.tab {
  font-family: var(--font-body); font-weight: var(--fw-semibold); font-size: var(--fs-sm);
  padding: 9px 16px; border-radius: var(--r-pill);
  background: transparent; color: var(--ink-soft);
  border: var(--bw) solid transparent;
  display: inline-flex; align-items: center; gap: 7px;
}
.tab:hover { background: var(--cream); color: var(--ink); }
.tab.is-active { background: var(--paper); color: var(--ink); border-color: var(--ink); box-shadow: var(--sh-block-xs); }
.tab .count { font-size: 11px; background: var(--ink); color:#fff; border-radius: var(--r-pill); padding: 1px 7px; font-weight: 700; }
.tab.is-active .count { background: var(--coral); }

/* underline tabs (content sections) */
.utabs { display: flex; gap: 26px; border-bottom: var(--bw) solid var(--line-soft); }
.utab { padding: 12px 2px; font-weight: var(--fw-semibold); color: var(--ink-faint); border-bottom: 3px solid transparent; margin-bottom: -2px; transition: color var(--t-fast); }
.utab:hover { color: var(--ink); }
.utab.is-active { color: var(--ink); border-color: var(--coral); }

/* =========================================================
   BADGES (rarity / game / status)
   ========================================================= */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: var(--fs-xs); font-weight: var(--fw-bold);
  letter-spacing: .01em;
  padding: 4px 10px; border-radius: var(--r-pill);
  border: var(--bw) solid var(--ink);
  white-space: nowrap;
}
.badge--sm { font-size: 10.5px; padding: 3px 8px; }

/* rarity */
.rar-common    { background: var(--r-common-bg);    color:#1F6B4A; }
.rar-uncommon  { background: var(--r-uncommon-bg);  color:#1D4ED8; }
.rar-rare      { background: var(--r-rare-bg);      color:#6D28D9; }
.rar-epic      { background: var(--r-epic-bg);      color:#5B21B6; }
.rar-legendary { background: var(--r-legendary-bg); color:#92660A; }
.rar-mythic    { background: var(--r-mythic-bg);    color:#BE185D; }
.rar-divine    { background: linear-gradient(90deg,#FCE0E5,#FFF0CC,#E1E5FD); color: var(--ink); }

/* game tags */
.game-adoptme { background: var(--g-adoptme-bg); color: var(--g-adoptme); }
.game-grow    { background: var(--g-grow-bg);    color: var(--g-grow); }
.game-mm2     { background: var(--g-mm2-bg);     color: var(--g-mm2); }
.game-blade   { background: var(--g-blade-bg);   color: var(--g-blade); }
.game-blox    { background: var(--g-blox-bg);    color: var(--g-blox); }
.game-petsim  { background: var(--g-petsim-bg);  color: var(--g-petsim); }

/* status-pill (with dot) */
.status { display: inline-flex; align-items: center; gap: 7px; font-size: var(--fs-xs); font-weight: var(--fw-bold); padding: 5px 11px 5px 9px; border-radius: var(--r-pill); border: var(--bw) solid var(--ink); }
.status .dot { width: 8px; height: 8px; border-radius: 50%; box-shadow: 0 0 0 2px rgba(255,255,255,.6); }
.status--ok    { background: var(--success-bg); color:#1F6B4A; } .status--ok .dot{ background: var(--success); }
.status--wait  { background: var(--warning-bg); color:#92660A; } .status--wait .dot{ background: var(--warning); }
.status--live  { background: var(--status-live-bg); color: var(--coral-deep); } .status--live .dot{ background: var(--coral); animation: pulse-dot 1.4s infinite; }
.status--err   { background: var(--danger-bg); color: var(--danger-deep); } .status--err .dot{ background: var(--danger); }
.status--info  { background: var(--info-bg); color: var(--info); } .status--info .dot{ background: var(--info); }
.status--muted { background: #EFE7DD; color: var(--ink-soft); } .status--muted .dot{ background: var(--ink-faint); }

@keyframes pulse-dot { 0%,100%{ box-shadow: 0 0 0 2px rgba(255,255,255,.6), 0 0 0 0 rgba(255,122,89,.5);} 50%{ box-shadow: 0 0 0 2px rgba(255,255,255,.6), 0 0 0 6px rgba(255,122,89,0);} }

/* =========================================================
   CARDS / SURFACES
   ========================================================= */
.card {
  background: var(--paper);
  border: var(--bw) solid var(--ink);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-block);
}
.card--soft { box-shadow: var(--sh-soft); border: var(--border-soft); }
.card--flat { box-shadow: none; }
.card-pad { padding: var(--sp-6); }

/* item card (marketplace) */
.item-card {
  background: var(--paper); border: var(--bw) solid var(--ink);
  border-radius: var(--r-lg); overflow: hidden;
  box-shadow: var(--sh-block); cursor: pointer;
  transition: transform var(--t-fast), box-shadow var(--t-fast);
  display: flex; flex-direction: column;
}
.item-card:hover { transform: translate(-2px,-2px); box-shadow: var(--sh-block-lg); }
.item-thumb { position: relative; aspect-ratio: 1/1; background: var(--cream); display: grid; place-items: center; overflow: hidden; }
.item-thumb img { width: 78%; height: 78%; object-fit: contain; filter: drop-shadow(0 6px 10px rgba(36,27,22,.18)); }
.item-thumb .game-tag { position: absolute; top: 9px; left: 9px; }
.item-thumb .fav { position: absolute; top: 9px; right: 9px; }
/* item-body wypełnia resztę karty (flex:1), item-foot zawsze na dole */
.item-body { padding: 11px 12px 13px; display: flex; flex-direction: column; gap: 7px; flex: 1; }
.item-name { font-family: var(--font-display); font-weight: 600; font-size: var(--fs-h4); line-height: 1.15; flex: 1; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 6px; }
.price { font-family: var(--font-display); font-weight: 600; font-size: var(--fs-price); color: var(--ink); }
.price .cur { font-size: 12px; color: var(--ink-soft); font-weight: 600; }

/* heart fav */
.fav { width: 30px; height: 30px; border-radius: 50%; background: rgba(255,255,255,.92); border: var(--bw) solid var(--ink); display: grid; place-items: center; font-size: 13px; color: var(--ink); transition: transform var(--t-fast), background var(--t-fast); }
.fav:hover { transform: scale(1.08); }
.fav.is-on { background: var(--bubble); color:#fff; }

/* feature/icon tile */
.itile { width: 44px; height: 44px; border-radius: var(--r-md); display: grid; place-items: center; border: var(--bw) solid var(--ink); flex: none; }
.itile--coral { background: var(--coral-tint); } .itile--grass { background: var(--grass-tint); }
.itile--blue  { background: var(--blueberry-tint); } .itile--lemon { background: var(--lemon-tint); }
.itile--grape { background: var(--grape-tint); } .itile--bubble { background: var(--bubble-tint); }

/* studs strip (signature roblox motif) */
.studs { display: flex; gap: 8px; align-items: center; }
.studs .stud { width: 10px; height: 10px; border-radius: 50%; background: var(--ink); opacity: .18; }
.studs--lemon .stud { background: var(--lemon-deep); opacity: 1; }

/* =========================================================
   AVATAR / RATING / TOOLTIP
   ========================================================= */
.avatar { display: inline-grid; place-items: center; border-radius: 50%; border: var(--bw) solid var(--ink); font-family: var(--font-display); font-weight: 600; color:#fff; overflow: hidden; flex: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--sm { width: 32px; height: 32px; font-size: 14px; }
.avatar--md { width: 42px; height: 42px; font-size: 17px; }
.avatar--lg { width: 56px; height: 56px; font-size: 22px; }
.avatar .on-dot { position: absolute; }

.stars { display: inline-flex; align-items: center; gap: 2px; color: var(--lemon-deep); font-size: 13px; }
.stars .num { color: var(--ink-soft); font-size: var(--fs-xs); font-weight: 700; margin-left: 4px; }

.tip { position: relative; display: inline-flex; }
.tip__bub { position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); background: var(--ink); color:#fff; font-size: var(--fs-xs); font-weight: 600; padding: 6px 10px; border-radius: var(--r-sm); white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity var(--t-fast); box-shadow: var(--sh-soft); }
.tip__bub::after { content:""; position: absolute; top: 100%; left: 50%; transform: translateX(-50%); border: 5px solid transparent; border-top-color: var(--ink); }
.tip:hover .tip__bub { opacity: 1; }

/* =========================================================
   TIMELINE (escrow steps)
   ========================================================= */
.timeline { display: flex; flex-direction: column; gap: 0; }
.tl-step { display: flex; gap: 14px; position: relative; padding-bottom: 22px; }
.tl-step:last-child { padding-bottom: 0; }
.tl-step::before { content:""; position: absolute; left: 17px; top: 36px; bottom: 0; width: 2.5px; background: var(--line-soft); }
.tl-step:last-child::before { display: none; }
.tl-step.is-done::before { background: var(--grass); }
.tl-node { width: 36px; height: 36px; flex: none; border-radius: 50%; border: var(--bw) solid var(--ink); display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; font-size: 15px; background: var(--paper); color: var(--ink-faint); z-index: 1; }
.tl-step.is-done .tl-node { background: var(--grass); color:#fff; }
.tl-step.is-active .tl-node { background: var(--coral); color:#fff; box-shadow: 0 0 0 4px var(--coral-tint); animation: pulse-node 1.6s infinite; }
.tl-body { padding-top: 5px; }
.tl-title { font-family: var(--font-display); font-weight: 600; font-size: var(--fs-h4); }
.tl-sub { font-size: var(--fs-sm); color: var(--ink-soft); margin-top: 2px; }
@keyframes pulse-node { 0%,100%{ box-shadow: 0 0 0 4px var(--coral-tint);} 50%{ box-shadow: 0 0 0 8px rgba(255,122,89,.12);} }

/* horizontal step bar */
.hsteps { display: flex; gap: 10px; }
.hstep { flex: 1; text-align: center; }
.hstep .hnode { width: 46px; height: 46px; margin: 0 auto 8px; border-radius: var(--r-md); border: var(--bw) solid var(--ink); display: grid; place-items: center; font-size: 22px; background: var(--paper); box-shadow: var(--sh-block-xs); }
.hstep.is-done .hnode { background: var(--grass-tint); }
.hstep .hlbl { font-size: 10px; font-weight: 800; letter-spacing: .08em; color: var(--ink-faint); text-transform: uppercase; }
.hstep .htitle { font-size: var(--fs-sm); font-weight: 700; margin-top: 2px; }

/* =========================================================
   MODAL / TOAST / DRAWER
   ========================================================= */
.overlay { position: fixed; inset: 0; background: rgba(36,27,22,.42); backdrop-filter: blur(2px); display: grid; place-items: center; padding: 24px; z-index: 200; animation: fade .16s ease; }
@keyframes fade { from{opacity:0} to{opacity:1} }
.modal { background: var(--paper); border: var(--bw-thick) solid var(--ink); border-radius: var(--r-2xl); box-shadow: var(--sh-block-lg); width: 100%; max-width: 480px; overflow: hidden; animation: pop .26s cubic-bezier(.34,1.56,.64,1); }
@keyframes pop { from{ transform: translateY(10px) scale(.97); opacity:0 } to{ transform: none; opacity:1 } }
.modal-head { padding: 20px 24px; border-bottom: var(--bw) solid var(--line-soft); display: flex; align-items: center; justify-content: space-between; }
.modal-body { padding: 24px; }
.modal-foot { padding: 16px 24px; border-top: var(--bw) solid var(--line-soft); display: flex; gap: 10px; justify-content: flex-end; }

.toast { display: flex; align-items: center; gap: 12px; background: var(--paper); border: var(--bw) solid var(--ink); border-radius: var(--r-md); box-shadow: var(--sh-block); padding: 13px 16px; max-width: 360px; animation: toast-in .3s cubic-bezier(.34,1.56,.64,1); }
.toast .ticon { width: 34px; height: 34px; border-radius: var(--r-sm); display: grid; place-items: center; flex: none; border: var(--bw) solid var(--ink); }
@keyframes toast-in { from{ transform: translateX(20px); opacity:0 } to{ transform:none; opacity:1 } }

/* =========================================================
   BANNERS / NOTICES
   ========================================================= */
.notice { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--r-md); border: var(--bw) solid var(--ink); font-size: var(--fs-sm); align-items: flex-start; }
.notice--info { background: var(--info-bg); }
.notice--ok { background: var(--success-bg); }
.notice--warn { background: var(--warning-bg); }
.notice--err { background: var(--danger-bg); }

/* progress bar */
.bar { height: 12px; background: var(--cream); border: var(--bw) solid var(--ink); border-radius: var(--r-pill); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--lemon); border-right: var(--bw) solid var(--ink); }

/* =========================================================
   SKELETON (loading)
   ========================================================= */
.sk { background: linear-gradient(100deg, #EFE6DA 30%, #F8F1E8 50%, #EFE6DA 70%); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: var(--r-sm); }
@keyframes sk { from{ background-position: 200% 0 } to{ background-position: -200% 0 } }

/* =========================================================
   HELPERS
   ========================================================= */
.row { display: flex; align-items: center; }
.col { display: flex; flex-direction: column; }
.gap-1{gap:4px}.gap-2{gap:8px}.gap-3{gap:12px}.gap-4{gap:16px}.gap-5{gap:20px}.gap-6{gap:24px}
.between { justify-content: space-between; }
.center { align-items: center; justify-content: center; }
.wrap { flex-wrap: wrap; }
.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); }
.mono { font-family: var(--font-mono); }
.grow { flex: 1; }

/* =========================================================
   DARK THEME — component fixes
   (--ink flips to cream, so high-contrast spots need dark text)
   ========================================================= */
[data-theme="dark"] .chip.is-active:not(.chip--coral):not(.chip--grass) { color: var(--vanilla); }
[data-theme="dark"] .tab .count { color: var(--vanilla); }
[data-theme="dark"] .tab.is-active .count { color: #fff; }
[data-theme="dark"] .btn--ink { --fg: var(--vanilla); }
[data-theme="dark"] .badge.rar-divine { color: var(--vanilla); }

/* notices → dark translucent so cream body text reads */
[data-theme="dark"] .notice--info { background: rgba(108,124,240,.16); }
[data-theme="dark"] .notice--ok   { background: rgba(93,187,142,.16); }
[data-theme="dark"] .notice--warn { background: rgba(255,201,77,.15); }
[data-theme="dark"] .notice--err  { background: rgba(229,72,77,.18); }

/* skeleton shimmer for dark */
[data-theme="dark"] .sk { background: linear-gradient(100deg,#2E2519 30%,#3A2F22 50%,#2E2519 70%); background-size:200% 100%; }

/* keep light pastel chips/badges readable — they already carry dark text */
[data-theme="dark"] .status--ok   { color:#1F6B4A; }
[data-theme="dark"] .status--wait { color:#92660A; }
[data-theme="dark"] .status--err  { color: var(--danger-deep); }

/* theme toggle */
.theme-toggle { display:inline-grid; place-items:center; width:40px; height:40px; border-radius:var(--r-pill); border:var(--bw) solid var(--ink); background:var(--paper); color:var(--ink); box-shadow:2px 2px 0 var(--ink); cursor:pointer; font-size:17px; transition: transform var(--t-fast); }
.theme-toggle:hover { transform: translate(-1px,-1px); box-shadow:3px 3px 0 var(--ink); }
.theme-toggle:active { transform: translate(1px,1px); box-shadow:1px 1px 0 var(--ink); }
