/* ─────────────────────────────────────────────────────────────────────────
   PIXIES — "Add to gallery" popover (with the exploding-face input) + the
   gallery page. Every class is namespaced (.pixie-* / .pg-*) and uses the
   site's existing tokens, so it can't collide with or change anything already
   on the site. Delete this file + its <link> tags to remove the styling.
   ───────────────────────────────────────────────────────────────────────── */

/* ===== maker stage buttons (View gallery / Add to gallery) ================
   They use the site's own .btn classes — this only handles the short labels
   used on narrow screens, so the buttons match Send / Contact me exactly. */
.pixie-btn__short { display: none; }
@media (max-width: 600px) {
  .pixie-btn__long { display: none; }
  .pixie-btn__short { display: inline; }
}

/* ===== Naming popover ====================================================== */
.pixie-pop {
  position: fixed; inset: 0; z-index: 13000;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.pixie-pop[hidden] { display: none; }
.pixie-pop__scrim {
  position: absolute; inset: 0;
  background: rgba(20, 20, 19, 0.42);
  backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
  opacity: 0; transition: opacity 220ms ease;
}
.pixie-pop.in .pixie-pop__scrim { opacity: 1; }

.pixie-pop__card {
  position: relative;
  width: min(360px, 100%);
  background: var(--canvas);
  border: 1px solid var(--hairline);       /* same hairline as the cards */
  border-radius: var(--r-lg, 12px);        /* unified container radius (matches cards) */
  padding: 24px 22px 20px;
  text-align: center;
  opacity: 0;
  transition: opacity 150ms ease;          /* simple fade — no slide-up */
}
.pixie-pop.in .pixie-pop__card { opacity: 1; }
/* instant swap (no animation) when replacing one popover with another */
.pixie-pop--instant .pixie-pop__scrim,
.pixie-pop--instant .pixie-pop__card { transition: none !important; }

.pixie-pop__close {
  position: absolute; top: 12px; right: 12px;
  width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: 8px; background: transparent; color: var(--slate);
  cursor: pointer; padding: 0;
  transition: color 160ms ease, background 160ms ease;
}
.pixie-pop__close:hover { color: var(--ink); background: var(--hover-grey); }
.pixie-pop__close svg { width: 16px; height: 16px; display: block; }

/* the just-built pixie as a small, subtle ID photo (head + shoulders) */
.pixie-pop__preview {
  width: 78px; height: 78px; margin: 0 auto 18px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--hairline);
  overflow: hidden;
}
.pixie-pop__preview img, .pixie-pop__preview svg {
  width: 100%; height: 100%;
  object-fit: cover; object-position: center 18%;
  image-rendering: pixelated; image-rendering: crisp-edges; display: block;
}
/* edit popover: a little restyle ("edit look") pencil on the corner of the face */
.pixie-pop__avatar { position: relative; width: 78px; margin: 0 auto 18px; }
.pixie-pop__avatar .pixie-pop__preview { margin: 0; }
.pixie-pop__restyle {
  position: absolute; right: -3px; bottom: -3px;
  width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; border: 2px solid var(--canvas);
  background: var(--ink); color: var(--on-primary); cursor: pointer;
  -webkit-tap-highlight-color: transparent; transition: background 160ms ease;
}
.pixie-pop__restyle:hover { background: var(--charcoal); }
.pixie-pop__restyle svg { display: block; }
.pixie-pop__sub { font-size: 12px; color: var(--slate); margin: -6px 0 18px; }

.pixie-pop__title {
  font-family: 'DM Sans', sans-serif; font-weight: 600; font-size: 18px;
  letter-spacing: -0.02em; color: var(--ink); margin: 0 0 16px;
}

/* the exploding input — a clean, straight field that matches the site's inputs */
.pixie-input { position: relative; margin: 0 auto 18px; width: 100%; }
/* same as the chat message input — consistency */
.pixie-input__field {
  width: 100%; min-height: 36px; padding: 8px 12px;
  font-family: 'DM Sans', sans-serif; font-size: 12px; color: var(--ink);
  background: transparent;
  border: 1px solid var(--hairline-strong);
  border-radius: 8px;
  outline: none;
  transition: border-color 150ms ease;
}
.pixie-input__field::placeholder { color: var(--stone); }
.pixie-input__field:focus { border-color: var(--stone); }   /* grey focus only — no pink, just the caret */
/* the layer the bursting faces fly out of — overflows the input, ignores clicks */
.pixie-burst {
  position: absolute; left: 0; right: 0; top: 50%;
  height: 0; pointer-events: none; z-index: 5;
  overflow: visible;
}
.pixie-particle {
  position: absolute; left: 0; top: 0;
  width: 40px; height: 40px;
  will-change: transform, opacity;
  image-rendering: pixelated; image-rendering: crisp-edges; display: block;
}

.pixie-pop__actions { display: flex; gap: 8px; justify-content: center; }
/* buttons hug their label (consistent padding, like every other button) */

/* name/edit popovers: no avatar, heading left, actions on the right (same layout) */
.pixie-pop__card--name { text-align: left; }
.pixie-pop__card--name .pixie-pop__title { text-align: left; margin-bottom: 18px; }
.pixie-pop__card--name .pixie-pop__actions { justify-content: flex-end; }
.pixie-pop__card--name .pixie-del-btn { margin-right: auto; }   /* push delete to the far left */

/* ===== Gallery page ======================================================= */
/* same container + top offset as the maker (.av-room), so the title lands in the
   exact same spot when you move between pages */
.pg-main { padding: 30px var(--page-margin) 80px; max-width: 1180px; margin: 0 auto; }
.pg-wrap { width: 100%; }

.pg-head {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  margin: 0 0 14px;                      /* same gap-to-content as the maker (.av-room row-gap) */
}
/* shared page-title style (matches .av-head__title in the maker) */
.pg-title {
  font-family: 'DM Sans', sans-serif; font-weight: 600;
  font-size: 28px; letter-spacing: -0.02em; color: var(--ink);
  margin: 0; line-height: 1.2;
  transition: color 320ms ease;
}
/* mobile: smaller title + tighter top offset, matching the maker page */
@media (max-width: 600px) {
  .pg-main { padding-top: 16px; }
  .pg-title { font-size: 20px; }
  .pg-head { margin-bottom: 12px; }
}
.pg-title-count { color: var(--stone); font-weight: 600; transition: color 320ms ease; }

.pg-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}
@media (max-width: 600px) {
  /* one big card per row on mobile (≈ two visible per screen) */
  .pg-grid { grid-template-columns: 1fr; gap: 16px; }
}

/* Instagram-style post card: header (avatar + name) → photo → like + count + date */
.pg-card {
  position: relative;
  display: flex; flex-direction: column;
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg, 12px);
  overflow: hidden;
  transition: background-color 320ms ease;
}
/* ── ONE card layout on every screen (only the sizing differs): a full-bleed
      photo on top, then the pixie name (+ ⋯ menu), then the like row.
      The photo sits first via order:-1 so it hugs the rounded top of the card. ── */
/* fixed row height (fits the 28px ⋯ button) so the name row — and therefore the like
   row beneath it — lands at the EXACT same place whether or not a card has the ⋯ menu */
.pg-card__head { display: flex; align-items: center; gap: 8px; padding: 12px 16px 0; min-height: 40px; }
.pg-card__user {
  flex: 1 1 auto; min-width: 0;
  font-family: 'DM Sans', sans-serif; font-size: 16px; font-weight: 600; color: var(--ink);
  line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: color 320ms ease;
}
/* ── the "photo": the pixie scene (double-tap to like) — full-bleed across the
      top of the card (short & wide so the cards stay compact) ── */
.pg-card__preview {
  order: -1;                                  /* photo first, flush with the card's rounded top */
  position: relative;
  margin: 0;
  aspect-ratio: 4 / 3;                        /* wide & short, not a tall square */
  background: var(--surface);
  display: flex; align-items: flex-start; justify-content: center;
  overflow: hidden;
  cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent;
}
.pg-card__preview--scene { background-size: cover; background-position: center; image-rendering: pixelated; }
.pg-card__preview svg {
  width: auto; height: 84%; margin-top: 4%;   /* character sized to the shorter height */
  image-rendering: pixelated; image-rendering: crisp-edges; display: block;
}
/* the big heart that pops over the photo when you double-tap to like it */
.pg-card__bigheart {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  pointer-events: none; opacity: 0;
}
.pg-card__bigheart svg { width: 94%; height: 94%; fill: #E8202A; }
/* the heart expands to fill the whole photo, holds, then fades — soft, no shadow */
.pg-card.liking .pg-card__bigheart { animation: pg-bigheart 900ms cubic-bezier(0.2, 0.85, 0.3, 1); }
@keyframes pg-bigheart {
  0% { opacity: 0; transform: scale(0.15); }
  28% { opacity: 1; transform: scale(1.04); }
  44% { opacity: 1; transform: scale(0.98); }
  62% { opacity: 1; transform: scale(1); }
  80% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.06); }
}
/* ── footer: just the heart + count (no date, any screen) ── */
.pg-card__foot { padding: 4px 16px 14px; }
.pg-card__actions { display: flex; align-items: center; }
/* "more" (⋯) menu trigger — a floating icon button in the photo's top-right corner,
   only on pixies this browser created. Same box as the dark-mode toggle (32×32, 8px
   radius, 16px icon → matching padding) and the same stroke + hover as the outline
   buttons (Create a pixie), on a solid fill so it stays legible over any photo. */
.pg-card__more {
  position: absolute; top: 10px; right: 10px; z-index: 4;
  width: 32px; height: 32px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px;
  background: var(--canvas);
  border: 1px solid var(--hairline-strong);
  color: var(--charcoal); cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 160ms ease, background 160ms ease, border-color 160ms ease;
}
.pg-card__more:hover { color: var(--ink); background: var(--hover-grey); }
.pg-card__more svg { display: block; width: 16px; height: 16px; }
/* mobile keeps the same layout — only the text/heart shrink a touch */
@media (max-width: 600px) {
  .pg-card__head { padding: 10px 16px 0; }
  .pg-card__user { font-size: 16px; }
  .pg-card__foot { padding: 2px 16px 12px; }
}
/* actions menu popover (edit name / edit look / delete) */
/* DESKTOP: the actions menu is a small dropdown anchored under the ⋯ — no dimming overlay */
.pixie-pop--menu { padding: 0; display: block; }
.pixie-pop--menu .pixie-pop__scrim { background: none; backdrop-filter: none; -webkit-backdrop-filter: none; }
.pixie-pop__card--menu {
  position: absolute; top: 0; left: 0;
  width: 168px; padding: 4px; text-align: left;
}
.pg-menu__item {
  display: block; width: 100%; text-align: left;
  padding: 8px 12px; border: none; background: none; border-radius: var(--r-md, 8px);
  font-family: 'DM Sans', sans-serif; font-size: 14px; font-weight: 500; color: var(--ink);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: background 140ms ease;
}
.pg-menu__item:hover { background: var(--hover-grey); }
/* MOBILE: the actions menu becomes a bottom sheet (rename/confirm stay centred) */
@media (max-width: 600px) {
  .pixie-pop--menu { display: flex; align-items: flex-end; padding: 0; }
  .pixie-pop--menu .pixie-pop__scrim { background: rgba(20, 20, 19, 0.4); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
  .pixie-pop__card--menu {
    position: static; width: 100%;
    border-radius: 18px 18px 0 0;
    border-bottom: none;                 /* flush with the screen edge — no line at the bottom */
    padding: 8px 10px calc(14px + env(safe-area-inset-bottom));
  }
  /* short drag handle, centred at the top of the sheet */
  .pixie-pop__card--menu::before {
    content: ''; display: block;
    width: 36px; height: 4px; border-radius: 999px;
    background: var(--hairline-strong);
    margin: 6px auto 10px;
  }
  .pixie-pop--menu .pixie-pop__card { transform: translateY(100%); transition: transform 260ms cubic-bezier(0.22, 1, 0.36, 1), opacity 200ms ease; }
  .pixie-pop--menu.in .pixie-pop__card { transform: translateY(0); }
  .pg-menu__item { padding: 14px 14px; font-size: 16px; border-radius: 10px; }
}

/* the pixie you just added gets a soft ring */
/* no extra ring on the just-added pixie — the edit icon already marks it as yours */

/* empty / loading state — centred in the open space below the title */
.pg-state {
  max-width: 460px; margin: 0 auto; text-align: center; color: var(--slate);
  min-height: calc(100dvh - 220px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.pg-state__face { display: block; margin: 0 auto 16px; width: 64px; height: 64px; border-radius: 50%; overflow: hidden; border: 1px solid var(--hairline); background: var(--surface); }
.pg-state__face svg { width: 100%; height: 100%; object-fit: cover; object-position: center 18%; image-rendering: pixelated; }
.pg-state p { font-size: 16px; margin: 0 0 16px; }
.pg-spinner {
  width: 26px; height: 26px; margin: 0 auto;
  border: 2.5px solid var(--hairline-strong); border-top-color: var(--charcoal);
  border-radius: 50%; animation: pixie-spin 0.8s linear infinite;
}
@keyframes pixie-spin { to { transform: rotate(360deg); } }

/* ── like button (heart with the count right next to it) ── */
.pg-like {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  position: relative;
  background: none; border: none; padding: 2px 4px 2px 2px; margin: -2px;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  color: var(--ink);
}
/* nudge the heart up ~1px so its visible ink (its lower point pulls the eye down)
   optically centres with the count's digits, not just box-to-box */
.pg-like__heart { width: 24px; height: 24px; display: block; flex: none; transform: translateY(-1px); }
@media (max-width: 600px) { .pg-like__heart { width: 22px; height: 22px; } }
.pg-like__heart path { fill: none; stroke: var(--ink); stroke-width: 1.9; stroke-linejoin: round; stroke-linecap: round; transition: fill 160ms ease, stroke 160ms ease; }
.pg-like:hover .pg-like__heart path { stroke: #E8202A; }
/* liked = a clean pure FILL, exactly like the big double-tap heart (no stroke edge) */
.pg-like.is-liked .pg-like__heart path { fill: #E8202A; stroke: none; }
.pg-like__count {
  font-family: 'DM Sans', sans-serif; font-size: 14px; font-weight: 400; color: var(--ink);
  font-variant-numeric: tabular-nums; line-height: 1;
}
/* pop when liked */
.pg-like.pop .pg-like__heart { animation: pg-like-pop 440ms cubic-bezier(0.2, 0.9, 0.3, 1.35); }
@keyframes pg-like-pop {
  0% { transform: scale(1); }
  28% { transform: scale(0.78); }
  60% { transform: scale(1.32); }
  100% { transform: scale(1); }
}
/* a little burst of hearts on like */
.pg-like__spark {
  position: absolute; width: 6px; height: 6px; border-radius: 50%;
  background: #E8202A; pointer-events: none; opacity: 0;
}
.pg-like.pop .pg-like__spark { animation: pg-spark 520ms ease-out forwards; }
@keyframes pg-spark {
  0% { opacity: 1; transform: translate(0, 0) scale(1); }
  100% { opacity: 0; transform: translate(var(--sx, 0), var(--sy, -14px)) scale(0.4); }
}

/* freeze transitions for one frame during a theme flip, so the nav background
   swaps WITH the page (no seam/line under the nav, no colour twitch) — same as home */
.theme-switching, .theme-switching *, .theme-switching *::before, .theme-switching *::after { transition: none !important; }

@media (prefers-reduced-motion: reduce) {
  .pixie-pop__card, .pixie-pop__scrim, .pg-card { transition: none; }
  .pg-like.pop .pg-like__heart, .pg-like.pop .pg-like__spark { animation: none; }
}
