/* Bakelyne — the cake studio (v1). Loaded only by /design and /admin. */

.studio {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(1.4rem, 3vw, 3rem);
  align-items: start;
}
@media (max-width: 60rem) { .studio { grid-template-columns: 1fr; } }

/* --- the cake --- */
.studio-stage {
  position: sticky; top: 5.8rem;
  background: var(--cream-card);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  padding: 1.1rem;
  box-shadow: var(--sh-1);
}
@media (max-width: 60rem) {
  .studio-stage { position: static; }
}
.studio-stage svg { width: 100%; height: auto; display: block; }

/* the 3-D viewer takes the SVG's place when WebGL is available */
.stage-viewer { position: relative; }
#cake3d {
  position: relative;
  aspect-ratio: 1 / 0.96;
  border-radius: calc(var(--r-md) - 4px);
  overflow: hidden;
  cursor: grab;
  touch-action: pan-y;
  /* A studio sweep: bright above, a soft horizon, warmer floor. */
  background:
    radial-gradient(90% 55% at 50% 30%, rgba(255,255,255,.55), transparent 70%),
    linear-gradient(180deg, #FFFDF8 0%, #F7EFE1 52%, #EADDC8 72%, #E3D3BA 100%);
}
#cake3d::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  border-radius: inherit;
  background: radial-gradient(120% 100% at 50% 45%, transparent 55%, rgba(74,44,33,.16) 100%);
}
#cake3d:active { cursor: grabbing; }
#cake3d canvas { width: 100%; height: 100%; display: block; }
.studio-stage .caption {
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  margin-top: .9rem; padding-top: .8rem;
  border-top: 1px solid var(--line-soft);
  font-family: var(--font-ui);
  font-size: .72rem; color: var(--ink-faint);
  letter-spacing: .16em; text-transform: uppercase;
}

.design-summary { list-style: none; margin: 1rem 0 0; display: grid; gap: .3rem; }
.design-summary li {
  display: flex; justify-content: space-between; gap: 1rem;
  font-size: .89rem; color: var(--cocoa);
  padding: .35rem 0; border-bottom: 1px dotted var(--line);
}
.design-summary li span { color: var(--ink-faint); font-family: var(--font-ui); }

/* --- controls --- */
.studio-tabs {
  display: flex; gap: .3rem; flex-wrap: wrap;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 1.6rem;
}
.studio-tabs button {
  background: none; border: none; border-bottom: 2px solid transparent;
  font-family: var(--font-ui); cursor: pointer;
  color: var(--ink-faint);
  font-size: .74rem; letter-spacing: .16em; text-transform: uppercase; font-weight: 500;
  padding: .75rem .9rem;
  transition: color .2s var(--ease), border-color .2s var(--ease);
}
.studio-tabs button.on { color: var(--cocoa); border-bottom-color: var(--butterscotch); }
.studio-tabs button:hover { color: var(--cocoa); }

.studio-step { display: none; }
.studio-step.on { display: block; }
.studio-step > h2 {
  font-size: 1.25rem; font-weight: 600; margin-bottom: .3rem;
}
.studio-step > .lede { font-size: .95rem; margin-bottom: 1.4rem; }

fieldset.opt-group { border: 0; padding: 0; }
.opt-group { margin-bottom: 1.5rem; }
.opt-group > legend, .opt-group > .label {
  display: block; font-family: var(--font-ui); font-weight: 500;
  font-size: .93rem; margin-bottom: .55rem; padding: 0;
}
.opt-group .hint { font-family: var(--font-ui); font-size: .84rem; color: var(--ink-faint); margin-top: .35rem; }

/* pill options — the span is the visual control, so no :has() is needed */
.pills { display: flex; flex-wrap: wrap; gap: .5rem; }
.pills label { display: inline-flex; cursor: pointer; }
.pills input { position: absolute; opacity: 0; width: 0; height: 0; }
.pills span {
  border: 1px solid var(--line); background: var(--cream-card);
  color: var(--ink-soft); border-radius: var(--r-pill);
  padding: .55rem 1.1rem; font-family: var(--font-ui); font-size: .89rem;
  transition: border-color .18s var(--ease), background .18s var(--ease),
              color .18s var(--ease), transform .18s var(--ease);
}
.pills label:hover span { border-color: var(--butterscotch); transform: translateY(-1px); }
.pills input:checked + span {
  background: var(--cocoa); border-color: var(--cocoa); color: var(--cream);
  box-shadow: 0 4px 12px rgba(74,44,33,.22);
}
.pills input:focus-visible + span { outline: 3px solid var(--amber); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .pills span, .swatches button { transition: none; } }

/* colour swatches */
.swatches { display: flex; flex-wrap: wrap; gap: .5rem; }
.swatches button {
  width: 2.4rem; height: 2.4rem; border-radius: 50%;
  border: 2px solid var(--line); cursor: pointer; padding: 0;
  box-shadow: var(--sh-1);
  transition: transform .18s var(--ease), box-shadow .18s var(--ease);
}
.swatches button:hover { transform: scale(1.08); }
.swatches button[aria-pressed="true"] {
  border-color: var(--cocoa);
  box-shadow: 0 0 0 3px var(--cream), 0 0 0 4px var(--cocoa);
}

/* reference photos */
.dropzone {
  border: 1.5px dashed var(--line);
  background: var(--cream-card);
  padding: 1.8rem 1.2rem; text-align: center;
  border-radius: var(--r-md);
  transition: border-color .2s var(--ease), background .2s var(--ease);
}
.dropzone:hover { border-color: var(--butterscotch); background: var(--blush); }
.dropzone p { color: var(--ink-soft); font-size: .92rem; margin-bottom: .9rem; }
.dropzone input[type="file"] { display: none; }
.dropzone .btn { cursor: pointer; }
#uploadNote { font-size: .86rem; color: var(--ink-faint); margin-top: .8rem; min-height: 1.2rem; }

.thumbs { display: flex; flex-wrap: wrap; gap: .7rem; margin-top: 1rem; }
.thumbs figure { position: relative; width: 5.5rem; height: 5.5rem; }
.thumbs img { width: 100%; height: 100%; object-fit: cover; border-radius: var(--r-sm); border: 1px solid var(--line); }
.thumbs .rm {
  position: absolute; top: -.5rem; right: -.5rem;
  width: 1.5rem; height: 1.5rem; border-radius: 50%;
  border: none; background: var(--cocoa); color: var(--cream);
  font-size: 1rem; line-height: 1; cursor: pointer;
}

.studio-nav { display: flex; justify-content: space-between; gap: 1rem; margin-top: 2rem; }
.studio-nav .btn { padding: .8rem 1.6rem; }

/* --- admin console --- */
.admin-shell { max-width: 74rem; margin: 0 auto; padding: 2rem 1.4rem 4rem; }
.admin-card {
  background: var(--cream-card); border: 1px solid var(--line-soft);
  border-radius: var(--r-md); box-shadow: var(--sh-1);
  padding: 1.5rem; margin-bottom: 1.2rem;
}
.admin-card h3 { font-size: 1.05rem; font-weight: 600; margin-bottom: .6rem; }
.admin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 1rem; }
.admin-row { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.admin-meta { font-family: var(--font-ui); font-size: .84rem; color: var(--ink-faint); }
.pill-tag {
  display: inline-block; font-family: var(--font-ui);
  font-size: .68rem; letter-spacing: .14em; text-transform: uppercase;
  background: var(--cream-deep); color: var(--ink-soft);
  padding: .22rem .7rem; border-radius: var(--r-pill); font-weight: 500;
}
.pill-tag.live { background: #E3F0DA; color: #3E5A2C; }
.pill-tag.warn { background: #F9E9E4; color: #7C3A22; }
.chat-log { display: grid; gap: .5rem; max-height: 26rem; overflow-y: auto; padding: .4rem; }
.chat-log .m { max-width: 80%; padding: .55rem .8rem; border-radius: 10px; font-size: .92rem; }
.chat-log .m.customer { background: var(--cream-deep); justify-self: start; }
.chat-log .m.bot { background: var(--cocoa); color: var(--cream); justify-self: end; }
.chat-log .m.baker { background: var(--butterscotch); color: var(--cream); justify-self: end; }
.chat-log .m .who { display: block; font-size: .68rem; letter-spacing: .12em; text-transform: uppercase; opacity: .7; }


/* ==========================================================================
   v2 — the studio redesign
   ========================================================================== */

/* --- progress through the five steps --- */
.studio-progress {
  height: 3px; border-radius: 2px;
  background: var(--line-soft);
  overflow: hidden;
  margin-bottom: .9rem;
}
.studio-progress i {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--butterscotch), var(--amber));
  border-radius: 2px;
  transition: width .4s var(--ease-out);
}

/* --- numbered step tabs --- */
.studio-tabs { gap: .15rem; }
.studio-tabs button {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .6rem .7rem;
}
.studio-tabs button b {
  display: grid; place-items: center;
  width: 1.5rem; height: 1.5rem; border-radius: 50%;
  background: var(--cream-deep); color: var(--ink-soft);
  font-size: .72rem; font-weight: 500;
  transition: background .22s var(--ease), color .22s var(--ease);
}
.studio-tabs button.on b { background: var(--cocoa); color: var(--amber); }
.studio-tabs button.done b { background: var(--butterscotch); color: var(--cream); }
.studio-tabs button.done b::after { content: "\2713"; font-size: .78rem; }
.studio-tabs button.done b { font-size: 0; }
/* On a narrow phone the five tabs wrapped to three rows and ate 94px of a
   720px screen. One scrollable row instead, with the numbers always visible
   and the label only on the step you are actually on. */
@media (max-width: 34rem) {
  .studio-tabs {
    flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .studio-tabs::-webkit-scrollbar { display: none; }
  .studio-tabs button { flex: 0 0 auto; padding: .6rem .5rem; }
  .studio-tabs button span { display: none; }
  .studio-tabs button.on span { display: inline; white-space: nowrap; }
}

/* --- the size slider: a bar you drag, not a menu you hunt through --- */
.sizer-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; margin-bottom: .7rem;
}
.sizer-head .label { margin-bottom: 0; }
.sizer-out {
  text-align: right; font-family: var(--font-ui); line-height: 1.3;
}
.sizer-out b {
  display: block; font-size: .95rem; font-weight: 600; color: var(--accent-ink);
}
.sizer-out span { font-size: .78rem; color: var(--ink-faint); }

.sizer-range {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 2rem; margin: 0;
  background: none; cursor: pointer; display: block;
}
.sizer-range:focus { outline: none; }
.sizer-range:focus-visible { outline: 3px solid var(--amber); outline-offset: 4px; border-radius: var(--r-pill); }

/* The track is painted from --fill (set in design.js) so the portion behind
   the thumb reads as "chosen" — Chrome has no ::-moz-range-progress. */
.sizer-range::-webkit-slider-runnable-track {
  height: .5rem; border-radius: var(--r-pill);
  background:
    linear-gradient(90deg, var(--butterscotch) 0 var(--fill, 0%), var(--cream-deep) var(--fill, 0%) 100%);
  border: 1px solid var(--line);
}
.sizer-range::-moz-range-track {
  height: .5rem; border-radius: var(--r-pill);
  background: var(--cream-deep); border: 1px solid var(--line);
}
.sizer-range::-moz-range-progress {
  height: .5rem; border-radius: var(--r-pill); background: var(--butterscotch);
}
.sizer-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 1.6rem; height: 1.6rem; border-radius: 50%;
  margin-top: -0.6rem;             /* centre on a .5rem track */
  background: var(--cream-card);
  border: 2px solid var(--cocoa);
  box-shadow: 0 3px 10px rgba(74,44,33,.28);
  transition: transform .16s var(--ease), box-shadow .16s var(--ease);
}
.sizer-range::-moz-range-thumb {
  width: 1.6rem; height: 1.6rem; border-radius: 50%; border: 2px solid var(--cocoa);
  background: var(--cream-card); box-shadow: 0 3px 10px rgba(74,44,33,.28);
}
.sizer-range:hover::-webkit-slider-thumb { transform: scale(1.08); }
.sizer-range:active::-webkit-slider-thumb {
  transform: scale(1.14);
  box-shadow: 0 3px 10px rgba(74,44,33,.28), 0 0 0 6px rgba(216,155,74,.22);
}

.sizer-ticks {
  display: flex; justify-content: space-between;
  margin-top: .1rem;
  font-family: var(--font-ui); font-size: .7rem; letter-spacing: .04em;
  color: var(--ink-faint);
}
.sizer-ticks span { flex: 1 1 0; text-align: center; }
.sizer-ticks span:first-child { text-align: left; }
.sizer-ticks span:last-child { text-align: right; }

/* --- flavour choices: pills that describe themselves --- */
.pills.choices {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem;
}
@media (max-width: 26rem) { .pills.choices { grid-template-columns: 1fr; } }
.pills.choices label { display: block; }
.pills.choices span {
  display: block; width: 100%; height: 100%;
  border-radius: var(--r-sm);
  padding: .6rem .8rem;
  text-align: left;
}
.pills.choices span b { display: block; font-size: .89rem; font-weight: 600; line-height: 1.3; }
.pills.choices span i {
  display: block; font-style: normal;
  font-size: .74rem; line-height: 1.35; color: var(--ink-faint); margin-top: .1rem;
}
.pills.choices input:checked + span i { color: rgba(251,245,235,.72); }

/* --- start again --- */
.stage-reset {
  background: none; border: none; padding: 0; cursor: pointer;
  font-family: var(--font-ui);
  font-size: .72rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-faint);
  text-decoration: underline; text-underline-offset: .2em;
  transition: color .18s var(--ease);
}
.stage-reset:hover { color: var(--accent-ink); }

/* --- mobile: keep the cake on screen while you change it ---
   The stage used to go static below 60rem, so every choice happened with the
   cake scrolled off the top — the whole point of a live preview lost. It now
   pins to the header as a compact strip instead. */
@media (max-width: 60rem) {
  .studio-stage {
    position: sticky; top: 4.4rem; z-index: 20;
    background: var(--cream);
    padding: .6rem .8rem .5rem;
    box-shadow: 0 10px 22px -12px rgba(74,44,33,.45);
  }
  /* Roughly a third of the screen: big enough to read the cake, small enough
     to leave the controls usable without scrolling the preview away. */
  .studio-stage #cake3d { aspect-ratio: auto; height: 27vh; min-height: 12rem; }
  .studio-stage #cakeStage svg { max-height: 27vh; margin: 0 auto; }
  /* The full breakdown and summary belong below the fold on a phone — the
     sticky strip carries the price, and #priceBarMobile repeats it. */
  .studio-stage .design-summary,
  .studio-stage .caption { display: none; }
  .studio-stage #pricePanel { margin-top: .45rem; padding-top: .45rem; }
  .studio-stage .pp-figure { font-size: 1.6rem; }
  .studio-stage .pp-top { margin-bottom: .25rem; }
  .studio-stage .pp-breakdown, .studio-stage .pp-disclaimer { display: none; }
}


/* Mobile intro: the paragraph pushed the cake 450px below the fold. */
@media (max-width: 60rem) {
  .studio-lede { display: none; }
  #main > .section.tight { padding-bottom: 1rem; }
  #main > .section.tight h1.display { font-size: clamp(1.7rem, 7vw, 2.2rem); margin-bottom: 0; }
}
