/*
 * Nährwert-/Zutaten-Tabelle
 *
 * Portiert aus dem Shopify-Theme (assets/qlf-product-info-table.css). Der dortige
 * Wrapper-Scope ".product__accordion" bzw. ".accordion .accordion__content" ist
 * hier durch den WordPress-Wrapper ".qlf-wp-nutrition" ersetzt; die inneren
 * Klassennamen bleiben identisch, damit die portierte JS-Logik unverändert greift.
 */

/* Hinweis: Die .qlf-info-toggle-Styles (FAQ-Accordion) liegen in
   quiz-result.css, damit sie überall verfügbar sind – nicht nur, wenn eine
   Nährwert-Tabelle geladen wird. */

/* Tabelle */
.qlf-wp-nutrition table {
    border: 0;
    text-align: center;
    width: 100%;
}

.qlf-wp-nutrition h {
    font-size: 1.1rem;
    font-weight: 700;
}

.qlf-wp-nutrition .nutritional-table-selector {
    margin-bottom: 20px;
}

.qlf-wp-nutrition .bundle-product-info-tables__item + .bundle-product-info-tables__item {
    margin-top: 32px;
    padding-top: 28px;
    border-top: 1px solid #d8d8d8;
}

.qlf-wp-nutrition .bundle-product-info-tables__title {
    margin: 0 0 18px;
    font-size: 17px;
    font-weight: 700;
}

.qlf-wp-nutrition .bundle-product-info-tables__selector ~ .bundle-product-info-tables__item {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}

.qlf-wp-nutrition .bundle-product-info-tables__selector ~ .bundle-product-info-tables__item .bundle-product-info-tables__title {
    display: none;
}

.qlf-wp-nutrition .nutritional-table-selector label {
    display: block;
    margin-bottom: 7px;
    font-size: 14px;
    font-weight: 700;
}

.qlf-wp-nutrition .nutritional-table-selector__field {
    position: relative;
    margin-bottom: 15px;
}

.qlf-wp-nutrition .nutritional-table-selector select {
    appearance: none;
    width: 100%;
    min-height: 48px;
    padding: 10px 44px 10px 14px;
    border: 1.5px solid #1a1c1d;
    border-radius: 8px;
    background: #fff;
    color: inherit;
    font: inherit;
    cursor: pointer;
}

.qlf-wp-nutrition .nutritional-table-selector__field > span {
    position: absolute;
    top: 50%;
    right: 15px;
    display: inline-flex;
    transform: translateY(-50%);
    pointer-events: none;
}

.qlf-wp-nutrition .nutritional-table-selector__field svg {
    width: 12px;
    height: 12px;
}

.qlf-wp-nutrition .nutritional-table-native-select {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.qlf-wp-nutrition .nutritional-table-custom-trigger {
    position: relative;
    width: 100%;
    min-height: 48px;
    padding: 12px 44px 12px 14px;
    border: 1.5px solid #1a1c1d;
    border-radius: 6px;
    background: #fff;
    color: inherit;
    display: flex;
    align-items: center;
    text-align: left;
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

/*
 * Pfeil am Dropdown-Trigger.
 *
 * nutrition-table.js versteckt den nativen <select> und setzt dessen
 * Chevron-<span> auf hidden (enhanceDropdown), sichtbar ist nur noch dieser
 * Button. Der Pfeil kommt daher als Pseudo-Element – gleiche Optik wie bei den
 * Varianten-Dropdowns und den <summary>-Togglen im Seiteninhalt.
 *
 * Farbe fest als #1a1c1d (= Rahmen-/Textfarbe des Triggers): in einer
 * Data-URI ist das SVG ein eigenes Dokument, currentColor würde dort nicht auf
 * die Elementfarbe auflösen, sondern auf Schwarz zurückfallen.
 */
.qlf-wp-nutrition .nutritional-table-custom-trigger::after {
    content: "";
    position: absolute;
    top: 50%;
    right: 12px;
    width: 15px;
    height: 15px;
    background-image: url("data:image/svg+xml,%3Csvg width='15' height='15' viewBox='0 0 20 20' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5 7.5L10 12.5L15 7.5' stroke='%231a1c1d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: contain;
    transform: translateY(-50%);
    transition: transform 0.1s ease;
    pointer-events: none;
}

/* Geöffnete Liste: Pfeil dreht nach oben. aria-expanded pflegt enhanceDropdown. */
.qlf-wp-nutrition .nutritional-table-custom-trigger[aria-expanded="true"]::after {
    transform: translateY(-50%) rotate(180deg);
}

.qlf-wp-nutrition .nutritional-table-custom-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    width: 100%;
    padding: 6px;
    margin: 0;
    border: 1px solid #e2e0db;
    border-radius: 6px;
    background: #fff;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
    list-style: none;
    overflow: auto;
    z-index: 5;
}

.qlf-wp-nutrition .nutritional-table-custom-list:not(.visible) {
    display: none;
}

.qlf-wp-nutrition .nutritional-table-custom-option {
    padding: 12px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
}

.qlf-wp-nutrition .nutritional-table-custom-option:hover,
.qlf-wp-nutrition .nutritional-table-custom-option.qlf-selected {
    background: #f1f1f1;
}

.qlf-wp-nutrition .nutritional-table-custom-option.qlf-selected {
    font-weight: 700;
    margin: 5px 0;
}

.qlf-wp-nutrition .nutritional-table tbody tr {
    border-bottom: 2px solid black;
    padding: 6px 0;
}

.qlf-wp-nutrition .nutritional-table {
    padding-bottom: 15px;
    margin-bottom: 15px;
}

.qlf-wp-nutrition .nutritional-table thead {
    display: block;
    font-weight: 700;
    font-size: 14px;
}

.qlf-wp-nutrition .nutritional-table thead,
.qlf-wp-nutrition .column-headline {
    border-bottom: 2px solid #000;
    font-weight: 700 !important;
    padding: 0;
}

.qlf-wp-nutrition .nutritional-table thead tr th:first-child,
.qlf-wp-nutrition .column-headline {
    font-size: 14px;
    font-weight: 700;
}

.qlf-wp-nutrition table thead,
.qlf-wp-nutrition table tbody {
    display: flex;
    flex-direction: column;
    font-size: 14px;
}

.qlf-wp-nutrition table tr {
    padding: 11px 0;
    display: flex;
    width: 100%;
}

.qlf-wp-nutrition table th,
.qlf-wp-nutrition table td {
    text-align: right;
}

/* Three fixed-proportion columns: left 45% | middle 35% | right 30%.
   flex-grow ratios (with basis 0) keep these proportions constant regardless
   of which portion column is currently sliding through the middle slot. */

/* Left column: nutrient name. */
.qlf-wp-nutrition table th:first-child,
.qlf-wp-nutrition table td:first-child {
    flex: 45;
    text-align: left;
}

/* Numeric data cells stay on a single line. */
.qlf-wp-nutrition table td:not(:first-child) {
    white-space: nowrap;
}

/* Headers carry long labels like "%NRV* pro Portion¹ (Erdbeere)"; allow them
   to wrap so the start of the text isn't clipped on mobile. */
.qlf-wp-nutrition table th:not(:first-child) {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    white-space: normal;
    overflow-wrap: anywhere;
}

.qlf-wp-nutrition table thead th {
    font-weight: 700;
}

/* Middle column: the active scrollable portion column. */
.qlf-wp-nutrition table thead th:not(.table-cell):not(:first-child),
.qlf-wp-nutrition table tbody td.table-slide {
    flex: 35;
}

/* Right column: the paired %NRV column. */
.qlf-wp-nutrition table th.table-cell:not(:first-child),
.qlf-wp-nutrition table td.table-cell:not(:first-child) {
    flex: 30;
}

.qlf-wp-nutrition .nutritional-table th.table-cell,
.qlf-wp-nutrition .nutritional-table td.table-cell {
    opacity: 1;
}

.qlf-wp-nutrition tbody tr {
    display: flex;
    justify-content: space-between;
    width: 100%;
    border-bottom: 1px solid #eaeaea;
}

.qlf-wp-nutrition tbody tr:first-child {
    margin-top: 0;
}

.qlf-wp-nutrition p.annotations {
    font-size: 0.75rem;
    margin-bottom: 0;
    color: #84868a;
}

.qlf-wp-nutrition .table__ingredients .column-headline {
    padding: 15px 6px;
    font-weight: 700;
}

.qlf-wp-nutrition .table__ingredients p {
    padding: 0 6px;
    font-size: 14px;
}

/*
 * Nährwert-/Zutaten-Popup (Modal)
 *
 * Portiert aus dem Shopify-Theme (assets/qlf-product-info-popup.css). Scope
 * ".product-info-popup" -> ".qlf-info-popup", CSS-Variablen durch feste Werte
 * ersetzt.
 */
.qlf-info-popup {
    display: block;
    border-top: 1px solid #e2e0db;
    font-family: 'Lato', sans-serif;
}

.qlf-info-popup__trigger {
    appearance: none;
    width: 100%;
    min-height: 58px;
    padding: 15px 0;
    border: 0;
    background: transparent;
    color: inherit;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    font: inherit;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
}

.qlf-info-popup__trigger-icon {
    position: relative;
    width: 16px;
    height: 16px;
    display: inline-block;
    flex: 0 0 16px;
}

.qlf-info-popup__trigger-icon::before,
.qlf-info-popup__trigger-icon::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 14px;
    height: 1.5px;
    border-radius: 1px;
    background: currentColor;
    transform: translate(-50%, -50%);
}

.qlf-info-popup__trigger-icon::after {
    transform: translate(-50%, -50%) rotate(90deg);
}

.qlf-info-popup__dialog {
    width: min(680px, calc(100% - 32px));
    max-height: min(820px, calc(100dvh - 40px));
    margin: auto;
    padding: 0;
    border: 0;
    border-radius: 16px;
    background: #fff;
    color: #1a1c1d;
    overflow: hidden;
    box-shadow: 0 18px 70px rgba(0, 0, 0, 0.22);
}

.qlf-info-popup__dialog:not([open]) {
    display: none;
}

.qlf-info-popup__dialog::backdrop {
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(7px);
    -webkit-backdrop-filter: blur(7px);
}

.qlf-info-popup__panel {
    max-height: min(820px, calc(100dvh - 40px));
    display: flex;
    flex-direction: column;
}

.qlf-info-popup__header {
    padding: 22px 64px 18px 24px;
    border-bottom: 1px solid #e2e0db;
    position: relative;
    flex: 0 0 auto;
}

.qlf-info-popup__header h2 {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    line-height: 1.2;
}

.qlf-info-popup__close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    padding: 10px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: inherit;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.qlf-info-popup__close:hover {
    background: rgba(26, 28, 29, 0.06);
}

.qlf-info-popup__content {
    min-height: 0;
    flex: 1 1 auto;
    padding: 24px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.qlf-info-popup__content .annotations {
    font-size: 12px;
    color: #b9b9b9;
}

.qlf-info-popup__content .table__ingredients p {
    font-size: 14px;
}

@media screen and (max-width: 768px) {
    .qlf-info-popup__dialog {
        width: 100%;
        max-width: none;
        max-height: calc(100dvh - 24px);
        margin: auto 0 0;
        border-radius: 16px 16px 0 0;
    }

    .qlf-info-popup__panel {
        max-height: calc(100dvh - 24px);
    }

    .qlf-info-popup__content {
        padding: 20px 16px max(24px, env(safe-area-inset-bottom));
    }
}

@media (prefers-reduced-motion: no-preference) {
    .qlf-info-popup__dialog[open] {
        animation: qlf-info-popup-in 180ms ease-out;
    }

    @keyframes qlf-info-popup-in {
        from {
            opacity: 0;
            transform: translateY(16px) scale(0.98);
        }

        to {
            opacity: 1;
            transform: none;
        }
    }
}
