/* ========================================================================
   IMAKE | Cake Builder visual refresh (scoped to body.builder-page)
   File: assets/css/builder-polish.css
   Change palette, spacing, border radii and component card styles here.

   IMPORTANT: The cake is rendered by customizer.js and the .stage/.layer rules
   in style.css. This stylesheet does NOT modify stacking, image transforms,
   layer positions, order calculations, or saved drafts. Only the surrounding
   layout is redesigned. At short desktop heights, the preview is scaled down
   proportionally to fit the available screen height.
   ======================================================================== */

body.builder-page {
  --bp-berry: #963757;
  --bp-rose: #c0577c;
  --bp-blush: #f8e4eb;
  --bp-petal: #fff3f6;
  --bp-cream: #fffaf5;
  --bp-ink: #3d2530;
  --bp-muted: #846673;
  --bp-border: #edc8d5;
  --bp-shadow: 0 12px 33px rgba(92, 43, 65, .095), 0 2px 8px rgba(92, 43, 65, .045);
  --bp-deep-shadow: 0 17px 46px rgba(92, 43, 65, .15), 0 3px 9px rgba(92, 43, 65, .06);
}

/* ----- Refined top navigation, keeping existing links and greeting ----- */
body.builder-page > header.site {
  background: rgba(255, 253, 250, .97);
  border-bottom: 1px solid rgba(191, 112, 144, .27);
  box-shadow: 0 4px 22px rgba(87, 37, 58, .085);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
body.builder-page > header.site::after {
  content: "";
  position: absolute;
  inset: auto 0 -1px;
  height: 2px;
  background: linear-gradient(90deg, transparent, #f3c6d4 18%, #b95278 50%, #f3c6d4 82%, transparent);
  opacity: .66;
  pointer-events: none;
}
body.builder-page > header.site .brand { border-radius: 10px; }
body.builder-page > header.site .brand:focus-visible {
  outline: 3px solid #db8ba8;
  outline-offset: 4px;
}
body.builder-page > header.site .nav { gap: 4px; }
body.builder-page > header.site .nav a {
  border: 1px solid transparent;
  border-radius: 999px;
  color: #7d5868;
}
body.builder-page > header.site .nav a:hover,
body.builder-page > header.site .nav a.active {
  color: var(--bp-berry);
  background: linear-gradient(140deg, #fff4f7, #f8e4eb);
  border-color: #f0cbd9;
}
body.builder-page > header.site .greet-pill {
  border: 1px solid #f1d5df;
  box-shadow: inset 0 1px 0 #fff;
  color: var(--bp-berry);
}

/* ----- Use nearly all available desktop width, without touching sidebar JS ----- */
body.builder-page > .wrap {
  width: min(1560px, calc(100% - 52px));
  max-width: none;
  margin-inline: auto;
  padding: 22px 0 76px;
}

/* ----- Welcome block, with soft icing-inspired double border ----- */
body.builder-page .wrap > .lead {
  position: relative;
  max-width: none;
  margin: 2px 0 21px;
  padding: 18px clamp(20px, 2.8vw, 38px) 20px;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 94% -23%, rgba(241, 174, 197, .37), transparent 38%),
    linear-gradient(110deg, rgba(255, 255, 255, .97), rgba(255, 246, 249, .93));
  border: 1px solid var(--bp-border);
  border-radius: 24px;
  box-shadow: var(--bp-shadow), inset 0 0 0 5px rgba(255, 255, 255, .64);
  text-align: left;
}
body.builder-page .wrap > .lead::before {
  content: "";
  position: absolute;
  top: 0;
  left: clamp(20px, 3vw, 40px);
  right: clamp(20px, 3vw, 40px);
  height: 4px;
  border-radius: 0 0 10px 10px;
  background: linear-gradient(90deg, #f4d3de, #b94871, #eeb5c9, #fff1d8);
  pointer-events: none;
}
body.builder-page .wrap > .lead::after {
  content: "";
  position: absolute;
  width: 170px;
  height: 170px;
  top: -84px;
  right: -48px;
  border: 1px solid rgba(193, 87, 124, .16);
  border-radius: 50%;
  box-shadow: 0 0 0 19px rgba(241, 177, 199, .075), 0 0 0 40px rgba(241, 177, 199, .06);
  pointer-events: none;
}
body.builder-page .lead-kicker {
  position: relative;
  z-index: 1;
  margin-bottom: 7px;
  border: 1px solid #f1ceda;
  background: #fff0f5;
  color: #a3325c;
  box-shadow: inset 0 1px 0 #fff;
  font-size: .76rem;
}
body.builder-page .lead h1 {
  position: relative;
  z-index: 1;
  margin: .15em 0 .18em;
  color: var(--bp-ink);
  font-size: clamp(1.85rem, 2.9vw, 2.6rem);
  line-height: 1.2;
  letter-spacing: -.045em;
}
body.builder-page .lead p {
  position: relative;
  z-index: 1;
  max-width: 1120px;
  margin: 0;
  font-size: .94rem;
  line-height: 1.6;
  color: var(--bp-muted);
}

/* ----- Balanced full-width two-column workspace ----- */
body.builder-page .builder {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 410px);
  gap: clamp(16px, 1.8vw, 28px);
  align-items: start;
  min-width: 0;
  overflow: visible;
}
body.builder-page .builder-choices,
body.builder-page .builder #steps { min-width: 0; }

/* ----- Component panels: satin edges, rose accent, visible focus ----- */
body.builder-page .builder-choices .step {
  position: relative;
  padding: 23px clamp(15px, 1.65vw, 26px) 21px;
  margin-bottom: 19px;
  background: linear-gradient(155deg, rgba(255,255,255,.99), rgba(255,250,251,.97));
  border: 1px solid var(--bp-border);
  border-radius: 23px;
  box-shadow: var(--bp-shadow), inset 0 0 0 5px rgba(255,249,250,.8);
  transition: box-shadow .2s ease, border-color .2s ease, opacity .28s ease, transform .28s ease;
}
body.builder-page .builder-choices .step::before {
  content: "";
  position: absolute;
  pointer-events: none;
  top: 0;
  left: 23px;
  width: min(125px, 28%);
  height: 4px;
  background: linear-gradient(90deg, #b95077, #e9adc3, transparent);
  border-radius: 0 0 8px 8px;
}
body.builder-page .builder-choices .step:hover {
  border-color: #dea5ba;
  box-shadow: var(--bp-deep-shadow), inset 0 0 0 5px rgba(255,249,250,.9);
}
body.builder-page .builder-choices .step h3 {
  margin: 0 0 5px;
  font-size: clamp(1.02rem, 1.3vw, 1.18rem);
  letter-spacing: -.025em;
  color: var(--bp-ink);
}
body.builder-page .builder-choices .step .num {
  width: 34px;
  height: 34px;
  font-size: .95rem;
  border: 2px solid rgba(255,255,255,.65);
  background: linear-gradient(145deg, #e2a0b9, #a73f66 80%);
  box-shadow: 0 4px 12px rgba(165,59,102,.25);
}
body.builder-page .builder-choices .step .hint {
  margin: 0 0 15px;
  font-size: .88rem;
  color: var(--bp-muted);
}
body.builder-page .builder-choices .step .badge {
  background: #fceaf0;
  border: 1px solid #f6dce6;
  color: #a13d60;
  padding: 5px 10px;
  letter-spacing: .06em;
}

/* ----- Keep component grid spacious and adapt to wide monitors ----- */
body.builder-page .step .options {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 121px), 1fr));
  gap: clamp(10px, 1.1vw, 15px);
}
body.builder-page .step .options.options-scrollable {
  max-height: 352px;
  padding: 3px 8px 6px 3px;
}
body.builder-page .step .opt {
  min-width: 0;
  padding: 10px 9px 11px;
  border: 1.5px solid #eed0dc;
  border-radius: 17px;
  background: #fff;
  box-shadow: 0 3px 10px rgba(110,51,76,.04);
}
body.builder-page .step .opt:not(.limit-disabled):hover {
  border-color: #d489a5;
  box-shadow: 0 10px 22px rgba(151,61,101,.16);
}
body.builder-page .step .opt.selected {
  border-color: #c64b79;
  background: linear-gradient(160deg, #fff7fa, #ffe9f0);
  box-shadow: 0 0 0 3px rgba(218,102,143,.17), 0 8px 20px rgba(156,63,98,.11);
}
body.builder-page .step .opt .thumb {
  border: 1px solid #fae8ee;
  border-radius: 12px;
  /* Keep existing image sizing, checkerboard and transparent PNG display. */
}
body.builder-page .step .opt .nm { margin-top: 10px; color: #462b36; }
body.builder-page .step .opt .pr { font-weight: 900; }
body.builder-page .step .opt .tick { background: #a23860; }
body.builder-page .step .opt:focus-visible {
  outline: 3px solid #e6a6be;
  outline-offset: 3px;
}
body.builder-page .step .opt.clear {
  border: 1.5px dashed #dfb2c2;
  background: #fff9fb;
}
body.builder-page .step-review-actions {
  margin-top: 18px;
  border-top: 1px dashed #ecd0db;
}

/* ----- Premium preview frame. The actual layered cake is unchanged. ----- */
body.builder-page .builder .stage-card {
  width: 100%;
  max-width: none; /* override the original 360px sidebar card limit */
  padding: clamp(14px, 1.6vw, 21px);
  background: linear-gradient(155deg, #fffefa, #fff8fb 75%, #fff4f7);
  border: 1px solid #e8c0cf;
  border-radius: 24px;
  box-shadow: var(--bp-deep-shadow), inset 0 0 0 6px rgba(255,255,255,.75);
}
body.builder-page .builder .stage-card::before {
  content: "";
  display: block;
  height: 4px;
  width: 65%;
  margin: -2px auto 13px;
  background: linear-gradient(90deg, transparent, #f0bdce, #a63d65, #f0bdce, transparent);
  border-radius: 999px;
}
/* .stage / .layer are intentionally NOT restyled, so the cake preview image,
   stacking, drag offsets and aspect ratio remain exactly as before. */
body.builder-page .builder .stage-card .price-tag {
  margin-top: 15px;
  padding: 12px 12px 11px;
  border: 1px solid #f1d2de;
  border-radius: 16px;
  background: linear-gradient(135deg, #fff0f5, #fce5ed);
  color: #9b3559;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.9);
  font-size: clamp(1.6rem, 2vw, 2rem);
  letter-spacing: -.025em;
}
body.builder-page .builder .stage-card .price-tag small { color: #986b7b; }
body.builder-page .builder .stage-card .stage-actions { gap: 11px; }
body.builder-page .builder .stage-card .stage-actions .btn {
  min-width: 0;
  min-height: 49px;
  border-radius: 16px;
  font-weight: 800;
  box-shadow: 0 5px 15px rgba(137,58,86,.13);
}
body.builder-page .builder .stage-card .stage-actions .btn:not(.ghost) {
  background: linear-gradient(125deg, #e99eb8, #a43e67);
}
body.builder-page .builder .stage-card .stage-actions .btn.ghost {
  border: 1.5px solid #e8adc1;
  background: #fff;
  color: #a43862;
  box-shadow: none;
}
body.builder-page .builder .stage-card .stage-actions .btn:focus-visible,
body.builder-page .builder .placement-reset:focus-visible {
  outline: 3px solid rgba(191,75,115,.4);
  outline-offset: 3px;
}
body.builder-page .builder .stage-card .placement-tools {
  background: #fff9fb;
  border: 1px dashed #e4b3c6;
  border-radius: 16px;
}

/* ----- Desktop: keep the sidebar within its column, as before. ----- */
@media (min-width: 961px) {
  body.builder-page .builder .stage-card {
    position: sticky;
    top: calc(var(--fixed-builder-header-height, 74px) + 13px);
    justify-self: stretch;
    max-height: min(700px, calc(100dvh - var(--fixed-builder-header-height, 74px) - 27px));
    overflow-y: auto;
    overflow-x: hidden;
  }
}

/* Only make the preview physically smaller if the desktop viewport is short.
   The same aspect ratio, layer placement percentages and previews are used. */
@media (min-width: 961px) and (max-height: 760px) {
  body.builder-page .builder .stage-card > .stage {
    max-width: min(360px, max(220px, calc(100dvh - var(--fixed-builder-header-height, 74px) - 295px)));
  }
}

@media (max-width: 1199px) and (min-width: 961px) {
  body.builder-page .builder { grid-template-columns: minmax(0, 1fr) minmax(312px, 350px); gap: 17px; }
  body.builder-page > .wrap { width: calc(100% - 34px); }
  body.builder-page .step .options { grid-template-columns: repeat(auto-fill, minmax(min(100%, 112px), 1fr)); }
}

@media (max-width: 960px) {
  body.builder-page > .wrap { width: calc(100% - 30px); padding-top: 17px; }
  body.builder-page .builder { grid-template-columns: minmax(0,1fr); gap: 18px; }
  body.builder-page .builder .stage-card {
    position: static;
    max-height: none;
    overflow: visible;
    justify-self: stretch;
    width: 100%;
  }
  body.builder-page .wrap > .lead { padding: 22px; text-align: left; }
  body.builder-page .lead p { margin: 0; }
}

@media (max-width: 600px) {
  body.builder-page > .wrap { width: calc(100% - 22px); padding: 13px 0 55px; }
  body.builder-page .wrap > .lead { border-radius: 19px; padding: 20px 17px; margin: 0 0 15px; }
  body.builder-page .lead h1 { font-size: clamp(1.68rem, 7vw, 2.1rem); }
  body.builder-page .lead p { font-size: .84rem; }
  body.builder-page .builder-choices .step {
    padding: 18px 12px 16px;
    margin-bottom: 13px;
    border-radius: 18px;
  }
  body.builder-page .builder-choices .step h3 { gap: 7px; }
  body.builder-page .builder-choices .step .num { width: 29px; height: 29px; }
  body.builder-page .builder-choices .step .badge { font-size: .58rem; padding: 4px 8px; }
  body.builder-page .step .options { grid-template-columns: repeat(auto-fill, minmax(min(100%, 108px), 1fr)); gap: 9px; }
  body.builder-page .step .opt { padding: 7px; border-radius: 13px; }
  body.builder-page .step .opt .nm { font-size: .78rem; }
  body.builder-page .builder .stage-card { border-radius: 18px; padding: 13px; }
  body.builder-page .builder .stage-card .stage-actions .btn { font-size: .81rem; padding-inline: 8px; }
  /* The mobile header wraps its links instead of hiding Login/Log out. The
     existing ResizeObserver in build.php measures the taller header. */
  body.builder-page > header.site {
    flex-wrap: wrap;
    justify-content: center;
    row-gap: 3px;
    padding: 9px 10px;
  }
  body.builder-page > header.site > .brand { margin-right: auto; }
  body.builder-page > header.site > .nav {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
    overflow: visible;
    gap: 3px;
  }
  body.builder-page > header.site .nav a { margin-left: 0; padding: 6px 8px; font-size: .77rem; }
  body.builder-page > header.site .nav .greet-pill { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  body.builder-page .builder-choices .step,
  body.builder-page .step .opt { transition-duration: .01ms !important; }
}
