/**
 * @file
 * Kit builder. Override the --mkb-* custom properties on .mkb to restyle it.
 * Uses logical properties so it works in Hebrew (RTL) and English (LTR).
 */
.mkb,
.mkb-preview {
  /* yarn.co.il standard: Noto Sans, #333/#555 text, #eee borders, #f8f9fa
     panels, 12px corners. Brand blue #2ba9e0 for highlights; filled buttons
     use the deeper #1778a6 so white text stays readable (about 5:1). */
  --mkb-brand: #2ba9e0;
  --mkb-accent: #1778a6;
  --mkb-accent-strong: #135f85;
  --mkb-accent-soft: #e6f4fb;
  --mkb-accent-line: #a9d8ee;
  --mkb-ink: #333;
  --mkb-text: #555;
  --mkb-muted: #666;
  --mkb-line: #eee;
  --mkb-line-strong: #d9d9d9;
  --mkb-surface: #fff;
  --mkb-soft: #f8f9fa;
  --mkb-chip: #f1f3f5;
  --mkb-warn-bg: #fff4d6;
  --mkb-warn: #6b4a00;
  --mkb-ok: #2e7d4f;
  --mkb-radius: 12px;
  font-family: 'Noto Sans', 'Noto Sans Hebrew', Arial, sans-serif;
}

.mkb {
  margin-block: 32px;
  color: var(--mkb-ink);
  line-height: 1.5;
}

.mkb *,
.mkb *::before,
.mkb *::after {
  box-sizing: border-box;
}

.mkb button {
  font: inherit;
  color: inherit;
}

.mkb :focus-visible {
  outline: 2px solid var(--mkb-accent);
  outline-offset: 2px;
}

.mkb-icon {
  width: 1.1em;
  height: 1.1em;
  flex: none;
}

.mkb__loading,
.mkb-hint {
  color: var(--mkb-muted);
  font-size: 0.9rem;
  margin: 0;
}

.mkb-alert {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--mkb-warn-bg);
  color: var(--mkb-warn);
  font-size: 0.875rem;
}

.mkb-banner {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-block-end: 16px;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--mkb-accent-soft);
  color: var(--mkb-accent-strong);
  font-weight: 600;
}

/* Admin preview bar on kits customers cannot see */
.mkb-preview {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-block: 16px 0;
  padding: 10px 16px;
  border: 1px solid #f0d58a;
  border-radius: 8px;
  background: var(--mkb-warn-bg);
  color: var(--mkb-warn);
  font-size: 0.9rem;
}

.mkb-preview--unpublished {
  border-color: #e3b4b4;
  background: #fdecec;
  color: #8a1f1f;
}

.mkb-preview__link {
  margin-inline-start: auto;
  color: inherit !important;
  font-weight: 700;
}

/* Layout: builder beside a summary; the summary drops below on narrow screens. */
.mkb-layout {
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
  align-items: flex-start;
}

.mkb-main {
  flex: 999 1 600px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-margin-top: 16px;
}

/* Step tabs */
.mkb-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mkb-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 8px 16px 8px 14px;
  border: 1.5px solid var(--mkb-line);
  border-radius: 14px;
  background: #fafbfc;
  cursor: pointer;
  text-align: start;
}

.mkb-tab.is-selected {
  border-color: var(--mkb-accent);
  background: var(--mkb-surface);
}

.mkb-tab__num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 50%;
  background: var(--mkb-chip);
  color: var(--mkb-text);
  font-size: 0.8125rem;
  font-weight: 700;
}

.mkb-tab.is-selected .mkb-tab__num {
  background: var(--mkb-ink);
  color: #fff;
}

.mkb-tab.is-done .mkb-tab__num {
  background: var(--mkb-accent);
  color: #fff;
}

.mkb-tab__text {
  display: flex;
  flex-direction: column;
}

.mkb-tab__label {
  font-weight: 700;
}

.mkb-tab__status {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--mkb-muted);
}

.mkb-tab.is-done .mkb-tab__status {
  color: var(--mkb-accent-strong);
}

/* Step panel */
.mkb-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px;
  border: 1px solid var(--mkb-line);
  border-radius: var(--mkb-radius);
  background: var(--mkb-surface);
}

.mkb-panel__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px 16px;
}

.mkb-panel__title {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 700;
}

.mkb-panel__hint {
  margin: 4px 0 0;
  color: var(--mkb-muted);
}

.mkb-chip {
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--mkb-chip);
  color: var(--mkb-text);
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
}

.mkb-chip.is-done {
  background: var(--mkb-accent-soft);
  color: var(--mkb-accent-strong);
}

.mkb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.mkb-panel__nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--mkb-line);
}

/* Item cards */
.mkb-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border: 1.5px solid var(--mkb-line);
  border-radius: var(--mkb-radius);
  background: var(--mkb-surface);
}

.mkb-card.is-selected {
  border-color: var(--mkb-accent);
  background: #f3fafd;
}

.mkb-card__media {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 12px;
  background: var(--mkb-chip);
  color: #767676;
}

.mkb-card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mkb-card__media .mkb-icon {
  width: 44px;
  height: 44px;
}

.mkb-card__badge {
  position: absolute;
  inset-block-start: 10px;
  inset-inline-start: 10px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--mkb-accent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
}

.mkb-card__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.mkb-card__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.3;
}

.mkb-card__price {
  font-weight: 700;
  white-space: nowrap;
  text-align: end;
}

.mkb-card__price small {
  display: block;
  color: var(--mkb-muted);
  font-size: 0.72rem;
  font-weight: 500;
}

.mkb-card__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
}

.mkb-card__variant {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  color: var(--mkb-text);
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

.mkb-card__stock {
  color: var(--mkb-ok);
  font-size: 0.8rem;
  font-weight: 600;
}

.mkb-card__stock.is-full {
  color: #8a5a00;
}

/* Color and option swatches */
.mkb-swatches {
  display: flex;
  flex-wrap: wrap;
  margin: -4px -7px;
}

.mkb-swatch {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

.mkb-swatch img {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-radius: 50%;
  object-fit: cover;
}

.mkb-swatch.is-active img {
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--mkb-brand);
}

.mkb-swatch.is-text {
  width: auto;
  min-width: 44px;
  padding: 0 4px;
}

.mkb-swatch__text {
  padding: 5px 10px;
  border: 1px solid var(--mkb-line-strong);
  border-radius: 999px;
  font-size: 0.8rem;
  white-space: nowrap;
}

.mkb-swatch.is-text.is-active .mkb-swatch__text {
  border-color: var(--mkb-accent);
  background: var(--mkb-accent-soft);
  color: var(--mkb-accent-strong);
  font-weight: 700;
}

.mkb-swatch__count {
  position: absolute;
  inset-block-start: 1px;
  inset-inline-end: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--mkb-accent);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 700;
}

/* Quantity stepper */
.mkb-stepper {
  display: flex;
  align-items: center;
  flex: none;
  border: 1px solid var(--mkb-line-strong);
  border-radius: 999px;
  background: var(--mkb-surface);
}

.mkb-stepper__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 40px;
  border: 0;
  background: none;
  color: var(--mkb-accent) !important;
  cursor: pointer;
}

.mkb-stepper__btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.mkb-stepper__value {
  min-width: 26px;
  font-weight: 700;
  text-align: center;
}

/* Buttons */
.mkb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  border: 1px solid var(--mkb-line-strong);
  border-radius: 8px;
  background: var(--mkb-surface);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.mkb-btn--outline {
  border: 1.5px solid var(--mkb-accent);
  color: var(--mkb-accent) !important;
  font-weight: 700;
}

.mkb-btn--primary {
  border: 0;
  background: var(--mkb-accent);
  color: #fff !important;
  font-weight: 700;
}

.mkb-btn--primary:hover {
  background: var(--mkb-accent-strong);
}

.mkb-btn--primary:disabled {
  background: var(--mkb-line);
  color: var(--mkb-text) !important;
  cursor: not-allowed;
}

.mkb-add {
  width: 100%;
  min-height: 54px;
  font-size: 1.05rem;
}

/* Summary */
.mkb-summary {
  position: sticky;
  top: 20px;
  flex: 1 1 320px;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 22px;
  border: 1px solid var(--mkb-line);
  border-radius: var(--mkb-radius);
  background: var(--mkb-surface);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
}

.mkb-summary__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.mkb-summary__title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
}

.mkb-summary__count,
.mkb-summary__note {
  color: var(--mkb-muted);
  font-size: 0.8rem;
}

.mkb-summary__note {
  margin: 0;
  text-align: center;
}

.mkb-summary__groups {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mkb-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mkb-group__head {
  display: flex;
  justify-content: space-between;
  font-size: 0.8125rem;
}

.mkb-group__title {
  font-weight: 700;
}

.mkb-group__count {
  color: var(--mkb-accent-strong);
  font-weight: 600;
}

.mkb-group__empty {
  color: #767676;
  font-size: 0.8125rem;
}

.mkb-line {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--mkb-text);
  font-size: 0.85rem;
}

.mkb-line__thumb {
  width: 22px;
  height: 22px;
  flex: none;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 50%;
  background: var(--mkb-chip);
  object-fit: cover;
}

.mkb-line__name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mkb-line__price {
  white-space: nowrap;
}

.mkb-line__remove {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin: -4px 0;
  margin-inline-end: -6px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--mkb-muted) !important;
  cursor: pointer;
}

.mkb-line__remove:hover {
  background: var(--mkb-chip);
}

.mkb-totals {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding-top: 14px;
  border-top: 1px solid var(--mkb-line);
  font-size: 0.875rem;
}

.mkb-totals > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  color: var(--mkb-text);
}

.mkb-totals dt,
.mkb-totals dd {
  margin: 0;
}

.mkb-totals__discount {
  color: var(--mkb-accent) !important;
  font-weight: 600;
}

.mkb-totals__total {
  margin-top: 4px;
  color: var(--mkb-ink) !important;
}

.mkb-totals__total dt {
  font-weight: 700;
  font-size: 0.95rem;
}

.mkb-totals__total dd {
  font-weight: 700;
  font-size: 1.6rem;
}

/* Bottom bar for phones */
.mkb-mobilebar {
  display: none;
}

/* Added-to-cart dialog */
.mkb-dialog {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.45);
}

.mkb-dialog__box {
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: 100%;
  max-width: 480px;
  padding: 26px;
  border-radius: var(--mkb-radius);
  background: var(--mkb-surface);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.2);
}

.mkb-dialog__head {
  display: flex;
  align-items: center;
  gap: 14px;
}

.mkb-dialog__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  flex: none;
  border-radius: 50%;
  background: var(--mkb-accent-soft);
  color: var(--mkb-accent);
}

.mkb-dialog__title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
}

.mkb-dialog__text {
  margin: 2px 0 0;
  color: var(--mkb-text);
}

.mkb-dialog__actions {
  display: flex;
  gap: 10px;
}

.mkb-dialog__actions > * {
  flex: 1;
  min-height: 50px;
}

/* Yarn amounts: pattern option and size picker in yarn steps */
.mkb-size {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 18px;
  border: 1px solid var(--mkb-accent-line);
  border-radius: var(--mkb-radius);
  background: var(--mkb-accent-soft);
  scroll-margin-top: 16px;
}

.mkb-size__head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px 16px;
}

.mkb-size__title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--mkb-ink);
}

.mkb-size__note {
  margin: 0;
  color: var(--mkb-muted);
  font-size: 0.85rem;
}

.mkb-size__link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--mkb-accent) !important;
  font-size: 0.875rem;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.mkb-size__group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mkb-size__label {
  color: var(--mkb-muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.mkb-sizes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mkb-sizebtn,
.mkb-optbtn {
  flex: none;
  border: 1.5px solid var(--mkb-line-strong);
  background: var(--mkb-surface);
  cursor: pointer;
}

.mkb-sizebtn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 62px;
  min-height: 52px;
  padding: 4px 10px;
  border-radius: 10px;
  line-height: 1.2;
}

.mkb-sizebtn b {
  font-size: 0.95rem;
}

.mkb-sizebtn small {
  color: var(--mkb-muted);
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
}

.mkb-optbtn {
  min-height: 44px;
  padding: 6px 16px;
  border-radius: 999px;
  font-weight: 700;
}

.mkb-sizebtn.is-active,
.mkb-optbtn.is-active {
  border-color: var(--mkb-accent);
  background: var(--mkb-accent);
  color: #fff !important;
}

.mkb-sizebtn.is-active small {
  color: #dff1fa;
}

.mkb-amounts {
  overflow-x: auto;
  border: 1px solid var(--mkb-line);
  border-radius: 10px;
  background: var(--mkb-surface);
}

.mkb-amounts table {
  width: 100%;
  margin: 0;
  border-collapse: collapse;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.mkb-amounts th,
.mkb-amounts td {
  padding: 8px 12px;
  border: 0;
  border-bottom: 1px solid var(--mkb-line);
  text-align: center;
  white-space: nowrap;
}

.mkb-amounts thead th {
  min-width: 90px;
  background: var(--mkb-soft);
  font-weight: 700;
  white-space: normal;
  vertical-align: bottom;
}

.mkb-amounts thead th:first-child,
.mkb-amounts tbody th {
  min-width: 0;
  text-align: start;
  font-weight: 700;
}

.mkb-amounts tbody tr:last-child > * {
  border-bottom: 0;
}

.mkb-amounts tr.is-active > * {
  background: #fff7df;
  font-weight: 700;
}

.mkb-amounts__cap {
  margin: 0;
  padding: 8px 12px;
  border-top: 1px solid var(--mkb-line);
  color: var(--mkb-muted);
  font-size: 0.78rem;
}

/* Balls needed, on a yarn card */
.mkb-rec {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border-radius: 10px;
  background: var(--mkb-accent-soft);
  color: var(--mkb-accent-strong);
  font-size: 0.85rem;
  line-height: 1.4;
}

.mkb-rec__text {
  display: flex;
  flex-direction: column;
}

.mkb-rec__text b {
  color: var(--mkb-ink);
  font-size: 0.95rem;
}

.mkb-rec__text small {
  font-size: 0.78rem;
}

/* Chosen option and size, in the kit summary */
.mkb-sumsize {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--mkb-accent-soft);
  color: var(--mkb-accent-strong);
  font-size: 0.85rem;
  font-weight: 700;
}

.mkb-sumsize button {
  padding: 0;
  border: 0;
  background: none;
  color: inherit !important;
  font-size: 0.8rem;
  text-decoration: underline;
  cursor: pointer;
}

@media (max-width: 900px) {
  .mkb {
    padding-bottom: 96px;
  }

  .mkb-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    margin-inline: -16px;
    padding-inline: 16px;
    scrollbar-width: none;
  }

  .mkb-tab {
    flex: none;
  }

  .mkb-panel {
    padding: 16px;
  }

  .mkb-size {
    padding: 14px;
  }

  .mkb-size .mkb-sizes {
    flex-wrap: nowrap;
    overflow-x: auto;
    margin-inline: -4px;
    padding: 2px 4px 4px;
    scrollbar-width: none;
  }

  .mkb-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
  }

  .mkb-summary {
    position: static;
    max-width: none;
  }

  .mkb-summary .mkb-add {
    display: none;
  }

  .mkb-mobilebar {
    position: fixed;
    inset-inline: 0;
    bottom: 0;
    z-index: 500;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--mkb-line);
    background: var(--mkb-surface);
    box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.08);
  }

  .mkb-mobilebar__price {
    display: flex;
    flex-direction: column;
    flex: none;
  }

  .mkb-mobilebar__label {
    color: var(--mkb-muted);
    font-size: 0.75rem;
  }

  .mkb-mobilebar strong {
    font-size: 1.3rem;
  }

  .mkb-mobilebar s {
    color: var(--mkb-muted);
    font-size: 0.85rem;
  }

  .mkb-mobilebar .mkb-add {
    flex: 1;
    min-height: 50px;
  }

  .mkb-dialog {
    align-items: flex-end;
    padding: 0;
  }

  .mkb-dialog__box {
    max-width: none;
    border-radius: var(--mkb-radius) var(--mkb-radius) 0 0;
  }

  .mkb-dialog__actions {
    flex-direction: column;
  }
}

@media (max-width: 420px) {
  .mkb-grid {
    grid-template-columns: 1fr;
  }
}