/* ============================================================
   HILO — Widget Calculateur V3
   Single-flow form — Mobile-first
   ============================================================ */

/* ── Widget Section ── */
.widget-section {
  position: relative;
  padding: var(--section-pad-y) 0;
}

.widget-section .container {
  max-width: var(--container-narrow);
}

/* ── Widget Card ── */
.widget {
  position: relative;
  background: var(--vellum-bg);
  backdrop-filter: blur(12px) saturate(160%);
  -webkit-backdrop-filter: blur(12px) saturate(160%);
  border: 1px solid var(--vellum-border);
  padding: clamp(1.5rem, 5vw, 2.5rem);
  overflow: hidden;
}

.widget::after {
  content: "";
  position: absolute;
  top: 4px; left: 4px;
  width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.02);
  z-index: -1;
  pointer-events: none;
}

/* ── Progress Bar ── */
.widget__progress {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: clamp(1.5rem, 4vw, 2rem);
}

.widget__progress-step {
  flex: 1;
  height: 3px;
  background: rgba(0, 0, 0, 0.06);
  position: relative;
  overflow: hidden;
  transition: background 0.3s var(--ease);
}

.widget__progress-fill {
  position: absolute;
  inset: 0;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.5s var(--ease);
}

.widget__progress-step--active .widget__progress-fill,
.widget__progress-step--done .widget__progress-fill {
  transform: scaleX(1);
}

.widget__progress-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--text-tertiary);
  flex-shrink: 0;
  min-width: 3ch;
  text-align: right;
}

/* ── Steps Container ── */
.widget__steps {
  position: relative;
  overflow: hidden;
}

.widget__step {
  display: none;
  opacity: 0;
  transform: translateX(30px);
  transition: opacity 0.4s var(--ease), transform 0.4s var(--ease);
}

.widget__step--active {
  display: block;
}

.widget__step--visible {
  opacity: 1;
  transform: translateX(0);
}

/* ── Step Header ── */
.widget__step-title {
  font-size: clamp(1.25rem, 3.5vw, 1.5rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.widget__step-desc {
  font-size: var(--small);
  font-weight: 300;
  color: var(--text-secondary);
  margin-bottom: clamp(1.25rem, 4vw, 1.75rem);
  line-height: 1.5;
}

/* ── Radio Cards ── */
.widget__cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.widget__card {
  position: relative;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: clamp(1rem, 3vw, 1.25rem) 0.75rem;
  background: rgba(0, 0, 0, 0.02);
  border: 1px solid rgba(0, 0, 0, 0.06);
  transition: all 0.3s var(--ease);
  text-align: center;
  outline: none;
}

.widget__card:hover {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.12);
}

.widget__card:focus-visible {
  box-shadow: 0 0 0 2px var(--accent);
}

.widget__card input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.widget__card--selected {
  background: rgba(0, 0, 0, 0.06);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.widget__card-icon {
  width: 32px;
  height: 32px;
  color: var(--text-secondary);
  transition: color 0.3s;
}

.widget__card--selected .widget__card-icon {
  color: var(--text-primary);
}

.widget__card-label {
  font-size: clamp(0.75rem, 2vw, 0.8125rem);
  font-weight: 400;
  color: var(--text-secondary);
  line-height: 1.3;
  transition: color 0.3s;
}

.widget__card--selected .widget__card-label {
  color: var(--text-primary);
  font-weight: 500;
}

/* ── Skip Link ── */
.widget__skip-link {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 300;
  color: var(--text-tertiary);
  text-decoration: none;
  border-bottom: 1px dotted var(--text-tertiary);
  transition: color 0.2s, border-color 0.2s;
  margin-bottom: 1rem;
}

.widget__skip-link:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ── Form Fields ── */
.widget__fields {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.widget__row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.widget__field {
  position: relative;
}

.widget__label {
  display: block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.widget__label-opt {
  color: var(--text-tertiary);
  font-weight: 400;
}

.widget__label-req {
  color: #c94444;
}

.widget__input {
  width: 100%;
  padding: 0.875rem 1rem;
  background: rgba(0, 0, 0, 0.02);
  border: 1px solid rgba(0, 0, 0, 0.08);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  font-weight: 300;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.widget__input::placeholder {
  color: var(--text-tertiary);
}

.widget__input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.04);
}

.widget__input--valid {
  border-color: var(--text-secondary);
}

.widget__input--error {
  border-color: #c94444;
  box-shadow: 0 0 0 3px rgba(201, 68, 68, 0.06);
}

.widget__error-msg {
  font-size: 0.75rem;
  color: #c94444;
  margin-top: 0.35rem;
  display: none;
}

.widget__input--error ~ .widget__error-msg {
  display: block;
}

select.widget__input {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%23666' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
  cursor: pointer;
}

/* ── Divider ── */
.widget__divider {
  border: none;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  margin: 0.5rem 0;
}

/* ── Autocomplete ── */
.widget__autocomplete {
  position: relative;
}

.widget__autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 50;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  max-height: 200px;
  overflow-y: auto;
  display: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.widget__autocomplete-list--open {
  display: block;
}

.widget__autocomplete-item {
  padding: 0.625rem 1rem;
  font-size: 0.9rem;
  font-weight: 300;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.15s;
}

.widget__autocomplete-item:hover,
.widget__autocomplete-item--active {
  background: rgba(0, 0, 0, 0.04);
}

.widget__autocomplete-canton {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

/* ── Checkbox ── */
.widget__checkbox {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  cursor: pointer;
  margin-top: 0.5rem;
}

.widget__checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.widget__checkbox-text {
  font-size: var(--small);
  font-weight: 300;
  color: var(--text-secondary);
  line-height: 1.4;
}

.widget__checkbox-text abbr {
  text-decoration: none;
  border-bottom: 1px dotted var(--text-tertiary);
  cursor: help;
}

/* ── Navigation Buttons ── */
.widget__nav {
  display: flex;
  gap: 0.75rem;
  margin-top: clamp(1.5rem, 4vw, 2rem);
}

.widget__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: 'Inter', sans-serif;
  font-size: var(--small);
  font-weight: 500;
  padding: 0.875rem 1.75rem;
  transition: all var(--speed) var(--ease);
  cursor: pointer;
  border: none;
  white-space: nowrap;
}

.widget__btn--next,
.widget__btn--submit,
.widget__btn--cta {
  flex: 1;
  background: var(--accent);
  color: #fff;
}

.widget__btn--next:hover,
.widget__btn--submit:hover,
.widget__btn--cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
}

.widget__btn--next:active,
.widget__btn--submit:active,
.widget__btn--cta:active {
  transform: translateY(0);
}

.widget__btn--next:disabled,
.widget__btn--submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.widget__btn--back {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid rgba(0, 0, 0, 0.08);
  padding: 0.875rem 1.25rem;
}

.widget__btn--back:hover {
  border-color: rgba(0, 0, 0, 0.2);
  color: var(--text-primary);
}

.widget__btn--cta {
  white-space: normal;
  text-align: center;
  line-height: 1.4;
  padding: 1rem 1.5rem;
  font-size: clamp(0.85rem, 2.2vw, 0.95rem);
}

.widget__btn-arrow {
  transition: transform 0.3s var(--ease);
  flex-shrink: 0;
}

.widget__btn:hover .widget__btn-arrow {
  transform: translateX(4px);
}

/* ── Submit Reassurance ── */
.widget__reassurance {
  font-size: 0.75rem;
  font-weight: 300;
  color: var(--text-tertiary);
  text-align: center;
  margin-top: 0.75rem;
  line-height: 1.5;
}

/* ── Live Result Panel ── */
.widget__live-result {
  margin-top: 1.5rem;
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transition: opacity 0.5s var(--ease), max-height 0.6s var(--ease), margin-top 0.5s var(--ease);
}

.widget__live-result--visible {
  opacity: 1;
  max-height: 1100px;
  margin-top: 2rem;
}

/* ── Result Cards Grid ── */
.widget__result-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 1rem;
}

.widget__result-card {
  background: var(--vellum-bg);
  backdrop-filter: blur(8px) saturate(140%);
  -webkit-backdrop-filter: blur(8px) saturate(140%);
  border: 1px solid var(--vellum-border);
  padding: clamp(1rem, 3vw, 1.5rem);
  text-align: center;
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease);
}

.widget__result-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
}

.widget__result-card-icon {
  display: block;
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
}

.widget__result-card-label {
  display: block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-tertiary);
  margin-bottom: 0.75rem;
}

.widget__result-card-value {
  display: block;
  font-size: clamp(1.125rem, 3vw, 1.5rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

/* ── Result Disclaimer ── */
.widget__result-disclaimer {
  font-size: 0.7rem;
  font-weight: 300;
  color: var(--text-tertiary);
  line-height: 1.5;
  text-align: center;
  margin-bottom: 1.25rem;
}

/* ── Confirmation Screen ── */
.widget__confirmation {
  display: none;
  text-align: center;
  padding: clamp(2rem, 5vw, 3rem) 0;
}

.widget__confirmation--visible {
  display: block;
}

.widget__checkmark {
  width: 64px;
  height: 64px;
  margin: 0 auto 1.5rem;
  position: relative;
}

.widget__checkmark svg {
  width: 100%;
  height: 100%;
}

.widget__checkmark-circle {
  stroke-dasharray: 166;
  stroke-dashoffset: 166;
  stroke: var(--accent);
  fill: none;
  animation: widgetCircle 0.6s var(--ease) forwards;
}

.widget__checkmark-check {
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  stroke: var(--accent);
  fill: none;
  animation: widgetCheck 0.3s var(--ease) 0.4s forwards;
}

@keyframes widgetCircle {
  to { stroke-dashoffset: 0; }
}

@keyframes widgetCheck {
  to { stroke-dashoffset: 0; }
}

.widget__confirmation-title {
  font-size: clamp(1.25rem, 3.5vw, 1.5rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}

.widget__confirmation-text {
  font-size: var(--body);
  font-weight: 300;
  color: var(--text-secondary);
  line-height: 1.6;
  max-width: 400px;
  margin: 0 auto 1.25rem;
}

.widget__confirmation-ref {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--text-tertiary);
}

/* ── Error Banner ── */
.widget__global-error {
  background: rgba(201, 68, 68, 0.06);
  border: 1px solid rgba(201, 68, 68, 0.2);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: var(--small);
  font-weight: 300;
  color: #c94444;
  line-height: 1.4;
  display: none;
}

.widget__global-error--visible {
  display: block;
}

/* ── LPD Notice ── */
.widget__lpd {
  font-size: 0.7rem;
  font-weight: 300;
  color: var(--text-tertiary);
  line-height: 1.5;
  margin-top: 0.75rem;
}

.widget__lpd abbr {
  text-decoration: none;
  border-bottom: 1px dotted var(--text-tertiary);
  cursor: help;
}

/* ── Conditional Fields ── */
.widget__conditional {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 0.5s var(--ease), opacity 0.4s var(--ease), margin 0.4s var(--ease);
  margin-bottom: 0;
}

.widget__conditional--visible {
  max-height: 500px;
  opacity: 1;
  margin-bottom: 1rem;
}

/* ── Checkbox Group (renovation) ── */
.widget__checkbox-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.widget__checkbox--renov {
  margin-top: 0;
}

/* ── Result Card Icon (SVG) ── */
.widget__result-card-icon svg {
  width: 28px;
  height: 28px;
  color: var(--text-secondary);
}

/* ── Negative Result Card ── */
.widget__result-card--negative .widget__result-card-value {
  color: #c94444;
}

.widget__result-card-note {
  display: block;
  font-size: 0.7rem;
  font-weight: 300;
  color: #c94444;
  line-height: 1.4;
  margin-top: 0.5rem;
}

/* ── Renovation Message Panel ── */
.widget__renov-message {
  margin-top: 1.5rem;
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transition: opacity 0.5s var(--ease), max-height 0.6s var(--ease), margin-top 0.5s var(--ease);
}

.widget__renov-message--visible {
  opacity: 1;
  max-height: 400px;
  margin-top: 2rem;
}

.widget__renov-message-inner {
  background: var(--vellum-bg);
  backdrop-filter: blur(8px) saturate(140%);
  -webkit-backdrop-filter: blur(8px) saturate(140%);
  border: 1px solid var(--vellum-border);
  padding: clamp(1.5rem, 4vw, 2rem);
  text-align: center;
}

.widget__renov-message-text {
  font-size: var(--body);
  font-weight: 300;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

/* ── Section Subtitle (renovation fields) ── */
.widget__section-subtitle {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.widget__renov-fields .widget__field,
.widget__renov-fields .widget__row {
  margin-bottom: 1.25rem;
}

/* ── Mobile adjustments ── */
@media (max-width: 480px) {
  .widget__cards {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .widget__card {
    padding: 0.875rem 0.5rem;
  }

  .widget__row {
    grid-template-columns: 1fr;
  }

  .widget__result-cards {
    grid-template-columns: 1fr;
  }

  .widget__checkbox-group {
    grid-template-columns: 1fr;
  }

  .widget__btn--submit {
    font-size: 0.82rem;
    white-space: normal;
    line-height: 1.35;
    padding: 0.875rem 0.75rem;
  }
  .widget__nav {
    flex-direction: column;
    gap: 0.5rem;
  }
  .widget__btn--back {
    width: 100%;
  }
}

/* ── Tablet+ ── */
@media (min-width: 768px) {
  .widget__cards {
    grid-template-columns: repeat(4, 1fr);
  }

  .widget__result-cards {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ── Surface Slider ── */
.widget__surface-slider-wrap { margin-bottom: 1rem; }
.widget__surface-header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 0.75rem; }
.widget__surface-display { display: flex; align-items: baseline; gap: 0.25rem; }
.widget__surface-value { font-family: 'JetBrains Mono', monospace; font-size: 1.75rem; font-weight: 400; color: #1a1a1a; line-height: 1; transition: color 0.15s ease; }
.widget__surface-unit { font-size: 0.85rem; color: #666; font-weight: 300; }
.widget__slider-track { position: relative; padding-bottom: 1.25rem; }
.widget__slider { -webkit-appearance: none; appearance: none; width: 100%; height: 3px; background: #e5e5e5; border-radius: 99px; outline: none; cursor: pointer; }
.widget__slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 22px; height: 22px; border-radius: 50%; background: #1a1a1a; cursor: pointer; border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,0.18); transition: transform 0.15s ease, box-shadow 0.15s ease; }
.widget__slider::-webkit-slider-thumb:hover { transform: scale(1.15); box-shadow: 0 2px 8px rgba(0,0,0,0.22); }
.widget__slider::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: #1a1a1a; cursor: pointer; border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,0.18); }
.widget__slider-labels { display: flex; justify-content: space-between; margin-top: 0.4rem; }
.widget__slider-label-min, .widget__slider-label-max { font-family: 'JetBrains Mono', monospace; font-size: 0.7rem; color: #aaa; text-transform: uppercase; letter-spacing: 0.05em; }
.widget__surface-hint { font-size: 0.75rem; color: #999; font-style: italic; margin-top: 0.25rem; line-height: 1.4; }
