/* ==========================================================================
   Divine Monuments — Monument Constructor
   Two-column Olympia layout, Vesper token system.
   Tokens defined in site.css :root — do NOT redefine here.
   ========================================================================== */

/* ── Two-column shell ─────────────────────────────────────────────────────── */
.dm-constructor {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 2rem;
  align-items: start;
  margin-block: 2rem;
}

.dm-constructor__preview {
  position: sticky;
  top: calc(var(--site-head-h, 72px) + 1rem);
  border-radius: var(--r);
  overflow: hidden;
  /* border: 1px solid var(--line); */
  background: var(--surface);
  min-height: 0;
}

/* Chamevo's customizer defaults to a tall host (--cv-customizer-height:700px,
   min 500px) which leaves big gray bands around the wide monument stage. These are
   inheritable custom properties, so we override them to make the customizer itself
   shorter — Chamevo then refits the canvas to the new height (no clipping). Tune
   --dm-preview-h. */
.dm-constructor__preview cv-customizer,
.dm-constructor__preview .chamevo-customizer {
  --dm-preview-h: 440px;
  --cv-customizer-height: var(--dm-preview-h);
  --cv-customizer-min-height: 0px;
  --cv-customizer-max-height: none;
}

/* Init mask: Chamevo auto-opens its first tool panel ("Add Text") on mount and
   its toolbar/chrome lives in unreachable shadow DOM. While .is-initializing is
   present (set in markup, removed by engine.js once the panel is closed), cover
   the designer so that auto-open never flashes before we dismiss it. */
.dm-constructor.is-initializing .dm-constructor__preview > * {
  visibility: hidden;
}
.dm-constructor.is-initializing .dm-constructor__preview::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--surface);
  z-index: 2;
}
/* Centered preloader spinner shown over the init mask until the canvas appears. */
.dm-constructor.is-initializing .dm-constructor__preview::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 38px;
  height: 38px;
  margin: -19px 0 0 -19px;
  border: 3px solid var(--line);
  border-top-color: var(--brass, #b08d57);
  border-radius: 50%;
  z-index: 3;
  animation: dm-spin 0.8s linear infinite;
}
@keyframes dm-spin {
  to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
  .dm-constructor.is-initializing .dm-constructor__preview::before {
    animation-duration: 1.6s;
  }
}

.dm-constructor__panel {
  /* #dm-stepper — JS renders into here */
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  overflow: hidden;
}

/* Mobile: stack vertically, preview on top */
@media (max-width: 820px) {
  .dm-constructor {
    grid-template-columns: 1fr;
  }
  .dm-constructor__preview {
    position: static;
    min-height: 280px;
  }
}

/* ── Attempt to hide Chamevo chrome (canvas-only view) ───────────────────── */
/*
 * Chamevo renders a <cv-customizer> Stencil web component. Shadow DOM parts
 * are not documented by Chamevo, so ::part() is not available.
 * We constrain the host element so only the canvas area is visible, and try
 * a best-effort hide of the toolbar via the custom property approach.
 * If chrome persists it is cosmetic — the canvas remains functional.
 */
.dm-constructor__preview cv-customizer,
.dm-constructor__preview .chamevo-customizer {
  --cv-toolbar-display: none;
  --cv-sidebar-display: none;
  --cv-header-display: none;
  display: block;
  width: 100%;
}

/* Chamevo wraps its UI in .cv-customizer__stage or .cha-stage-wrapper.
   Best-effort suppression of toolbar/panel nodes we cannot reach in shadow DOM. */
.dm-constructor__preview .cv-toolbar,
.dm-constructor__preview .cv-sidebar,
.dm-constructor__preview .cv-header,
.dm-constructor__preview [class*="toolbar"],
.dm-constructor__preview [class*="panel-tabs"] {
  display: none !important;
}

/* ── Product title ───────────────────────────────────────────────────────── */
.dm-constructor__title {
  font-family: var(--serif);
  font-size: clamp(1.6rem, 3vw, 2rem);
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.01em;
  line-height: 1.1;
  margin-bottom: 0;
}

/* ── Step tab row ─────────────────────────────────────────────────────────── */
.dm-step-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  touch-action: pan-x;
  scrollbar-width: thin;
  scrollbar-color: var(--brass) transparent;
}
.dm-step-tabs::-webkit-scrollbar { height: 6px; }
.dm-step-tabs::-webkit-scrollbar-track { background: transparent; }
.dm-step-tabs::-webkit-scrollbar-thumb {
  background: var(--brass);
  border-radius: 3px;
}
/* Drag-to-scroll (see enableDragScroll in ui.js). */
.dm-step-tabs { cursor: grab; }
.dm-step-tabs--dragging {
  cursor: grabbing;
  user-select: none;
}

.dm-step-tab {
  /* Grow to fill when there's room, but never shrink below the label width —
     so a crowded tab bar scrolls horizontally instead of clipping the last tab. */
  flex: 1 0 auto;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-soft);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 8px 9px;
  cursor: pointer;
  white-space: nowrap;
  transition: color .2s var(--ease), border-color .2s var(--ease);
  margin-bottom: -1px;
}
.dm-step-tab:hover {
  color: var(--text);
}
.dm-step-tab--active {
  color: var(--brass-deep);
  border-bottom-color: var(--brass);
}

/* ── Step panel ───────────────────────────────────────────────────────────── */
.dm-step-panel__hint {
  font-family: var(--sans);
  font-size: 13.5px;
  color: var(--text-soft);
  margin-bottom: .75rem;
}

/* ── Option cards grid ────────────────────────────────────────────────────── */
.dm-option-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: .75rem;
}

.dm-option-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--r);
  padding: .75rem .5rem;
  cursor: pointer;
  text-align: center;
  transition:
    border-color .2s var(--ease),
    box-shadow .2s var(--ease),
    background .2s var(--ease);
}
.dm-option-card:hover {
  border-color: var(--brass-light);
  background: var(--bg-alt, var(--paper-2));
}
.dm-option-card--selected {
  border-color: var(--brass);
  box-shadow: 0 0 0 2px var(--brass);
  background: color-mix(in oklch, var(--brass) 8%, var(--surface));
}

.dm-option-card__thumb {
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
  overflow: hidden;
  background: var(--paper-3);
}
.dm-option-card__thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.dm-option-card__label {
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-soft);
  line-height: 1.3;
}
.dm-option-card--selected .dm-option-card__label {
  color: var(--brass-deep);
  font-weight: 600;
}

/* ── Colour swatches ─────────────────────────────────────────────────────── */
.dm-colour-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
}

.dm-colour-swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .4rem;
  background: none;
  border: 1.5px solid var(--line);
  border-radius: var(--r);
  padding: .6rem .5rem;
  cursor: pointer;
  min-width: 72px;
  transition:
    border-color .2s var(--ease),
    box-shadow .2s var(--ease);
}
.dm-colour-swatch:hover {
  border-color: var(--brass-light);
}
.dm-colour-swatch--selected {
  border-color: var(--brass);
  box-shadow: 0 0 0 2px var(--brass);
}

.dm-colour-swatch__dot {
  display: block;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  flex-shrink: 0;
}
.dm-colour-swatch--selected .dm-colour-swatch__dot {
  box-shadow: 0 0 0 2px var(--brass), 0 0 0 4px var(--surface);
}

.dm-colour-swatch__label {
  font-family: var(--sans);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-soft);
  text-align: center;
  line-height: 1.3;
  white-space: nowrap;
}
.dm-colour-swatch--selected .dm-colour-swatch__label {
  color: var(--brass-deep);
  font-weight: 600;
}

/* ── Action row ──────────────────────────────────────────────────────────── */
.dm-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: .5rem;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}

.dm-actions__clear {
  font-size: 14px;
  padding: 10px 18px;
}
.dm-actions__clear:disabled,
.dm-actions__clear[aria-disabled="true"] {
  opacity: .4;
  pointer-events: none;
}

.dm-actions__quote {
  margin-left: auto;
}
.dm-actions__quote:disabled {
  opacity: .6;
  pointer-events: none;
}

/* Mobile action row: stack */
@media (max-width: 480px) {
  .dm-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .dm-actions__quote {
    margin-left: 0;
    justify-content: center;
  }
  .dm-option-grid {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  }
}

/* ── Quote form (mirrors .cha-shortcode-form Vesper styling) ─────────────── */
.dm-quote-form {
  display: grid;
  gap: .75rem;
  max-width: 32rem;
  margin-top: 1.25rem;
}

.dm-quote-form label {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-soft);
}

.dm-quote-form input[type="text"],
.dm-quote-form input[type="email"] {
  width: 100%;
  padding: .85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: .5rem;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  transition: border-color .2s var(--ease);
}
.dm-quote-form input[type="text"]:focus,
.dm-quote-form input[type="email"]:focus {
  outline: none;
  border-color: var(--brass);
}

.dm-quote-form [type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .9rem 1.4rem;
  background: var(--brass);
  color: var(--ink);
  border: none;
  border-radius: .5rem;
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .2s var(--ease);
}
.dm-quote-form [type="submit"]:disabled {
  opacity: .55;
  pointer-events: none;
}

.dm-quote-form__status {
  font-family: var(--sans);
  font-size: 14px;
  min-height: 1.4em;
  color: var(--text-soft);
}
.dm-quote-form__status--ok  { color: var(--brass-deep); }
.dm-quote-form__status--err { color: #c0392b; }

/* ── Admin-only coordinate readout (admin-coords.js) ─────────────────────────
   Live un-zoomed Left/Top/z per part so an admin can author Chamevo Graphic
   Options. Mounted only for current_user_can('manage_options'); customers never
   load the script, so this rule set stays dormant for them. */
.dm-admin-coords {
  position: fixed;
  left: 12px;
  bottom: 12px;
  z-index: 9999;
  min-width: 220px;
  background: rgba(20, 20, 22, .92);
  color: #f4f4f5;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  line-height: 1.4;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .35);
  user-select: none;
}
.dm-ac-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  font-weight: 700;
  letter-spacing: .02em;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
}
.dm-ac-toggle {
  background: none;
  border: 0;
  color: inherit;
  font: inherit;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.dm-ac-body { padding: 6px 8px 8px; }
.dm-ac-body[hidden] { display: none; }
.dm-admin-coords table { width: 100%; border-collapse: collapse; }
.dm-admin-coords td {
  padding: 2px 6px 2px 0;
  white-space: nowrap;
}
.dm-ac-name {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dm-ac-copyable { cursor: pointer; }
.dm-ac-copyable:hover { background: rgba(255, 255, 255, .08); }
.dm-ac-copyable.is-copied { background: rgba(120, 200, 120, .28); }
.dm-ac-empty { color: rgba(255, 255, 255, .5); }
.dm-ac-hint {
  margin: 6px 0 0;
  color: rgba(255, 255, 255, .5);
  font-size: 11px;
}
.dm-ac-hint code {
  background: rgba(255, 255, 255, .1);
  padding: 0 3px;
  border-radius: 3px;
}
