/* Ooshie Swap component layer — built on tokens.css + vendor/open-props.min.css */

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--ink);
  background: linear-gradient(160deg, var(--bg-start), var(--bg-end));
  background-attachment: fixed;
}

.app-body {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem 3rem;
}

a {
  color: inherit;
}

h1 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.01em;
  margin: 1.75rem 0 1rem;
}

button {
  font-family: var(--font-body);
  cursor: pointer;
}

:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 2px;
}

/* ---------- header / shell ---------- */

.app-header {
  position: relative;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 1.25rem 1rem;
  overflow: hidden;
  isolation: isolate;
}

.wordmark {
  position: relative;
  z-index: 1;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.5rem;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}

.wordmark span {
  color: var(--accent);
}

.app-nav {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.nav-pill {
  display: inline-block;
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 1px solid var(--surface-border);
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
}

.nav-pill:hover {
  background: var(--surface-border);
}

.theme-toggle {
  position: relative;
  z-index: 1;
  margin-left: auto;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--surface-border);
  background: var(--surface);
  color: var(--ink);
  font-size: 1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sparkles {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.sparkles span {
  position: absolute;
  color: var(--accent);
  opacity: 0.55;
  font-size: var(--size, 0.9rem);
  top: var(--top);
  left: var(--left);
  animation: sparkle-drift 6s ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}

@keyframes sparkle-drift {
  0%, 100% { transform: translateY(0) scale(1); opacity: 0.35; }
  50% { transform: translateY(-6px) scale(1.15); opacity: 0.8; }
}

@media (prefers-reduced-motion: reduce) {
  .sparkles span {
    animation: none;
    opacity: 0.5;
  }
}

/* ---------- collection grid ---------- */

.collection-grid {
  display: flex;
  flex-wrap: wrap;
  width: 100%;
  gap: 1rem;
}

.character-row {
  box-sizing: border-box;
  min-width: 0;
  flex: 0 1 calc((100% - 9 * 1rem) / 10);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.5rem;
}

@media (max-width: 900px) {
  .character-row { flex-basis: calc((100% - 4 * 1rem) / 5); }
}

@media (max-width: 480px) {
  .character-row { flex-basis: calc((100% - 1 * 1rem) / 2); }
}

.thumb {
  position: relative;
  width: 100%;
  max-width: 96px;
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--surface-border);
  box-shadow: inset 0 1px 3px rgb(0 0 0 / 25%);
  padding: 0.35rem;
  overflow: hidden;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: grayscale(0.65) brightness(0.8);
  transition: filter 0.2s ease;
}

.character-row[data-owned="true"] .thumb img {
  filter: none;
}

.thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 30%, rgb(255 255 255 / 55%) 45%, transparent 60%);
  transform: translateX(-120%);
  transition: transform 0.6s ease;
}

.character-row:hover .thumb::after,
.character-row:focus-within .thumb::after {
  transform: translateX(120%);
}

@media (prefers-reduced-motion: reduce) {
  .thumb::after { transition: none; }
}

.owned-badge {
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.7rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.4);
}

.character-row[data-owned="true"] .owned-badge {
  opacity: 1;
  transform: scale(1);
}

.character-row.is-fresh .owned-badge {
  animation: badge-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.character-row.is-fresh .thumb::after {
  animation: unwrap-sheen 0.7s ease both;
}

@keyframes badge-pop {
  0% { transform: scale(0.2); opacity: 0; }
  60% { transform: scale(1.25); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes unwrap-sheen {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(120%); }
}

@media (prefers-reduced-motion: reduce) {
  .character-row.is-fresh .owned-badge,
  .character-row.is-fresh .thumb::after {
    animation: none;
  }
}

.character-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
  min-width: 0;
}

.name-tag {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.5em;
  max-width: 100%;
  padding: 0.15rem 0.7rem;
  border-radius: 14px;
  background: var(--tag);
  color: var(--tag-ink);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.15;
  overflow-wrap: break-word;
}

.counter {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.counter button {
  width: 1.6rem;
  height: 1.6rem;
  border-radius: var(--radius-pill);
  border: none;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
  font-size: 0.95rem;
  line-height: 1;
}

.counter button:hover {
  filter: brightness(1.08);
}

.counter .count {
  min-width: 1.4rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

/* ---------- discover / chat / auth (shared shell) ---------- */

.match-row,
#signup-area,
form {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  margin-bottom: 1rem;
}

.match-row form,
#signup-area form {
  background: none;
  border: none;
  padding: 0;
  margin: 0.5rem 0 0;
}

input {
  font-family: var(--font-body);
  padding: 0.5rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--surface-border);
  background: rgb(255 255 255 / 90%);
  color: #171a33;
  margin-right: 0.4rem;
}

form button[type="submit"] {
  padding: 0.5rem 1rem;
  border-radius: var(--radius-pill);
  border: none;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}

.message {
  padding: 0.5rem 0.75rem;
  margin: 0.35rem 0;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--surface-border);
  max-width: 70%;
}
