/* WGF simple character editor. Every rule is scoped to .wgfe; colours and fonts take the website's After Dark
   variables when the page defines them (--paper, --ink, --red-on-paper, --serif, --sans), else the fallbacks below. */
.wgfe {
  --wgfe-paper: var(--paper, #f4efe6);
  --wgfe-paper-2: var(--paper-2, #e9e2d5);
  --wgfe-ink: var(--ink, #17151a);
  --wgfe-ink-2: var(--ink-2, #4a453f);
  --wgfe-muted: var(--ink-muted, #6e675e);
  --wgfe-red: var(--red-on-paper, #b5121b);
  --wgfe-line: rgba(23, 21, 26, .14);
  --wgfe-r: var(--r, 16px);
  --wgfe-serif: var(--serif, 'Instrument Serif', Georgia, 'Times New Roman', serif);
  --wgfe-sans: var(--sans, 'Geist', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif);
  display: grid;
  grid-template-columns: minmax(300px, 440px) minmax(0, 1fr);
  max-width: 1180px;
  margin: 0 auto;
  background: var(--wgfe-paper);
  color: var(--wgfe-ink);
  border-radius: var(--wgfe-r);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .45);
  font-family: var(--wgfe-sans);
  font-size: 16px;
  line-height: 1.4;
  text-align: left;
}
.wgfe *, .wgfe *::before, .wgfe *::after { box-sizing: border-box; }
.wgfe button { font: inherit; color: inherit; }
.wgfe-loading { grid-column: 1 / -1; padding: 60px; text-align: center; color: var(--wgfe-muted); }

/* ----- stage (the big character) ----- */
.wgfe-stage {
  position: sticky; top: 12px; align-self: start;
  display: flex; flex-direction: column; align-items: center; gap: 18px;
  padding: 28px 24px 24px;
}
.wgfe-spot {
  position: relative; width: 100%; aspect-ratio: 1; max-width: 448px;
  display: grid; place-items: center;
  border-radius: calc(var(--wgfe-r) - 4px);
  background: radial-gradient(ellipse 70% 62% at 50% 44%, #fffaf1 0%, #f1e8d8 58%, #e1d4bf 100%);
  box-shadow: inset 0 0 0 1px var(--wgfe-line);
}
.wgfe-preview { display: block; image-rendering: pixelated; image-rendering: crisp-edges; position: relative; z-index: 1; }
.wgfe-spot::after {           /* floor shadow under the feet */
  content: ''; position: absolute; left: 50%; bottom: calc(50% - var(--wgfe-feet, 0px) - 3%);
  width: var(--wgfe-shadow, 34%); height: 6%; transform: translateX(-50%);
  background: radial-gradient(closest-side, rgba(60, 40, 20, .26), rgba(60, 40, 20, 0));
}
.wgfe-pause {
  position: absolute; right: 10px; bottom: 10px; z-index: 2;
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--wgfe-line);
  background: rgba(255, 255, 255, .7); font-size: 12px; cursor: pointer; color: var(--wgfe-ink-2);
}
.wgfe-stage-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.wgfe-attrib { margin: 0; font-size: 12px; line-height: 1.35; text-align: center; color: var(--wgfe-muted); }
.wgfe-attrib a { color: inherit; text-decoration: underline; }

/* ----- buttons ----- */
.wgfe-btn {
  min-height: 44px; padding: 0 18px; border-radius: 999px; cursor: pointer;
  border: 1.5px solid var(--wgfe-ink); background: transparent; font-weight: 600; font-size: 15px;
}
.wgfe-btn:hover:not(:disabled) { background: rgba(23, 21, 26, .06); }
.wgfe-btn:disabled { opacity: .35; cursor: default; }
.wgfe-btn.wgfe-quiet { border-color: transparent; color: var(--wgfe-muted); font-weight: 500; }
.wgfe-btn.wgfe-primary { background: var(--wgfe-red); border-color: var(--wgfe-red); color: #fff; }
.wgfe-btn.wgfe-primary:hover { background: #95101a; }
.wgfe button:focus-visible, .wgfe input:focus-visible, .wgfe a:focus-visible { outline: 3px solid #2a6fdb; outline-offset: 2px; }
.wgfe-link { background: none; border: 0; padding: 0; color: var(--wgfe-red); text-decoration: underline; cursor: pointer; font-weight: 600; }

/* ----- panel ----- */
.wgfe-panel { display: flex; flex-direction: column; min-width: 0; padding: 22px 28px 0; border-left: 1px solid var(--wgfe-line); }
.wgfe-steps { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.wgfe-steps button {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px 0 6px;
  border-radius: 999px; border: 1px solid var(--wgfe-line); background: transparent; cursor: pointer; color: var(--wgfe-ink-2);
}
.wgfe-steps .wgfe-num {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--wgfe-paper-2); font-size: 13px; font-weight: 700;
}
.wgfe-steps button.on { background: var(--wgfe-ink); color: var(--wgfe-paper); border-color: var(--wgfe-ink); }
.wgfe-steps button.on .wgfe-num { background: var(--wgfe-red); color: #fff; }
.wgfe-step-head h2 { font-family: var(--wgfe-serif); font-weight: 400; font-size: 40px; line-height: 1.05; margin: 18px 0 4px; }
.wgfe-step-head p { margin: 0 0 6px; color: var(--wgfe-muted); }
.wgfe-section { padding: 18px 0 4px; border-bottom: 1px solid var(--wgfe-line); }
.wgfe-section:last-child { border-bottom: 0; }
.wgfe-section h3 { margin: 0 0 12px; font-size: 17px; font-weight: 700; }
.wgfe-section h4 { margin: 0 0 8px; font-size: 14px; font-weight: 600; color: var(--wgfe-ink-2); }
.wgfe-section h4.wgfe-group { margin: 16px 0 8px; text-transform: uppercase; letter-spacing: .08em; font-size: 12px; color: var(--wgfe-muted); }
.wgfe-value { font-weight: 500; color: var(--wgfe-muted); }
.wgfe-note { margin: -6px 0 12px; font-size: 14px; color: var(--wgfe-muted); }
.wgfe-colors { margin: 0 0 14px; }
.wgfe-blocked .wgfe-tiles { opacity: .45; }

/* ----- picture tiles ----- */
.wgfe-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; margin-bottom: 12px; }
.wgfe-tile {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 6px;
  padding: 10px 4px 8px; border-radius: 14px; border: 2px solid transparent; background: var(--wgfe-paper-2); cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
}
.wgfe-tile canvas { display: block; image-rendering: pixelated; image-rendering: crisp-edges; max-width: 100%; height: auto !important; }
.wgfe-tile:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(23, 21, 26, .12); }
.wgfe-tile:disabled { cursor: not-allowed; }
.wgfe-tile.on { border-color: var(--wgfe-red); background: #fff; }
.wgfe-tile.on::after {
  content: '✓'; position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; background: var(--wgfe-red); color: #fff; font-size: 13px; font-weight: 700;
}
.wgfe-tile-label { font-size: 13px; line-height: 1.2; text-align: center; color: var(--wgfe-ink-2); }
.wgfe-tile.on .wgfe-tile-label { color: var(--wgfe-ink); font-weight: 600; }
.wgfe-tiles[data-crop="body"], .wgfe-tiles[data-crop="head"] { grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); }
.wgfe-tiles[data-crop="face"], .wgfe-tiles[data-crop="chest"] { grid-template-columns: repeat(auto-fill, minmax(116px, 1fr)); }

/* ----- colour swatches ----- */
.wgfe-swatches { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.wgfe-swatch {
  width: 36px; height: 36px; border-radius: 50%; border: 0; padding: 0; cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .22);
}
.wgfe-swatch:hover { transform: scale(1.08); }
.wgfe-swatch.on { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .22), 0 0 0 3px var(--wgfe-paper), 0 0 0 5px var(--wgfe-ink); }

/* ----- footer: colours of what was just picked, then back / next; stays in view ----- */
.wgfe-foot {
  position: sticky; bottom: 0; z-index: 3;
  margin: 8px -28px 0; padding: 12px 28px 16px;
  background: var(--wgfe-paper); border-top: 1px solid var(--wgfe-line);
  box-shadow: 0 -10px 24px rgba(244, 239, 230, .9);
}
.wgfe-foot-nav { display: flex; justify-content: space-between; gap: 12px; }
.wgfe-dock { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; margin-bottom: 10px; }
.wgfe-dock .wgfe-colors { margin: 0; }
.wgfe-dock h4 { margin: 0 0 6px; font-size: 14px; font-weight: 700; color: var(--wgfe-ink); }
.wgfe-dock .wgfe-swatches { gap: 6px; margin-bottom: 4px; }
.wgfe-dock .wgfe-swatch { width: 30px; height: 30px; }

/* ----- done ----- */
.wgfe-name { display: grid; gap: 6px; max-width: 420px; }
.wgfe-name span { font-size: 14px; color: var(--wgfe-muted); }
.wgfe-name input { min-height: 48px; padding: 0 14px; font: inherit; font-size: 18px; border-radius: 10px; border: 1.5px solid var(--wgfe-line); background: #fff; color: var(--wgfe-ink); }
.wgfe-summary { margin: 0; padding-left: 20px; columns: 2 220px; }
.wgfe-summary li { margin: 2px 0; }
.wgfe-save { display: flex; flex-wrap: wrap; gap: 10px; padding: 22px 0 6px; }
.wgfe-msg { min-height: 1.4em; margin: 6px 0; color: var(--wgfe-ink-2); font-weight: 600; }
.wgfe-credits { font-size: 13px; color: var(--wgfe-muted); margin: 18px 0 8px; }
.wgfe-credits a { color: inherit; }

/* ----- phones: character on top, kept in view while choosing ----- */
@media (max-width: 760px) {
  .wgfe { grid-template-columns: minmax(0, 1fr); border-radius: 12px; }
  .wgfe-stage {
    top: 0; z-index: 5; flex-direction: row; align-items: center; gap: 12px; padding: 10px 12px;
    background: var(--wgfe-paper); border-bottom: 1px solid var(--wgfe-line); border-radius: 12px 12px 0 0;
  }
  .wgfe-spot { width: 200px; flex: none; }
  .wgfe-stage { flex-wrap: wrap; }
  .wgfe-stage-actions { flex-direction: column; align-items: stretch; flex: 1; }
  .wgfe-attrib { flex-basis: 100%; font-size: 11px; }
  .wgfe-stage-actions .wgfe-btn { min-height: 40px; padding: 0 12px; font-size: 14px; }
  .wgfe-panel { border-left: 0; padding: 12px 16px 0; }
  .wgfe-steps { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
  .wgfe-steps button { flex: none; }
  .wgfe-step-head h2 { font-size: 32px; }
  .wgfe-tiles { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
  .wgfe-foot { margin: 8px -16px 0; padding: 10px 16px 12px; }
  .wgfe-dock .wgfe-swatches { flex-wrap: nowrap; overflow-x: auto; padding: 4px 2px 6px; }
  .wgfe-dock .wgfe-swatch { flex: none; }
  .wgfe-tiles[data-crop] { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
}
@media (max-width: 380px) { .wgfe-spot { width: 150px; } }
@media (prefers-reduced-motion: reduce) { .wgfe-tile, .wgfe-swatch { transition: none; } .wgfe-tile:hover, .wgfe-swatch:hover { transform: none; } }
