/* Cake customiser page. Everything is scoped under .cz */
.cz { --cz-top: 72px; --cz-line: rgba(43, 26, 18, 0.12); }

.cz .cz-hero { max-width: 640px; margin: 0 auto 36px; }
.cz .cz-hero h1 { font-size: clamp(32px, 5vw, 52px); }

.cz-layout {
  max-width: var(--max, 1240px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: clamp(28px, 4vw, 60px);
  align-items: start;
}

/* ---------- preview ---------- */
.cz-preview {
  position: sticky;
  top: calc(var(--cz-top) + 20px);
  z-index: 5;
  display: flex;
  flex-direction: column;
  background: var(--sand);
  border: 1px solid rgba(43, 26, 18, 0.08);
  border-radius: var(--radius-lg, 22px);
  padding: 18px 18px 20px;
}
.cz-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 400 / 440;
  max-height: calc(100vh - var(--cz-top) - 150px);
  min-height: 260px;
  background: radial-gradient(ellipse 60% 52% at 50% 50%, var(--cream-soft) 0%, rgba(255, 253, 248, 0) 100%);
  border-radius: 16px;
}
.cz-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transition: opacity 0.32s ease, transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
.cz-layer.is-in { opacity: 0; transform: translateY(8px) scale(0.985); }
.cz-layer.is-out { opacity: 0; }
.cz-caption {
  margin: 12px 0 0;
  text-align: center;
  font-size: 15px;
  font-weight: 500;
  color: var(--brown);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cz-note { margin: 4px 0 0; text-align: center; font-size: 13px; color: var(--muted); }

@keyframes cz-flicker {
  0%, 100% { transform: scale(1, 1) rotate(-2deg); }
  50% { transform: scale(0.94, 1.07) rotate(2deg); }
}
.cz-flame { transform-box: fill-box; transform-origin: 50% 100%; animation: cz-flicker 1.7s ease-in-out infinite; }

/* ---------- form ---------- */
.cz-form { min-width: 0; }
.cz-sec { padding: 28px 0; border-top: 1px solid var(--cz-line); }
.cz-sec:first-child { padding-top: 4px; border-top: 0; }
.cz-h {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: clamp(21px, 2.2vw, 25px);
  margin: 0 0 20px;
}
.cz-num {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--brown);
  color: var(--cream);
  font-family: 'Work Sans', system-ui, sans-serif;
  font-size: 13px;
  font-weight: 600;
}
.cz-fields { display: grid; gap: 22px; }
.cz-fields--row { grid-template-columns: 1fr 1fr; gap: 16px; }
.cz-field { min-width: 0; margin: 0; padding: 0; border: 0; }
.cz .cz-label {
  display: block;
  padding: 0;
  margin: 0 0 10px;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--brown-mid);
}
.cz-opt { font-weight: 400; color: var(--muted); }
.cz-hint { margin: 8px 0 0; font-size: 13px; line-height: 1.45; color: var(--muted); }
.cz-hint:empty { display: none; }
.cz-hint--split { display: flex; justify-content: space-between; gap: 12px; }
.cz-hint--err { color: var(--err); font-weight: 500; }
.cz .di-in[aria-invalid="true"] { border-color: var(--err); }
.cz .di-in { min-height: 46px; }

/* visually hidden but focusable radio */
.cz-vh {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}

/* chips */
.cz-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.cz-chip { position: relative; display: inline-flex; cursor: pointer; }
.cz-chip__face {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 9px 16px;
  border: 1px solid rgba(43, 26, 18, 0.2);
  border-radius: 999px;
  background: var(--cream-soft);
  color: var(--brown);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}
.cz-chip__face .icon { width: 18px; height: 18px; color: var(--caramel-deep); }
.cz-chip:hover .cz-chip__face { border-color: var(--caramel); }
.cz-chip:active .cz-chip__face { transform: scale(0.97); }
.cz-vh:checked + .cz-chip__face { background: var(--brown); border-color: var(--brown); color: var(--cream); }
.cz-vh:checked + .cz-chip__face .icon { color: var(--gold); }
.cz-vh:focus-visible + .cz-chip__face { outline: 2px solid var(--caramel-deep); outline-offset: 3px; }
.cz-chips--shape .cz-chip__face { padding: 10px 20px; font-size: 15px; }

/* colour swatches */
.cz-swatches {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(62px, 1fr));
  gap: 12px 4px;
}
.cz-sw {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 4px 0;
  cursor: pointer;
}
.cz-sw__dot {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--sw);
  color: var(--brown);
  box-shadow: inset 0 0 0 1px rgba(43, 26, 18, 0.2);
  transition: box-shadow 0.18s ease, transform 0.18s ease;
}
.cz-sw__dot--dark { color: var(--cream); }
.cz-sw__dot .icon { width: 18px; height: 18px; stroke-width: 2.4; opacity: 0; transform: scale(0.5); transition: opacity 0.18s ease, transform 0.2s ease; }
.cz-sw:hover .cz-sw__dot { transform: translateY(-2px); }
.cz-vh:checked + .cz-sw__dot {
  box-shadow: inset 0 0 0 1px rgba(43, 26, 18, 0.2), 0 0 0 3px var(--cream), 0 0 0 5px var(--brown);
}
.cz-vh:checked + .cz-sw__dot .icon { opacity: 1; transform: none; }
.cz-vh:focus-visible + .cz-sw__dot { outline: 2px solid var(--caramel-deep); outline-offset: 7px; }
.cz-sw__name { font-size: 13px; color: var(--brown-mid); line-height: 1.2; }
.cz-vh:checked ~ .cz-sw__name { color: var(--brown); font-weight: 600; }

/* summary */
.cz-sum {
  margin-top: 8px;
  padding: clamp(20px, 3vw, 28px);
  background: var(--cream-soft);
  border: 1px solid var(--cz-line);
  border-radius: var(--radius-lg, 22px);
}
.cz-dl { margin: 0 0 22px; display: grid; gap: 0; font-size: 14.5px; }
.cz-dl__row {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 14px;
  padding: 9px 0;
  border-bottom: 1px solid rgba(43, 26, 18, 0.07);
}
.cz-dl__row:last-child { border-bottom: 0; }
.cz-dl dt { color: var(--muted); font-weight: 500; }
.cz-dl dd { margin: 0; color: var(--brown); overflow-wrap: anywhere; }
.cz-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin: 0 5px 0 2px;
  border-radius: 50%;
  vertical-align: -1px;
  box-shadow: inset 0 0 0 1px rgba(43, 26, 18, 0.25);
}
.cz-actions { display: flex; flex-direction: column; gap: 10px; }
.cz .cz-send { width: 100%; border-radius: 14px; }
.cz .cz-send .icon { transition: transform 0.25s ease; }
.cz .cz-send:hover .icon { transform: translateX(3px); }
.cz-tools { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.cz .cz-tool { flex: 1 1 auto; min-height: 44px; padding: 10px 16px; }
.cz .cz-tool .icon { color: var(--caramel-deep); }
.cz-status { margin: 4px 0 0; min-height: 1.45em; text-align: center; font-size: 13.5px; font-weight: 500; color: var(--brown-mid); }
.cz-status:empty { min-height: 0; }
.cz-share-box { margin-top: 4px; }
.cz-share-box[hidden] { display: none; }
.cz-share-box .di-in { width: 100%; min-height: 44px; font-size: 13.5px; }

/* starting designs */
.cz-sec--presets .cz-h { margin-bottom: 6px; }
.cz-presets__lead { margin: 0 0 16px; }
.cz-presets { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.cz-preset {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 8px 16px 8px 10px;
  border: 1px solid rgba(43, 26, 18, 0.2);
  border-radius: 999px;
  background: var(--sand);
  color: var(--brown);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}
.cz-preset:hover { border-color: var(--caramel); background: var(--cream-soft); }
.cz-preset:active { transform: scale(0.97); }
.cz-preset:focus-visible { outline: 2px solid var(--caramel-deep); outline-offset: 3px; }
.cz-preset__dots { display: inline-flex; }
.cz-preset__dots span {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(43, 26, 18, 0.25), 0 0 0 2px var(--sand);
}
.cz-preset__dots span + span { margin-left: -6px; }

/* name and age side by side */
.cz-pair { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; }

/* lettering chips preview their own type */
.cz-chip__face.cz-f-script { font-family: 'Great Vibes', cursive; font-size: 21px; font-weight: 400; padding-top: 6px; padding-bottom: 6px; }
.cz-chip__face.cz-f-serif { font-family: 'Playfair Display', Georgia, serif; font-weight: 600; }
.cz-chip__face.cz-f-sans { font-family: 'Work Sans', system-ui, sans-serif; }
.cz-chip__face .cz-dot { margin: 0; width: 14px; height: 14px; }
.cz-vh:checked + .cz-chip__face .cz-dot { box-shadow: inset 0 0 0 1px rgba(255, 253, 248, 0.6), 0 0 0 1px rgba(255, 253, 248, 0.35); }
.cz-sum__note { text-align: center; margin-top: 14px; }
.cz-noscript { padding: 16px; border: 1px solid var(--cz-line); border-radius: 12px; background: var(--cream-soft); }

.cz-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- tablet and phone: compact sticky preview on top ---------- */
@media (max-width: 900px) {
  .cz .cz-hero { margin-bottom: 20px; }
  .cz-layout { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .cz-preview {
    top: var(--cz-top);
    z-index: 30;
    margin: 0 calc(-1 * clamp(16px, 4vw, 40px));
    padding: 6px 16px 10px;
    border-radius: 0 0 20px 20px;
    border-width: 0 0 1px;
    box-shadow: 0 10px 24px rgba(43, 26, 18, 0.08);
  }
  .cz-stage { aspect-ratio: auto; height: calc(40vh - 44px); max-height: 340px; min-height: 180px; }
  .cz-caption { margin-top: 4px; font-size: 14px; }
  .cz-note { display: none; }
  .cz-sec { padding: 24px 0; }
  .cz-sec:first-child { padding-top: 10px; }
}
@media (max-width: 560px) {
  .cz-fields--row { grid-template-columns: minmax(0, 1fr); }
  .cz-chip__face { padding: 8px 13px; font-size: 13.5px; }
  .cz-chips--shape .cz-chip__face { padding: 9px 15px; font-size: 14px; }
  .cz-dl__row { grid-template-columns: 86px minmax(0, 1fr); gap: 10px; }
  .cz-preset { padding: 7px 13px 7px 9px; font-size: 13.5px; }
  .cz .cz-tool { padding: 10px 12px; font-size: 13.5px; }
}
@media (max-width: 360px) {
  .cz-pair { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  .cz-layer, .cz-chip__face, .cz-sw__dot, .cz-sw__dot .icon, .cz .cz-send .icon, .cz-preset { transition: none; }
  .cz-preset:active { transform: none; }
  .cz-flame { animation: none; }
}

/* Short landscape phones: sticky preview would cover the controls */
@media (max-width: 900px) and (max-height: 560px) {
  .cz-preview { position: static; }
}
