/* ============================================================
   Flavor Menu – Allergens & Nutrition
   ============================================================ */

/* ── Card Flip ───────────────────────────────────────────── */

.flavor-card--flippable {
    perspective: 1000px;
    cursor: pointer;
    position: relative;
}

/* Horizontal card grid fix */
.flavor-hcard.flavor-card--flippable {
    display: block;
}
.flavor-hcard .flavor-card__flipper {
    width: 100%;
}
.flavor-hcard .flavor-card__front {
    display: grid;
    grid-template-columns: 160px 1fr;
    width: 100%;
}
/* Horizontal: image fills full card height (no fixed aspect-ratio) */
.flavor-hcard .flavor-card__front .flavor-hcard__img {
    aspect-ratio: unset;
    align-self: stretch;
    min-height: 120px;
}
@media ( max-width: 560px ) {
    .flavor-hcard .flavor-card__front {
        grid-template-columns: 100px 1fr;
    }
}

/* Featured hero flip */
.flavor-featured__hero.flavor-card--flippable {
    display: block;
    overflow: visible;
    background: none;
    border: none;
}
.flavor-featured__hero.flavor-card--flippable .flavor-card__front {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 320px;
    overflow: hidden;
    border-radius: var( --fm-radius, 12px );
    background: var( --fm-surface, #1a1a1a );
    border: 1px solid var( --fm-border, rgba( 255, 255, 255, 0.1 ) );
}
@media ( max-width: 680px ) {
    .flavor-featured__hero.flavor-card--flippable .flavor-card__front {
        grid-template-columns: 1fr;
    }
}

/* Featured mini flip */
.flavor-featured__mini.flavor-card--flippable {
    overflow: visible;
    background: none;
    border: none;
    box-shadow: none;
}
.flavor-featured__mini.flavor-card--flippable .flavor-card__front {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: var( --fm-radius, 12px );
    background: var( --fm-surface, #1a1a1a );
    border: 1px solid var( --fm-border, rgba( 255, 255, 255, 0.1 ) );
    height: 100%;
}

.flavor-card__flipper {
    position: relative;
    width: 100%;
    transform-style: preserve-3d;
    transition: transform 0.55s cubic-bezier( 0.4, 0.2, 0.2, 1 );
}

.flavor-card--flippable.is-flipped .flavor-card__flipper {
    transform: rotateY( 180deg );
}

.flavor-card__front,
.flavor-card__back {
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.flavor-card__front {
    width: 100%;
}

.flavor-card__back {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform: rotateY( 180deg );
    background-color: var( --fm-surface, #1a1a1a );
    border-radius: 12px;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-sizing: border-box;
}

.flavor-card__back-close {
    position: absolute;
    top: 10px;
    right: 12px;
    background: none;
    border: none;
    color: var( --fm-text-muted, #8a8580 );
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
}

.flavor-card__back-close:hover {
    color: var( --fm-text, #e8e4df );
    background: rgba( 255, 255, 255, 0.06 );
}

.flavor-card__back-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var( --fm-heading, #f5f0eb );
    padding-right: 24px;
}

.flavor-card__back-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* Horizontal back: side-by-side layout */
.flavor-card__back-body {
    display: flex;
    gap: 16px;
    flex: 1;
    align-items: flex-start;
}
.flavor-card__back-allergens {
    flex: 1;
    min-width: 0;
}
.flavor-card__back-nutrition {
    flex: 1;
    min-width: 0;
}

/* Mobile: show compact string, hide nutrition table */
.flavor-card__back-nutrition-compact {
    display: none;
    font-size: 11px;
    color: var( --fm-text-muted, #8a8580 );
    line-height: 1.8;
}

@media ( max-width: 560px ) {
    .flavor-card__back-body {
        flex-direction: column;
    }
    .flavor-card__back-nutrition-compact {
        display: block;
    }
    .flavor-card__back-nutrition .flavor-allergen-nutrition-label,
    .flavor-card__back-nutrition .flavor-allergen-nutrition-rows {
        display: none;
    }
}

/* full chips on card back: abbr + name stacked */
.flavor-allergen-chip--full {
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 10px;
    min-width: 44px;
    text-align: center;
    font-size: 11px;
    cursor: default;
}
.flavor-allergen-chip--full strong {
    font-size: 13px;
    display: block;
}
.flavor-allergen-chip--full span {
    font-weight: 400;
    white-space: nowrap;
}

/* ── Card Image: Allergen Hint Badge ─────────────────────── */

.flavor-menu__card-image,
.flavor-hcard__img,
.flavor-featured__hero-img,
.flavor-featured__mini-img {
    position: relative; /* ensure absolute children work */
}

.flavor-card-allergen-hint {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba( 0, 0, 0, 0.55 );
    backdrop-filter: blur( 4px );
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    color: #fff;
    z-index: 2;
}

.flavor-card-allergen-hint svg {
    width: 14px;
    height: 14px;
}

/* ── Allergen Chip (shared, small) ───────────────────────── */

.flavor-allergen-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: var( --fm-accent-soft, rgba( 201, 168, 76, 0.12 ) );
    color: var( --fm-accent, #c9a84c );
    border: 1px solid currentColor;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.4;
    letter-spacing: 0.04em;
}

/* ── ⓘ Info Button — icon only, no border ring ───────────── */

.flavor-allergen-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: none;
    border: none;
    color: var( --fm-accent, #c9a84c );
    cursor: pointer;
    padding: 0;
    margin-left: 7px;
    vertical-align: middle;
    flex-shrink: 0;
    transition: color 0.15s;
    line-height: 1;
}

.flavor-allergen-btn svg {
    width: 18px;
    height: 18px;
    stroke-width: 2;
    overflow: visible;
}

/* SVG circle: outline by default, filled on hover/active */
.flavor-allergen-btn svg circle {
    fill: none;
    stroke: currentColor;
    transition: fill 0.15s, stroke 0.15s;
}

.flavor-allergen-btn svg line,
.flavor-allergen-btn svg polyline {
    stroke: currentColor;
    transition: stroke 0.15s;
}

.flavor-allergen-btn:hover svg circle,
.flavor-allergen-btn.is-active svg circle {
    fill: currentColor;
}

.flavor-allergen-btn:hover svg line,
.flavor-allergen-btn:hover svg polyline,
.flavor-allergen-btn.is-active svg line,
.flavor-allergen-btn.is-active svg polyline {
    stroke: var( --fm-surface, #1a1a1a );
}

/* ── Floating Popup — always centered in viewport ────────── */

.flavor-allergen-popup {
    position: fixed;
    z-index: 9999;
    background: var( --fm-surface, #1a1a1a );
    border: 1px solid var( --fm-border, rgba( 255, 255, 255, 0.1 ) );
    border-radius: 10px;
    padding: 16px;
    width: 280px;
    max-width: calc( 100vw - 32px );
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba( 0, 0, 0, 0.55 );
    left: 50%;
    top: 50%;
    transform: translate( -50%, -50% );
}

.flavor-allergen-popup__title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var( --fm-heading, #f5f0eb );
    margin-bottom: 10px;
    padding-right: 20px;
}

.flavor-allergen-popup__close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    color: var( --fm-text-muted, #8a8580 );
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    transition: color 0.15s;
}

.flavor-allergen-popup__close:hover {
    color: var( --fm-text, #e8e4df );
}

.flavor-allergen-popup__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 8px;
}

.flavor-allergen-popup__names {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-bottom: 10px;
}

.flavor-allergen-popup__name-item {
    font-size: 12px;
    color: var( --fm-text, #e8e4df );
    line-height: 1.5;
}

.flavor-allergen-popup__name-item strong {
    color: var( --fm-accent, #c9a84c );
    margin-right: 3px;
}

.flavor-allergen-popup__nutrition {
    border-top: 1px solid var( --fm-border, rgba( 255, 255, 255, 0.08 ) );
    padding-top: 10px;
    margin-top: 2px;
}

/* ── Nutrition Rows (dotted leader lines) ────────────────── */

.flavor-allergen-nutrition-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var( --fm-text-muted, #8a8580 );
    margin: 0 0 6px;
}

.flavor-allergen-nutrition-rows {
    width: 100%;
}

.flavor-allergen-nutrition-row {
    display: flex;
    align-items: baseline;
    padding: 2px 0;
}

.flavor-allergen-nutrition-row__label {
    font-size: 12px;
    color: var( --fm-text, #e8e4df );
    flex-shrink: 0;
    padding-left: 2px;
}

.flavor-allergen-nutrition-row__dots {
    flex: 1;
    border-bottom: 1px dotted var( --fm-border, rgba( 255, 255, 255, 0.2 ) );
    margin: 0 6px 3px;
    height: 0;
    align-self: flex-end;
}

.flavor-allergen-nutrition-row__value {
    font-size: 12px;
    font-weight: 600;
    color: var( --fm-text, #e8e4df );
    flex-shrink: 0;
    white-space: nowrap;
    padding-right: 2px;
}

/* ── Table Layout: chips + popover ──────────────────────── */

.flavor-table__allergen-wrap {
    position: relative;
    margin-top: 5px;
}

.flavor-allergen-chips-row {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    cursor: pointer;
}

.flavor-allergen-chips-row:hover .flavor-allergen-chip {
    border-color: var( --fm-accent, #c9a84c );
}

.flavor-allergen-popover {
    position: absolute;
    bottom: calc( 100% + 6px );
    left: 0;
    z-index: 100;
    background-color: var( --fm-surface, #1a1a1a );
    border: 1px solid var( --fm-border, #2a2a2a );
    border-radius: 8px;
    padding: 12px 14px;
    min-width: 200px;
    max-width: 300px;
    box-shadow: 0 6px 20px rgba( 0, 0, 0, 0.35 );
}

.flavor-allergen-popover__list {
    font-size: 12px;
    color: var( --fm-text, #e8e4df );
    line-height: 1.9;
    margin-bottom: 8px;
}

.flavor-allergen-popover .flavor-allergen-nutrition-label,
.flavor-allergen-popover .flavor-allergen-nutrition-rows {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid var( --fm-border, #2a2a2a );
}

/* ── Compact layout: row click + btn position ────────────── */

.flavor-compact__item.has-allergens {
    cursor: pointer;
}

/* ── Allergen Legend ─────────────────────────────────────── */

.flavor-allergen-legend {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var( --fm-border, #2a2a2a );
}

.flavor-allergen-legend__title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var( --fm-text-muted, #8a8580 );
    margin-bottom: 8px;
}

.flavor-allergen-legend__items {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 20px;
}

.flavor-allergen-legend__item {
    font-size: 12px;
    color: var( --fm-text-muted, #8a8580 );
}

.flavor-allergen-legend__item strong {
    color: var( --fm-accent, #c9a84c );
}
