/* ==========================================================================
   SKANDOM — konfigurator domu
   Rozszerza style.css + pages.css. Ładowany tylko na konfigurator.html.
   ========================================================================== */

.konf { background: var(--bg-dark); color: var(--ink-on-dark); }

/* ---------- Układ: podgląd + panel ---------- */
.konf-shell {
  display: grid;
  grid-template-columns: 1fr 27rem;
  min-height: 100svh;
}

/* ---------- Podgląd ---------- */
.konf-preview {
  position: sticky;
  top: 0;
  height: 100svh;
  display: flex;
  flex-direction: column;
  background: oklch(0.18 0.01 220);
  overflow: hidden;
}
.konf-stage {
  position: relative;
  flex: 1;
  display: grid;
  place-items: center;
  overflow: hidden;
  isolation: isolate;
}
.konf-stage img,
.konf-stage video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  animation: konf-fade 520ms var(--ease-out) both;
}
@keyframes konf-fade {
  from { opacity: 0; transform: scale(1.015); }
  to { opacity: 1; transform: scale(1); }
}
/* Pauza filmu — WCAG 2.2.2 (ruch >5 s musi dać się zatrzymać) */
.konf-playtoggle {
  position: absolute;
  right: clamp(1rem, 2vw, 1.5rem);
  bottom: clamp(1rem, 2vw, 1.5rem);
  z-index: 2;
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  border: 1px solid oklch(1 0 0 / 0.3);
  background: oklch(0.15 0.01 220 / 0.6);
  backdrop-filter: blur(6px);
  color: var(--ink-on-dark);
  cursor: pointer;
  opacity: 0.75;
  transition: opacity 200ms ease, background 200ms ease;
}
.konf-playtoggle .ico { width: 0.9375rem; height: 0.9375rem; fill: currentColor; stroke: none; }
.konf-playtoggle:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; opacity: 1; }
@media (hover: hover) and (pointer: fine) {
  .konf-playtoggle:hover { opacity: 1; background: oklch(0.15 0.01 220 / 0.85); }
}

.konf-stage-caption {
  padding: 1rem clamp(1.25rem, 3vw, 2rem);
  font-size: 0.9219rem;
  font-weight: 540;
  color: var(--ink-on-dark);
  background: oklch(0.15 0.01 220);
  border-top: 1px solid var(--hairline-dark);
  min-height: 3.25rem;
  display: flex;
  align-items: center;
}

/* Stan oczekiwania — podgląd dla kombinacji bez gotowego materiału */
.konf-stage.is-pending { background: var(--bg-dark-2); }
.konf-pending {
  max-width: 32ch;
  padding: 2rem;
  text-align: center;
  display: grid;
  justify-items: center;
  gap: 0.625rem;
  animation: konf-fade 400ms var(--ease-out) both;
}
.konf-pending .ico {
  width: 2.25rem;
  height: 2.25rem;
  color: var(--brand);
  opacity: 0.8;
  margin-bottom: 0.5rem;
}
.konf-pending-title {
  font-stretch: 80%;
  font-weight: 720;
  letter-spacing: -0.015em;
  font-size: 1.25rem;
  color: var(--ink-on-dark);
}
.konf-pending-note { font-size: 0.875rem; line-height: 1.6; color: var(--muted-on-dark); }

/* ---------- Panel ---------- */
.konf-panel {
  display: flex;
  flex-direction: column;
  background: var(--bg-dark);
  border-left: 1px solid var(--hairline-dark);
  min-height: 100svh;
}
.konf-head {
  padding: clamp(6.5rem, 12vh, 8rem) clamp(1.5rem, 2.5vw, 2.25rem) 1.5rem;
  border-bottom: 1px solid var(--hairline-dark);
}
.konf-model {
  font-stretch: 80%;
  font-weight: 720;
  letter-spacing: -0.02em;
  font-size: 1.75rem;
  line-height: 1.1;
  color: var(--ink-on-dark);
}
.konf-model-sub { font-size: 0.875rem; font-style: italic; color: var(--brand-bright); margin-top: 0.25rem; }

.konf-progress { margin-top: 1.5rem; }
.konf-progress p { font-size: 0.875rem; font-weight: 540; color: var(--muted-on-dark); margin-bottom: 0.5rem; }
.konf-progress-track {
  height: 3px;
  border-radius: 999px;
  background: oklch(1 0 0 / 0.12);
  overflow: hidden;
}
.konf-progress-bar {
  height: 100%;
  background: var(--brand);
  transform-origin: left;
  transform: scaleX(0);
  transition: transform 420ms var(--ease-out);
}

.konf-stepper { display: flex; flex-wrap: wrap; gap: 0.375rem; margin-top: 1.25rem; }
.konf-stepper-item button {
  position: relative;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 520;
  color: var(--muted-on-dark);
  background: none;
  border: 1px solid var(--hairline-dark);
  border-radius: 999px;
  padding: 0.3125rem 0.6875rem;
  cursor: pointer;
  transition: color 180ms ease, border-color 180ms ease, background 180ms ease;
}
/* Niewidzialne rozszerzenie celu dotykowego do ~45px (WCAG 2.5.8) */
.konf-stepper-item button::after { content: ''; position: absolute; inset: -8px -2px; }
.konf-stepper-item.is-done button { color: var(--brand-bright); border-color: oklch(0.62 0.038 102 / 0.5); }
.konf-stepper-item.is-active button {
  color: var(--bg-dark);
  background: var(--brand);
  border-color: var(--brand);
}
@media (hover: hover) and (pointer: fine) {
  .konf-stepper-item button:hover { color: var(--ink-on-dark); border-color: var(--brand); }
  .konf-stepper-item.is-active button:hover { color: var(--bg-dark); }
}

/* ---------- Krok ---------- */
.konf-step { padding: clamp(1.5rem, 3vh, 2.25rem) clamp(1.5rem, 2.5vw, 2.25rem); flex: 1; }
/* Wejście treści kroku przy przejściu Dalej/Wstecz — czysty CSS (kompozytor) */
.konf-step.is-entering > * { animation: konf-step-in 300ms var(--ease-out) both; }
.konf-step.is-entering > *:nth-child(2) { animation-delay: 40ms; }
.konf-step.is-entering > *:nth-child(3) { animation-delay: 80ms; }
@keyframes konf-step-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}
.konf-step h2 {
  font-stretch: 80%;
  font-weight: 720;
  letter-spacing: -0.02em;
  font-size: 1.5rem;
  line-height: 1.15;
  color: var(--ink-on-dark);
}
.konf-step > p {
  margin-top: 0.625rem;
  font-size: 0.9219rem;
  line-height: 1.6;
  color: var(--muted-on-dark);
  text-wrap: pretty;
  /* Panel jest wąski (27rem, na mobile ~100vw): justowanie rozstrzeliwuje
     odstępy między słowami. Wyrównanie do lewej czyta się spokojniej. */
  text-align: left;
}

/* Etykieta poziomu wyboru („Układ desek", „Kolor elewacji") */
.konf-sublabel {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--brand-bright);
  margin: 1.5rem 0 0.625rem;
}
.konf-sublabel:first-child { margin-top: 1.5rem; }

/* Próbka koloru przy opcjach kolorystycznych — odcień widoczny przed
   kliknięciem. Wartości pobrane z renderów (patrz swatch w MODELS). */
.konf-swatch {
  flex: none;
  width: 1.625rem;
  height: 1.625rem;
  margin-top: 0.0625rem;
  border-radius: 50%;
  border: 1px solid oklch(1 0 0 / 0.28);
  box-shadow: inset 0 1px 2px oklch(0 0 0 / 0.35);
}
.konf-option.is-selected .konf-swatch { border-color: oklch(1 0 0 / 0.5); }

/* Drugi poziom: konkretna opcja (kolor) */
.konf-options-list { display: grid; gap: 0.625rem; }
.konf-options-list + .konf-sublabel { margin-top: 1.5rem; }

.konf-options { display: block; margin-top: 0.25rem; }
.konf-option {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 0.875rem;
  width: 100%;
  padding: 1rem 1.125rem;
  text-align: left;
  font-family: inherit;
  background: oklch(1 0 0 / 0.04);
  border: 1px solid oklch(1 0 0 / 0.32);
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 200ms var(--ease-out), background 200ms var(--ease-out);
}
.konf-option-mark {
  flex: none;
  display: grid;
  place-items: center;
  width: 1.25rem;
  height: 1.25rem;
  margin-top: 0.125rem;
  border: 1px solid oklch(1 0 0 / 0.35);
  border-radius: 50%;
  color: transparent;
  transition: background 200ms ease, border-color 200ms ease, color 200ms ease;
}
.konf-option-mark .ico { width: 0.75rem; height: 0.75rem; stroke-width: 3; }
.konf-option-text { display: grid; gap: 0.25rem; }
.konf-option-name { font-size: 1rem; font-weight: 620; color: var(--ink-on-dark); }
.konf-option-desc { font-size: 0.8125rem; line-height: 1.55; color: var(--muted-on-dark); text-align: left; }
.konf-option-flag {
  position: absolute;
  top: 0.625rem;
  right: 0.75rem;
  font-size: 0.6875rem;
  font-style: italic;
  color: var(--brand-bright);
}

/* Wyraźne oznaczenie wybranego wariantu (wymóg briefu) */
.konf-option.is-selected {
  border-color: var(--brand);
  background: oklch(0.62 0.038 102 / 0.12);
}
.konf-option.is-selected .konf-option-mark {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--bg-dark);
}
.konf-option:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
@media (hover: hover) and (pointer: fine) {
  .konf-option:hover { border-color: oklch(0.62 0.038 102 / 0.6); background: oklch(1 0 0 / 0.07); }
  /* hover na wybranej nie może zgasić zaznaczenia (ta sama specyficzność niżej w kaskadzie) */
  .konf-option.is-selected:hover { border-color: var(--brand); background: oklch(0.62 0.038 102 / 0.16); }
}

/* ---------- Nawigacja ---------- */
.konf-nav {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 0.75rem;
  padding: 1.125rem clamp(1.5rem, 2.5vw, 2.25rem);
  border-top: 1px solid var(--hairline-dark);
  background: oklch(0.2 0.012 220 / 0.96);
  backdrop-filter: blur(8px);
}
.konf-nav .btn { flex: 1; justify-content: center; }
.konf-nav .btn:disabled { opacity: 0.4; pointer-events: none; }

/* ---------- Podsumowanie ---------- */
.konf-summary { padding: clamp(1.5rem, 3vh, 2.25rem) clamp(1.5rem, 2.5vw, 2.25rem); }
.konf-summary h2 {
  font-stretch: 80%;
  font-weight: 720;
  letter-spacing: -0.02em;
  font-size: 1.5rem;
  color: var(--ink-on-dark);
}
.konf-summary > p { margin-top: 0.625rem; font-size: 0.9219rem; color: var(--muted-on-dark); line-height: 1.6; }

.konf-back {
  margin-top: 1rem;
  color: var(--brand-bright);
  background: none;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  padding: 0.5rem 0.25rem;
  margin-inline: -0.25rem;
}

.konf-summary-list { margin-top: 1.5rem; border-top: 1px solid var(--hairline-dark); }
.konf-summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9375rem 0;
  border-bottom: 1px solid var(--hairline-dark);
}
.konf-summary-step { font-size: 0.8125rem; color: var(--muted-on-dark); }
.konf-summary-value { font-size: 1rem; font-weight: 620; color: var(--ink-on-dark); margin-top: 0.125rem; }
.konf-summary-value.is-empty { color: var(--muted-on-dark); font-weight: 420; font-style: italic; }
.konf-summary-edit {
  font-size: 0.8125rem;
  color: var(--brand-bright);
  background: none;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  flex: none;
  /* cel dotykowy ~44px bez zmiany layoutu */
  padding: 0.75rem 0.25rem;
  margin: -0.75rem -0.25rem;
}
.konf-summary-edit .ico { width: 0.875rem; height: 0.875rem; }

.konf-price {
  margin-top: 1.5rem;
  padding: 1.125rem 1.25rem;
  border: 1px solid oklch(0.62 0.038 102 / 0.4);
  border-radius: 6px;
  background: oklch(0.62 0.038 102 / 0.1);
}
.konf-price p:first-child { font-size: 0.8125rem; color: var(--muted-on-dark); }
.konf-price p:nth-child(2) {
  font-stretch: 80%;
  font-weight: 720;
  font-size: 1.25rem;
  color: var(--brand-bright);
  margin-top: 0.25rem;
}
.konf-price-note {
  margin-top: 0.625rem;
  font-size: 0.8125rem;
  line-height: 1.55;
  color: var(--muted-on-dark);
}

.konf-actions { display: flex; flex-wrap: wrap; gap: 0.625rem; margin-top: 1.5rem; }
.konf-actions .btn { flex: 1; justify-content: center; white-space: nowrap; }

.konf-form { margin-top: 2.25rem; padding-top: 2.25rem; border-top: 1px solid var(--hairline-dark); }
.konf-form h3 { font-size: 1.125rem; font-weight: 660; color: var(--ink-on-dark); margin-bottom: 0.5rem; }
.konf-form > p { font-size: 0.875rem; color: var(--muted-on-dark); margin-bottom: 1.25rem; line-height: 1.6; }
.konf-form .form-grid { grid-template-columns: 1fr; }
.konf-form .field label { color: var(--ink-on-dark); }
.konf-form .field input,
.konf-form .field textarea {
  background: oklch(1 0 0 / 0.06);
  border-color: var(--hairline-dark);
  color: var(--ink-on-dark);
}
.konf-form .field .req { color: var(--brand-bright); }
.konf-form .consent label { color: var(--muted-on-dark); }
.konf-form .consent a { color: var(--brand-bright); }
/* Status wysyłki na ciemnym panelu (bazowe kolory z pages.css są pod jasne tło) */
.konf-form .form-status.is-ok {
  background: oklch(0.62 0.038 102 / 0.16);
  color: var(--brand-bright);
  border-color: var(--brand);
}
.konf-form .form-status.is-error {
  background: oklch(0.55 0.16 25 / 0.18);
  color: oklch(0.8 0.11 25);
  border-color: oklch(0.6 0.16 25 / 0.55);
}

/* ---------- Responsywność ---------- */
@media (max-width: 1100px) {
  .konf-shell { grid-template-columns: 1fr 24rem; }
}

@media (max-width: 900px) {
  .konf-shell { grid-template-columns: 1fr; min-height: 0; }
  .konf-preview {
    position: sticky;
    top: 0;
    height: auto;
    z-index: 5;
  }
  /* 16/9 + limit wysokości: panel opcji musi być widoczny pod podglądem */
  .konf-stage { aspect-ratio: 16 / 9; max-height: 40svh; flex: none; }
  .konf-pending { padding-top: clamp(3.5rem, 18vw, 5.5rem); }
  .konf-stage-caption { min-height: 0; padding: 0.75rem 1.25rem; font-size: 0.8125rem; }
  .konf-panel { border-left: 0; min-height: 0; }
  .konf-head { padding-top: 1.75rem; }
  .konf-nav { position: sticky; bottom: 0; }
}

@media (max-width: 540px) {
  .konf-actions .btn { flex: none; width: 100%; }
  /* Mniej pionowego miejsca na małym ekranie */
  .konf-option { padding: 0.8125rem 0.875rem; gap: 0.6875rem; }
  .konf-swatch { width: 1.5rem; height: 1.5rem; }
  .konf-sublabel { margin: 1.125rem 0 0.5rem; }

  /* flaga „materiał w przygotowaniu" nie nachodzi na nazwę opcji */
  .konf-option-flag { position: static; order: -1; margin-bottom: 0.25rem; display: block; }
  .konf-option-text { display: flex; flex-direction: column; }
}

/* ---------- Druk / zapis do PDF podsumowania ---------- */
@media print {
  .site-header, .mobile-menu, .site-footer,
  .konf-preview, .konf-nav, .konf-stepper, .konf-progress,
  .konf-actions, .konf-form, .konf-summary-edit { display: none !important; }
  .konf, .konf-panel { background: #fff; color: #000; border: 0; }
  .konf-shell { display: block; min-height: 0; }
  .konf-summary { padding: 0; }
  .konf-summary h2, .konf-summary-value, .konf-model { color: #000; }
  .konf-summary-step, .konf-summary > p { color: #444; }
  .konf-summary-row { border-color: #ccc; }
  .konf-price { border-color: #999; background: none; }
  .konf-price p:last-child { color: #000; }
  .konf-print-head { display: block !important; margin-bottom: 1.5rem; }
  .breadcrumbs { display: none !important; }
  .konf-summary-value.is-empty { color: #666; }
  .konf-model-sub { color: #444; font-style: normal; }
}
.konf-print-head { display: none; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .konf-stage img, .konf-stage video, .konf-pending { animation: none; }
  .konf-progress-bar { transition: none; }
  .konf-step.is-entering > * { animation: none; }
}
