/* Lampenschirm-Designer (partials/lampdesigner.php + assets/js/lampdesigner.js).
   Candy Workshop tokens from shop.css; step numbers, summary and share line come
   from keyfidget.css, which this page loads too. */

/* ---- 3D stage: sticky beside the form on wide screens, on top while scrolling on phones */
.ld-visual { position: relative; min-width: 0; }
@media (min-width: 821px) { .ld-visual { position: sticky; top: 92px; align-self: start; } }
.ld-stage {
  position: relative; aspect-ratio: 4 / 5; border: var(--outline); border-radius: var(--radius); box-shadow: var(--pop-lg);
  background: radial-gradient(circle at 50% 36%, #fff, var(--tile, var(--tile-sky)) 74%); overflow: hidden;
  transition: background .5s;
}
.ld-stage.is-night { background: radial-gradient(circle at 50% 42%, #4a2a6e, var(--night) 58%, #160b2c); }
.ld-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; opacity: 0; transition: opacity .4s; }
.ld-stage canvas:active { cursor: grabbing; }
.ld-stage-photo { width: 100%; height: 100%; object-fit: cover; transition: opacity .4s; }
.ld-stage.is-3d canvas { opacity: 1; }
.ld-stage.is-3d .ld-stage-photo { opacity: 0; }
.ld-stage .model-loading { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); font-weight: 600; color: var(--ink-2); }
.ld-stage .model-loading[hidden], .ld-stage-tools[hidden], .ld-stage-hint[hidden], .ld-dims[hidden] { display: none; }
.ld-stage-hint {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); margin: 0; width: max-content; max-width: calc(100% - 24px);
  font-size: .8rem; font-weight: 600; color: var(--ink-2); background: rgba(255,255,255,.85); border-radius: 999px; padding: 4px 12px; pointer-events: none;
}
.ld-stage-tools { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; pointer-events: none; }
.ld-stage-tools > * { pointer-events: auto; }
.ld-tool {
  font: 650 .85rem/1 var(--display); color: var(--ink); background: rgba(255,255,255,.92); border: var(--outline); border-radius: 999px;
  padding: 7px 12px; cursor: pointer; box-shadow: 0 2px 0 var(--ink); transition: transform .2s var(--bounce), background .15s;
}
.ld-tool:hover { transform: translateY(-1px); background: var(--tile-sun); }
.ld-tool[aria-pressed="true"] { background: var(--ink); color: #fff; }
.ld-tool[data-ld-light][aria-pressed="true"] { background: var(--pop-sun); color: var(--ink); }
.ld-seg { display: inline-flex; }
.ld-seg .ld-tool { border-radius: 0; box-shadow: 0 2px 0 var(--ink); }
.ld-seg .ld-tool:first-child { border-radius: 999px 0 0 999px; border-right-width: 1px; }
.ld-seg .ld-tool:last-child { border-radius: 0 999px 999px 0; border-left-width: 1px; }
.ld-stage.is-night .ld-stage-hint { background: rgba(255,255,255,.14); color: #f3e9ff; }
.ld-dims { position: absolute; inset: 0; pointer-events: none; }
.ld-dim {
  position: absolute; left: 0; top: 0; white-space: nowrap; font: 700 .82rem/1 var(--display); color: var(--ink);
  background: #fff; border: 2px solid var(--ink); border-radius: 8px; padding: 4px 7px;
}
.ld-dim--light { color: var(--accent-dark); border-color: var(--accent); }
.ld-photos { align-items: center; }
.ld-photos-label { font-family: var(--display); font-weight: 700; font-size: .9rem; margin-right: 2px; }
.ld-photo { padding: 0; border: 0; background: none; cursor: zoom-in; border-radius: 14px; }
.ld-photo img { width: 56px; height: 56px; }

.ld-panel { min-width: 0; }
@media (max-width: 820px) {
  /* the scrolling tile rows must not widen the single column (shop.css uses 1fr) */
  .product.ld { grid-template-columns: minmax(0, 1fr); }
  /* the preview stays in view under the header while the controls scroll past */
  .ld-visual { position: sticky; top: 64px; z-index: 5; }
  .ld-stage { aspect-ratio: auto; height: min(46vh, 430px); box-shadow: var(--pop); }
  .ld-photos { display: none; }
  .ld-tool { padding: 6px 10px; font-size: .78rem; }
}

/* ---- panel */
.ld-lede { margin: 0 0 6px; color: var(--ink-2); max-width: 52ch; }
.ld-price-row { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 14px; }
.ld-size-note { font-family: var(--display); font-weight: 700; color: var(--ink-2); }
.ld-step { border: 0; padding: 0; margin: 0 0 24px; min-width: 0; }
.ld-step legend { display: flex; align-items: center; gap: 10px; width: 100%; padding: 0; margin-bottom: 12px; font-family: var(--display); font-size: 1.2rem; font-weight: 750; }
.ld-dice { margin-left: auto; font-size: .85rem; padding: 4px 12px; }
.ld-help { margin: 6px 0 0; font-size: .88rem; color: var(--ink-2); min-height: 0; }
.ld-help:empty { display: none; }

/* tiles: looks and patterns get rendered pictures, shapes an outline icon */
.ld-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 9px; }
.ld-tiles--shapes { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); }
@media (max-width: 820px) {
  .ld-tiles--looks, .ld-tiles--patterns { display: flex; overflow-x: auto; scroll-snap-type: x proximity; padding: 2px 2px 8px; margin: 0 -2px; }
  .ld-tiles--looks .ld-tile, .ld-tiles--patterns .ld-tile { flex: 0 0 86px; scroll-snap-align: start; }
}
.ld-tile {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 4px 8px; cursor: pointer;
  font: inherit; color: var(--ink); text-align: center; background: #fff; border: 2px solid var(--line); border-radius: var(--radius-sm);
  transition: border-color .15s, transform .25s var(--bounce), box-shadow .15s;
}
.ld-tile input { position: absolute; opacity: 0; pointer-events: none; }
.ld-tile:hover { transform: translateY(-2px); border-color: var(--ink); }
.ld-tile[aria-pressed="true"], .ld-tile:has(input:checked) { border-color: var(--ink); background: var(--tile-sun); box-shadow: 0 3px 0 var(--ink); }
.ld-tile:has(input:focus-visible), .ld-tile:focus-visible { outline: 3px solid var(--pop-sky); outline-offset: 2px; }
.ld-tile-pic { display: block; width: 100%; aspect-ratio: 9 / 11; border-radius: 8px; background: linear-gradient(160deg, #fff, var(--paper-2)); overflow: hidden; }
.ld-tile-pic img { width: 100%; height: 100%; object-fit: cover; }
.ld-tile-pic:not(.has-pic) { animation: ld-pulse 1.6s ease-in-out infinite; }
.ld-form:not(.is-live) .ld-tile-pic { display: none; }
@keyframes ld-pulse { 50% { opacity: .55; } }
.ld-tile-name { font-family: var(--display); font-weight: 700; font-size: .86rem; line-height: 1.15; hyphens: auto; overflow-wrap: anywhere; }
.ld-tile-icon { --c: #fff; color: var(--ink); line-height: 0; }
.ld-tile:has(input:checked) .ld-tile-icon { --c: #fff7d6; }

/* size chips and sliders */
.ld-sizes { margin-bottom: 12px; }
.ld-sizes .chip[aria-pressed="true"] { background: var(--ink); color: #fff; }
.ld-chip-sub { font-family: var(--sans); font-size: .76rem; font-weight: 600; opacity: .75; margin-left: 4px; }
.ld-range-row { display: grid; grid-template-columns: 7.5em minmax(0, 1fr) auto; align-items: center; gap: 4px 12px; margin: 8px 0; }
.ld-range-row > label { font-weight: 650; }
.ld-range-row input[type=range] { width: 100%; accent-color: var(--accent); }
.ld-range-row input[type=range][hidden] { display: none; }
.ld-range-row input[type=range]:not([hidden]) ~ .ld-range-val { min-width: 7.5em; }
.ld-range-val { font-size: .9rem; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.ld-range-val input[type=number] { width: 5.2em; padding: 4px 6px; border: 2px solid var(--line); border-radius: 8px; font: inherit; color: var(--ink); background: #fff; }
.ld-range-row input[type=range]:disabled { opacity: .4; }
@media (max-width: 480px) {
  .ld-range-row { grid-template-columns: 1fr auto; }
  .ld-range-row input[type=range] { grid-column: 1 / -1; grid-row: 2; }
}

/* colour and socket */
.ld-colors, .ld-sockets { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.ld-color { position: relative; cursor: pointer; }
.ld-color input { position: absolute; opacity: 0; pointer-events: none; }
.ld-color-card {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; background: #fff; border: 2px solid var(--line); border-radius: 999px;
  font-family: var(--display); font-weight: 700; transition: border-color .15s, transform .25s var(--bounce);
}
.ld-color:hover .ld-color-card { border-color: var(--ink); transform: translateY(-1px); }
.ld-color input:checked + .ld-color-card { border-color: var(--ink); background: var(--tile-sun); box-shadow: 0 3px 0 var(--ink); }
.ld-color input:focus-visible + .ld-color-card { outline: 3px solid var(--pop-sky); outline-offset: 2px; }
.ld-color input:disabled + .ld-color-card { opacity: .45; cursor: not-allowed; }
.ld-color-dot { width: 20px; height: 20px; border-radius: 50%; background: var(--c); border: 2px solid rgba(28,19,48,.3); box-shadow: inset 0 -3px 0 rgba(0,0,0,.08); }

/* fine tuning */
.ld-fine { margin: 0 0 22px; border: 2px solid var(--line); border-radius: var(--radius-sm); background: #fff; padding: 0 14px; }
.ld-fine[open] { padding-bottom: 12px; border-color: var(--ink); }
.ld-fine summary { cursor: pointer; padding: 12px 0; list-style: none; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.ld-fine summary::-webkit-details-marker { display: none; }
.ld-fine summary::before { content: '+'; font: 800 1.1rem/1 var(--display); width: 22px; height: 22px; display: inline-grid; place-items: center; border: 2px solid var(--ink); border-radius: 50%; }
.ld-fine[open] summary::before { content: '–'; }
.ld-fine-title { font-family: var(--display); font-weight: 750; font-size: 1.1rem; }
.ld-fine-sub { font-size: .85rem; color: var(--muted); }
.ld-styles { margin: 2px 0 10px 7.5em; }
@media (max-width: 480px) { .ld-styles { margin-left: 0; } }
.ld-chip-radio { position: relative; }
.ld-chip-radio input { position: absolute; opacity: 0; pointer-events: none; }
.ld-chip-radio .chip { display: inline-block; font-size: .85rem; padding: 4px 12px; }
.ld-chip-radio input:checked + .chip { background: var(--ink); color: #fff; }
.ld-chip-radio input:disabled + .chip { opacity: .4; cursor: not-allowed; }
.ld-chip-radio input:focus-visible + .chip { outline: 3px solid var(--pop-sky); outline-offset: 2px; }
.ld-switch { display: flex; align-items: center; gap: 10px; margin-top: 6px; font-weight: 600; cursor: pointer; }
.ld-switch input { width: 20px; height: 20px; accent-color: var(--accent); }
.ld-switch:has(input:disabled) { opacity: .45; }

.ld-note { margin: 0 0 10px; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--tile-sky); border: 2px solid var(--ink); font-size: .9rem; font-weight: 600; }
.ld-facts { margin: 4px 0 14px; padding: 0; list-style: none; font-size: .86rem; color: var(--ink-2); }
.ld-facts li { position: relative; padding-left: 20px; margin: 4px 0; }
.ld-facts li::before { content: '●'; position: absolute; left: 2px; top: 0; color: var(--accent); font-size: .7rem; line-height: 1.9; }
.ld-facts a { color: var(--ink-2); text-decoration: underline; }

@media (prefers-reduced-motion: reduce) {
  .ld-tile, .ld-tool, .ld-color-card { transition: none; }
  .ld-tile-pic:not(.has-pic) { animation: none; }
}
