/**
 * Restaurant Card - Yemeksepeti Style
 * FIXED: Große Food-Bilder, Badges, Clean Layout
 * CSP-konform
 */

/* === Card Container === */
.restaurant-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: all 0.25s;
    cursor: pointer;
    position: relative;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.restaurant-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

/* === Image Section === */
.restaurant-image-wrapper {
    position: relative;
    width: 100%;
    /* 4:3 = Format, in dem die Partner-Bilder tatsaechlich geliefert werden
       (Beispiel Orient Borken: 362x272 = 1.33). Vorher stand hier 16/10 = 1.6 —
       zusammen mit 'cover' wurde dadurch oben und unten abgeschnitten, beim
       Orient-Bild die komplette Kopfzeile "Pizzeria & Doener" samt Logo.
       Nebeneffekt: .skeleton-image nutzt bereits 4/3, der Layout-Sprung beim
       Nachladen des Bildes faellt damit ebenfalls weg. */
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: #f8f8f8;
}

/* Unscharfer Fuellhintergrund aus demselben Bild.
   ---------------------------------------------------------------------------
   'cover' fuellt die Box, schneidet aber ab. 'contain' schneidet nichts ab,
   laesst dafuer Raender — beim Midyat-47-Bild oben und unten deutlich sichtbar.
   Beides zugleich ist bei abweichendem Seitenverhaeltnis unmoeglich.

   Loesung: Dasselbe Bild liegt ein zweites Mal darunter, formatfuellend, stark
   unscharf. Der Rahmen ist damit farblich gefuellt statt weiss, und das
   eigentliche Bild bleibt vollstaendig sichtbar. Ein 4:3-Bild verdeckt den
   Hintergrund ohnehin komplett — sichtbar wird er nur dort, wo sonst eine
   Luecke waere.

   Kein zweiter Netzwerk-Request: gleiche URL, der Browser liefert sie aus dem
   Cache. aria-hidden, weil rein dekorativ. */
.restaurant-image-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* scale gleicht die weichen Kanten aus, die blur() am Rand erzeugt */
    transform: scale(1.15);
    filter: blur(18px) saturate(1.3) brightness(0.92);
    z-index: 0;
    pointer-events: none;
}

.restaurant-image {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    /* 'contain' garantiert, dass NIE etwas abgeschnitten wird (Wunsch 2026-08-24).
       Die Luecken, die dabei bei abweichenden Formaten entstehen, fuellt
       .restaurant-image-bg — siehe dort. */
    object-fit: contain;
    transition: transform 0.4s;
}

.restaurant-card:hover .restaurant-image {
    transform: scale(1.08);
}

/* Hintergrund zieht beim Hover leicht mit, sonst entsteht am Rand ein Spalt. */
.restaurant-card:hover .restaurant-image-bg {
    transform: scale(1.22);
    transition: transform 0.4s;
}

/* Wer Bewegung reduziert haben moechte, bekommt keinen Zoom. */
@media (prefers-reduced-motion: reduce) {
    .restaurant-image,
    .restaurant-image-bg {
        transition: none;
    }
    .restaurant-card:hover .restaurant-image {
        transform: none;
    }
    .restaurant-card:hover .restaurant-image-bg {
        transform: scale(1.15);
    }
}

/* === Image Placeholder === */
.restaurant-image-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--theme-primary, #667eea) 0%, var(--theme-secondary, #764ba2) 100%);
}

.restaurant-image-placeholder i {
    font-size: 48px;
    color: white;
    opacity: 0.8;
}

/* Color variations for placeholders */
.restaurant-card:nth-child(6n+1) .restaurant-image-placeholder { background: linear-gradient(135deg, #ff6b6b 0%, #ee5a5a 100%); }
.restaurant-card:nth-child(6n+2) .restaurant-image-placeholder { background: linear-gradient(135deg, #4ecdc4 0%, #44a8a0 100%); }
.restaurant-card:nth-child(6n+3) .restaurant-image-placeholder { background: linear-gradient(135deg, #45b7d1 0%, #3a9bb5 100%); }
.restaurant-card:nth-child(6n+4) .restaurant-image-placeholder { background: linear-gradient(135deg, #96ceb4 0%, #7fb89e 100%); }
.restaurant-card:nth-child(6n+5) .restaurant-image-placeholder { background: linear-gradient(135deg, #ffeaa7 0%, #fdcb6e 100%); }
.restaurant-card:nth-child(6n+6) .restaurant-image-placeholder { background: linear-gradient(135deg, #a29bfe 0%, #6c5ce7 100%); }

/* === Badges (Top Left) === */
.badge-container {
    position: absolute;
    top: 12px;
    left: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 10;
}

.badge {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    color: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    display: inline-block;
    max-width: fit-content;
}

.badge-yeclub {
    background: var(--color-danger, #e21b1b);
}

.badge-sponsored {
    background: var(--color-sponsored, #9333ea);
}

.badge-discount {
    background: var(--color-danger, #e21b1b);
}

.badge-express {
    background: var(--theme-success, #16a34a);
}

.badge-new {
    background: var(--color-info, #0ea5e9);
}

/* === "Öne Çıkan" Badge (Top Right) === */
.badge-featured {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 6px 12px;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(8px);
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    color: white;
    z-index: 10;
}

/* === DEMO-Vorschau-Badge (Top Right, ersetzt Featured wenn beide) === */
.badge-demo {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 6px 12px;
    background: linear-gradient(135deg, #fd7e14 0%, #f39c12 100%);
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 4px rgba(253, 126, 20, 0.3);
    z-index: 11;  /* ueber Featured-Badge */
}

/* === Card Body === */
.restaurant-card-body {
    padding: 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* === Restaurant Header === */
.restaurant-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.restaurant-name {
    font-size: 17px;
    font-weight: 700;
    color: #333;
    margin: 0;
    line-height: 1.3;
    flex: 1;
}

.restaurant-rating {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    background: var(--theme-success, #16a34a);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
    margin-left: 8px;
    text-decoration: none;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.15s;
}

a.restaurant-rating:hover {
    color: white;
    opacity: 0.85;
    transform: scale(1.05);
}

.restaurant-rating i {
    font-size: 11px;
}

.restaurant-rating.rating-low {
    background: var(--theme-warning, #f59e0b);
}

.restaurant-rating .rating-count {
    font-weight: 400;
    opacity: 0.8;
    margin-left: 2px;
}

/* === Restaurant Info (Meta) === */
.restaurant-info {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
    font-size: 14px;
    color: #666;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.info-item i {
    font-size: 13px;
    color: #999;
}

.info-separator {
    width: 4px;
    height: 4px;
    background: #ddd;
    border-radius: 50%;
}

/* === Cuisine Tags === */
.cuisine-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.cuisine-tag {
    padding: 5px 10px;
    background: #f5f5f5;
    border-radius: 6px;
    font-size: 12px;
    color: #666;
    font-weight: 600;
}

/* === Footer (Delivery Info) === */
.restaurant-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 12px;
    border-top: 1px solid #f0f0f0;
    margin-top: auto;
}

.delivery-info {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: #666;
}

.delivery-time,
.delivery-fee {
    display: flex;
    align-items: center;
    gap: 4px;
}

.delivery-time i {
    color: var(--theme-success, #16a34a);
    font-size: 12px;
}

.delivery-fee i {
    color: var(--color-danger, #e21b1b);
    font-size: 12px;
}

.min-order {
    font-size: 13px;
    color: #666;
    font-weight: 600;
}

.free-delivery {
    color: var(--theme-success, #16a34a);
    font-weight: 700;
}

/* === Info Link (SEO Detail Page) === */
.restaurant-info-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #f0f0f0;
    color: var(--theme-primary, #667eea);
    text-decoration: none;
    transition: all 0.2s;
    flex-shrink: 0;
}

.restaurant-info-link:hover {
    background: var(--theme-primary, #667eea);
    color: white;
}

.restaurant-info-link i {
    font-size: 14px;
}

/* === Closed Overlay === */
.status-closed {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.65);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
}

.status-closed-text {
    background: white;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 700;
    color: #333;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* === Sponsored Card Highlight === */
.restaurant-card.sponsored {
    box-shadow: 0 2px 12px rgba(226,27,27,0.15);
}

.restaurant-card.sponsored:hover {
    box-shadow: 0 8px 28px rgba(226,27,27,0.2);
}

/* === Special Promotions Banner === */
.promo-banner {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(90deg, var(--theme-warning, #fbbf24) 0%, color-mix(in srgb, var(--theme-warning, #f59e0b) 90%, black) 100%);
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 700;
    color: #78350f;
    text-align: center;
    z-index: 15;
}

.promo-banner.discount-20 {
    background: linear-gradient(90deg, var(--color-danger, #e21b1b) 0%, color-mix(in srgb, var(--color-danger, #b91c1c) 85%, black) 100%);
    color: white;
}

/* === Skeleton Loading === */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-image {
    width: 100%;
    aspect-ratio: 4 / 3;
}

.skeleton-text {
    height: 16px;
    border-radius: 4px;
    margin-bottom: 10px;
}

.skeleton-text.short {
    width: 60%;
}

.skeleton-text.medium {
    width: 80%;
}

/* === Responsive === */
@media (max-width: 768px) {
    .restaurant-card-body {
        padding: 14px;
    }

    .restaurant-name {
        font-size: 16px;
    }

    .restaurant-info {
        font-size: 13px;
    }

    .badge-container {
        top: 10px;
        left: 10px;
    }

    .badge {
        padding: 5px 10px;
        font-size: 11px;
    }
}

/* ============================================================
   Click-Feedback fuer Restaurant-Cards (UX-Fix 2026-05-26)
   ============================================================
   Vorher: Klick auf eine Card hat sofort einen Health-Check ueber
   fetch() gemacht (~200-500ms) — ohne UI-Feedback. Der Kunde dachte
   nichts passiert und hat mehrfach geklickt -> Race-Conditions,
   mehrere geoeffnete Tabs.

   Jetzt: sofort nach erstem Klick wird .is-clicking gesetzt, die Card
   bekommt visuelles Feedback (Spinner-Overlay + halbtransparent +
   pointer-events: none gegen Doppel-Click).
*/
.restaurant-card.is-clicking {
    pointer-events: none;
    opacity: 0.7;
    transform: scale(0.99);
    transition: opacity 0.15s ease, transform 0.15s ease;
    position: relative;
}

/* Spinner-Overlay zentriert ueber der Card */
.restaurant-card.is-clicking::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 36px;
    height: 36px;
    margin: -18px 0 0 -18px;
    border: 3px solid rgba(255, 255, 255, 0.85);
    border-top-color: var(--theme-primary, #E87722);
    border-radius: 50%;
    animation: oto-card-spin 0.8s linear infinite;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
    z-index: 10;
}

/* Dunkler Overlay damit der Spinner besser sichtbar ist */
.restaurant-card.is-clicking::before {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.15);
    border-radius: inherit;
    z-index: 9;
    pointer-events: none;
}

@keyframes oto-card-spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .restaurant-card.is-clicking::after {
        animation: none;
    }
}
