/* Brand Color Variables */
:root {
    --flaeske-brand-green: #4A7C59;
    --flaeske-brand-gold: #D4A017;
    --flaeske-brand-cream: #F9F7F2;
    --flaeske-brand-charcoal: #2C2C2C;
    --flaeske-brand-error: #EF4444;
    --flaeske-gray-100: #f3f4f6;
    --flaeske-gray-200: #e5e7eb;
    --flaeske-gray-300: #d1d5db;
    --flaeske-gray-400: #9ca3af;
    --flaeske-gray-500: #6b7280;
    --flaeske-gray-600: #4b5563;
    --flaeske-orange-50: #fff7ed;
    --flaeske-orange-400: #fb923c;
}

/* Main Container */
.flaeske-toplist-v2 {
    max-width: 48rem; /* max-w-3xl */
    margin: 0 auto;
    padding: 1rem 1rem 4rem 1rem; /* Reduced top padding since it's part of content */
    border-bottom: 1px solid rgba(74, 124, 89, 0.05); /* border-brand-green/5 */
    font-family: 'Lato', sans-serif;
}

/* Title Section */
.flaeske-toplist-v2-header {
    text-align: center;
    margin-bottom: 3rem; /* mb-12 */
}

.flaeske-toplist-v2-title {
    font-family: 'Merriweather', serif;
    font-size: 1.875rem; /* text-3xl */
    font-weight: 700;
    color: var(--flaeske-brand-charcoal);
    margin: 0 0 2rem 0; /* mb-8 */
}

/* Toggle Container */
.flaeske-toplist-v2-toggle {
    display: inline-flex;
    background: white;
    border-radius: 9999px; /* rounded-full */
    padding: 0.375rem; /* p-1.5 */
    border: 1px solid var(--flaeske-gray-100);
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05); /* shadow-sm */
}

.flaeske-toplist-v2-toggle-btn {
    padding: 0.5rem 1.5rem; /* px-6 py-2 */
    border-radius: 9999px; /* rounded-full */
    border: none;
    background: transparent;
    color: var(--flaeske-gray-500);
    font-size: 0.875rem; /* text-sm */
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Lato', sans-serif;
}

.flaeske-toplist-v2-toggle-btn:hover {
    color: var(--flaeske-brand-charcoal);
    background: var(--flaeske-gray-100);
}

.flaeske-toplist-v2-toggle-btn.active {
    background: var(--flaeske-brand-green);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06); /* shadow-md */
}

/* List Container */
.flaeske-toplist-v2-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem; /* space-y-3 */
}

/* Toplist Item - Base */
.flaeske-toplist-v2-item {
    position: relative;
    background: white;
    border-radius: 0.75rem; /* rounded-xl */
    padding: 1rem; /* p-4 */
    border: 1px solid var(--flaeske-gray-100);
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px -1px rgba(74, 124, 89, 0.05), 0 1px 2px -1px rgba(74, 124, 89, 0.03); /* shadow-card */
    display: flex;
    align-items: center;
    gap: 1.25rem; /* gap-5 */
    cursor: pointer;
}

.flaeske-toplist-v2-item:hover {
    border-color: rgba(74, 124, 89, 0.3); /* border-brand-green/30 */
    box-shadow: 0 10px 15px -3px rgba(74, 124, 89, 0.1), 0 4px 6px -2px rgba(74, 124, 89, 0.05); /* shadow-floating */
}

/* Position 1 - Winner */
.flaeske-toplist-v2-item[data-position="1"] {
    border: 2px solid rgba(212, 160, 23, 0.2); /* border-brand-gold/20 */
}

.flaeske-toplist-v2-item[data-position="1"]:hover {
    border-color: var(--flaeske-brand-gold);
}

/* Position 4-5 - Slightly more subtle but not greyed out */
.flaeske-toplist-v2-item[data-position="4"],
.flaeske-toplist-v2-item[data-position="5"] {
    background: white; /* Full white background instead of semi-transparent */
    border: 1px solid var(--flaeske-gray-100);
    padding: 0.75rem; /* p-3 */
}

.flaeske-toplist-v2-item[data-position="4"]:hover,
.flaeske-toplist-v2-item[data-position="5"]:hover {
    background: white;
    border-color: var(--flaeske-brand-green);
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05); /* shadow-sm */
}

/* Rank Badge */
.flaeske-toplist-v2-rank {
    flex-shrink: 0;
    width: 2.5rem; /* w-10 */
    height: 2.5rem; /* h-10 */
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 9999px; /* rounded-full */
    font-family: 'Merriweather', serif;
    font-weight: 700;
    font-size: 1.125rem; /* text-lg */
    color: var(--flaeske-gray-500);
    background: var(--flaeske-gray-100);
}

/* Position 1 Badge - Gold */
.flaeske-toplist-v2-item[data-position="1"] .flaeske-toplist-v2-rank {
    width: 3rem; /* w-12 */
    height: 3rem; /* h-12 */
    background: var(--flaeske-brand-gold);
    color: white;
    font-weight: 900; /* font-black */
    font-size: 1.25rem; /* text-xl */
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06); /* shadow-md */
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06), 0 0 0 4px rgba(212, 160, 23, 0.1); /* ring-4 ring-brand-gold/10 */
}

/* Position 3 Badge - Orange */
.flaeske-toplist-v2-item[data-position="3"] .flaeske-toplist-v2-rank {
    background: var(--flaeske-orange-50);
    color: var(--flaeske-orange-400);
}

/* Position 4-5 Badge - Smaller but still visible */
.flaeske-toplist-v2-item[data-position="4"] .flaeske-toplist-v2-rank,
.flaeske-toplist-v2-item[data-position="5"] .flaeske-toplist-v2-rank {
    width: 2rem; /* w-8 */
    height: 2rem; /* h-8 */
    font-size: 0.875rem; /* text-sm */
    font-weight: 700;
    background: var(--flaeske-gray-100);
    color: var(--flaeske-gray-600);
}

/* Content Section */
.flaeske-toplist-v2-content {
    flex-grow: 1;
    min-width: 0;
}

.flaeske-toplist-v2-content-header {
    display: flex;
    align-items: center;
    gap: 0.5rem; /* gap-2 */
    margin-bottom: 0.125rem; /* mb-0.5 */
}

.flaeske-toplist-v2-name {
    font-family: 'Merriweather', serif;
    font-weight: 700;
    font-size: 1.125rem; /* text-lg */
    color: var(--flaeske-brand-charcoal);
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: color 0.3s ease;
    cursor: help; /* Indicate that hovering will show more info */
    position: relative;
}

/* Enhanced tooltip for truncated names */
.flaeske-toplist-v2-name[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--flaeske-brand-charcoal);
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    white-space: nowrap;
    z-index: 1000;
    margin-bottom: 0.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    pointer-events: none;
    font-family: 'Lato', sans-serif;
    font-weight: 400;
}

.flaeske-toplist-v2-name[title]:hover::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 0.375rem solid transparent;
    border-top-color: var(--flaeske-brand-charcoal);
    margin-bottom: -0.25rem;
    z-index: 1001;
    pointer-events: none;
}

.flaeske-toplist-v2-item:hover .flaeske-toplist-v2-name {
    color: var(--flaeske-brand-green);
}

/* Winner Badge (Position 1 only) */
.flaeske-toplist-v2-winner-badge {
    background: rgba(212, 160, 23, 0.1); /* bg-brand-gold/10 */
    color: var(--flaeske-brand-gold);
    font-size: 0.625rem; /* text-[10px] */
    font-weight: 700;
    padding: 0.125rem 0.5rem; /* px-2 py-0.5 */
    border-radius: 9999px; /* rounded-full */
    text-transform: uppercase;
    letter-spacing: 0.05em; /* tracking-wide */
}

/* Location Text */
.flaeske-toplist-v2-location {
    font-size: 0.75rem; /* text-xs */
    color: var(--flaeske-gray-400);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em; /* tracking-wider */
    margin: 0;
}

/* Position 4-5 Location - Smaller but readable */
.flaeske-toplist-v2-item[data-position="4"] .flaeske-toplist-v2-location,
.flaeske-toplist-v2-item[data-position="5"] .flaeske-toplist-v2-location {
    font-size: 0.625rem; /* text-[10px] */
    color: var(--flaeske-gray-500); /* Slightly darker than gray-400 for better readability */
}

/* Position 4-5 Name - Smaller but still prominent */
.flaeske-toplist-v2-item[data-position="4"] .flaeske-toplist-v2-name,
.flaeske-toplist-v2-item[data-position="5"] .flaeske-toplist-v2-name {
    font-size: 1rem; /* text-base */
    font-weight: 700;
    font-family: 'Lato', sans-serif;
    color: var(--flaeske-brand-charcoal); /* Keep same color as other positions */
}

/* Meta & Actions Section */
.flaeske-toplist-v2-meta {
    display: flex;
    align-items: center;
    gap: 1rem; /* gap-4 */
}

/* Ad Libitum Icon */
.flaeske-toplist-v2-adlib {
    width: 2rem; /* w-8 */
    height: 2rem; /* h-8 */
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 9999px; /* rounded-full */
    background: var(--flaeske-brand-cream);
    color: var(--flaeske-brand-green);
    flex-shrink: 0;
}

.flaeske-toplist-v2-adlib-icon {
    font-size: 1.125rem; /* text-lg */
    font-weight: 700;
    line-height: 1;
}

.flaeske-toplist-v2-adlib-placeholder {
    width: 2rem; /* w-8 */
    height: 2rem; /* h-8 */
    flex-shrink: 0;
}

/* Rating Display */
.flaeske-toplist-v2-rating {
    text-align: right;
    display: block; /* Always visible - users need to see ratings on all devices */
}

.flaeske-toplist-v2-rating-number {
    font-size: 1.25rem; /* text-xl */
    font-weight: 900; /* font-black */
    color: var(--flaeske-brand-charcoal);
    line-height: 1;
}

.flaeske-toplist-v2-item[data-position="4"] .flaeske-toplist-v2-rating-number,
.flaeske-toplist-v2-item[data-position="5"] .flaeske-toplist-v2-rating-number {
    font-size: 1.125rem; /* text-lg */
    font-weight: 700;
    color: var(--flaeske-gray-600); /* Darker gray for better visibility */
}

.flaeske-toplist-v2-item[data-position="4"]:hover .flaeske-toplist-v2-rating-number,
.flaeske-toplist-v2-item[data-position="5"]:hover .flaeske-toplist-v2-rating-number {
    color: var(--flaeske-brand-charcoal);
}

.flaeske-toplist-v2-rating-stars {
    display: flex;
    color: var(--flaeske-brand-gold);
    font-size: 0.875rem; /* Larger for visibility - was text-[8px] which is too small */
    gap: 0.125rem; /* gap-0.5 */
    margin-top: 0.25rem; /* mt-1 */
    line-height: 1;
}

.flaeske-toplist-v2-rating-stars .star-empty {
    color: var(--flaeske-gray-200);
}

/* Heart Button */
.flaeske-toplist-v2-heart {
    width: 2.5rem; /* w-10 = 40px */
    height: 2.5rem; /* h-10 = 40px */
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 9999px; /* rounded-full */
    background: #f9fafb; /* bg-gray-50 */
    color: var(--flaeske-gray-300);
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
    padding: 0;
}

.flaeske-toplist-v2-heart:hover {
    background: var(--flaeske-brand-error);
    color: white;
}

.flaeske-toplist-v2-heart.in-wishlist {
    background: var(--flaeske-brand-error) !important;
    color: white !important;
}

.flaeske-toplist-v2-heart.in-wishlist:hover {
    background: #dc2626 !important; /* Darker red on hover when active */
    color: white !important;
}

.flaeske-toplist-v2-heart svg {
    width: 1.25rem; /* w-5 = 20px */
    height: 1.25rem; /* h-5 = 20px */
    stroke-width: 2;
}

/* Position 4-5 Heart - Smaller button but SVG stays same size */
.flaeske-toplist-v2-item[data-position="4"] .flaeske-toplist-v2-heart,
.flaeske-toplist-v2-item[data-position="5"] .flaeske-toplist-v2-heart {
    width: 2rem; /* w-8 = 32px */
    height: 2rem; /* h-8 = 32px */
    background: transparent;
}

/* Ensure in-wishlist state overrides position-specific styles */
.flaeske-toplist-v2-item[data-position="4"] .flaeske-toplist-v2-heart.in-wishlist,
.flaeske-toplist-v2-item[data-position="5"] .flaeske-toplist-v2-heart.in-wishlist {
    background: var(--flaeske-brand-error) !important;
    color: white !important;
}

/* SVG stays w-5 h-5 (20px) even for position 4-5 per brand guideline */
.flaeske-toplist-v2-item[data-position="4"] .flaeske-toplist-v2-heart svg,
.flaeske-toplist-v2-item[data-position="5"] .flaeske-toplist-v2-heart svg {
    width: 1.25rem; /* w-5 = 20px - same as positions 1-3 */
    height: 1.25rem; /* h-5 = 20px - same as positions 1-3 */
}

.flaeske-toplist-v2-item[data-position="4"] .flaeske-toplist-v2-heart:hover,
.flaeske-toplist-v2-item[data-position="5"] .flaeske-toplist-v2-heart:hover {
    color: var(--flaeske-brand-error);
    background: transparent;
}

/* Divider - Boblerne */
.flaeske-toplist-v2-divider {
    display: flex;
    align-items: center;
    gap: 1rem; /* gap-4 */
    padding: 1rem 0; /* py-4 */
}

.flaeske-toplist-v2-divider-line {
    height: 1px; /* h-px */
    background: var(--flaeske-gray-200);
    flex-grow: 1;
}

.flaeske-toplist-v2-divider-text {
    font-size: 0.75rem; /* text-xs */
    font-weight: 700;
    color: var(--flaeske-gray-400);
    text-transform: uppercase;
    letter-spacing: 0.1em; /* tracking-widest */
}

/* Empty State */
.flaeske-toplist-v2-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--flaeske-gray-500);
    font-size: 1rem;
}

/* Panel Management */
.flaeske-toplist-v2-panel {
    display: none;
}

.flaeske-toplist-v2-panel.active {
    display: block;
    animation: flaeske-toplist-v2-fadeIn 0.3s ease;
}

@keyframes flaeske-toplist-v2-fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile Responsive - Compact Design */
@media (max-width: 640px) {
    .flaeske-toplist-v2 {
        padding: 1rem 0.75rem;
    }
    
    .flaeske-toplist-v2-header {
        margin-bottom: 1.5rem;
    }
    
    .flaeske-toplist-v2-title {
        font-size: 1.5rem;
        margin-bottom: 1rem;
    }
    
    .flaeske-toplist-v2-list {
        gap: 0.5rem; /* Tighter spacing between items */
    }
    
    .flaeske-toplist-v2-item {
        padding: 0.75rem; /* Compact padding */
        gap: 0.75rem;
        flex-wrap: nowrap; /* Keep horizontal layout */
        align-items: center;
    }
    
    /* Rank badge - smaller on mobile */
    .flaeske-toplist-v2-rank {
        width: 2rem;
        height: 2rem;
        font-size: 0.875rem;
        flex-shrink: 0;
    }
    
    .flaeske-toplist-v2-item[data-position="1"] .flaeske-toplist-v2-rank {
        width: 2.25rem;
        height: 2.25rem;
        font-size: 1rem;
    }
    
    /* Content section - compact */
    .flaeske-toplist-v2-content {
        flex: 1;
        min-width: 0;
    }
    
    .flaeske-toplist-v2-content-header {
        margin-bottom: 0.125rem;
    }
    
    .flaeske-toplist-v2-name {
        font-size: 0.9375rem; /* 15px */
        line-height: 1.2;
    }
    
    /* Mobile tooltip positioning */
    .flaeske-toplist-v2-name[title]:hover::after {
        font-size: 0.75rem;
        padding: 0.375rem 0.5rem;
        max-width: 200px;
        word-wrap: break-word;
        white-space: normal;
    }
    
    .flaeske-toplist-v2-location {
        font-size: 0.6875rem; /* 11px */
        margin: 0;
    }
    
    .flaeske-toplist-v2-winner-badge {
        font-size: 0.5625rem; /* 9px */
        padding: 0.125rem 0.375rem;
    }
    
    /* Meta section - horizontal, compact */
    .flaeske-toplist-v2-meta {
        gap: 0.5rem;
        flex-shrink: 0;
        align-items: center;
        flex-wrap: nowrap; /* Keep items in one row */
    }
    
    /* Ad libitum icon - smaller */
    .flaeske-toplist-v2-adlib,
    .flaeske-toplist-v2-adlib-placeholder {
        width: 1.5rem;
        height: 1.5rem;
        flex-shrink: 0;
    }
    
    .flaeske-toplist-v2-adlib-icon {
        font-size: 0.875rem;
    }
    
    /* Rating - always visible, compact */
    .flaeske-toplist-v2-rating {
        display: flex !important;
        flex-direction: column;
        align-items: flex-end;
        gap: 0.125rem;
        flex-shrink: 0;
        text-align: right;
        margin: 0;
        width: auto;
    }
    
    .flaeske-toplist-v2-rating-number {
        font-size: 1rem;
        line-height: 1;
    }
    
    .flaeske-toplist-v2-rating-stars {
        font-size: 0.625rem; /* 10px - visible but compact */
        gap: 0.0625rem;
        margin-top: 0;
    }
    
    /* Heart button - fixed size and position */
    .flaeske-toplist-v2-heart {
        width: 2rem !important; /* Fixed size on mobile */
        height: 2rem !important;
        flex-shrink: 0;
        background: #f9fafb;
    }
    
    .flaeske-toplist-v2-heart svg {
        width: 1rem !important; /* 16px */
        height: 1rem !important;
    }
    
    .flaeske-toplist-v2-heart.in-wishlist {
        background: var(--flaeske-brand-error) !important;
        color: white !important;
    }
    
    /* Position 4-5 adjustments for mobile */
    .flaeske-toplist-v2-item[data-position="4"],
    .flaeske-toplist-v2-item[data-position="5"] {
        padding: 0.625rem;
    }
    
    .flaeske-toplist-v2-item[data-position="4"] .flaeske-toplist-v2-rank,
    .flaeske-toplist-v2-item[data-position="5"] .flaeske-toplist-v2-rank {
        width: 1.75rem;
        height: 1.75rem;
        font-size: 0.75rem;
    }
    
    /* Divider - compact */
    .flaeske-toplist-v2-divider {
        padding: 0.75rem 0;
        gap: 0.75rem;
    }
    
    .flaeske-toplist-v2-divider-text {
        font-size: 0.625rem;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .flaeske-toplist-v2-item,
    .flaeske-toplist-v2-heart,
    .flaeske-toplist-v2-toggle-btn {
        transition: none;
    }
    
    .flaeske-toplist-v2-panel.active {
        animation: none;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .flaeske-toplist-v2-item {
        border: 2px solid #000;
    }
    
    .flaeske-toplist-v2-rank {
        border: 2px solid #000;
    }
}

