/* Drawing colours. These are the defaults; Pima_Svg_Style prints the ones
   chosen in Aspetto › Personalizza › Configuratore right after this file. */
.pima-configurator {
  --pima-preview-line: #000000;
  --pima-preview-surface: #d7d2ce;
  --pima-preview-contrast: #d7d2ce;
  --pima-preview-shadow: rgba(0, 0, 0, 0.55);
  --pima-preview-shadow-blur: 13px;
  --pima-preview-shadow-y: 18px;
  --pima-mosaic-shadow: rgba(0, 0, 0, 0.55);
  --pima-mosaic-shadow-blur: 8px;
  --pima-mosaic-shadow-y: 4px;
  display: grid;
  gap: clamp(20px, 3vw, 32px);
}

/* The preview column is as wide as the composition it shows; the steps take
   the rest. The stage still stretches to the row height, so the sticky card
   inside it stops where the list of steps ends. */
.pima-configurator__top {
  --pima-preview-top: 96px;
  --pima-preview-height: clamp(260px, calc(100vh - var(--pima-preview-top) - 250px), 480px);
  display: grid;
  grid-template-columns: auto minmax(380px, 1fr);
  gap: clamp(20px, 3vw, 32px);
  align-items: stretch;
}

.pima-configurator__bottom {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.pima-configurator__stage {
  min-width: 0;
}

.pima-preview-card,
.pima-configurator__panel,
.pima-summary {
  border: 1px solid var(--pima-line, rgba(238, 232, 225, 0.12));
  border-radius: 6px;
  background: var(--pima-surface, #151317);
}

/* Sized by the drawing, not by the column: the card follows the page beside
   the steps (top aligned with the first one) and stops at the last one. */
.pima-preview-card {
  position: sticky;
  top: var(--pima-preview-top);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 340px;
}

.pima-preview-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.032) 1px, transparent 1px);
  background-size: 34px 34px;
  opacity: 0.46;
}

/* The bar and the note must not widen the card: only the drawing does. */
.pima-preview-card__bar,
.pima-preview-card > p {
  contain: inline-size;
}

.pima-preview-card__bar {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 48px;
  padding: 0 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--pima-muted, #a59da1);
  font-family: var(--pima-font-mono, monospace);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.pima-preview-card__bar strong {
  color: var(--pima-steel, #cfcac5);
  font-weight: 500;
  letter-spacing: 0.06em;
}

.pima-preview-card > p {
  position: relative;
  z-index: 1;
  margin: 0;
  padding: 14px 18px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  color: #a99fa3;
  font-size: 12px;
}

.pima-preview {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  padding: 24px 28px;
  background: radial-gradient(circle at 50% 45%, rgba(238, 232, 225, 0.06), transparent 55%), #111013;
}

/* Flex, not grid: an auto-sized grid row makes the SVG's percentage height
   indefinite, so the composition fell back to its intrinsic aspect ratio and
   grew past the card. A flex container with a definite height keeps
   height: 100% resolvable; the width then follows the drawing's own ratio
   (the SVG carries width/height attributes), so the card hugs it. */
.pima-preview__layers {
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--pima-preview-height);
  min-height: 0;
  transition: opacity 160ms ease;
}

.pima-preview__layers.is-loading {
  opacity: 0.58;
}

.pima-composite-svg {
  display: block;
  width: auto;
  max-width: min(520px, 100%);
  height: 100%;
  max-height: 100%;
  overflow: visible;
  filter: drop-shadow(0 var(--pima-preview-shadow-y) var(--pima-preview-shadow-blur) var(--pima-preview-shadow));
}

.pima-composite-svg__image,
.pima-piece {
  pointer-events: none;
}

/* Inlined drawings: configurator.js turns each paint into a class by role
   (light paint is surface, dark paint is line). */
.pima-piece .pima-fill-surface {
  fill: var(--piece-surface);
}

.pima-piece .pima-fill-line {
  fill: var(--piece-line);
}

.pima-piece .pima-stroke-surface {
  stroke: var(--piece-surface);
}

.pima-piece .pima-stroke-line {
  stroke: var(--piece-line);
}

/* Line-only drawings: no surface under them, so the lighter colour. */
.pima-piece .pima-fill-contrast {
  fill: var(--piece-contrast);
}

.pima-piece .pima-stroke-contrast {
  stroke: var(--piece-contrast);
}

.pima-composite-svg__placeholder rect {
  fill: rgba(22, 18, 23, 0.88);
  stroke: rgba(215, 92, 141, 0.58);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.pima-composite-svg__placeholder text {
  fill: #d7cdd1;
  font-size: 11px;
  font-weight: 800;
  text-anchor: middle;
  dominant-baseline: middle;
}

/* The choice panel: one family at a time. The tabs name every family with
   the variant chosen for it, so the whole hilt is still read at a glance. */
.pima-configurator__panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.pima-configurator__tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px 10px 20px;
  border-bottom: 1px solid var(--pima-line-soft, rgba(238, 232, 225, 0.08));
}

.pima-configurator__tools > span {
  white-space: nowrap;
  color: var(--pima-muted, #a59da1);
  font-family: var(--pima-font-mono, monospace);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.pima-configurator__tools > div {
  display: flex;
  gap: 4px;
}

.pima-configurator__tools button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  color: var(--pima-ink, #eee8e1);
  background: transparent;
  font: 600 13px/1 var(--pima-font-body, sans-serif);
  white-space: nowrap;
  cursor: pointer;
  transition: background 160ms ease;
}

.pima-configurator__tools button:hover {
  background: rgba(238, 232, 225, 0.07);
}

.pima-configurator__tools svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pima-configurator__tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-bottom: 1px solid var(--pima-line-soft, rgba(238, 232, 225, 0.08));
}

.pima-tab {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  min-height: 72px;
  padding: 0 16px;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--pima-ink, #eee8e1);
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease;
}

.pima-tab:hover {
  background: rgba(238, 232, 225, 0.04);
}

.pima-tab.is-active {
  border-bottom-color: var(--pima-rose, #f27fae);
  background: var(--pima-surface-2, #1c1a1f);
}

.pima-tab__num {
  color: var(--pima-faint, #8a8286);
  font-family: var(--pima-font-mono, monospace);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.pima-tab.is-active .pima-tab__num {
  color: var(--pima-rose, #f27fae);
}

.pima-tab__value {
  max-width: 100%;
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pima-configurator__step {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  padding: 20px 20px 0;
}

.pima-step__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.pima-step__head small {
  color: var(--pima-muted, #a59da1);
  font-size: 12px;
}

.pima-step__head span,
.pima-summary__head span {
  display: block;
  color: var(--pima-rose, #f27fae);
  font-family: var(--pima-font-mono, monospace);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.pima-step__head h3 {
  margin: 6px 0 0;
  font-size: 30px;
}

/* Every variant in view: eight ricassi no longer hide behind arrows. */
.pima-step__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  align-content: start;
}

.pima-step-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 20px -20px 0;
  padding: 14px 20px;
  border-top: 1px solid var(--pima-line-soft, rgba(238, 232, 225, 0.08));
}

.pima-step-nav button {
  min-height: 44px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  font: 600 13px/1 var(--pima-font-body, sans-serif);
  cursor: pointer;
}

.pima-step-nav__prev {
  color: var(--pima-ink, #eee8e1);
  background: transparent;
}

.pima-step-nav__prev:disabled {
  opacity: 0.3;
  cursor: default;
}

.pima-step-nav__next {
  color: var(--pima-bg, #0d0c0e);
  background: var(--pima-ink, #eee8e1);
  transition: background 160ms ease;
}

.pima-step-nav__next:hover {
  background: #ffffff;
}

.pima-part-option {
  min-width: 0;
  display: grid;
  /* One column no wider than the card: with `auto` a wide drawing (the
     knuckle-bow tangs) set the minimum width and pushed thumbnail and name
     out of the card. */
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
  align-content: start;
  padding: 12px;
  border: 1px solid var(--pima-line, rgba(238, 232, 225, 0.12));
  border-radius: 5px;
  color: var(--pima-muted, #a59da1);
  text-align: left;
  background: #111013;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
}

/* The mosaic: each option carries the technical drawing of its own piece, so
   the shapes are compared by eye instead of by name. The drawings are white
   faces with black engraving, which read as metal on the dark card. */
.pima-part-option__thumb {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  height: 96px;
  margin-bottom: 6px;
  padding: 8px;
  border-radius: 3px;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.07), transparent 68%),
    rgba(255, 255, 255, 0.022);
}

.pima-part-option__thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 var(--pima-mosaic-shadow-y) var(--pima-mosaic-shadow-blur) var(--pima-mosaic-shadow));
  transition: transform 200ms ease;
}

.pima-part-option:hover .pima-part-option__thumb img {
  transform: scale(1.04);
}

.pima-part-option.is-selected .pima-part-option__thumb {
  background:
    radial-gradient(circle at 50% 42%, rgba(242, 127, 174, 0.12), transparent 70%),
    rgba(255, 255, 255, 0.03);
}

.pima-part-option:hover {
  border-color: rgba(238, 232, 225, 0.4);
  color: var(--pima-ink, #eee8e1);
}

.pima-part-option.is-selected {
  color: var(--pima-ink, #eee8e1);
  border-color: var(--pima-rose, #f27fae);
  background: #221c22;
}

.pima-part-option:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.pima-part-option__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pima-part-option strong,
.pima-part-option span,
.pima-part-option b {
  display: block;
}

.pima-part-option strong {
  overflow: hidden;
  color: inherit;
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pima-part-option em {
  color: var(--pima-rose, #f27fae);
  font-style: normal;
}

.pima-part-option span:not(.pima-part-option__top) {
  margin-top: 7px;
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pima-part-option b {
  margin-top: 4px;
  color: var(--pima-steel, #cfcac5);
  font-family: var(--pima-font-mono, monospace);
  font-size: 11px;
  font-weight: 400;
}

.pima-summary {
  display: grid;
  gap: 16px;
  padding: 20px;
}

.pima-summary__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.pima-summary__head h2 {
  margin: 0;
  font-size: 32px;
}

.pima-summary dl {
  display: grid;
  gap: 12px;
  margin: 0;
}

.pima-summary dl div {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.pima-summary dt {
  color: var(--pima-muted, #a59da1);
  font-family: var(--pima-font-mono, monospace);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.pima-summary dd {
  margin: 0;
}

.pima-summary dd strong,
.pima-summary dd small {
  display: block;
}

.pima-summary dd small {
  margin-top: 3px;
  color: var(--pima-muted, #a59da1);
  font-size: 12px;
}

.pima-summary dl b {
  color: var(--pima-steel, #cfcac5);
  font-family: var(--pima-font-mono, monospace);
  font-size: 12px;
  font-weight: 400;
  white-space: nowrap;
}

.pima-summary__total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 4px;
}

.pima-summary__total span {
  color: var(--pima-muted, #a59da1);
  font-family: var(--pima-font-mono, monospace);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.pima-summary__total strong {
  color: var(--pima-ink, #eee8e1);
  font-family: var(--pima-font-display, serif);
  font-size: 40px;
  font-weight: 500;
  line-height: 1;
}

.pima-summary p {
  margin: 0;
  color: var(--pima-muted, #a59da1);
  font-size: 13px;
}

.pima-part-option__note {
  color: #e3b778;
  font-size: 11px;
  line-height: 1.4;
  white-space: normal !important;
}

/* Cart bar: code, total and the one action stay in view while the steps
   scroll, and follow the configurator down to its summary. */
.pima-configurator__bar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px 24px;
  padding: 14px 20px;
  border: 1px solid var(--pima-line, rgba(238, 232, 225, 0.12));
  border-bottom: 0;
  border-radius: 6px 6px 0 0;
  background: rgba(9, 8, 10, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.pima-configurator__bar-info {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 16px;
  min-width: 0;
}

.pima-configurator__bar-label,
.pima-configurator__bar-total span {
  color: var(--pima-faint, #8a8286);
  font-family: var(--pima-font-mono, monospace);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.pima-configurator__bar-info strong {
  white-space: nowrap;
  color: var(--pima-steel, #cfcac5);
  font-family: var(--pima-font-mono, monospace);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.06em;
}

.pima-configurator__bar-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--pima-muted, #a59da1);
  font-size: 13px;
}

.pima-configurator__bar-state::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #7fc79a;
}

.pima-configurator__bar-state.is-warning::before {
  background: #e3b778;
}

.pima-configurator__bar-action {
  display: flex;
  align-items: center;
  gap: 24px;
}

.pima-configurator__bar-total {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.pima-configurator__bar-total strong {
  color: var(--pima-ink, #eee8e1);
  font-family: var(--pima-font-display, serif);
  font-size: 30px;
  font-weight: 500;
  line-height: 1;
}

.pima-configurator__bar button {
  min-height: 54px;
  padding: 0 30px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: var(--pima-accent, #b8285f);
  font: 600 15px/1 var(--pima-font-body, sans-serif);
  cursor: pointer;
  transition: background 160ms ease, opacity 160ms ease;
}

.pima-configurator__bar button:hover:not(:disabled) {
  background: var(--pima-accent-hover, #cc316d);
}

.pima-configurator__bar button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pima-configurator__bar button[aria-busy="true"] {
  cursor: wait;
}

.pima-configurator__bar .pima-cart-status {
  grid-column: 1 / -1;
  min-height: 0;
  margin: 0;
  font-size: 13px;
}

.pima-configurator__bar .pima-cart-status:empty {
  display: none;
}

.pima-cart-status {
  min-height: 22px;
  color: #ffc4db;
}

.pima-cart-status.is-success {
  color: #b8e8c7;
}

.pima-cart-status.is-error {
  color: #ff9aa9;
}

.pima-cart-status a {
  color: #fff;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

@media (max-width: 980px) {
  .pima-configurator__top,
  .pima-configurator__bottom {
    grid-template-columns: 1fr;
  }

  /* The preview stays pinned above the choices, compact, so every change is
     seen as it is made. The stage is the sticky element: its parent spans the
     whole panel, so it keeps sticking while the variants scroll under it. */
  .pima-configurator__top {
    --pima-preview-height: min(26vh, 220px);
    gap: 12px;
  }

  .pima-configurator__stage {
    position: sticky;
    top: var(--pima-header-h-compact, var(--pima-header-h, 64px));
    z-index: 4;
    padding-top: 8px;
    background: var(--pima-bg, #0d0c0e);
  }

  .pima-preview-card {
    position: relative;
    top: auto;
    min-width: 0;
  }

  /* The code is already in the cart bar below. */
  .pima-preview-card__bar {
    display: none;
  }

  .pima-preview {
    padding: 12px;
  }

  .pima-preview-card > p {
    display: none;
  }
}

@media (max-width: 620px) {
  .pima-configurator__tools {
    padding-left: 14px;
  }

  .pima-configurator__tools button {
    padding: 0 10px;
  }

  .pima-tab {
    align-items: center;
    min-height: 56px;
    padding: 0 4px;
    text-align: center;
  }

  /* Four tabs on a phone: the family name only. */
  .pima-tab__value {
    display: none;
  }

  .pima-tab__num {
    font-size: 9px;
    letter-spacing: 0.08em;
  }

  .pima-configurator__step {
    padding: 16px 14px 0;
  }

  .pima-step__head h3 {
    font-size: 24px;
  }

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

  .pima-part-option__thumb {
    height: 80px;
  }

  .pima-step-nav {
    margin-inline: -14px;
    padding-inline: 14px;
  }

  .pima-summary dl div {
    grid-template-columns: 1fr;
  }

  .pima-summary dl b {
    justify-self: start;
  }

  .pima-configurator__tools {
    gap: 4px;
  }

  .pima-configurator__tools > span {
    font-size: 10px;
    letter-spacing: 0.08em;
  }

  .pima-configurator__bar {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px 14px 12px;
  }

  .pima-configurator__bar-label,
  .pima-configurator__bar-state {
    display: none;
  }

  .pima-configurator__bar-info strong {
    font-size: 11px;
  }

  .pima-configurator__bar-action {
    justify-content: space-between;
    gap: 12px;
  }

  .pima-configurator__bar-total {
    align-items: flex-start;
  }

  .pima-configurator__bar-total strong {
    font-size: 24px;
  }

  .pima-configurator__bar button {
    min-height: 48px;
    padding: 0 18px;
    font-size: 14px;
  }
}

/* `.pima-part-option span` would make the name row a block: the check mark
   then dropped under the name. */
.pima-part-option .pima-part-option__top {
  display: flex;
}

/* Names on two lines, not an ellipsis: the tangs with a knuckle bow differ
   only at the end ("Ricasso Anelli Ramo / Rami Paranocche"). */
.pima-part-option__top strong {
  min-width: 0;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  white-space: normal;
}

/* Sizes are the useful line in the tabbed grid: two lines, not an ellipsis. */
.pima-part-option span.pima-part-option__dims {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-family: var(--pima-font-mono, monospace);
  font-size: 11px;
  line-height: 1.45;
  white-space: normal;
}

/* Inside Elementor content, `.elementor img { height: auto }` would let the
   drawings overflow their thumbnail box. */
.elementor .pima-part-option__thumb img {
  height: 100%;
}
