/* The For Justice editor (assets/js/afj-editor.js): only ever loaded for
   the AFJ admin or the MSC. Takes the page's own colours: maroon on the
   For Justice pages, navy in the Admin Portal. */
:root {
  --afj-ed-ink: #201a1a;
  --afj-ed-accent: var(--green-700, #6e1f22);
  --afj-ed-gold: var(--gold, var(--gold-400, #c8a24a));
  --afj-ed-line: #d8cbb8;
  --afj-ed-paper: #fcf9f3;
  --afj-ed-curve: cubic-bezier(0.23, 1, 0.32, 1);
}

/* ── buttons on the page ── */
.afj-edit {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 34px; padding: 0.4rem 0.85rem;
  font: 600 0.8125rem/1.2 var(--font-body, system-ui, sans-serif);
  color: var(--afj-ed-accent); background: var(--afj-ed-paper);
  border: 1px solid var(--afj-ed-accent); border-radius: 0;
  cursor: pointer; text-decoration: none;
  transition: transform 120ms var(--afj-ed-curve), background-color 150ms ease, color 150ms ease;
}
.afj-edit:active { transform: scale(0.97); }
.afj-edit.is-strong { background: var(--afj-ed-gold); border-color: var(--afj-ed-gold); color: #2a0b0d; }
@media (hover: hover) and (pointer: fine) {
  .afj-edit:hover { background: var(--afj-ed-accent); color: #fff; }
  .afj-edit.is-strong:hover { filter: brightness(1.06); background: var(--afj-ed-gold); color: #2a0b0d; }
}
.afj-edit-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.75rem 0 1.25rem; }
.cat-head .afj-edit-row, .section-head .afj-edit-row { margin-bottom: 0; }
.rbook-caption .afj-edit, .lec-body .afj-edit, .statement > .afj-edit { margin-top: 0.6rem; align-self: flex-start; }
.m-item .afj-edit.on-photo { position: absolute; top: 8px; left: 8px; z-index: 2; }
.article-list .afj-edit { justify-self: start; margin: -0.5rem 0 1rem; }
.article > .afj-edit { margin-bottom: 1rem; }
.afj-edit-note { max-width: 46rem; margin: 0 0 1rem; padding: 0.75rem 0 0; border-top: 2px solid var(--afj-ed-accent); font-size: 0.9375rem; }

/* ── the bar along the bottom ── */
.afj-edit-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1003;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  min-height: 52px; padding: 0.4rem 16px;
  background: #1c0506; color: #f3ead9;
  border-top: 1px solid rgba(232, 196, 104, 0.4);
  font: 500 0.875rem/1.3 var(--font-body, system-ui, sans-serif);
}
.afj-edit-bar b { color: #e8c468; }
.afj-edit-bar-tools { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.afj-edit-bar .afj-edit { background: transparent; color: #f3ead9; border-color: rgba(243, 234, 217, 0.4); }
@media (hover: hover) and (pointer: fine) { .afj-edit-bar .afj-edit:hover { border-color: #e8c468; color: #e8c468; background: transparent; } }
.afj-editing body { padding-bottom: 52px; }
.afj-editing .to-top { bottom: 68px; }

/* ── the form panel, from the right ── */
.afj-ed-open { overflow: hidden; }
.afj-ed-back {
  position: fixed; inset: 0; z-index: 2100;
  display: flex; justify-content: flex-end;
  background: rgba(20, 8, 8, 0.45);
  transition: opacity 200ms ease;
}
@starting-style { .afj-ed-back { opacity: 0; } }
.afj-ed-panel {
  display: flex; flex-direction: column;
  width: min(540px, 100%); height: 100%;
  background: var(--afj-ed-paper); color: var(--afj-ed-ink);
  font-family: var(--font-body, system-ui, sans-serif);
  transition: transform 250ms var(--afj-ed-curve);
}
@starting-style { .afj-ed-panel { transform: translateX(40px); } }
@media (prefers-reduced-motion: reduce) { .afj-ed-back, .afj-ed-panel { transition: none; } }
.afj-ed-head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1rem 1.25rem; background: var(--afj-ed-accent); color: #fff;
}
.afj-ed-head h2 { margin: 0; font: 600 1.5rem/1.2 var(--font-head, var(--font-display, Georgia, serif)); color: #fff; }
.afj-ed-x { width: 40px; height: 40px; border: 0; background: none; color: #fff; font-size: 1.6rem; line-height: 1; cursor: pointer; }
.afj-ed-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 1.25rem; display: grid; gap: 1.25rem; align-content: start; }
.afj-ed-field { display: grid; gap: 0.3rem; }
.afj-ed-field > label, .afj-ed-label { font-size: 0.875rem; font-weight: 600; }
.afj-ed-field em { font-style: normal; font-weight: 500; color: var(--afj-ed-accent); font-size: 0.8125rem; margin-left: 0.25rem; }
.afj-ed-field input:not([type=checkbox]):not([type=file]), .afj-ed-field select {
  width: 100%; min-height: 42px; padding: 0.45rem 0;
  font-weight: 400; font-size: 1rem; line-height: 1.4; font-family: inherit; color: var(--afj-ed-ink);
  background: none; border: 0; border-bottom: 1px solid var(--afj-ed-ink); border-radius: 0;
}
.afj-ed-field textarea {
  width: 100%; padding: 0.6rem 0.75rem; resize: vertical;
  font-weight: 400; font-size: 0.9375rem; line-height: 1.6; font-family: inherit; color: var(--afj-ed-ink);
  background: #fff; border: 1px solid var(--afj-ed-ink); border-radius: 0;
}
.afj-ed-field input:focus, .afj-ed-field select:focus, .afj-ed-field textarea:focus {
  outline: none; border-color: var(--afj-ed-gold); box-shadow: inset 0 -1px 0 var(--afj-ed-gold);
}
.afj-ed-help { font-size: 0.8125rem; color: #5e524c; line-height: 1.45; }
.afj-ed-check label { display: flex; align-items: center; gap: 0.5rem; font-weight: 600; font-size: 0.9375rem; }
.afj-ed-check input { width: 18px; height: 18px; accent-color: var(--afj-ed-accent); }
.afj-ed-preview img { max-width: 100%; max-height: 220px; width: auto; display: block; border: 1px solid var(--afj-ed-line); }
.afj-ed-picks { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.afj-ed-status { font-size: 0.8125rem; color: var(--afj-ed-accent); font-weight: 600; }
.afj-ed-foot { padding: 1rem 1.25rem; border-top: 1px solid var(--afj-ed-line); background: var(--afj-ed-paper); }
.afj-ed-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.afj-ed-error { margin: 0 0 0.75rem; padding-top: 0.6rem; border-top: 2px solid #a3191f; color: #a3191f; font-weight: 600; font-size: 0.9375rem; }
.afj-ed-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 42px; padding: 0.6rem 1.2rem;
  font-weight: 600; font-size: 0.9375rem; line-height: 1.2; font-family: inherit; color: var(--afj-ed-ink);
  background: transparent; border: 1px solid var(--afj-ed-ink); border-radius: 0; cursor: pointer;
  transition: transform 120ms var(--afj-ed-curve), background-color 150ms ease;
}
.afj-ed-btn:active { transform: scale(0.97); }
.afj-ed-btn.is-primary { background: var(--afj-ed-accent); border-color: var(--afj-ed-accent); color: #fff; }
.afj-ed-btn.is-danger { margin-left: auto; color: #a3191f; border-color: #a3191f; }
.afj-ed-btn:disabled { opacity: 0.6; cursor: default; }
@media (pointer: coarse) { .afj-ed-field input, .afj-ed-field textarea, .afj-ed-field select { font-size: 16px !important; } }

/* ── the Admin Portal's For Justice section ── */
.afj-dash-tabs { display: flex; flex-wrap: wrap; gap: 1.25rem; margin: 0 0 1.5rem; border-bottom: 1px solid var(--afj-ed-line); }
.afj-dash-tabs button {
  padding: 0.6rem 0; border: 0; border-bottom: 2px solid transparent; background: none;
  font-weight: 600; font-size: 0.9375rem; line-height: 1.2; font-family: inherit; color: var(--color-text-muted, #5e524c); cursor: pointer;
}
.afj-dash-tabs button[aria-selected="true"] { color: var(--color-text, #201a1a); border-bottom-color: var(--afj-ed-gold); }
.afj-dash-group { margin: 0 0 2rem; }
.afj-dash-group-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--color-text, #201a1a); }
.afj-dash-group-head h3 { margin: 0 auto 0 0; font-size: 1.25rem; }
.afj-dash-row { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; gap: 0.9rem; align-items: center; padding: 0.6rem 0; border-bottom: 1px solid var(--afj-ed-line); }
.afj-dash-row img, .afj-dash-thumb { width: 48px; height: 48px; object-fit: cover; background: #e9e2d6; }
.afj-dash-row b { display: block; font-weight: 600; }
.afj-dash-row small { color: var(--color-text-muted, #5e524c); }
.afj-dash-chip { display: inline-block; margin-left: 0.4rem; padding: 0.05rem 0.4rem; font-size: 0.75rem; font-weight: 600; border: 1px solid currentColor; }
.afj-dash-intro { max-width: 46rem; color: var(--color-text-muted, #5e524c); margin: 0 0 1.25rem; }

.afj-edit.on-hero { position: absolute; right: 16px; bottom: 16px; z-index: 3; }
.afj-ed-note { margin: 0; padding-top: 0.6rem; border-top: 1px solid var(--afj-ed-line); }
.afj-dash-row .afj-dash-key { font-family: ui-monospace, monospace; font-size: 0.75rem; }
