/* components.css — the PRECISION component kit (docs/PRECISION.md §5).
   Buttons, chips, badges, cards, inputs, empty states, toasts, modal.
   Loaded after the old sheets during the transition so its definitions win;
   surface sheets style their own screens with these as the vocabulary. */

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--ui);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  padding: 5px 14px;
  border-radius: var(--r);
  border: 1px solid transparent;
  background: none;
  cursor: pointer;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: default; }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn svg { width: 13px; height: 13px; flex-shrink: 0; }

.btn-primary {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: #0a3a7a; border-color: #0a3a7a; }

.btn-secondary {
  background: var(--bg);
  border-color: var(--line);
  color: var(--ink);
}
.btn-secondary:hover:not(:disabled) { border-color: var(--navy); }

.btn-ghost {
  color: var(--sub);
  font-weight: 500;
}
.btn-ghost:hover:not(:disabled) { color: var(--ink); background: var(--soft); }

.btn-danger {
  background: var(--bg);
  border-color: var(--err);
  color: var(--err);
}
.btn-danger:hover:not(:disabled) { background: var(--err-soft); }

.btn-sm { font-size: 12px; padding: 4px 9px; }

/* ---- Chips + badges ------------------------------------------------------ */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 500;
  color: var(--sub);
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 2px 9px;
  white-space: nowrap;
}
.chip::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--faint);
  flex-shrink: 0;
}
.chip.chip-active::before { background: var(--gold); }
.chip.chip-done::before { background: var(--ok); }
.chip.chip-plain::before { display: none; }

.badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: var(--r-sm);
  padding: 1px 7px;
  background: var(--soft);
  border: 1px solid var(--line);
  color: var(--sub);
}
.badge-ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.badge-warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.badge-err { background: var(--err-soft); border-color: transparent; color: var(--err); }
.badge-accent { background: var(--gold-soft); border-color: transparent; color: var(--ink); }

/* ---- Cards --------------------------------------------------------------- */

.card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 14px 16px;
}
.card.clickable { cursor: pointer; }
.card.clickable:hover { border-color: var(--sub); }
.card-eyebrow {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--sub);
  margin-bottom: 4px;
}
.card-title { font-size: 14px; font-weight: 600; }
.card-desc { font-size: 12.5px; color: var(--sub); line-height: 1.5; margin: 4px 0 0; }

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

.input, .textarea,
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="url"], select, textarea {
  font-family: var(--ui);
  font-size: 13.5px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 7px 10px;
}
input[type="hidden"] { display: none; }
.input:focus, .textarea:focus,
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: var(--focus);
}
textarea { resize: vertical; line-height: 1.55; }

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--sub);
  margin-bottom: 4px;
}
.field-hint { font-size: 12px; color: var(--faint); margin-top: 3px; }
.field-error { font-size: 12px; color: var(--err); margin-top: 3px; }

/* ---- States -------------------------------------------------------------- */

.empty-state {
  font-size: 12.5px;
  color: var(--sub);
  background: var(--soft);
  border-radius: var(--r);
  padding: 12px 14px;
  text-align: center;
}

/* ---- Toast --------------------------------------------------------------- */

/* dom.js#showToast contract: element appended, then .visible added; kinds
   'success' / 'error'; may contain a link. */
.toast {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  background: var(--ink);
  color: #fff;
  font-size: 12.5px;
  font-weight: 500;
  border-radius: var(--r);
  padding: 8px 14px;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.toast.visible { opacity: 1; }
.toast.error { background: var(--err); }
.toast.success { background: var(--ok); }
.toast a { color: var(--gold); }
@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; }
}

/* ---- Modal --------------------------------------------------------------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(14, 21, 38, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-body {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px;
  width: min(440px, 100%);
  max-height: 85vh;
  overflow-y: auto;
}
.modal-body h2 { font-size: 14px; margin-bottom: 10px; }
.modal-body .cta {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 14px;
}

/* ==== Comment rail (.cmt-*) — shared anchored-comment kit ==================
   Owned by the drafting/editing surface (appended per PRECISION §10); the
   coach review screen and the student editing view both consume it without
   redefining. Rendered by app/infrastructure/commentRail.js, which writes
   each card's `top` and the rail's `minHeight` inline — the cards must stay
   position: absolute inside a positioned rail element (hosts give their rail
   `position: relative` and set the column width). Base .cmt-mark lives in
   base.css. */

.cmt-mark.hl { background: var(--gold-soft); border-bottom-color: var(--gold); }
.cmt-mark.active { background: var(--gold-soft); box-shadow: var(--focus); }

.cmt-card {
  position: absolute;
  left: 0;
  right: 0;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color 0.12s, top 0.15s ease;
}
.cmt-card.hl, .cmt-card:hover { border-color: var(--sub); }
.cmt-card.active { border-color: var(--gold); box-shadow: var(--focus); }
.cmt-card.orphaned { opacity: 0.7; }
/* Addressed cards recede so the open ones carry the eye. */
.cmt-card.addressed { opacity: 0.55; }
.cmt-card.addressed:hover, .cmt-card.addressed.hl { opacity: 1; }

.cmt-card-author {
  font-size: 11px;
  font-weight: 600;
  color: var(--sub);
  margin-bottom: 3px;
}
.cmt-card-author.goldie { color: var(--warn); }
/* Goldie's notes read as machine notes, never the coach's judgment. */
.cmt-card-goldie { background: var(--soft); border-style: dashed; }

.cmt-card-quote {
  font-size: 12px;
  line-height: 1.45;
  color: var(--faint);
  border-left: 2px solid var(--gold-soft);
  padding-left: 8px;
  margin-bottom: 5px;
}
.cmt-card-text {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink);
}

.cmt-card-del {
  float: right;
  margin: -2px -4px 0 6px;
  background: transparent;
  border: none;
  color: var(--faint);
  font-size: 14px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: var(--r-sm);
  cursor: pointer;
}
.cmt-card-del:hover { color: var(--err); background: var(--soft); }

.cmt-card-addressed {
  margin-top: 6px;
  font-size: 11px;
  font-weight: 500;
  color: var(--faint);
  display: flex;
  align-items: center;
  gap: 5px;
}
.cmt-card-addressed input { accent-color: var(--gold); margin: 0; }
.cmt-card-addressed.done { color: var(--ok); }
.cmt-card-addressed.open { color: var(--warn); }

/* The "+" offered in the rail at the selection's line. */
.cmt-add {
  position: absolute;
  left: -13px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--navy);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.cmt-add:hover { background: var(--navy); border-color: var(--navy); color: #fff; }

/* Composer card: opens already as a textbox, pinned to the selection's line.
   Its buttons carry the kit classes (.btn-ghost / .btn-primary). */
.cmt-composer {
  position: absolute;
  left: 0;
  right: 0;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 10px 12px;
  z-index: 5;
}
.cmt-compose-text {
  display: block;
  width: 100%;
  font-size: 12.5px;
  line-height: 1.5;
}
.cmt-compose-actions {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 8px;
}
.cmt-compose-error { color: var(--err); font-size: 12px; margin: 6px 0 0; }
