/* moin pfp generator: page-specific styles.
   Colours, fonts, doodle borders and button styles come from /assets/styles.css. */

.pfp-back { display: inline-flex; align-items: center; gap: .375rem; }

/* Layout: preview + controls side by side on wide screens, stacked on phones. */
.pfp-layout { display: grid; gap: 2rem; align-items: start; }
.pfp-stage, .pfp-controls { min-width: 0; }
.pfp-controls { display: grid; gap: 1.75rem; }
@media (width >= 56rem) {
  .pfp-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 2.5rem; }
  .pfp-stage { position: sticky; top: 1.5rem; }
}

.pfp-card { padding: 1rem; }
@media (width >= 40rem) { .pfp-card { padding: 1.5rem; } }

/* A floated legend is laid out like a normal block instead of sitting in the fieldset border. */
.pfp-fieldset { min-width: 0; margin: 0; }
.pfp-fieldset > legend { float: left; width: 100%; padding: 0; margin-bottom: 1rem; }
.pfp-fieldset > legend + * { clear: both; }
.pfp-legend { display: flex; align-items: center; flex-wrap: wrap; gap: .25rem .75rem; line-height: 1.1; }
.pfp-step {
  display: inline-flex; flex: none; align-items: center; justify-content: center;
  width: 2.5rem; height: 2.5rem; font-size: 1.5rem; line-height: 1;
  border-radius: 50% 45% 55% 48% / 48% 55% 45% 52%;
}
.pfp-picked { margin-bottom: .875rem; }
.pfp-bggroup + .pfp-bggroup, [data-pfp="bg-extras"] > .pfp-bggroup { margin-top: 1.25rem; }
.pfp-group-label { margin-bottom: .625rem; font-family: "Patrick Hand", "Comic Sans MS", cursive; font-size: 1.25rem; line-height: 1.2; color: var(--muted-foreground); }
.pfp-anim-badge {
  position: absolute; left: 50%; bottom: 5%; width: 36%; height: 36%; transform: translateX(-50%);
  display: grid; place-items: center; border-radius: 50%; pointer-events: none;
  background-color: var(--card); color: var(--color-foreground); box-shadow: 0 0 0 2px var(--color-foreground);
}
.pfp-anim-badge svg { width: 70%; height: 70%; }

/* Preview */
.pfp-checker {
  background-color: #fcfaf1;
  background-image: repeating-conic-gradient(#e6e1cd 0 25%, transparent 0 50%);
  background-size: 1.5rem 1.5rem;
}
.pfp-canvas-wrap {
  position: relative; aspect-ratio: 1 / 1; overflow: hidden;
  border: 2.5px solid var(--color-foreground); border-radius: .75rem;
}
.pfp-canvas-wrap canvas { display: block; width: 100%; height: 100%; transition: opacity .2s ease; }
.pfp-stage[aria-busy="true"] .pfp-canvas-wrap canvas { opacity: .55; }

.pfp-rounds {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: center;
  gap: 1rem 2.5rem; margin-top: 1.25rem;
}
.pfp-round-fig { display: flex; flex-direction: column; align-items: center; gap: .5rem; margin: 0; }
.pfp-round-fig figcaption { font-family: "Patrick Hand", "Comic Sans MS", cursive; font-size: 1.125rem; line-height: 1.2; color: var(--muted-foreground); }
.pfp-round {
  display: block; width: 7.5rem; height: 7.5rem; border-radius: 50%;
  border: 2.5px solid var(--color-foreground); background-size: .75rem .75rem;
}
.pfp-round-sm { width: 3rem; height: 3rem; background-size: .5rem .5rem; }

.pfp-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: .875rem 1rem; }
.pfp-actions button { cursor: pointer; }
.pfp-actions button:disabled { cursor: progress; opacity: .6; }
.pfp-status { min-height: 1.5em; }

/* Play/stop for animated backgrounds, over the preview's corner (not part of the image). */
.pfp-motion {
  position: absolute; left: .625rem; bottom: .625rem; display: grid; place-items: center;
  width: 2.75rem; height: 2.75rem; border-radius: 50%; cursor: pointer; box-shadow: 2px 2px 0 var(--color-foreground);
}

/* GIF progress */
.pfp-gifbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .5rem .875rem; margin-top: 1rem; }
.pfp-gifbar-label { min-width: 12ch; font-weight: 700; color: var(--color-foreground); }
.pfp-gifbar progress { width: min(16rem, 100%); height: .875rem; accent-color: var(--primary); }
.pfp-gif-note { max-width: 32rem; margin-inline: auto; line-height: 1.45; }
/* "share on X" panel: shown after the image is copied (or downloaded), X opens from its button. */
.pfp-xpanel { margin-top: 1.25rem; padding: 1rem 1.125rem; text-align: center; }
.pfp-xpanel-msg { font-weight: 700; font-size: 1.0625rem; line-height: 1.45; color: var(--color-foreground); }
.pfp-xpanel-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .75rem 1.25rem; margin-top: .875rem; }
.pfp-textbtn {
  padding: .125rem 0; cursor: pointer; font-weight: 700; color: var(--color-foreground);
  border-bottom: 2px solid color-mix(in srgb, var(--color-foreground) 40%, transparent);
}
.pfp-textbtn:hover { border-bottom-color: var(--color-foreground); }

/* Choice inputs stay in the accessibility tree and keyboard order; their labels are the visible controls. */
.pfp-radio {
  position: absolute; width: 1px; height: 1px; margin: 0; padding: 0; border: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; opacity: 0;
}
.pfp-radio:focus-visible + label { outline: 3px dashed var(--color-foreground); outline-offset: 3px; }

/* Faces */
.pfp-faces { position: relative; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .5rem; }
.pfp-face {
  display: block; cursor: pointer; padding: .2rem;
  border: 2.5px solid transparent; border-radius: 1rem; background-color: var(--background);
  transition: transform .12s ease, background-color .12s ease;
}
.pfp-face img { display: block; width: 100%; height: auto; }
.pfp-radio:checked + .pfp-face {
  border-color: var(--color-foreground); background-color: var(--secondary);
  box-shadow: 3px 3px 0 var(--color-foreground); transform: rotate(-3deg);
}
@media (hover: hover) {
  .pfp-face:hover { transform: translateY(-2px); }
  .pfp-radio:checked + .pfp-face:hover { transform: rotate(-3deg) translateY(-2px); }
}

/* Backgrounds */
.pfp-swatches { position: relative; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .75rem .5rem; justify-items: center; }
@media (width >= 30rem) { .pfp-swatches { grid-template-columns: repeat(8, minmax(0, 1fr)); } }
.pfp-swatch {
  position: relative; display: block; width: 100%; max-width: 3rem; aspect-ratio: 1 / 1;
  border: 2.5px solid var(--color-foreground); border-radius: 50%; overflow: hidden; cursor: pointer;
  background-size: .75rem .75rem;
}
.pfp-swatch canvas { display: block; width: 100%; height: 100%; }
.pfp-radio:checked + .pfp-swatch, .pfp-custom.is-active { box-shadow: 0 0 0 3px var(--card), 0 0 0 6px var(--color-foreground); }
.pfp-custom { background: conic-gradient(#ff5c5c, #ffd84d, #6fdc6f, #5cc8ff, #b36bff, #ff5c5c); }
/* Focus ring sits outside the 6px selected ring so both stay visible on the selected swatch. */
.pfp-radio:focus-visible + .pfp-swatch { outline-offset: 7px; }
.pfp-custom:focus-within { outline: 3px dashed var(--color-foreground); outline-offset: 7px; }
.pfp-custom-dot {
  position: absolute; inset: 24%; border-radius: 50%; pointer-events: none;
  border: 2px solid var(--color-foreground); background-color: var(--pfp-custom, #ffd84d);
}
.pfp-color {
  position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; border: 0;
  opacity: 0; cursor: pointer;
}

/* Caption */
.pfp-input {
  display: block; width: 100%; margin-top: 1rem; padding: .625rem 1rem;
  font: 700 1.25rem/1.4 "Nunito", ui-sans-serif, system-ui, sans-serif; color: var(--color-foreground);
}
.pfp-input::placeholder { color: var(--muted-foreground); opacity: 1; }
.pfp-chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.pfp-chip { cursor: pointer; padding: .2rem .875rem; line-height: 1.4; color: var(--color-foreground); transition: transform .1s ease; }
.pfp-chip[aria-pressed="true"] { background-color: var(--secondary); box-shadow: 2px 2px 0 var(--color-foreground); }
@media (hover: hover) { .pfp-chip:hover { transform: translate(1px, 1px); } }

/* Floating round preview, shown on narrow screens while the main preview is scrolled away. */
.pfp-mini {
  position: fixed; right: 1rem; bottom: calc(1rem + env(safe-area-inset-bottom, 0px)); z-index: 20;
  width: 4.5rem; height: 4.5rem; padding: 0; border-radius: 50%; overflow: hidden; cursor: pointer;
  background-size: .75rem .75rem;
}
.pfp-mini canvas { display: block; width: 100%; height: 100%; }

@media (prefers-reduced-motion: reduce) {
  .pfp-face, .pfp-chip, .pfp-canvas-wrap canvas { transition: none; }
  .pfp-radio:checked + .pfp-face, .pfp-radio:checked + .pfp-face:hover { transform: none; }
}
@media (forced-colors: active) {
  .pfp-radio:checked + .pfp-face, .pfp-radio:checked + .pfp-swatch, .pfp-custom.is-active { outline: 3px solid CanvasText; outline-offset: 2px; }
}

/* Text link on the light background (the footer's underline style, in the foreground colour). */
.pfp-link { border-bottom: 2px solid color-mix(in srgb, var(--color-foreground) 40%, transparent); }
.pfp-link:hover { border-bottom-color: var(--color-foreground); }
