/* ============================================================
   ProteinIQ — main.css  (mobile-first, no frameworks, ~12KB)
   ============================================================ */

/* --- Custom Properties --- */
:root {
  --clr-brand:      #2563eb;
  --clr-brand-dark: #1d4ed8;
  --clr-accent:     #16a34a;
  --clr-danger:     #dc2626;
  --clr-text:       #111827;
  --clr-muted:      #6b7280;
  --clr-border:     #e5e7eb;
  --clr-bg:         #f9fafb;
  --clr-card:       #ffffff;

  --score-high:     #16a34a;
  --score-mid:      #d97706;
  --score-low:      #dc2626;

  --radius:         0.5rem;
  --radius-sm:      0.25rem;
  --shadow-sm:      0 1px 3px rgba(0,0,0,.08);
  --shadow:         0 4px 12px rgba(0,0,0,.1);
  --transition:     0.2s ease;

  --font-sans:      system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono:      'JetBrains Mono', monospace;

  --max-w:          1200px;
  --gap:            1.5rem;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body { font-family: var(--font-sans); color: var(--clr-text); background: var(--clr-bg); line-height: 1.6; }
img  { max-width: 100%; height: auto; display: block; }
a    { color: var(--clr-brand); text-decoration: none; }
a:hover { text-decoration: underline; }
ul, ol { list-style: none; }

/* --- Skip Link --- */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  background: var(--clr-brand);
  color: #fff;
  padding: .5rem 1rem;
  border-radius: var(--radius);
  z-index: 999;
}
.skip-link:focus { top: 1rem; }

/* --- Container --- */
.container { width: 100%; max-width: var(--max-w); margin: 0 auto; padding: 0 1rem; }

/* --- Site Header --- */
.site-header {
  background: #fff;
  border-bottom: 1px solid var(--clr-border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}
.site-header__inner { display: flex; align-items: center; gap: 1rem; height: 60px; }
.logo { font-weight: 700; font-size: 1.25rem; color: var(--clr-text); white-space: nowrap; }
.logo:hover { text-decoration: none; }
.logo__icon { color: var(--clr-brand); }

.main-nav { display: none; flex-wrap: wrap; gap: .25rem; margin-left: auto; }
.main-nav a {
  padding: .3rem .75rem;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  color: var(--clr-text);
  transition: background var(--transition);
}
.main-nav a:hover { background: var(--clr-bg); text-decoration: none; }

.nav-toggle {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: .4rem;
}
.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--clr-text);
  border-radius: 2px;
  transition: var(--transition);
}

@media (min-width: 768px) {
  .nav-toggle { display: none; }
  .main-nav { display: flex; }
}

/* Mobile nav open state (toggled via JS) */
.main-nav.is-open {
  display: flex;
  flex-direction: column;
  position: absolute;
  top: 60px;
  left: 0;
  right: 0;
  background: #fff;
  border-bottom: 1px solid var(--clr-border);
  padding: 1rem;
  box-shadow: var(--shadow);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .55rem 1.25rem;
  border-radius: var(--radius);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid transparent;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  white-space: nowrap;
  text-decoration: none;
}
.btn--primary   { background: var(--clr-brand); color: #fff; }
.btn--primary:hover { background: var(--clr-brand-dark); text-decoration: none; }
.btn--outline   { background: transparent; border-color: var(--clr-brand); color: var(--clr-brand); }
.btn--outline:hover { background: var(--clr-brand); color: #fff; text-decoration: none; }
.btn--danger    { background: var(--clr-danger); color: #fff; border-color: var(--clr-danger); }
.btn--danger:hover { opacity: .9; }
.btn-icon { background: none; border: none; cursor: pointer; font-size: .85rem; color: var(--clr-muted); padding: .2rem; }
.btn-icon:hover { color: var(--clr-danger); }

/* --- Hero --- */
.hero {
  background: linear-gradient(135deg, #1e40af 0%, #2563eb 60%, #3b82f6 100%);
  color: #fff;
  padding: 4rem 1rem;
  margin: 0 -1rem 2.5rem;
  text-align: center;
}
.hero__title { font-size: clamp(1.5rem, 4vw, 2.75rem); font-weight: 800; line-height: 1.2; margin-bottom: .75rem; }
.hero__sub   { font-size: 1.05rem; opacity: .9; max-width: 600px; margin: 0 auto 1.5rem; }
.hero__cta   { display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap; }
.hero .btn--primary { background: #fff; color: var(--clr-brand); }
.hero .btn--primary:hover { background: #e0e7ff; }
.hero .btn--outline { border-color: rgba(255,255,255,.7); color: #fff; }
.hero .btn--outline:hover { background: rgba(255,255,255,.15); }

/* --- Sections --- */
.section { padding: 2.5rem 0; }
.section--alt { background: #fff; margin: 0 -1rem; padding: 2.5rem 1rem; }
.section__title { font-size: 1.4rem; font-weight: 700; margin-bottom: 1.25rem; }
.section__more { text-align: center; margin-top: 1.5rem; }

/* --- Food Grid --- */
.food-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--gap);
}
.food-grid--2 { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

/* --- Food Card --- */
.food-card {
  background: var(--clr-card);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow var(--transition), transform var(--transition);
}
.food-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.food-card__img-link { display: block; aspect-ratio: 4/3; overflow: hidden; }
.food-card__img { width: 100%; height: 100%; object-fit: cover; transition: transform var(--transition); }
.food-card:hover .food-card__img { transform: scale(1.03); }
.food-card__body { padding: 1rem; }
.food-card__name { font-size: 1rem; font-weight: 600; margin: .5rem 0 .25rem; line-height: 1.3; }
.food-card__name a { color: var(--clr-text); }
.food-card__name a:hover { color: var(--clr-brand); text-decoration: none; }
.food-card__brand { font-size: .8rem; color: var(--clr-muted); margin-bottom: .5rem; }
.food-card__stats { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .75rem; }
.food-card__stats li { font-size: .82rem; background: var(--clr-bg); border-radius: var(--radius-sm); padding: .2rem .5rem; }
.food-card__stats li strong { color: var(--clr-brand); }
.food-card__actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.food-card__actions .btn { font-size: .8rem; padding: .35rem .8rem; flex: 1; }

/* --- Score Badge --- */
.score-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  font-weight: 700;
  font-size: .85rem;
  color: #fff;
  float: right;
  margin-left: .5rem;
}
.score--high { background: var(--score-high); }
.score--mid  { background: var(--score-mid); }
.score--low  { background: var(--score-low); }

/* --- Score Row (detail page) --- */
.score-row { display: flex; gap: 1rem; margin: 1rem 0; flex-wrap: wrap; }
.score-box {
  text-align: center;
  padding: .75rem 1.25rem;
  border-radius: var(--radius);
  min-width: 80px;
  color: #fff;
}
.score-box--overall { background: var(--clr-brand); }
.score-box--cutting { background: var(--score-high); }
.score-box--bulking { background: var(--score-mid); }
.score-box__val { display: block; font-size: 1.8rem; font-weight: 800; line-height: 1; }
.score-box__lbl { font-size: .75rem; opacity: .9; }

/* --- Filter Bar --- */
.filter-bar { background: #fff; border: 1px solid var(--clr-border); border-radius: var(--radius); padding: 1rem; margin-bottom: 1.5rem; }
.filter-group { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; margin-bottom: .75rem; }
.filter-group:last-of-type { margin-bottom: 0; }
.filter-label { font-size: .8rem; font-weight: 600; color: var(--clr-muted); min-width: 50px; }
.chip-group { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip {
  padding: .25rem .75rem;
  border: 1px solid var(--clr-border);
  border-radius: 999px;
  font-size: .8rem;
  cursor: pointer;
  background: #fff;
  color: var(--clr-text);
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.chip:hover { border-color: var(--clr-brand); color: var(--clr-brand); }
.chip--active { background: var(--clr-brand); border-color: var(--clr-brand); color: #fff; }
.filter-select {
  padding: .3rem .65rem;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
  font-size: .85rem;
  background: #fff;
  cursor: pointer;
}
.filter-actions { display: flex; gap: .5rem; margin-top: .75rem; }

/* --- Breadcrumb --- */
.breadcrumb { margin-bottom: 1rem; }
.breadcrumb ol { display: flex; flex-wrap: wrap; gap: .35rem; font-size: .85rem; color: var(--clr-muted); }
.breadcrumb li + li::before { content: '/'; margin-right: .35rem; }
.breadcrumb a { color: var(--clr-brand); }

/* --- Food Detail --- */
.food-detail { padding: 1.5rem 0; }
.food-detail__hero { display: grid; gap: 2rem; margin-bottom: 2rem; }
@media (min-width: 640px) { .food-detail__hero { grid-template-columns: 1fr 1fr; } }
.food-detail__img { border-radius: var(--radius); width: 100%; }
.food-detail__name { font-size: clamp(1.3rem, 3vw, 2rem); font-weight: 800; line-height: 1.2; margin-bottom: .25rem; }
.food-detail__brand { color: var(--clr-muted); font-size: .9rem; margin-bottom: .5rem; }
.food-detail__price { font-size: 1.5rem; font-weight: 700; color: var(--clr-brand); margin: .75rem 0; }
.food-detail__store { font-size: .9rem; font-weight: 400; color: var(--clr-muted); }

.nutrition-table { width: 100%; border-collapse: collapse; margin-top: .75rem; }
.nutrition-table th, .nutrition-table td { padding: .6rem 1rem; border-bottom: 1px solid var(--clr-border); font-size: .9rem; text-align: left; }
.nutrition-table th { background: var(--clr-bg); width: 50%; font-weight: 600; }

.food-detail__nutrition, .food-detail__summary { margin-bottom: 2rem; }
.food-detail__nutrition h2, .food-detail__summary h2 { font-size: 1.15rem; font-weight: 700; margin-bottom: .75rem; border-bottom: 2px solid var(--clr-brand); padding-bottom: .4rem; display: inline-block; }

/* --- Compare Table --- */
.compare-table-wrap { overflow-x: auto; }
.compare-table { width: 100%; border-collapse: collapse; min-width: 500px; }
.compare-table th, .compare-table td { padding: .65rem 1rem; border: 1px solid var(--clr-border); font-size: .85rem; vertical-align: middle; }
.compare-table thead th { background: var(--clr-bg); text-align: center; }
.compare-table thead th img { margin: 0 auto .4rem; border-radius: var(--radius-sm); }
.compare-table tbody tr:nth-child(even) td { background: #fafafa; }
.cell--best { background: #dcfce7 !important; font-weight: 700; }
.compare-empty { text-align: center; padding: 3rem; }
.compare-actions { margin-top: 1rem; display: flex; gap: .5rem; }

/* --- Search Form --- */
.search-form { display: flex; gap: .5rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.search-input {
  flex: 1;
  min-width: 200px;
  padding: .55rem 1rem;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  font-size: 1rem;
}
.search-input:focus { outline: 2px solid var(--clr-brand); }

/* --- Page Header --- */
.page-header { margin-bottom: 1.5rem; }
.page-header h1 { font-size: clamp(1.4rem, 4vw, 2.25rem); font-weight: 800; margin-bottom: .5rem; }
.page-intro { color: var(--clr-muted); max-width: 680px; margin-bottom: .5rem; }
.result-count { font-size: .85rem; color: var(--clr-muted); }
.no-results { padding: 2rem; text-align: center; color: var(--clr-muted); background: #fff; border-radius: var(--radius); border: 1px dashed var(--clr-border); }

/* --- Store & Goal Cards --- */
.store-grid, .card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
}
.store-card, .goal-card {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem;
  background: #fff;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  font-weight: 600;
  font-size: .95rem;
  text-align: center;
  color: var(--clr-text);
  transition: box-shadow var(--transition), border-color var(--transition);
}
.store-card:hover, .goal-card:hover { box-shadow: var(--shadow); border-color: var(--clr-brand); text-decoration: none; }

/* --- Two col --- */
.two-col { display: grid; gap: 2rem; }
@media (min-width: 900px) { .two-col { grid-template-columns: 1fr 1fr; } }

/* --- Site Footer --- */
.site-footer { background: #111827; color: #9ca3af; padding: 2.5rem 1rem; margin-top: 4rem; }
.site-footer__inner { display: flex; flex-direction: column; align-items: center; gap: 1rem; text-align: center; }
.site-footer__nav { display: flex; flex-wrap: wrap; gap: .75rem; justify-content: center; }
.site-footer__nav a { color: #9ca3af; font-size: .85rem; }
.site-footer__nav a:hover { color: #fff; }
.site-footer__copy { font-size: .85rem; }
.site-footer__disclaimer { font-size: .75rem; opacity: .7; max-width: 600px; }

/* --- Error page --- */
.error-page { text-align: center; padding: 5rem 1rem; }
.error-page h1 { font-size: 2rem; margin-bottom: 1rem; }
.error-page p { color: var(--clr-muted); margin-bottom: 2rem; }
.error-page__actions { display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap; }

/* --- View transitions (modern browsers) --- */
@media (prefers-reduced-motion: no-preference) {
  @supports (view-transition-name: none) {
    ::view-transition-group(*),
    ::view-transition-old(*),
    ::view-transition-new(*) {
      animation-duration: 0.25s;
      animation-timing-function: cubic-bezier(0.19, 1, 0.22, 1);
    }
  }
}

/* --- Utilities --- */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
