/* ==========================================================================
   LAAN JEWELRY — Custom Builder (خواست) styles
   Uses the shared design tokens from style.css. Mobile-first, RTL-safe.
   ========================================================================== */

.builder-hero { text-align: center; padding: clamp(28px, 6vw, 64px) 0 clamp(12px, 3vw, 24px); }
.builder-hero .accent.script { color: var(--gold-deep); font-style: italic; }

/* --- step 1: pick a real catalog piece to build on --- */
.base-pick { margin-bottom: clamp(16px, 3vw, 24px); }
.base-pick-head { margin-bottom: 14px; }
.base-pick-head h2 { font-size: var(--t-md); margin: 0 0 4px; }
.base-pick-head p { font-size: var(--t-sm); margin: 0; }
.base-pick .base-switch { margin: 0 0 16px; }

.base-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.base-card {
  display: flex; flex-direction: column; gap: 2px; padding: 0 0 12px; text-align: start;
  background: var(--cream); border: 1px solid var(--line); border-radius: var(--r);
  cursor: pointer; overflow: hidden; font: inherit; color: inherit;
  box-shadow: var(--sh-sm);
  transition: transform var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease);
}
.base-card:hover { transform: translateY(-3px); box-shadow: var(--sh-md); border-color: var(--gold-soft); }
.base-card:focus-visible { outline: 2px solid var(--gold-deep); outline-offset: 2px; }
/* `contain` (not cover) — a base photo is the whole piece on a transparent
   background; cropping it would hide the thing being chosen. */
.base-card-media { display: block; aspect-ratio: 1; background: var(--sand); overflow: hidden; }
.base-card-media img { width: 100%; height: 100%; object-fit: contain; display: block; padding: 8%; }
.base-card-name { padding: 10px 12px 0; font-weight: 600; font-size: var(--t-sm); color: var(--ink); }
.base-card-price { padding: 0 12px; font-size: var(--t-xs); color: var(--gold-deep); }

/* --- the chosen piece, shown in place of the picker --- */
.base-chosen {
  display: flex; align-items: center; gap: 14px; padding: 10px 14px;
  margin-bottom: clamp(12px, 2vw, 18px);
  background: var(--cream); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--sh-sm);
}
.base-chosen > img { flex: none; width: 48px; height: 60px; object-fit: cover; border-radius: 7px; background: var(--sand); }
.base-chosen-info { flex: 1; min-width: 0; display: grid; gap: 1px; }
.base-chosen-label { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--taupe); }
.base-chosen-info strong { font-family: var(--f-display); font-size: 1.05rem; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.base-chosen-price { font-size: var(--t-xs); color: var(--gold-deep); }
.base-chosen .btn { flex: none; }
/* .builder-shell .btn forces full-width buttons for the side panel; the
   change-piece button lives inline in this bar and must stay compact. */
.builder-shell .base-chosen .btn { width: auto; }

/* --- base (bracelet / necklace) segmented control --- */
.base-switch {
  display: inline-flex; gap: 4px; padding: 5px; margin: 6px auto 0;
  background: var(--sand); border: 1px solid var(--line); border-radius: var(--r-pill);
  box-shadow: var(--sh-sm);
}
.base-switch button {
  border: 0; background: transparent; cursor: pointer;
  font-family: var(--f-body); font-weight: 600; font-size: var(--t-sm);
  color: var(--mocha); padding: 10px 22px; border-radius: var(--r-pill);
  display: inline-flex; align-items: center; gap: 8px;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease), transform var(--dur-1) var(--ease);
}
.base-switch button svg { width: 20px; height: 20px; }
.base-switch button[aria-pressed="true"] {
  background: var(--espresso); color: var(--on-dark); box-shadow: var(--sh-sm);
}
.base-switch button:not([aria-pressed="true"]):hover { color: var(--ink); transform: translateY(-1px); }

/* --- layout --- */
.builder-shell {
  display: grid; grid-template-columns: 1fr; gap: clamp(16px, 3vw, 28px);
  align-items: start; padding-bottom: clamp(40px, 8vw, 96px);
}
@media (min-width: 960px) {
  .builder-shell { grid-template-columns: minmax(0, 1fr) 320px; }
}

/* --- the stage (drop area) --- */
.stage-wrap { min-width: 0; }
/* The canvas mirrors the recommended base artwork (customstore BASE_ART):
   a necklace hangs portrait 3:4, a bracelet sits landscape 4:3. Correctly-sized
   artwork therefore fills the frame with no letterboxing. Capped by height on
   portrait so a necklace can't push the tray off-screen on a laptop. */
.stage {
  position: relative; width: 100%; aspect-ratio: 4 / 3;
  margin-inline: auto;
  background:
    radial-gradient(120% 90% at 50% 12%, var(--cream), var(--sand-deep) 92%);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.6), var(--sh-md);
  overflow: hidden; touch-action: none; user-select: none;
}
.stage[hidden] { display: none; }
.stage[data-shape="bracelet"] { aspect-ratio: 4 / 3; }
.stage[data-shape="necklace"] { aspect-ratio: 3 / 4; max-width: min(100%, 62vh); }
.stage.is-target { border-color: var(--gold-soft); box-shadow: inset 0 0 0 2px var(--gold-soft), var(--sh-md); }
/* The chosen product photo, sitting under the charms. `contain` keeps the whole
   piece visible so there's no hidden area to drop a charm onto. */
.stage-base {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain; padding: 6%; pointer-events: none; user-select: none;
}

.stage-hint {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  color: var(--taupe); font-size: var(--t-sm); text-align: center;
  pointer-events: none; opacity: 1; transition: opacity var(--dur-2) var(--ease);
  display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 0 24px;
}
.stage-hint svg { width: 34px; height: 34px; color: var(--gold); animation: bhint 2.4s var(--ease) infinite; }
.stage.has-pieces .stage-hint { opacity: 0; }
@keyframes bhint { 0%,100% { transform: translateY(0); } 50% { transform: translateY(7px); } }

/* placed pieces */
.placed {
  position: absolute; width: 12%; max-width: 96px; aspect-ratio: 1;
  transform: translate(-50%, -50%) scale(0); transform-origin: center;
  cursor: grab; touch-action: none;
  filter: drop-shadow(0 4px 8px rgba(43,29,20,.28));
  transition: transform var(--dur-2) var(--ease-out), filter var(--dur-1) var(--ease);
  animation: pop-in var(--dur-2) var(--ease-out) forwards;
}
.placed img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; -webkit-user-drag: none; }
/* Settled state. Every placed charm used to run an endless `float` keyframe that
   animated margin-top — a layout-triggering property, so the whole stage
   reflowed every frame for every charm. A design with a dozen charms was
   permanently janky. Placed pieces now simply rest where they were put. */
.placed.is-idle { animation: pop-in var(--dur-2) var(--ease-out) forwards; }
.placed.is-grab { cursor: grabbing; transition: none; transform: translate(-50%, -50%) scale(1.18); z-index: 5; filter: drop-shadow(0 12px 18px rgba(43,29,20,.34)); animation: none; }
.placed.is-selected { outline: 2px dashed var(--gold-deep); outline-offset: 3px; border-radius: 6px; }
.placed.is-snap { animation: snap-pulse var(--dur-2) var(--ease-out); }
.placed .placed-x {
  position: absolute; top: -9px; inset-inline-end: -9px; width: 22px; height: 22px; border-radius: 50%;
  border: 0; background: var(--espresso); color: var(--on-dark); font-size: 14px; line-height: 1; cursor: pointer;
  display: none; align-items: center; justify-content: center; box-shadow: var(--sh-sm);
}
.placed.is-selected .placed-x, .placed:hover .placed-x { display: flex; }

@keyframes pop-in { 0% { transform: translate(-50%,-50%) scale(.4); } 100% { transform: translate(-50%,-50%) scale(1); } }
@keyframes snap-pulse { 0% { filter: drop-shadow(0 0 0 rgba(201,168,110,.9)); } 100% { filter: drop-shadow(0 4px 8px rgba(43,29,20,.28)); } }

/* drag ghost that follows the pointer while adding from the tray */
.drag-ghost {
  position: fixed; z-index: var(--z-toast); width: 74px; height: 74px; margin: -37px 0 0 -37px;
  pointer-events: none; transform: scale(.6); opacity: 0; transition: transform var(--dur-1) var(--ease), opacity var(--dur-1) var(--ease);
  filter: drop-shadow(0 10px 16px rgba(43,29,20,.35));
}
.drag-ghost.is-on { transform: scale(1.05); opacity: 1; }
.drag-ghost img { width: 100%; height: 100%; object-fit: contain; }

/* --- tray --- */
.tray { margin-top: clamp(16px, 3vw, 24px); }
.tray-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.tray-head h2 { font-size: var(--t-md); margin: 0; }
/* Two stacked chip rows: main categories, then the sub-categories of whichever
   main one is open. The sub row is visually quieter and inset behind a gold
   rule, so at a glance you read "these belong to the row above". */
.tray-cats { display: grid; gap: 8px; margin-bottom: 14px; }
.tray-cat-row { display: flex; flex-wrap: wrap; gap: 8px; }
.tray-cats button {
  border: 1px solid var(--line); background: var(--cream); color: var(--mocha);
  font-family: var(--f-body); font-weight: 600; font-size: var(--t-xs);
  padding: 7px 14px; border-radius: var(--r-pill); cursor: pointer;
  transition: all var(--dur-1) var(--ease);
}
.tray-cats button[aria-pressed="true"] { background: var(--gold); color: #fff; border-color: var(--gold); }
.tray-cats button:hover { border-color: var(--gold-soft); }

.tray-cat-row--sub {
  padding-inline-start: 12px; margin-inline-start: 2px;
  border-inline-start: 2px solid var(--gold-soft);
  animation: tray-subs-in var(--dur-2) var(--ease-out) both;
}
.tray-cat-row--sub button { font-size: 11px; padding: 6px 12px; background: transparent; }
.tray-cat-row--sub button[aria-pressed="true"] {
  background: var(--gold-soft); color: var(--ink); border-color: var(--gold-soft);
}
@keyframes tray-subs-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .tray-cat-row--sub { animation: none; } }

.tray-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 10px; }
.tray-item {
  position: relative; aspect-ratio: 1; background: var(--cream); border: 1px solid var(--line);
  border-radius: var(--r); padding: 10px; cursor: grab; touch-action: none;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--sh-sm); opacity: 0; transform: translateY(10px);
  animation: tray-in var(--dur-3) var(--ease-out) forwards;
  transition: transform var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease);
}
.tray-item:hover { transform: translateY(-4px) scale(1.03); box-shadow: var(--sh-md); border-color: var(--gold-soft); }
.tray-item:active { cursor: grabbing; }
.tray-item img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; -webkit-user-drag: none; }
.tray-item .tray-name { position: absolute; inset-inline: 0; bottom: -18px; text-align: center; font-size: 10px; color: var(--taupe); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@keyframes tray-in { to { opacity: 1; transform: translateY(0); } }
.tray-empty { grid-column: 1/-1; text-align: center; color: var(--taupe); padding: 32px 16px; }

/* --- side summary --- */
.build-side { position: sticky; top: 88px; }
.build-card { background: var(--cream); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; box-shadow: var(--sh-sm); }
.build-card h2 { font-size: var(--t-md); margin: 0 0 4px; }
.build-count { color: var(--taupe); font-size: var(--t-sm); margin-bottom: 14px; }
.build-count b { color: var(--gold-deep); font-size: var(--t-md); }
.build-list { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; gap: 8px; max-height: 220px; overflow: auto; }
.build-list li { display: flex; align-items: center; gap: 10px; font-size: var(--t-sm); color: var(--cocoa); }
.build-list img { width: 30px; height: 30px; object-fit: contain; background: var(--sand); border-radius: 6px; padding: 3px; }
.build-list .qty { margin-inline-start: auto; color: var(--taupe); font-variant-numeric: tabular-nums; }
/* The base piece heads the list and carries a price rather than a ×qty. */
.build-list .build-base { padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.build-list .build-base img { object-fit: cover; padding: 0; }
.build-list .build-base span:first-of-type { font-weight: 600; color: var(--ink); }
.build-list .build-base .qty { color: var(--gold-deep); font-size: var(--t-xs); }
.tray[hidden] { display: none; }
/* live estimated total */
.build-total {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 14px 0 4px; margin-top: 4px; border-top: 1px solid var(--line);
}
.build-total-label { font-size: var(--t-sm); color: var(--mocha); letter-spacing: .02em; }
.build-total-amt {
  font-family: var(--f-display); font-weight: 700; font-size: var(--t-lg);
  color: var(--ink); font-variant-numeric: tabular-nums; line-height: 1.1;
}
.build-total-note { font-size: var(--t-xs); margin: 0 0 16px; }

/* customer's own note — sits between the estimate and the send button */
.build-note { margin: 0 0 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.build-note-label {
  display: block; font-size: var(--t-sm); font-weight: 600;
  color: var(--ink); margin-bottom: 7px;
}
.build-note-input {
  display: block; width: 100%; min-height: 84px; resize: vertical;
  padding: 11px 12px; font: inherit; font-size: var(--t-sm); line-height: 1.5;
  color: var(--ink); background: var(--ivory);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  transition: border-color var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
}
.build-note-input::placeholder { color: var(--taupe); opacity: .9; }
.build-note-input:focus-visible {
  outline: none; border-color: var(--emerald);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--emerald) 18%, transparent);
}
.build-note-hint {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  font-size: var(--t-xs); margin: 6px 0 0;
}
.build-note-count {
  flex: none; color: var(--taupe); font-variant-numeric: tabular-nums;
  /* the count reads left-to-right even in Arabic/Kurdish */
  direction: ltr; unicode-bidi: isolate;
}
.build-note-count.is-max { color: var(--gold-deep); }

.build-actions { display: flex; flex-direction: column; gap: 10px; }

/* small helpers reused from components but scoped safe here */
.builder-shell .btn { width: 100%; justify-content: center; }
.btn.is-disabled { opacity: .5; pointer-events: none; }
@media (prefers-reduced-motion: reduce) {
  .placed, .tray-item, .stage-hint svg, .placed.is-idle { animation: none !important; }
  .placed { transform: translate(-50%,-50%) scale(1); }
}

/* ---------- Consent modal (shown before sending a custom design) --------- */
.consent-scrim {
  position: fixed; inset: 0; z-index: 700; display: none;
  align-items: center; justify-content: center; padding: 20px;
  background: color-mix(in srgb, var(--espresso) 60%, transparent);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}
.consent-scrim.is-open { display: flex; animation: consentFade var(--dur-2) var(--ease-out); }
@keyframes consentFade { from { opacity: 0; } to { opacity: 1; } }
.consent-card {
  width: min(440px, 100%); background: var(--cream);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--sh-lg); padding: 26px 24px;
  animation: consentPop var(--dur-2) var(--ease-out);
}
@keyframes consentPop { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
.consent-card h2 { font-family: var(--f-display); font-size: var(--t-lg); color: var(--ink); margin-bottom: 8px; }
/* Screenshot warning — the one thing the shopper must not skim past, so it
   sits above the question with a gold rule and a warmer background. */
.consent-warn {
  display: flex; gap: 10px; align-items: flex-start;
  margin: 0 0 16px; padding: 12px 14px;
  border: 1px solid var(--gold); border-inline-start: 3px solid var(--gold-deep);
  border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--gold) 12%, var(--ivory));
  color: var(--ink); font-size: var(--t-sm); line-height: 1.55; font-weight: 500;
}
.consent-warn::before { content: "📸"; flex: none; font-size: 1.05em; line-height: 1.4; }
.consent-q { color: var(--cocoa); font-size: var(--t-sm); line-height: 1.5; margin-bottom: 18px; }
.consent-opt {
  display: flex; align-items: flex-start; gap: 12px; cursor: pointer;
  padding: 12px 14px; margin-bottom: 10px; border-radius: var(--r);
  border: 1px solid var(--line-strong); background: var(--ivory);
  font-size: var(--t-sm); color: var(--ink); transition: border-color var(--dur-2) var(--ease), background var(--dur-2) var(--ease);
}
.consent-opt:hover { border-color: var(--gold); }
.consent-opt input { width: 20px; height: 20px; margin-top: 1px; accent-color: var(--emerald); flex: none; cursor: pointer; }
.consent-actions { display: flex; gap: 10px; margin-top: 18px; }
.consent-actions .btn { flex: 1; justify-content: center; }
.consent-wa {
  margin: 14px 0 0; text-align: center; font-size: var(--t-sm); font-weight: 700;
  color: var(--emerald); letter-spacing: .01em; direction: ltr; unicode-bidi: plaintext;
}
/* Tapping the number opens the studio's chat, same as the send button. */
.consent-num {
  color: var(--emerald); text-decoration: underline; text-underline-offset: 3px;
  direction: ltr; unicode-bidi: isolate; white-space: nowrap;
}
.consent-num:hover { color: var(--gold-deep); }
@media (prefers-reduced-motion: reduce) {
  .consent-scrim.is-open, .consent-card { animation: none; }
}
