/* ---------------------------------------------------------------
   Profile page — extends style.css's tokens (--ink, --gold, etc.)
   style.css sets html/body to overflow:hidden for the fixed canvas
   page; this page scrolls, so we undo that here.
---------------------------------------------------------------- */

.profile-body,
html:has(body.profile-body),
body.profile-body {
  height: auto;
  min-height: 100%;
  overflow: visible;
}

body.profile-body {
  overflow-y: auto;
}

.profile-body .topbar {
  position: sticky;
  top: 0;
}

.back-link {
  display: block;
  font-size: 0.66rem;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: 2px;
}

.back-link:hover { color: var(--gold); }

.profile-main {
  max-width: 880px;
  margin: 0 auto;
  padding: 96px 20px 64px;
}

/* ---------- signed-out ---------- */

.signed-out {
  text-align: center;
  padding: 60px 20px;
}

.signed-out h2 { margin: 10px 0 8px; }
.signed-out .btn { margin-top: 18px; display: inline-block; text-decoration: none; }

/* ---------- profile header ---------- */

.profile-card {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 28px;
}

.avatar {
  width: 64px;
  height: 64px;
  flex-shrink: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--ink);
  background: var(--gold);
}

.profile-id h2 { font-size: 1.3rem; }
.profile-id .fine { font-size: 0.62rem; margin-top: 2px; }

/* ---------- stats ---------- */

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 32px;
}

.stat {
  padding: 16px;
  text-align: center;
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.stat-value { font-size: 1.5rem; color: var(--gold); }
.stat-label { font-size: 0.62rem; color: var(--muted); margin-top: 4px; letter-spacing: 0.04em; }

/* ---------- panels ---------- */

.panel { margin-bottom: 36px; }

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.panel-title {
  font-size: 0.95rem;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.panel-head .panel-title { flex: 1; }

.empty-note { padding: 18px 0; font-size: 0.78rem; }

/* ---------- purchase history ---------- */

.history-list { display: flex; flex-direction: column; gap: 8px; }

.history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.history-date { font-size: 0.76rem; }
.history-amount { text-align: right; }
.history-amount .gold { color: var(--gold); font-size: 0.9rem; }
.fine { font-size: 0.64rem; }
.gold { color: var(--gold); }

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

.card-deck {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
}

.pcard {
  perspective: 700px;
  height: 224px;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
}

.pcard-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
  transform-style: preserve-3d;
}

.pcard.flipped .pcard-inner { transform: rotateY(180deg); }

.pcard-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--gold-dim);
  background: linear-gradient(160deg, var(--ink-2), #12161f);
  box-shadow: var(--shadow);
  backface-visibility: hidden;
}

.pcard-back {
  transform: rotateY(180deg);
  text-align: center;
  overflow-y: auto;
  gap: 3px;
}

.pcard-swatch {
  width: 64px;
  height: 64px;
  image-rendering: pixelated;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: repeating-conic-gradient(#20242f 0% 25%, #181c26 0% 50%) 50% / 12px 12px;
}

.pcard-swatch.loaded { border-color: var(--gold-dim); }

.pcard-serial { font-size: 0.62rem; color: var(--gold); letter-spacing: 0.04em; }
.pcard-coords { font-size: 0.68rem; color: var(--muted); }

.pcard-back-name {
  font-weight: 600;
  font-size: 0.95rem;
  overflow-wrap: anywhere;
  max-width: 100%;
}

.pcard-cert-btn {
  margin-top: 6px;
  padding: 6px 10px;
  font-size: 0.62rem;
}

.pcard-won .pcard-face { border-color: var(--gold); }

.pcard-ribbon {
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 1rem;
  filter: drop-shadow(0 0 3px rgba(217, 164, 65, 0.6));
}

.pcard-prize {
  margin-top: 6px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--gold-dim);
  background: rgba(217, 164, 65, 0.08);
  width: 100%;
  text-align: left;
}

.pcard-prize .op-title { color: var(--gold); font-weight: 600; font-size: 0.72rem; margin-bottom: 2px; }
.pcard-prize .op-detail { color: var(--muted); font-size: 0.62rem; }
.pcard-prize .op-redeem { margin-top: 4px; color: var(--paper); font-size: 0.62rem; }

.deck-more-wrap { text-align: center; margin-top: 18px; }

/* ---------- small screens / portrait ---------- */

@media (max-width: 640px) {
  .profile-main { padding: 88px 14px 48px; }
  .stat-row { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .stat { padding: 12px 8px; }
  .stat-value { font-size: 1.2rem; }
  .card-deck { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
  .pcard { height: 190px; }
  .pcard-swatch { width: 48px; height: 48px; }
}
