/* ==========================================================================
   styles/sidebar.css
   The frontmatter panel: collapsible cards, one per group of fields.
   ========================================================================== */

.card { border-bottom: 1px solid var(--line-soft); }

.card__toggle {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 13px 16px;
  background: none; border: 0; cursor: pointer;
  font-family: inherit; font-size: 0.8rem; font-weight: 600; color: var(--fg);
  text-align: start;
  transition: background var(--fast);
}
.card__toggle:hover { background: var(--panel-2); }
.card__toggle .chevron {
  width: 13px; height: 13px; margin-inline-start: auto; color: var(--fg-faint);
  transition: transform var(--fast);
}
.card.is-collapsed .chevron { transform: rotate(-90deg); }
.card.is-collapsed .card__body { display: none; }

.card__count {
  font-size: 0.66rem; font-weight: 500; color: var(--fg-faint);
  font-family: var(--font-mono); direction: ltr;
}

.card__body { padding: 4px 16px 16px; }

/* --- the two-up rows used for dates and short pairs --------------------- */
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 7px; }

/* --- a switch that reads as a switch, not as a dropdown ----------------- */
/* A <button> shrinks to its content, so without an explicit width the label
   and the track were squeezed together and the Persian text ran out of room. */
.switch {
  display: flex; width: 100%; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 10px 12px; margin-bottom: 9px;
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius-sm); cursor: pointer;
  font-family: inherit; font-size: 0.8rem; color: var(--fg);
  text-align: start;
}
.switch__label { flex: 1; min-width: 0; line-height: 1.6; }
.switch:hover { border-color: var(--fg-faint); }
.switch__track {
  width: 34px; height: 19px; border-radius: 12px; flex-shrink: 0;
  background: var(--line); position: relative;
  transition: background var(--fast);
}
.switch__track::after {
  content: ''; position: absolute; top: 2px; inset-inline-start: 2px;
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--paper); box-shadow: 0 1px 2px rgba(0,0,0,.25);
  transition: transform var(--fast);
}
.switch[aria-checked='true'] .switch__track { background: var(--accent); }
.switch[aria-checked='true'] .switch__track::after { transform: translateX(-15px); }

/* --- an input with a button beside it -----------------------------------
   The input carries width:100% from .control, which in a flex row leaves the
   button nothing to sit in. flex:1 with min-width:0 lets it give way. */
.input-row { display: flex; gap: 6px; align-items: stretch; }
.input-row .control { flex: 1; min-width: 0; width: auto; }
.input-row .btn { flex-shrink: 0; white-space: nowrap; }

/* --- unknown fields we preserve but do not render a form for ------------ */
.preserved {
  margin-top: 6px; padding: 10px 12px;
  background: var(--accent-wash); border-radius: var(--radius-sm);
  font-size: 0.72rem; color: var(--fg-dim); line-height: 1.9;
}
.preserved code {
  font-family: var(--font-mono); font-size: 0.7rem; direction: ltr;
  unicode-bidi: isolate; color: var(--accent-strong);
}

/* --- footnote and source lists ------------------------------------------ */
.helper {
  font-size: 0.7rem; color: var(--fg-faint); line-height: 1.85; margin-top: 5px;
}

/* --------------------------------------------------------------------------
   Document type
   -------------------------------------------------------------------------- */

.type-picker { padding: 14px 16px 4px; border-bottom: 1px solid var(--line-soft); }

.type-picker__row { display: flex; gap: 6px; }

.type-picker__option {
  flex: 1; padding: 9px 10px;
  font-family: inherit; font-size: 0.82rem; color: var(--fg-dim);
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius-sm); cursor: pointer;
  transition: background var(--fast), border-color var(--fast), color var(--fast);
}
.type-picker__option:hover { border-color: var(--fg-faint); }
.type-picker__option[aria-pressed='true'] {
  background: var(--accent-wash); border-color: var(--accent);
  color: var(--accent-strong); font-weight: 600;
}

/* --------------------------------------------------------------------------
   Roles
   -------------------------------------------------------------------------- */

.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 9px; }

.chip {
  font-family: inherit; font-size: 0.76rem; color: var(--fg-dim);
  background: var(--paper); border: 1px solid var(--line);
  border-radius: 20px; padding: 5px 11px; cursor: pointer;
  transition: background var(--fast), border-color var(--fast), color var(--fast);
}
.chip:hover { border-color: var(--fg-faint); color: var(--fg); }
.chip[aria-pressed='true'] {
  background: var(--accent); border-color: var(--accent);
  color: var(--on-accent); font-weight: 600;
}

/* --------------------------------------------------------------------------
   Social links
   -------------------------------------------------------------------------- */

.social-row {
  display: grid; grid-template-columns: 68px 1fr; gap: 8px;
  align-items: center; margin-bottom: 6px;
}
.social-row__name { font-size: 0.76rem; color: var(--fg-dim); }
.social-row .control { font-size: 0.75rem; padding: 6px 8px; }
