/* Boden-Visualizer: ruhig, warm, mobil zuerst. Markenfarbe kommt per CSSOM aus /api/config. */

:root {
  color-scheme: light dark;
  --bg: #f5f3ef;
  --surface: #ffffff;
  --surface-2: #efebe4;
  --surface-3: #e5dfd5;
  --text: #1d1b18;
  --muted: #625c53;
  --line: #ddd6cb;
  --line-strong: #c4baab;
  --brand: #6f5b46;
  --on-brand: #ffffff;
  --accent: var(--brand); /* Hervorhebungen; BRAND_ACCENT setzt eine eigene Farbe */
  --on-accent: var(--on-brand);
  --danger: #9b2c22;
  --danger-bg: #fbecea;
  --success-bg: #e7f2ea;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgb(30 25 20 / 5%), 0 10px 30px rgb(30 25 20 / 5%);
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
}

/* Eingebettet (iframe) immer hell: die einbettende Seite bestimmt das Aussehen. */
:root.is-embedded { color-scheme: light; }

@media (prefers-color-scheme: dark) {
  :root:not(.is-embedded) {
    --bg: #141311;
    --surface: #1c1a18;
    --surface-2: #25221f;
    --surface-3: #302c27;
    --text: #f1ede7;
    --muted: #aba397;
    --line: #34302b;
    --line-strong: #4d463e;
    --brand: #c2a283;
    --on-brand: #1d1b18;
    --danger: #f2a197;
    --danger-bg: #3b1e1a;
    --success-bg: #1a2e21;
    --shadow: none;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 1rem/1.6 var(--font-sans);
  -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; }
h1, h2, h3 { font-family: var(--font-serif); font-weight: 500; line-height: 1.2; }
.muted { color: var(--muted); }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

.wrap { width: 100%; max-width: 1040px; margin-inline: auto; padding-inline: 16px; }

/* Kopf und Einleitung */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.site-header .wrap { display: flex; align-items: center; min-height: 56px; }
.brand { display: flex; align-items: center; gap: 10px; margin: 0; font-weight: 650; letter-spacing: 0.01em; }
.brand-mark { width: 12px; height: 12px; border-radius: 3px; background: var(--brand); }

.intro { padding: 36px 0 8px; }
.intro h1 { margin: 0 0 12px; font-size: clamp(1.9rem, 1.2rem + 2.8vw, 3rem); letter-spacing: -0.01em; text-wrap: balance; }
.lead { max-width: 40rem; margin: 0; color: var(--muted); font-size: 1.075rem; }

/* Schritte */
.step {
  margin-top: 20px;
  padding: 20px 16px 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.step h2 { display: flex; align-items: center; gap: 12px; margin: 0 0 18px; font-size: 1.45rem; }
.step h2:focus { outline: none; }
.step-no {
  display: inline-grid; place-items: center; flex: none;
  width: 32px; height: 32px; border-radius: 50%;
  border: 1.5px solid var(--accent);
  font: 600 0.95rem/1 var(--font-sans);
}

/* Zustimmung */
.check { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: start; margin: 0 0 16px; }
.check input { width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--brand); }
.check label { font-size: 0.95rem; cursor: pointer; }

/* Ablagefeld */
.dropzone-label {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  padding: 28px 16px;
  text-align: center;
  background: var(--surface-2);
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}
.dropzone-label:hover, .dropzone.is-dragover .dropzone-label { border-color: var(--brand); background: var(--surface-3); }
.dropzone input:focus-visible + .dropzone-label { outline: 3px solid var(--text); outline-offset: 2px; }
.dropzone.is-busy .dropzone-label { opacity: 0.6; cursor: progress; }
.dz-icon { width: 40px; height: 40px; color: var(--muted); }
.dz-title { font-weight: 600; }
.dz-or, .dz-hint { color: var(--muted); font-size: 0.9rem; }
.dz-button { margin: 4px 0; pointer-events: none; }
.tip { margin: 12px 0 0; color: var(--muted); font-size: 0.92rem; }

.preview { margin-top: 16px; }
.preview img { width: 100%; max-height: 420px; object-fit: contain; background: var(--surface-2); border-radius: var(--radius-sm); }
.preview-bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px;
  margin-top: 10px; color: var(--muted); font-size: 0.95rem;
}

/* Kategorie-Filter */
.group { min-width: 0; margin: 0; padding: 0; border: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip, .material, .segment { position: relative; }
.chip label {
  display: inline-flex; align-items: center;
  min-height: 40px; padding: 0 16px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: 0.95rem;
  cursor: pointer;
}
.chip input:checked + label { background: var(--text); border-color: var(--text); color: var(--bg); }

/* Musterkarten */
.material-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.material label {
  position: relative;
  display: block; height: 100%;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.material label:hover { border-color: var(--line-strong); }
.material img { width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; background: var(--surface-2); }
.material-text { display: block; padding: 10px 12px 12px; }
.material-name { display: block; font-weight: 600; font-size: 0.95rem; line-height: 1.3; }
.material-cat { display: block; margin-top: 2px; color: var(--muted); font-size: 0.82rem; }
.material input:checked + label { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.material input:checked + label::before {
  content: ""; position: absolute; top: 8px; right: 8px; z-index: 1;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 4px rgb(0 0 0 / 25%);
}
.material input:checked + label::after {
  content: ""; position: absolute; top: 14px; right: 14px; z-index: 2;
  width: 16px; height: 16px;
  background: var(--on-accent);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 8.5l3 3 7-7' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 8.5l3 3 7-7' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* Oberfläche */
.finish { margin-top: 22px; }
.finish legend { margin-bottom: 8px; padding: 0; font-weight: 600; }
.segmented {
  display: flex; gap: 4px; padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
}
.segment { flex: 1 1 0; }
.segment label {
  display: flex; align-items: center; justify-content: center;
  min-height: 40px; padding: 0 14px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.95rem;
  cursor: pointer;
}
.segment input:checked + label { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgb(0 0 0 / 15%); }
.segment input:disabled + label { opacity: 0.4; cursor: not-allowed; }

.chip input:focus-visible + label,
.material input:focus-visible + label,
.segment input:focus-visible + label { outline: 3px solid var(--text); outline-offset: 2px; }

.summary { min-height: 1.6em; margin: 16px 0 0; color: var(--muted); }

/* Knöpfe */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 22px;
  border: 1px solid transparent; border-radius: 999px;
  font: inherit; font-weight: 600; text-decoration: none; text-align: center;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, filter 0.15s, opacity 0.15s;
}
.button:focus-visible, .link-button:focus-visible { outline: 3px solid var(--text); outline-offset: 2px; }
.button-primary { background: var(--brand); color: var(--on-brand); }
.button-primary:hover:not(:disabled) { filter: brightness(1.08); }
.button-secondary { background: var(--surface); border-color: var(--line-strong); color: var(--text); }
.button-secondary:hover { border-color: var(--text); }
.button-ghost { background: transparent; color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.button:disabled { opacity: 0.45; cursor: not-allowed; }
.button-block { width: 100%; }
.link-button {
  padding: 4px 0; background: none; border: 0;
  color: var(--text); font: inherit; text-decoration: underline; text-underline-offset: 3px;
  cursor: pointer;
}

.render-row { margin-top: 20px; }
.hint { margin: 10px 0 0; color: var(--muted); font-size: 0.92rem; }

/* Fortschritt */
.progress { margin-top: 18px; }
.progress-track { position: relative; height: 4px; overflow: hidden; background: var(--surface-3); border-radius: 999px; }
.progress-track::after {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 35%;
  background: var(--accent); border-radius: inherit;
  animation: progress-slide 1.4s ease-in-out infinite;
}
@keyframes progress-slide { from { transform: translateX(-100%); } to { transform: translateX(300%); } }
.progress-text { margin: 10px 0 0; font-weight: 600; }
.progress-note { margin: 2px 0 0; color: var(--muted); font-size: 0.9rem; }

.error {
  margin: 14px 0 0; padding: 10px 14px;
  background: var(--danger-bg); color: var(--danger);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
}

/* Vorher/Nachher */
.compare {
  position: relative;
  width: min(100%, calc(72vh * var(--ratio, 1.3333)));
  aspect-ratio: var(--ratio, 1.3333);
  margin-inline: auto;
  overflow: hidden;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  cursor: ew-resize;
}
.compare img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; -webkit-user-drag: none; }
.compare-after { position: absolute; inset: 0; clip-path: inset(0 0 0 var(--pos, 50%)); }
.compare-handle {
  position: absolute; top: 0; bottom: 0; left: var(--pos, 50%);
  width: 2px; margin-left: -1px;
  background: #ffffff;
  box-shadow: 0 0 0 1px rgb(0 0 0 / 18%);
  pointer-events: none;
}
.compare-handle::after {
  content: ""; position: absolute; top: 50%; left: 50%;
  width: 44px; height: 44px; transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #ffffff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 7l-5 5 5 5M15 7l5 5-5 5' fill='none' stroke='%231d1b18' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 22px no-repeat;
  box-shadow: 0 2px 10px rgb(0 0 0 / 30%);
}
.compare-tag {
  position: absolute; top: 12px;
  padding: 3px 10px;
  background: rgb(20 18 16 / 62%); color: #ffffff;
  border-radius: 999px;
  font-size: 0.8rem; font-weight: 600; letter-spacing: 0.02em;
  pointer-events: none;
}
.tag-before { left: 12px; }
.tag-after { right: 12px; }
.compare-range { display: block; width: 100%; margin: 14px 0 0; accent-color: var(--accent); }
.caption { margin: 8px 0 0; color: var(--muted); text-align: center; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.actions .button { flex: 1 1 100%; }

/* Offertanfrage */
.lead-summary {
  display: flex; align-items: center; gap: 12px;
  margin: 0 0 18px; padding: 10px;
  background: var(--surface-2); border-radius: var(--radius-sm);
}
.lead-summary img { width: 84px; height: 60px; object-fit: cover; border-radius: 6px; flex: none; }
.lead-summary p { margin: 0; font-weight: 600; }
.form-grid { display: grid; gap: 14px; margin-bottom: 16px; }
.field label { display: block; margin-bottom: 6px; font-size: 0.95rem; font-weight: 600; }
.field input, .field textarea {
  width: 100%; min-height: 48px; padding: 10px 14px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  font: inherit;
}
.field textarea { min-height: 120px; resize: vertical; }
.field input:focus-visible, .field textarea:focus-visible { outline: 3px solid var(--text); outline-offset: 1px; }
.field [aria-invalid="true"] { border-color: var(--danger); }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.thanks { padding: 18px 20px; background: var(--success-bg); border-radius: var(--radius-sm); }
.thanks:focus { outline: none; }
.thanks h3 { margin: 0 0 6px; font-size: 1.3rem; }
.thanks p { margin: 0; }

/* Fuss */
.site-footer { margin-top: 40px; padding: 24px 0 40px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.9rem; }
.site-footer p { max-width: 46rem; margin: 0 0 10px; }
.legal-links { display: flex; flex-wrap: wrap; gap: 6px 20px; }
.legal-links a { color: var(--text); text-underline-offset: 3px; }

/* Eingebettet: ohne Kopf, Einleitung und Rechtslinks (die stehen auf der einbettenden Seite),
   durchsichtig und ohne vh, das sich im iframe mit der automatischen Höhe aufschaukeln würde. */
html.is-embedded body { background: transparent; }
.is-embedded .site-header, .is-embedded .intro, .is-embedded .legal-links { display: none !important; }
.is-embedded .compare { width: min(100%, calc(560px * var(--ratio, 1.3333))); }

@media (min-width: 560px) {
  .material-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .actions .button { flex: 0 0 auto; }
  .segmented { display: inline-flex; }
  .segment { flex: 0 0 auto; }
}

@media (min-width: 720px) {
  .step { padding: 28px 28px 32px; }
  .intro { padding-top: 48px; }
  .button-block { width: auto; min-width: 280px; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .field-wide { grid-column: 1 / -1; }
}

@media (min-width: 880px) {
  .material-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
  .progress-track::after { width: 100%; opacity: 0.5; animation: none; }
}
