/* Corporate Gifting 2D studio — marketplace-backed customizer */

.cg-studio-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.cg-studio-panel__meta {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.cg-studio-panel__badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  align-self: flex-start;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ci-brand, #A52422);
  background: rgba(165, 36, 34, 0.08);
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
}

.cg-studio-panel__badge.is-live {
  color: #166534;
  background: rgba(22, 101, 52, 0.1);
}

.cg-studio-panel__hint {
  margin: 0;
  font-size: 0.8rem;
  color: var(--ci-text-muted, #6b7280);
  line-height: 1.4;
}

.cg-mockup-rail {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

.cg-mockup-chip {
  flex: 0 0 auto;
  border: 1px solid var(--ci-border, #e5e7eb);
  background: #fff;
  border-radius: 0.65rem;
  padding: 0.4rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  color: #111827;
  white-space: nowrap;
}

.cg-mockup-chip.is-active {
  border-color: var(--ci-brand, #A52422);
  background: rgba(165, 36, 34, 0.08);
  color: var(--ci-brand, #A52422);
}

/* Desktop: preview left, controls right */
.cg-studio-workspace {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  align-items: start;
}

@media (min-width: 960px) {
  .cg-studio-workspace {
    /* Give the product stage more room so the bottle reads large. */
    grid-template-columns: minmax(0, 1.55fr) minmax(240px, 0.75fr);
    gap: 1.25rem;
  }

  .cg-studio-controls {
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 6rem);
    overflow-y: auto;
  }
}

.cg-studio-preview-col {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-width: 0;
}

.cg-view-rail {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.cg-view-btn {
  border: 1px solid var(--ci-border, #e5e7eb);
  background: #f9fafb;
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  color: #6b7280;
}

.cg-view-btn.is-active {
  background: #fff;
  color: var(--ci-brand, #A52422);
  border-color: var(--ci-brand, #A52422);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.cg-region-rail {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  align-items: center;
}

.cg-region-rail__label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #6b7280;
  margin-right: 0.15rem;
}

.cg-region-btn {
  border: 1px solid var(--ci-border, #e5e7eb);
  background: #fff;
  border-radius: 0.45rem;
  padding: 0.28rem 0.65rem;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  color: #374151;
}

.cg-region-btn.is-active {
  color: #fff;
  background: var(--ci-brand, #A52422);
  border-color: var(--ci-brand, #A52422);
}

.cg-color-rail {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  align-items: center;
}

.cg-color-swatch {
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 999px;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px #d1d5db;
  cursor: pointer;
  padding: 0;
}

.cg-color-swatch.is-active {
  box-shadow: 0 0 0 2px var(--ci-brand, #A52422);
}

.cg-studio-mount {
  width: 100%;
}

.cg-studio-controls {
  border: 1px solid var(--ci-border, #e5e7eb);
  border-radius: 0.9rem;
  background: #fafafa;
  padding: 0.9rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.cg-studio-controls__title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: #111827;
}

.cg-studio-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.cg-studio-field__label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #4b5563;
}

.cg-studio-input,
.cg-studio-file {
  width: 100%;
  border: 1px solid var(--ci-border, #e5e7eb);
  border-radius: 0.55rem;
  background: #fff;
  padding: 0.55rem 0.65rem;
  font-size: 0.875rem;
  color: #111827;
}

.cg-studio-input:focus {
  outline: 2px solid rgba(165, 36, 34, 0.25);
  outline-offset: 1px;
}

textarea.cg-studio-input {
  resize: vertical;
  min-height: 4.5rem;
  line-height: 1.35;
  white-space: pre-wrap;
}

.cg-studio-color {
  width: 3rem;
  height: 2.25rem;
  padding: 0.15rem;
  border: 1px solid var(--ci-border, #e5e7eb);
  border-radius: 0.45rem;
  background: #fff;
  cursor: pointer;
}

.cg-studio-range {
  width: 100%;
}

.cg-preview-stage {
  width: 100%;
}

.cg-preview-stage__frame {
  position: relative;
  width: 100%;
  /* Match vendor print-area editor (1:1) so approved regions land on the bottle. */
  aspect-ratio: 1 / 1;
  min-height: min(78vh, 600px);
  max-height: min(88vh, 720px);
  overflow: hidden;
  border-radius: 1rem;
  border: 1px solid var(--ci-border, #e5e7eb);
  background: #f0f0f0;
  touch-action: none;
  user-select: none;
}

.cg-preview-stage__frame.is-drop-active {
  outline: 3px solid rgba(165, 36, 34, 0.45);
  outline-offset: 2px;
}

.cg-preview-stage__canvases,
.cg-preview-stage__overlay {
  position: absolute;
  inset: 0;
}

.cg-preview-stage__canvas-wrap {
  position: absolute;
  inset: 0;
  display: none;
}

.cg-preview-stage__canvas-wrap.is-active {
  display: block;
}

.cg-preview-stage__canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.cg-branding-clip {
  position: absolute;
  z-index: 1;
  /* Keep overflow visible so rotate/resize handles remain grabbable. */
  overflow: visible;
  pointer-events: none;
  box-sizing: border-box;
}

.cg-branding-clip__content {
  position: absolute;
  inset: 0;
  /* Visible so rotate handles above the text stay clickable. */
  overflow: visible;
  pointer-events: none;
}

.cg-branding-clip--guided {
  border: 2px dashed rgba(165, 36, 34, 0.85);
  outline: 2px dashed rgba(232, 122, 24, 0.9);
  outline-offset: -4px;
  background: rgba(165, 36, 34, 0.04);
}

.cg-branding-clip.is-editable {
  pointer-events: auto;
  cursor: move;
}

.cg-branding-clip.is-editable .cg-branding-clip__content {
  pointer-events: auto;
}

.cg-print-region {
  position: absolute;
  z-index: 1;
  pointer-events: none;
  border: 2px dashed rgba(165, 36, 34, 0.85);
  outline: 2px dashed rgba(232, 122, 24, 0.9);
  outline-offset: -4px;
  background: rgba(165, 36, 34, 0.04);
  box-sizing: border-box;
}

.cg-print-region.is-editable {
  pointer-events: auto;
  cursor: move;
}

.cg-logo-layer,
.cg-text-layer {
  position: absolute;
  pointer-events: none;
}

.cg-logo-layer.is-editable,
.cg-text-layer.is-editable {
  pointer-events: auto;
}

.cg-logo-layer__img {
  display: block;
  width: 100%;
  height: auto;
}

.cg-logo-layer__vinyl {
  position: absolute;
  inset: -7%;
  border-radius: 10%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(18, 32, 51, 0.18);
}

.cg-logo-layer__etch {
  width: 100%;
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
}

.cg-logo-layer__hit,
.cg-text-layer__hit {
  position: absolute;
  inset: 0;
  cursor: move;
  box-shadow: 0 0 0 2px var(--ci-brand, #A52422);
}

.cg-text-layer {
  line-height: 1.15;
  /* Branding text should stay one line unless the user inserts newlines. */
  white-space: pre;
  width: max-content;
  max-width: none;
  word-break: normal;
  overflow-wrap: normal;
}

.cg-text-layer__label {
  display: inline-block;
  white-space: pre;
  pointer-events: none;
}

.cg-text-layer.is-vinyl {
  padding: 0.32em 0.55em;
  background: #fff;
  border-radius: 0.28em;
  box-shadow: 0 2px 5px rgba(18, 32, 51, 0.16);
}

.cg-handle {
  position: absolute;
  z-index: 12;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 999px;
  border: 2px solid #fff;
  background: var(--ci-brand, #A52422);
  padding: 0;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.28);
  pointer-events: auto;
  touch-action: none;
}

.cg-handle--resize {
  right: -0.55rem;
  bottom: -0.55rem;
  cursor: nwse-resize;
}

.cg-handle--rotate {
  top: -2.1rem;
  left: 50%;
  transform: translateX(-50%);
  width: 1.35rem;
  height: 1.35rem;
  background: #f5b400;
  cursor: grab;
  /* Keep the yellow rotate knob above text so it stays grabbable at any angle. */
  z-index: 20;
}

.cg-handle--rotate:active {
  cursor: grabbing;
}

.cg-handle-line {
  pointer-events: none;
  position: absolute;
  top: -1.15rem;
  left: 50%;
  width: 1px;
  height: 1.15rem;
  background: var(--ci-brand, #A52422);
  transform: translateX(-50%);
}

.cg-studio-legacy-preview[hidden] {
  display: none !important;
}

/* On the corporate gifting page, keep studio section full-width of main column */
.page-customize-corporate-gifting .cg-studio-panel {
  min-width: 0;
}
