/* ============================================================================
   BLOOM — commons/components/edit-mode.css
   Edit affordances for the OWNER/EDITOR record & page object editor.
   Load AFTER badges.css (it consumes badges.css CSS-variable tokens only).

   Purely visual. The JS (edit-mode.js) resolves the caller's role and shows /
   hides chrome, but the SERVER (RLS + my_edit_role() + the SECURITY DEFINER
   RPCs) is the real gate. Colors come only from badges.css tokens.

   Relationship to editable.js's injected styles: editable.js styles the
   site_content prose/pill editor (the floating .ed-* FAB + toolbar). THIS file
   styles the record/page OBJECT editor (sticky .editbar + .meta panel + dialog).
   The two are independent; class prefixes do not collide (.editbar / .meta /
   .em-* here vs .ed-* there). See the header of edit-mode.js.
   ============================================================================ */

/* --- editable fields are only interactive while the page is in edit mode --- */
[data-editing="on"] [data-edit-field]{
  outline:1.5px dashed var(--green-lite); outline-offset:4px; border-radius:6px;
}
[data-editing="on"] [data-edit-field]:hover{ background:var(--zone-green); }
[data-editing="on"] [data-edit-field][contenteditable="true"]:focus{
  outline:2px solid var(--teal); background:#fff;
}
[data-editing="on"] .edit-pencil{ display:inline-flex; }
.edit-pencil{ display:none; color:var(--green-lite); }
[data-editing="off"] .edit-hint{ display:none; }

/* --- dirty marker + save-draft button --- */
[data-dirty="true"] .editbar__save{ display:inline-flex; }
.editbar__save{ display:none; }

/* --- role-scoped visibility (JS sets data-role on the root) ---------------- */
/* Anything owner-only is removed from the layout for an editor. Belt and
   braces: the JS also disables the controls, and the server rejects the write. */
[data-role="editor"] [data-owner-only]{ display:none !important; }
/* Nothing shows until a role is resolved (data-role="" hides all edit chrome). */
[data-role=""] .editbar,
[data-role=""] .meta,
[data-role=""] [data-editor-banner]{ display:none !important; }

/* --- edit toolbar (sticky, dense edit-chrome) ------------------------------ */
.editbar{ position:sticky; top:0; z-index:20; background:var(--panel);
  border:1.5px solid var(--bar-green); border-radius:16px; box-shadow:0 6px 0 var(--shadow);
  padding:12px 16px; margin-bottom:18px; display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.editbar__label{ font-family:"Baloo 2",system-ui,sans-serif; font-weight:800; font-size:15px;
  color:var(--green-deep); display:inline-flex; align-items:center; gap:8px; }
.editbar__role{ font-family:"Nunito Sans",system-ui,sans-serif; font-weight:800; font-size:11px;
  letter-spacing:.06em; text-transform:uppercase; color:var(--ink-soft);
  background:var(--zone-green); border-radius:999px; padding:3px 10px; }
.editbar__spacer{ margin-left:auto; }
.editbar .btn[aria-pressed="true"]{ background:var(--bar-green); color:var(--green-deep); }

/* --- editor "your changes are reviewed" banner ----------------------------- */
.em-banner{ background:var(--zone-green); border:1.5px solid var(--bar-green);
  border-radius:14px; padding:12px 16px; margin-bottom:16px;
  font-family:"Nunito Sans",system-ui,sans-serif; font-size:14.5px; color:var(--ink);
  line-height:1.5; }
.em-banner[hidden]{ display:none; }

/* --- metadata panel (dense) ------------------------------------------------ */
.meta{ background:var(--panel); border:1.5px solid var(--bar-green); border-radius:20px;
  box-shadow:4px 5px 0 var(--zone-green); padding:18px 20px; }
.meta[hidden]{ display:none; }
.meta__head{ display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:6px; }
.meta__title{ font-family:"Baloo 2",system-ui,sans-serif; font-weight:800; font-size:16px; color:var(--green-deep); margin:0; }
.meta__row{ display:flex; flex-direction:column; gap:5px; margin-bottom:13px;
  font-family:"Nunito Sans",system-ui,sans-serif; font-weight:700; font-size:13px; color:var(--ink-soft); }
.meta__row select, .meta__row input[type="text"]{
  font-family:"Nunito Sans",system-ui,sans-serif; font-size:14.5px; font-weight:600; color:var(--ink);
  padding:8px 10px; border-radius:10px; border:1.5px solid var(--bar-green); background:#fff; max-width:100%; }
.meta__row select:focus, .meta__row input[type="text"]:focus{ outline:2px solid var(--teal); outline-offset:1px; }
.meta__ro{ display:flex; align-items:center; justify-content:space-between; gap:10px; padding:10px 0;
  border-top:1.5px solid var(--zone-green);
  font-family:"Nunito Sans",system-ui,sans-serif; font-weight:700; font-size:14px; color:var(--ink); }
.meta__ro input[type="checkbox"]{ width:19px; height:19px; accent-color:var(--teal); flex:none; cursor:pointer; }
.meta__lock{ display:inline-flex; align-items:center; gap:5px; font-size:11px; font-weight:800;
  font-family:"Nunito Sans",system-ui,sans-serif;
  color:var(--ink-soft); background:var(--bar-green); border-radius:999px; padding:3px 9px; }
.meta__lock[hidden]{ display:none; }
.meta__link{ display:inline-block; margin-top:6px; font-family:"Nunito Sans",system-ui,sans-serif;
  font-weight:700; font-size:14px; color:var(--green-deep); }

/* disabled (read-only for editors) */
.meta select:disabled, .meta input:disabled{ opacity:.62; cursor:not-allowed; background:#F5FAF6; }

/* danger zone */
.meta__danger{ margin-top:16px; padding-top:14px; border-top:1.5px solid var(--zone-green);
  display:flex; flex-wrap:wrap; gap:10px; align-items:center; }
.meta__danger-kick{ width:100%; font-family:"Nunito Sans",system-ui,sans-serif; font-weight:800;
  font-size:12px; letter-spacing:.06em; text-transform:uppercase; color:#A23B2D; margin:0 0 2px; }
.btn--danger{ background:#FBE6E2; color:#A23B2D; box-shadow:0 4px 0 rgba(162,59,45,.18); }
.btn--danger:hover{ background:#F6D3CC; }

/* --- accessible confirm dialog (archive / delete) -------------------------- */
.em-dialog{ border:none; border-radius:20px; padding:0; max-width:440px; width:calc(100vw - 32px);
  box-shadow:0 24px 60px rgba(18,81,58,.32); color:var(--ink); background:var(--panel); }
.em-dialog::backdrop{ background:rgba(18,39,28,.44); }
.em-dialog__body{ padding:22px 24px 20px; }
.em-dialog__title{ font-family:"Baloo 2",system-ui,sans-serif; font-weight:800; font-size:20px;
  color:var(--green-deep); margin:0 0 8px; }
.em-dialog__text{ font-family:"Nunito Sans",system-ui,sans-serif; font-size:15px; line-height:1.55;
  color:var(--ink-soft); margin:0 0 18px; }
.em-dialog__actions{ display:flex; justify-content:flex-end; gap:10px; flex-wrap:wrap; }

/* --- toast --------------------------------------------------------------- */
.em-toast{ position:fixed; left:50%; bottom:24px; transform:translateX(-50%); z-index:1001;
  font-family:"Nunito Sans",system-ui,sans-serif; font-weight:700; font-size:14px; color:#fff;
  background:var(--green-deep); border-radius:12px; padding:11px 18px;
  box-shadow:0 8px 24px rgba(18,81,58,.3); max-width:calc(100vw - 32px); }

/* ============================================================================
   Record editor panel (owner metadata + taxonomy backfill; editor suggestions).
   Self-contained subtree mounted by BLOOMEditMode.mountRecordEditor(). Uses
   badges.css tokens only. This subtree is edit-mode-managed ONLY (no editable.js
   data-edit attributes live inside it) — the one-scheme-per-element rule.
   ============================================================================ */
.em-panel{ background:var(--panel); border:2px solid var(--bar-green); border-radius:20px;
  box-shadow:4px 5px 0 var(--zone-green); padding:20px 22px; margin-top:20px; }
.em-panel__head{ display:flex; align-items:center; gap:12px; flex-wrap:wrap; }
.em-panel__kick{ font-family:"Nunito Sans",system-ui,sans-serif; font-weight:800; font-size:11.5px;
  letter-spacing:.08em; text-transform:uppercase; color:var(--gold); margin:0; width:100%; }
.em-panel__title{ font-family:"Baloo 2",system-ui,sans-serif; font-weight:800; font-size:20px;
  color:var(--green-deep); margin:0; }
.em-panel__toggle{ margin-left:auto; }
.em-panel__body{ margin-top:16px; display:flex; flex-direction:column; gap:22px; }
.em-panel__body[hidden]{ display:none; }

.em-sec__h{ font-family:"Baloo 2",system-ui,sans-serif; font-weight:800; font-size:16px;
  color:var(--green-deep); margin:0 0 4px; }

/* fields (labels + inputs) */
.em-field{ display:flex; flex-direction:column; gap:5px; margin-bottom:12px;
  font-family:"Nunito Sans",system-ui,sans-serif; font-weight:700; font-size:13px; color:var(--ink-soft); }
.em-field__lab{ font-weight:700; }
.em-field__in{ font-family:"Nunito Sans",system-ui,sans-serif; font-size:14.5px; font-weight:600; color:var(--ink);
  padding:9px 11px; border-radius:11px; border:1.5px solid var(--bar-green); background:#fff; max-width:100%; }
textarea.em-field__in{ min-height:80px; resize:vertical; line-height:1.5; }
.em-field__in:focus{ outline:2px solid var(--teal); outline-offset:1px; }

.em-ro{ display:flex; align-items:center; justify-content:space-between; gap:10px; padding:9px 0;
  border-top:1.5px solid var(--zone-green);
  font-family:"Nunito Sans",system-ui,sans-serif; font-weight:700; font-size:14px; color:var(--ink); cursor:pointer; }
.em-ro input[type="checkbox"]{ width:19px; height:19px; accent-color:var(--teal); flex:none; cursor:pointer; }

.em-metasec .btn, .em-tax .btn{ margin-top:8px; }

/* taxonomy chip pickers */
.em-tax__lead{ font-family:"Nunito Sans",system-ui,sans-serif; font-size:13.5px; color:var(--ink-soft);
  font-weight:600; line-height:1.5; margin:0 0 12px; }
.em-tax__group{ margin-bottom:14px; }
.em-tax__glabel{ display:block; font-family:"Baloo 2",system-ui,sans-serif; font-weight:800; font-size:14px;
  color:var(--ink); margin-bottom:7px; }
.em-chiprow{ display:flex; flex-wrap:wrap; gap:8px; }
.em-chip{ font-family:"Baloo 2",system-ui,sans-serif; font-weight:600; font-size:13.5px; color:var(--green-deep);
  background:#fff; border:1.5px solid var(--bar-green); border-radius:999px; padding:6px 14px; cursor:pointer;
  line-height:1.1; }
.em-chip:hover{ background:var(--zone-green); }
.em-chip.is-on, .em-chip[aria-pressed="true"]{ background:var(--green); border-color:var(--green); color:#fff; }
.em-chip:focus-visible{ outline:3px solid var(--teal); outline-offset:2px; }

/* objectives */
.em-obj{ margin-top:6px; }
.em-obj__list{ display:flex; flex-direction:column; gap:10px; margin:8px 0; }
.em-obj__row{ display:grid; grid-template-columns:1fr 190px auto; gap:10px; align-items:center; }
.em-obj__lvl{ max-width:100%; }
@media (max-width:640px){ .em-obj__row{ grid-template-columns:1fr; } }

/* danger zone */
.em-danger{ padding-top:14px; border-top:1.5px solid var(--zone-green); display:flex; flex-wrap:wrap; gap:10px; align-items:center; }
.em-danger__kick{ width:100%; font-family:"Nunito Sans",system-ui,sans-serif; font-weight:800; font-size:12px;
  letter-spacing:.06em; text-transform:uppercase; color:#A23B2D; margin:0 0 2px; }

/* --- reduced motion -------------------------------------------------------- */
@media (prefers-reduced-motion: reduce){
  .btn, .em-dialog{ transition:none !important; }
}
