/* WalkAtlas Stage 5H — Group creation, settings and administration.
   Load after social-stage5g.css. Add data-wa-social-5h="settings" or
   "create" to the specific real Group surface (including the legacy entry
   point if used). Hooks are presentation only, never permission checks.
   Preserve Stage 5F shell scrolling, managed appearance dialogs and map. */
[data-wa-social-5h] {
  --h5-ink: var(--f5-ink, #173c30);
  --h5-text: var(--f5-text, #263d35);
  --h5-muted: var(--f5-muted, #52665c);
  --h5-green: var(--f5-green, #236b43);
  --h5-dark: var(--f5-dark, #175333);
  --h5-sage: var(--f5-sage, #edf5ed);
  --h5-bg: var(--f5-bg, #f5f7f3);
  --h5-paper: #fff;
  --h5-line: #dce5dc;
  --h5-control: #849b89;
  --h5-focus: #176f9f;
  --h5-danger: #8d2438;
  --h5-radius: 14px;
  display: grid; align-content: start; gap: 14px;
  width: 100%; max-width: 1080px; min-width: 0; margin-inline: auto;
  padding: clamp(8px, 2%, 20px); color: var(--h5-text); text-align: start;
  container: wa-h5 / inline-size;
}
[data-wa-social-5h="create"] { max-width: 820px; }
[data-wa-social-5h], [data-wa-social-5h] *,
[data-wa-social-5h] *::before, [data-wa-social-5h] *::after { box-sizing: border-box; }
[data-wa-social-5h] [hidden] { display: none !important; }
[data-wa-social-5h] :is(h2,h3,h4,p) { margin: 0; overflow-wrap: anywhere; }
[data-wa-social-5h] :is(button,input,select,textarea,a,summary):focus-visible {
  outline: 3px solid var(--h5-focus); outline-offset: 2px;
}
[data-wa-social-5h] :is(.wa-h5-heading,.wa-h5-stack,.wa-h5-panel,.wa-h5-field) {
  display: grid; align-content: start; gap: 10px; min-width: 0;
}
[data-wa-social-5h] .wa-h5-heading { gap: 5px; }
[data-wa-social-5h] .wa-h5-title {
  color: var(--h5-ink); font-size: clamp(1.2rem, 1.05rem + .8cqi, 1.65rem);
  line-height: 1.3; font-weight: 750;
}
[data-wa-social-5h] .wa-h5-section-title { color: var(--h5-ink); font-size: 1.05rem; line-height: 1.35; font-weight: 720; }
[data-wa-social-5h] :is(.wa-h5-meta,.wa-h5-description,.wa-h5-hint) {
  color: var(--h5-muted); font-size: .875rem; line-height: 1.5; overflow-wrap: anywhere;
}
[data-wa-social-5h] .wa-h5-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
[data-wa-social-5h] .wa-h5-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
[data-wa-social-5h] .wa-h5-actions > * { flex: 1 1 8rem; min-width: 0; }
[data-wa-social-5h] :is(.wa-h5-button,.wa-h5-nav-button,.wa-h5-disclosure > summary) {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-width: 0; max-width: 100%; min-height: 44px; margin: 0; padding: 9px 12px;
  border: 1px solid var(--h5-control); border-radius: 10px; background: var(--h5-paper);
  color: var(--h5-ink); box-shadow: none; font: inherit; font-size: .875rem;
  line-height: 1.35; font-weight: 650; text-align: center; text-decoration: none;
  white-space: normal; overflow-wrap: anywhere; cursor: pointer;
}
[data-wa-social-5h] .wa-h5-button.is-primary { background: var(--h5-green); color: #fff; border-color: var(--h5-green); }
[data-wa-social-5h] .wa-h5-button.is-danger { background: #fff5f5; color: var(--h5-danger); border-color: #bd8290; }
[data-wa-social-5h] .wa-h5-button.is-quiet { background: transparent; border-color: transparent; justify-content: flex-start; }
[data-wa-social-5h] :is(button:disabled,[aria-disabled="true"]) { opacity: .65; cursor: not-allowed; }
[data-wa-social-5h] .wa-h5-icon { width: 20px; height: 20px; flex: none; }
[data-wa-social-5h] .wa-h5-card {
  display: grid; align-content: start; gap: 12px; min-width: 0;
  padding: clamp(12px, 2.5cqi, 20px); border: 1px solid var(--h5-line);
  background: var(--h5-paper); border-radius: var(--h5-radius);
}
/* Settings directory on mobile; separate navigation pane on wide panels. */
[data-wa-social-5h] .wa-h5-layout { display: grid; grid-template-columns: minmax(0,1fr); align-items: start; gap: 14px; min-width: 0; }
[data-wa-social-5h] .wa-h5-directory { display: grid; gap: 6px; min-width: 0; }
[data-wa-social-5h] .wa-h5-nav-button { width: 100%; justify-content: flex-start; text-align: start; min-height: 58px; border-color: var(--h5-line); padding: 11px; }
[data-wa-social-5h] .wa-h5-nav-copy { flex: 1 1 auto; min-width: 0; display: grid; gap: 3px; }
[data-wa-social-5h] .wa-h5-nav-copy strong { font-size: .94rem; line-height: 1.35; overflow-wrap: anywhere; }
[data-wa-social-5h] .wa-h5-nav-copy small { color: var(--h5-muted); font-weight: 400; font-size: .8rem; line-height: 1.4; }
[data-wa-social-5h] .wa-h5-nav-button[aria-current="page"] { border-color: var(--h5-green); background: var(--h5-sage); }
[data-wa-social-5h] .wa-h5-chevron { margin-inline-start: auto; flex: none; color: var(--h5-muted); }
[data-wa-social-5h] .wa-h5-panel { gap: 14px; }
/* JS controls visible/inert panels and focus; CSS never exposes denied panels. */
[data-wa-social-5h="settings"][data-settings-screen="section"] .wa-h5-directory { display: none; }
[data-wa-social-5h="settings"][data-settings-screen="directory"] .wa-h5-panel { display: none; }
[data-wa-social-5h] .wa-h5-section-back { justify-self: start; }
/* Form labels and controls. Native radio/checkbox semantics retained. */
[data-wa-social-5h] .wa-h5-field { gap: 6px; }
[data-wa-social-5h] .wa-h5-field > :is(label,span) { font-size: .9rem; font-weight: 650; color: var(--h5-ink); text-align: start; }
[data-wa-social-5h] :is(.wa-h5-field,.wa-h5-search) :is(input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),select,textarea) {
  width: 100%; min-width: 0; min-height: 46px; padding: 10px 12px;
  background: var(--h5-paper); color: var(--h5-ink); border: 1px solid var(--h5-control);
  border-radius: 10px; font: inherit; font-size: 1rem; line-height: 1.45; text-align: start; box-shadow: none;
}
[data-wa-social-5h] .wa-h5-field textarea { min-height: 112px; resize: vertical; }
[data-wa-social-5h] .wa-h5-field [aria-invalid="true"] { border-color: var(--h5-danger); }
[data-wa-social-5h] .wa-h5-error { color: var(--h5-danger); font-size: .875rem; line-height: 1.45; overflow-wrap: anywhere; }
[data-wa-social-5h] .wa-h5-options { display: grid; gap: 8px; min-width: 0; padding: 0; margin: 0; border: 0; }
[data-wa-social-5h] .wa-h5-options legend { padding: 0; margin-block-end: 8px; font-weight: 700; }
[data-wa-social-5h] .wa-h5-option { display: flex; align-items: flex-start; gap: 10px; min-height: 52px; padding: 12px; border: 1px solid var(--h5-control); border-radius: 12px; background: var(--h5-paper); cursor: pointer; }
[data-wa-social-5h] .wa-h5-option > input { flex: none; width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--h5-green); }
[data-wa-social-5h] .wa-h5-option > span { display: grid; gap: 4px; min-width: 0; overflow-wrap: anywhere; }
[data-wa-social-5h] .wa-h5-option:has(input:checked) { border-color: var(--h5-green); background: var(--h5-sage); }
[data-wa-social-5h] .wa-h5-option:focus-within { outline: 2px solid var(--h5-focus); outline-offset: 2px; }
[data-wa-social-5h] .wa-h5-search { display: grid; gap: 8px; grid-template-columns: minmax(0,1fr); align-items: end; min-width: 0; }
[data-wa-social-5h] .wa-h5-location { display: grid; gap: 5px; padding: 12px; border: 1px solid var(--h5-line); border-radius: 12px; background: var(--h5-sage); min-width: 0; }
[data-wa-social-5h] .wa-h5-location strong { overflow-wrap: anywhere; }
[data-wa-social-5h] .wa-h5-note { padding: 11px 12px; border: 1px solid var(--h5-line); border-radius: 10px; background: var(--h5-bg); color: var(--h5-muted); font-size: .875rem; line-height: 1.5; overflow-wrap: anywhere; }
[data-wa-social-5h] .wa-h5-note.is-warning { background: #fff5db; color: #73500e; border-color: #e0c58c; }
[data-wa-social-5h] .wa-h5-note.is-error { background: #fff5f5; color: var(--h5-danger); border-color: #e6b9c3; }
[data-wa-social-5h] .wa-h5-note.is-success { background: var(--h5-sage); color: var(--h5-dark); border-color: #afc8ad; }
[data-wa-social-5h] .wa-h5-save { display: grid; gap: 8px; padding-block-start: 12px; border-block-start: 1px solid var(--h5-line); }
/* Appearance previews use existing authorised image sources; no CSS URL fetches. */
[data-wa-social-5h] .wa-h5-appearance-preview { display: grid; gap: 10px; min-width: 0; }
[data-wa-social-5h] .wa-h5-cover { width: 100%; aspect-ratio: 3 / 1; object-fit: cover; background: var(--h5-sage); border-radius: 12px; }
[data-wa-social-5h] .wa-h5-avatar { width: 44px; height: 44px; flex: none; border: 1px solid var(--h5-line); border-radius: 50%; object-fit: cover; display: grid; place-items: center; background: var(--h5-sage); color: var(--h5-dark); font-weight: 750; }
[data-wa-social-5h] .wa-h5-person { display: flex; align-items: center; gap: 10px; min-width: 0; }
[data-wa-social-5h] .wa-h5-person-copy { display: grid; gap: 3px; min-width: 0; flex: 1; overflow-wrap: anywhere; }
[data-wa-social-5h] .wa-h5-person-copy strong { color: var(--h5-ink); font-weight: 700; line-height: 1.35; }
[data-wa-social-5h] .wa-h5-people { display: grid; gap: 8px; min-width: 0; }
[data-wa-social-5h] .wa-h5-person-row { display: grid; gap: 10px; align-items: center; padding: 11px; border: 1px solid var(--h5-line); border-radius: 12px; background: var(--h5-paper); min-width: 0; }
[data-wa-social-5h] .wa-h5-badges { display: flex; flex-wrap: wrap; gap: 5px; min-width: 0; }
[data-wa-social-5h] .wa-h5-badge { display: inline-flex; align-items: center; width: fit-content; max-width: 100%; padding: 4px 8px; border: 1px solid var(--h5-line); border-radius: 999px; background: var(--h5-bg); color: var(--h5-muted); font-size: .78rem; line-height: 1.35; font-weight: 650; overflow-wrap: anywhere; }
[data-wa-social-5h] .wa-h5-badge.is-owner { background: var(--h5-sage); color: var(--h5-dark); border-color: #afc8ad; }
[data-wa-social-5h] .wa-h5-badge.is-admin { background: #edf3fa; color: #305a83; border-color: #bdcfe1; }
[data-wa-social-5h] .wa-h5-badge.is-pending { background: #fff5db; color: #73500e; border-color: #e0c58c; }
[data-wa-social-5h] .wa-h5-disclosure { min-width: 0; border: 1px solid var(--h5-line); border-radius: 12px; background: var(--h5-paper); }
[data-wa-social-5h] .wa-h5-disclosure > summary { width: 100%; justify-content: space-between; border: 0; text-align: start; list-style: none; }
[data-wa-social-5h] .wa-h5-disclosure > summary::-webkit-details-marker { display: none; }
[data-wa-social-5h] .wa-h5-disclosure[open] > summary { border-block-end: 1px solid var(--h5-line); border-radius: 12px 12px 0 0; }
[data-wa-social-5h] .wa-h5-disclosure-body { display: grid; gap: 10px; min-width: 0; padding: 12px; }
[data-wa-social-5h] .wa-h5-empty { padding: 14px; border: 1px dashed var(--h5-control); border-radius: 10px; color: var(--h5-muted); font-size: .875rem; line-height: 1.5; overflow-wrap: anywhere; }
[data-wa-social-5h] .wa-h5-danger { border-color: #e6b9c3; }
[data-wa-social-5h] .wa-h5-danger .wa-h5-section-title { color: var(--h5-danger); }
/* Create: one form, required details first, optional items below. */
[data-wa-social-5h] .wa-h5-create-form { display: grid; align-content: start; gap: 14px; min-width: 0; }
[data-wa-social-5h] .wa-h5-create-summary { display: grid; gap: 6px; min-width: 0; padding: 12px; background: var(--h5-sage); border: 1px solid #afc8ad; border-radius: 12px; }
@container wa-h5 (min-width: 450px) {
  [data-wa-social-5h] .wa-h5-search { grid-template-columns: minmax(0,1fr) auto; }
  [data-wa-social-5h] .wa-h5-options.is-two { grid-template-columns: repeat(2,minmax(0,1fr)); }
  [data-wa-social-5h] .wa-h5-actions > * { flex: 0 1 auto; }
  [data-wa-social-5h] .wa-h5-save { grid-template-columns: minmax(0,1fr) auto; align-items: center; }
}
@container wa-h5 (min-width: 720px) {
  [data-wa-social-5h] .wa-h5-layout { grid-template-columns: minmax(220px, .7fr) minmax(0, 1.65fr); gap: 18px; }
  [data-wa-social-5h="settings"]:is([data-settings-screen="directory"],[data-settings-screen="section"]) .wa-h5-directory { display: grid; }
  [data-wa-social-5h="settings"]:is([data-settings-screen="directory"],[data-settings-screen="section"]) .wa-h5-panel { display: grid; }
  [data-wa-social-5h] .wa-h5-section-back { display: none; }
  [data-wa-social-5h] .wa-h5-person-row { grid-template-columns: minmax(0,1fr) auto; }
}
/* Stage 5G carry-forward: never break a metric name within the word.
   Use the existing wa-g5 container, not the full viewport. At high zoom
   auto-fit may reduce the number of columns further. */
#socialPanelBody [data-wa-social-5g="progress"][data-stage5g-compare] .wa-g5-segments[data-options="4"] {
  grid-template-columns: repeat(auto-fit,minmax(min(100%, 8em),1fr));
}
#socialPanelBody [data-wa-social-5g="progress"][data-stage5g-compare] .wa-g5-segment {
  overflow-wrap: normal; word-break: normal; hyphens: none; white-space: normal;
}
@container wa-g5 (max-width: 540px) {
  #socialPanelBody [data-wa-social-5g="progress"][data-stage5g-compare] .wa-g5-segments[data-options="4"] {
    grid-template-columns: repeat(2,minmax(0,1fr));
  }
}
@container wa-g5 (max-width: 280px) {
  #socialPanelBody [data-wa-social-5g="progress"][data-stage5g-compare] .wa-g5-segments[data-options="4"] { grid-template-columns: minmax(0,1fr); }
}
/* For 200% text and unusually narrow panels: apply data-large-text only
   when measured text no longer fits; don't clip or truncate metric names. */
#socialPanelBody [data-stage5g-compare][data-large-text="true"] .wa-g5-segments[data-options="4"] { grid-template-columns: minmax(0,1fr); }
@media (prefers-reduced-motion: reduce) {
  [data-wa-social-5h] *, [data-wa-social-5h] *::before, [data-wa-social-5h] *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Group map selection uses the existing map and a single cancel control. */
.wa-h5-map-cancel {
  position: fixed; inset: max(72px, env(safe-area-inset-top)) 12px auto auto; z-index: 99999;
  color: #173c30; background: #fff; border: 1px solid #849b89; border-radius: 10px;
  min-height: 44px; padding: 8px 12px; font: inherit;
}
#socialDropdown #socialPanelBody [data-wa-social-5h] :is(button.wa-h5-button,button.wa-h5-nav-button) {
  background: var(--h5-paper) !important;
}
#socialDropdown #socialPanelBody [data-wa-social-5h] button.wa-h5-button.is-primary {
  background: var(--h5-green) !important; color: #fff;
}
#socialDropdown #socialPanelBody [data-wa-social-5h] button.wa-h5-nav-button[aria-current="page"] {
  background: var(--h5-sage) !important;
}
#socialDropdown #socialPanelBody [data-wa-social-5h] button.wa-h5-button.is-danger {
  background: #fff5f5 !important;
}
[data-stage5h-ownership-notice]:empty { display: none; }

/* Match legacy Social Hub specificity on the opted-in panels. */
#socialDropdown #socialPanelBody [data-wa-social-5h] .wa-h5-nav-button {
  text-align: start !important; justify-content: flex-start !important; border-radius: 10px !important;
}
#socialDropdown #socialPanelBody [data-wa-social-5h="settings"][data-h5-wide="true"] .wa-h5-section-back {
  display: none !important;
}
#socialDropdown #socialPanelBody [data-wa-social-5h="create"] form.wa-h5-create-form {
  margin: 0; padding: 0; border: 0; background: transparent; box-shadow: none;
}
#socialPanelBody [data-stage5g-compare][data-h5-metrics="4"] .wa-g5-segments[data-options="4"] {
  grid-template-columns: repeat(4,minmax(0,1fr));
}
#socialPanelBody [data-stage5g-compare][data-h5-metrics="2"] .wa-g5-segments[data-options="4"] {
  grid-template-columns: repeat(2,minmax(0,1fr));
}
#socialPanelBody [data-stage5g-compare][data-h5-metrics="1"] .wa-g5-segments[data-options="4"] {
  grid-template-columns: minmax(0,1fr);
}
