/* ==========================================================================
   Gravestone Designer (frontend)
   - Cleaned: removed duplicated rules and merged repeated sections
   - Scoped under #gd-root to avoid theme/admin collisions
   ========================================================================== */

/* --- utilities --- */
#gd-root .hidden {
  display: none !important;
}

/* remove number spinners */
#gd-root input::-webkit-outer-spin-button,
#gd-root input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* selection border used by swatches/shapes/decor list */
#gd-root .gd-swatch.selected,
#gd-root .gd-shape.selected,
#gd-root .gd-decoration.selected {
  border-color: #e353bf;
}

/* ==========================================================================
   Panel / Layout
   ========================================================================== */

#gd-root.gd-panel {
  border: 2px solid #ddd;
  border-radius: 15px;
  box-shadow: 0 1px 33px 1px rgba(0, 0, 0, 0.2);
  background-color: var(--global-palette8);
}

#gd-root .gd-topbar {
  display: flex;
  align-items: center;
  line-height: 1;
  background-color: var(--global-palette7);
  padding: 14px 10px 10px 10px;
  border-radius: 15px 15px 0 0;
}

#gd-root .gd-topbar-link {
  padding: 0;
  margin-left: 20px;
  background: transparent;
  cursor: pointer;
  color: var(--global-palette4);
}

#gd-root .gd-topbar-icon {
  scale: 1.2;
  fill: var(--global-palette4);
  transition: all 0.15s ease-in-out;
}

#gd-root .gd-topbar-icon:hover {
  fill: var(--global-palette1);
}

#gd-root .gd-topbar-title {
  margin-left: 30px;
  color: var(--global-palette4);
  font-size: 24px;
  font-weight: 700;
}

#gd-root .gd-main-section {
  display: flex;
}

#gd-root .gd-display {
  width: 50%;
  padding: 20px 40px;
}

#gd-root .gd-left-display {
  border-bottom-left-radius: 15px;
  display: flex;
  flex-direction: column;
  gap: 40px;
}

#gd-root .gd-right-display {
  border-radius: 15px;
  border-bottom-left-radius: 0;
  border-top-right-radius: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background-color: #f9ebe3;
}

#gd-root h3 {
  margin: 0 10px 0 0 !important;
  font-size: 26px;
  text-align: center;
}

#gd-root label {
  display: block;
  margin: 8px 0;
}

#gd-root select {
  width: 100%;
  padding: 8px;
  margin-top: 4px;
  box-sizing: border-box;
}

#gd-root .gd-checkbox {
  margin-bottom: 4px;
}

/* toolbar row on the left panel (grid checkbox + button) */
#gd-root .gd-toolbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
#gd-root .gd-toolbar-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ==========================================================================
   SVG / Preview
   ========================================================================== */

#gd-root #gd-svg-container {
  width: 100%;
  height: auto;
  display: block;
  position: relative;
}

#gd-root #gd-preview-svg {
  width: 100%;
  height: auto;
  display: block;
}

/* Stone background: lighten and desaturate so text/decorations are easier to see (front-end only) */
#gd-root #gd-stone-image {
  filter: brightness(1) saturate(1) contrast(0.72);
}

/* allow dragging on touch: disable browser gestures on svg and children */
#gd-root #gd-preview-svg,
#gd-root #gd-preview-svg * {
  touch-action: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* grid overlay */
#gd-root #gd-grid-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: none;
}

#gd-root .gd-preview-disclaimer {
  text-align: center;
  font-size: 14px;
}

/* selection visuals (SVG) */
#gd-root .gd-selected-rect {
  fill: none;
  stroke: #2a9dd4;
  stroke-width: 1;
  pointer-events: none;
}

/* Tooltip (SVG group) */
.gd-move-hint {
  pointer-events: none;
}

/* Tooltip background */
.gd-move-hint__bg {
  fill: rgba(255, 255, 255, 0.90);
  stroke-width: 0;
}

/* Tooltip arrow */
.gd-move-hint__arrow {
  fill: rgba(255, 255, 255, 0.90);
  stroke-width: 0;
}

/* Tooltip text: smaller + not heavy */
.gd-move-hint__text {
  fill: #111;
  font-size: 5.2px;
  font-weight: 500;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

/* ==========================================================================
   Steps / Scrolling panels
   ========================================================================== */

#gd-root .gd-steps-container {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 0;
}

#gd-root .gd-step {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  justify-content: space-between;
}

#gd-root .gd-step.hidden {
  display: none;
}

#gd-root .gd-main-step-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* scrollable controls area */
#gd-root .gd-step .gd-controls-list,
#gd-root .gd-step .gd-swatches,
#gd-root .gd-step .gd-shapes,
#gd-root .gd-step .gd-decor-list,
#gd-root .gd-step .gd-summary {
  overflow: auto;
  flex: 1 1 auto;
  min-height: 0;
  padding-right: 6px;
  max-height: 45vh;
}

/* ==========================================================================
   Swatches / Shapes / Decorations buttons
   ========================================================================== */

#gd-root .gd-swatches,
#gd-root .gd-shapes,
#gd-root .gd-decor-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-start;
  justify-content: center;
}

#gd-root .gd-swatch,
#gd-root .gd-shape,
#gd-root .gd-decoration {
  width: 120px;
  height: 120px;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  border: 3px solid transparent;
  cursor: pointer;
  padding: 0;
  font-size: 18px;
}

#gd-root .gd-button-text {
  background-color: rgba(0, 0, 0, 0.161);
  padding: 8px 0 4px 0;
}

/* ==========================================================================
   Text controls
   ========================================================================== */

#gd-root .gd-controls-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#gd-root .gd-text-row {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px;
  background: rgba(255, 255, 255, 0.7);
}

#gd-root .gd-text-row input[type="text"],
#gd-root .gd-text-row input[type="number"],
#gd-root .gd-text-row select,
#gd-root .gd-text-row input[type="color"] {
  padding: 6px;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  width: 100%;
}


/* ==========================================================================
   Decoration detail panel
   ========================================================================== */

#gd-root .gd-decor-detail {
  margin-top: 8px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.05);
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 20px;
}

/* Padding only when the decoration detail menu is active (visible) */
#gd-root .gd-decor-detail[aria-hidden="false"] {
  padding: 8px 20px;
}

/* Edit-existing-decoration menu: different background */
#gd-root .gd-decor-detail.gd-decor-detail-edit {
  background: var(--global-palette8);
}

#gd-root .gd-size-box {
  display: flex;
  align-items: center;
  gap: 10px;
}

#gd-root .gd-size-box div {
  text-wrap: nowrap;
}
#gd-root .gd-size-box select {
  flex-shrink: 0;
}
/* ==========================================================================
   Summary
   ========================================================================== */

#gd-root .gd-summary table {
  width: 100%;
  border-collapse: collapse;
}

#gd-root .gd-summary th,
#gd-root .gd-summary td {
  padding: 8px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  text-align: left;
}
#gd-root .gd-summary td:nth-of-type(2) {
  text-wrap: nowrap;
}

#gd-root .gd-summary tfoot td {
  font-weight: 700;
}

#gd-root .gd-summary-list-highlight {
  background-color: var(--global-palette7);
}

/* ==========================================================================
   Buttons / Actions
   ========================================================================== */

#gd-root .gd-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

#gd-root .gd-btn {
  padding: 15px 30px;
  border-radius: 8px;
  border: 2px solid rgba(0, 0, 0, 0.5);
  background: transparent;
  cursor: pointer;
  color: black;
}

#gd-root .gd-btn-primary {
  background: var(--global-palette1, #a36);
  color: white;
  border: none;
}

#gd-root .gd-price {
  background: #fff;
  padding: 15px 30px;
  border-radius: 8px;
  color: black;
}

/* (optional) general buttons inside rows */
#gd-root .gd-text-row button,
#gd-root .gd-decor-detail button {
  border-radius: 6px;
  border: 2px solid rgba(0, 0, 0, 0.6);
  background: transparent;
  cursor: pointer;
  font-size: 18px;
  color: var(--global-palette4);
  padding: 12px 15px 8px 15px;
}

#gd-root .gd-text-row button {
  width: 100%;
}

/* ==========================================================================
   Save/Load box
   ========================================================================== */

#gd-root .gd-savebox {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border-radius: 8px;
}

/* ==========================================================================
   Modal
   ========================================================================== */

#gd-root .gd-modal {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 9999;
  font-family: inherit;
}

#gd-root .gd-modal[aria-hidden="false"] {
  display: block;
}

#gd-root .gd-modal__overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  pointer-events: auto;
}

#gd-root .gd-modal__dialog {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  max-width: 94vw;
  max-height: 94vh;
  background: white;
  border-radius: 10px;
  padding: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: stretch;
  justify-content: center;
  box-sizing: border-box;
  overflow: hidden;
}

#gd-root .gd-modal__content {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#gd-root .gd-modal__content img {
  display: block;
  max-width: 88vw;
  max-height: 88vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

#gd-root .gd-modal__close {
  position: absolute;
  right: 8px;
  top: 8px;
  background: transparent;
  border: none;
  font-size: 20px;
  padding: 6px;
  cursor: pointer;
  color: #333;
  border-radius: 6px;
}

#gd-root .gd-modal__close:hover {
  background: rgba(0, 0, 0, 0.04);
}

/* disable body scroll when modal open */
body.gd-modal-open {
  overflow: hidden;
  touch-action: none;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (min-width: 600px) {
  #gd-root .mobile-break {
    display: none;
  }
}

@media (max-width: 1000px) {
  #gd-root .gd-topbar-title {
    font-size: 22px;
  }

  #gd-root .gd-main-section {
    flex-direction: column;
  }

  #gd-root .gd-display {
    width: 100%;
    padding: 10px;
  }

  #gd-root .gd-left-display {
    gap: 5px;
  }

  #gd-root .gd-right-display {
    height: 450px;
  }

  #gd-root #gd-svg-container {
    width: 80%;
    margin: 0 auto;
  }

  #gd-root.gd-panel {
    height: 100%;
    overflow: auto;
  }

  #gd-root .gd-step .gd-swatches,
  #gd-root .gd-step .gd-decor-list,
  #gd-root .gd-step .gd-summary {
    max-height: 300px;
  }

  /* Stone shapes grid: lower max-height so footer (Takaisin / Yhteensä / Seuraava) stays visible on small viewports */
  #gd-root .gd-step .gd-shapes {
    max-height: 260px;
  }

  #gd-root .gd-step .gd-controls-list {
    max-height: 200px;
  }

  #gd-root .gd-main-step-content {
    gap: 5px;
  }

  #gd-root .gd-actions {
    margin-top: 0;
    padding-top: 0;
    gap: 5px;
  }

  #gd-root button {
    font-size: 16px;
    padding: 1.2em 0.8em;
  }

  #gd-root h3 {
    font-size: 20px;
  }

  #gd-root .gd-swatch,
  #gd-root .gd-shape,
  #gd-root .gd-decoration {
    width: 100px;
    height: 100px;
    font-size: 16px;
  }

  #gd-root .gd-step .gd-decor-list {
    max-height: 240px;
  }

  #gd-root .gd-decor-detail {
    font-size: 15px;
    gap: 5px;
  }

  #gd-root .gd-decor-detail button {
    font-size: 15px;
  }

  #gd-root .gd-decor-title {
    display: none;
  }

  #gd-root .gd-savebox {
    display: block;
  }

  #gd-root .gd-savebox input {
    margin-bottom: 5px;
  }

  #gd-root .gd-savebox button {
    width: 50%;
    font-size: 15px;
    padding: 0.7em 0;
  }
  #gd-root .gd-btn {
    font-size: 15px;
    padding: 0.7em 1em;
  }
}

@media (max-width: 400px) {
  #gd-root .gd-actions button {
    font-size: 14px;
    padding: 1.2em 0.8em;
  }
}