/* ============================================================================
 * BigPDF — Visual Margin Cropper & 2-Up Spread Splitter (/tools/visual-crop/)
 * Built on /brand.css --bp-* design tokens and .bp-wb-* workbench shell
 * ============================================================================ */

[hidden] {
  display: none !important;
}

html:not(.bp-embed) .bp-embed-only {
  display: none !important;
}

.vc-page-head {
  padding: 2px 0 14px;
}

.vc-head-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.vc-page-title {
  font-size: clamp(1.55rem, 2.9vw, 2.2rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.03em;
  margin-bottom: 6px;
}

.vc-dot {
  color: var(--bp-accent);
}

.vc-page-sub {
  font-size: 15.5px;
  line-height: 1.62;
  color: var(--bp-ink-secondary);
  max-width: 68ch;
  margin: 0;
}

.vc-wb-section {
  padding-bottom: 44px;
}

html.bp-embed .vc-wb-section,
body.bp-embed .vc-wb-section {
  padding-bottom: 0;
}

html.bp-embed .bp-proof-frame::before,
body.bp-embed .bp-proof-frame::before {
  display: none;
}

/* Workbench Bar Additions */
.vc-mode-bar {
  gap: 8px;
}

.vc-page-stepper {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.vc-page-stepper[hidden] {
  display: none;
}

.vc-step-btn {
  min-width: 28px;
  padding: 0 8px;
  font-size: 15px;
}

.vc-step-readout {
  font-size: 11.5px;
  color: var(--bp-ink-on-dark-muted);
  padding: 0 6px;
  white-space: nowrap;
}

/* Stage & Interactive Crop Sheet */
.bp-wb-stage.is-dragover {
  background-color: var(--bp-teal-soft);
}

.vc-hud-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.vc-hud-btn {
  border: 1px solid rgba(255, 255, 255, 0.18);
  cursor: pointer;
  transition: background-color 0.13s var(--bp-ease), color 0.13s var(--bp-ease);
}

.vc-hud-btn:hover {
  background: var(--bp-accent);
  color: #FFFFFF;
}

.vc-samples-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.vc-samples-label {
  font-family: var(--bp-font-mono);
  font-size: 11.5px;
  color: var(--bp-ink-muted);
}

.vc-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 36px 20px;
  color: var(--bp-ink-strong);
  font-size: 13px;
}

.vc-loading[hidden] {
  display: none;
}

.vc-spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2.5px solid var(--bp-line-strong);
  border-top-color: var(--bp-teal);
  animation: vc-spin 0.7s linear infinite;
}

@keyframes vc-spin {
  to { transform: rotate(360deg); }
}

.vc-canvas-wrap {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 38px 10px 10px;
}

.vc-canvas-wrap[hidden] {
  display: none;
}

.vc-sheet-frame {
  position: relative;
  display: inline-block;
  max-width: 100%;
  user-select: none;
  -webkit-user-select: none;
}

.vc-sheet-frame canvas {
  display: block;
  max-width: 100%;
  max-height: 540px;
  width: auto;
  height: auto;
}

html.bp-embed .vc-sheet-frame canvas,
body.bp-embed .vc-sheet-frame canvas {
  max-height: 460px;
}

/* Clipped outside-crop dim mask layer (4 curtains) */
.vc-mask-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 3;
}

.vc-shade {
  position: absolute;
  background: rgba(23, 27, 33, 0.34);
}

/* Unclipped interactive crop box overlay */
.vc-crop-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
}

.vc-crop-box {
  /* Override brand.css 9999px shadow since we use exact clipped curtains */
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.65) inset;
  background: rgba(14, 110, 110, 0.04);
  touch-action: none;
  line-height: 1;
}

.vc-crop-box.is-dragging {
  background: rgba(14, 110, 110, 0.09);
}

/* Flip dimension badge inside box when top margin is tiny */
.vc-crop-box.is-top-tight .bp-crop-dims {
  top: 6px;
  left: 6px;
}

/* Generous invisible touch hit area on 8 handles */
.bp-crop-handle {
  width: 14px;
  height: 14px;
  touch-action: none;
}

.bp-crop-handle::after {
  content: "";
  position: absolute;
  inset: -9px;
}

.bp-crop-handle:hover,
.bp-crop-handle:focus-visible {
  background: var(--bp-teal);
  border-color: #FFFFFF;
}

/* Mirror even-page dashed ghost reference */
.vc-mirror-ghost {
  position: absolute;
  border: 1.5px dashed rgba(14, 110, 110, 0.55);
  pointer-events: none;
  z-index: 1;
}

.vc-mirror-ghost span {
  position: absolute;
  bottom: 4px;
  right: 4px;
  padding: 2px 5px;
  border-radius: 3px;
  background: rgba(14, 110, 110, 0.85);
  color: #FFFFFF;
  font-family: var(--bp-font-mono);
  font-size: 9.5px;
  font-weight: 600;
}

/* 2-Up Editorial Vermilion Gutter */
.vc-gutter {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 24px;
  margin-left: -12px;
  border-left: 0;
  cursor: col-resize;
  touch-action: none;
  z-index: 6;
}

.vc-gutter::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  transform: translateX(-1px);
  border-left: 2.5px dashed var(--bp-accent);
  pointer-events: none;
}

.vc-gutter-grip {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 4px 8px;
  border-radius: var(--bp-radius-pill);
  background: var(--bp-accent);
  color: #FFFFFF;
  border: 2px solid #FFFFFF;
  box-shadow: 0 2px 8px rgba(23, 27, 33, 0.3);
  font-family: var(--bp-font-mono);
  font-size: 10.5px;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
}

.vc-gutter:hover .vc-gutter-grip,
.vc-gutter.is-dragging .vc-gutter-grip {
  background: var(--bp-accent-hover);
  transform: translate(-50%, -50%) scale(1.06);
}

.vc-half-badge {
  position: absolute;
  bottom: -24px;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(23, 27, 33, 0.86);
  color: #FFFFFF;
  font-family: var(--bp-font-mono);
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  z-index: 5;
}

.vc-crop-box.is-bottom-tight .vc-half-badge {
  bottom: 7px;
}

.vc-half-left {
  left: 0;
}

.vc-half-right {
  right: 0;
}

.vc-crop-box.is-bottom-tight .vc-half-left {
  left: 7px;
}

.vc-crop-box.is-bottom-tight .vc-half-right {
  right: 7px;
}

/* Compact inspector spacing so entire drafting studio stays above the fold */
#cropWorkbench .bp-wb-panel {
  padding: 12px 15px;
  gap: 9px;
}

#cropWorkbench .bp-wb-actions {
  padding: 12px 15px;
}

#cropWorkbench .bp-wb-telemetry {
  padding: 9px 10px;
  gap: 6px;
}

#cropWorkbench .bp-wb-tel-val {
  font-size: 12.5px;
}

/* Inspector Enhancements */
.vc-unit-switch {
  display: inline-flex;
  border-radius: 5px;
  border: 1px solid var(--bp-line-strong);
  overflow: hidden;
  background: var(--bp-sub);
}

.vc-unit-switch button {
  border: 0;
  background: transparent;
  padding: 2px 8px;
  font-family: var(--bp-font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--bp-ink-muted);
  cursor: pointer;
}

.vc-unit-switch button.is-active {
  background: var(--bp-ink);
  color: #FFFFFF;
}

.vc-margin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.vc-num-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.vc-num-field span {
  font-family: var(--bp-font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--bp-ink-muted);
}

.vc-num-field .bp-input {
  min-height: 34px;
  padding: 0 9px;
  font-size: 13px;
}

.vc-toggle-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
}

.vc-toggle-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.vc-toggle-copy strong {
  font-size: 13px;
  font-weight: 600;
  color: var(--bp-ink);
  line-height: 1.3;
}

.vc-toggle-copy small {
  font-size: 12px;
  line-height: 1.4;
  color: var(--bp-ink-muted);
}

.vc-switch {
  -webkit-appearance: none;
  appearance: none;
  flex: none;
  width: 38px;
  height: 22px;
  margin: 2px 0 0;
  border-radius: var(--bp-radius-pill);
  background: var(--bp-control);
  border: 1px solid var(--bp-line-strong);
  position: relative;
  cursor: pointer;
  transition: background-color 0.16s var(--bp-ease), border-color 0.16s var(--bp-ease);
}

.vc-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: 0 1px 3px rgba(23, 27, 33, 0.28);
  transition: transform 0.16s var(--bp-ease);
}

.vc-switch:checked {
  background: var(--bp-teal);
  border-color: var(--bp-teal);
}

.vc-switch-accent:checked {
  background: var(--bp-accent);
  border-color: var(--bp-accent);
}

.vc-switch:checked::after {
  transform: translateX(16px);
}

.vc-switch:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.vc-status-tag {
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bp-sub);
  border: 1px solid var(--bp-line);
  color: var(--bp-ink-muted);
  font-family: var(--bp-font-mono);
  font-size: 10.5px;
  font-weight: 600;
}

.vc-status-tag.is-on {
  background: var(--bp-accent-soft);
  border-color: var(--bp-accent-border);
  color: var(--bp-accent-text);
}

.vc-2up-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 4px;
}

.vc-2up-controls[hidden] {
  display: none;
}

.vc-accent-val {
  color: var(--bp-accent-text);
}

.bp-wb-tel-val.is-teal {
  color: var(--bp-teal);
}

.vc-export-status {
  padding: 9px 11px;
  border-radius: var(--bp-radius-xs);
  border: 1px solid var(--bp-emerald-border);
  background: var(--bp-emerald-bg);
  color: var(--bp-emerald);
  font-family: var(--bp-font-mono);
  font-size: 11.5px;
  line-height: 1.45;
}

.vc-export-status.is-error {
  border-color: var(--bp-rose-border);
  background: var(--bp-rose-bg);
  color: var(--bp-rose);
}

.vc-export-status[hidden] {
  display: none;
}

.vc-quick-samples {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 4px;
}

.vc-quick-label {
  font-family: var(--bp-font-mono);
  font-size: 11px;
  color: var(--bp-ink-muted);
}

.vc-mini-link {
  border: 0;
  background: transparent;
  padding: 2px 5px;
  border-radius: 4px;
  font-family: var(--bp-font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--bp-teal);
  cursor: pointer;
}

.vc-mini-link:hover {
  background: var(--bp-teal-soft);
}

/* Bottom Thumbnail Filmstrip */
.bp-wb-thumbs[hidden] {
  display: none;
}

.vc-stack-chip-card {
  width: 78px;
  justify-content: center;
  text-align: center;
  background: var(--bp-sub);
}

.vc-stack-chip-icon {
  font-family: var(--bp-font-mono);
  font-size: 16px;
  font-weight: 700;
  color: var(--bp-teal);
}

.bp-thumb-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* Below-the-fold Spec Grid */
.vc-spec-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.vc-spec-card {
  padding: 20px;
  border-radius: var(--bp-radius-md);
  background: var(--bp-sheet);
  border: 1px solid var(--bp-line);
  box-shadow: var(--bp-shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.vc-spec-card h3 {
  font-size: 1.08rem;
  margin: 0;
}

.vc-spec-card p {
  font-size: 14px;
  line-height: 1.6;
  color: var(--bp-ink-secondary);
  margin: 0;
}

.vc-related-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 22px;
}

@media (max-width: 960px) {
  .vc-spec-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .vc-canvas-wrap {
    padding: 8px 4px 8px;
  }

  .vc-hud-right {
    width: 100%;
    justify-content: space-between;
  }

  .vc-sheet-frame canvas {
    max-height: 440px;
  }

  .vc-mode-bar {
    width: 100%;
    justify-content: space-between;
  }
}

@media (max-width: 390px) {
  .vc-canvas-wrap {
    padding: 4px 0 4px;
  }
}
