/* Dinner Planner — photo-forward, phone-first.
   Warm cream, heavy black type and a coral accent, from the cooking-magazine
   reference Karma picked (2026-07-28). It replaced a near-black scheme whose
   argument was that food photos should be the brightest thing on screen at 6pm.
   That argument still holds, so the photos keep their own dark treatment: the
   veils, white captions and text shadows on .recipe-card and .surprise-card sit
   ON the photograph, not on the page, and are deliberately unchanged. Lighten
   those and the food stops leading. */

:root {
  --bg: #f1eae0;
  --surface: #fffdfa;
  --surface-2: #e9e0d3;
  --line: #ddd1c1;
  --text: #1c1a18;
  --muted: #6b6154;

  /* Two corals, because one cannot do both jobs on a light background:
     --accent is a FILL and is dark enough for white text on it (4.6:1).
     --accent-ink is for the accent used AS TEXT on cream (4.8:1) — the nav's
     current tab and a pressed filter chip. The reference's brighter coral
     measured 3.6:1 with white on it and 3.2:1 as text, both of which fail
     WCAG AA, and the tab label failing is not a cosmetic problem. */
  --accent: #c9432c;
  --accent-ink: #b83a24;
  --accent-soft: #fae4de;

  /* Deeper than the old dark-theme versions: these carry the cook chips, and a
     pastel that read fine on near-black is unreadable on cream. */
  --karma: #b34570;
  --geordan: #2c6d8f;
  --together: #6a4ea6;
  --out: #8b8279;

  --radius: 16px;
  --nav-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body { padding-bottom: calc(var(--nav-h) + var(--safe-b)); }

/* Heavy and tight, following the reference: headings carry the personality
   here, since the palette itself is quiet. */
h1, h2, h3 { margin: 0; font-weight: 800; letter-spacing: -0.022em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 0.75rem; }

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, textarea, select {
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.6rem 0.7rem;
  width: 100%;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { resize: vertical; min-height: 5rem; line-height: 1.55; }
label { display: block; font-size: 0.82rem; color: var(--muted); margin: 0 0 0.3rem; }

.app { max-width: 720px; margin: 0 auto; }
.view { padding: 1rem 1rem 2rem; }
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 1rem; }
.muted { color: var(--muted); }
.small { font-size: 0.84rem; }
.center { text-align: center; }
.row { display: flex; gap: 0.6rem; align-items: center; }
.row-wrap { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; }
.stack > * + * { margin-top: 0.85rem; }
.grow { flex: 1; min-width: 0; }

/* ---- buttons ---- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.62rem 0.95rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 0.92rem; font-weight: 550;
  min-height: 42px;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff7f4; font-weight: 700; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-danger { color: #a8281c; border-color: #e8cac4; }
.btn-block { width: 100%; }
.btn-lg { padding: 0.85rem 1.2rem; font-size: 1rem; min-height: 52px; }

/* ---- cards ---- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 2rem 1.25rem;
  text-align: center;
  color: var(--muted);
}

/* ---- recipe grid: photos lead ---- */

.recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.75rem;
}

.recipe-card {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-2);
  text-align: left;
  padding: 0;
  border: none;
}
.recipe-card img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.recipe-card .fallback {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: 2rem; opacity: 0.45;
}
.recipe-card .veil {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.92) 0%, rgba(0,0,0,0.55) 38%, rgba(0,0,0,0) 72%);
}
.recipe-card .meta {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 0.7rem 0.7rem 0.75rem;
}
/* Anything sitting ON a photograph declares its own colour and never inherits.
   These used to inherit --text, which was near-white under the old dark theme
   and became near-black when the app went cream — leaving card titles
   unreadable against their own photos. Inheriting here is always a bug: the
   backdrop is a photo, not the page. */
.recipe-card .title {
  color: #ffffff;
  font-weight: 700; font-size: 0.95rem; line-height: 1.25;
  text-shadow: 0 1px 3px rgba(0,0,0,0.95), 0 2px 12px rgba(0,0,0,0.8);
}
.recipe-card .sub {
  color: #ece4da; font-size: 0.75rem; margin-top: 0.2rem;
  text-shadow: 0 1px 3px rgba(0,0,0,0.9);
}
.recipe-card .flag {
  position: absolute; top: 0.55rem; right: 0.55rem;
  background: rgba(0,0,0,0.55); backdrop-filter: blur(6px);
  border-radius: 999px; padding: 0.15rem 0.45rem; font-size: 0.8rem;
}

/* ---- chips ---- */

.chip {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 0.82rem;
  white-space: nowrap;
  min-height: 34px;
}
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); }
.chip-sm { font-size: 0.75rem; padding: 0.2rem 0.5rem; min-height: 26px; }

.cook-chip { font-weight: 600; border-width: 1px; }
.cook-karma { color: var(--karma); border-color: color-mix(in srgb, var(--karma) 45%, transparent); background: color-mix(in srgb, var(--karma) 12%, transparent); }
.cook-geordan { color: var(--geordan); border-color: color-mix(in srgb, var(--geordan) 45%, transparent); background: color-mix(in srgb, var(--geordan) 12%, transparent); }
.cook-together { color: var(--together); border-color: color-mix(in srgb, var(--together) 45%, transparent); background: color-mix(in srgb, var(--together) 12%, transparent); }
.cook-eating_out { color: var(--out); border-color: var(--line); }

/* ---- planner ---- */

.day {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.8rem 0.85rem;
}
.day.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-soft); }
.day-head { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; margin-bottom: 0.55rem; }
.day-name { font-weight: 650; font-size: 0.95rem; }
.day-date { color: var(--muted); font-size: 0.8rem; font-weight: 450; }

.meal {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.4rem 0; border-top: 1px solid var(--line);
}
.meal:first-of-type { border-top: none; }
.meal-thumb {
  width: 44px; height: 44px; border-radius: 10px; object-fit: cover;
  background: var(--surface-2); flex: none;
}
.meal-title { font-size: 0.92rem; }

/* ---- surprise ---- */

.surprise-card {
  position: relative;
  border-radius: 22px;
  overflow: hidden;
  aspect-ratio: 4 / 5;
  background: var(--surface-2);
  margin-bottom: 1rem;
}
.surprise-card img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.surprise-card .fallback { position: absolute; inset: 0; display: grid; place-items: center; font-size: 4rem; opacity: 0.4; }
.surprise-card .veil { position: absolute; inset: 0; background: linear-gradient(to top, rgba(0,0,0,0.88) 6%, rgba(0,0,0,0.15) 55%, rgba(0,0,0,0) 78%); }
.surprise-card .meta { position: absolute; left: 0; right: 0; bottom: 0; padding: 1.1rem; }
.surprise-card h2 {
  color: #ffffff; font-size: 1.5rem;
  text-shadow: 0 1px 4px rgba(0,0,0,0.95), 0 2px 16px rgba(0,0,0,0.8);
}
.surprise-card .meta, .surprise-card .meta .muted, .surprise-card .meta .small { color: #ece4da; }

/* ---- shopping ---- */

.shop-item {
  display: flex; align-items: flex-start; gap: 0.7rem;
  padding: 0.65rem 0.2rem;
  border-bottom: 1px solid var(--line);
  width: 100%; text-align: left;
}
.shop-item:last-child { border-bottom: none; }
.shop-box {
  flex: none; width: 22px; height: 22px; margin-top: 2px;
  border-radius: 6px; border: 1.5px solid var(--line);
  display: grid; place-items: center; font-size: 0.75rem;
}
.shop-item.done .shop-box { background: var(--accent); border-color: var(--accent); color: #fff7f4; }
.shop-item.done .shop-text { text-decoration: line-through; color: var(--muted); }
.shop-item.have .shop-text { text-decoration: line-through; text-decoration-style: dotted; color: var(--muted); }
.shop-qty { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 0.85rem; }

/* ---- bars, tallies ---- */

.bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); }
.bar.over > span { background: #b8362a; }

.tally { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; }
.tally .n { font-size: 1.8rem; font-weight: 650; line-height: 1.1; }

/* ---- nav ---- */

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(6, 1fr);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.nav button {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; height: var(--nav-h);
  font-size: 0.68rem; color: var(--muted);
}
.nav button .ico { font-size: 1.2rem; line-height: 1; }
.nav button > span:last-child { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.nav button[aria-current="page"] { color: var(--accent-ink); }

/* ---- sheet / modal ---- */

.sheet-backdrop {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(44,30,24,0.45);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  width: 100%; max-width: 720px;
  max-height: 92vh; overflow-y: auto;
  padding: 1rem 1rem calc(1.25rem + var(--safe-b));
  border-top: 1px solid var(--line);
}
.sheet-grab { width: 38px; height: 4px; border-radius: 999px; background: var(--line); margin: 0 auto 0.9rem; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + var(--safe-b) + 14px);
  z-index: 60;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 0.55rem 1rem; font-size: 0.88rem;
  box-shadow: 0 8px 28px rgba(60,42,32,0.18);
}

.banner {
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  border-radius: 12px; padding: 0.6rem 0.8rem; font-size: 0.84rem; color: #8a2b1c;
}

/* Inline explanation inside a sheet — used when an import cannot be read.
   Deliberately not a toast: the person needs to see it while fixing the link. */
.notice {
  border-radius: 12px; padding: 0.6rem 0.8rem;
  font-size: 0.84rem; line-height: 1.45;
}
.notice-warn {
  background: #fdf0e6;
  border: 1px solid #edcdb2;
  color: #8a4a1c;
}

.split-note { color: var(--muted); font-size: 0.75rem; }

.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.auth-card { width: 100%; max-width: 360px; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  .btn:active { transform: none; }
}

/* ---- kitchen (fridge / freezer) ---- */

.inv-row {
  display: flex; align-items: center; gap: 0.7rem;
  width: 100%; text-align: left;
  padding: 0.6rem 0.1rem;
  border-top: 1px solid var(--line);
  color: inherit;
}
.inv-row:first-of-type { border-top: none; }
.inv-name { font-size: 0.95rem; }

.inv-date {
  flex: none; font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  padding: 0.15rem 0.5rem; border-radius: 999px;
  border: 1px solid transparent;
}
/* Expired and expiring are the whole point of the screen, so they are the only
   things allowed to shout on it. */
.inv-expired { color: #8a2b1c; background: #fae4de; border-color: #edbfb4; font-weight: 600; }
.inv-soon    { color: #8a4a1c; background: #fdf0e6; border-color: #edcdb2; font-weight: 600; }
.inv-dated   { color: var(--muted); }

/* The Tonight nudge is a button, so it needs to stop looking like body text. */
.nudge { display: block; width: 100%; text-align: left; }
.nudge strong { display: block; margin-bottom: 0.15rem; }

/* ---- month view (next 4 weeks) ---- */

.month-day {
  display: flex; align-items: center; gap: 0.6rem;
  width: 100%; text-align: left; color: inherit;
  padding: 0.5rem 0.1rem;
  border-top: 1px solid var(--line);
}
.month-day:first-of-type { border-top: none; }
.month-day.today .month-day-name { color: var(--accent-ink); font-weight: 700; }
.month-day-name { flex: none; width: 5.4rem; font-size: 0.85rem; font-weight: 600; }
.month-day-meals {
  font-size: 0.85rem; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
