/* STM Konfigurator - Oberflaeche (M2). Alles unter .stmk mit eigenem Praefix;
   Themes (The7, Avada) werden auf Container-Ebene neutralisiert (Analyse E9).
   Mobile-first: die Basis gilt fuers Handy, min-width erweitert. */

.stmk {
    /* Token - je Site per Child-Theme uebersteuerbar. */
    --stmk-akzent:        #1a56a0;
    --stmk-akzent-text:   #ffffff;
    --stmk-text:          #24292e;
    --stmk-text-leise:    #5b636b;
    --stmk-flaeche:       #ffffff;
    --stmk-flaeche-alt:   #f4f5f6;
    --stmk-rand:          #d4d8dc;
    --stmk-fehlerfarbe:   #b3261e;
    --stmk-radius:        10px;
    --stmk-schatten:      0 2px 10px rgba(20, 30, 40, .08);
    --stmk-abstand:       16px;
    --stmk-schrift:       inherit;

    box-sizing: border-box;
    color: var(--stmk-text);
    font-family: var(--stmk-schrift);
    line-height: 1.5;
    max-width: 960px;
    margin-inline: auto;
}

/* --- Theme-Neutralisierung ------------------------------------------- */
.stmk *, .stmk *::before, .stmk *::after { box-sizing: inherit; }
.stmk :is(h2, h3, p, ul, dl, fieldset, legend) {
    margin: 0; padding: 0; border: 0;
    color: inherit; text-transform: none; letter-spacing: normal;
    background: none; list-style: none;
}
.stmk :is(h2, h3)::first-letter { font-size: inherit; color: inherit; }
.stmk img { max-width: 100%; height: auto; display: block; }

/* --- Buehne ------------------------------------------------------------ */
.stmk-buehne {
    background: var(--stmk-flaeche);
    border: 1px solid var(--stmk-rand);
    border-radius: var(--stmk-radius);
    box-shadow: var(--stmk-schatten);
    padding: var(--stmk-abstand);
}
@media (min-width: 640px) { .stmk-buehne { padding: calc(var(--stmk-abstand) * 1.75); } }

/* --- Kopf / Fortschritt ------------------------------------------------ */
.stmk-kopf { display: grid; gap: 8px; margin-bottom: calc(var(--stmk-abstand) * 1.25); }
.stmk-fortschritt-text { font-size: .85rem; color: var(--stmk-text-leise); }
.stmk-fortschritt {
    height: 6px; border-radius: 3px; background: var(--stmk-flaeche-alt); overflow: hidden;
}
.stmk-fortschritt-fuellung {
    height: 100%; background: var(--stmk-akzent); border-radius: 3px;
    transition: width .25s ease;
}
.stmk-schritt-titel { font-size: 1.3rem; font-weight: 650; outline: none; }
.stmk-hinweis { color: var(--stmk-text-leise); font-size: .9rem; }
.stmk-hinweis--schutz { border-left: 3px solid var(--stmk-akzent); padding-left: 10px; }

/* --- Felder ------------------------------------------------------------ */
.stmk-schritt { display: grid; gap: calc(var(--stmk-abstand) * 1.25); }
.stmk-feld { display: grid; gap: 6px; }
.stmk-label { font-weight: 600; font-size: .95rem; display: block; }
.stmk-pflicht { color: var(--stmk-fehlerfarbe); }
.stmk-eingabe {
    appearance: none;
    font: inherit; color: inherit;
    background: var(--stmk-flaeche);
    border: 1.5px solid var(--stmk-rand);
    border-radius: calc(var(--stmk-radius) - 4px);
    padding: 10px 12px;
    width: 100%; max-width: 420px;
    min-height: 44px;
}
.stmk-eingabe:focus-visible { outline: 2px solid var(--stmk-akzent); outline-offset: 1px; border-color: var(--stmk-akzent); }
textarea.stmk-eingabe { max-width: 100%; resize: vertical; }
.stmk-einheit-zeile { display: flex; align-items: center; gap: 8px; }
.stmk-einheit-zeile .stmk-eingabe { max-width: 160px; }
.stmk-einheit { color: var(--stmk-text-leise); }
.stmk-feld-fehler { color: var(--stmk-fehlerfarbe); font-size: .88rem; font-weight: 600; }
.stmk-feld--fehler .stmk-eingabe { border-color: var(--stmk-fehlerfarbe); }

.stmk-checkbox { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; font-size: .92rem; }
.stmk-checkbox input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--stmk-akzent); flex: none; }
.stmk-ds-link { color: var(--stmk-akzent); text-decoration: underline; white-space: nowrap; }

/* --- Karten-Auswahl (Radio-Kacheln) ------------------------------------ */
.stmk-karten { display: grid; gap: 10px; min-width: 0; }
.stmk-karten-gitter {
    display: grid; gap: 10px;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
}
.stmk-karten--muster .stmk-karten-gitter { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.stmk-karten-gitter--farben { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }

.stmk-karte {
    position: relative;
    display: grid; gap: 8px; align-content: start;
    border: 1.5px solid var(--stmk-rand);
    border-radius: var(--stmk-radius);
    background: var(--stmk-flaeche);
    padding: 12px;
    cursor: pointer;
    min-height: 44px;
}
.stmk-karte:hover { border-color: var(--stmk-akzent); }
.stmk-karte:has(input:checked) {
    border-color: var(--stmk-akzent);
    box-shadow: inset 0 0 0 1.5px var(--stmk-akzent);
    background: color-mix(in srgb, var(--stmk-akzent) 5%, var(--stmk-flaeche));
}
.stmk-karte:has(input:focus-visible) { outline: 2px solid var(--stmk-akzent); outline-offset: 2px; }
.stmk-karte-text { display: grid; gap: 2px; font-size: .92rem; }
.stmk-karte-text small { color: var(--stmk-text-leise); font-size: .82rem; }
.stmk-karte-icon { width: 44px; height: 44px; color: var(--stmk-akzent); }
.stmk-karte-icon svg { width: 100%; height: 100%; }
.stmk-karte-bild { border-radius: calc(var(--stmk-radius) - 4px); aspect-ratio: 32 / 21; object-fit: cover; width: 100%; }
.stmk-farbprobe {
    width: 100%; height: 44px;
    border-radius: calc(var(--stmk-radius) - 4px);
    border: 1px solid rgba(0, 0, 0, .12);
    display: grid; place-items: center;
}
.stmk-farbprobe--sonder {
    background: repeating-conic-gradient(var(--stmk-flaeche-alt) 0% 25%, var(--stmk-flaeche) 0% 50%) 0 0 / 16px 16px;
    color: var(--stmk-text-leise); font-weight: 700; font-size: 1.2rem;
}
.stmk-badge {
    position: absolute; top: 8px; right: 8px;
    background: var(--stmk-akzent); color: var(--stmk-akzent-text);
    font-size: .7rem; font-weight: 700; letter-spacing: .02em;
    padding: 2px 8px; border-radius: 99px;
}
.stmk-farbgruppe { font-size: .95rem; font-weight: 650; margin-top: 6px; }
.stmk-sonderfarbe { margin-top: 4px; }

/* --- Foto -------------------------------------------------------------- */
.stmk-fotozone {
    display: grid; gap: 12px; justify-items: start;
    border: 2px dashed var(--stmk-rand);
    border-radius: var(--stmk-radius);
    background: var(--stmk-flaeche-alt);
    padding: var(--stmk-abstand);
}
.stmk-fotovorschau { max-height: 320px; border-radius: calc(var(--stmk-radius) - 4px); }

/* --- Visueller Editor (M4) ---------------------------------------------- */
.stmk-editor { display: grid; gap: 10px; }
.stmk-editor-anleitung { font-size: .92rem; font-weight: 600; color: var(--stmk-akzent); min-height: 1.4em; }
/* Die Buehne ist exakt so gross wie das Foto - KEIN object-fit mit Balken.
   Sonst rechnen die Eckpunkte gegen die Buehne, waehrend das Foto nur in
   deren Mitte liegt: bei jedem Hochkant-Handyfoto saesse das Muster falsch
   (live gefunden 25.08.2026, 197 px Versatz). */
.stmk-editor-stage {
    position: relative;
    width: fit-content;
    max-width: 100%;
    margin-inline: auto;
    border-radius: var(--stmk-radius);
    overflow: hidden;
    background: #222;
    touch-action: none;           /* Zeigersteuerung gehoert dem Editor */
    line-height: 0;               /* kein Zeilenabstand unter dem Bild */
}
.stmk-editor-foto {
    display: block;
    max-width: 100%;
    max-height: 62vh;
    width: auto;
    height: auto;
    user-select: none;
    -webkit-user-drag: none;
}
.stmk-editor-lagen, .stmk-editor-wz, .stmk-editor-overlay { position: absolute; inset: 0; }
.stmk-editor-lagen { overflow: hidden; pointer-events: none; }
.stmk-editor-muster {
    position: absolute; top: 0; left: 0;
    transform-origin: 0 0;
    -webkit-mask-repeat: repeat; mask-repeat: repeat;
    will-change: transform;
}
/* Wasserzeichen liegt UEBER den Musterlagen, unter den Griffen (E10). */
.stmk-editor-wz {
    pointer-events: none;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="420" height="260"><text x="30" y="150" font-family="sans-serif" font-size="26" font-weight="600" fill="rgba(255,255,255,.28)" transform="rotate(-18 210 130)">Unverbindliche%20Vorschau</text></svg>');
}
.stmk-editor-overlay { width: 100%; height: 100%; }
.stmk-editor-kante {
    fill: transparent;
    stroke: rgba(255, 255, 255, .55);
    stroke-width: 1.5;
    stroke-dasharray: 6 4;
    pointer-events: stroke;
    cursor: pointer;
}
/* Die aktive Flaeche ist in ganzer Ausdehnung greifbar und verschiebbar. */
.stmk-editor-kante.ist-aktiv {
    stroke: #fff;
    stroke-width: 2;
    stroke-dasharray: none;
    pointer-events: all;
    cursor: move;
}
.stmk-editor-griff { cursor: grab; outline: none; }
.stmk-editor-griff:active { cursor: grabbing; }
.stmk-editor-griff-treffer { fill: transparent; }
.stmk-editor-griff-punkt {
    fill: var(--stmk-akzent);
    stroke: #fff;
    stroke-width: 2.5;
}
.stmk-editor-griff:focus-visible .stmk-editor-griff-punkt { stroke: #ffd766; stroke-width: 3.5; }
.stmk-editor-lupe {
    position: absolute;
    width: 132px; height: 132px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .4);
    pointer-events: none;
    background: #111;
}
.stmk-editor-pruefung {
    background: #fff8e6;
    border: 1px solid #e3c766;
    border-radius: calc(var(--stmk-radius) - 2px);
    padding: 8px 12px;
    font-size: .9rem;
}
.stmk-editor-werkzeuge { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.stmk-editor-flchip {
    display: inline-flex; align-items: center; gap: 2px;
    border: 1.5px solid var(--stmk-rand);
    border-radius: 99px;
    padding: 2px 4px 2px 12px;
    font-size: .88rem;
    background: var(--stmk-flaeche);
}
.stmk-editor-flchip.ist-aktiv { border-color: var(--stmk-akzent); box-shadow: inset 0 0 0 1px var(--stmk-akzent); }
.stmk-editor-flname { appearance: none; background: none; border: 0; font: inherit; cursor: pointer; padding: 4px 2px; }
.stmk-editor-flweg {
    appearance: none; background: none; border: 0;
    font-size: 1.05rem; line-height: 1;
    color: var(--stmk-text-leise);
    cursor: pointer; padding: 6px 8px; border-radius: 50%;
}
.stmk-editor-flweg:hover { color: var(--stmk-fehlerfarbe); }
.stmk-editor-chips { display: grid; gap: 8px; }
.stmk-editor-chipzeile { display: flex; flex-wrap: wrap; gap: 6px; }
.stmk-editor-chip {
    appearance: none; padding: 0; cursor: pointer;
    border: 2px solid var(--stmk-rand);
    border-radius: 8px;
    background: var(--stmk-flaeche);
    width: 46px; height: 46px;
    overflow: hidden;
    flex: none;
}
.stmk-editor-chip img { width: 100%; height: 100%; object-fit: cover; display: block; }
.stmk-editor-chip--farbe { border-radius: 50%; width: 32px; height: 32px; }
.stmk-editor-chip.ist-aktiv { border-color: var(--stmk-akzent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--stmk-akzent) 40%, transparent); }
.stmk-editor-chip:focus-visible { outline: 2px solid var(--stmk-akzent); outline-offset: 2px; }

/* --- Upload / Dateiliste ------------------------------------------------ */
.stmk-dateiliste { display: grid; gap: 4px; font-size: .9rem; }
.stmk-entfernen {
    appearance: none; background: none; border: 0; padding: 0;
    color: var(--stmk-akzent); font: inherit; font-size: .85rem;
    text-decoration: underline; cursor: pointer;
}
.stmk-entfernen:focus-visible { outline: 2px solid var(--stmk-akzent); outline-offset: 2px; }

/* --- Zusammenfassung ---------------------------------------------------- */
.stmk-zusammenfassung { display: grid; gap: 14px; }
.stmk-zblock {
    border: 1px solid var(--stmk-rand);
    border-radius: var(--stmk-radius);
    padding: 12px 14px;
    display: grid; gap: 8px;
}
.stmk-zblock-kopf { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.stmk-zblock-kopf h3 { font-size: 1rem; font-weight: 650; }
.stmk-zliste { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: 4px 12px; font-size: .92rem; }
.stmk-zliste dt { color: var(--stmk-text-leise); }
.stmk-zliste dd { margin: 0; }
.stmk-zfoto { max-height: 120px; border-radius: 6px; }
.stmk-zmontage {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    border: 1px solid var(--stmk-rand);
}
.stmk-zmontage:not([src]) { display: none; }

/* --- Fuss / Knoepfe ------------------------------------------------------ */
.stmk-fuss {
    display: flex; flex-wrap: wrap; gap: 10px;
    justify-content: flex-end; align-items: center;
    margin-top: calc(var(--stmk-abstand) * 1.5);
    padding-top: var(--stmk-abstand);
    border-top: 1px solid var(--stmk-rand);
}
.stmk-fuss > :first-child { margin-right: auto; }
.stmk-knopf {
    appearance: none;
    font: inherit; font-weight: 600;
    border-radius: calc(var(--stmk-radius) - 2px);
    border: 1.5px solid var(--stmk-akzent);
    background: var(--stmk-flaeche);
    color: var(--stmk-akzent);
    padding: 10px 20px;
    min-height: 44px;
    cursor: pointer;
    text-transform: none; letter-spacing: normal; box-shadow: none;
}
.stmk-knopf--primaer { background: var(--stmk-akzent); color: var(--stmk-akzent-text); }
.stmk-knopf--leise { border-color: var(--stmk-rand); color: var(--stmk-text); }
.stmk-knopf:hover { filter: brightness(1.06); }
.stmk-knopf:focus-visible { outline: 2px solid var(--stmk-akzent); outline-offset: 2px; }

.stmk-zblock--positionen { background: var(--stmk-flaeche-alt); }
.stmk-positionsliste { display: grid; gap: 6px; font-size: .92rem; }
.stmk-erfolg { display: grid; gap: 10px; padding: calc(var(--stmk-abstand) * 1.5) 0; text-align: center; justify-items: center; }
.stmk-erfolg h2 { outline: none; }

.stmk-meldung {
    background: color-mix(in srgb, var(--stmk-akzent) 8%, var(--stmk-flaeche));
    border: 1px solid var(--stmk-akzent);
    border-radius: calc(var(--stmk-radius) - 2px);
    padding: 10px 14px; font-size: .92rem;
    margin-top: var(--stmk-abstand);
}

.stmk-fehler {
    background: #fdf3f3;
    border: 1px solid #e6b8b8;
    border-radius: var(--stmk-radius);
    color: #8c2f2f;
    padding: 12px 16px;
}

/* --- Hilfen -------------------------------------------------------------- */
.stmk-vh {
    position: absolute; width: 1px; height: 1px;
    margin: -1px; padding: 0; border: 0;
    clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}
@media (prefers-reduced-motion: reduce) {
    .stmk-fortschritt-fuellung { transition: none; }
}

/* Druck-Bremse (E10): Zusammenfassung und Muster sind fuer den Bildschirm.
   Eine Bremse, kein Schloss - Screenshots verhindert niemand. */
@media print {
    .stmk .stmk-buehne > * { display: none !important; }
    .stmk .stmk-buehne::after {
        content: 'Der Konfigurator-Inhalt ist für den Druck nicht vorgesehen. Nach dem Absenden erhalten Sie eine Eingangsbestätigung per E-Mail.';
        display: block;
        padding: 16px 0;
    }
}
@media (max-width: 480px) {
    .stmk-karten-gitter { grid-template-columns: 1fr 1fr; }
    .stmk-karten--muster .stmk-karten-gitter { grid-template-columns: 1fr; }
    .stmk-fuss .stmk-knopf--primaer { flex: 1 1 auto; }
    .stmk-zliste { grid-template-columns: 1fr; gap: 0 0; }
    .stmk-zliste dd { margin-bottom: 6px; }
}
