/**
 * Headstone Builder — Styles v1.4.4
 * Desktop: sticky left preview + scrollable right options
 * Mobile:  fixed preview bar (rendered in wp_footer, outside form.cart)
 *
 * Designed & Developed by Instant Web Tools, LLC
 * https://instantwebtools.co | https://iwcloud.me/shop
 */

/* ── Variables ── */
:root {
  --hb-navy:    #1B2A4A;
  --hb-crimson: #8B1A1A;
  --hb-gold:    #C9A96E;
  --hb-cream:   #F7F4EF;
  --hb-border:  #E0DBD3;
  --hb-muted:   #7a7570;
  --hb-radius:  5px;
}

/* ─────────────────────────────────────────
   WRAPPER
───────────────────────────────────────── */
.hb-builder-wrap {
  margin: 28px 0 0;
  font-family: 'Josefin Sans', -apple-system, sans-serif;
}

/* ─────────────────────────────────────────
   DESKTOP: 2-column layout
   Left = sticky preview | Right = options
───────────────────────────────────────── */
.hb-layout {
  display: grid;
  grid-template-columns: 480px 1fr;
  gap: 36px;
  align-items: start;
}

/* ── Left: sticky preview ── */
.hb-sticky-col {
  position: sticky;
  top: 40px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hb-preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.hb-preview-label {
  font-size: 9px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--hb-muted); font-weight: 600;
}
.hb-live-badge {
  font-size: 9px; font-weight: 700;
  background: var(--hb-crimson); color: #fff;
  padding: 3px 10px; border-radius: 20px;
  letter-spacing: 1px; text-transform: uppercase;
  animation: hb-pulse 2.5s ease-in-out infinite;
}
@keyframes hb-pulse { 0%,100%{opacity:1;} 50%{opacity:.7;} }

/* Stone stage */
.hb-stage {
  background: var(--hb-cream);
  border: 1px solid var(--hb-border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 10px 10px;
  position: relative;
  overflow: hidden;
}
.hb-stage::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 20%, rgba(201,169,110,0.08) 0%, transparent 65%);
  pointer-events: none;
}
#hb-canvas {
  display: block; width: 100%; max-width: 520px; height: auto;
  border-radius: 3px; position: relative; z-index: 2;
  filter: drop-shadow(0 12px 32px rgba(0,0,0,0.20)) drop-shadow(0 3px 8px rgba(0,0,0,0.12));
}

/* Color info pill */
.hb-stage-info {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 16px;
  background: var(--hb-cream);
  border: 1px solid var(--hb-border);
  border-radius: 20px;
  align-self: center;
}
.hb-stage-color-dot {
  width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid rgba(0,0,0,0.12);
  display: none; flex-shrink: 0;
}
.hb-stage-color-label {
  font-size: 11px; font-weight: 600;
  color: var(--hb-navy); letter-spacing: .4px;
}

/* ── Right: scrollable options ── */
.hb-scroll-col { display: flex; flex-direction: column; }

/* ── Sections ── */
.hb-section { padding: 20px 0; border-bottom: 1px solid var(--hb-border); }
.hb-section:last-child { border-bottom: none; }
.hb-section-label {
  font-size: 10px; font-weight: 700; color: var(--hb-crimson);
  letter-spacing: 2px; text-transform: uppercase;
  margin-bottom: 14px; display: block;
}

/* ── Fields ── */
.hb-field-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.hb-field-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 10px; }
.hb-field-group label { font-size: 10px; font-weight: 700; color: var(--hb-muted); letter-spacing: .5px; text-transform: uppercase; }

.hb-input, .hb-textarea, .hb-select {
  width: 100%; padding: 10px 13px;
  border: 1.5px solid var(--hb-border); border-radius: var(--hb-radius);
  font-family: inherit; font-size: 13px; color: var(--hb-navy);
  background: #fafaf8; transition: border-color .15s;
  box-sizing: border-box;
}
.hb-input:focus, .hb-textarea:focus, .hb-select:focus { outline: none; border-color: var(--hb-crimson); }
.hb-textarea { resize: vertical; min-height: 74px; }
.hb-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%23888' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px;
}
.hb-char-count { font-size: 10px; color: var(--hb-muted); text-align: right; margin-top: -6px; }

/* ── Font grid ── */
.hb-font-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; }
.hb-font-card {
  border: 1.5px solid var(--hb-border); border-radius: var(--hb-radius);
  padding: 10px 6px; text-align: center; cursor: pointer;
  background: #fafaf8; font-family: inherit; transition: border-color .15s, background .15s;
}
.hb-font-card:hover  { border-color: var(--hb-navy); }
.hb-font-card.active { border-color: var(--hb-crimson); background: #fff8f5; }
.hb-font-name   { display: block; font-size: 9px; color: var(--hb-muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 4px; }
.hb-font-sample { display: block; font-size: 17px; color: var(--hb-navy); line-height: 1; }

/* ── Category pills ── */
.hb-cat-pills { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
.hb-cat-pill {
  border: 1.5px solid var(--hb-border); border-radius: 20px;
  padding: 4px 11px; font-size: 10px; font-family: inherit;
  font-weight: 600; color: var(--hb-muted); cursor: pointer;
  background: #fafaf8; transition: all .15s;
}
.hb-cat-pill:hover  { border-color: var(--hb-navy); color: var(--hb-navy); }
.hb-cat-pill.active { border-color: var(--hb-crimson); background: var(--hb-crimson); color: #fff; }

/* ── Icon grid ── */
.hb-icon-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 6px; margin-bottom: 8px; }
.hb-icon-card {
  border: 1.5px solid var(--hb-border); border-radius: var(--hb-radius);
  padding: 8px 3px 6px; text-align: center; cursor: pointer;
  background: #fafaf8; font-family: inherit; color: var(--hb-muted);
  transition: border-color .15s, background .15s, color .15s;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.hb-icon-card:hover  { border-color: var(--hb-navy); color: var(--hb-navy); }
.hb-icon-card.active { border-color: var(--hb-crimson); background: #fff8f5; color: var(--hb-crimson); }
.hb-icon-card span   { font-size: 8px; display: block; line-height: 1.3; }

.hb-no-emblem-btn {
  width: 100%; border: 1px dashed var(--hb-border); border-radius: var(--hb-radius);
  padding: 7px; font-family: inherit; font-size: 10px; color: var(--hb-muted);
  background: none; cursor: pointer; transition: border-color .15s, color .15s;
}
.hb-no-emblem-btn:hover  { border-color: var(--hb-navy); color: var(--hb-navy); }
.hb-no-emblem-btn.active { border-color: var(--hb-crimson); color: var(--hb-crimson); background: #fff8f5; }

/* ── Upload ── */
.hb-upload-zone {
  border: 1.5px dashed var(--hb-border); border-radius: 6px;
  padding: 12px 10px; text-align: center; background: #fafaf8;
  cursor: pointer; transition: border-color .15s; color: var(--hb-muted);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.hb-upload-zone:hover    { border-color: var(--hb-crimson); }
.hb-upload-zone.dragging { border-color: var(--hb-crimson); background: #fff8f5; }
.hb-upload-title { font-size: 11px; font-weight: 700; color: var(--hb-navy); }
.hb-upload-sub   { font-size: 10px; color: var(--hb-muted); }
#hb-upload-preview { display: flex; align-items: center; gap: 8px; margin-top: 8px; padding: 7px; background: #f8f7f5; border-radius: var(--hb-radius); border: 1px solid var(--hb-border); }
#hb-upload-filename { font-size: 10px; color: var(--hb-navy); flex: 1; word-break: break-all; }
.hb-remove-upload   { background: none; border: none; color: var(--hb-crimson); cursor: pointer; font-size: 13px; font-weight: 700; padding: 2px 5px; }
.hb-uploading { opacity: .6; pointer-events: none; }

/* ── Add to Cart bar ── */
.hb-cart-bar {
  display: flex; align-items: center; gap: 16px;
  margin-top: 28px; padding: 16px 20px;
  background: var(--hb-cream); border: 1.5px solid var(--hb-border); border-radius: 8px;
}
.hb-cart-bar-info { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; }
.hb-cart-color-dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(0,0,0,0.12); flex-shrink: 0; display: none; }
.hb-cart-summary { font-size: 12px; color: var(--hb-muted); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hb-add-to-cart-btn {
  display: flex; align-items: center; gap: 8px;
  background: var(--hb-crimson); color: #fff; border: none;
  padding: 14px 28px; font-family: inherit; font-size: 13px;
  font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase;
  cursor: pointer; border-radius: 4px; transition: background .2s, transform .1s;
  white-space: nowrap; flex-shrink: 0;
}
.hb-add-to-cart-btn:hover  { background: #6e1212; }
.hb-add-to-cart-btn:active { transform: scale(0.98); }
.hb-add-to-cart-btn.loading { opacity: .7; pointer-events: none; }


/* ─────────────────────────────────────────
   MOBILE — preview bar rendered in wp_footer
   outside form.cart so position:fixed works
   on iOS Safari regardless of keyboard state.
   Visual Viewport API in JS keeps it pinned.
───────────────────────────────────────── */

/* Footer preview bar: hidden on desktop */
.hb-mobile-preview-bar { display: none; }

@media (max-width: 900px) {

  /* Hide the in-form sticky col — mobile uses footer bar */
  .hb-sticky-col { display: none !important; }

  /* Stack layout */
  .hb-layout { grid-template-columns: 1fr; gap: 0; }

  /* Scroll col sits below fixed bar (JS sets exact margin) */
  .hb-scroll-col { margin-top: 10px; padding-top: 16px; }

  /* ── Footer preview bar ── */
  .hb-mobile-preview-bar {
    display: flex !important;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 999999;
    background: var(--hb-navy);
    padding: 10px 16px 12px;
    padding-top: calc(10px + env(safe-area-inset-top, 0px));
    box-shadow: 0 2px 16px rgba(0,0,0,0.4);
    /* Own compositing layer — required for Visual Viewport translateY */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    will-change: transform;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    transition: none !important;
    animation: none !important;
  }

  /* Canvas — hard locked, never resizes */
  #hb-canvas-mobile {
    width: 300px !important; height: 300px !important;
    min-width: 300px !important; min-height: 300px !important;
    max-width: 300px !important; max-height: 300px !important;
    display: block !important; flex-shrink: 0 !important; flex-grow: 0 !important;
    border-radius: 4px;
    filter: drop-shadow(0 4px 14px rgba(0,0,0,0.5));
    transition: none !important; animation: none !important;
  }

  .hb-mobile-preview-info {
    display: flex; flex-direction: row; align-items: center;
    justify-content: center; gap: 8px; width: 100%; flex-shrink: 0;
  }
  .hb-mobile-color-dot {
    width: 11px; height: 11px; border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.3);
    display: none; flex-shrink: 0;
  }
  .hb-mobile-color-label {
    color: rgba(255,255,255,0.9); font-size: 11px; font-weight: 600;
    text-align: center; font-family: 'Josefin Sans', -apple-system, sans-serif;
    letter-spacing: 0.3px;
  }
  .hb-live-badge { font-size: 8px !important; padding: 2px 7px !important; }

  /* Admin bar offset */
  .admin-bar .hb-mobile-preview-bar { top: 46px; }

  /* Inputs — 16px prevents iOS keyboard zoom */
  .hb-input, .hb-textarea, .hb-select { font-size: 16px; padding: 12px 14px; }

  .hb-font-grid  { grid-template-columns: 1fr 1fr; }
  .hb-icon-grid  { grid-template-columns: repeat(3,1fr); }
  .hb-field-row  { grid-template-columns: 1fr 1fr; }

  .hb-cart-bar { flex-direction: column; gap: 10px; padding: 14px 16px; margin-bottom: env(safe-area-inset-bottom, 0px); }
  .hb-add-to-cart-btn { width: 100%; justify-content: center; padding: 16px; font-size: 14px; }
}

/* Very narrow phones */
@media (max-width: 320px) {
  #hb-canvas-mobile {
    width: 220px !important; height: 220px !important;
    min-width: 220px !important; min-height: 220px !important;
    max-width: 220px !important; max-height: 220px !important;
  }
  .hb-field-row { grid-template-columns: 1fr; }
}
