/* ══════════════════════════════════════════════════════════════
   TheSwapGuide.com — Design System
   Ingredient Substitution Hub | Food & Cooking Theme
   ══════════════════════════════════════════════════════════════ */

:root {
  --primary: #d97706;
  --primary-dark: #b45309;
  --primary-light: #fef3c7;
  --primary-ghost: #fffbeb;
  --accent: #059669;
  --accent-dark: #047857;
  --accent-light: #d1fae5;
  --bg: #fffbeb;
  --card-bg: #ffffff;
  --text: #1c1917;
  --text-light: #78716c;
  --text-muted: #a8a29e;
  --border: #e7e5e4;
  --border-light: #f5f5f4;
  --success: #10b981;
  --error: #ef4444;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
}

/* ═══════════════ RESET ═══════════════ */
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
html{scroll-behavior:smooth;-webkit-text-size-adjust:100%}
body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Oxygen,Ubuntu,sans-serif;line-height:1.6;color:var(--text);background:var(--bg);-webkit-font-smoothing:antialiased}
a{color:var(--primary);text-decoration:none;transition:color .15s}
a:hover{color:var(--primary-dark)}
img{max-width:100%;height:auto}
button{cursor:pointer;font-family:inherit}

/* ═══════════════ HEADER ═══════════════ */
.site-header{background:#fff;border-bottom:1px solid var(--border);position:sticky;top:0;z-index:100;backdrop-filter:blur(8px)}
.header-inner{max-width:1200px;margin:0 auto;padding:0 1.5rem;display:flex;align-items:center;justify-content:space-between;height:64px}
.logo{display:flex;align-items:center;gap:.5rem;font-size:1.25rem;font-weight:700;color:var(--text)}
.logo-icon{width:36px;height:36px;background:linear-gradient(135deg,var(--primary),var(--primary-dark));border-radius:var(--radius-sm);display:flex;align-items:center;justify-content:center;font-size:1.2rem}
.logo-text span{color:var(--primary)}
.nav-links{display:flex;gap:1.5rem;align-items:center}
.nav-links a{color:var(--text-light);font-weight:500;font-size:.9rem}
.nav-links a:hover{color:var(--primary)}
.nav-links a.active{color:var(--primary);font-weight:600}

/* ═══════════════ HERO ═══════════════ */
.hero{background:linear-gradient(135deg,#92400e,#b45309,#d97706);color:#fff;padding:4rem 1.5rem;text-align:center;position:relative;overflow:hidden}
.hero::before{content:'';position:absolute;top:-50%;left:-50%;width:200%;height:200%;background:radial-gradient(circle,rgba(255,255,255,.08) 0%,transparent 60%);animation:pulse 8s ease-in-out infinite}
@keyframes pulse{0%,100%{transform:scale(1)}50%{transform:scale(1.05)}}
.hero h1{font-size:2.8rem;font-weight:800;margin-bottom:.75rem;position:relative;z-index:1}
.hero p{font-size:1.2rem;opacity:.9;max-width:600px;margin:0 auto 2rem;position:relative;z-index:1}
.hero-search{max-width:620px;margin:0 auto;position:relative;z-index:1}
.hero-search .search-box{display:flex;background:#fff;border-radius:var(--radius-xl);box-shadow:0 20px 40px rgba(0,0,0,.25);overflow:hidden}
.hero-search input{flex:1;border:none;padding:1rem 1.5rem;font-size:1.05rem;outline:none;color:var(--text)}
.hero-search input::placeholder{color:var(--text-muted)}
.hero-search button{background:var(--primary);color:#fff;border:none;padding:1rem 1.75rem;font-size:1rem;font-weight:600;white-space:nowrap;transition:background .2s}
.hero-search button:hover{background:var(--primary-dark)}

/* ═══════════════ TRUST BADGES ═══════════════ */
.trust-badges{max-width:900px;margin:1.5rem auto 0;display:flex;justify-content:center;gap:2rem;flex-wrap:wrap;position:relative;z-index:1}
.trust-badge{display:flex;align-items:center;gap:.4rem;font-size:.85rem;opacity:.85}
.trust-badge .badge-icon{font-size:1.1rem}

/* ═══════════════ CATEGORIES ═══════════════ */
.categories-section{padding:2.5rem 1.5rem;max-width:1200px;margin:0 auto}
.categories-section h2{text-align:center;font-size:1.6rem;margin-bottom:1.5rem;color:var(--text)}
.cat-pills{display:flex;flex-wrap:wrap;justify-content:center;gap:.6rem}
.cat-pill{padding:.55rem 1.2rem;border:2px solid var(--border);border-radius:var(--radius-xl);background:var(--card-bg);color:var(--text-light);font-weight:500;font-size:.88rem;cursor:pointer;transition:all .2s}
.cat-pill:hover{border-color:var(--primary);color:var(--primary)}
.cat-pill.active{background:var(--primary);color:#fff;border-color:var(--primary)}

/* ═══════════════ POPULAR SECTION ═══════════════ */
.popular-section{padding:0 1.5rem 3rem;max-width:1200px;margin:0 auto}
.popular-section h2{text-align:center;font-size:1.6rem;margin-bottom:.25rem}
.popular-section .section-sub{text-align:center;color:var(--text-light);margin-bottom:1.5rem;font-size:.95rem}
.ingredient-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(300px,1fr));gap:1.25rem}
.ingredient-card{background:var(--card-bg);border:1px solid var(--border);border-radius:var(--radius-lg);padding:1.5rem;transition:all .2s;cursor:pointer;display:flex;gap:1rem;align-items:flex-start}
.ingredient-card:hover{border-color:var(--primary);box-shadow:var(--shadow-md);transform:translateY(-2px)}
.ingredient-card .card-emoji{font-size:2rem;flex-shrink:0;width:48px;height:48px;display:flex;align-items:center;justify-content:center;background:var(--primary-ghost);border-radius:var(--radius)}
.ingredient-card h3{font-size:1.05rem;margin-bottom:.25rem;color:var(--text)}
.ingredient-card .card-cat{font-size:.78rem;color:var(--text-muted);text-transform:uppercase;letter-spacing:.5px;margin-bottom:.35rem}
.ingredient-card .card-sub{font-size:.85rem;color:var(--text-light);line-height:1.4}
.ingredient-card .card-tag{display:inline-block;padding:.15rem .55rem;border-radius:99px;font-size:.7rem;font-weight:600;margin-right:.3rem;margin-top:.4rem}
.tag-vegan{background:#d1fae5;color:#065f46}
.tag-gluten-free{background:#fef3c7;color:#92400e}
.tag-dairy-free{background:#dbeafe;color:#1e40af}
.tag-keto{background:#fce7f3;color:#9d174d}

/* ═══════════════ INGREDIENT PAGE ═══════════════ */
.ingredient-page{max-width:860px;margin:0 auto;padding:2rem 1.5rem}
.breadcrumb{font-size:.85rem;color:var(--text-muted);margin-bottom:1.5rem}
.breadcrumb a{color:var(--text-light)}
.ingredient-hero{background:var(--card-bg);border:1px solid var(--border);border-radius:var(--radius-xl);padding:2rem;margin-bottom:1.5rem}
.ingredient-hero .ing-header{display:flex;align-items:center;gap:1rem;margin-bottom:1rem}
.ingredient-hero .ing-emoji{font-size:3rem;width:72px;height:72px;display:flex;align-items:center;justify-content:center;background:var(--primary-ghost);border-radius:var(--radius-lg)}
.ingredient-hero h1{font-size:2rem;font-weight:800}
.ingredient-hero .ing-meta{display:flex;gap:.5rem;flex-wrap:wrap;margin-bottom:1rem}
.ingredient-hero .ing-desc{color:var(--text-light);font-size:1.05rem;line-height:1.7}

/* Substitutes list */
.substitutes-list{display:flex;flex-direction:column;gap:1rem}
.substitute-item{background:var(--card-bg);border:1px solid var(--border);border-radius:var(--radius-lg);padding:1.25rem 1.5rem;display:flex;gap:1rem;align-items:flex-start;transition:all .2s}
.substitute-item:hover{border-color:var(--accent);box-shadow:var(--shadow)}
.substitute-item.best{border-left:4px solid var(--accent)}
.substitute-item .sub-rank{font-size:1.5rem;font-weight:800;color:var(--primary);flex-shrink:0;width:36px;text-align:center}
.substitute-item .sub-content{flex:1}
.substitute-item h3{font-size:1.1rem;margin-bottom:.25rem}
.substitute-item .sub-ratio{font-size:.85rem;color:var(--primary-dark);font-weight:600;margin-bottom:.35rem}
.substitute-item .sub-desc{font-size:.9rem;color:var(--text-light);line-height:1.5}

/* ═══════════════ INFO BOX ═══════════════ */
.info-box{background:var(--primary-ghost);border:1px solid var(--primary-light);border-radius:var(--radius);padding:1.25rem;margin:1.5rem 0}
.info-box h4{color:var(--primary-dark);margin-bottom:.5rem;font-size:.95rem}
.info-box p,.info-box ul{font-size:.9rem;color:var(--text-light);line-height:1.6}
.info-box ul{padding-left:1.2rem}
.info-box li{margin-bottom:.3rem}

/* ═══════════════ FAQ ═══════════════ */
.faq-section{padding:2.5rem 1.5rem;max-width:860px;margin:0 auto}
.faq-section h2{text-align:center;font-size:1.6rem;margin-bottom:1.5rem}
.faq-item{background:var(--card-bg);border:1px solid var(--border);border-radius:var(--radius-lg);margin-bottom:.75rem;overflow:hidden}
.faq-question{padding:1.1rem 1.5rem;display:flex;justify-content:space-between;align-items:center;cursor:pointer;font-weight:600;font-size:.95rem;user-select:none}
.faq-question::after{content:'+';font-size:1.3rem;color:var(--text-muted);font-weight:300;transition:transform .2s}
.faq-item.open .faq-question::after{content:'−';transform:rotate(180deg)}
.faq-answer{padding:0 1.5rem;max-height:0;overflow:hidden;transition:max-height .25s ease,padding .25s ease}
.faq-item.open .faq-answer{max-height:300px;padding:0 1.5rem 1.25rem}
.faq-answer p{color:var(--text-light);font-size:.9rem;line-height:1.6}

/* ═══════════════ AD PLACEHOLDER ═══════════════ */
.ad-placeholder{background:var(--border-light);border:2px dashed var(--border);border-radius:var(--radius);padding:1.5rem;text-align:center;color:var(--text-muted);font-size:.85rem;margin:1.5rem 0;min-height:90px;display:flex;align-items:center;justify-content:center}

/* ═══════════════ RESULTS / SEARCH DROPDOWN ═══════════════ */
.search-results{position:absolute;top:100%;left:0;right:0;background:var(--card-bg);border:1px solid var(--border);border-radius:var(--radius-lg);box-shadow:var(--shadow-lg);margin-top:.5rem;max-height:400px;overflow-y:auto;display:none;z-index:50}
.search-results.visible{display:block}
.search-result-item{padding:.85rem 1.25rem;display:flex;align-items:center;gap:.75rem;cursor:pointer;border-bottom:1px solid var(--border-light);transition:background .1s}
.search-result-item:last-child{border-bottom:none}
.search-result-item:hover{background:var(--primary-ghost)}
.search-result-item .sr-emoji{font-size:1.3rem}
.search-result-item .sr-info{flex:1}
.search-result-item .sr-name{font-weight:600;font-size:.9rem}
.search-result-item .sr-sub{font-size:.8rem;color:var(--text-light)}

/* ═══════════════ NO RESULTS ═══════════════ */
.no-results{text-align:center;padding:2.5rem 1.5rem}
.no-results .nr-emoji{font-size:3rem;margin-bottom:1rem}
.no-results h3{margin-bottom:.5rem}
.no-results p{color:var(--text-light)}

/* ═══════════════ CTA SECTION ═══════════════ */
.cta-section{background:linear-gradient(135deg,#92400e,#b45309);color:#fff;text-align:center;padding:3rem 1.5rem;margin-top:2rem}
.cta-section h2{font-size:1.8rem;margin-bottom:.75rem}
.cta-section p{opacity:.9;margin-bottom:1.5rem;max-width:500px;margin-left:auto;margin-right:auto}
.cta-section .btn{display:inline-block;background:#fff;color:var(--primary-dark);padding:.75rem 2rem;border-radius:var(--radius-xl);font-weight:700;font-size:1rem;transition:all .2s}
.cta-section .btn:hover{transform:translateY(-2px);box-shadow:0 10px 25px rgba(0,0,0,.25)}

/* ═══════════════ FOOTER ═══════════════ */
.site-footer{background:#1c1917;color:#a8a29e;padding:2.5rem 1.5rem 1.5rem}
.footer-grid{max-width:1200px;margin:0 auto;display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:2rem;margin-bottom:1.5rem}
.footer-col h4{color:#fff;margin-bottom:.75rem;font-size:.9rem}
.footer-col a{display:block;color:var(--text-muted);font-size:.85rem;padding:.25rem 0;transition:color .15s}
.footer-col a:hover{color:var(--primary)}
.footer-bottom{max-width:1200px;margin:0 auto;text-align:center;padding-top:1.5rem;border-top:1px solid rgba(255,255,255,.08);font-size:.8rem}

/* ═══════════════ UTILITY CLASSES ═══════════════ */
.container{max-width:1200px;margin:0 auto;padding:0 1.5rem}
.text-center{text-align:center}
.mb-1{margin-bottom:.5rem}
.mb-2{margin-bottom:1rem}
.mb-3{margin-bottom:1.5rem}

/* ═══════════════ MOBILE ═══════════════ */
@media(max-width:768px){
  .hero h1{font-size:1.8rem}
  .hero p{font-size:1rem}
  .hero-search input{padding:.85rem 1rem;font-size:.95rem}
  .hero-search button{padding:.85rem 1.2rem;font-size:.9rem}
  .ingredient-grid{grid-template-columns:1fr}
  .ingredient-hero h1{font-size:1.5rem}
  .nav-links{display:none}
  .trust-badges{gap:1rem}
  .cat-pill{font-size:.8rem;padding:.45rem .9rem}
  .substitute-item{padding:1rem}
  .ingredient-hero{padding:1.25rem}
}

/* ═══════════════ BLOG PAGE ═══════════════ */
.blog-page{max-width:720px;margin:0 auto;padding:2rem 1.5rem}
.blog-page .breadcrumb{margin-bottom:1rem}
.blog-page .article-hero{background:var(--card-bg);border:1px solid var(--border);border-radius:var(--radius-xl);padding:2rem;margin-bottom:2.5rem}
.blog-page .article-hero h1{font-size:2rem;font-weight:800;line-height:1.25;margin-bottom:.75rem}
.blog-page .article-meta{display:flex;align-items:center;gap:.75rem;color:var(--text-muted);font-size:.85rem}
.blog-page .article-content{font-size:1.05rem;line-height:1.85;color:var(--text)}
.blog-page .article-content p{margin-bottom:1.5rem}
.blog-page .article-content h2{font-size:1.55rem;font-weight:700;margin:2.5rem 0 1rem;color:var(--text);line-height:1.3}
.blog-page .article-content h3{font-size:1.2rem;font-weight:600;margin:2rem 0 .75rem;color:var(--text)}
.blog-page .article-content strong{color:var(--text);font-weight:600}
.blog-page .article-content ul,.blog-page .article-content ol{margin:0 0 1.5rem 1.5rem;line-height:1.85}
.blog-page .article-content li{margin-bottom:.5rem}
.blog-page .article-content a{color:var(--primary);text-decoration:underline;text-underline-offset:2px}
.blog-page .article-content a:hover{color:var(--primary-dark)}
.blog-page .article-content blockquote{border-left:4px solid var(--primary);margin:1.5rem 0;padding:.75rem 1.25rem;background:var(--primary-ghost);border-radius:0 var(--radius) var(--radius) 0;color:var(--text-light);font-style:italic}
/* Blog tables */
.blog-page .article-content table{width:100%;border-collapse:collapse;margin:1.5rem 0 2rem;font-size:.88rem;line-height:1.4;word-break:break-word}
/* Mobile: horizontal scroll only when needed */
@media(max-width:768px){
  .blog-page .article-content table{display:block;overflow-x:auto;-webkit-overflow-scrolling:touch;font-size:.82rem}
}
.blog-page .article-content thead{background:var(--primary);color:#fff}
.blog-page .article-content th{padding:.55rem .65rem;text-align:left;font-weight:600;white-space:nowrap;font-size:.82rem}
.blog-page .article-content td{padding:.55rem .65rem;border-bottom:1px solid var(--border);vertical-align:top;line-height:1.45}
.blog-page .article-content tbody tr:nth-child(even){background:var(--primary-ghost)}
.blog-page .article-content tbody tr:hover{background:var(--primary-light)}
.blog-page .article-content td:first-child{font-weight:600}
/* Blog related guides */
.blog-page .related-guides{margin-top:3rem;padding-top:2rem;border-top:2px solid var(--border)}
.blog-page .related-guides h3{text-align:center;margin-bottom:1rem}
.blog-page .ad-placeholder{margin:2rem 0}

@media(max-width:768px){
  .blog-page .article-hero h1{font-size:1.5rem}
  .blog-page .article-content{font-size:1rem;line-height:1.75}
  .blog-page .article-content h2{font-size:1.3rem}
  .blog-page .article-content table{font-size:.82rem}
}

