/* Yellow Baar editor styles. Builds on the tokens of site.css; no external resources. */

[hidden] {
  display: none !important;
}

.page-edit {
  --danger: #9b1c1c; /* 7.6:1 on white */
  --ok-bg: #e6f4ea;
  --ok-ink: #14532d;
}

.edit-header {
  background: var(--ink);
  color: var(--paper);
  padding: 14px 0;
}

.edit-header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
}

.edit-header h1 {
  flex: 1 1 auto;
  margin: 0;
  font-size: 1.125rem;
}

.edit-header :focus-visible {
  outline-color: var(--yellow);
}

.edit-main {
  padding-top: 24px;
  padding-bottom: 48px;
  max-width: 820px;
}

.notice {
  margin: 0 0 20px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 2px solid var(--ink);
  background: var(--soft);
  color: var(--ink);
  font-weight: 600;
}

.notice p {
  margin: 0;
}

.notice .notice-more {
  margin-top: 4px;
  font-weight: 400;
}

.messages {
  scroll-margin-top: 72px;
}

.messages > p {
  margin: 0 0 16px;
}

fieldset.bare {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

fieldset.bare:disabled {
  opacity: 0.6;
}

.panel {
  margin: 0 0 24px;
  padding: 20px 16px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 1.375rem;
}

.panel h3 {
  margin: 0 0 8px;
  font-size: 1.0625rem;
}

.hint {
  margin: 4px 0 12px;
  color: var(--muted);
  font-size: 0.875rem;
}

.edit-nav {
  position: sticky;
  top: 0;
  z-index: 5;
  margin: 0 calc(var(--gutter) * -1) 20px;
  padding: 8px var(--gutter);
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.edit-nav ul {
  display: flex;
  gap: 4px 16px;
  margin: 0;
  padding: 0;
  list-style: none;
  flex-wrap: wrap;
}

.edit-nav a {
  display: inline-block;
  padding: 6px 2px;
  font-weight: 600;
}

/* --- Form controls ---------------------------------------------------------- */

.field {
  margin: 0 0 14px;
}

.field label {
  display: block;
  margin-bottom: 4px;
  font-weight: 600;
  font-size: 0.9375rem;
}

.field input[type="text"],
.field input[type="password"],
.field input[type="date"],
.field input[type="time"],
.field input[type="url"],
.field input[type="email"],
.field select,
.field textarea {
  display: block;
  width: 100%;
  max-width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--muted);
  border-radius: 10px;
  background: var(--white);
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
}

.field textarea {
  resize: vertical;
}

.field input.invalid,
.field textarea.invalid,
.field select.invalid {
  border-color: var(--danger);
  border-width: 2px;
}

.field-check {
  display: flex;
  align-items: center;
  gap: 10px;
}

.field-check input {
  width: 22px;
  height: 22px;
  flex: none;
}

.field-check label {
  margin: 0;
}

.field-error {
  margin: 4px 0 0;
  color: var(--danger);
  font-size: 0.875rem;
  font-weight: 600;
}

.bilingual .en-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  margin-top: 8px;
}

.bilingual .en-label {
  margin: 0;
  color: var(--muted);
  font-weight: 400;
}

.bilingual > input:last-child,
.bilingual > textarea:last-child {
  border-style: dashed;
}

.chip {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ink);
  background: var(--badge-grey);
}

.chip-manual {
  background: var(--soft);
  box-shadow: inset 0 0 0 1px var(--ink);
}

.chip-pending {
  background: var(--yellow);
}

.items {
  margin-bottom: 12px;
}

fieldset.item,
div.item {
  min-width: 0;
  margin: 0 0 16px;
  padding: 14px 12px 4px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
}

fieldset.item legend {
  padding: 0 6px;
  font-weight: 700;
}

.item-actions {
  margin: 0 0 12px;
}

.image-preview {
  display: block;
  max-width: 160px;
  max-height: 120px;
  margin: 0 0 8px;
  object-fit: cover;
  border-radius: 10px;
}

.image-placeholder {
  display: inline-block;
  margin: 0 0 8px;
  padding: 8px 14px;
  border-radius: 10px;
  background: var(--placeholder);
  color: var(--muted);
}

.image-field input[type="file"] {
  display: block;
  max-width: 100%;
  margin-bottom: 8px;
  font: inherit;
}

/* --- Buttons ------------------------------------------------------------------ */

.btn {
  display: inline-block;
  min-height: 44px;
  padding: 9px 18px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--white);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.btn:hover {
  background: var(--soft);
}

.btn-primary {
  background: var(--yellow);
}

.btn-primary:hover {
  background: var(--yellow);
  box-shadow: 0 0 0 3px var(--ink);
}

.btn-danger {
  border-color: var(--danger);
  color: var(--danger);
}

.btn-quiet {
  border-color: var(--muted);
  font-weight: 600;
}

.btn:disabled {
  opacity: 0.6;
  cursor: progress;
}

.edit-header .btn {
  background: transparent;
  color: var(--paper);
  border-color: var(--on-ink-muted);
}

/* --- Messages ------------------------------------------------------------------ */

.msg {
  margin: 0 0 16px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 2px solid var(--ink);
  background: var(--white);
  color: var(--ink);
}

.msg p {
  margin: 0 0 4px;
  font-weight: 600;
}

.msg ul {
  margin: 4px 0 0;
  padding-left: 20px;
}

.msg-ok {
  background: var(--ok-bg);
  border-color: var(--ok-ink);
  color: var(--ok-ink);
  font-weight: 600;
}

.msg-ok a {
  color: var(--ok-ink);
}

.msg-error {
  border-color: var(--danger);
  color: var(--danger);
}

.msg-warn {
  background: var(--soft);
}

/* --- Save bar and versions ----------------------------------------------------- */

.save-bar {
  position: sticky;
  bottom: 0;
  z-index: 4;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px 16px;
  margin: 0 calc(var(--gutter) * -1) 24px;
  padding: 12px var(--gutter);
  background: var(--paper);
  border-top: 2px solid var(--ink);
}

.save-bar .field {
  flex: 1 1 220px;
  margin: 0;
}

.dirty-flag {
  flex: 1 0 100%;
  color: var(--ink);
  font-weight: 700;
}

.versions {
  margin: 0;
  padding: 0;
  list-style: none;
}

.version {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.version-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-wrap: anywhere;
}

.version-note {
  color: var(--ink);
}

.version-id {
  color: var(--muted);
  font-size: 0.75rem;
}

@media (min-width: 640px) {
  .panel {
    padding: 24px 26px;
  }

  fieldset.item,
  div.item {
    padding: 16px 18px 4px;
  }
}

/* --- Archive and date helpers --------------------------------------------------- */

details.archive {
  margin-top: 20px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

details.archive summary {
  min-height: 44px;
  padding: 10px 0;
  font-weight: 700;
  cursor: pointer;
}

.archive-tag {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 600;
}

.field > .field-check {
  margin-top: 6px;
}

.field > .field-check label {
  font-weight: 400;
}

.field input[type="checkbox"] {
  width: 22px;
  height: 22px;
  flex: none;
}

.field-check {
  display: flex;
  align-items: center;
  gap: 10px;
}

.field input:disabled {
  background: var(--badge-grey);
}
