/* Buttons, cards, rows, meters, sheets, toasts. */

/* ---------------------------------------------------------------- button -- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: 46px;
  padding: 0 var(--s-5);
  border-radius: var(--r-md);
  font-weight: 700;
  letter-spacing: 0.005em;
  border: 1px solid transparent;
  transition:
    transform var(--dur-fast) var(--ease),
    background var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease);
}

.btn:active:not(:disabled) { transform: scale(0.975); }
.btn--full { width: 100%; }

.btn--sm {
  min-height: 34px;
  padding: 0 var(--s-3);
  font-size: var(--fs-sm);
  border-radius: var(--r-sm);
}

.btn--primary {
  background: linear-gradient(180deg, var(--gold-400), var(--gold-600));
  color: var(--on-accent);
  box-shadow: var(--shadow-sm);
}

.btn--primary:hover:not(:disabled) {
  background: linear-gradient(180deg, var(--gold-300), var(--gold-500));
}

.btn--ghost {
  background: var(--ink-700);
  border-color: var(--border);
  color: var(--bone-100);
}

.btn--ghost:hover:not(:disabled) { background: var(--ink-600); }

.btn--danger {
  background: transparent;
  border-color: rgba(224, 72, 60, 0.5);
  color: var(--alert-500);
}

.btn--danger:hover:not(:disabled) { background: rgba(224, 72, 60, 0.12); }

.btn:disabled {
  opacity: 0.45;
  box-shadow: none;
}

/* ------------------------------------------------------------------ pill -- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.pill--neutral,
.pill--muted {
  background: var(--ink-600);
  color: var(--bone-300);
  border: 1px solid var(--border);
}

.pill--gold {
  background: var(--accent-soft);
  color: var(--gold-400);
  border: 1px solid rgba(245, 182, 60, 0.32);
}

.pill--good {
  background: rgba(79, 191, 123, 0.15);
  color: var(--turf-500);
  border: 1px solid rgba(79, 191, 123, 0.32);
}

.pill--danger {
  background: rgba(224, 72, 60, 0.15);
  color: var(--alert-500);
  border: 1px solid rgba(224, 72, 60, 0.32);
}

/* -------------------------------------------------------- section header -- */

.section-header {
  display: flex;
  align-items: baseline;
  gap: var(--s-3);
  flex-wrap: wrap;
  padding-top: var(--s-2);
}

.section-header__title {
  font-size: var(--fs-lg);
  font-weight: 800;
  letter-spacing: -0.01em;
}

.section-header__hint {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin-right: auto;
}

.section-header .btn { margin-left: auto; }

/* ------------------------------------------------------------------ card -- */

.card {
  display: grid;
  grid-template-rows: auto 1fr;
  text-align: left;
  border-radius: var(--r-lg);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  overflow: hidden;
  color: inherit;
  transition: transform var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

button.card:hover { border-color: var(--border-strong); }
button.card:active { transform: scale(0.99); }

.card--feature {
  border-color: rgba(245, 182, 60, 0.28);
  box-shadow: var(--shadow-md);
}

.card--daily { border-color: rgba(155, 123, 245, 0.26); }
.card--reward { border-color: rgba(245, 182, 60, 0.4); }
.card--equipped { border-color: rgba(245, 182, 60, 0.45); }

.card--locked { opacity: 0.62; }

.card--badge .card__media { aspect-ratio: 1; }
.card--badge.is-selected {
  border-color: var(--gold-500);
  box-shadow: var(--glow-gold);
}

.card--pattern .card__media { aspect-ratio: 3 / 2; }
.card--pattern .card__title { font-size: var(--fs-sm); }

.card__media {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--ink-800);
  overflow: hidden;
}

.card__media > .art {
  width: 100%;
  height: 100%;
}

.card__lock {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(5, 7, 12, 0.6);
  color: var(--gold-400);
  backdrop-filter: blur(2px);
}

.card__badge {
  position: absolute;
  top: var(--s-2);
  right: var(--s-2);
  padding: 4px 10px;
  border-radius: var(--r-pill);
  background: rgba(5, 7, 12, 0.8);
  border: 1px solid var(--border-strong);
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--gold-400);
}

.card__body {
  display: grid;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-4) var(--s-4);
  align-content: start;
}

.card__title {
  font-size: var(--fs-md);
  font-weight: 700;
  line-height: 1.25;
}

.card__subtitle {
  font-size: var(--fs-sm);
  line-height: 1.55;
  color: var(--text-muted);
}

.card__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2);
}

.card__meta-item {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.card__footer { padding-top: var(--s-1); }

.card__cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--gold-400);
}

/* ------------------------------------------------------------------- row -- */

.row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  text-align: left;
  color: inherit;
  transition: background var(--dur-fast) var(--ease);
}

button.row:hover:not(:disabled) { background: var(--ink-600); }
button.row:active:not(:disabled) { transform: scale(0.995); }
.row:disabled { opacity: 0.55; }

.row--done { border-color: rgba(79, 191, 123, 0.28); }
.row--locked { opacity: 0.6; }

.row__leading {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: var(--r-sm);
  background: var(--ink-600);
  color: var(--gold-400);
}

.row__body {
  display: grid;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.row__title {
  font-size: var(--fs-md);
  font-weight: 650;
}

.row__subtitle {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  line-height: 1.5;
}

.row__trailing {
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--s-2);
  color: var(--text-muted);
}

.row__score {
  font-family: var(--font-numeric);
  font-weight: 700;
  color: var(--gold-400);
}

.row__trailing .meter { width: 72px; }

.level-index {
  font-family: var(--font-numeric);
  font-weight: 700;
  color: var(--gold-400);
}

/* ------------------------------------------------------------------ stat -- */

.stat {
  display: grid;
  gap: 2px;
  padding: var(--s-3);
  border-radius: var(--r-md);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  min-width: 0;
}

.stat--wide { grid-column: span 2; }

.stat__label {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.stat__value {
  font-size: var(--fs-lg);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat__hint {
  font-size: var(--fs-xs);
  color: var(--slate-500);
}

/* ----------------------------------------------------------------- meter -- */

.meter {
  height: 7px;
  border-radius: var(--r-pill);
  background: var(--ink-600);
  overflow: hidden;
}

.meter__fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold-600), var(--gold-400));
  transition: width var(--dur-slow) var(--ease-out);
}

.meter--good .meter__fill {
  background: linear-gradient(90deg, var(--turf-700), var(--turf-500));
}

.meter-row { display: grid; gap: 6px; }

.meter-row__head {
  display: flex;
  justify-content: space-between;
  gap: var(--s-3);
  font-size: var(--fs-xs);
}

.meter-row__label { color: var(--text-muted); }
.meter-row__value { font-variant-numeric: tabular-nums; color: var(--bone-300); }

/* ----------------------------------------------------------------- stars -- */

.stars {
  display: inline-flex;
  gap: 2px;
  align-items: center;
}

.star--on { color: var(--gold-500); }
.star--off { color: var(--ink-400); }

/* ----------------------------------------------------------------- empty -- */

.empty {
  display: grid;
  justify-items: center;
  gap: var(--s-3);
  padding: var(--s-6) var(--s-4);
  text-align: center;
  border-radius: var(--r-lg);
  background: var(--bg-raised);
  border: 1px dashed var(--border-strong);
}

.empty__art {
  width: min(100%, 300px);
  border-radius: var(--r-md);
  overflow: hidden;
  opacity: 0.75;
}

.empty__icon { color: var(--gold-500); }

.empty__title {
  font-size: var(--fs-lg);
  font-weight: 750;
}

.empty__body {
  max-width: 44ch;
  font-size: var(--fs-sm);
  line-height: 1.6;
  color: var(--text-muted);
}

.empty--error { border-color: rgba(224, 72, 60, 0.4); }

.loading {
  display: grid;
  justify-items: center;
  gap: var(--s-3);
  padding: var(--s-7) 0;
}

.loading__ring {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid var(--ink-500);
  border-top-color: var(--gold-500);
  animation: spin 900ms linear infinite;
}

.loading__label {
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- inputs -- */

.switch {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  cursor: pointer;
}

.switch__text { display: grid; gap: 3px; flex: 1; min-width: 0; }
.switch__label { font-size: var(--fs-md); font-weight: 600; }
.switch__hint { font-size: var(--fs-xs); color: var(--text-muted); line-height: 1.5; }

.switch__input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch__track {
  flex: none;
  position: relative;
  width: 48px;
  height: 28px;
  border-radius: var(--r-pill);
  background: var(--ink-500);
  border: 1px solid var(--border);
  transition: background var(--dur) var(--ease);
}

.switch__thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--slate-400);
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease);
}

.switch__input:checked ~ .switch__track {
  background: var(--gold-600);
}

.switch__input:checked ~ .switch__track .switch__thumb {
  transform: translateX(20px);
  background: var(--ink-900);
}

.switch__input:focus-visible ~ .switch__track {
  outline: 2px solid var(--gold-400);
  outline-offset: 2px;
}

.slider {
  display: grid;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  background: var(--bg-raised);
  border: 1px solid var(--border);
}

.slider__head {
  display: flex;
  justify-content: space-between;
  gap: var(--s-3);
}

.slider__label { font-size: var(--fs-sm); font-weight: 600; }

.slider__value {
  font-family: var(--font-numeric);
  font-size: var(--fs-sm);
  color: var(--gold-400);
}

.slider__input {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 26px;
  background: transparent;
}

.slider__input::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--ink-500);
}

.slider__input::-moz-range-track {
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--ink-500);
}

.slider__input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  margin-top: -8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--gold-500);
  border: 2px solid var(--ink-900);
}

.slider__input::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border: 2px solid var(--ink-900);
  border-radius: 50%;
  background: var(--gold-500);
}

.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 3px;
  padding: 3px;
  border-radius: var(--r-md);
  background: var(--ink-700);
  border: 1px solid var(--border);
  overflow-x: auto;
}

.segmented__item {
  padding: 9px var(--s-2);
  border-radius: calc(var(--r-md) - 4px);
  font-size: var(--fs-sm);
  font-weight: 650;
  color: var(--text-muted);
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}

.segmented__item.is-active {
  background: var(--ink-500);
  color: var(--gold-400);
}

.field {
  display: grid;
  gap: 6px;
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  background: var(--bg-raised);
  border: 1px solid var(--border);
}

.field__label {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.field__input {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--ink-900);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: var(--fs-md);
}

.field__input:focus {
  outline: none;
  border-color: var(--gold-600);
}

.field__hint { font-size: var(--fs-xs); color: var(--slate-500); }

/* ---------------------------------------------------------------- sheets -- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  align-items: end;
  justify-items: center;
  padding: var(--s-4);
  padding-bottom: calc(var(--safe-bottom) + var(--s-4));
  background: rgba(5, 7, 12, 0.72);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
}

.sheet-backdrop.is-open { opacity: 1; }
.sheet-backdrop.is-closing { opacity: 0; }

@media (min-width: 620px) {
  .sheet-backdrop { align-items: center; }
}

.sheet {
  width: min(100%, 520px);
  max-height: min(86dvh, 720px);
  display: grid;
  grid-template-rows: auto 1fr auto;
  border-radius: var(--r-xl);
  background: var(--ink-800);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  transform: translateY(18px);
  transition: transform var(--dur) var(--ease-out);
  overflow: hidden;
}

.sheet-backdrop.is-open .sheet { transform: none; }

.sheet--danger { border-color: rgba(224, 72, 60, 0.45); }
.sheet--play { border-color: rgba(245, 182, 60, 0.35); }

.sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-4) var(--s-3);
  border-bottom: 1px solid var(--border);
}

.sheet__title { font-size: var(--fs-lg); font-weight: 750; }

.sheet__body {
  padding: var(--s-4);
  overflow-y: auto;
  display: grid;
  gap: var(--s-3);
}

.sheet__actions {
  display: grid;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-4) var(--s-4);
  border-top: 1px solid var(--border);
}

/* ---------------------------------------------------------------- toasts -- */

.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + var(--s-3));
  transform: translateX(-50%);
  z-index: 140;
  display: grid;
  gap: var(--s-2);
  width: min(92vw, 420px);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: 11px var(--s-4);
  border-radius: var(--r-pill);
  background: var(--ink-700);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-md);
  font-size: var(--fs-sm);
  font-weight: 600;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.toast.is-open { opacity: 1; transform: none; }
.toast--good { border-color: rgba(79, 191, 123, 0.45); color: var(--turf-500); }

/* ----------------------------------------------------------------- misc --- */

.credits {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  color: var(--gold-400);
}

.credits--sm { font-size: var(--fs-sm); }

.price {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--gold-400);
}

.price--short { color: var(--slate-500); }

.kv {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--s-2) var(--s-4);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  font-size: var(--fs-sm);
}

.kv__key { color: var(--text-muted); }

.kv__value {
  margin: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.divider {
  height: 1px;
  background: var(--border);
}

.divider--labelled {
  display: grid;
  place-items: center;
  height: auto;
  background: none;
  font-size: var(--fs-xs);
  color: var(--slate-500);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
