/* MealPlanner. Mobile-first, iOS-first. No build step, no framework. */

:root {
  --bg:        #faf9f6;
  --surface:   #ffffff;
  --border:    #e3e0d8;
  --text:      #1c1b18;
  --muted:     #6b675e;
  --accent:    #1f6f4a;
  --accent-dim:#e6f0ea;
  --have:      #2e7d4f;
  --low:       #c98a1b;
  --out:       #b3413b;
  --radius:    12px;
  --tabbar-h:  58px;
  --safe-b:    env(safe-area-inset-bottom, 0px);
  --safe-t:    env(safe-area-inset-top, 0px);

  /* Light only, by design — see CLAUDE.md. Declaring it stops the browser
   * from darkening form controls, scrollbars and autofill on a device set to
   * dark, which would leave grey inputs sitting on paper. */
  color-scheme: light;
}

* { 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, sans-serif;
  /* Stop iOS from bouncing the whole page behind the fixed chrome. */
  overscroll-behavior-y: none;
  -webkit-text-size-adjust: 100%;
}

/* ------------------------------------------------------------ chrome */

#topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(var(--safe-t) + 12px) 16px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

#topbar h1 { margin: 0; font-size: 1.35rem; font-weight: 650; letter-spacing: -0.01em; }

.icon-btn {
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
  padding: 6px 8px;
  cursor: pointer;
  border-radius: 8px;
}
.icon-btn:active { background: var(--accent-dim); }

#view {
  padding: 16px 16px calc(var(--tabbar-h) + var(--safe-b) + 24px);
  max-width: 720px;
  margin: 0 auto;
}

#tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 10;
  display: flex;
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 550;
  cursor: pointer;
  /* Keeps a long-press from selecting the label on iOS. */
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
.tab .glyph { font-size: 1.25rem; line-height: 1; }
.tab[aria-selected="true"] { color: var(--accent); }

/* ------------------------------------------------------------- blocks */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.card h2 { margin: 0 0 10px; font-size: 1rem; font-weight: 650; }

.muted { color: var(--muted); }
.loading { color: var(--muted); padding: 32px 0; text-align: center; }

.kv { display: flex; justify-content: space-between; gap: 16px; padding: 7px 0; }
.kv + .kv { border-top: 1px solid var(--border); }
.kv dt { color: var(--muted); margin: 0; }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.pill.ok    { background: var(--accent-dim); color: var(--have); }
.pill.warn  { background: color-mix(in srgb, var(--low) 18%, transparent); color: var(--low); }
.pill.error { background: color-mix(in srgb, var(--out) 18%, transparent); color: var(--out); }

.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 0;
}
.checklist li + li { border-top: 1px solid var(--border); }
.checklist .mark { flex: none; width: 1.2em; font-weight: 700; }
.checklist .done .mark { color: var(--have); }
.checklist .todo .mark { color: var(--muted); }
.checklist small { display: block; color: var(--muted); }

button.primary {
  width: 100%;
  padding: 13px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}
button.primary:active { filter: brightness(0.92); }

/* iOS install hint. Safari never offers to install a web app, so without this
   the Add to Home Screen step is invisible unless you already know about it.
   Sits above the tab bar, dismisses permanently. */

#install-hint {
  position: fixed;
  left: 8px;
  right: 8px;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 8px);
  z-index: 20;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 12px 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: 0 6px 24px rgb(0 0 0 / 0.18);
  animation: ih-rise 0.28s ease-out;
}
#install-hint[hidden] { display: none; }

@keyframes ih-rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

.ih-body { flex: 1; font-size: 0.85rem; line-height: 1.45; }
.ih-body strong { display: block; margin-bottom: 2px; font-size: 0.9rem; }
.ih-body span { color: var(--muted); }
.ih-body b { color: var(--text); }

.ih-share {
  display: inline-block;
  padding: 0 4px;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--accent);
  font-weight: 700;
}

.ih-close {
  flex: none;
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
  padding: 0 4px;
  cursor: pointer;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 16px;
}
.empty .glyph { font-size: 2.5rem; display: block; margin-bottom: 10px; opacity: 0.6; }
