/* =========================================================
   Hofoworks — shared configurator UI
   Used by every configurator (pergola, jewelry, interior).
   Relies on the tokens defined in main.css.
   ========================================================= */
.cfgx {
  display: grid; grid-template-columns: minmax(0, 1fr) 360px;
  height: 100%; min-height: 560px;
  background: var(--bg-2);
  color: var(--ink);
  /* card: thin border + soft lift, so the configurator reads as one object on the page */
  border: 1px solid var(--line); border-radius: 16px; overflow: hidden;
  box-shadow: 0 1px 2px rgba(17, 17, 17, .04), 0 4px 12px -4px rgba(17, 17, 17, .06), 0 24px 56px -24px rgba(17, 17, 17, .22);
}

/* ---------- 3D stage ---------- */
.cfgx-stage { position: relative; min-width: 0; min-height: 0; background: #F1F0ED; }
.cfgx-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; cursor: grab; opacity: 0; transition: opacity .6s var(--ease); }
.cfgx-canvas:active { cursor: grabbing; }
.cfgx-stage.is-ready .cfgx-canvas { opacity: 1; }

.cfgx-loading {
  position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px;
  color: var(--ink-3); transition: opacity .4s; pointer-events: none;
}
.cfgx-loading span { width: 28px; height: 28px; border-radius: 50%; border: 1.5px solid var(--line-2); border-top-color: var(--accent); animation: cfgx-spin 0.9s linear infinite; }
.cfgx-stage.is-ready .cfgx-loading { opacity: 0; }
@keyframes cfgx-spin { to { transform: rotate(360deg); } }

.cfgx-hud { position: absolute; left: 16px; top: 16px; color: var(--ink-2); background: rgba(255,255,255,.82); backdrop-filter: blur(8px); padding: 7px 11px; border-radius: 999px; pointer-events: none; }
.cfgx-tools { position: absolute; right: 16px; top: 16px; display: flex; gap: 8px; }
.cfgx-tool { height: 34px; padding: 0 14px; border-radius: 999px; background: rgba(255,255,255,.9); backdrop-filter: blur(8px); font-size: 13px; font-weight: 500; transition: color .2s; }
.cfgx-tool:hover { color: var(--accent); }
.cfgx-hint { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); color: var(--ink-3); background: rgba(255,255,255,.75); padding: 6px 10px; border-radius: 999px; pointer-events: none; transition: opacity .5s; white-space: nowrap; }
.cfgx-stage.is-interacting .cfgx-hint { opacity: 0; }

/* Segmented control */
.cfgx-seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 999px; background: rgba(255,255,255,.9); backdrop-filter: blur(8px); }
.cfgx-seg button { height: 28px; padding: 0 12px; border-radius: 999px; font-size: 13px; color: var(--ink-2); transition: background-color .2s, color .2s; }
.cfgx-seg button:hover { color: var(--ink); }
.cfgx-seg button.is-on { background: var(--ink); color: #fff; }
.cfgx-panel .cfgx-seg { background: var(--bg-2); }
.cfgx-seg-fill { display: flex; width: 100%; }
.cfgx-seg-fill button { flex: 1; }

/* ---------- Options panel ---------- */
.cfgx-panel { background: #fff; border-left: 1px solid var(--line); overflow-y: auto; overscroll-behavior: contain; padding: 22px 22px 26px; }
.cfgx-head { padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.cfgx-head h2 { font-size: 24px; font-weight: 500; letter-spacing: -.035em; line-height: 1.1; margin: 8px 0 6px; font-stretch: 125%; font-variation-settings: "wdth" 125; }
.cfgx-sub { color: var(--ink-2); font-size: 14px; }
.cfgx-muted { color: var(--ink-3); }

.cfgx-sec { padding: 18px 0; border-bottom: 1px solid var(--line); display: grid; gap: 12px; }
.cfgx-sec h3 { display: flex; align-items: baseline; gap: 10px; font-size: 14px; font-weight: 600; }
.cfgx-sec h3 b { font-weight: 400; color: var(--accent); }
.cfgx-sec h3 em { margin-left: auto; font-style: normal; font-weight: 400; font-size: 12.5px; color: var(--ink-2); }

.cfgx-range { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; font-size: 13.5px; color: var(--ink-2); }
.cfgx-range output { font-family: var(--mono); font-size: 12px; color: var(--ink); }
.cfgx-range input { grid-column: 1 / -1; }
.cfgx input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: transparent; cursor: pointer; }
.cfgx input[type="range"]::-webkit-slider-runnable-track { height: 2px; background: var(--line-2); border-radius: 2px; }
.cfgx input[type="range"]::-moz-range-track { height: 2px; background: var(--line-2); border-radius: 2px; }
.cfgx input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -8px; border-radius: 50%; background: #fff; border: 1.5px solid var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); transition: border-color .2s, transform .2s; }
.cfgx input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 1.5px solid var(--ink); }
.cfgx input[type="range"]:hover::-webkit-slider-thumb { border-color: var(--accent); transform: scale(1.08); }
.cfgx input[type="range"]:focus-visible { outline: none; }
.cfgx input[type="range"]:focus-visible::-webkit-slider-thumb { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(47,69,255,.18); }

.cfgx-swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.cfgx-swatches button {
  width: 36px; height: 36px; border-radius: 50%; background: var(--sw);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); position: relative; transition: transform .2s;
}
.cfgx-swatches button.is-wood { background: repeating-linear-gradient(100deg, #a77f58 0 3px, #b9936b 3px 7px, #9d7550 7px 9px); }
.cfgx-swatches button::after { content: ""; position: absolute; inset: -5px; border-radius: 50%; border: 1.5px solid transparent; transition: border-color .2s; }
.cfgx-swatches button:hover { transform: scale(1.06); }
.cfgx-swatches button.is-on::after { border-color: var(--ink); }

.cfgx-chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.cfgx-chips button { height: 34px; border-radius: 999px; border: 1px solid var(--line-2); font-size: 13px; color: var(--ink-2); transition: all .2s; }
.cfgx-chips button:hover:not(:disabled) { color: var(--ink); border-color: var(--ink); }
.cfgx-chips button.is-on { background: var(--ink); border-color: var(--ink); color: #fff; }
.cfgx-chips button:disabled { opacity: .35; cursor: not-allowed; }

.cfgx-switch { position: relative; display: flex; align-items: center; gap: 12px; font-size: 14px; cursor: pointer; }
.cfgx-switch input { position: absolute; left: 0; top: 0; width: 1px; height: 1px; margin: 0; opacity: 0; pointer-events: none; }
.cfgx-switch span { width: 40px; height: 24px; border-radius: 999px; background: var(--line-2); position: relative; transition: background-color .2s; flex: none; }
.cfgx-switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .25s var(--ease); }
.cfgx-switch input:checked + span { background: var(--accent); }
.cfgx-switch input:checked + span::after { transform: translateX(16px); }
.cfgx-switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.cfgx-summary { border-bottom: 0; }
.cfgx-summary dl { display: grid; gap: 0; }
.cfgx-summary dl div { display: grid; grid-template-columns: 90px 1fr; gap: 10px; padding: 6px 0; font-size: 13.5px; }
.cfgx-summary dt { color: var(--ink-3); padding-top: 2px; }
.cfgx-cta {
  display: flex; justify-content: center; align-items: center; gap: 10px; height: 48px; margin-top: 6px;
  border-radius: 999px; background: var(--ink); color: #fff; font-size: 14px; font-weight: 500; transition: background-color .25s;
}
.cfgx-cta:hover { background: var(--accent); }
.cfgx-note { color: var(--ink-3); text-align: center; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .cfgx { grid-template-columns: 1fr; grid-template-rows: minmax(340px, 58svh) auto; height: auto; min-height: 0; border-radius: 0; }
  .cfgx-panel { border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
  .cfgx-hud { top: auto; bottom: 12px; left: 12px; font-size: 9.5px; }
  .cfgx-tools { top: 12px; right: 12px; }
  .cfgx-hint { display: none; }
}
