/*
 * Produkt-Downloads – Grundgestaltung.
 *
 * Zwei Dinge sind hier Absicht:
 *
 * 1. Alle Farben leiten sich aus der Textfarbe des Themes ab (currentColor).
 *    Damit passt die Liste in helle wie dunkle Layouts, ohne dass wir die
 *    Hintergrundfarbe kennen müssen. Eigene Werte setzt man auf .pd.
 * 2. Jede Regel steht unter .pd, und bei allem, was Themes üblicherweise selbst
 *    stylen (button, a, input, ul), steht zusätzlich der Elementtyp davor.
 *    Themes treffen Buttons gern über [type="button"] – ohne den Elementtyp
 *    gewinnt deren Regel, und die Filter-Chips sehen aus wie Theme-Buttons.
 */
.pd {
    --pd-border: color-mix(in srgb, currentColor 18%, transparent);
    --pd-border-strong: color-mix(in srgb, currentColor 35%, transparent);
    --pd-muted: color-mix(in srgb, currentColor 75%, transparent);
    --pd-hover: color-mix(in srgb, currentColor 8%, transparent);
    --pd-active: color-mix(in srgb, currentColor 15%, transparent);
    --pd-accent: currentColor;
    --pd-radius: 6px;
    --pd-gap: 1rem;
}

/* Themes setzen display-Werte auf Buttons und Listenelemente und hebeln damit
   das [hidden]-Attribut aus – ohne das filtert die Suche ins Nichts. */
.pd [hidden] {
    display: none !important;
}

/* Steuerung ------------------------------------------------------------- */

.pd .pd__controls {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: var(--pd-gap);
    margin-bottom: 1.5rem;
}

.pd .pd__search {
    position: relative;
    flex: 1 1 18rem;
}

.pd .pd__search-label {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
    color: var(--pd-muted);
}

.pd input.pd__search-input {
    box-sizing: border-box;
    width: 100%;
    padding: 0.625rem 5.5rem 0.625rem 0.75rem;
    border: 1px solid var(--pd-border-strong);
    border-radius: var(--pd-radius);
    background: transparent;
    color: inherit;
    font: inherit;
}

.pd button.pd__search-reset {
    position: absolute;
    right: 0.375rem;
    bottom: 0.375rem;
    padding: 0.25rem 0.5rem;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--pd-muted);
    font: inherit;
    font-size: 0.8125rem;
    cursor: pointer;
}

.pd button.pd__search-reset:hover {
    color: inherit;
    text-decoration: underline;
}

.pd .pd__filter {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.pd button.pd__chip {
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--pd-border-strong);
    border-radius: 999px;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 0.875rem;
    font-weight: 400;
    line-height: 1.3;
    text-transform: none;
    letter-spacing: normal;
    cursor: pointer;
}

.pd button.pd__chip:hover {
    background: var(--pd-hover);
}

/* Bewusst ohne gefüllte Fläche: die Gegenfarbe für den Text hinge vom
   Theme-Hintergrund ab, den wir nicht kennen. */
.pd button.pd__chip.is-active {
    border-color: var(--pd-accent);
    background: var(--pd-active);
    color: inherit;
    font-weight: 600;
}

.pd .pd__count {
    flex: 0 0 auto;
    margin: 0;
    color: var(--pd-muted);
    font-size: 0.875rem;
}

/* Liste ----------------------------------------------------------------- */

.pd ul.pd__list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.pd ul.pd__list > li.pd__item {
    margin: 0;
    padding: 0;
    border-bottom: 1px solid var(--pd-border);
    list-style: none;
}

.pd ul.pd__list > li.pd__item::before,
.pd ul.pd__downloads > li.pd__download::before {
    content: none;
}

.pd .pd__summary {
    display: flex;
    align-items: center;
    gap: var(--pd-gap);
    padding: 0.875rem 0;
    cursor: pointer;
    list-style: none;
}

.pd .pd__summary::-webkit-details-marker {
    display: none;
}

.pd .pd__summary::marker {
    content: none;
}

.pd .pd__summary:focus-visible {
    outline: 2px solid var(--pd-accent);
    outline-offset: 2px;
}

.pd .pd__media {
    flex: 0 0 auto;
    width: 4rem;
}

.pd .pd__media img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 4px;
}

.pd .pd__text {
    display: flex;
    flex: 1 1 auto;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 0.75rem;
}

.pd .pd__title {
    flex: 1 1 auto;
    font-weight: 600;
}

.pd .pd__manufacturer,
.pd .pd__meta {
    color: var(--pd-muted);
    font-size: 0.875rem;
}

.pd .pd__indicator {
    flex: 0 0 auto;
    width: 0.625rem;
    height: 0.625rem;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg) translate(-2px, -2px);
    transition: transform 0.15s ease;
}

.pd .pd__details[open] .pd__indicator {
    transform: rotate(-135deg) translate(-2px, -2px);
}

/* Downloads ------------------------------------------------------------- */

.pd ul.pd__downloads {
    margin: 0 0 1rem;
    padding: 0;
    list-style: none;
}

.pd ul.pd__downloads > li.pd__download {
    margin: 0 0 0.375rem;
    padding: 0;
    list-style: none;
}

.pd a.pd__download-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--pd-border);
    border-radius: var(--pd-radius);
    color: inherit;
    text-decoration: none;
}

.pd a.pd__download-link:hover,
.pd a.pd__download-link:focus-visible {
    border-color: var(--pd-border-strong);
    background: var(--pd-hover);
    color: inherit;
}

.pd .pd__download-icon {
    flex: 0 0 auto;
    min-width: 2.75rem;
    padding: 0.25rem 0.375rem;
    border: 1px solid var(--pd-border-strong);
    border-radius: 4px;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-align: center;
}

.pd .pd__download-body {
    display: flex;
    flex-direction: column;
}

.pd .pd__download-meta {
    color: var(--pd-muted);
    font-size: 0.8125rem;
}

.pd .pd__empty {
    padding: 2rem 0;
    color: var(--pd-muted);
    text-align: center;
}

/* Kacheln --------------------------------------------------------------- */

.pd--tiles ul.pd__list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
    /* ohne start würden Nachbarkacheln mitwachsen, sobald eine aufgeklappt wird */
    align-items: start;
    gap: var(--pd-gap);
}

.pd--tiles ul.pd__list > li.pd__item {
    border: 1px solid var(--pd-border);
    border-radius: var(--pd-radius);
    overflow: hidden;
}

.pd--tiles .pd__summary {
    flex-direction: column;
    align-items: stretch;
    padding: 0;
}

.pd--tiles .pd__media {
    width: 100%;
}

.pd--tiles .pd__media img {
    border-radius: 0;
    aspect-ratio: 4 / 3;
    object-fit: cover;
}

.pd--tiles .pd__text {
    padding: 0.75rem;
}

.pd--tiles .pd__indicator {
    margin: 0 0.75rem 0.75rem auto;
}

.pd--tiles ul.pd__downloads {
    padding: 0 0.75rem;
}

@media (max-width: 40em) {
    .pd .pd__controls {
        flex-direction: column;
        align-items: stretch;
    }

    /* In Spaltenrichtung würde die flex-basis von 18rem zur Mindesthöhe werden */
    .pd .pd__search {
        flex: 0 0 auto;
    }

    /* nicht für Kacheln – dort füllt das Bild die ganze Kachelbreite */
    .pd:not(.pd--tiles) .pd__media {
        width: 3rem;
    }
}
