/* =======================================================
   K12 CRAFTER — COMPONENTS
   Reusable UI: buttons, badges, cards, product card, forms.
   ======================================================= */

/* SECTION HEADER */
.section-header {
  text-align: center;
  max-width: 640px;
  margin: 0 auto 48px;
}
.section-header p {
  margin-top: 12px;
  color: var(--k-gray-500);
  font-size: 1.0625rem;
}

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-ui);
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.01em;
  padding: 12px 24px;
  border-radius: var(--r-md);
  border: 2px solid transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: all var(--dur-fast) var(--ease);
}
.btn:hover  { transform: translateY(-1px); text-decoration: none; }
.btn:active { transform: translateY(0) scale(0.98); }

.btn-primary        { background: var(--k-green); color: #fff; border-color: var(--k-green); }
.btn-primary:hover  { background: var(--k-green-dark); border-color: var(--k-green-dark); color: #fff; }
.btn-secondary       { background: var(--k-blue); color: #fff; border-color: var(--k-blue); }
.btn-secondary:hover { background: var(--k-blue-dark); border-color: var(--k-blue-dark); color: #fff; }
.btn-outline        { background: transparent; color: var(--k-blue); border-color: var(--k-blue); }
.btn-outline:hover  { background: var(--k-blue-light); color: var(--k-blue); }
.btn-outline-white       { background: transparent; color: #fff; border-color: rgba(255,255,255,0.5); }
.btn-outline-white:hover { background: rgba(255,255,255,0.12); color: #fff; border-color: #fff; }
.btn-ghost          { background: transparent; color: var(--k-blue); border-color: transparent; }
.btn-ghost:hover    { background: var(--k-blue-light); }

.btn-pill { border-radius: var(--r-pill); }
.btn-sm   { font-size: 0.75rem; padding: 8px 16px; }
.btn-lg   { font-size: 1rem;   padding: 15px 32px; }
.btn-full { width: 100%; }

/* BADGES */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--font-ui);
  font-size: 0.6875rem; font-weight: 700;
  letter-spacing: 0.03em;
  padding: 4px 10px;
  border-radius: var(--r-pill);
}
.badge-blue  { background: var(--k-blue-light);  color: var(--k-blue-dark); }
.badge-green { background: var(--k-green-light); color: var(--k-green-dark); }
.badge-navy  { background: var(--k-navy);         color: #fff; }
.badge-gray  { background: var(--k-gray-100);    color: var(--k-gray-700); }
.badge-sky   { background: var(--k-sky);          color: var(--k-blue-dark); }
.badge-sale  { background: #FEF3C7;               color: #92400E; }
.badge-new   { background: var(--k-green);        color: #fff; }

/* CARDS */
.card {
  background: var(--k-white);
  border: 1px solid var(--k-gray-100);
  border-radius: var(--r-lg);
  overflow: hidden;
  transition: box-shadow var(--dur-normal) var(--ease), border-color var(--dur-normal) var(--ease);
}
.card:hover { box-shadow: 0 8px 32px rgba(0,71,187,0.10); border-color: var(--k-blue-mid); }
.card-blue  { background: var(--k-blue-light); border-color: var(--k-blue-mid); }
.card-sky   { background: var(--k-sky);        border-color: #B3D6F5; }
.card-green { background: var(--k-green-light); border-color: #B3E6C5; }

/* PRODUCT CARD */
.product-card {
  display: flex; flex-direction: column;
  border-radius: var(--r-lg);
  border: 1px solid var(--k-gray-100);
  background: var(--k-white);
  overflow: hidden;
  transition: box-shadow 0.2s var(--ease), border-color 0.2s var(--ease);
  text-decoration: none; color: inherit;
}
.product-card:hover {
  box-shadow: 0 8px 32px rgba(0,71,187,0.10);
  border-color: var(--k-blue-mid);
  text-decoration: none; color: inherit;
}
.product-card__image {
  aspect-ratio: 4/3;
  background: var(--k-blue-light);
  position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.product-card__image img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform 0.3s ease;
}
.product-card:hover .product-card__image img { transform: scale(1.03); }
.product-card__badges {
  position: absolute; top: 10px; left: 10px;
  display: flex; flex-direction: column; gap: 4px;
}
.product-card__placeholder-icon { font-size: 3rem; color: var(--k-blue-mid); }
.product-card__body {
  padding: 16px; display: flex; flex-direction: column; flex: 1; gap: 6px;
}
.product-card__meta  { display: flex; flex-wrap: wrap; gap: 4px; }
.product-card__title {
  font-family: var(--font-ui); font-size: 0.9375rem;
  font-weight: 700; color: var(--k-gray-900); line-height: 1.4;
}
.product-card__rating {
  display: flex; align-items: center; gap: 4px;
  font-size: 0.8125rem; color: var(--k-gray-500);
}
.stars { color: #F5A623; }
.product-card__footer {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: auto; padding-top: 12px;
  border-top: 1px solid var(--k-gray-100);
}
.product-card__price { font-size: 1rem; font-weight: 800; color: var(--k-navy); }
.product-card__price .original {
  font-size: 0.8125rem; font-weight: 400; color: var(--k-gray-500);
  text-decoration: line-through; margin-right: 4px;
}

/* FORMS */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 20px; }
.form-label {
  font-size: 0.8125rem; font-weight: 600; color: var(--k-gray-700);
}
.form-input, .form-select, .form-textarea {
  font-family: var(--font-ui);
  font-size: 0.9375rem; color: var(--k-gray-900);
  background: var(--k-white);
  border: 1.5px solid var(--k-gray-300);
  border-radius: var(--r-md);
  padding: 11px 14px; width: 100%; outline: none;
  transition: border-color var(--dur-fast) ease, box-shadow var(--dur-fast) ease;
}
.form-input::placeholder, .form-textarea::placeholder { color: var(--k-gray-300); }
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--k-blue);
  box-shadow: 0 0 0 3px rgba(0,71,187,0.12);
}
.form-input.error {
  border-color: var(--color-error);
  box-shadow: 0 0 0 3px rgba(226, 75, 74, 0.12);
}
.form-error-msg {
  font-size: 0.75rem;
  color: var(--color-error);
  margin-top: 2px;
}
.form-textarea { min-height: 140px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* PHOTO PLACEHOLDER
   A clearly-temporary image placeholder so the user knows real photos go here.
   Variants: --hero (4:5), --portrait (3:4), --landscape (4:3), --square (1:1). */
.photo-placeholder {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--k-blue-light) 0%, var(--k-sky) 100%);
  border-radius: var(--r-lg);
  overflow: hidden;
  text-align: center;
  color: var(--k-blue-dark);
  background-size: cover;
  background-position: center;
}
.photo-placeholder::before {
  content: '';
  position: absolute; inset: 0;
  background-image:
    linear-gradient(135deg, transparent 49.5%, rgba(0,71,187,0.06) 49.5%, rgba(0,71,187,0.06) 50.5%, transparent 50.5%);
  background-size: 24px 24px;
  pointer-events: none;
}
.photo-placeholder__label {
  position: relative;
  font-family: var(--font-ui);
  font-size: 0.75rem; font-weight: 600;
  color: var(--k-blue-dark);
  background: rgba(255,255,255,0.85);
  padding: 6px 14px;
  border-radius: var(--r-pill);
  border: 1px solid rgba(0,71,187,0.18);
  max-width: 80%;
}
.photo-placeholder--hero      { aspect-ratio: 4/5; width: 100%; max-width: 420px; }
.photo-placeholder--portrait  { aspect-ratio: 3/4; width: 100%; max-width: 280px; }
.photo-placeholder--landscape { aspect-ratio: 4/3; width: 100%; }
.photo-placeholder--square    { aspect-ratio: 1/1; width: 100%; }

/* Dark variant — placeholder on navy section backgrounds */
.photo-placeholder--dark {
  background: linear-gradient(135deg, rgba(255,255,255,0.06) 0%, rgba(255,255,255,0.03) 100%);
  border: 1px solid rgba(255,255,255,0.10);
}
.photo-placeholder--dark::before {
  background-image:
    linear-gradient(135deg, transparent 49.5%, rgba(255,255,255,0.04) 49.5%, rgba(255,255,255,0.04) 50.5%, transparent 50.5%);
}
.photo-placeholder--dark .photo-placeholder__label {
  background: rgba(0,0,0,0.30);
  color: rgba(255,255,255,0.70);
  border-color: rgba(255,255,255,0.15);
}


/* When a background-image is set inline, hide the placeholder chrome. */
.photo-placeholder[style*="background-image"]::before,
.photo-placeholder[style*="background-image"] .photo-placeholder__label { display: none; }


/* STAR RATING */
.star-rating {
  display: flex; align-items: center; gap: 4px;
}
.star-rating .stars { color: #F5A623; font-size: 0.875rem; letter-spacing: 1px; }
.star-rating .stars--sm { font-size: 0.75rem; }
.star-rating .stars--lg { font-size: 1.125rem; }
.star-rating .rating-count {
  font-size: 0.8125rem; color: var(--k-blue);
  font-weight: 500; text-decoration: underline; cursor: pointer;
}

/* TOAST */
.toast {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px;
  border-radius: var(--r-lg);
  font-family: var(--font-ui);
  box-shadow: 0 8px 32px rgba(0,0,0,0.14);
  min-width: 280px; max-width: 400px;
  animation: toast-in var(--dur-slow) var(--ease);
}
.toast--success { background: var(--k-green-dark); color: #fff; }
.toast--info    { background: var(--k-navy);        color: #fff; }
.toast--warning { background: var(--color-warning); color: #fff; }
.toast--error   { background: var(--color-error);   color: #fff; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.toast-stack {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 1100; pointer-events: none;
}
.toast-stack .toast { pointer-events: auto; }

/* EMPTY STATE */
.empty-state {
  text-align: center;
  padding: 64px 16px;
  background: var(--k-gray-50);
  border-radius: var(--r-xl);
  border: 1px dashed var(--k-gray-300);
}
.empty-state__icon  { font-size: 3rem; margin-bottom: 12px; }
.empty-state__title { font-size: 1.0625rem; font-weight: 700; color: var(--k-navy); margin-bottom: 4px; }
.empty-state__desc  { font-size: 0.875rem; color: var(--k-gray-500); max-width: 280px; margin: 0 auto 20px; }

/* FILTER CHIP */
.filter-bar {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 8px; margin-bottom: 20px;
}
.filter-chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.8125rem; font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--r-pill);
  border: 1.5px solid var(--k-gray-200);
  background: var(--k-white);
  color: var(--k-gray-700);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
}
.filter-chip:hover { border-color: var(--k-blue-mid); }
.filter-chip.active {
  background: var(--k-blue-light);
  border-color: var(--k-blue);
  color: var(--k-blue);
}
.filter-chip__remove {
  font-size: 0.875rem; color: var(--k-gray-300); line-height: 1;
  background: none; border: none; cursor: pointer; padding: 0;
}
.sort-select {
  margin-left: auto;
  font-size: 0.8125rem; font-weight: 600;
  padding: 7px 12px;
  border-radius: var(--r-md);
  border: 1.5px solid var(--k-gray-200);
  background: var(--k-white);
  color: var(--k-gray-700);
  font-family: var(--font-ui); cursor: pointer;
}

/* PAGINATION */
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 4px; margin-top: 40px;
}
.page-btn {
  width: 36px; height: 36px;
  border-radius: var(--r-md);
  border: 1px solid var(--k-gray-200);
  background: var(--k-white);
  font-size: 0.875rem; font-weight: 600;
  color: var(--k-gray-700);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-ui);
  transition: all var(--dur-fast) var(--ease);
  text-decoration: none;
}
.page-btn.active {
  background: var(--k-blue); color: #fff; border-color: var(--k-blue);
}
.page-btn:hover:not(.active) {
  background: var(--k-blue-light); border-color: var(--k-blue-mid);
}

/* FORMAT SELECTOR PILLS (product page variation) */
.format-options {
  display: flex; gap: 8px; flex-wrap: wrap;
}
.format-option {
  padding: 8px 16px;
  border-radius: var(--r-md);
  border: 1.5px solid var(--k-gray-200);
  background: var(--k-white);
  font-size: 0.8125rem; font-weight: 600;
  color: var(--k-gray-700);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
  user-select: none;
}
.format-option:hover,
.format-option.selected {
  border-color: var(--k-blue);
  color: var(--k-blue);
  background: var(--k-blue-light);
}
.format-option.out-of-stock {
  opacity: 0.4; cursor: not-allowed; text-decoration: line-through;
}

/* QUANTITY STEPPER */
.qty-stepper {
  display: inline-flex; align-items: stretch;
  border: 1.5px solid var(--k-gray-200);
  border-radius: var(--r-md);
  overflow: hidden;
  height: 44px;
}
.qty-stepper button {
  width: 40px; background: var(--k-gray-50);
  font-size: 1rem; font-weight: 700;
  color: var(--k-gray-700); cursor: pointer;
}
.qty-stepper button:hover { background: var(--k-blue-light); color: var(--k-blue); }
.qty-stepper input {
  width: 56px; text-align: center;
  font-family: var(--font-ui); font-size: 0.9375rem; font-weight: 600;
  border: none; outline: none;
  border-left: 1.5px solid var(--k-gray-200);
  border-right: 1.5px solid var(--k-gray-200);
}

/* SKELETON LOADER */
.skeleton {
  background: linear-gradient(90deg, var(--k-gray-100) 25%, var(--k-gray-200) 50%, var(--k-gray-100) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: var(--r-sm);
}
@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton--line { height: 12px; margin-bottom: 8px; }
.skeleton--title { height: 20px; margin-bottom: 12px; }
.skeleton--card { aspect-ratio: 4/3; }

/* LOADING BUTTON */
.btn.is-loading {
  opacity: 0.7;
  pointer-events: none;
  cursor: not-allowed;
}
.btn.is-loading::after {
  content: '';
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: btn-spin 0.7s linear infinite;
  margin-left: 8px;
  vertical-align: middle;
}
@keyframes btn-spin {
  to { transform: rotate(360deg); }
}

/* TRUST BAR — COMPACT (product page 3-col) */
.trust-bar-compact {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 16px 0;
}
.trust-item {
  display: flex; flex-direction: column;
  align-items: center; text-align: center;
  padding: 8px 4px;
  background: var(--k-gray-50);
  border-radius: var(--r-md);
  border: 1px solid var(--k-gray-100);
}
.trust-item__icon  { font-size: 1.25rem; margin-bottom: 3px; }
.trust-item__label { font-size: 0.6875rem; font-weight: 700; color: var(--k-gray-700); }

/* CHECKOUT PROGRESS */
.checkout-progress {
  display: flex; align-items: center;
  margin-bottom: 32px;
}
.checkout-step {
  display: flex; flex-direction: column; align-items: center;
  flex: 1; position: relative;
}
.checkout-step::after {
  content: '';
  position: absolute; top: 14px; left: 50%;
  width: 100%; height: 2px;
  background: var(--k-gray-200); z-index: 0;
}
.checkout-step:last-child::after { display: none; }
.checkout-step__dot {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid var(--k-gray-200);
  background: var(--k-white);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700;
  color: var(--k-gray-500);
  position: relative; z-index: 1;
}
.checkout-step.is-done .checkout-step__dot {
  background: var(--k-green); border-color: var(--k-green); color: #fff;
}
.checkout-step.is-done::after { background: var(--k-green); }
.checkout-step.is-active .checkout-step__dot {
  background: var(--k-blue); border-color: var(--k-blue); color: #fff;
}
.checkout-step__label {
  font-size: 0.6875rem; font-weight: 600;
  color: var(--k-gray-500); margin-top: 4px;
  text-align: center;
}
.checkout-step.is-active .checkout-step__label { color: var(--k-blue); }
.checkout-step.is-done   .checkout-step__label { color: var(--k-green-dark); }
