/* Stardust (/stardust): a full-screen canvas with the count on top and the
   shop as a bottom drawer on phones, a right-hand panel from 900px. Builds on
   tokens.css. main.js positions the star button and assumes the collapsed
   drawer is 42% of the height and the panel 400px wide — keep them in step. */

html, body.sd { height: 100%; overflow: hidden; }
body.sd {
  min-height: 0;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.sd-sky { position: fixed; inset: 0; z-index: 0; }

.sd-star {
  position: fixed; z-index: 1;
  border: 0; padding: 0; border-radius: 50%;
  background: transparent; cursor: pointer;
  touch-action: none;
}
.sd-star:focus-visible { outline-offset: -6px; }

/* ---------- top bar ---------- */
.sd-top {
  position: fixed; z-index: 2; top: 0; left: 0; right: 0;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) 16px 0;
  pointer-events: none;
}
.sd-top > * { pointer-events: auto; }
.sd-home, .sd-icon {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 50%;
  background: rgba(2, 4, 3, 0.6); color: var(--muted);
  font: 400 18px/1 var(--font); cursor: pointer;
}
.sd-home:hover, .sd-icon:hover { color: var(--text); border-color: var(--line-strong); }
.sd-icon { gap: 3px; align-content: center; position: relative; }
.sd-icon span { display: block; width: 14px; height: 1.5px; background: currentColor; border-radius: 1px; }
.sd-icon[data-sync="ok"]::after,
.sd-icon[data-sync="error"]::after,
.sd-icon[data-sync="syncing"]::after {
  content: ''; position: absolute; top: 3px; right: 3px; width: 7px; height: 7px; border-radius: 50%;
  background: var(--sage);
}
.sd-icon[data-sync="error"]::after { background: var(--error); }

.sd-count { text-align: center; text-shadow: 0 1px 10px rgba(0, 0, 0, 0.8); min-width: 0; }
.sd-total {
  font: 600 clamp(26px, 7.5vw, 38px)/1.1 var(--mono);
  letter-spacing: -0.01em; color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.sd-label { font-size: 12px; color: var(--muted); letter-spacing: 0.02em; }
.sd-label span { font-family: var(--mono); color: var(--sage); }
.sd-boost {
  display: inline-block; margin-top: 6px; padding: 2px 10px;
  border: 1px solid var(--line-strong); border-radius: 999px;
  font: 600 11px/1.6 var(--mono); color: #F2D48A; letter-spacing: 0.04em;
}
.sd-boost[hidden] { display: none; }

/* ---------- shop panel ---------- */
.sd-panel {
  position: fixed; z-index: 3; left: 0; right: 0; bottom: 0;
  height: 42%;
  display: flex; flex-direction: column;
  background: rgba(8, 16, 11, 0.94);
  border-top: 1px solid var(--line-strong);
  border-radius: 18px 18px 0 0;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  transition: height 0.3s var(--ease);
  padding-bottom: env(safe-area-inset-bottom);
}
.sd-panel[data-open="true"] { height: 82%; }
.sd-handle {
  flex: none; height: 22px; border: 0; background: transparent; cursor: pointer;
  display: grid; place-items: center;
}
.sd-handle span { width: 38px; height: 4px; border-radius: 2px; background: var(--line-strong); }

.sd-tabs { flex: none; display: flex; gap: 4px; padding: 0 12px 8px; }
.sd-tabs button {
  flex: 1; padding: 9px 4px; border: 0; border-radius: 10px;
  background: transparent; color: var(--muted);
  font: 500 14px/1 var(--font); cursor: pointer; white-space: nowrap;
}
.sd-tabs button[aria-selected="true"] { background: var(--raised); color: var(--text); }
.sd-badge {
  display: inline-block; min-width: 16px; margin-left: 4px; padding: 1px 4px;
  border-radius: 8px; background: var(--sage); color: var(--bg);
  font: 700 10px/14px var(--mono); vertical-align: 1px;
}
.sd-badge:empty { display: none; }

.sd-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 0 12px 16px; -webkit-overflow-scrolling: touch; }

.sd-amount { display: flex; gap: 6px; justify-content: flex-end; margin-bottom: 8px; }
.sd-amount button {
  padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px;
  background: transparent; color: var(--muted); font: 500 12px/1.4 var(--mono); cursor: pointer;
}
.sd-amount button[aria-pressed="true"] { border-color: var(--sage); color: var(--sage); }

.sd-row {
  width: 100%; display: flex; align-items: center; gap: 12px;
  margin-bottom: 6px; padding: 11px 14px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--text);
  text-align: left; font: inherit; cursor: pointer;
  transition: border-color 0.15s, opacity 0.15s, transform 0.08s;
}
.sd-row:hover { border-color: var(--line-strong); }
.sd-row:active { transform: scale(0.985); }
.sd-row.cant { opacity: 0.5; }
.sd-row.owned { opacity: 0.6; cursor: default; }
.sd-row.locked { opacity: 0.35; cursor: default; }
.sd-row.nope { animation: sd-nope 0.3s; }
.sd-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.sd-row-name { font-weight: 600; font-size: 15px; line-height: 1.3; }
.sd-row-desc { font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.sd-row-meta { font: 500 12px/1.5 var(--mono); color: var(--sage); margin-top: 2px; }
.sd-row-owned { flex: none; font: 600 22px/1 var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; }

.sd-empty, .sd-held { color: var(--muted); font-size: 13px; padding: 12px 4px; }
.sd-nova-btn {
  width: 100%; padding: 14px; margin: 4px 0 2px;
  border: 1px solid var(--sage); border-radius: 12px;
  background: rgba(143, 179, 154, 0.12); color: var(--sage-hi);
  font: 600 14px/1.35 var(--font); cursor: pointer;
}
.sd-nova-btn.cant { border-color: var(--line); background: transparent; color: var(--muted); cursor: default; }
.sd-nova-btn.nope { animation: sd-nope 0.3s; }

@keyframes sd-nope {
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* desktop: the shop is a side panel */
@media (min-width: 900px) {
  .sd-panel, .sd-panel[data-open="true"] {
    left: auto; top: 0; width: 400px; height: 100%;
    border-top: 0; border-left: 1px solid var(--line-strong); border-radius: 0;
    padding-top: 16px;
  }
  .sd-handle { display: none; }
  .sd-top { right: 400px; }
}

/* ---------- menu ---------- */
.sd-menu {
  width: min(460px, calc(100% - 32px)); max-height: calc(100% - 48px);
  padding: 0; border: 1px solid var(--line-strong); border-radius: 16px;
  background: var(--surface); color: var(--text);
  user-select: text; -webkit-user-select: text;
}
.sd-menu::backdrop { background: rgba(2, 4, 3, 0.7); }
.sd-menu-inner { padding: 18px 20px 22px; }
.sd-menu-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.sd-menu h2 { font-size: 20px; letter-spacing: -0.01em; }
.sd-menu h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.14em; color: var(--muted); margin: 20px 0 8px; font-weight: 600; }
.sd-close { width: 36px; height: 36px; border: 0; background: transparent; color: var(--muted); font-size: 24px; cursor: pointer; }
.sd-close:hover { color: var(--text); }
.sd-note { font-size: 13px; color: var(--muted); line-height: 1.5; }
.sd-muted { color: var(--muted); letter-spacing: 0; text-transform: none; font-weight: 400; }
.sd-msg { font-size: 13px; color: var(--sage); min-height: 1.2em; margin-top: 6px; }
.sd-form { display: grid; gap: 10px; }
.sd-form[hidden] { display: none; }
.sd-form label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.sd-form input {
  padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--bg); color: var(--text); font: 400 16px/1.3 var(--font);
}
.sd-form input:focus { outline: none; border-color: var(--sage); }
.sd-form-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.sd-form-btns button {
  padding: 9px 16px; border: 1px solid var(--sage); border-radius: 999px;
  background: var(--sage); color: var(--bg); font: 600 14px/1 var(--font); cursor: pointer;
}
.sd-form-btns button.ghost { background: transparent; color: var(--sage); }
#sd-signed-in p { font-size: 14px; }

.sd-stats { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; margin: 0; font-size: 13.5px; }
.sd-stats dt { color: var(--muted); }
.sd-stats dd { margin: 0; font-family: var(--mono); text-align: right; }

.sd-ach { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 6px; }
.sd-ach li { padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; opacity: 0.45; display: grid; gap: 2px; }
.sd-ach li.got { opacity: 1; border-color: var(--line-strong); }
.sd-ach strong { font-size: 13px; }
.sd-ach span { font-size: 11.5px; color: var(--muted); line-height: 1.35; }
.sd-foot { margin-top: 20px; }

/* ---------- toasts ---------- */
/* just above the drawer (bottom of the screen on desktop), clear of the star */
.sd-toasts {
  position: fixed; z-index: 4; left: 50%; bottom: calc(42% + 10px);
  transform: translateX(-50%); width: min(360px, calc(100% - 32px));
  display: flex; flex-direction: column; justify-content: flex-end; gap: 6px; pointer-events: none;
}
@media (min-width: 900px) { .sd-toasts { left: calc(50% - 200px); bottom: 24px; } }
.sd-toast {
  padding: 7px 12px; border: 1px solid var(--line-strong); border-radius: 10px;
  background: rgba(8, 16, 11, 0.95);
  font-size: 13px; line-height: 1.4; color: var(--text);
  animation: sd-in 0.3s var(--ease);
  transition: opacity 0.5s, transform 0.5s;
}
.sd-toast strong { color: var(--sage-hi); font-weight: 600; margin-right: 6px; }
.sd-toast.out { opacity: 0; transform: translateY(6px); }
@keyframes sd-in { from { opacity: 0; transform: translateY(8px); } }

.sd-noscript { position: fixed; inset: 40% 16px auto; text-align: center; color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  .sd-panel, .sd-row, .sd-toast { transition: none; }
  .sd-row.nope, .sd-nova-btn.nope, .sd-toast { animation: none; }
}
