/* ============================================
   RANDOM FOOD GENERATOR — Warm Food Theme
   Real photos, Western-focused, premium feel
   ============================================ */

:root {
    --bg:           #fefaf5;
    --bg-card:      #ffffff;
    --bg-input:     #faf5ed;
    --text:         #2d2a26;
    --text-muted:   #8a8078;
    --accent:       #e8743c;
    --accent-hover: #d4622a;
    --accent-soft:  rgba(232,116,60,0.08);
    --accent-glow:  rgba(232,116,60,0.16);
    --border:       #ebe4da;
    --border-strong:#d8cfc4;
    --green:        #5a9670;
    --radius:       14px;
    --radius-lg:    20px;
    --radius-xl:    26px;
    --shadow-sm:    0 1px 3px rgba(0,0,0,0.03);
    --shadow-md:    0 4px 20px rgba(0,0,0,0.05);
    --shadow-lg:    0 12px 48px rgba(0,0,0,0.07);
    --ease-out:     cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring:  cubic-bezier(0.34, 1.56, 0.64, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

/* ============================================
   NAVIGATION
   ============================================ */
nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    max-width: 960px;
    margin: 0 auto;
    border-bottom: 1px solid var(--border);
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(14px);
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav-logo {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.nav-logo span { color: var(--accent); }
.nav-links { display: flex; gap: 1.25rem; list-style: none; }
.nav-links a {
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    transition: color 0.2s;
}
.nav-links a:hover { color: var(--accent); }

/* ============================================
   NAV DROPDOWN
   ============================================ */
.nav-dropdown { position: relative; }
.nav-dropdown-toggle {
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    transition: color 0.2s;
    cursor: pointer;
}
.nav-dropdown-toggle:hover { color: var(--accent); }
.nav-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(6px);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 0.4rem;
    min-width: 200px;
    list-style: none;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s var(--ease-out);
    z-index: 200;
}
.nav-dropdown.open .nav-dropdown-menu,
.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown-menu:hover {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(4px);
}
.nav-dropdown-menu li { display: block; }
.nav-dropdown-menu a {
    display: block;
    padding: 0.5rem 0.75rem;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.15s;
}
.nav-dropdown-menu a:hover {
    background: var(--accent-soft);
    color: var(--accent);
}
.nav-dropdown-menu a.active {
    color: var(--accent);
    font-weight: 600;
}


/* ============================================
   HERO
   ============================================ */
.hero {
    text-align: center;
    padding: 3rem 1.5rem 1.5rem;
    max-width: 700px;
    margin: 0 auto;
}
.hero h1 {
    font-size: 2.6rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.15;
    color: var(--text);
    margin-bottom: 0.5rem;
}
.hero h1 span { color: var(--accent); }
.hero p {
    font-size: 1.05rem;
    color: var(--text-muted);
    max-width: 480px;
    margin: 0 auto;
}

/* ============================================
   MAIN TOOL SECTION
   ============================================ */
.tool-section {
    max-width: 560px;
    margin: 0 auto;
    padding: 0 1.25rem 3rem;
}

/* Food display card — now with image */
.food-display {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    margin-bottom: 1.5rem;
    transition: transform 0.25s var(--ease-out), box-shadow 0.25s var(--ease-out);
}
.food-display:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Food image */
.food-img-wrap {
    width: 100%;
    height: 260px;
    overflow: hidden;
    background: #f0ebe2;
    position: relative;
}
/* Image fade-in transition */
.food-img-wrap img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.4s ease;
}
.food-img-wrap img.img-loaded {
    opacity: 1;
}
.food-img-wrap .food-emoji {
    transition: opacity 0.3s ease;
}
.food-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s var(--ease-out);
}
.food-display:hover .food-img-wrap { transform: scale(1.02); }
.food-img-wrap span { transition: transform 0.4s var(--ease-out); display: inline-block; }
.food-display:hover .food-img-wrap span { transform: scale(1.1); }

/* Food info below image */
.food-info {
    padding: 1.5rem 1.75rem;
    text-align: center;
}
.food-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.75rem;
    line-height: 1.3;
}
.food-tags {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
}
.food-tag {
    display: inline-block;
    padding: 0.3rem 0.8rem;
    background: var(--accent-soft);
    color: var(--accent);
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    border: 1px solid var(--accent-glow);
}

/* Card pop animation */

/* ============================================
   FLIP CARD — CSS Grid crossfade
   ============================================ */
.card-inner {
    display: grid;
    width: 100%;
}
.card-inner > * {
    grid-area: 1 / 1;
}

/* Front face */
.card-front {
    position: relative;
    z-index: 2;
    transition: opacity 0.35s ease, visibility 0.35s ease;
    opacity: 1;
    visibility: visible;
}

/* Flip button */
.flip-btn {
    position: absolute;
    bottom: 0.75rem;
    right: 0.75rem;
    width: 36px; height: 36px;
    border-radius: 50%;
    border: 1.5px solid var(--border);
    background: var(--bg-card);
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 5;
}
.flip-btn:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    transform: rotate(90deg);
}
.flip-btn-back {
    position: relative;
    bottom: auto; right: auto;
    align-self: center;
    margin-top: 0.5rem;
}

/* Back face */
.card-back {
    z-index: 1;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.35s ease, visibility 0.35s ease;
    padding: 1.5rem;
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Back face content */
.back-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.recipe-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.recipe-list li {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    font-size: 0.85rem;
    line-height: 1.45;
    color: var(--text);
}
.step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px; height: 24px;
    min-width: 24px;
    background: var(--accent-soft);
    color: var(--accent);
    border-radius: 50%;
    font-size: 0.7rem;
    font-weight: 700;
    flex-shrink: 0;
}
.nutrition-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
}
.nut-item {
    text-align: center;
    padding: 0.6rem 0.3rem;
    background: var(--accent-soft);
    border-radius: var(--radius);
}
.nut-val {
    display: block;
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--accent);
    line-height: 1.2;
}
.nut-label {
    display: block;
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 0.15rem;
}

/* Flipped state */
.food-display.flipped .card-front {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
.food-display.flipped .card-back {
    opacity: 1;
    visibility: visible;
    z-index: 3;
}

/* Responsive */
@media (max-width: 480px) {
    .card-back { padding: 1rem; gap: 0.85rem; }
    .nutrition-grid { grid-template-columns: repeat(2, 1fr); }
    .recipe-list li { font-size: 0.8rem; }
}

.card-pop { animation: card-pop 0.4s var(--ease-spring); }
@keyframes card-pop {
    0% { transform: scale(0.97); }
    60% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

/* Generate button */
.btn-generate {
    display: block;
    width: 100%;
    padding: 1.05rem;
    font-size: 1.1rem;
    font-weight: 700;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.2s var(--ease-out);
    position: relative;
    overflow: hidden;
    margin-bottom: 1.75rem;
    letter-spacing: -0.01em;
}
.btn-generate:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px var(--accent-glow);
}
.btn-generate:active { transform: scale(0.97); }

/* Keyboard hint */
.kb-hint {
    text-align: center;
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: -1rem;
    margin-bottom: 1.25rem;
}
.kb-hint kbd {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.7rem;
    margin: 0 0.2rem;
}

/* Utility buttons */
.btn-row {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 2rem;
}
.btn-secondary {
    flex: 1;
    padding: 0.7rem;
    font-size: 0.85rem;
    font-weight: 600;
    background: var(--bg-card);
    color: var(--text);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
}
.btn-secondary:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
}

/* ============================================
   FILTERS
   ============================================ */
.filter-section {
    margin-bottom: 0.6rem;
}
.filter-section h3 {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    font-weight: 700;
}
.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}
.filter-chip {
    padding: 0.35rem 0.8rem;
    font-size: 0.78rem;
    font-weight: 600;
    background: var(--bg-card);
    color: var(--text-muted);
    border: 1.5px solid var(--border);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}
.filter-chip:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.filter-chip.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* ============================================
   HISTORY
   ============================================ */
.history-section {
    margin-top: 2rem;
}
.history-section h3 {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    font-weight: 700;
}
.history-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.6rem 0.85rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
}
.history-item:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
}
.history-thumb {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    object-fit: cover;
    flex-shrink: 0;
}
.history-info { display: flex; flex-direction: column; gap: 0.15rem; overflow: hidden; }
.history-name { font-weight: 700; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-tag { font-size: 0.72rem; color: var(--text-muted); }

/* ============================================
   RIPPLE
   ============================================ */
.ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255,255,255,0.35);
    transform: scale(0);
    animation: ripple-anim 0.6s ease-out;
    pointer-events: none;
}
@keyframes ripple-anim {
    to { transform: scale(2.5); opacity: 0; }
}

/* ============================================
   TOAST
   ============================================ */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text);
    color: #fff;
    padding: 0.7rem 1.5rem;
    border-radius: 30px;
    font-size: 0.85rem;
    font-weight: 600;
    z-index: 999;
    opacity: 0;
    transition: all 0.3s var(--ease-spring);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============================================
   FOOTER
   ============================================ */
footer {
    text-align: center;
    padding: 2rem 1.5rem 3rem;
    border-top: 1px solid var(--border);
    margin-top: 2rem;
}
.footer-links {
    display: flex;
    gap: 1.25rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.footer-links a {
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.8rem;
    transition: color 0.2s;
}
.footer-links a:hover { color: var(--accent); }
.footer-crosslink {
    margin-top: 0.75rem;
    font-size: 0.78rem;
    color: var(--text-muted);
}
.footer-crosslink a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}
.footer-crosslink a:hover { text-decoration: underline; }

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}


/* ============================================
   MORE TOOLS SECTION
   ============================================ */
.more-tools-section {
    padding: 3rem 0 2rem;
    border-top: 1px solid var(--border);
    margin-top: 2rem;
}
.section-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent);
    font-weight: 700;
    margin-bottom: 0.5rem;
}
.section-title {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 0.4rem;
    color: var(--text);
}
.section-desc {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    max-width: 500px;
}
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}
.tool-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    text-decoration: none;
    color: var(--text);
    transition: all 0.3s var(--ease-out);
    display: block;
}
.tool-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--accent);
}
.tool-card-icon {
    font-size: 2rem;
    display: block;
    margin-bottom: 0.75rem;
}
.tool-card h3 {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 0.35rem;
}
.tool-card p {
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.45;
}

@media (max-width: 640px) {
    .tools-grid { grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
    .tool-card { padding: 1rem; }
    .tool-card h3 { font-size: 0.82rem; }
    .section-title { font-size: 1.3rem; }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 640px) {
    .hero h1 { font-size: 1.8rem; }
    .hero p { font-size: 0.9rem; }
    .food-img-wrap { height: 200px; }
    .food-info { padding: 1.25rem 1rem; }
    .food-name { font-size: 1.25rem; }
    .food-tag { font-size: 0.7rem; padding: 0.2rem 0.6rem; }
    .btn-generate { font-size: 1rem; padding: 0.85rem; }
    nav { padding: 0.75rem 1rem; }
    .nav-links { gap: 0.75rem; }
    .nav-links a { font-size: 0.78rem; }
    .nav-dropdown-menu { left: 0; transform: translateY(6px); min-width: 160px; }
    .nav-dropdown:hover .nav-dropdown-menu { transform: translateY(4px); }
}
