/* AVISTA 3D — wspólne style konfiguratora, rysunku, podglądu 3D i wyceny.
   Każda wersja ustawia własne zmienne kolorów (--fg, --muted, --line, ...). Mobile-first. */

@property --w { syntax: '<length>'; inherits: true; initial-value: 200px; }
@property --h { syntax: '<length>'; inherits: true; initial-value: 140px; }
@property --z { syntax: '<length>'; inherits: true; initial-value: 16px; }
@property --c { syntax: '<color>'; inherits: true; initial-value: #26262a; }
@property --rz { syntax: '<angle>'; inherits: true; initial-value: -34deg; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; overflow-x: hidden; -webkit-font-smoothing: antialiased; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }

:root {
  --ease: cubic-bezier(.2, .8, .2, 1);
  --fg: #1d1d1f; --muted: #6e6e73; --line: rgba(0,0,0,.12);
  --chip: rgba(0,0,0,.05); --chip-on: #1d1d1f; --chip-on-fg: #fff;
  --accent: #0071e3; --accent-fg: #fff; --card: #fff;
  --draw: #1d1d1f; --dim: #0071e3; --radius: 18px;
}

/* ---------- reveal ---------- */
.reveal { opacity: 0; transform: translateY(28px); transition: opacity 1s var(--ease), transform 1s var(--ease); transition-delay: var(--d, 0s); }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  .drw .dl { animation: none !important; stroke-dashoffset: 0 !important; }
  .r3d { animation: none !important; }
}

/* ---------- przyciski ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4em; min-height: 46px; padding: 0 22px; border-radius: 999px; border: 0; background: var(--accent); color: var(--accent-fg); font-weight: 600; text-decoration: none; cursor: pointer; transition: transform .25s var(--ease), filter .25s; }
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(.97); }

/* ---------- konfigurator ---------- */
.cfg { display: grid; gap: 20px; color: var(--fg); }
.cfg-visual { display: grid; gap: 14px; min-width: 0; }
.cfg-tabs { display: inline-flex; gap: 4px; padding: 4px; border-radius: 999px; background: var(--chip); justify-self: center; max-width: 100%; }
.cfg-tabs button { border: 0; background: transparent; color: var(--muted); border-radius: 999px; padding: 9px 16px; font-size: 14px; font-weight: 600; cursor: pointer; transition: background .3s var(--ease), color .3s; }
.cfg-tabs button.on { background: var(--chip-on); color: var(--chip-on-fg); }
.cfg-tabs button:disabled { opacity: .35; cursor: default; }
.cfg-stage { position: relative; border-radius: var(--radius); overflow: hidden; background: var(--card); min-height: 300px; }
.cfg-pane { display: none; min-width: 0; }
.cfg-pane.on { display: block; animation: fade .5s var(--ease); }
.cfg-photo { background: #f4f4f2; }
.cfg-photo img { width: 100%; aspect-ratio: 1 / 1; object-fit: contain; transition: opacity .35s ease, transform .6s var(--ease); }
.cfg-photo img.fade { opacity: 0; transform: scale(.98); }
.cfg-drawing { padding: 14px; color: var(--draw); }
.sw-sm { width: 30px; height: 30px; }
.r3d .latch { position: absolute; bottom: 18%; width: 9%; height: 46%; max-width: 26px; border-radius: 2px; background: var(--lc); display: none; box-shadow: inset 0 -2px 0 rgba(0,0,0,.25); }
.r3d .latch:first-child { left: 22%; }
.r3d .latch:last-child { right: 22%; }
.r3d.has-latch .latch { display: block; }
.cfg-panel { min-width: 0; }
.cfg-picker { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -2px 14px; padding: 2px; }
.cfg-picker::-webkit-scrollbar { display: none; }
.cfg-picker button { flex: none; border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 9px 14px; font-size: 14px; cursor: pointer; white-space: nowrap; transition: all .3s var(--ease); }
.cfg-picker button.on { background: var(--chip-on); color: var(--chip-on-fg); border-color: transparent; }
.cfg-name { font-size: clamp(24px, 6vw, 32px); line-height: 1.1; letter-spacing: -.02em; margin: 0 0 6px; }
.cfg-desc { color: var(--muted); margin: 0 0 18px; line-height: 1.45; }
.cfg-group { margin-bottom: 18px; }
.cfg-label { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: .06em; }
.cfg-label span { color: var(--fg); text-transform: none; letter-spacing: 0; font-weight: 600; margin-left: 4px; }
.cfg-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.cfg-chips button { min-height: 44px; padding: 8px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--chip); cursor: pointer; font-size: 15px; font-weight: 500; display: inline-flex; flex-direction: column; align-items: flex-start; justify-content: center; line-height: 1.15; transition: border-color .25s, background .25s, transform .2s var(--ease); }
.cfg-chips button small { font-size: 12px; color: var(--muted); font-weight: 500; }
.cfg-chips button:active { transform: scale(.96); }
.cfg-chips button.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.cfg-swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.sw { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--sw); cursor: pointer; box-shadow: inset 0 0 0 1px rgba(0,0,0,.15), 0 0 0 0 var(--accent); transition: box-shadow .3s var(--ease), transform .2s; }
.sw.on { box-shadow: inset 0 0 0 1px rgba(0,0,0,.15), 0 0 0 3px var(--card), 0 0 0 5px var(--accent); }
.sw:active { transform: scale(.92); }
.cfg-specs, .q-res { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 0 18px; }
.q-res { grid-template-columns: repeat(2, 1fr); }
.cfg-specs div, .q-res div { background: var(--chip); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.cfg-specs dt, .q-res dt { font-size: 12px; color: var(--muted); }
.cfg-specs dd, .q-res dd { margin: 2px 0 0; font-weight: 600; font-size: 14px; }
.cfg-buy { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.cfg-price, .q-total strong { font-size: 30px; font-weight: 700; letter-spacing: -.02em; display: inline-block; }
.bump { animation: bump .5s var(--ease); }
@keyframes bump { 0% { transform: translateY(6px); opacity: .2; } 100% { transform: none; opacity: 1; } }
.cfg-note { color: var(--muted); font-size: 13px; margin: 14px 0 0; }
@media (min-width: 900px) {
  .cfg { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 36px; align-items: start; }
  .cfg-panel { position: sticky; top: 90px; }
}

/* ---------- rysunek techniczny ---------- */
.drw { width: 100%; height: auto; max-height: 520px; display: block; }
.drw .dl { fill: none; stroke: currentColor; stroke-width: 1.3; vector-effect: non-scaling-stroke; stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw .9s var(--ease) forwards; animation-delay: calc(var(--i, 0) * 22ms); }
.drw .pk { stroke-width: 1; }
.drw .ex, .drw .dm { stroke: var(--dim); stroke-width: .9; }
.drw .ax { stroke: var(--dim); stroke-width: .7; opacity: .7; }
.drw .hl { fill: none; stroke: currentColor; stroke-width: .8; vector-effect: non-scaling-stroke; stroke-dasharray: 4 3; opacity: 0; animation: fade .6s .5s forwards; }
.drw .da { fill: var(--dim); opacity: 0; animation: fade .5s .45s forwards; }
.drw .dt { fill: currentColor; font-family: ui-monospace, "JetBrains Mono", SFMono-Regular, Menlo, monospace; opacity: 0; animation: fade .6s .5s forwards; }
.drw .dim { fill: var(--dim); font-weight: 600; }
.drw .lbl { opacity: 0; font-size: .8em; letter-spacing: .08em; fill: var(--muted); }
.drw .tb { font-weight: 700; }
.drw .tbs { fill: var(--muted); }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes fade { to { opacity: 1; } }
.drw .lbl { animation: fade .6s .3s forwards; }

/* ---------- podgląd 3D ---------- */
.r3d { height: 300px; display: grid; place-items: center; perspective: 1500px; cursor: grab; touch-action: pan-y; user-select: none; transition: --w .9s var(--ease), --h .9s var(--ease), --z .9s var(--ease), --c .7s ease; animation: sway 7s ease-in-out infinite alternate; }
.r3d.drag { animation: none; cursor: grabbing; }
@keyframes sway { from { --rz: -42deg; } to { --rz: -24deg; } }
.r3d-box { position: relative; width: var(--w); height: var(--h); transform-style: preserve-3d; transform: translateY(-6%) rotateX(56deg) rotateZ(var(--rz)); }
.r3d .f { position: absolute; }
.r3d .f-top { left: 0; top: 0; width: var(--w); height: var(--h); transform: translateZ(var(--z)); border-radius: 3px; background: linear-gradient(135deg, color-mix(in srgb, var(--c) 82%, white), var(--c) 55%, color-mix(in srgb, var(--c) 88%, black)); }
.r3d .f-top svg { width: 100%; height: 100%; display: block; }
.r3d .f-front { left: 0; top: var(--h); width: var(--w); height: var(--z); transform-origin: top; transform: rotateX(90deg); background: color-mix(in srgb, var(--c) 74%, black); }
.r3d .f-back { left: 0; top: 0; width: var(--w); height: var(--z); transform-origin: top; transform: rotateX(90deg); background: color-mix(in srgb, var(--c) 68%, black); }
.r3d .f-right { left: var(--w); top: 0; width: var(--z); height: var(--h); transform-origin: left; transform: rotateY(-90deg); background: color-mix(in srgb, var(--c) 60%, black); }
.r3d .f-left { left: 0; top: 0; width: var(--z); height: var(--h); transform-origin: left; transform: rotateY(-90deg); background: color-mix(in srgb, var(--c) 64%, black); }
.r3d-shadow { position: absolute; left: 4%; top: 6%; width: 96%; height: 98%; background: rgba(0,0,0,.32); filter: blur(16px); transform: translateZ(-1px); border-radius: 8px; }
@media (min-width: 600px) { .r3d { height: 360px; } }

/* ---------- wycena ---------- */
.q { display: grid; gap: 22px; color: var(--fg); }
.q-left, .q-right { min-width: 0; }
.q-drop { position: relative; display: grid; place-items: center; min-height: 260px; border-radius: var(--radius); border: 2px dashed var(--line); background: var(--card); cursor: pointer; overflow: hidden; transition: border-color .3s, background .3s, transform .3s var(--ease); }
.q-drop.over { border-color: var(--accent); transform: scale(.99); }
.q-canvas { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; transition: opacity .6s; touch-action: pan-y; }
.has-model .q-canvas { opacity: 1; }
.has-model .q-drop-msg { opacity: 0; pointer-events: none; }
.has-model .q-drop { border-style: solid; }
.q-drop-msg { display: grid; justify-items: center; gap: 6px; text-align: center; padding: 24px; transition: opacity .4s; }
.q-drop-msg span { color: var(--muted); font-size: 14px; max-width: 280px; }
.q-drop-icon { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: var(--chip); color: var(--accent); margin-bottom: 6px; }
.q-file { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin-top: 10px; font-size: 14px; color: var(--muted); }
.q-sample { background: none; border: 0; color: var(--accent); font-weight: 600; cursor: pointer; padding: 8px 0; }
.q-hint { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.q-inf { width: 100%; accent-color: var(--accent); height: 32px; }
.q-row { display: grid; gap: 0 16px; }
.q-qty { display: inline-flex; align-items: center; border: 1.5px solid var(--line); border-radius: 12px; overflow: hidden; }
.q-qty button { width: 44px; height: 44px; border: 0; background: var(--chip); font-size: 20px; cursor: pointer; }
.q-qty input { width: 56px; height: 44px; border: 0; text-align: center; background: transparent; -moz-appearance: textfield; }
.q-qty input::-webkit-inner-spin-button { -webkit-appearance: none; }
.q-total { display: flex; align-items: baseline; justify-content: space-between; padding: 16px 0; border-top: 1px solid var(--line); margin-bottom: 8px; }
.q-total span { color: var(--muted); }
.q-form { display: grid; gap: 10px; }
.q-form input, .q-form textarea, .contact-form input, .contact-form textarea { width: 100%; min-height: 48px; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--card); font-size: 16px; outline: none; transition: border-color .25s; }
.q-form input:focus, .q-form textarea:focus, .contact-form input:focus, .contact-form textarea:focus { border-color: var(--accent); }
.q-form .btn { width: 100%; }
@media (min-width: 560px) { .q-row { grid-template-columns: auto 1fr; } }
@media (min-width: 900px) {
  .q { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 36px; align-items: start; }
  .q-left { position: sticky; top: 90px; }
  .q-drop { min-height: 440px; }
}
