:root {
    /* Colors - Organic & Editorial Palette */
    --color-bg-main: #F9F8F4;      /* Warm Paper */
    --color-bg-sidebar: #EBE9E1;   /* Darker Paper */
    --color-text-primary: #1A1917; /* Soft Black */
    --color-text-secondary: #58544D; /* Muted Earth */
    --color-accent: #2C5F2D;       /* Deep Forest Green */
    --color-accent-hover: #1E421F;
    --color-border: #D8D4CC;
    --color-card-bg: #FFFFFF;

    /* Typography */
    --font-heading: 'Playfair Display', serif;
    --font-body: 'Inter', sans-serif;

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2.5rem;

    /* Motion (calm/refined) */
    --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
    --dur-press: 110ms;
    --dur-fast: 160ms;
    --dur-med: 240ms;
    --dur-slow: 360ms;

    /* Back-compat */
    --ease-out: var(--ease-out-quart);
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    background-color: var(--color-bg-main);
    color: var(--color-text-primary);
    line-height: 1.6;
    height: 100vh;
    overflow: hidden; /* App-like feel */
}

/* Layout */
.app-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    background-color: var(--color-bg-sidebar);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    padding: var(--space-xl) 0 0 0;
    height: 100%;
    min-height: 0; /* allow .country-nav to overflow/scroll */
}

.brand {
    padding: 0 var(--space-xl) var(--space-lg);
}

.brand h1 {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 2rem;
    line-height: 1.1;
    margin-bottom: var(--space-sm);
    letter-spacing: -0.02em;
}

.brand .subtitle {
    color: var(--color-text-secondary);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
}

.search-container {
    padding: 0 var(--space-xl) var(--space-lg);
    position: relative;
}

#search-input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(255,255,255,0.6);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-family: var(--font-body);
    font-size: 0.95rem;
    color: var(--color-text-primary);
    transition: all 0.2s var(--ease-out);
}

#search-input:focus {
    outline: none;
    background: white;
    border-color: var(--color-accent);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}


.random-btn {
    width: 100%;
    padding: 0.75rem 1rem;
    margin-bottom: var(--space-sm);
    background: var(--color-accent);
    color: white;
    border: none;
    border-radius: 8px;
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition:
        transform var(--dur-fast) var(--ease-out-quart),
        background-color var(--dur-fast) var(--ease-out-quart),
        box-shadow var(--dur-med) var(--ease-out-quart);
    transform: translateZ(0);
}

.random-btn:hover {
    background: var(--color-accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 10px 18px rgba(0,0,0,0.08);
}

.random-btn:active {
    transform: translateY(0) scale(0.99);
    transition-duration: var(--dur-press);
}

.random-btn.is-busy {
    pointer-events: none;
    opacity: 0.92;
}

/* Mobile visible button */
.random-btn.mobile-visible {
    display: none;
    position: absolute;
    right: var(--space-md);
    top: 50%;
    transform: translateY(-50%);
    width: auto;
    min-width: 100px;
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    margin: 0;
}

.country-nav {
    flex: 1;
    overflow-y: auto;
    min-height: 0; /* required for overflow inside flex column */
    padding: 0 var(--space-xl) var(--space-xl);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Subtle scrollbars (Firefox + WebKit) */
.country-nav,
.main-content {
    scrollbar-width: thin;
    scrollbar-color: rgba(88, 84, 77, 0.35) transparent;
}

.country-nav::-webkit-scrollbar,
.main-content::-webkit-scrollbar {
    width: 10px;
}

.country-nav::-webkit-scrollbar-track,
.main-content::-webkit-scrollbar-track {
    background: transparent;
}

.country-nav::-webkit-scrollbar-thumb,
.main-content::-webkit-scrollbar-thumb {
    background-color: rgba(88, 84, 77, 0.28);
    border-radius: 999px;
    border: 3px solid transparent;
    background-clip: content-box;
}

.country-nav::-webkit-scrollbar-thumb:hover,
.main-content::-webkit-scrollbar-thumb:hover {
    background-color: rgba(88, 84, 77, 0.42);
}

.nav-item {
    padding: 0.6rem 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--color-text-secondary);
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.country-flag {
    width: 28px;
    height: 20px;
    display: inline-block;
    flex: 0 0 auto;
    border-radius: 3px;
    object-fit: cover;
    background-color: #f0f0f0;
    box-shadow: 
        inset 0 0 0 1px rgba(0,0,0,0.06), /* Inner definition */
        0 1px 2px rgba(0,0,0,0.06);       /* Subtle lift */
    transition: transform 0.2s ease;
}

.nav-item:hover .country-flag {
    transform: scale(1.05); /* Gentle interaction feedback */
}

.nav-label {
    flex: 1;
    min-width: 0;
}

.nav-flag {
    margin-left: auto;
}

.country-header .country-flag {
    width: 64px;
    height: 44px;
    border-radius: 10px;
}


.nav-item:hover {
    background-color: rgba(0,0,0,0.03);
    color: var(--color-text-primary);
}

.nav-item.active {
    background-color: var(--color-accent);
    color: white;
    font-weight: 500;
}

/* Main Content */
.main-content {
    height: 100%;
    overflow-y: auto;
    padding: var(--space-xl);
    position: relative;
    min-height: 0; /* allow main panel scrolling within grid */
}

.content-area {
    max-width: 900px;
    margin: 0 auto;
    padding-bottom: 4rem;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 80vh;
    text-align: center;
    color: var(--color-text-secondary);
    animation: fadeIn 0.5s ease-out;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: var(--space-md);
    opacity: 0.8;
}

.empty-state h2 {
    font-family: var(--font-heading);
    font-size: 2rem;
    color: var(--color-text-primary);
    margin-bottom: var(--space-md);
}

.empty-state p {
    max-width: 400px;
}

/* Restaurant Card Styles */
.country-header {
    margin-bottom: var(--space-xl);
    border-bottom: 2px solid var(--color-border);
    padding-bottom: var(--space-lg);
    animation: slideUp 0.4s var(--ease-out);
}

.country-header h2 {
    font-family: var(--font-heading);
    font-size: 3rem;
    font-weight: 400;
    color: var(--color-text-primary);
    margin-bottom: var(--space-xs);
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.restaurant-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--space-lg);
    animation: fadeIn 0.5s var(--ease-out);
}

.restaurant-card {
    background: var(--color-card-bg);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: var(--space-lg);
    transition:
        transform var(--dur-med) var(--ease-out-quart),
        box-shadow var(--dur-med) var(--ease-out-quart),
        border-color var(--dur-fast) var(--ease-out-quart),
        opacity var(--dur-med) var(--ease-out-quart),
        filter var(--dur-med) var(--ease-out-quart);
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
}

.restaurant-card.is-entering {
    opacity: 0;
    transform: translateY(8px);
}

.restaurant-card.is-entered {
    opacity: 1;
    transform: translateY(0);
}

.restaurant-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0,0,0,0.06);
    border-color: var(--color-accent);
}

.restaurant-title {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-md);
    margin-bottom: var(--space-sm);
}

.restaurant-name {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    margin-bottom: 0;
    color: var(--color-text-primary);
}

.restaurant-maps-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: inherit;
    text-decoration: none;
    white-space: nowrap;
    opacity: 0.85;
    transition: opacity 0.15s var(--ease-out), transform 0.15s var(--ease-out);
    line-height: 1;
}

.restaurant-maps-link svg {
    width: 18px;
    height: 18px;
    display: block;
}

.restaurant-maps-link:hover {
    opacity: 1;
    transform: translateY(-1px);
}

.restaurant-location {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    margin-bottom: var(--space-md);
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.location-icon {
    opacity: 0.6;
}

.restaurant-comments {
    margin-top: auto;
    background: var(--color-bg-main);
    padding: var(--space-md);
    border-radius: 8px;
}

.comment-list {
    list-style: none;
}

.comment-item {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    margin-bottom: var(--space-sm);
    font-style: italic;
    position: relative;
    padding-left: 0.75rem;
}

.comment-item::before {
    content: "“";
    position: absolute;
    left: 0;
    color: var(--color-accent);
    font-weight: bold;
}

.comment-item:last-child {
    margin-bottom: 0;
}

/* Lucky Shuffle Animation */
.lucky-shuffle-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--color-bg-main);
    z-index: 10;
    overflow: hidden;
}

.lucky-shuffle-container::before {
    content: "";
    position: absolute;
    inset: -20%;
    background:
      radial-gradient(closest-side, rgba(44, 95, 45, 0.12), rgba(44, 95, 45, 0) 68%),
      radial-gradient(closest-side, rgba(44, 95, 45, 0.08), rgba(44, 95, 45, 0) 70%);
    filter: blur(2px);
    opacity: 0;
    transform: scale(0.98);
    transition:
      opacity var(--dur-slow) var(--ease-out-quart),
      transform var(--dur-slow) var(--ease-out-quart);
    pointer-events: none;
}

.lucky-shuffle-container.is-ready::before {
    opacity: 1;
    transform: scale(1);
}

.lucky-shuffle-label {
    font-family: var(--font-body);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-text-secondary);
    margin-bottom: var(--space-md);
    opacity: 0.7;
}

.lucky-shuffle-item {
    font-family: var(--font-heading);
    font-size: 3.5rem;
    color: var(--color-text-primary);
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: var(--space-md);
    text-align: center;
    /* Optimizations */
    will-change: transform, opacity, filter;
    transform: translateZ(0);
    transition:
        transform var(--dur-med) var(--ease-out-expo),
        opacity var(--dur-fast) var(--ease-out-quart),
        filter var(--dur-med) var(--ease-out-quart);
}

.lucky-shuffle-item.is-ticking {
    transform: translateY(-1px);
    filter: saturate(1.02);
}

.lucky-shuffle-item.is-winner {
    transform: translateY(0) scale(1.03);
    filter: saturate(1.06);
}

.lucky-shuffle-flag {
    width: 60px;
    height: 40px;
    border-radius: 6px;
    object-fit: cover;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* Refined Highlight */
.restaurant-card.lucky-highlight {
    border-color: var(--color-accent);
    border-width: 2px;
    background-color: #fff;
    transform: scale(1.02);
    box-shadow: 0 20px 40px rgba(0,0,0,0.12), 0 0 0 1px var(--color-accent); /* Double border effect */
    opacity: 1;
    filter: brightness(1);
    z-index: 2; /* Lift above dimmed siblings */
    transition:
        transform var(--dur-slow) var(--ease-out-expo),
        box-shadow var(--dur-slow) var(--ease-out-quart),
        border-color var(--dur-med) var(--ease-out-quart),
        opacity var(--dur-med) var(--ease-out-quart),
        filter var(--dur-med) var(--ease-out-quart);
}

.restaurant-card.lucky-highlight::after {
    content: "";
    position: absolute;
    inset: -6px;
    border-radius: 16px;
    border: 1px solid rgba(44, 95, 45, 0.22);
    opacity: 0;
    transform: scale(0.985);
    pointer-events: none;
}

.restaurant-card.lucky-highlight.ring-settle::after {
    animation: ringSettle 520ms var(--ease-out-expo) both;
}

@keyframes ringSettle {
    0% { opacity: 0; transform: scale(0.985); }
    55% { opacity: 1; transform: scale(1.01); }
    100% { opacity: 0.75; transform: scale(1); }
}

.restaurant-card.lucky-highlight::before {
    content: "Our Pick";
    position: absolute;
    top: -12px;
    right: 20px;
    background: var(--color-accent);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 4px 12px;
    border-radius: 100px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    animation: fadeSlideIn 0.6s var(--ease-out) backwards;
    animation-delay: 0.2s;
}

.restaurant-card.lucky-dimmed {
    opacity: 0.4;
    filter: blur(0.5px) grayscale(0.2); /* Slight blur adds depth */
    transition: all 0.6s var(--ease-out);
    transform: scale(0.98);
}

.restaurant-card.lucky-dimmed:hover {
    opacity: 0.8;
    filter: blur(0px) grayscale(0);
    transform: scale(1);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Mobile Header & Overlay (Base Styles) */
.mobile-header {
    display: none;
    align-items: center;
    padding: 0 var(--space-md);
    height: 60px;
    background: var(--color-bg-sidebar);
    border-bottom: 1px solid var(--color-border);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    min-height: 60px;
}

.menu-toggle {
    background: none;
    border: none;
    color: var(--color-text-primary);
    cursor: pointer;
    padding: var(--space-sm);
    margin-right: var(--space-sm);
    margin-left: -0.5rem; /* Align with padding */
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.menu-toggle:active {
    background-color: rgba(0,0,0,0.05);
}

.mobile-brand-text {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-text-primary);
    letter-spacing: -0.01em;
}

.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 90;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(2px);
}

.menu-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    body {
        overflow: auto;
        height: auto;
    }

    .mobile-header {
        display: flex;
    }

    .app-layout {
        display: block; /* Remove grid */
        height: auto;
        padding-top: 60px; /* Space for fixed header */
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px; /* Drawer width */
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
        box-shadow: 2px 0 12px rgba(0,0,0,0.1);
        border-right: none;
        padding-top: 0; /* Let internal content handle spacing */
    }

    .sidebar.open {
        transform: translateX(0);
    }
    
    .brand {
        padding-top: var(--space-lg);
    }
    
    .brand h1 {
        font-size: 1.5rem;
    }
    
    .brand .subtitle {
        display: block; /* Keep subtitle */
    }

    .search-container {
        padding-bottom: var(--space-md);
    }

    /* Keep vertical list for drawer */
    .country-nav {
        display: flex;
        flex-direction: column;
        padding-bottom: var(--space-xl);
    }
    
    .nav-item {
        padding: 0.75rem 1rem; /* Larger touch target */
        border-radius: 6px;
    }

    .main-content {
        height: auto;
        min-height: calc(100vh - 60px);
        overflow: visible; /* Let body scroll */
        padding: var(--space-lg) var(--space-md);
    }

    .country-header h2 {
        font-size: 2rem;
    }

    .restaurant-grid {
        grid-template-columns: 1fr; /* Stack cards */
    }
    
    .restaurant-name {
        font-size: 1.35rem;
    }

    .empty-state h2 {
        font-size: 1.5rem;
    }

    .lucky-shuffle-item {
        font-size: 2.5rem;
    }

    /* Show the mobile visible button */
    .random-btn.mobile-visible {
        display: block;
    }

    /* Hide the desktop version of the button on mobile */
    .random-btn:not(.mobile-visible) {
        display: none;
    }
}