/* components.css — cards, buttons, chips, modals, toasts, skeletons, badges */

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}
.card-pad { padding: var(--s-4); }
.card + .card { margin-top: var(--s-3); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 34px; padding: 6px 16px;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  font-weight: 600; font-size: var(--fs-14);
  background: var(--n-100); color: var(--text);
  transition: background 0.12s ease, box-shadow 0.12s ease;
}
.btn:hover { background: var(--n-200); text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--c-primary); color: var(--c-primary-contrast); }
.btn-primary:hover { background: var(--c-primary-hover); }
.btn-outline { background: transparent; border-color: var(--c-primary); color: var(--c-primary); }
.btn-outline:hover { background: var(--c-primary-soft); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--n-100); }
.btn-danger { background: transparent; border-color: var(--c-danger); color: var(--c-danger); }
.btn-danger:hover { background: var(--c-danger-soft); }
.btn-sm { min-height: 28px; padding: 3px 12px; font-size: var(--fs-13); }
.btn-block { width: 100%; }
.btn-icon {
  min-height: 40px; min-width: 40px; padding: var(--s-2); border-radius: var(--radius-pill);
  background: transparent; color: var(--text-muted);
}
.btn-icon:hover { background: var(--n-100); }

/* Chips / pills */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong); background: var(--surface);
  font-size: var(--fs-13); font-weight: 500; color: var(--text-muted);
}
.chip[aria-pressed="true"], .chip.is-active { background: var(--c-primary-soft); border-color: var(--c-primary); color: var(--c-primary); }
.chip button { background: none; border: none; color: inherit; padding: 0; line-height: 1; }

/* Badge (counts) */
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  font-size: 11px; font-weight: 700; line-height: 1;
  background: var(--c-danger); color: #fff; border-radius: var(--radius-pill);
}

/* Degree badge — the product's signature glyph */
.degree {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: var(--fs-13); color: var(--text-subtle); font-weight: 600;
  white-space: nowrap;
}
.degree-glyph { display: inline-flex; gap: 2px; align-items: center; }
.degree-glyph i {
  width: 5px; height: 5px; border-radius: 50%; background: var(--c-primary); display: block;
}
.degree-1 .degree-glyph i { background: var(--c-primary); }
.degree-2 .degree-glyph i { background: var(--r-support); }
.degree-3 .degree-glyph i { background: var(--n-500); }
.degree-label { font-size: 11px; }

/* Avatar */
.avatar { border-radius: 50%; overflow: hidden; flex-shrink: 0; background: var(--n-200); display: block; }
.avatar svg { display: block; width: 100%; height: 100%; }
.avatar-sm { width: 32px; height: 32px; }
.avatar-md { width: 48px; height: 48px; }
.avatar-lg { width: 72px; height: 72px; }
.avatar-xl { width: 128px; height: 128px; border: 3px solid var(--surface); }

/* Toasts */
#toast-region {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + var(--s-4)); z-index: var(--z-toast);
  display: flex; flex-direction: column; gap: var(--s-2); width: min(92vw, 420px);
  pointer-events: none;
}
.toast {
  background: var(--n-900); color: #fff; padding: var(--s-3) var(--s-4);
  border-radius: var(--radius-card); box-shadow: var(--shadow-overlay);
  display: flex; gap: var(--s-3); align-items: flex-start; pointer-events: auto;
  animation: toast-in 0.18s ease;
}
.toast-danger { background: var(--c-danger); }
.toast-success { background: var(--c-success); }
.toast .toast-action { margin-left: auto; color: #fff; text-decoration: underline; background: none; border: none; font-weight: 600; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(26,23,18,0.45);
  z-index: var(--z-modal); display: flex; align-items: flex-start; justify-content: center;
  padding: var(--s-6) var(--s-4); overflow-y: auto;
}
.modal {
  background: var(--surface); border-radius: var(--radius-card);
  box-shadow: var(--shadow-overlay); width: min(560px, 100%);
  margin-top: 6vh; animation: modal-in 0.16s ease;
}
.modal-lg { width: min(720px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: var(--s-4); border-bottom: 1px solid var(--border); }
.modal-head h2 { font-family: var(--font-display); }
.modal-body { padding: var(--s-4); }
.modal-foot { padding: var(--s-4); border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: var(--s-2); }
@keyframes modal-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { .modal { animation: none; } }

/* Popover */
.popover {
  position: absolute; z-index: var(--z-popover);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-card); box-shadow: var(--shadow-overlay);
  padding: var(--s-3); max-width: 300px;
}

/* Skeletons */
.skeleton { background: var(--n-200); border-radius: var(--radius-sm); position: relative; overflow: hidden; }
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.55), transparent);
  animation: shimmer 1.3s infinite;
}
@keyframes shimmer { 100% { transform: translateX(100%); } }
.skeleton::after { transform: translateX(-100%); }
@media (prefers-reduced-motion: reduce) { .skeleton::after { animation: none; display: none; } }
.sk-line { height: 12px; margin-bottom: 8px; }
.sk-line.w-60 { width: 60%; }
.sk-line.w-40 { width: 40%; }
.sk-circle { border-radius: 50%; }

/* Form fields */
.field { margin-bottom: var(--s-4); }
.field label { display: block; font-weight: 600; font-size: var(--fs-13); margin-bottom: var(--s-1); }
.input, .textarea, .select {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--surface); font-size: var(--fs-14);
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--c-primary); }
.textarea { resize: vertical; min-height: 80px; }
.field-hint { font-size: var(--fs-13); color: var(--text-subtle); margin-top: var(--s-1); }
.field-error { font-size: var(--fs-13); color: var(--c-danger); margin-top: var(--s-1); }

/* Tabs */
.tabs { display: flex; gap: var(--s-1); border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab {
  padding: var(--s-3) var(--s-4); background: none; border: none;
  border-bottom: 2px solid transparent; color: var(--text-muted); font-weight: 600; white-space: nowrap;
}
.tab[aria-selected="true"] { color: var(--c-primary); border-bottom-color: var(--c-primary); }
.tab:hover { color: var(--text); }
.vtabs { display: flex; flex-direction: column; gap: 2px; }
.vtabs .tab { border-bottom: none; border-left: 3px solid transparent; text-align: left; border-radius: var(--radius-sm); }
.vtabs .tab[aria-selected="true"] { border-left-color: var(--c-primary); background: var(--c-primary-soft); }

/* Frontier chip */
.frontier-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: var(--radius-pill);
  border: 1px dashed var(--n-500); background: repeating-linear-gradient(45deg, transparent, transparent 6px, var(--n-100) 6px, var(--n-100) 12px);
  color: var(--text-muted); font-size: var(--fs-13); font-weight: 600;
}
.frontier-chip::before { content: "◌"; }
.frontiers-hidden .frontier-chip { display: none !important; }

/* Empty / error states */
.state-block { text-align: center; padding: var(--s-8) var(--s-4); color: var(--text-muted); }
.state-block h3 { color: var(--text); margin-bottom: var(--s-2); }
.state-block .state-icon { font-size: 40px; margin-bottom: var(--s-3); }

/* Divider */
.divider { height: 1px; background: var(--border); border: 0; margin: var(--s-4) 0; }

/* Reaction picker */
.reaction-picker {
  position: absolute; z-index: var(--z-popover);
  display: flex; gap: var(--s-1); padding: var(--s-2);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-pill); box-shadow: var(--shadow-overlay);
  animation: pop-in 0.14s ease;
}
@keyframes pop-in { from { opacity: 0; transform: scale(0.9) translateY(6px); } to { opacity: 1; transform: scale(1) translateY(0); } }
@media (prefers-reduced-motion: reduce) { .reaction-picker { animation: none; } }
.reaction-btn {
  width: 40px; height: 40px; border-radius: 50%; border: none; background: none;
  font-size: 22px; line-height: 1; transition: transform 0.1s ease;
}
.reaction-btn:hover, .reaction-btn:focus-visible { transform: scale(1.25); background: var(--n-100); }

/* Tooltip note */
.hover-card { width: 280px; }
