/* Record sections (assets/record-sections.js): the collapsed headings a filed record opens with.
   projects/inspection-qc-release-updates step 5. Its own file, beside the script, so styles.css (shared core) is not
   touched. Colours are styles.css's tokens only. The pattern is the Truck Inspections archive's: a button carrying
   aria-expanded, a chevron that turns off it, a short ease, closed by default. Nothing here names a record kind. */

.rs-section {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card); margin: 0 0 12px; overflow: hidden;
}
.rs-section[hidden] { display: none; }
.rs-heading { margin: 0; font-size: 1rem; }
.rs-toggle {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; min-height: 48px; margin: 0; padding: 10px 14px;
  border: 0; border-radius: 0; background: none; box-shadow: none; cursor: pointer;
  font: inherit; font-weight: 700; color: var(--text-strong); text-align: left;
}
.rs-toggle:focus-visible { outline: 2px solid var(--info-accent); outline-offset: -2px; }
.rs-title { flex: 1 1 auto; min-width: 0; }
.rs-badge {
  flex: none; padding: 1px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 700;
  background: var(--error-bg); color: var(--error); border: 1px solid var(--error-border);
}
.rs-badge[hidden] { display: none; }
.rs-chevron {
  flex: none; width: 0.55rem; height: 0.55rem; margin-right: 0.3rem;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(-45deg); transition: transform 0.18s ease;
}
.rs-toggle[aria-expanded="true"] .rs-chevron { transform: rotate(45deg); }

/* Closed, the panel has no height and cannot be tabbed into; the visibility change waits for the ease to finish. */
.rs-panel {
  display: grid; grid-template-rows: 0fr; visibility: hidden;
  transition: grid-template-rows 0.18s ease, visibility 0s linear 0.18s;
}
.rs-section.rs-open > .rs-panel {
  grid-template-rows: 1fr; visibility: visible;
  transition: grid-template-rows 0.18s ease, visibility 0s;
}
.rs-clip { min-height: 0; overflow: hidden; }
.rs-body { padding: 0 14px 14px; display: flex; flex-direction: column; gap: 10px; }
.rs-section.rs-external > .rs-panel { display: none; }

@media (prefers-reduced-motion: reduce) {
  .rs-panel, .rs-section.rs-open > .rs-panel, .rs-chevron { transition: none; }
}

.rs-note { margin: 0; color: var(--text-muted); }
.rs-note-error { color: var(--error); }
.rs-retry { align-self: flex-start; }

/* LOTO / JSA / Timesheet */
.rs-form-group { display: flex; flex-direction: column; gap: 8px; }
.rs-form-group > h3 { margin: 0; font-size: 0.9rem; color: var(--text-strong); }
.rs-form {
  background: var(--bg); border: 1px solid var(--border-soft); border-radius: var(--radius-md);
  padding: 10px 12px; display: flex; flex-direction: column; gap: 8px;
}
.rs-form-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.rs-pill {
  display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 700;
  border: 1px solid var(--border); background: var(--card); color: var(--text-muted);
}
.rs-pill-final { background: var(--success-bg); border-color: var(--success-border); color: var(--success); }
.rs-pill-open { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn); }
.rs-details { margin: 0; display: grid; grid-template-columns: minmax(0, auto) minmax(0, 1fr); gap: 2px 12px; font-size: 0.9rem; }
.rs-details dt { color: var(--text-muted); }
.rs-details dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }
.rs-open-original { align-self: flex-start; text-decoration: none; }

/* History */
.rs-history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.rs-event {
  background: var(--bg); border: 1px solid var(--border-soft); border-left: 4px solid var(--border);
  border-radius: var(--radius-md); padding: 8px 12px;
}
.rs-event[data-side="engineer"], .rs-event[data-kind="decision"] { border-left-color: var(--info-accent); }
.rs-event[data-side="crew"] { border-left-color: var(--success-accent); }
.rs-event[data-kind="return"] { border-left-color: var(--error-accent); }
.rs-event-top { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.rs-event-title { font-weight: 700; color: var(--text-strong); }
.rs-event-who, .rs-event-at { font-size: 0.8rem; color: var(--text-muted); }
.rs-event-body { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.rs-comment { display: flex; flex-direction: column; gap: 6px; }
.rs-comment textarea { width: 100%; min-height: 72px; }
.rs-comment .btn { align-self: flex-start; }
