/* <bw-wife-picker> — portrait gallery + "Add your own" card + custom panel.
   Colours come from the host app's theme variables. Cards are <bw-card>. */

.bw-wife-picker { display: block; text-align: left; }
.bw-wife-picker [hidden] { display: none !important; }

.bwp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: 10px;
}

.bwp-saved { margin-bottom: 16px; }
.bwp-taken { margin-top: 18px; }
.bwp-h {
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--faint); margin: 0 0 8px;
}
.bwp-h--gold { color: var(--gold); }

/* The panel opens under the gallery, tied to the "Add your own" card by the
   same gold edge, so the gallery itself never reflows. */
.bwp-custom {
  margin-top: 12px; padding: 14px;
  border: 1px solid var(--gold); border-radius: 10px;
  background: var(--surface-2);
}
.bwp-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
/* Keep host-wide label typography/margins out of the shared upload UI. */
.bw-wife-picker .bwp-field label {
  display: flex; flex-direction: column; gap: 6px; margin: 0;
  font-size: 0.78rem; font-weight: 400; letter-spacing: normal;
  text-transform: none; color: var(--muted);
}
.bwp-label { font-size: 0.78rem; color: var(--muted); }
.bwp-opt { color: var(--faint); }
.bwp-custom input[type="text"], .bwp-custom input[type="url"] {
  width: 100%; padding: 12px 14px; border-radius: 8px;
  border: 1px solid var(--border-strong); background: var(--bg);
  color: var(--text); font-family: inherit; font-size: 1rem;
}
.bwp-custom input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.bwp-preview { display: flex; align-items: center; gap: 10px; min-height: 56px; }
.bwp-preview img {
  width: 72px; height: 108px; object-fit: cover; object-position: top;
  border-radius: 4px; border: 1px solid var(--border-strong); background: var(--bg);
}
.bwp-ph {
  display: inline-flex; align-items: center; justify-content: center;
  width: 72px; height: 108px; border-radius: 4px; border: 1px dashed var(--border-strong); font-size: 1.1rem;
}
.bwp-hint { font-size: 0.78rem; color: var(--faint); }

.bwp-avatars { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; }
.bwp-avatar {
  padding: 0; border: 2px solid var(--border); border-radius: 6px;
  background: var(--surface); cursor: pointer; overflow: hidden; aspect-ratio: 36 / 50;
}
.bwp-avatar img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.bwp-avatar:hover { border-color: var(--border-strong); }
.bwp-avatar.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
/* The current upload appears among the avatar choices so it stays visible
   and re-selectable; dashed until picked, then it selects like the rest. */
.bwp-avatar--upload { border-style: dashed; }
.bwp-avatar--upload.sel { border-style: solid; }

.bwp-pic-row { display: flex; gap: 8px; align-items: stretch; margin-top: 4px; }
.bwp-pic-row input[type="url"] { flex: 1; min-width: 0; padding: 10px 12px; font-size: 0.9rem; }
.bwp-btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 14px; min-height: 44px; border-radius: 8px;
  border: 1px solid var(--border-strong); background: var(--bg); color: var(--text);
  font: inherit; font-size: 0.85rem; cursor: pointer; white-space: nowrap;
}
.bwp-btn:hover { border-color: var(--muted); }
.bw-wife-picker .bwp-field .bwp-file {
  position: relative; overflow: hidden; display: inline-flex; flex-direction: row;
  color: var(--text); font-size: 0.85rem; flex-shrink: 0;
}
.bwp-file input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.bwp-err { color: var(--danger, #e0557a); font-size: 0.8rem; min-height: 0; }
.bwp-err:empty { display: none; }

@media (max-width: 640px) {
  .bwp-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
}

/* Frame overlay for uploaded portraits (option A, 2026-10-21). Uploads are
   stored raw; the frame is drawn here — 15% oversized with the outer rim
   cropped by the box — so only a slim ornate border covers the photo. Both
   apps' service workers precache the asset, so the frame also paints
   offline. `framed` on <bw-card> and the seat/voter renderers decide where
   it appears; stock portraits and pre-overlay uploads carry their own baked
   frame and are never wrapped. */
.bw-framed { position: relative; display: inline-block; overflow: hidden; }
.bw-framed::after {
  content: ""; position: absolute; inset: -7.5%; pointer-events: none;
  background: url("/img/portrait-frame-v1.png") 0 0 / 100% 100% no-repeat;
}
.bwp-preview .bw-framed { border-radius: 4px; }
/* Show the whole ornament in the upload preview, just as on poker seats. */
.bwp-preview .bw-framed::after { inset: 0; }
.bwp-preview .bw-framed img { display: block; }
