/* =========================================
   FORM EDITOR — the Registration Form Editor modal (epic 0035 §4).
   Google-Forms-style: a full-screen panel with one scrolling canvas of
   cards (form header → sections → add section). Prefix: fe-
   ========================================= */

/* Same panel geometry as the other large modals (scheduler, playoff editor). */
.fe {
  position: relative;
  background: var(--bg);
  width: min(1100px, 96vw);
  height: min(94vh, 1100px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
}
.fe__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 0.9rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.fe__title { margin: 0; font-size: 1.15rem; font-weight: 800; display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.fe__subtitle { margin: 2px 0 0; font-size: 0.85rem; color: var(--ink-3); }
.fe__actions { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }
.fe__status { font-size: 0.78rem; color: var(--ink-3); margin-right: 0.25rem; white-space: nowrap; }
.fe__close {
  background: transparent; border: 0; font-size: 1.4rem; line-height: 1; color: var(--ink-3);
  cursor: pointer; padding: 0.2rem 0.5rem; border-radius: var(--r-sm);
}
.fe__close:hover { background: var(--bg-2); color: var(--ink); }
.fe__body { flex: 1; overflow-y: auto; padding: 1.25rem; }
.fe-canvas { max-width: 860px; margin: 0 auto; display: flex; flex-direction: column; gap: 0.9rem; }

/* ── Shared atoms ── */
.fe-lbl { display: block; font-size: 0.66rem; font-weight: 800; letter-spacing: 0.08em; color: var(--ink-3); text-transform: uppercase; margin-bottom: 3px; }
.fe-inp, .fe-sel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 6px 9px;
  font-size: 0.86rem;
  font-family: inherit;
  color: var(--ink);
  width: 100%;
  transition: border-color 0.12s, box-shadow 0.12s;
}
textarea.fe-inp { resize: vertical; min-height: 2.2rem; line-height: 1.45; }
.fe-inp:focus, .fe-sel:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus-ring); }
.fe-inp--lg { font-size: 1.05rem; font-weight: 700; }
/* The question text itself — bold so questions read apart from their
   descriptions and options at a glance. */
.fe-inp--label { font-weight: 700; font-size: 0.95rem; }
.fe-inp--desc { font-size: 0.8rem; color: var(--ink-2); }
.fe-inp--lock { background: var(--bg-2); color: var(--ink-3); cursor: not-allowed; }
.fe-inp--error { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.fe-inp::placeholder { color: var(--ink-4); font-style: italic; }
.fe-sel { width: auto; padding-right: 1.6rem; cursor: pointer; }
.fe-sel:disabled { background: var(--bg-2); color: var(--ink-3); cursor: not-allowed; }
.fe-sel--route { max-width: 220px; font-size: 0.78rem; }
.fe-sel--warn { border-color: var(--warning); }
.fe-row { display: flex; align-items: center; gap: 8px; }
.fe-grow { flex: 1; min-width: 0; }
.fe-field { margin-top: 0.55rem; }
.fe-field__error { font-size: 0.75rem; color: var(--danger); min-height: 0; }
.fe-req { color: var(--danger); font-weight: 800; }
.fe-hint { font-size: 0.74rem; font-style: italic; color: var(--ink-3); }
.fe-hint--map { color: var(--accent); font-style: normal; }
.fe-warn { font-size: 0.76rem; font-weight: 700; color: var(--warning-dark); }
.fe-warn--block { background: var(--warning-soft); border-left: 3px solid var(--warning); padding: 0.6rem 0.9rem; border-radius: 0 var(--r-sm) var(--r-sm) 0; font-weight: 500; color: var(--ink); }
.fe-warn--block ul { margin: 0.25rem 0 0 1.1rem; }
.fe-lock-chip { display: inline-block; padding: 0 7px; border-radius: var(--r-pill); font-size: 0.62rem; font-weight: 800; background: var(--danger-soft); color: var(--danger-dark); letter-spacing: 0.02em; white-space: nowrap; }
/* Monochrome padlock (see FormsHelper#fe_lock_icon) — inherits the ink of
   whatever it sits in, so it reads as a status marker, not decoration. */
.fe-lock-ico { color: var(--ink-4); }
.fe-lock-chip .fe-lock-ico { color: currentColor; }
.fe-lock-chip .fe-lock-ico svg { width: 10px; height: 10px; }
.fe-link { background: none; border: 0; color: var(--accent); font-weight: 700; font-size: 0.8rem; cursor: pointer; padding: 0; font-family: inherit; }
.fe-link:hover { text-decoration: underline; }
.fe-file { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }

/* ── Cards ── */
.fe-card { background: var(--surface); border: 1px solid var(--ink-4); border-radius: var(--r-lg); padding: 0.9rem 1rem; }
.fe-card__meta { font-size: 0.7rem; font-weight: 800; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.5rem; }
.fe-banner {
  display: flex; align-items: center; justify-content: center; gap: 0.4rem;
  border: 1px dashed var(--ink-4); border-radius: var(--r-md); padding: 1.1rem;
  color: var(--ink-3); font-style: italic; font-size: 0.82rem; background: var(--surface-2);
  cursor: pointer; position: relative;
}
.fe-banner:hover { border-color: var(--accent); color: var(--accent); }
.fe-banner--set { padding: 0; border: 0; overflow: hidden; cursor: default; }
.fe-banner__img { width: 100%; max-height: 200px; object-fit: cover; display: block; border-radius: var(--r-md); }
.fe-banner__remove { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(17,24,39,0.7); color: #fff; cursor: pointer; font-size: 1rem; line-height: 1; }

/* ── Section ── */
/* Every section card reads the same. Section 1 used to take an accent
   border, which implied "selected" rather than "pinned" — the footer note
   already says it can't be deleted or moved. */
.fe-sec { border: 1px solid var(--ink-4); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; }
.fe-sec__head { padding: 0.75rem 0.9rem; border-bottom: 1px solid var(--line-2); }
/* Matches the .fe-lbl treatment used by FORM HEADER / TITLE / DESCRIPTION. */
.fe-sec__meta { font-size: 0.66rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); display: flex; align-items: center; gap: 0.5rem; }
.fe-sec__body { padding: 0.75rem 0.9rem; background: var(--surface-2); display: flex; flex-direction: column; gap: 0.6rem; min-height: 3rem; }
.fe-sec__foot { display: flex; align-items: center; gap: 0.9rem; padding: 0.6rem 0.9rem; border-top: 1px solid var(--line-2); background: var(--surface); flex-wrap: wrap; font-size: 0.78rem; font-weight: 700; color: var(--ink-2); }
.fe-sec__after { display: inline-flex; align-items: center; gap: 0.5rem; }
.fe-sec__after .fe-sel { min-width: 200px; }
.fe-sec__move { margin-left: auto; display: inline-flex; align-items: center; gap: 0.25rem; }
.fe-sec__foot-note { margin-left: auto; }
.fe-move { border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-sm); font-size: 0.65rem; padding: 2px 7px; cursor: pointer; color: var(--ink-2); }
.fe-move:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.fe-move:disabled { opacity: 0.35; cursor: not-allowed; }
.fe-del { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 2px 9px; font-size: 0.72rem; font-weight: 700; color: var(--ink-2); background: var(--surface); cursor: pointer; font-family: inherit; }
.fe-del:hover:not(:disabled) { border-color: var(--danger); color: var(--danger); }
.fe-del:disabled { opacity: 0.45; cursor: not-allowed; }
.fe-add-row { display: flex; gap: 0.6rem; }
.fe-add { flex: 1; border: 1px dashed var(--ink-4); border-radius: var(--r-md); text-align: center; padding: 0.5rem; font-size: 0.8rem; font-style: italic; font-weight: 600; color: var(--ink-3); background: var(--surface); cursor: pointer; font-family: inherit; }
.fe-add:hover { border-color: var(--accent); color: var(--accent); }
.fe-add--section { flex: none; width: 100%; padding: 0.75rem; font-size: 0.9rem; background: var(--surface); }

/* ── Question / content cards ── */
.fe-q, .fe-block { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); overflow: hidden; }
.fe-q--locked { border-color: var(--danger-soft); }
.fe-item--ghost { opacity: 0.4; }
.fe-q__head { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--line-2); }
.fe-q__num { font-size: 0.64rem; font-weight: 800; letter-spacing: 0.05em; color: var(--ink-3); white-space: nowrap; }
.fe-q__body { padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; }
.fe-q__foot { display: flex; align-items: center; justify-content: flex-end; gap: 14px; padding: 6px 10px; border-top: 1px solid var(--line-2); background: var(--surface-2); }
.fe-drag { color: var(--ink-4); font-size: 0.95rem; line-height: 0.7; letter-spacing: -2px; cursor: grab; user-select: none; }
.fe-drag--off { cursor: not-allowed; opacity: 0.4; }
.fe-drag--opt { font-size: 0.85rem; }
.fe-trash, .fe-opt__x { background: none; border: 0; cursor: pointer; color: var(--ink-3); font-size: 0.9rem; padding: 2px 4px; border-radius: var(--r-sm); font-family: inherit; }
.fe-trash:hover, .fe-opt__x:hover { color: var(--danger); background: var(--danger-soft); }
.fe-block__head { padding: 6px 10px; border-bottom: 1px solid var(--line-2); font-size: 0.64rem; font-weight: 800; letter-spacing: 0.05em; color: var(--ink-3); display: flex; align-items: center; gap: 8px; }
.fe-block__head .fe-trash { margin-left: auto; }

/* Required switch */
/* position:relative pins the absolutely-positioned .fe-switch's containing
   block to the toggle itself. Without it the switch resolves to the nearest
   positioned ancestor — the .fe dialog — and every question's switch inflates
   .fe's scroll height, letting scrollIntoView scroll the header out of view. */
.fe-req-toggle { position: relative; display: inline-flex; align-items: center; gap: 6px; font-size: 0.72rem; font-weight: 700; color: var(--ink-2); cursor: pointer; user-select: none; }
.fe-req-toggle--locked { cursor: default; }
.fe-switch { position: absolute; opacity: 0; width: 1px; height: 1px; }
.fe-switch__track { width: 26px; height: 15px; border-radius: 999px; background: var(--ink-4); position: relative; display: inline-block; transition: background 0.15s; }
.fe-switch__track::after { content: ""; position: absolute; top: 1.5px; left: 1.5px; width: 12px; height: 12px; border-radius: 50%; background: #fff; transition: left 0.15s; }
.fe-switch:checked + .fe-switch__track { background: var(--accent); }
.fe-switch:checked + .fe-switch__track::after { left: 12.5px; }
.fe-switch:disabled + .fe-switch__track { opacity: 0.6; }
.fe-switch:focus-visible + .fe-switch__track { box-shadow: var(--focus-ring); }

/* Options */
.fe-opts { display: flex; flex-direction: column; gap: 5px; }
.fe-opt { display: flex; align-items: center; gap: 7px; font-size: 0.82rem; }
.fe-opt .fe-inp { padding: 4px 8px; font-size: 0.82rem; }
.fe-opt__mark { width: 13px; height: 13px; border: 1.5px solid var(--ink-4); flex-shrink: 0; }
.fe-opt__mark--radio { border-radius: 50%; }
.fe-opt__mark--ghost { opacity: 0.4; }
.fe-opt--add { gap: 6px; }
.fe-season-note { font-size: 0.78rem; color: var(--ink-2); display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.fe-season-note .badge { margin: 0; font-size: 0.72rem; }

/* Rating */
.fe-rating-cfg { display: flex; gap: 1rem; align-items: flex-end; }
.fe-rating-cfg__field .fe-sel { min-width: 90px; }
.fe-rating-preview { display: flex; gap: 0.9rem; align-items: center; flex-wrap: wrap; padding: 4px 2px; }
.fe-rating-preview__item { text-align: center; font-size: 0.68rem; color: var(--ink-3); font-weight: 700; display: flex; flex-direction: column; align-items: center; gap: 1px; }
.fe-rating-preview__icon { width: 22px; height: 22px; color: var(--ink-4); }
.fe-rating-preview__icon svg { width: 100%; height: 100%; }
.fe-rating-preview__item.is-on .fe-rating-preview__icon { color: var(--warning); }

/* Image slots */
.fe-img { display: inline-flex; align-items: center; flex-shrink: 0; }
.fe-imgbtn { width: 28px; height: 26px; border: 1px solid var(--line); border-radius: var(--r-sm); display: inline-flex; align-items: center; justify-content: center; color: var(--ink-3); background: var(--surface); cursor: pointer; position: relative; }
.fe-imgbtn svg { width: 15px; height: 15px; }
.fe-imgbtn:hover { border-color: var(--accent); color: var(--accent); }
.fe-img__thumb-wrap { position: relative; display: inline-block; }
.fe-img__thumb { width: 44px; height: 44px; object-fit: cover; border-radius: var(--r-sm); border: 1px solid var(--line); display: block; }
.fe-img--sm .fe-img__thumb { width: 30px; height: 30px; }
.fe-img__remove { position: absolute; top: -6px; right: -6px; width: 16px; height: 16px; border-radius: 50%; border: 0; background: var(--ink); color: #fff; font-size: 0.7rem; line-height: 1; cursor: pointer; padding: 0; }

@media (max-width: 767px) {
  .fe__header { flex-direction: column; }
  .fe__body { padding: 0.75rem; }
  .fe-sec__foot { gap: 0.5rem; }
  .fe-sec__move { margin-left: 0; }
}
