/* Menu item constructor modal (storefront + directory) */

.sf-modal {
  border: none;
  border-radius: var(--dir-radius, 18px);
  padding: 0;
  background: transparent;
  max-width: min(880px, calc(100vw - 1.5rem));
  width: 100%;
  max-height: min(90vh, 760px);
  color: inherit;
}

.sf-modal::backdrop {
  background: rgba(20, 16, 12, 0.55);
}

.sf-ctor-form.sf-modal__panel {
  position: relative;
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  max-height: min(90vh, 760px);
  background: var(--dir-surface, #fff);
  border-radius: var(--dir-radius, 18px);
  box-shadow: var(--dir-shadow, 0 18px 48px rgba(0, 0, 0, 0.22));
  overflow: hidden;
}

.sf-ctor {
  display: grid;
  grid-template-columns: minmax(240px, 0.9fr) minmax(0, 1.15fr);
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
}

.sf-ctor__close {
  position: absolute;
  top: 0.7rem;
  right: 0.7rem;
  z-index: 6;
  width: 2.2rem;
  height: 2.2rem;
  border: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--dir-surface, #fff) 90%, #000 4%);
  color: var(--dir-text-muted, #78716c);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.sf-ctor__visual {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  padding: 1.75rem 1.25rem;
  background:
    radial-gradient(90% 70% at 50% 30%, color-mix(in srgb, var(--dir-accent-soft, #ccfbf1) 75%, transparent), transparent 72%),
    color-mix(in srgb, var(--dir-surface-2, #f5f5f4) 88%, var(--dir-page-bg, #f4f1ec));
  min-height: 0;
}

.sf-ctor__media {
  width: min(100%, 300px);
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  overflow: hidden;
  background: var(--dir-surface, #fff);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.12);
  flex: 0 0 auto;
}

.sf-ctor__media > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.sf-ctor__media.is-empty {
  display: grid;
  place-items: center;
  border-radius: var(--dir-radius, 18px);
  aspect-ratio: 1 / 1;
  font-size: 2.75rem;
  color: var(--dir-accent, #0f766e);
  background:
    linear-gradient(145deg, var(--dir-accent-soft, #ccfbf1), color-mix(in srgb, var(--dir-accent, #0f766e) 12%, var(--dir-surface, #fff)));
}

.sf-ctor__main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--dir-surface, #fff);
  border-left: 1px solid var(--dir-border, #e5e0d8);
}

.sf-ctor__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1.1rem 1.2rem 0.55rem;
  padding-right: 3rem;
  flex: 0 0 auto;
}

.sf-ctor__title {
  margin: 0;
  font-family: var(--dir-font-display, "Fraunces", Georgia, serif);
  font-size: clamp(1.3rem, 2.2vw, 1.55rem);
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.sf-ctor__desc {
  margin: 0.35rem 0 0;
  color: var(--dir-text-muted, #78716c);
  font-size: 0.92rem;
  line-height: 1.4;
}

.sf-ctor__summary {
  margin: 0.4rem 0 0;
  font-size: 0.84rem;
  color: var(--dir-accent, #0f766e);
  font-weight: 560;
  line-height: 1.35;
}

.sf-ctor__reset {
  border: 0;
  background: transparent;
  color: var(--dir-accent, #0f766e);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  padding: 0.2rem 0;
}

.sf-ctor__nav {
  display: flex;
  gap: 0.15rem;
  overflow-x: auto;
  padding: 0.15rem 1rem 0;
  border-bottom: 1px solid var(--dir-border, #e5e0d8);
  scrollbar-width: none;
  flex: 0 0 auto;
  background: var(--dir-surface, #fff);
}

.sf-ctor__nav::-webkit-scrollbar {
  display: none;
}

.sf-ctor__nav-btn {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: var(--dir-text-muted, #78716c);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 560;
  padding: 0.55rem 0.7rem;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
}

.sf-ctor__nav-btn.is-active {
  color: var(--dir-text, #1c1917);
  border-bottom-color: var(--dir-accent, #0f766e);
}

.sf-ctor__nav-btn.has-pick::after {
  content: "";
  display: inline-block;
  width: 0.38rem;
  height: 0.38rem;
  margin-left: 0.3rem;
  border-radius: 999px;
  background: var(--dir-accent, #0f766e);
  vertical-align: middle;
}

.sf-ctor__scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.9rem 1.15rem 1.1rem;
  overscroll-behavior: contain;
}

.sf-ctor__section {
  scroll-margin-top: 0.35rem;
  margin-bottom: 1.4rem;
}

.sf-ctor__section:last-child {
  margin-bottom: 0.35rem;
}

.sf-ctor__section-title {
  margin: 0 0 0.65rem;
  font-family: var(--dir-font-display, "Fraunces", Georgia, serif);
  font-size: 1.05rem;
  font-weight: 620;
}

.sf-ctor__section-hint {
  margin: -0.3rem 0 0.65rem;
  font-size: 0.8rem;
  color: var(--dir-text-muted, #78716c);
}

/* Single-select: chip row */
.sf-ctor__pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.sf-ctor__pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.6rem 0.95rem;
  border-radius: 999px;
  border: 1.5px solid var(--dir-border, #e5e0d8);
  background: var(--dir-surface, #fff);
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 560;
  color: var(--dir-text, #1c1917);
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.sf-ctor__pill input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.sf-ctor__pill.is-on,
.sf-ctor__pill:has(input:checked) {
  border-color: var(--dir-accent, #0f766e);
  background: color-mix(in srgb, var(--dir-accent-soft, #ccfbf1) 55%, var(--dir-surface, #fff));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--dir-accent, #0f766e) 25%, transparent);
}

.sf-ctor__pill-price {
  color: var(--dir-text-muted, #78716c);
  font-size: 0.8rem;
  font-weight: 500;
}

/* Option tiles: compact 3–4 column cards */
.sf-ctor__list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(5.6rem, 1fr));
  gap: 0.5rem;
}

.sf-ctor__tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.3rem;
  min-width: 0;
  padding: 0.4rem;
  border: 1.5px solid var(--dir-border, #e5e0d8);
  border-radius: var(--dir-radius-sm, 12px);
  background: var(--dir-surface, #fff);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
  user-select: none;
}

.sf-ctor__tile:hover {
  border-color: color-mix(in srgb, var(--dir-accent, #0f766e) 35%, var(--dir-border, #e5e0d8));
}

.sf-ctor__tile.is-on,
.sf-ctor__tile:has(input:checked) {
  border-color: var(--dir-accent, #0f766e);
  background: color-mix(in srgb, var(--dir-accent-soft, #ccfbf1) 42%, var(--dir-surface, #fff));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--dir-accent, #0f766e) 22%, transparent);
}

.sf-ctor__tile > input[type="checkbox"],
.sf-ctor__tile > input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
  margin: 0;
}

.sf-ctor__tile-media {
  aspect-ratio: 1 / 1;
  width: 100%;
  border-radius: 0.55rem;
  overflow: hidden;
  background: var(--dir-surface-2, #f5f5f4);
  border: 1px solid var(--dir-border, #e5e0d8);
}

.sf-ctor__tile-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.sf-ctor__tile-media.is-empty {
  display: grid;
  place-items: center;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--dir-accent, #0f766e);
  background:
    linear-gradient(145deg, var(--dir-accent-soft, #ccfbf1), color-mix(in srgb, var(--dir-accent, #0f766e) 10%, var(--dir-surface, #fff)));
}

.sf-ctor__tile-name {
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.2;
  min-height: 2.4em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--dir-text, #1c1917);
}

.sf-ctor__tile-price {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--dir-text, #1c1917);
  white-space: nowrap;
}

.sf-ctor__tile-step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  margin-top: 0.1rem;
}

.sf-ctor__tile-step button {
  width: 1.45rem;
  height: 1.45rem;
  border: 0;
  border-radius: 999px;
  background: var(--dir-accent-soft, #ccfbf1);
  color: var(--dir-accent, #0f766e);
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
  font-size: 0.85rem;
}

.sf-ctor__tile-step input {
  width: 1.4rem;
  border: 0;
  text-align: center;
  background: transparent;
  font: inherit;
  font-weight: 620;
  font-size: 0.8rem;
  padding: 0;
}

/* Legacy row styles kept for safety if old markup appears */
.sf-ctor__row {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.8rem;
  border: 1.5px solid var(--dir-border, #e5e0d8);
  border-radius: var(--dir-radius-sm, 12px);
  background: var(--dir-surface, #fff);
  cursor: pointer;
}

.sf-ctor__row-name {
  font-size: 0.95rem;
  font-weight: 560;
  line-height: 1.3;
  min-width: 0;
}

.sf-ctor__row-price {
  font-size: 0.9rem;
  font-weight: 650;
  white-space: nowrap;
}

.sf-ctor__row-step {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.sf-ctor__row-step button {
  width: 1.7rem;
  height: 1.7rem;
  border: 0;
  border-radius: 999px;
  background: var(--dir-accent-soft, #ccfbf1);
  color: var(--dir-accent, #0f766e);
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
}

.sf-ctor__row-step input {
  width: 1.7rem;
  border: 0;
  text-align: center;
  background: transparent;
  font: inherit;
  font-weight: 620;
  font-size: 0.9rem;
  padding: 0;
}

.sf-ctor__foot {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.75rem 1.1rem 0.95rem;
  border-top: 1px solid var(--dir-border, #e5e0d8);
  background: var(--dir-surface, #fff);
  flex: 0 0 auto;
}

.sf-modal__qty {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  border: 1px solid var(--dir-border, #e5e0d8);
  border-radius: 999px;
  padding: 0.15rem 0.3rem;
  flex: 0 0 auto;
}

.sf-modal__qty button {
  border: 0;
  background: transparent;
  width: 1.85rem;
  height: 1.85rem;
  cursor: pointer;
  color: var(--dir-accent, #0f766e);
  font-weight: 700;
  font-size: 1.05rem;
}

.sf-modal__qty input {
  width: 2rem;
  border: 0;
  text-align: center;
  background: transparent;
  font: inherit;
  font-weight: 620;
}

.sf-ctor__submit {
  flex: 1 1 auto;
  display: inline-flex !important;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 2.85rem;
  padding: 0.7rem 1.1rem !important;
  border-radius: var(--dir-radius-pill, 999px) !important;
}

.sf-ctor__extras-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
  width: min(100%, 300px);
}

.sf-ctor__extras-block[hidden] {
  display: none !important;
}

.sf-ctor__extras-title {
  margin: 0;
  font-family: var(--dir-font-display, "Fraunces", Georgia, serif);
  font-size: 0.95rem;
  font-weight: 650;
  line-height: 1.2;
  text-align: center;
  color: var(--dir-text, #1c1917);
}

.sf-ctor__extras {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.55rem 0.45rem;
  width: 100%;
  margin: 0;
}

.sf-ctor__extras[hidden] {
  display: none !important;
}

.sf-ctor__extra-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  width: 3.1rem;
}

.sf-ctor__extra-thumb {
  position: relative;
  width: 2.85rem;
  height: 2.85rem;
  border-radius: 0.55rem;
  border: 1px solid var(--dir-border, #e5e0d8);
  background: var(--dir-surface, #fff);
  padding: 0;
  overflow: visible;
  cursor: help;
  font-size: 0.75rem;
  font-weight: 650;
  color: var(--dir-accent, #0f766e);
}

.sf-ctor__extra-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  display: block;
}

.sf-ctor__extra-price {
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--dir-text, #1c1917);
  white-space: nowrap;
  text-align: center;
}

.sf-ctor__extra-tip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 0.35rem);
  transform: translateX(-50%);
  min-width: 9rem;
  max-width: 14rem;
  padding: 0.45rem 0.55rem;
  border-radius: 0.55rem;
  background: rgba(20, 24, 28, 0.92);
  color: #fff;
  font-size: 0.72rem;
  line-height: 1.25;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 5;
  text-align: left;
  font-weight: 500;
}

.sf-ctor__extra-thumb:hover .sf-ctor__extra-tip,
.sf-ctor__extra-thumb:focus-visible .sf-ctor__extra-tip {
  opacity: 1;
}

.sf-ctor__opt-img {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 0.45rem;
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid var(--dir-border, #e5e0d8);
}

.sf-ctor__opt-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.sf-ctor__pill .sf-ctor__opt-img {
  width: 1.55rem;
  height: 1.55rem;
}

.sf-ctor__submit-price {
  font-weight: 700;
}

.sf-ctor__error {
  margin: 0;
  padding: 0 1.1rem 0.75rem;
  color: #b91c1c;
  font-size: 0.85rem;
  flex: 0 0 auto;
}

@media (max-width: 720px) {
  .sf-modal {
    max-width: calc(100vw - 0.75rem);
    max-height: 94vh;
  }

  .sf-ctor-form.sf-modal__panel {
    max-height: 94vh;
  }

  .sf-ctor {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .sf-ctor__visual {
    padding: 0.85rem 1rem 0.4rem;
  }

  .sf-ctor__media {
    width: min(42vw, 160px);
  }

  .sf-ctor__list {
    grid-template-columns: repeat(auto-fill, minmax(5.1rem, 1fr));
  }

  .sf-ctor__main {
    border-left: 0;
    border-top: 1px solid var(--dir-border, #e5e0d8);
    min-height: 0;
  }

  .sf-ctor__foot {
    padding-bottom: calc(0.85rem + env(safe-area-inset-bottom, 0px));
  }
}
