/* The guests' site: phones first (a party's guests are on theirs), fine on a desktop; light and dark. */

:root {
  --ground: #f6f4ef;
  --card: #ffffff;
  --ink: #1d1c1a;
  --muted: #5a574f;
  --line: #d6d2c8;
  --accent: #b3164a;          /* the head guide's crimson, a little deeper for contrast on white */
  --accent-ink: #ffffff;
  --focus: #1f5fd1;
  --none: repeating-linear-gradient(45deg, #ece9e2 0 6px, #d9d5cc 6px 12px);
  --stage: #c9c5bb;
  --doll-floor: rgba(0, 0, 0, 0.3);
  --radius: 12px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ground: #141416;
    --card: #1f1f23;
    --ink: #f1efe9;
    --muted: #b4b0a6;
    --line: #3a3a40;
    --accent: #f0628f;
    --accent-ink: #1a0910;
    --focus: #8cb4ff;
    --none: repeating-linear-gradient(45deg, #2a2a2f 0 6px, #34343a 6px 12px);
    --stage: #55555d;
    --doll-floor: rgba(0, 0, 0, 0.45);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  padding: 0 max(16px, env(safe-area-inset-left)) 48px max(16px, env(safe-area-inset-right));
  background: var(--ground);
  color: var(--ink);
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1 { font-size: 1.7rem; line-height: 1.15; margin: 20px 0 6px; }
h2 { font-size: 1.2rem; margin: 0 0 8px; }
p { margin: 0 0 8px; }
a { color: var(--accent); }
[hidden] { display: none !important; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

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

button, .button {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 8px 16px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--card); color: var(--ink);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.quiet { min-height: 36px; padding: 4px 12px; font-weight: 500; font-size: 0.92rem; }
button.danger { border-color: #b3202a; color: #b3202a; }
@media (prefers-color-scheme: dark) { button.danger { border-color: #ff8a8a; color: #ff8a8a; } }
button:disabled { opacity: 0.55; cursor: progress; }
/* the file input stays focusable but invisible: its label is the button, and shows the focus */
input[type="file"]:focus-visible + label { outline: 3px solid var(--focus); outline-offset: 2px; }

input:not([type]), input[type="text"], input[type="date"] {
  width: 100%; min-height: 44px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--ink); font: inherit;
}

.hint { color: var(--muted); font-size: 0.9rem; }
.top { max-width: 1100px; margin: 0 auto; }
.top p { color: var(--muted); }

/* ── where the guest stands ─────────────────────────────────────────────────────────────── */
.status {
  max-width: 1100px; margin: 12px auto 16px; padding: 14px 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
}
.status .state { font-size: 1.35rem; font-weight: 700; }
.status .actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 0; }
.status .actions:empty, .status .actions:not(:has(> :not([hidden]))) { display: none; }
.portrait { display: block; width: 160px; height: 160px; object-fit: contain; border-radius: var(--radius); background: var(--ground); margin: 4px 0 8px; }

/* ── the maker: the doll beside the rest on a wide screen, above it on a phone ───────────────── */
.maker { max-width: 1100px; margin: 0 auto; display: grid; gap: 16px; }
@media (min-width: 820px) {
  .maker { grid-template-columns: minmax(320px, 480px) 1fr; align-items: start; }
  .viewer { position: sticky; top: 16px; }
  .stage { --tallest: 66vh; }                     /* under the page's heading, the feet in sight without scrolling */
}
.viewer { margin: 0; min-width: 0; }
.viewer figcaption { text-align: center; margin-top: 6px; color: var(--muted); font-size: 0.9rem; }

/* the stage: the doll in the middle, as tall as the screen has room for, a column for the arrows either side
   of it. The ground's mid-toned so a white shirt and a black one both stand out from it. --shape is the doll's
   width over its height, which picker.js sets from the body. */
.stage {
  --side: 52px;
  --shape: 0.45;
  position: relative;
  display: grid; grid-template-columns: var(--side) minmax(0, 1fr) var(--side); justify-items: center;
  width: 100%; margin: 0 auto; padding: 6px;
  max-width: calc(2 * var(--side) + 12px + var(--tallest, 76vh) * var(--shape));
  background: var(--stage); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden;
}
/* dragged sideways it turns; up or down, the page scrolls. The floor's a soft shadow under its feet. */
.doll {
  grid-column: 2; grid-row: 2; display: block; width: 100%; aspect-ratio: var(--shape);
  background: radial-gradient(ellipse 42% 3.2% at 50% 96%, var(--doll-floor), transparent);
  touch-action: pan-y; cursor: grab; user-select: none; -webkit-user-select: none;
}
.doll:active { cursor: grabbing; }
.stage.flat .doll { background: none; touch-action: auto; cursor: default; }
.turn-round { grid-column: 2; grid-row: 3; min-height: 36px; margin-top: 2px; }
/* no doll to dress (no WebGL, or templates from before there was one): the skin laid flat, with room down the sides for all the arrows */
.stage.flat { min-height: 420px; }
.stage.flat .doll { align-self: center; }
/* what's just been chosen, over the doll's head, where it's in sight whatever the page has scrolled to */
.wearing {
  grid-column: 2; grid-row: 1; display: block; height: 26px;
  text-align: center; font-size: 0.8rem; font-weight: 600; line-height: 26px; white-space: nowrap;
}

@media (max-width: 340px) { .wearing { font-size: 0.68rem; } }

/* a row of arrows, across the stage at its part's height: only the arrows and their name stop a finger */
.part {
  position: absolute; left: 6px; right: 6px; height: 44px;
  display: flex; align-items: center; justify-content: space-between;
  pointer-events: none;
}
.arrow {
  position: relative; flex: none; width: var(--side); height: 44px; min-height: 0; padding: 0;
  border-radius: 12px; border-color: transparent; background: var(--card);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.22);
  pointer-events: auto; touch-action: manipulation;
}
.arrow::before {
  content: ""; width: 11px; height: 11px;
  border-left: 3px solid currentColor; border-bottom: 3px solid currentColor;
  transform: translateX(2px) rotate(45deg);
}
.arrow.next::before { transform: translateX(-2px) rotate(-135deg); }
.arrow:active { background: var(--accent); color: var(--accent-ink); }
@media (hover: hover) { .arrow:hover { background: var(--accent); color: var(--accent-ink); } }
.arrow:disabled { opacity: 0.35; cursor: default; }
/* its name, over the arrow on the left: the rows are too close together at the head for anything under them */
.part-name {
  position: absolute; left: 0; top: -14px; width: var(--side); text-align: center;
  font-size: 0.68rem; font-weight: 700; line-height: 14px; white-space: nowrap; color: var(--muted);
}

.picker { min-width: 0; }
.photo-part { margin-top: 4px; }
/* the face is on "your photo" and there isn't one yet: this is what comes next */
.photo-part.wanted { padding: 10px; border: 2px solid var(--accent); border-radius: var(--radius); }
.consent { font-size: 0.92rem; color: var(--muted); border-left: 3px solid var(--accent); padding-left: 10px; }
.photo-said { font-weight: 600; margin-top: 6px; }
.photo-said:empty { display: none; }
#photo-button.busy { opacity: 0.55; cursor: progress; }

.field { margin: 18px 0 8px; max-width: 420px; }
.field label { display: block; font-weight: 700; margin-bottom: 4px; }
.save { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 16px 0 8px; }
.save p { margin: 0; color: var(--muted); }
.keep-note { color: var(--muted); font-size: 0.92rem; margin-top: 16px; }

/* ── the host's page ─────────────────────────────────────────────────────────────────────── */
.host { max-width: 1100px; margin: 0 auto; }
.panel {
  padding: 14px 16px; margin: 12px 0 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
}
.start { display: grid; gap: 10px; max-width: 420px; }
.start label { font-weight: 700; }
.start .check { display: flex; align-items: center; gap: 8px; }
.start .check input { width: 1.25rem; height: 1.25rem; margin: 0; }
.guests { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
@media (min-width: 720px) { .guests { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); } }
.guest { padding: 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.guest h3 { margin: 0; font-size: 1.05rem; }
.guest .who { color: var(--muted); font-size: 0.88rem; overflow-wrap: anywhere; }
.guest .what { font-weight: 700; margin: 4px 0 8px; }
.guest.waiting { border-color: var(--accent); }
.pictures { display: flex; gap: 6px; margin: 8px 0; }
.pictures figure { margin: 0; text-align: center; font-size: 0.75rem; color: var(--muted); }
.pictures img { display: block; width: 88px; height: 88px; object-fit: cover; border-radius: 8px; background: var(--none); border: 1px solid var(--line); }
.buttons { display: flex; flex-wrap: wrap; gap: 6px; }
