/* StickerGo - 3D spot view: splat stage, hotspots, strata slider, scan assistant.
   Only .sg-splat / .sg-stage / .sg-scan / .sg-hotspot* / .sg-strata* / .sg-ring* live
   here so this file cannot collide with the app shell stylesheet. Every colour goes
   through a var() with a fallback, so the module also renders standalone. */

.sg-splat {
  --splat-bg: var(--sg-bg, #0b0b0e);
  --splat-fg: var(--sg-fg, #f2f2f4);
  --splat-muted: var(--sg-muted, #9b9ba4);
  --splat-accent: var(--sg-accent, #ff3d5a);
  --splat-line: var(--sg-line, #26262e);
  --splat-card: var(--sg-card, #15151a);
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  color: var(--splat-fg);
  min-height: 100%;
}

.sg-splat__head { display: flex; flex-direction: column; gap: 0.15rem; }
.sg-splat__title { font-size: 1.35rem; font-weight: 800; letter-spacing: -0.02em; margin: 0; }
.sg-splat__sub { margin: 0; color: var(--splat-muted); font-size: 0.85rem; }
.sg-splat__body { display: flex; flex-direction: column; gap: 0.75rem; }
.sg-splat__error { background: var(--splat-card); border: 1px solid var(--splat-line); border-radius: 12px; padding: 1rem; }
.sg-splat__errdetail { color: var(--splat-muted); font-size: 0.8rem; word-break: break-word; }
.sg-note { color: var(--splat-muted); font-size: 0.8rem; margin: 0; }

/* --------------------------------------------------------------- stage --- */

.sg-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  max-height: 70vh;
  border-radius: 14px;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 50% 0%, #1b1b23 0%, #0b0b0e 70%);
  border: 1px solid var(--splat-line);
  touch-action: none;
  contain: paint;
}

@media (min-width: 720px) {
  .sg-stage { aspect-ratio: 16 / 10; max-height: 76vh; }
}

.sg-stage__canvas { display: block; width: 100%; height: 100%; }

.sg-stage__overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.sg-stage__progress {
  position: absolute;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.62);
  color: var(--splat-fg);
  font-size: 0.78rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  backdrop-filter: blur(6px);
}
.sg-stage__progress[hidden] { display: none; }

.sg-stage__tools { display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* ------------------------------------------------------------ hotspots --- */

.sg-hotspots { position: absolute; inset: 0; pointer-events: none; }

.sg-hotspot {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin: -14px 0 0 -14px;      /* centre the 28px dot on the anchor */
  padding: 0;
  border: 0;
  background: none;
  color: var(--splat-fg);
  font: inherit;
  cursor: pointer;
  pointer-events: auto;
  min-height: 44px;             /* thumb-sized hit area around the 28px dot */
  min-width: 44px;              /* label-less dots stay tappable too */
  transition: opacity 140ms linear, filter 140ms linear;
  will-change: transform;
}
.sg-hotspot.is-hidden { display: none; }
.sg-hotspot.is-occluded { opacity: 0.28; filter: saturate(0.4); pointer-events: none; }

.sg-hotspot__dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--splat-accent) center/cover no-repeat;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85), 0 2px 10px rgba(0, 0, 0, 0.6);
  flex: none;
}
.sg-hotspot.has-thumb .sg-hotspot__dot { background-color: #222; }

.sg-hotspot__label {
  display: none;
  max-width: 8rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.66);
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sg-hotspot.has-label .sg-hotspot__label { display: block; }
/* two anchors a few centimetres apart would print their names on top of each
   other -- the nearer label wins, the other stays reachable via its dot */
.sg-hotspot.is-crowded .sg-hotspot__label { display: none; }
.sg-hotspot[data-rarity="5"] .sg-hotspot__dot { box-shadow: 0 0 0 2px #ffd23f, 0 0 14px #ffd23f88; }
.sg-hotspot[data-rarity="4"] .sg-hotspot__dot { box-shadow: 0 0 0 2px #b388ff, 0 0 10px #b388ff66; }

/* -------------------------------------------------------------- strata --- */

.sg-strata {
  position: absolute;
  left: 0.75rem;
  right: 0.75rem;
  bottom: 0.75rem;
  padding: 0.5rem 0.7rem 0.35rem;
  border-radius: 12px;
  background: rgba(10, 10, 14, 0.72);
  backdrop-filter: blur(8px);
  border: 1px solid var(--splat-line);
  pointer-events: auto;
}
.sg-strata.is-single { display: none; }
.sg-strata__caption { font-size: 0.78rem; font-weight: 700; margin-bottom: 0.2rem; }
.sg-strata__range { width: 100%; min-height: 44px; accent-color: var(--splat-accent); }
.sg-strata__ticks {
  display: flex;
  justify-content: space-between;
  font-size: 0.66rem;
  color: var(--splat-muted);
}

/* ---------------------------------------------------------------- jobs --- */

.sg-jobs { display: flex; flex-direction: column; gap: 0.6rem; }
.sg-job {
  background: var(--splat-card);
  border: 1px solid var(--splat-line);
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
}
.sg-job__label { font-weight: 700; font-size: 0.9rem; }
.sg-job__bar { height: 6px; border-radius: 99px; background: #26262e; overflow: hidden; margin: 0.45rem 0 0.3rem; }
.sg-job__fill { height: 100%; width: 0; background: var(--splat-accent); transition: width 400ms ease; }
.sg-job__meta { font-size: 0.68rem; color: var(--splat-muted); font-family: ui-monospace, monospace; }
.sg-job.is-failed .sg-job__fill { background: #6b6b76; }

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

.sg-empty {
  background: var(--splat-card);
  border: 1px solid var(--splat-line);
  border-radius: 14px;
  padding: 1.4rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: flex-start;
}
.sg-empty__title { margin: 0; font-size: 1.05rem; font-weight: 800; }
.sg-empty__text { margin: 0; color: var(--splat-muted); font-size: 0.88rem; line-height: 1.45; }

.sg-btn {
  font: inherit;
  font-weight: 700;
  border-radius: 999px;
  min-height: 44px;
  padding: 0.55rem 1.1rem;
  border: 1px solid var(--splat-line);
  background: #1d1d24;
  color: var(--splat-fg);
  cursor: pointer;
}
.sg-btn--primary { background: var(--splat-accent); border-color: transparent; color: #fff; }
.sg-btn--ghost { background: transparent; font-size: 0.82rem; padding: 0.4rem 0.9rem; }
.sg-btn--ghost.is-on { border-color: var(--splat-accent); color: var(--splat-accent); }
.sg-btn:active { transform: translateY(1px); }

/* ------------------------------------------------------- scan assistant --- */

.sg-scan {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: #000;
  display: grid;
  overflow: hidden;
}
.sg-scan__video {
  grid-area: 1 / 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.sg-scan__hud {
  grid-area: 1 / 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 0.6rem;
  padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to top, rgba(0, 0, 0, 0.75) 0%, rgba(0, 0, 0, 0) 45%);
  color: #fff;
  text-align: center;
}
.sg-scan__hint { margin: 0; font-size: 0.9rem; font-weight: 600; text-shadow: 0 1px 4px #000; max-width: 22rem; }
.sg-scan__counter { font-size: 0.78rem; font-variant-numeric: tabular-nums; opacity: 0.85; }
.sg-scan__actions { display: flex; align-items: center; gap: 1rem; }
.sg-scan__shutter {
  width: 66px; height: 66px; border-radius: 50%;
  border: 4px solid #fff; background: rgba(255, 255, 255, 0.18);
  color: #fff; font-size: 0.7rem; font-weight: 700; cursor: pointer;
}
.sg-scan__done { opacity: 0.45; pointer-events: none; }
.sg-scan.is-ready .sg-scan__done { opacity: 1; pointer-events: auto; }
.sg-scan__close {
  position: absolute; top: calc(0.6rem + env(safe-area-inset-top, 0px)); right: 0.7rem;
  width: 40px; height: 40px; border-radius: 50%;
  border: 0; background: rgba(0, 0, 0, 0.5); color: #fff; font-size: 1.5rem; line-height: 1; cursor: pointer;
}

.sg-ring { width: min(58vw, 240px); aspect-ratio: 1; margin-bottom: auto; margin-top: 12vh; }
.sg-ring__seg { fill: none; stroke: rgba(255, 255, 255, 0.22); stroke-width: 6; stroke-linecap: round; }
.sg-ring__seg.is-on { stroke: var(--sg-accent, #ff3d5a); }
.sg-ring__needle {
  stroke: #fff; stroke-width: 2; stroke-linecap: round;
  transform-origin: 50% 50%; transform-box: view-box;
  opacity: 0.9;
}

@media (prefers-reduced-motion: reduce) {
  .sg-hotspot, .sg-job__fill { transition: none; }
}
