/* StickerGo — base layer: reset, design tokens, typography, primitives.
 * Street / slap aesthetic: dark asphalt base, acid accent, condensed headlines,
 * cards that sit on the page like slapped-on paper.
 * Everything here is a token or a primitive. Layout lives in shell.css.
 */

/* ---------------------------------------------------------------- reset -- */

*, *::before, *::after { box-sizing: border-box; }
html, body, h1, h2, h3, h4, p, figure, blockquote, dl, dd, ul, ol { margin: 0; padding: 0; }
ul[class], ol[class] { list-style: none; }
img, svg, video, canvas { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--acid); outline-offset: 2px; border-radius: 2px; }
:focus:not(:focus-visible) { outline: none; }

/* --------------------------------------------------------------- tokens -- */

:root {
  color-scheme: dark;

  /* asphalt */
  --bg:        #0a0a0c;
  --bg-2:      #131318;
  --bg-3:      #1c1c24;
  --bg-4:      #262630;
  --line:      #32323e;
  --line-soft: #23232c;
  --mark:      #6b6b7c;   /* big decorative glyphs; >=3:1 on --bg */

  /* ink */
  --ink:       #f5f2ea;
  --ink-dim:   #b3aea4;
  --ink-faint: #8b867c;   /* >=4.5:1 on --bg and on the tab bar */

  /* paper (sticker surfaces) */
  --paper:     #eee7d8;
  --paper-2:   #ded5c1;
  --paper-ink: #16141a;

  /* accents */
  --acid:      #d6ff2b;   /* primary — hazard yellow-green, screams in the dark */
  --acid-deep: #a8cc00;
  --hot:       #ff2e63;   /* secondary — spray pink */
  --cyan:      #2fe3d6;
  --ok:        #4fd48a;
  --warn:      #ffb02e;
  --danger:    #ff5540;

  /* rarity R1..R5 */
  --r1: #b6b1a6;
  --r2: #59d7a0;
  --r3: #56aaff;
  --r4: #c479ff;
  --r5: #ffd23a;

  /* type */
  --font-display: "Archivo Black", "Anton", "Haettenschweiler", Impact,
                  "Franklin Gothic Heavy", "Arial Narrow", system-ui, sans-serif;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-md: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.5rem;
  --fs-2xl: 2rem;
  --fs-3xl: 2.75rem;

  /* rhythm */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;

  --radius: 4px;
  --radius-lg: 10px;

  /* one-handed, in the dark, at a lamppost */
  --tap: 56px;        /* comfortable primary controls */
  --tap-min: 44px;    /* hard floor for anything tappable */
  --tab-h: 68px;
  --header-h: 56px;

  --shadow-hard: 4px 4px 0 rgba(0, 0, 0, 0.62);
  --shadow-soft: 0 8px 26px rgba(0, 0, 0, 0.55);

  --tilt-a: -1.1deg;
  --tilt-b: 0.9deg;
  --tilt-c: -0.5deg;

  --dur: 180ms;
  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);

  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);

  /* pure-CSS paper grain (inline SVG turbulence, no network) */
  --grain: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ----------------------------------------------------------------- body -- */

html { -webkit-text-size-adjust: 100%; }

body {
  min-height: 100dvh;
  margin: 0;
  background-color: var(--bg);
  background-image:
    radial-gradient(120% 80% at 50% -20%, rgba(214, 255, 43, 0.07), transparent 60%),
    repeating-linear-gradient(115deg, rgba(255, 255, 255, 0.017) 0 2px, transparent 2px 7px);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--fs-md);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: rgba(214, 255, 43, 0.18);
}

body::before {   /* asphalt grain over the whole app */
  content: "";
  position: fixed;
  inset: 0;
  background-image: var(--grain);
  opacity: 0.05;
  pointer-events: none;
  z-index: 1;
  mix-blend-mode: screen;
}

/* ----------------------------------------------------------- typography -- */

.display, h1, h2 {
  font-family: var(--font-display);
  font-weight: 900;
  font-stretch: 82%;
  letter-spacing: 0.01em;
  line-height: 0.94;
  text-transform: uppercase;
}
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); font-weight: 800; letter-spacing: -0.01em; }

.eyebrow {
  font-family: var(--font-display);
  font-stretch: 82%;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: var(--fs-xs);
  color: var(--ink-faint);
}
.muted { color: var(--ink-dim); }
.faint { color: var(--ink-faint); }
.mono { font-family: var(--font-mono); font-size: var(--fs-sm); }
.num { font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stack > * + * { margin-top: var(--sp-3); }
.row { display: flex; align-items: center; gap: var(--sp-2); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.center { text-align: center; }
.hidden { display: none !important; }

.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;
}

/* -------------------------------------------------------------- buttons -- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: var(--tap);
  padding: 0 var(--sp-5);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--bg-3);
  color: var(--ink);
  font-family: var(--font-display);
  font-stretch: 82%;
  font-size: var(--fs-md);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-decoration: none;
  box-shadow: var(--shadow-hard);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
              background-color var(--dur) var(--ease);
}
.btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.62); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.45; pointer-events: none; }

.btn-primary { background: var(--acid); color: #10130a; border-color: #10130a; }
.btn-hot     { background: var(--hot); color: #fff; border-color: #2a0410; }
.btn-ghost   { background: transparent; border-color: var(--line); color: var(--ink-dim);
               box-shadow: none; }
.btn-ghost:active { transform: none; }
.btn-sm { min-height: 44px; padding: 0 var(--sp-3); font-size: var(--fs-sm); box-shadow: 2px 2px 0 rgba(0,0,0,.5); }
.btn-block { display: flex; width: 100%; }
.btn-icon { min-width: var(--tap); padding: 0 var(--sp-3); }

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

.input, .select, .textarea {
  width: 100%;
  min-height: var(--tap);
  padding: var(--sp-3);
  background: var(--bg-2);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
}
.input::placeholder { color: var(--ink-faint); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--acid); outline: none; }

.switch { display: inline-flex; align-items: center; gap: var(--sp-3); min-height: var(--tap); }

/* ---------------------------------------------------------------- cards -- */
/* A card is a slapped-on sticker: paper, hard shadow, a hair off-axis. */

.card {
  position: relative;
  background: var(--bg-2);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hard);
  padding: var(--sp-4);
  transform: rotate(var(--tilt-c));
  transition: transform var(--dur) var(--ease);
}
.card + .card { margin-top: var(--sp-4); }
.card:nth-of-type(odd)  { transform: rotate(var(--tilt-a)); }
.card:nth-of-type(even) { transform: rotate(var(--tilt-b)); }
.card-flat { transform: none !important; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); }
.card-body { margin-top: var(--sp-3); }
.card-foot { margin-top: var(--sp-3); padding-top: var(--sp-3); border-top: 1px dashed var(--line); }

.card-paper {
  background: var(--paper);
  color: var(--paper-ink);
  border-color: #0000;
}
.card-paper::before {  /* fibre grain on the paper */
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--grain);
  opacity: 0.09;
  pointer-events: none;
  border-radius: inherit;
}
.card-paper .muted { color: #4a463f; }

/* torn bottom edge — scalloped mask, no images */
.torn::after {
  content: "";
  position: absolute;
  left: -2px; right: -2px; bottom: -7px;
  height: 9px;
  background: inherit;
  -webkit-mask-image: radial-gradient(circle at 7px 0, transparent 5.5px, #000 6px);
  mask-image: radial-gradient(circle at 7px 0, transparent 5.5px, #000 6px);
  -webkit-mask-size: 14px 9px;
  mask-size: 14px 9px;
  -webkit-mask-repeat: repeat-x;
  mask-repeat: repeat-x;
}

/* a strip of tape across the top corner */
.taped::before {
  content: "";
  position: absolute;
  top: -9px; left: 18px;
  width: 62px; height: 20px;
  background: rgba(240, 236, 220, 0.22);
  border-left: 1px dashed rgba(255, 255, 255, 0.25);
  border-right: 1px dashed rgba(255, 255, 255, 0.25);
  transform: rotate(-4deg);
  pointer-events: none;
}

/* ---------------------------------------------------------------- chips -- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border: 2px solid currentColor;
  border-radius: 999px;
  font-family: var(--font-display);
  font-stretch: 82%;
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-dim);
  white-space: nowrap;
}
.chip-solid { border-color: transparent; background: var(--bg-4); color: var(--ink); }
.chip-acid  { background: var(--acid); color: #10130a; border-color: transparent; }
.chip-hot   { background: var(--hot); color: #fff; border-color: transparent; }
.chip-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

.rarity-1 { color: var(--r1); }
.rarity-2 { color: var(--r2); }
.rarity-3 { color: var(--r3); }
.rarity-4 { color: var(--r4); }
.rarity-5 { color: var(--r5); }
.chip.rarity-5 { box-shadow: 0 0 0 1px rgba(255, 210, 58, 0.35), 0 0 14px rgba(255, 210, 58, 0.25); }

/* ------------------------------------------------------------- skeleton -- */

.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--bg-3);
  border-radius: var(--radius);
  min-height: 14px;
}
.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.07), transparent);
  animation: sg-shimmer 1.25s infinite;
}
@keyframes sg-shimmer { to { transform: translateX(100%); } }
.skeleton-card { height: 104px; margin-bottom: var(--sp-4); }

/* ------------------------------------------------------------- progress -- */

.progress {
  position: relative;
  height: 10px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: var(--bg-3);
  overflow: hidden;
}
.progress > i {
  display: block;
  height: 100%;
  width: 0%;
  background: repeating-linear-gradient(115deg, var(--acid) 0 10px, var(--acid-deep) 10px 20px);
  transition: width 320ms var(--ease);
}
.progress-indeterminate > i {
  width: 38% !important;
  animation: sg-slide 1.15s ease-in-out infinite alternate;
}
@keyframes sg-slide { from { margin-left: -4%; } to { margin-left: 66%; } }

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

.empty {
  padding: var(--sp-6) var(--sp-4);
  text-align: center;
  border: 2px dashed var(--line);
  border-radius: var(--radius-lg);
  color: var(--ink-dim);
}
.empty h3 { color: var(--ink); margin-bottom: var(--sp-2); }
.empty .btn { margin-top: var(--sp-4); }
.empty-mark {
  font-family: var(--font-display);
  font-size: var(--fs-3xl);
  color: var(--mark);
  line-height: 1;
  margin-bottom: var(--sp-3);
}

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

#sg-toasts {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tab-h) + var(--safe-b) + var(--sp-3));
  transform: translateX(-50%);
  z-index: 90;
  width: min(560px, calc(100vw - 24px));
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  min-height: 48px;
  background: var(--bg-3);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hard);
  font-size: var(--fs-sm);
  animation: sg-pop 200ms var(--ease);
}
.toast-ok    { border-color: var(--ok);     }
.toast-error { border-color: var(--danger); }
.toast-warn  { border-color: var(--warn);   }
.toast-info  { border-color: var(--acid);   }
.toast-bar { width: 4px; align-self: stretch; border-radius: 2px; background: currentColor; }
.toast.leaving { animation: sg-out 180ms var(--ease) forwards; }
@keyframes sg-pop { from { transform: translateY(14px) scale(0.97); opacity: 0; } }
@keyframes sg-out { to { transform: translateY(10px); opacity: 0; } }

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

.sheet-scrim {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: sg-fade 160ms var(--ease);
}
.sheet {
  width: min(620px, 100%);
  max-height: 88dvh;
  overflow: auto;
  padding: var(--sp-4);
  padding-bottom: calc(var(--sp-5) + var(--safe-b));
  background: var(--bg-2);
  border: 2px solid var(--line);
  border-bottom: 0;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  animation: sg-up 220ms var(--ease);
}
.sheet-grab {
  width: 46px; height: 5px; border-radius: 3px;
  background: var(--line); margin: 0 auto var(--sp-4);
}
@keyframes sg-fade { from { opacity: 0; } }
@keyframes sg-up { from { transform: translateY(24px); } }

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

.divider { height: 2px; background: repeating-linear-gradient(90deg, var(--line) 0 8px, transparent 8px 14px); }

.thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: var(--bg-3);
  border-radius: var(--radius);
}
.thumb-fallback {
  display: grid;
  place-items: center;
  color: var(--ink-faint);
  font-family: var(--font-display);
  font-size: var(--fs-xl);
}

.color-dots { display: inline-flex; gap: 3px; }
.color-dot { width: 12px; height: 12px; border-radius: 50%; border: 1px solid rgba(0,0,0,.5); }

/* ---------------------------------------------------- reduced motion / a11y */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .card, .card:nth-of-type(odd), .card:nth-of-type(even) { transform: none; }
  .taped::before { transform: none; }
}

@media (prefers-contrast: more) {
  :root { --ink-dim: #ddd8ce; --ink-faint: #b6b1a6; --line: #56566a; --mark: #8f8fa2; }
}
