/*
 * Produktfinder - Frontend.
 *
 * Dieses Stylesheet wird ausschliesslich von finder.tpl eingebunden, gilt also
 * nur auf der Finder-Seite. Deshalb darf hier auch Shop-Chrome ausgeblendet
 * werden, ohne andere Seiten zu treffen.
 *
 * Farben folgen dem ITTradeport-Theme (_variables.scss). Bewusst eigene
 * Klassen statt Theme-Utilities, damit der Finder bei einem Theme-Update
 * nicht stillschweigend anders aussieht.
 *
 * Mobil ist alles einspaltig - das ist Abnahmekriterium 4 des Konzepts.
 */

/* Der Finder ist ein eigenstaendiger Einstieg ohne Hierarchie darueber -
   "Startseite / Produktfinder" traegt nichts bei und nimmt dem Einstieg Ruhe.
   Ueber Smarty geht es nicht: der Shop setzt $Brotnavi erst nach dem
   Seitenhandler des Plugins. */
.breadcrumb-container {
    display: none;
}

.itt-finder {
    /* WCAG 2.2 AA: Werte wie im Theme (custom.css :root), Text/Weiss mind. 4,5:1 */
    --itt-primary: #3d8436;
    --itt-primary-dark: #346f2e;
    --itt-secondary: #292f2d;
    --itt-gray: #6d7078;
    --itt-gray-medium: #dde4e6;
    --itt-field-border: #7f99a1;
    --itt-gray-lighter: #f5f7f8;
    --itt-radius: 10px;

    /* Die Seitenraender kommen vom Shop-Container, damit der Finder buendig
       zu Brotkrume, Boxen und Footer sitzt. Oben nur so viel Luft, dass sich
       der Finder von der Seitenueberschrift absetzt. */
    padding: 1.5rem 0 4rem;
    color: var(--itt-secondary);
}

/* Das Theme gibt jedem <section> in <main> 2rem Innenabstand. Zusammen mit
   dem Abstand der Seitenueberschrift riss das ein Loch von ueber 100px auf.
   Die Abstaende steuert der Finder selbst. */
.itt-finder > [data-screen] {
    padding: 0;
}

/* Fliesstext bleibt lesbar schmal, auch wenn der Container breiter ist. */
.itt-finder__lead,
.itt-finder__hint {
    max-width: 52ch;
}

/* --- Kopfbereich ------------------------------------------------------- */

.itt-finder__eyebrow {
    margin: 0 0 .35rem;
    color: var(--itt-primary);
    font-size: .8rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.itt-finder__headline {
    margin: 0 0 .75rem;
    font-size: clamp(1.6rem, 4.5vw, 2.3rem);
    line-height: 1.2;
    font-weight: 700;
}

.itt-finder__lead {
    margin: 0 0 1.75rem;
    max-width: 46ch;
    color: var(--itt-gray);
    font-size: 1.05rem;
    line-height: 1.55;
}

/* Icons in Schaltflaechen laufen mit dem Text in einer Zeile. */
.itt-finder__restart,
.itt-finder__exits .btn {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
}

/* Inline-SVG statt <img>: nur so erbt das Icon die Schriftfarbe der
   Schaltflaeche. Als Bild bliebe es dunkelgruen und saeuft auf dem gruenen
   Primaerbutton ab. */
.itt-finder__btn-icon {
    flex: 0 0 auto;
    width: 1.15em;
    height: 1.15em;
    /* Optischer Ausgleich: Grossbuchstaben sitzen hoeher als die Icon-Mitte. */
    margin-top: -.08em;
}

/* --- Fortschritt ------------------------------------------------------- */

.itt-finder__progress {
    margin-bottom: 2.5rem;
}

.itt-finder__progress-bar {
    height: 6px;
    border-radius: 999px;
    background: var(--itt-gray-medium);
    overflow: hidden;
}

.itt-finder__progress-bar span {
    display: block;
    height: 100%;
    width: 20%;
    border-radius: 999px;
    background: var(--itt-primary);
    transition: width .45s cubic-bezier(.4, 0, .2, 1);
}

.itt-finder__progress-label {
    margin: .5rem 0 0;
    color: var(--itt-gray);
    font-size: .85rem;
}

/* --- Frage und Antwortkacheln ----------------------------------------- */

.itt-finder__question {
    margin: 0 0 .5rem;
    font-size: clamp(1.3rem, 3.6vw, 1.75rem);
    font-weight: 700;
    line-height: 1.25;
}

/* Luft zwischen Frageblock und Antworten: vorher standen sie so dicht
   beieinander, dass die Ueberschrift gequetscht wirkte. */
.itt-finder__hint {
    margin: 0 0 2.25rem;
    max-width: 58ch;
    color: var(--itt-gray);
    font-size: .98rem;
    line-height: 1.5;
}

/* Ohne Zusatzzeile traegt die Ueberschrift den Abstand allein. */
.itt-finder__hint[hidden] + .itt-finder__options {
    margin-top: 2.25rem;
}

.itt-finder__options {
    display: grid;
    grid-template-columns: 1fr;
    gap: .75rem;
}

@media (min-width: 640px) {
    .itt-finder__options[data-columns="2"] {
        grid-template-columns: 1fr 1fr;
    }
}



/* Die ganze Kachel ist klickbar, nicht nur Text oder Kaestchen. */
.itt-finder__option {
    display: flex;
    align-items: center;
    gap: .9rem;
    width: 100%;
    padding: 1.1rem 1.25rem;
    border: 2px solid var(--itt-gray-medium);
    border-radius: var(--itt-radius);
    background: #fff;
    text-align: left;
    font-size: 1.02rem;
    line-height: 1.35;
    cursor: pointer;
    transition: border-color .15s, background-color .15s, transform .1s;
}

.itt-finder__option:hover {
    border-color: var(--itt-primary);
    background: #fafdfa;
}

.itt-finder__option:active {
    transform: scale(.995);
}

.itt-finder__option[aria-pressed="true"] {
    border-color: var(--itt-primary);
    background: #f0f8ef;
}

.itt-finder__option:focus-visible {
    outline: 3px solid var(--itt-primary);
    outline-offset: 2px;
}

/* Die Marke steht rechts - links sitzt das Icon. */
.itt-finder__option-mark {
    flex: 0 0 22px;
    order: 3;
    width: 22px;
    height: 22px;
    border: 2px solid var(--itt-field-border);
    border-radius: 50%;
    position: relative;
}

.itt-finder__option[data-multi="1"] .itt-finder__option-mark {
    border-radius: 6px;
}

.itt-finder__option[aria-pressed="true"] .itt-finder__option-mark {
    border-color: var(--itt-primary);
    background: var(--itt-primary);
}

.itt-finder__option[aria-pressed="true"] .itt-finder__option-mark::after {
    content: "";
    position: absolute;
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.itt-finder__option-label {
    flex: 1;
}

/* Icon im gleichen gruenen Badge wie die Spec-Kacheln des Themes. */
.itt-finder__option-icon {
    display: flex;
    flex: 0 0 2.5rem;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: .6rem;
    background: #eaf6e8;
    transition: background-color .15s;
}

.itt-finder__option-icon img {
    width: 1.5rem;
    height: 1.5rem;
}

.itt-finder__option[aria-pressed="true"] .itt-finder__option-icon {
    background: #d6eed2;
}

.itt-finder__option-note {
    display: block;
    margin-top: .15rem;
    color: var(--itt-gray);
    font-size: .85rem;
}

/* --- Navigation -------------------------------------------------------- */

.itt-finder__nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1.75rem;
}

.itt-finder__back,
.itt-finder__restart {
    border: 0;
    background: none;
    padding: .6rem .2rem;
    color: var(--itt-gray);
    font-size: .95rem;
    text-decoration: underline;
    cursor: pointer;
}

.itt-finder__back:hover,
.itt-finder__restart:hover {
    color: var(--itt-secondary);
}

.itt-finder__next {
    padding: .7rem 1.8rem;
}

/* --- Abgleich ---------------------------------------------------------- */

.itt-finder__reconcile {
    padding: 4rem 0;
    text-align: center;
}

.itt-finder__pulse {
    width: 56px;
    height: 56px;
    margin: 0 auto 1.5rem;
    border: 4px solid var(--itt-gray-medium);
    border-top-color: var(--itt-primary);
    border-radius: 50%;
    animation: itt-finder-spin 1s linear infinite;
}

@keyframes itt-finder-spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .itt-finder__pulse { animation: none; }
    .itt-finder__progress-bar span { transition: none; }
}

.itt-finder__reconcile-text {
    /* Auto-Margins, sonst sitzt der schmale Block trotz text-align des
       Elternteils links statt unter dem Loader. */
    max-width: 52ch;
    margin: 0 auto;
    color: var(--itt-gray);
    font-size: 1.05rem;
}

/* --- Ergebnis ---------------------------------------------------------- */

/* Die Begruendungszeile ist ein ganzer Satz - Versalien waeren hier zu laut. */
.itt-finder__reason {
    margin: 0 0 .35rem;
    color: var(--itt-primary);
    font-size: .95rem;
    font-weight: 600;
}

.itt-finder__result-count {
    margin: -.35rem 0 1.5rem;
    color: var(--itt-gray);
    font-size: .95rem;
}

.itt-finder__notices {
    margin-bottom: 1.5rem;
}

.itt-finder__notice {
    display: flex;
    align-items: flex-start;
    gap: .7rem;
    padding: .85rem 1.1rem;
    margin-bottom: .6rem;
    border-left: 4px solid var(--itt-primary);
    border-radius: 6px;
    background: var(--itt-gray-lighter);
    color: var(--itt-secondary);
    font-size: .95rem;
}

/* auto-fit statt fester Spaltenzahl: leere Spuren fallen weg und die
   verbleibenden Karten teilen sich die Breite. Damit fuellen vier, drei oder
   zwei Karten die Reihe immer aus - eine feste Spaltenzahl liesse bei jeder
   anderen Anzahl eine Luecke.

   Die Mindestbreite ist so gewaehlt, dass im Shop-Container vier Karten
   nebeneinander passen (4 x 200 + 3 x 16 < 928). Genau das ist der Regelfall:
   eine hervorgehobene Empfehlung ueber die volle Breite, darunter vier. */
.itt-finder__products {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.itt-finder__product {
    display: flex;
    flex-direction: column;
    padding: 1.1rem;
    border: 1px solid var(--itt-gray-medium);
    border-radius: var(--itt-radius);
    background: #fff;
    text-decoration: none;
    color: inherit;
    transition: box-shadow .15s, border-color .15s;
}

.itt-finder__product:hover {
    border-color: var(--itt-primary);
    box-shadow: 0 6px 20px rgba(41, 47, 45, .09);
    color: inherit;
    text-decoration: none;
}

/* Ein Geraet wird als Empfehlung hervorgehoben. */
.itt-finder__product--recommended {
    border-color: var(--itt-primary);
    box-shadow: 0 6px 20px rgba(83, 181, 74, .16);
}

/* Die Empfehlung steht ueber dem Raster, nicht darin. */
.itt-finder__featured {
    margin-bottom: 1rem;
}

.itt-finder__featured:empty {
    display: none;
}

@media (min-width: 720px) {
    .itt-finder__product--recommended {
        flex-direction: row;
        align-items: center;
        gap: 1.5rem;
    }
    .itt-finder__product--recommended .itt-finder__product-image {
        flex: 0 0 200px;
    }
}

.itt-finder__badge {
    align-self: flex-start;
    margin-bottom: .6rem;
    padding: .25rem .7rem;
    border-radius: 999px;
    background: var(--itt-primary);
    color: #fff;
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.itt-finder__product-image {
    margin-bottom: .9rem;
    text-align: center;
}

.itt-finder__product-image img {
    max-width: 100%;
    height: auto;
    max-height: 170px;
    object-fit: contain;
}

.itt-finder__product-brand {
    color: var(--itt-gray);
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.itt-finder__product-name {
    margin: .2rem 0 .7rem;
    font-size: 1.02rem;
    font-weight: 600;
    line-height: 1.35;
}

/* Die Spec-Kacheln kommen als .it-listing-specs aus dem Theme und bringen
   ueber .productbox-column ihre Styles mit - hier wird nichts wiederholt. */
.itt-finder__product-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
}

.itt-finder__price {
    margin-top: auto;
    font-size: 1.2rem;
    font-weight: 700;
}

.itt-finder__price small {
    display: block;
    color: var(--itt-gray);
    font-size: .78rem;
    font-weight: 400;
}

/* --- Angaben und Ausgaenge -------------------------------------------- */

.itt-finder__answers {
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--itt-gray-medium);
}

.itt-finder__answers-title {
    margin: 0 0 .75rem;
    font-size: 1rem;
    font-weight: 700;
}

.itt-finder__answer-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.itt-finder__answer-list li {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: .5rem;
    padding: .55rem 0;
    border-bottom: 1px solid var(--itt-gray-lighter);
    font-size: .95rem;
}

.itt-finder__answer-question {
    flex: 1 1 14rem;
    color: var(--itt-gray);
}

.itt-finder__answer-value {
    font-weight: 600;
}

/* Antworten sind einzeln aenderbar, ohne den Finder neu zu starten. */
.itt-finder__answer-change {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    border: 0;
    background: none;
    padding: 0;
    color: var(--itt-primary);
    font-size: .88rem;
    text-decoration: underline;
    cursor: pointer;
}

/* Unsichtbar vergroesserte Trefferflaeche: mind. 24x24px (WCAG 2.5.8),
   ohne den Link optisch zu veraendern. */
.itt-finder__answer-change::after {
    content: "";
    position: absolute;
    inset: 50% 0 auto;
    min-height: 24px;
    transform: translateY(-50%);
}

.itt-finder__answer-change-icon img {
    width: .95rem;
    height: .95rem;
}

.itt-finder__exits {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    margin-top: 2rem;
}

.itt-finder__empty {
    padding: 2rem;
    border: 1px dashed var(--itt-gray-medium);
    border-radius: var(--itt-radius);
    text-align: center;
    color: var(--itt-gray);
}

/* Ueberschriften/Statuszeile bekommen per Skript den Fokus (Orientierung fuer
   Tastatur und Screenreader). Sie sind nicht bedienbar, ein Fokusring waere
   dort nur irritierend. */
.itt-finder [tabindex="-1"]:focus {
    outline: none;
}
