/* HPH Food Log: the adult screens. Colours, type and shapes follow the accepted designs
   (design/canvas_source/PD_1..3, PR_1..6). No inline styles anywhere: the CSP refuses them.
   Fonts are served by this app (static/fonts), never from a font service. */

@font-face { font-family: "Inter"; src: url("/fonts/inter-latin.woff2") format("woff2");
  font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Josefin Sans"; src: url("/fonts/josefin-sans-latin.woff2") format("woff2");
  font-weight: 100 700; font-style: normal; font-display: swap; }

:root {
  --bg: #FBF7EC; --ink: #14213D; --muted: #4A5675; --line: #E6DCC3; --card: #FFFFFF;
  --chip-line: #C9BFA4; --brass: #C8963E; --save: #E3B55C; --on-navy: #FFF6E0; --track: #DCD3BC;
  --ok-bg: #E6F1E2; --ok-fg: #2F6B2A; --warn-bg: #FBEBD3; --warn-fg: #8A4B00;
  --now-bg: #E3ECFB; --now-fg: #1D4FB8; --later-bg: #ECEFEA; --later-fg: #4F5D57;
  --row-warn: #FDF4E6; --app-box: #EFE9D8; --err: #8A1C1C;
  --head: "Josefin Sans", system-ui, sans-serif;
  --body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 var(--body); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--ink); }
.boot-note { margin: 48px 18px; color: var(--muted); }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── frame ── */
#app { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.screen { width: 100%; max-width: 600px; margin: 0 auto; flex: 1 0 auto; display: flex; flex-direction: column;
  padding: 0 0 calc(76px + env(safe-area-inset-bottom)); }
.screen.no-nav { padding-bottom: 24px; }
.page { padding: 4px 18px 0; display: flex; flex-direction: column; gap: 14px; }
.top { padding: calc(14px + env(safe-area-inset-top)) 18px 8px; display: flex; flex-direction: column; gap: 6px; }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.back { min-height: 44px; margin: calc(8px + env(safe-area-inset-top)) 4px 0; padding: 0 10px 0 6px; border: 0; background: none;
  font-size: 16px; font-weight: 600; display: inline-flex; align-items: center; gap: 2px; align-self: flex-start; }
h1 { margin: 0; font: 700 30px/1.05 var(--head); }
h2 { margin: 6px 0 0; font-size: 16px; font-weight: 700; }
h3 { margin: 0; font-size: 15px; font-weight: 700; }
p { margin: 0; }
.sub { font-size: 14px; color: var(--muted); }
.lead { font-size: 16px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.err { color: var(--err); font-weight: 600; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.flex { display: flex; align-items: center; gap: 10px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.right { margin-left: auto; }
.mt { margin-top: 8px; }

/* ── bottom navigation ── */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--card); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); padding-bottom: env(safe-area-inset-bottom); }
.tabs a { min-height: 58px; display: flex; align-items: center; justify-content: center; text-decoration: none;
  border-top: 3px solid var(--card); color: var(--muted); font-size: 13px; font-weight: 600; }
.tabs a[aria-current="page"] { border-top-color: var(--brass); color: var(--ink); font-weight: 700; }

/* ── lists ── */
.list { background: var(--card); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; display: flex; flex-direction: column; }
.row { min-height: 70px; padding: 8px 12px; border: 0; border-bottom: 1px solid var(--line); background: var(--card);
  text-align: left; display: flex; align-items: center; gap: 12px; width: 100%; text-decoration: none; color: inherit; }
.list > :last-child { border-bottom: 0; }
.row.warn { background: var(--row-warn); }
.row.short { min-height: 58px; }
.ico { width: 48px; height: 48px; flex: 0 0 auto; border-radius: 10px; object-fit: cover; background: #F6E9CF; display: block; }
.ico.big { width: 72px; height: 72px; }
.row-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-title { font-size: 17px; font-weight: 600; }
.row-sub { font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.chev { flex: 0 0 auto; color: var(--muted); }
.pill { padding: 4px 12px; border-radius: 12px; font-size: 15px; font-weight: 700; white-space: nowrap; background: var(--later-bg); color: var(--later-fg); }
.pill.ok { background: var(--ok-bg); color: var(--ok-fg); }
.pill.warn { background: var(--warn-bg); color: var(--warn-fg); }
.pill.now { background: var(--now-bg); color: var(--now-fg); }
.pill.later { background: var(--later-bg); color: var(--later-fg); }
.pill.pick { background: #F3E3BC; color: #6B4A00; }
.pill.small { font-size: 13px; padding: 2px 10px; }

/* ── controls ── */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 46px; padding: 0 16px; border: 1px solid var(--chip-line); border-radius: 23px; background: var(--card);
  font-size: 15px; font-weight: 500; }
.chip[aria-pressed="true"] { border: 2px solid var(--ink); background: var(--ink); color: var(--on-navy); font-weight: 700; }
.chip.small { min-height: 40px; padding: 0 14px; font-size: 14px; }
.amounts { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.amt { min-height: 56px; border: 1px solid var(--chip-line); border-radius: 12px; background: var(--card); font-size: 14px; font-weight: 600; }
.amt[aria-pressed="true"] { border: 2px solid var(--ink); background: var(--ink); color: var(--on-navy); }
.btn { min-height: 56px; padding: 0 18px; border: 0; border-radius: 14px; background: var(--save); color: var(--ink);
  font-size: 18px; font-weight: 700; text-align: center; text-decoration: none; display: flex; align-items: center; justify-content: center; }
.btn.navy { background: var(--ink); color: var(--on-navy); }
.btn.outline { min-height: 52px; border: 1.5px solid var(--ink); background: var(--card); font-size: 17px; font-weight: 600; }
.btn.small { min-height: 44px; font-size: 15px; border-radius: 22px; padding: 0 16px; }
.btn[disabled] { opacity: .45; cursor: default; }
.btn.danger { border-color: var(--err); color: var(--err); }
.link { min-height: 44px; border: 0; background: none; font-size: 15px; font-weight: 600; text-decoration: underline; }
.pillbtn.navy { background: var(--ink); color: var(--on-navy); }
.pillbtn { min-height: 44px; padding: 0 14px; border: 1.5px solid var(--ink); border-radius: 22px; background: var(--card); font-size: 13px; font-weight: 600; white-space: nowrap; text-decoration: none; display: inline-flex; align-items: center; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .lab { font-size: 14px; font-weight: 700; }
.hint { font-size: 13px; color: var(--muted); }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], input[type="time"],
input[type="search"], input[type="tel"], select, textarea {
  min-height: 48px; padding: 8px 12px; border: 1px solid var(--chip-line); border-radius: 12px; background: var(--card); width: 100%; }
textarea { min-height: 96px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid var(--now-fg); outline-offset: 2px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.check input { width: 22px; height: 22px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ── cards and notes ── */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; display: flex; flex-direction: column; }
.card > .kv, .card > .pad { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.card > :last-child { border-bottom: 0; }
.pad { padding: 14px 16px; }
.kv { display: flex; flex-direction: column; gap: 3px; }
.kv .k { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; }
.kv .v { font-size: 17px; display: flex; align-items: center; gap: 10px; overflow-wrap: anywhere; }
.bar { display: flex; gap: 3px; }
.bar i { width: 16px; height: 8px; border-radius: 3px; background: var(--track); display: block; }
.bar i.on { background: var(--ink); }
.clinic { border: 1.5px solid var(--brass); border-radius: 14px; background: var(--card); padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.clinic.navy { border: 2px solid var(--ink); }
.clinic .k, .appbox .k { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }
.clinic .q { font-size: 16px; }
.appbox { background: var(--app-box); border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.banner { border: 2px solid var(--brass); border-radius: 16px; background: var(--card); padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.banner h3 { font-size: 17px; }
.banner .msg { font-size: 15px; white-space: pre-line; }
.banner.done { border-color: var(--line); }
.callrow { min-height: 62px; border-radius: 14px; padding: 8px 16px; display: flex; align-items: center; gap: 12px; text-decoration: none; border: 1.5px solid var(--ink); background: var(--card); color: var(--ink); }
.callrow.navy { background: var(--ink); color: var(--on-navy); }
.callrow .t { font-size: 17px; font-weight: 700; display: block; }
.callrow .n { font-size: 14px; display: block; }
.empty { padding: 18px 16px; color: var(--muted); }
.statline { font-size: 14px; color: var(--muted); }
.status { position: sticky; top: 0; z-index: 9; background: #F3E3BC; color: #4A3200; font-size: 13px; font-weight: 600; padding: 6px 18px; text-align: center; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(86px + env(safe-area-inset-bottom)); background: var(--ink); color: var(--on-navy);
  padding: 10px 18px; border-radius: 22px; font-size: 15px; font-weight: 600; z-index: 30; max-width: 92vw; }
.face { margin: 22px 18px 0; padding-top: 10px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.scrim { position: fixed; inset: 0; background: rgba(20, 33, 61, .45); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.dialog { background: var(--bg); border-radius: 20px 20px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); width: 100%; max-width: 600px; display: flex; flex-direction: column; gap: 12px; }

/* ── days, tables, summary ── */
.days { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.days .chip { padding: 0 6px; }
.scroll-x { overflow-x: auto; }
table.grid { border-collapse: collapse; width: 100%; font-size: 14px; }
table.grid th, table.grid td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.grid th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.tag { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 10px; background: var(--later-bg); color: var(--later-fg); margin-right: 4px; }
.tag.warn { background: var(--warn-bg); color: var(--warn-fg); }
.photo-pick { display: flex; align-items: center; gap: 12px; }

.scan-video { width: 100%; max-height: 50vh; border-radius: 12px; background: #000; object-fit: cover; }

/* ── sign-in ── */
.login { max-width: 420px; margin: 0 auto; padding: calc(48px + env(safe-area-inset-top)) 18px 24px; display: flex; flex-direction: column; gap: 14px; }

/* ── printing: the weekly summary (about 0.6 in margins, title and page numbers in the footer) ── */
@page { margin: 0.6in; @bottom-center { content: "HPH Food Log: weekly summary. Private family log. Page " counter(page) " of " counter(pages); font-size: 9pt; } }
@media print {
  body { background: #fff; font-size: 11pt; }
  .tabs, .back, .no-print, .status, .toast { display: none !important; }
  .screen { max-width: none; padding: 0; }
  .page, .top { padding-left: 0; padding-right: 0; }
  .card, .list { border-color: #999; break-inside: avoid; }
}
