/* RecipeHunter — mobile-first, kitchen-friendly.
   Big tap targets, high contrast, and a step view readable at arm's length. */

:root {
  --bg: #fbf9f6;
  --surface: #ffffff;
  --surface-2: #f4f0ea;
  --ink: #1e1b18;
  --ink-2: #5f574e;
  --ink-3: #8c8378;
  --line: #e6dfd5;
  --accent: #c8492b;
  --accent-soft: #fbeae5;
  --good: #2f7d4f;
  --good-soft: #e6f2ea;
  --warn: #b4791a;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow: 0 1px 2px rgba(30, 27, 24, .05), 0 8px 24px rgba(30, 27, 24, .06);
  --maxw: 1120px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14120f;
    --surface: #1d1a16;
    --surface-2: #262119;
    --ink: #f3eee7;
    --ink-2: #bbb1a4;
    --ink-3: #8d8377;
    --line: #332c24;
    --accent: #ef7d5d;
    --accent-soft: #3a201a;
    --good: #6cc48c;
    --good-soft: #1c3327;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 84px; /* room for the mobile tab bar */
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }

/* --- header ---------------------------------------------------------- */

.topbar {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar .wrap {
  display: flex; align-items: center; gap: 14px; height: 58px;
}
.brand { font-weight: 700; letter-spacing: -.02em; font-size: 18px; display: flex; gap: 8px; align-items: center; }
.brand span { color: var(--accent); }
.topnav { margin-left: auto; display: flex; gap: 4px; align-items: center; }
.topnav a {
  padding: 8px 12px; border-radius: 999px; color: var(--ink-2);
  font-size: 14px; font-weight: 550;
}
.topnav a:hover { background: var(--surface-2); color: var(--ink); }
.topnav a.active { background: var(--ink); color: var(--bg); }
/* On phones the bottom tab bar is the navigation, so the top links only
   duplicate it and wrap badly at 375px. Keep just the sign-in call to action. */
@media (max-width: 900px) {
  .topnav a:not(.btn) { display: none; }
  .brand { font-size: 17px; }
}

/* --- bottom tab bar (mobile) ----------------------------------------- */

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  display: none; background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.tabbar a {
  flex: 1; text-align: center; padding: 6px 2px; font-size: 11px;
  color: var(--ink-3); font-weight: 600;
}
.tabbar a.active { color: var(--accent); }
.tabbar .ico { font-size: 20px; display: block; line-height: 1.3; }
@media (max-width: 900px) { .tabbar { display: flex; } }

/* --- generic bits ---------------------------------------------------- */

.page-head { padding: 22px 0 8px; }
.page-head h1 { margin: 0 0 4px; font-size: 26px; letter-spacing: -.02em; }
.page-head p { margin: 0; color: var(--ink-2); font-size: 15px; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 11px 17px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font-size: 14px;
  font-weight: 600; cursor: pointer; font-family: inherit;
  transition: transform .06s ease, background .15s ease;
}
.btn:active { transform: scale(.97); }
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 13px; }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 11px; border-radius: 999px; background: var(--surface-2);
  color: var(--ink-2); font-size: 12.5px; font-weight: 600;
  border: 1px solid transparent; white-space: nowrap;
}
.chip-accent { background: var(--accent-soft); color: var(--accent); }
.chip-good { background: var(--good-soft); color: var(--good); }

input[type=text], input[type=password], input[type=number], input[type=search],
textarea, select {
  width: 100%; padding: 12px 14px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); font: inherit; font-size: 16px; /* 16px stops iOS zoom */
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent;
}
label { font-size: 13px; font-weight: 650; color: var(--ink-2); display: block; margin-bottom: 6px; }

.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.stack > * + * { margin-top: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* --- search / filter bar --------------------------------------------- */

.searchbar { display: flex; gap: 8px; margin: 4px 0 14px; }
.searchbar input { flex: 1; }
.filters { display: flex; gap: 7px; overflow-x: auto; padding: 2px 0 12px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filters a { flex: none; }

/* --- recipe grid ----------------------------------------------------- */

.grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
@media (max-width: 560px) { .grid { grid-template-columns: 1fr; gap: 14px; } }

.rcard { overflow: hidden; position: relative; display: flex; flex-direction: column; }
.rcard .thumb { aspect-ratio: 4/3; background: var(--surface-2); overflow: hidden; }
.rcard .thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s ease; }
.rcard:hover .thumb img { transform: scale(1.04); }
.rcard .body { padding: 13px 15px 15px; display: flex; flex-direction: column; gap: 7px; flex: 1; }
.rcard h3 { margin: 0; font-size: 16.5px; letter-spacing: -.01em; line-height: 1.3; }
.rcard .sub { color: var(--ink-2); font-size: 13.5px; margin: 0; line-height: 1.4; }
.rcard .meta { margin-top: auto; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.fav-btn {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  width: 38px; height: 38px; border-radius: 999px; border: none;
  background: rgba(255,255,255,.92); cursor: pointer; font-size: 17px;
  display: grid; place-items: center; box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.fav-btn.on { background: var(--accent); }

.pctbar { height: 5px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.pctbar i { display: block; height: 100%; background: var(--good); border-radius: 999px; }

/* --- recipe detail --------------------------------------------------- */

.hero { position: relative; border-radius: var(--radius-lg); overflow: hidden; margin-top: 16px; }
.hero img { width: 100%; aspect-ratio: 4/3; object-fit: cover; }
@media (min-width: 800px) { .hero img { aspect-ratio: 21/9; } }
.hero .overlay {
  position: absolute; inset: auto 0 0 0; padding: 44px 20px 18px; color: #fff;
  background: linear-gradient(to top, rgba(0,0,0,.82), rgba(0,0,0,.32) 55%, transparent);
}
.hero h1 { margin: 0 0 3px; font-size: 25px; letter-spacing: -.02em; line-height: 1.2; }
.hero .sub { margin: 0; opacity: .9; font-size: 14.5px; }

.statgrid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 1px; background: var(--line); border-radius: var(--radius);
  overflow: hidden; border: 1px solid var(--line);
}
.statgrid div { background: var(--surface); padding: 12px 10px; text-align: center; }
.statgrid .k { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 700; }
.statgrid .v { font-size: 16px; font-weight: 650; margin-top: 2px; }

.cols { display: grid; gap: 22px; }
/* Grid items default to min-width:auto, so a wide child (the ingredient
   picker) can push the track past the viewport. Pin it to zero and let the
   child scroll instead. */
.cols > * { min-width: 0; }
@media (min-width: 900px) { .cols { grid-template-columns: minmax(0,1fr) minmax(0,1.25fr); align-items: start; } }

section.block { margin-top: 22px; }
section.block > h2 {
  font-size: 13px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--ink-3); margin: 0 0 10px; font-weight: 750;
}

/* --- servings selector ----------------------------------------------- */

.servings { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.servings a {
  min-width: 42px; padding: 9px 12px; text-align: center; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
  font-weight: 650; font-size: 14px; color: var(--ink-2);
}
.servings a.on { background: var(--ink); border-color: var(--ink); color: var(--bg); }

/* --- ingredients ----------------------------------------------------- */

.igroup + .igroup { margin-top: 16px; }
.igroup h3 {
  font-size: 12px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-3); margin: 0 0 6px; font-weight: 750;
  display: flex; align-items: center; gap: 6px;
}
ul.ilist { list-style: none; margin: 0; padding: 0; }
ul.ilist li {
  display: flex; gap: 12px; align-items: baseline;
  padding: 9px 0; border-bottom: 1px solid var(--line);
}
ul.ilist li:last-child { border-bottom: 0; }
.qty {
  flex: none; min-width: 62px; font-variant-numeric: tabular-nums;
  font-weight: 700; font-size: 14.5px;
}
.qty.calc { color: var(--ink-2); font-weight: 600; }
.iname { flex: 1; font-size: 14.5px; }
.iprep { color: var(--ink-3); font-size: 13px; font-style: italic; }
.have-dot { flex: none; width: 8px; height: 8px; border-radius: 999px; background: var(--line); margin-top: 7px; }
.have-dot.yes { background: var(--good); }

/* --- steps ----------------------------------------------------------- */

ol.steps { list-style: none; counter-reset: s; margin: 0; padding: 0; }
ol.steps li { counter-increment: s; display: flex; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); }
ol.steps li:last-child { border-bottom: 0; }
ol.steps li::before {
  content: counter(s); flex: none; width: 28px; height: 28px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-weight: 750;
  font-size: 13px; display: grid; place-items: center;
}
ol.steps h4 { margin: 0 0 3px; font-size: 15px; letter-spacing: -.01em; }
ol.steps p { margin: 0; color: var(--ink-2); font-size: 14.5px; }

.tip {
  background: var(--accent-soft); border-radius: var(--radius);
  padding: 14px 16px; font-size: 14px; color: var(--ink);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
}
.tip strong { color: var(--accent); }

/* --- cook mode ------------------------------------------------------- */

body.cook { background: var(--surface); padding-bottom: 0; }
.cookbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center;
  gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.progress { flex: 1; height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--accent); transition: width .25s ease; }
.cookmain { max-width: 720px; margin: 0 auto; padding: 24px 20px 140px; }
.cookmain .stepno { font-size: 12px; letter-spacing: .09em; text-transform: uppercase; color: var(--accent); font-weight: 800; }
.cookmain h1 { font-size: 27px; margin: 6px 0 16px; letter-spacing: -.02em; line-height: 1.2; }
.cookmain .bodytext { font-size: 19px; line-height: 1.62; color: var(--ink); }
@media (min-width: 700px) { .cookmain .bodytext { font-size: 20px; } }
.cooknav {
  position: fixed; bottom: 0; left: 0; right: 0; display: flex; gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 95%, transparent);
  backdrop-filter: blur(12px); border-top: 1px solid var(--line);
}
.cooknav .btn { flex: 1; padding: 15px; font-size: 15px; }
.stepimg { border-radius: var(--radius); overflow: hidden; margin-bottom: 18px; }

/* --- pantry ---------------------------------------------------------- */

.pantry-tags { display: flex; flex-wrap: wrap; gap: 7px; }
.ptag {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 8px 7px 13px;
  border-radius: 999px; background: var(--surface); border: 1px solid var(--line);
  font-size: 13.5px; font-weight: 600;
}
.ptag button {
  border: none; background: var(--surface-2); color: var(--ink-3); cursor: pointer;
  width: 20px; height: 20px; border-radius: 999px; font-size: 13px; line-height: 1;
  display: grid; place-items: center; padding: 0;
}
.ptag button:hover { background: var(--accent); color: #fff; }

.picker { max-height: 320px; overflow-y: auto; overflow-x: hidden; padding-right: 4px; }
.picker-group + .picker-group { margin-top: 14px; }
.picker-group h4 { margin: 0 0 7px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); }
.picker button {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 7px 13px; font: inherit; font-size: 13.5px; cursor: pointer;
  margin: 0 5px 5px 0; color: var(--ink-2);
}
.picker button:hover { border-color: var(--good); color: var(--good); background: var(--good-soft); }

/* --- ratings --------------------------------------------------------- */

.stars { display: flex; gap: 3px; direction: rtl; justify-content: flex-end; }
.stars input { display: none; }
.stars label {
  font-size: 27px; cursor: pointer; color: var(--line); margin: 0;
  transition: color .12s ease; line-height: 1;
}
.stars input:checked ~ label,
.stars label:hover, .stars label:hover ~ label { color: #e8a33d; }

.seg { display: flex; gap: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.seg input { display: none; }
.seg label {
  flex: 1; text-align: center; padding: 11px 6px; margin: 0; cursor: pointer;
  font-size: 12.5px; font-weight: 650; color: var(--ink-2); background: var(--surface);
  border-right: 1px solid var(--line);
}
.seg label:last-of-type { border-right: 0; }
.seg input:checked + label { background: var(--ink); color: var(--bg); }

.toggle-row { display: flex; gap: 10px; }
.toggle-row label {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 12px; border: 1px solid var(--line); border-radius: var(--radius);
  cursor: pointer; font-size: 14px; font-weight: 650; margin: 0; background: var(--surface);
}
.toggle-row input { display: none; }
.toggle-row input:checked + span { color: var(--accent); }
.toggle-row label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

/* --- misc ------------------------------------------------------------ */

.empty { text-align: center; padding: 48px 20px; color: var(--ink-3); }
.empty .big { font-size: 40px; margin-bottom: 10px; }

.suggest-row {
  display: flex; gap: 14px; align-items: center; padding: 13px 0;
  border-bottom: 1px solid var(--line);
}
.suggest-row:last-child { border-bottom: 0; }
.suggest-row img { width: 66px; height: 66px; border-radius: var(--radius); object-fit: cover; flex: none; }
.suggest-row .info { flex: 1; min-width: 0; }
.suggest-row h3 { margin: 0 0 3px; font-size: 15px; }
.suggest-row .miss { font-size: 12.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest-row .score { flex: none; text-align: right; }
.suggest-row .score b { font-size: 19px; font-variant-numeric: tabular-nums; }

/* Plan rows carry two buttons as well as the text, which squeezes the title
   to a few characters on a phone. Let the actions drop to their own line. */
.plan-row .actions { display: flex; flex-direction: column; gap: 6px; flex: none; }
@media (max-width: 560px) {
  .plan-row { flex-wrap: wrap; }
  .plan-row .info { flex: 1 1 auto; }
  .plan-row .actions { flex-direction: row; width: 100%; }
  .plan-row .actions form { flex: 1; }
  .plan-row .actions .btn { width: 100%; }
}

.cardview { display: grid; gap: 18px; }
@media (min-width: 820px) { .cardview { grid-template-columns: 1fr 1fr; } }
.cardview figure { margin: 0; }
.cardview figcaption { font-size: 12.5px; color: var(--ink-3); margin-top: 7px; text-align: center; }
.cardview img { border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow); }

/* --- calories -------------------------------------------------------- */

.chip-kcal { background: #fdf0e3; color: #a35a12; }
@media (prefers-color-scheme: dark) { .chip-kcal { background: #3a2a17; color: #e8a962; } }

.statgrid .kcal-cell { background: var(--accent-soft); }
.statgrid .kcal-cell .v { color: var(--accent); }

.kcal-hero { padding: 20px; text-align: center; }
.kcal-hero .big-kcal {
  font-size: 46px; font-weight: 750; letter-spacing: -.03em;
  line-height: 1; color: var(--accent); font-variant-numeric: tabular-nums;
}
.kcal-hero .kcal-label {
  font-size: 12px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--ink-3); font-weight: 700; margin-top: 5px;
}
.kcal-hero .macros {
  display: flex; justify-content: center; gap: 18px; flex-wrap: wrap;
  margin-top: 14px; font-size: 13.5px; color: var(--ink-2);
}
.kcal-hero .macros b { color: var(--ink); font-variant-numeric: tabular-nums; }
.macrobar {
  display: flex; height: 8px; border-radius: 999px; overflow: hidden;
  margin-top: 12px; background: var(--surface-2);
}
.macrobar i { display: block; height: 100%; }
.macrobar .m-p { background: #3f7fbf; }
.macrobar .m-c { background: #e0a33c; }
.macrobar .m-f { background: #c8492b; }

.kcal-lines { width: 100%; border-collapse: collapse; margin-top: 16px; font-size: 13.5px; text-align: left; }
.kcal-lines td { padding: 9px 0; border-top: 1px solid var(--line); vertical-align: top; }
.kcal-lines td:last-child { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 650; }
.kcal-lines tr.est td { color: var(--ink-2); }
.kcal-lines tr.sum td { font-weight: 700; }
.kcal-lines .muted { font-weight: 400; }

.tag-est {
  display: inline-block; padding: 1px 7px; border-radius: 999px;
  background: var(--surface-2); color: var(--ink-3);
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; font-weight: 700;
}
.prov { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip-warn { background: #fbf0dd; color: #8a6014; }
@media (prefers-color-scheme: dark) { .chip-warn { background: #382c14; color: #dcae5c; } }

table.nutri { width: 100%; border-collapse: collapse; font-size: 14px; }
table.nutri td { padding: 7px 0; border-bottom: 1px solid var(--line); }
table.nutri td:last-child { text-align: right; font-variant-numeric: tabular-nums; font-weight: 650; }
table.nutri tr:last-child td { border-bottom: 0; }
