/* app.css — Mealwise
 * Mobile-first: the Shop view gets used one-handed in a supermarket aisle,
 * so tap targets are large and the store sections are skimmable at arm's length.
 */

:root {
  --bg: #f7f5f2;
  --surface: #ffffff;
  --surface-2: #f0ede8;
  --border: #e2ddd5;
  --text: #23201c;
  --text-dim: #6d675f;
  --text-faint: #9a938a;

  --accent: #2f7d4f;
  --accent-soft: #e6f2ea;
  --accent-text: #1f5c39;

  --warn: #a8681a;
  --warn-soft: #fdf2e2;
  --danger: #b4442f;
  --danger-soft: #fbeae7;

  --coles: #d1373a;
  --aldi: #1f4c9e;
  --bigw: #1a8ac4;
  --costco: #5a3f9e;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 12px rgba(0,0,0,.04);
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161513;
    --surface: #201f1c;
    --surface-2: #2a2825;
    --border: #37342f;
    --text: #eeebe6;
    --text-dim: #a8a29a;
    --text-faint: #78726a;

    --accent: #5fb583;
    --accent-soft: #1c3427;
    --accent-text: #8fd0aa;

    --warn: #d99a4e;
    --warn-soft: #33280f;
    --danger: #e07a63;
    --danger-soft: #3a201a;

    --coles: #e8615f;
    --aldi: #6b93df;
    --bigw: #56b4e0;
    --costco: #9b7fd4;

    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 12px rgba(0,0,0,.25);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; line-height: 1.25; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
a { color: var(--accent-text); }

button, input, select, textarea { font: inherit; color: inherit; }

/* ─────────────────────────────── layout ─────────────────────────────── */

.app { max-width: 1100px; margin: 0 auto; padding: 0 1rem 6rem; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  margin: 0 -1rem 1rem;
  padding: .7rem 1rem;
  display: flex; align-items: center; gap: .75rem;
}
.topbar .brand { font-weight: 700; letter-spacing: -.02em; font-size: 1.05rem; }
.topbar .brand span { color: var(--accent); }
.topbar .spacer { flex: 1; }

/* Bottom tab bar on phones, inline tabs on wider screens. */
.nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  display: flex; background: var(--surface);
  border-top: 1px solid var(--border);
  padding: .3rem .25rem calc(.3rem + env(safe-area-inset-bottom));
}
.nav a {
  flex: 1; text-align: center; text-decoration: none;
  color: var(--text-faint); font-size: .68rem; font-weight: 600;
  padding: .35rem .1rem; border-radius: var(--radius-sm);
  display: flex; flex-direction: column; align-items: center; gap: .15rem;
}
.nav a .ic { font-size: 1.15rem; line-height: 1; }
.nav a.on { color: var(--accent); background: var(--accent-soft); }

@media (min-width: 760px) {
  .nav {
    position: static; border-top: 0; background: transparent;
    padding: 0; gap: .25rem; margin-left: auto;
  }
  .nav a { flex: none; flex-direction: row; font-size: .85rem; padding: .35rem .7rem; }
  .nav a .ic { font-size: 1rem; }
  .app { padding-bottom: 3rem; }
}

/* ─────────────────────────────── pieces ─────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  margin-bottom: 1rem;
}
.card.tight { padding: .75rem; }

.row { display: flex; align-items: center; gap: .6rem; }
.row.wrap { flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.stack { display: flex; flex-direction: column; gap: .5rem; }
.grow { flex: 1; min-width: 0; }

.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.small { font-size: .82rem; }
.tiny  { font-size: .74rem; }
.num   { font-variant-numeric: tabular-nums; font-family: var(--mono); }
.right { text-align: right; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.btn {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: .5rem .85rem; cursor: pointer; font-weight: 600; font-size: .88rem;
  transition: background .12s, border-color .12s;
}
.btn:hover { border-color: var(--text-faint); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: .3rem .55rem; font-size: .78rem; }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

input[type=text], input[type=number], input[type=date], select, textarea {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .45rem .6rem; width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent);
}
label.field { display: block; margin-bottom: .7rem; }
label.field > span { display: block; font-size: .8rem; font-weight: 600;
  color: var(--text-dim); margin-bottom: .2rem; }

.pill {
  display: inline-flex; align-items: center; gap: .25rem;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: .1rem .5rem; font-size: .72rem; font-weight: 600;
  color: var(--text-dim); white-space: nowrap;
}
.pill.accent { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
.pill.warn   { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }

/* Scoped to .store-dot on purpose: these same s-* classes are also applied to
   the store NAME, which must take the colour as text, not as a filled block. */
.store-dot { width: .6rem; height: .6rem; border-radius: 50%; flex: none; }
.store-dot.s-coles  { background: var(--coles); }
.store-dot.s-aldi   { background: var(--aldi); }
.store-dot.s-bigw   { background: var(--bigw); }
.store-dot.s-costco { background: var(--costco); }
.store-name.s-coles  { color: var(--coles); }
.store-name.s-aldi   { color: var(--aldi); }
.store-name.s-bigw   { color: var(--bigw); }
.store-name.s-costco { color: var(--costco); }

/* A seeded (unconfirmed) price is always visibly provisional. */
.seeded { color: var(--warn); border-bottom: 1px dashed currentColor; cursor: pointer; }
.seeded::after { content: "?"; font-size: .7em; vertical-align: super; margin-left: 1px; }
.confirmed { cursor: pointer; border-bottom: 1px dashed transparent; }
.confirmed:hover { border-bottom-color: var(--text-faint); }

/* A price read from the retailer's own site — real, but not confirmed by you
   in your store, so it gets a quiet tick rather than the amber "?" of a guess. */
.verified { cursor: pointer; border-bottom: 1px dashed transparent; color: var(--accent-text); }
.verified::after { content: "✓"; font-size: .7em; vertical-align: super; margin-left: 1px; opacity: .7; }
.verified:hover { border-bottom-color: var(--accent); }

.bar {
  height: 6px; border-radius: 3px; background: var(--surface-2);
  overflow: hidden; display: flex;
}
.bar > i { display: block; height: 100%; background: var(--accent); }
.bar > i.over { background: var(--warn); }
.bar.thin { height: 4px; }

.banner {
  border-radius: var(--radius); padding: .7rem .9rem; font-size: .85rem;
  border: 1px solid transparent; margin-bottom: 1rem;
}
.banner.info { background: var(--accent-soft); color: var(--accent-text); }
.banner.warn { background: var(--warn-soft); color: var(--warn); }

.empty { text-align: center; padding: 2.5rem 1rem; color: var(--text-faint); }

/* ─────────────────────────────── plan grid ─────────────────────────────── */

.week-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .75rem; }

.days { display: grid; gap: .75rem; }
@media (min-width: 900px) { .days { grid-template-columns: repeat(7, 1fr); gap: .5rem; } }

.day {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column;
}
.day.today { border-color: var(--accent); }
.day > header {
  padding: .45rem .6rem; background: var(--surface-2);
  display: flex; align-items: baseline; gap: .4rem; border-bottom: 1px solid var(--border);
}
.day > header .dn { font-weight: 700; font-size: .82rem; }
.day > header .dd { font-size: .7rem; color: var(--text-faint); }
.day .slots { display: flex; flex-direction: column; }

.slot {
  border-bottom: 1px solid var(--border); padding: .4rem .6rem;
  min-height: 3rem; cursor: pointer; display: flex; flex-direction: column;
  justify-content: center; gap: .1rem; background: none; border-left: 0;
  border-right: 0; border-top: 0; width: 100%; text-align: left; font: inherit;
}
.slot:last-child { border-bottom: 0; }
.slot:hover { background: var(--surface-2); }
.slot .lbl { font-size: .62rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-faint); font-weight: 700; }
.slot .nm { font-size: .8rem; line-height: 1.25; font-weight: 550; }
.slot.filled .lbl { color: var(--text-faint); }
.slot.empty-slot .nm { color: var(--text-faint); font-weight: 400; }
.slot .meta { font-size: .68rem; color: var(--text-faint); }
.slot.leftover { background: var(--accent-soft); }
.slot.leftover .nm { color: var(--accent-text); }

.day > footer { padding: .45rem .6rem; border-top: 1px solid var(--border);
  font-size: .7rem; color: var(--text-dim); display: flex; flex-direction: column; gap: .25rem; }

/* ─────────────────────────────── shop ─────────────────────────────── */

.store-block { margin-bottom: 1rem; }
.store-block > header {
  display: flex; align-items: center; gap: .5rem; padding: .6rem .85rem;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0; font-weight: 700;
}
.store-block .lines {
  border: 1px solid var(--border); border-top: 0;
  border-radius: 0 0 var(--radius) var(--radius); background: var(--surface);
}
.aisle-head {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-faint); font-weight: 700; padding: .5rem .85rem .15rem;
}
.line { display: flex; align-items: flex-start; gap: .7rem; padding: .55rem .85rem;
  border-top: 1px solid var(--border); }
.line:first-of-type { border-top: 0; }
.line.done { opacity: .45; }
.line.done .nm { text-decoration: line-through; }
.tick {
  width: 1.4rem; height: 1.4rem; flex: none; margin-top: .1rem;
  border: 2px solid var(--border); border-radius: 6px; background: transparent;
  cursor: pointer; display: grid; place-items: center; color: transparent;
  font-size: .85rem; font-weight: 700;
}
.tick.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.line .nm { font-weight: 600; font-size: .9rem; }
.line .sub { font-size: .74rem; color: var(--text-faint); }
.line .cost { font-weight: 700; white-space: nowrap; }

.tip { font-size: .72rem; color: var(--warn); margin-top: .2rem; }

/* ─────────────────────────────── recipes ─────────────────────────────── */

.rgrid { display: grid; gap: .75rem; grid-template-columns: 1fr; }
@media (min-width: 600px) { .rgrid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 960px) { .rgrid { grid-template-columns: repeat(3, 1fr); } }

.rcard {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .8rem; cursor: pointer;
  display: flex; flex-direction: column; gap: .4rem; text-align: left;
  font: inherit; color: inherit;
}
.rcard:hover { border-color: var(--accent); }
.rcard .nm { font-weight: 650; font-size: .95rem; line-height: 1.3; }
.rcard .stats { display: flex; gap: .6rem; font-size: .74rem; color: var(--text-dim);
  font-variant-numeric: tabular-nums; }
.rcard .stats b { color: var(--text); font-weight: 700; }

/* ─────────────────────────────── modal ─────────────────────────────── */

.modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 100;
  display: flex; align-items: flex-end; justify-content: center; padding: 0;
}
@media (min-width: 700px) { .modal-bg { align-items: center; padding: 2rem; } }
.modal {
  background: var(--bg); border-radius: var(--radius) var(--radius) 0 0;
  width: 100%; max-width: 640px; max-height: 88vh; overflow-y: auto;
  padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom));
  border: 1px solid var(--border);
}
@media (min-width: 700px) { .modal { border-radius: var(--radius); } }
.modal > header { display: flex; align-items: center; gap: .5rem;
  position: sticky; top: -1rem; background: var(--bg); padding: .25rem 0 .6rem;
  margin: -.25rem 0 .5rem; border-bottom: 1px solid var(--border); z-index: 2; }

/* ─────────────────────────────── cook mode ─────────────────────────────── */

.cook { max-width: 720px; margin: 0 auto; }
.cook .step {
  font-size: 1.3rem; line-height: 1.55; padding: 1.25rem 0; min-height: 8rem;
}
@media (min-width: 700px) { .cook .step { font-size: 1.5rem; } }
.cook .stepnum { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-faint); font-weight: 700; margin-bottom: .5rem; }
.cook .ing { display: flex; gap: .6rem; padding: .45rem 0;
  border-bottom: 1px solid var(--border); font-size: 1rem; }
.cook .ing:last-child { border-bottom: 0; }

/* ─────────────────────────────── value table ─────────────────────────────── */

.vtable { width: 100%; border-collapse: collapse; font-size: .85rem; }
.vtable th {
  text-align: left; font-size: .7rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-faint); padding: .4rem .5rem; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface);
}
.vtable td { padding: .45rem .5rem; border-bottom: 1px solid var(--border); }
.vtable td.n { font-variant-numeric: tabular-nums; text-align: right; font-weight: 600; }
.vtable tr:last-child td { border-bottom: 0; }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.rank { color: var(--text-faint); font-variant-numeric: tabular-nums; width: 1.5rem; }

/* ─────────────────────────────── print ─────────────────────────────── */

@media print {
  .nav, .topbar, .btn, .no-print { display: none !important; }
  .app { padding: 0; max-width: none; }
  .card, .store-block .lines, .store-block > header {
    box-shadow: none; border-color: #ccc; break-inside: avoid;
  }
  body { background: #fff; color: #000; font-size: 11pt; }
  .line { padding: .3rem .5rem; }
  .tick { border-color: #666; }
}
