/* Bright Crafts shared components. Uses the custom properties in tokens.css.
   Class names follow BEM and match the component names in docs/design. */

/* ---------- Reset and base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bc-bg);
  color: var(--bc-ink);
  font-family: var(--bc-font-body);
  font-size: var(--bc-text-md);
  line-height: var(--bc-leading-body);
}
img, svg { display: block; max-width: 100%; }
img { height: auto; }
h1, h2, h3, h4 { font-family: var(--bc-font-heading); font-weight: 400; line-height: var(--bc-leading-tight); margin: 0 0 var(--bc-space-3); }
h1 { font-size: var(--bc-text-3xl); }
h2 { font-size: var(--bc-text-2xl); }
h3 { font-size: var(--bc-text-xl); }
p { margin: 0 0 var(--bc-space-4); }
a { color: var(--bc-primary); text-underline-offset: 2px; }
a:hover { color: var(--bc-primary-hover); }
button, input, select, textarea { font: inherit; color: inherit; }
table { border-collapse: collapse; }
.mono { font-family: var(--bc-font-mono); }
.muted { color: var(--bc-ink-muted); }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link { position: absolute; left: var(--bc-space-2); top: -100px; z-index: 100; background: var(--bc-surface);
  padding: var(--bc-space-3) var(--bc-space-4); border-radius: var(--bc-radius-sm); }
.skip-link:focus { top: var(--bc-space-2); }
.icon { width: 24px; height: 24px; flex: none; }
.icon--sm { width: 18px; height: 18px; }
.stitch { border: 0; border-top: var(--bc-stitch); margin: var(--bc-space-6) 0; }

/* ---------- Wordmark ---------- */
.wordmark { display: inline-flex; flex-direction: column; text-decoration: none; color: var(--bc-ink);
  font-family: var(--bc-font-heading); font-size: 21px; line-height: 1.1; }
.wordmark__text { padding-bottom: 3px; border-bottom: var(--bc-stitch); white-space: nowrap; }
.wordmark__lead { color: var(--bc-primary); }
.wordmark--lg { font-size: 26px; }
.wordmark--inverse { color: var(--bc-ink-inverse); }
.wordmark--inverse .wordmark__lead { color: #f2a26f; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--bc-space-2);
  min-height: var(--bc-tap); padding: 0 var(--bc-space-5); border-radius: var(--bc-radius-pill);
  border: 2px solid transparent; font-weight: 700; font-size: var(--bc-text-md); line-height: 1.2;
  text-decoration: none; cursor: pointer; text-align: center;
}
.btn--primary { background: var(--bc-primary); color: #fff; }
.btn--primary:hover { background: var(--bc-primary-hover); color: #fff; }
.btn--secondary { background: transparent; border-color: var(--bc-ink); color: var(--bc-ink); }
.btn--secondary:hover { background: var(--bc-fill); color: var(--bc-ink); }
.btn--dark { background: var(--bc-ink); color: var(--bc-ink-inverse); }
.btn--dark:hover { background: #000; color: var(--bc-ink-inverse); }
.btn--danger { background: var(--bc-danger); color: #fff; }
.btn--danger:hover { background: #7d1124; color: #fff; }
.btn--danger-outline { background: transparent; border-color: var(--bc-danger); color: var(--bc-danger); }
.btn--light { background: var(--bc-bg); color: var(--bc-ink); }
.btn--lg { min-height: 56px; }
.btn--sm { min-height: 44px; padding: 0 var(--bc-space-4); font-size: var(--bc-text-sm); }
.btn--block { display: flex; width: 100%; }
.btn:disabled, .btn[aria-disabled="true"] { background: var(--bc-line); border-color: transparent; color: #6f6257; cursor: not-allowed; }
.btn__danger-mark { width: 16px; height: 16px; border: 2px solid currentColor; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; font-size: 11px; }
.btn__spinner { width: 16px; height: 16px; border: 2.5px solid rgba(255,255,255,.4); border-top-color: #fff;
  border-radius: 50%; animation: bc-spin .8s linear infinite; }
.btn.is-loading { opacity: .9; pointer-events: none; }
.link-btn { background: none; border: 0; padding: 0 var(--bc-space-1); min-height: 44px; color: var(--bc-primary);
  font-weight: 700; text-decoration: underline; cursor: pointer; }
@keyframes bc-spin { to { transform: rotate(360deg); } }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--bc-space-4); }
.field__label { font-weight: 700; font-size: 16px; }
.field__optional { font-weight: 400; color: var(--bc-ink-muted); }
.field__hint { font-size: 14px; color: var(--bc-ink-muted); }
.field__error { display: flex; gap: 6px; align-items: flex-start; font-size: var(--bc-text-sm); font-weight: 700; color: var(--bc-danger); }
.field__error:empty { display: none; }
.field__error::before { content: "!"; flex: none; width: 16px; height: 16px; margin-top: 3px; border-radius: 50%;
  background: var(--bc-danger); color: #fff; font-size: 11px; display: inline-flex; align-items: center; justify-content: center; }
.input, .select, .textarea {
  width: 100%; min-height: var(--bc-tap); padding: 0 14px; background: #fff;
  border: 1.5px solid var(--bc-line-strong); border-radius: var(--bc-radius-sm); font-size: var(--bc-text-md);
}
.textarea { padding: 12px 14px; min-height: 120px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border: 2px solid var(--bc-focus); box-shadow: 0 0 0 3px var(--bc-info-tint); }
.input[readonly] { background: var(--bc-fill); border-color: var(--bc-line); color: var(--bc-ink-muted); }
.input-validation-error, .input.is-invalid, .select.is-invalid, .textarea.is-invalid { border: 2px solid var(--bc-danger); }
.field-grid { display: grid; gap: 0 var(--bc-space-4); }
@media (min-width: 768px) { .field-grid--2 { grid-template-columns: 1fr 1fr; } }

.check { display: flex; align-items: center; gap: var(--bc-space-3); min-height: 44px; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--bc-primary); flex: none; margin: 0; }
.check--card { border: 1.5px solid var(--bc-line-strong); border-radius: var(--bc-radius-md); padding: 14px 16px; background: var(--bc-surface); }

.radio-card { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border: 1.5px solid var(--bc-line-strong);
  border-radius: var(--bc-radius-md); background: var(--bc-surface); cursor: pointer; margin-bottom: var(--bc-space-2); }
.radio-card input { width: 22px; height: 22px; accent-color: var(--bc-primary); flex: none; margin: 0; }
.radio-card__body { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.radio-card__meta { font-size: var(--bc-text-sm); color: var(--bc-ink-muted); }
.radio-card:has(input:checked) { border: 2px solid var(--bc-primary); background: #fff8f2; }

.error-summary { border: 2px solid var(--bc-danger); background: var(--bc-danger-tint); color: #7d1124;
  border-radius: 10px; padding: var(--bc-space-4); margin-bottom: var(--bc-space-5); }
.error-summary:focus { outline: 3px solid var(--bc-focus); outline-offset: 2px; }
.error-summary h2 { font-family: var(--bc-font-body); font-weight: 700; font-size: var(--bc-text-md); margin-bottom: var(--bc-space-2); }
.error-summary ul { margin: 0; padding-left: var(--bc-space-5); }
.error-summary a { color: #7d1124; font-weight: 700; }
.validation-summary-valid { display: none; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: var(--bc-text-xs); font-weight: 700; line-height: 1.3;
  padding: 4px 10px; border-radius: var(--bc-radius-pill); white-space: nowrap; }
.badge--one-of-a-kind { background: var(--bc-secondary-tint); border: 1px solid var(--bc-secondary); color: var(--bc-ink); }
.badge--made-to-order { background: var(--bc-surface); border: 1.5px dashed var(--bc-primary); color: var(--bc-primary-hover); }
.badge--sold { background: var(--bc-ink); color: var(--bc-ink-inverse); }
.badge--low-stock { background: var(--bc-primary-tint); color: #7d3210; }
.badge--reserved { background: var(--bc-warning-tint); color: #5e3d00; border: 1px dashed var(--bc-warning); }

.status { display: inline-flex; align-items: center; gap: 4px; font-size: var(--bc-text-xs); font-weight: 700;
  padding: 4px 10px; border-radius: var(--bc-radius-sm); white-space: nowrap; }
.status--pending { background: var(--bc-secondary-tint); color: #6b4600; }
.status--paid { background: var(--bc-info-tint); color: var(--bc-info); }
.status--shipped { background: var(--bc-success-tint); color: var(--bc-success); }
.status--cancelled { background: var(--bc-fill); color: var(--bc-ink-muted); }
.status--refunded, .status--partiallyrefunded { background: var(--bc-danger-tint); color: var(--bc-danger); }

/* ---------- Alerts and toast ---------- */
.alert { display: flex; gap: 12px; padding: 14px 16px; border-radius: 10px; font-size: 16px; line-height: 1.45; margin-bottom: var(--bc-space-4); }
.alert__icon { flex: none; font-weight: 700; width: 1em; text-align: center; }
.alert__body > :last-child { margin-bottom: 0; }
.alert--info { background: var(--bc-info-tint); color: #1f3a5f; }
.alert--success { background: var(--bc-success-tint); color: #24533a; }
.alert--warning { background: var(--bc-warning-tint); color: #5e3d00; }
.alert--error { background: var(--bc-danger-tint); color: #7d1124; border: 1.5px solid var(--bc-danger); }
.alert a { color: inherit; font-weight: 700; }

.toast { position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 60; max-width: 560px; margin: 0 auto;
  display: flex; align-items: center; gap: 14px; background: var(--bc-ink); color: var(--bc-ink-inverse);
  border-radius: var(--bc-radius-md); padding: 12px 12px 12px 16px; box-shadow: 0 8px 24px rgba(43,33,27,.25);
  animation: bc-slide-up .2s ease-out; }
.toast[hidden] { display: none; }
.toast__thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; flex: none; background: var(--bc-fill); }
.toast__text { flex: 1; font-size: var(--bc-text-sm); }
.toast__actions { display: flex; gap: var(--bc-space-2); flex-wrap: wrap; }
@keyframes bc-slide-up { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Navigation bits ---------- */
.breadcrumbs { font-size: var(--bc-text-sm); color: var(--bc-ink-muted); margin-bottom: var(--bc-space-3); }
.breadcrumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: var(--bc-space-2); margin: 0; padding: 0; }
.breadcrumbs li + li::before { content: "/"; margin-right: var(--bc-space-2); }
.breadcrumbs a { color: var(--bc-ink-muted); }
.breadcrumbs [aria-current] { color: var(--bc-ink); font-weight: 700; }

.chips { display: flex; gap: var(--bc-space-2); flex-wrap: wrap; list-style: none; margin: 0; padding: 0; }
.chip { display: inline-flex; align-items: center; min-height: 44px; padding: 0 var(--bc-space-4);
  border-radius: var(--bc-radius-pill); border: 1.5px solid var(--bc-line-strong); color: var(--bc-ink);
  text-decoration: none; font-size: var(--bc-text-sm); background: transparent; cursor: pointer; }
.chip:hover { background: var(--bc-fill); color: var(--bc-ink); }
.chip[aria-current], .chip.is-active { background: var(--bc-ink); border-color: var(--bc-ink); color: var(--bc-ink-inverse); font-weight: 700; }

.pagination { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; list-style: none; margin: var(--bc-space-6) 0; padding: 0; }
.pagination a, .pagination span { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; height: 44px;
  border-radius: var(--bc-radius-pill); color: var(--bc-ink); text-decoration: none; }
.pagination__step { padding: 0 14px; border: 1.5px solid var(--bc-line-strong); font-size: var(--bc-text-sm); }
.pagination [aria-current] { background: var(--bc-ink); color: var(--bc-ink-inverse); font-weight: 700; }

/* ---------- Cards, panels, empty state ---------- */
.panel { background: var(--bc-surface); border-radius: var(--bc-radius-lg); padding: var(--bc-space-5); box-shadow: var(--bc-shadow-1); }
.panel--bordered { box-shadow: none; border: 1px solid var(--bc-line); }
.empty-state { border: 2px dashed var(--bc-line); border-radius: var(--bc-radius-lg); padding: var(--bc-space-7) var(--bc-space-5);
  text-align: center; display: flex; flex-direction: column; align-items: center; gap: var(--bc-space-3); }
.empty-state__mark { width: 64px; height: 64px; border-radius: 50%; background: var(--bc-fill); border: var(--bc-stitch); }
.empty-state h2, .empty-state h1 { font-size: var(--bc-text-xl); margin: 0; }
.empty-state p { margin: 0; color: var(--bc-ink-muted); }

/* ---------- Placeholder imagery ---------- */
.placeholder-img { position: relative; background: repeating-linear-gradient(135deg, #efe6d6 0 12px, #f5eee1 12px 24px);
  display: flex; align-items: flex-end; justify-content: center; overflow: hidden; }
.placeholder-img__label { margin: 0 0 var(--bc-space-3); font-family: var(--bc-font-mono); font-size: 11px; color: var(--bc-ink-muted);
  background: rgba(255,253,248,.9); padding: 2px 8px; border-radius: 4px; }

/* ---------- Tables ---------- */
.table-wrap { border: 1px solid var(--bc-line); border-radius: var(--bc-radius-md); overflow-x: auto; background: var(--bc-surface); }
.table { width: 100%; font-size: 14px; }
.table th { background: var(--bc-bg); font-weight: 700; text-align: left; padding: 10px 14px; white-space: nowrap; }
.table td { padding: 12px 14px; border-top: 1px solid var(--bc-fill); vertical-align: middle; }
.table tbody tr:nth-child(even) { background: #fffaf2; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Dialog ---------- */
.dialog { border: 0; padding: 0; background: transparent; max-width: min(440px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(43,33,27,.55); }
.dialog__card { background: var(--bc-surface); border-radius: var(--bc-radius-lg); padding: var(--bc-space-5) 28px; }
.dialog__title { font-size: 22px; }
.dialog__actions { display: flex; justify-content: flex-end; gap: var(--bc-space-3); flex-wrap: wrap; margin-top: var(--bc-space-4); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
