/* DupeEats · community.css (A5): form parts shared with submit.css, photo picker,
   gallery dialog, photo form, report dialog. :root tokens of main.css only. Mobile first.
   A11: loads on intent on the recipe, debate, drop and cook pages (app.js loader); a normal
   stylesheet on /submit-a-dupe/. The parts visible before any tap (gallery grid, credits,
   report links, rating-block links, byline, photo credit, cook page) live in
   community-base.css, a head stylesheet wherever this file loads on intent. */

/* ---------- form parts ---------- */
.sf-field { display: grid; gap: var(--s-2); margin: 0; padding: 0; border: 0; min-width: 0; }
.sf-label { padding: 0; font-size: var(--fs-sm); font-weight: 700; color: var(--ink); }
.sf-optional { font-weight: 400; color: var(--muted); }
.sf-input {
  width: 100%; min-height: 48px; padding: 0 var(--s-4); border: 1px solid var(--control); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink); font: inherit; transition: border-color 160ms ease, box-shadow 160ms ease;
}
.sf-textarea { padding: var(--s-3) var(--s-4); line-height: 1.5; resize: vertical; }
.sf-input::placeholder { color: var(--muted); }
.sf-input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.sf-select {
  appearance: none; -webkit-appearance: none; padding-right: 40px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23484841' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center / 18px;
}
.sf-hint { font-size: var(--fs-sm); color: var(--muted); }
.sf-hint .text-link { font-size: inherit; }
.sf-hint--row { display: flex; justify-content: space-between; gap: var(--s-3); }
.sf-count { flex: none; font-variant-numeric: tabular-nums; }
.sf-error { font-size: var(--fs-sm); font-weight: 600; color: oklch(42% 0.17 30); }
.has-error > .sf-input, .has-error .sf-input[aria-invalid], .sf-input[aria-invalid="true"] { border-color: oklch(48% 0.18 30); box-shadow: 0 0 0 1px oklch(48% 0.18 30); }
/* A11: keep focus visible on a field marked invalid (WCAG 2.4.7). */
.sf-input[aria-invalid="true"]:focus, .has-error .sf-input:focus { box-shadow: 0 0 0 1px oklch(48% 0.18 30), 0 0 0 3px var(--surface), 0 0 0 5px var(--cobalt); }
.is-tip .sf-error { color: var(--ink-2); font-weight: 400; }
.sf-choices { display: grid; gap: var(--s-2); }
.sf-choice, .sf-level { position: relative; display: block; cursor: pointer; }
.sf-choice input, .sf-level input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.sf-choice span, .sf-level > span {
  display: flex; align-items: center; gap: var(--s-3); min-height: 48px; padding: var(--s-2) var(--s-4);
  border-radius: var(--r-sm); box-shadow: inset 0 0 0 1px var(--line-strong); background: var(--surface);
  font-size: var(--fs-sm); font-weight: 600; line-height: 1.3; transition: box-shadow 160ms ease, background-color 160ms ease;
}
.sf-choice span::before { content: ""; flex: none; width: 20px; height: 20px; border-radius: 50%; box-shadow: inset 0 0 0 2px var(--line-strong); background: var(--surface); }
.sf-choice:hover span, .sf-level:hover > span { box-shadow: inset 0 0 0 2px var(--ink); }
.sf-choice input:checked + span { box-shadow: inset 0 0 0 2px var(--ink); }
.sf-choice input:checked + span::before { box-shadow: inset 0 0 0 6px var(--ink); }
.sf-choice input:focus-visible + span, .sf-level input:focus-visible + span { box-shadow: inset 0 0 0 2px var(--ink), var(--ring); }
.sf-level-list { display: grid; gap: var(--s-2); }
.sf-level__check { display: grid; place-items: center; flex: none; width: 22px; height: 22px; border-radius: 50%; box-shadow: inset 0 0 0 2px var(--line-strong); color: transparent; }
.sf-level input:checked + span { background: var(--lime); box-shadow: inset 0 0 0 2px var(--ink); }
.sf-level input:checked + span .sf-level__check { background: var(--ink); color: var(--lime); box-shadow: none; }
.has-error .sf-level > span { box-shadow: inset 0 0 0 1px oklch(48% 0.18 30); }
.sf-consents { display: grid; gap: var(--s-3); }
.sf-check { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: var(--s-1) var(--s-3); align-items: start; }
.sf-check input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--ink); }
.sf-check label { font-size: var(--fs-sm); line-height: 1.45; cursor: pointer; }
.sf-check > :not(input):not(label) { grid-column: 2; }
.sf-social { display: grid; grid-template-columns: minmax(0, 9fr) minmax(0, 11fr); gap: var(--s-2); }
.sf-at { position: relative; }
.sf-at > span { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 600; }
.sf-at .sf-input { padding-left: 30px; }
.sf-trap { position: absolute !important; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.form-status:empty { display: none; }
.form-status { font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--sunken); color: var(--ink); }
.license summary { cursor: pointer; color: var(--cobalt); font-size: var(--fs-sm); font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.license-draft { display: inline-block; margin: var(--s-1) 0 var(--s-2); padding: 2px var(--s-2); border-radius: 4px; background: var(--cobalt-soft); color: var(--cobalt); font-size: var(--fs-xs); font-weight: 700; }
.license-text { font-size: var(--fs-sm); color: var(--ink-2); max-height: 260px; overflow: auto; padding-right: var(--s-2); padding-bottom: var(--s-3); }
.license .panel-note { margin-top: 0; padding-top: var(--s-2); border-top: 1px solid var(--line); }
.license-text p + p { margin-top: var(--s-2); }

/* ---------- photo picker ---------- */
.ph-picker { display: grid; gap: var(--s-2); }
.ph-add {
  display: flex; align-items: center; gap: var(--s-3); min-height: 72px; padding: var(--s-3) var(--s-4);
  border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface); cursor: pointer; transition: border-color 160ms ease;
}
.ph-add:hover { border-color: var(--ink); }
.ph-add:focus-within { box-shadow: var(--ring); }
.ph-add[hidden] { display: none; }
.ph-add__icon { display: grid; place-items: center; flex: none; width: 48px; height: 48px; border-radius: 50%; background: var(--lime); color: var(--ink); }
.ph-add__text { display: grid; line-height: 1.3; }
.ph-add__text span { font-size: var(--fs-sm); color: var(--muted); }
.has-error:not(.is-tip) .ph-add { border-color: oklch(48% 0.18 30); }
.ph-list { display: grid; gap: var(--s-2); }
.ph { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: var(--s-1) var(--s-3); align-items: center; padding: var(--s-2); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.ph-img { position: relative; grid-row: span 2; width: 64px; height: 64px; border-radius: var(--r-sm); overflow: hidden; background: var(--sunken) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237a7a70' stroke-width='1.6'%3E%3Cpath d='M4 8h3l2-3h6l2 3h3v11H4zM12 17a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7Z'/%3E%3C/svg%3E") no-repeat center / 28px; }
.ph-img img { width: 100%; height: 100%; object-fit: cover; }
.ph[data-state="uploading"] .ph-img img { opacity: 0.55; }
.ph-ring {
  position: absolute; inset: 14px; border-radius: 50%;
  background: conic-gradient(var(--ink) calc(var(--p, 0) * 1%), oklch(99.5% 0.002 110 / 0.7) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent 62%, #000 64%); mask: radial-gradient(farthest-side, transparent 62%, #000 64%);
}
.ph-status { font-size: var(--fs-sm); font-weight: 700; font-variant-numeric: tabular-nums; }
.ph:first-child .ph-status { color: var(--ink); }
.ph[data-state="error"] .ph-status { color: oklch(42% 0.17 30); font-weight: 600; }
.ph-acts { display: flex; flex-wrap: wrap; gap: 0 var(--s-3); }
.ph-btn { min-height: 44px; margin-block: -8px; padding: 0; border: 0; background: none; color: var(--cobalt); font-size: var(--fs-sm); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }


/* dialogs: bottom sheet on phones, centred panel from 761px */
.cg-dialog, .sheet {
  width: 100%; max-width: 100%; max-height: 92dvh; margin: auto 0 0; padding: 0; border: 0; border-radius: var(--r-md) var(--r-md) 0 0;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-pop); overflow: auto; overscroll-behavior: contain;
}
.cg-dialog::backdrop, .sheet::backdrop { background: oklch(20% 0.01 105 / 0.6); }
.cg-dialog[open], .sheet[open] { animation: de-sheet 240ms var(--ease-out); }
@keyframes de-sheet { from { transform: translateY(24px); opacity: 0; } }
.cg-dialog__bar, .sheet-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-3) var(--s-2) var(--s-3) var(--s-5); border-bottom: 1px solid var(--line); }
.cg-dialog__title, .sheet-head h2 { font-size: var(--fs-base); font-weight: 700; }
.cg-dialog__title:focus, .sheet-head h2:focus { box-shadow: none; }
.sheet-close { display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: var(--r-sm); background: none; color: var(--ink-2); }
.sheet-close:hover { background: var(--sunken); color: var(--ink); }
.cg-dialog__fig { margin: 0; }
.cg-dialog__fig img { width: 100%; max-height: 62dvh; object-fit: contain; background: var(--sunken); }
.cg-dialog__meta { display: grid; gap: var(--s-2); padding: var(--s-4) var(--s-5) 0; }
.cg-dialog__caption:empty { display: none; }
.cg-dialog__caption { font-size: var(--fs-md); line-height: 1.4; }
.cg-dialog__by { display: flex; align-items: center; gap: var(--s-1); color: var(--ink-2); }
.cg-dialog__row { display: flex; align-items: center; gap: var(--s-3); }
.cg-dialog__nav { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); padding: var(--s-4) var(--s-5) max(var(--s-5), env(safe-area-inset-bottom)); }
.cg-dialog__nav .report-link { margin-left: auto; }
.cg-flip { display: inline-flex; transform: rotate(180deg); }
.sheet-body { display: grid; gap: var(--s-5); padding: var(--s-5); }
.sheet-foot { display: flex; flex-wrap: wrap; gap: var(--s-2); padding: 0 var(--s-5) max(var(--s-5), env(safe-area-inset-bottom)); }
.report-copy { display: grid; gap: var(--s-4); }
.report-copy[hidden], [data-copyright][hidden] { display: none; }
.report-ok { padding: var(--s-4) var(--s-5) var(--s-5); font-weight: 700; }
.report-ok:focus { box-shadow: none; }
.report-inline .sheet-head { padding-left: 0; border: 0; }
.report-inline .sheet-head h2 { font-size: var(--fs-lg); }
.report-inline .sheet-body, .report-inline .sheet-foot { padding-inline: 0; }

/* ---------- photo form ---------- */
.photo-form { display: grid; gap: var(--s-5); max-width: 720px; margin-top: var(--s-5); padding: var(--s-5); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.photo-form[hidden], .pf-done[hidden], .photo-form [hidden], .sheet [hidden], .report-inline [hidden] { display: none; }
.pf-head h3 { font-size: var(--fs-lg); }
.pf-head h3:focus { box-shadow: none; }
.pf-head .panel-note { margin-top: var(--s-1); }
.pf-about { display: grid; gap: var(--s-4); padding-top: var(--s-5); border-top: 1px solid var(--line); }
.pf-about__title { font-size: var(--fs-base); }
.pf-done { display: flex; gap: var(--s-3); align-items: flex-start; max-width: 720px; margin-top: var(--s-5); padding: var(--s-5); border-radius: var(--r-md); background: var(--bg); font-weight: 600; }
.pf-done p:focus { box-shadow: none; }
.sf-done__icon { display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 50%; background: var(--lime); color: var(--ink); }


@media (min-width: 761px) {
  .sf-level-list { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .sf-level > span { flex-direction: column; justify-content: center; min-height: 76px; text-align: center; gap: 6px; }
  .cg-dialog, .sheet { width: min(560px, calc(100vw - 48px)); margin: auto; border-radius: var(--r-md); max-height: 90dvh; }
  .cg-dialog { width: min(960px, calc(100vw - 48px)); }
  .photo-form { padding: var(--s-6); }
}
@media (prefers-reduced-motion: reduce) {
  .cg-dialog[open], .sheet[open] { animation: none; }
  .sf-input, .ph-add { transition: none; }
}
