/* iPhone-style structure, in the app's own matte colours. Loaded after style.css; behaviour is in native.js.
   1. the screen's name is the title: large on the page, small in a frosted bar once scrolled
   2. a floating frosted bottom bar that the page scrolls under
   3. sheets rise from the bottom, with a handle to drag them shut
   4. quieter Pantry rows
   5. Settings as rows with switches
   6. text follows the phone's text size
   7. award pop-up clear of the headline; solid bars for Reduce Transparency and Increase Contrast */

:root { --nv-sep: color-mix(in srgb, var(--ink) 15%, transparent); --nv-fill: color-mix(in srgb, var(--ink) 8%, transparent);
  --nv-bar-b: max(10px, calc(env(safe-area-inset-bottom, 0px) - 12px)); --nv-top: env(safe-area-inset-top, 0px);
  --nv-glass: color-mix(in srgb, var(--card) 72%, transparent); --nv-glass-top: color-mix(in srgb, var(--bg) 82%, transparent);
  --nv-blur: blur(22px) saturate(1.6); --nv-ease: cubic-bezier(.22, 1, .36, 1); }

/* 6. text size: native.js sets the root size from the phone's setting; everything measured in rem follows it */
body { font-size: 1rem; }
h1, h2, h3, .brand, .big-name { font-weight: 700; }

#navtitle, #navback { display: none; }

@media (max-width: 899px), (hover: none) {
  /* ---- 1. titles ---- */
  body:not(.bare) header.top { position: fixed; left: 0; right: 0; top: 0; height: calc(44px + var(--nv-top)); padding: var(--nv-top) 52px 0; gap: 0; justify-content: center;
    background: transparent; border-bottom: .5px solid transparent; box-shadow: none; pointer-events: none;
    transition: background-color .2s ease, border-color .2s ease; }
  body:not(.bare) header.top .brand { display: none; }
  body:not(.bare) #navtitle { display: block; font: 600 1.0625rem/44px var(--display, inherit); letter-spacing: -.01em; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    opacity: 0; transform: translateY(5px); transition: opacity .18s ease, transform .28s var(--nv-ease); }
  html.nv-scrolled body:not(.bare) header.top { background: var(--nv-glass-top); -webkit-backdrop-filter: var(--nv-blur); backdrop-filter: var(--nv-blur); border-bottom-color: var(--nv-sep); }
  html.nv-scrolled #navtitle { opacity: 1; transform: none; }
  body:not(.bare) #navback { display: none; position: absolute; left: 2px; bottom: 0; width: 44px; height: 44px; min-height: 0; padding: 0; border: 0; border-radius: 50%; background: none; box-shadow: none;
    color: var(--pa); justify-content: center; pointer-events: auto; }
  body:not(.bare) #navback .ion-ic { width: 26px; height: 26px; }
  html.nv-pushed body:not(.bare) #navback { display: inline-flex; }
  body:not(.bare) main { padding-top: calc(var(--nv-top) + 14px); }
  html.nv-pushed body:not(.bare) main { padding-top: calc(var(--nv-top) + 46px); }
  main h1 { font-size: 2.125rem; line-height: 1.1; letter-spacing: -.02em; margin: 0 0 .8rem; }

  /* ---- 2. bottom bar ---- */
  body:not(.bare) { padding-bottom: calc(92px + var(--nv-bar-b)); }
  nav.bottom { left: max(12px, env(safe-area-inset-left, 0px)); right: max(12px, env(safe-area-inset-right, 0px)); bottom: var(--nv-bar-b); padding: 4px; border-radius: 32px;
    border: .5px solid color-mix(in srgb, var(--ink) 13%, transparent); background: var(--nv-glass); -webkit-backdrop-filter: var(--nv-blur); backdrop-filter: var(--nv-blur);
    box-shadow: 0 8px 28px rgba(30, 25, 15, .14); }
  nav.bottom a { position: relative; z-index: 1; padding: .42rem 0 .34rem; border-radius: 28px; font-size: .6875rem; font-weight: 500; }
  nav.bottom a.on { font-weight: 600; }
  /* the marker is a soft pill behind the tab that is showing; it slides between tabs (FX.nav sets --nav-i) */
  nav.bottom::before { top: 4px; bottom: 4px; height: auto; left: var(--nav-x, calc(4px + var(--nav-i, 0) * (100% - 8px) / var(--nav-n, 4))); width: var(--nav-w, calc((100% - 8px) / var(--nav-n, 4)));
    border-radius: 28px; background: var(--nv-fill); }
  nav.bottom a.scanbtn .ic { width: 46px; height: 28px; margin-top: 0; border: 0; border-radius: 14px; box-shadow: none; }
  nav.bottom a.scanbtn .ic .ion-ic { width: 22px; height: 22px; }
  nav.bottom a.scanbtn:not(.on) .ic::after { border-radius: 18px; }
  .fab { bottom: calc(80px + var(--nv-bar-b)); right: 16px; }
  body:not(.bare) .savebar { bottom: calc(70px + var(--nv-bar-b)); }
}

/* ---- 3. sheets ---- */
.nv-sheetbar { display: none; }
@media (max-width: 699px) {
  dialog#modal:not(.plusdlg) { margin: auto 0 0; width: 100vw; max-width: 100vw; max-height: calc(100dvh - var(--nv-top) - 24px); border-radius: 26px 26px 0 0;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, .16); overscroll-behavior: contain; }
  @keyframes nv-sheet-up { from { transform: translateY(100%); } }
  dialog#modal:not(.plusdlg)[open] { animation: nv-sheet-up .46s var(--nv-ease); }
  dialog#modal:not(.plusdlg)::backdrop, dialog#modal:not(.plusdlg)[open]::backdrop { background: rgba(0, 0, 0, .3); }
  @supports (overlay: auto) {
    dialog#modal:not(.plusdlg) { opacity: 1; transform: translateY(100%); transition: transform .26s ease-in, overlay .26s allow-discrete, display .26s allow-discrete; }
    dialog#modal:not(.plusdlg)[open] { transform: none; transition: none; }
    dialog#modal:not(.plusdlg)::backdrop { background: rgba(0, 0, 0, 0); transition: background-color .26s ease, overlay .26s allow-discrete, display .26s allow-discrete; }
    dialog#modal:not(.plusdlg)[open]::backdrop { background: rgba(0, 0, 0, .3); transition: none; }
  }
  dialog#modal.nv-drag { animation: none !important; transition: none !important; }
  dialog#modal.nv-settle { animation: none !important; transition: transform .34s var(--nv-ease) !important; }
  /* the strip across the top: a handle to drag the sheet shut, and the close button */
  dialog#modal:not(.plusdlg)[open] { display: flex; flex-direction: column; }
  dialog#modal:not(.plusdlg) > * { flex: none; }
  dialog#modal:not(.plusdlg) .nv-sheetbar { display: block; order: -1; position: sticky; top: 0; z-index: 6; height: 40px; margin-bottom: -6px; background: var(--card); border-radius: 26px 26px 0 0; touch-action: none; cursor: grab; }
  .nv-sheetbar::before { content: ""; position: absolute; top: 7px; left: 50%; width: 38px; height: 5px; margin-left: -19px; border-radius: 3px; background: color-mix(in srgb, var(--ink) 22%, transparent); }
  .nv-sheetbar .nv-x { position: absolute; top: 8px; right: 12px; width: 30px; height: 30px; min-height: 0; padding: 0; border: 0; border-radius: 50%; box-shadow: none; background: var(--nv-fill);
    color: var(--muted); justify-content: center; }
  .nv-sheetbar .nv-x .ion-ic { width: 18px; height: 18px; }
  dialog#modal:not(.plusdlg) #modal-body { padding-top: .5rem; padding-bottom: calc(1.1rem + env(safe-area-inset-bottom, 0px)); }
  dialog#modal:not(.plusdlg) #modal-body > .modal-actions { bottom: calc(-1.1rem - env(safe-area-inset-bottom, 0px)); padding-bottom: calc(1.1rem + env(safe-area-inset-bottom, 0px)); margin-bottom: calc(-1.1rem - env(safe-area-inset-bottom, 0px)); }
}

/* ---- 4. Pantry rows: a name, one grey line of facts, the amount ---- */
#inv .card > h3 { font-size: .9375rem; font-weight: 600; color: var(--muted); }
#inv .list li { border-bottom: 0; flex-wrap: nowrap; min-height: 60px; -webkit-touch-callout: none;
  background-image: linear-gradient(var(--nv-sep), var(--nv-sep)); background-repeat: no-repeat; background-position: 56px 0; background-size: 100% .5px; }
#inv .list li:first-child { background-image: none; }
#inv .list .grow { min-width: 0; }
#inv .list .name { font-size: 1.0625rem; }
#inv .list .grow > .small { display: inline; font-size: .9375rem; color: var(--muted); }
#inv .list .grow > .small:not(:empty):has(+ .small > *)::after { content: " · "; }
#inv .list .pill { display: inline; padding: 0; border-radius: 0; background: none; font-size: inherit; font-weight: 500; color: var(--muted); }
#inv .list .pill::before { content: none; }
#inv .list .pill:has(+ .pill, + .muted)::after { content: " ·"; color: var(--muted); font-weight: 400; }
#inv .list .pill:is(.warn, .bad) { font-weight: 600; } #inv .list .pill.warn { color: var(--warn); } #inv .list .pill.bad { color: var(--bad); }
#inv .list .qty { font-size: 1.0625rem; font-weight: 600; }
#inv .usebtn { border: 0; border-radius: 99px; box-shadow: none; background: var(--nv-fill); min-height: 34px; padding: 0 .95rem; font-size: .9375rem; font-weight: 700; flex: none; }
#inv li.nv-held { background-color: var(--deep); transform: scale(.985); }

/* ---- 5. Settings: label on the left, value on the right, switches for on and off ---- */
#view[data-view="settings"] .field-row { display: block; }
#view[data-view="settings"] .field-row > div:empty { display: none; }
#view[data-view="settings"] .field-row > div { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 48px; border-top: .5px solid var(--nv-sep); }
#view[data-view="settings"] .field-row label { flex: 1; margin: 0; font-size: 1.0625rem; color: var(--ink); }
#view[data-view="settings"] .field-row :is(input, select) { flex: 0 1 auto; width: auto; max-width: 58%; min-height: 44px; padding: 0 0 0 .4rem; border: 0; border-radius: 8px; background-color: transparent; box-shadow: none;
  color: var(--muted); font-size: 1.0625rem; text-align: right; text-align-last: right; }
#view[data-view="settings"] .field-row input[type=number] { width: 6.5rem; }
#view[data-view="settings"] .field-row input:not([type=number]):not([type=checkbox]) { width: 9.5rem; }
#view[data-view="settings"] .field-row :is(input, select):focus { color: var(--ink); outline: 0; }
#view[data-view="settings"] label.row:has(> input.check) { flex-direction: row-reverse; justify-content: space-between; flex-wrap: nowrap; min-height: 48px; margin: 0; font-size: 1.0625rem; border-top: .5px solid var(--nv-sep); }
#view[data-view="settings"] h3 + label.row:has(> input.check) { border-top: 0; }
#view[data-view="settings"] input.check { flex: none; width: 51px !important; height: 31px; min-height: 0; border: 0; border-radius: 16px; background: color-mix(in srgb, var(--ink) 17%, transparent); }
#view[data-view="settings"] input.check:checked { background: var(--good, var(--ok)); }
#view[data-view="settings"] input.check::after { inset: auto; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; -webkit-mask: none; mask: none; transform: none;
  box-shadow: 0 2px 5px rgba(0, 0, 0, .22); transition: transform .3s var(--spring, ease); }
#view[data-view="settings"] input.check:checked::after { transform: translateX(20px); }
#view[data-view="settings"] input.check:active { transform: none; }

/* ---- 7. small things ---- */
/* an award arrives above the bottom bar, clear of the headline */
@media (max-width: 899px), (hover: none) { .award-pop { top: calc(env(safe-area-inset-top, 0px) + .6rem); bottom: auto; } }
/* swiping in from the left edge goes back: a marker follows the finger */
.nv-edge { position: fixed; z-index: 80; left: -44px; top: 50%; width: 40px; height: 40px; margin-top: -20px; border-radius: 50%; display: grid; place-items: center; pointer-events: none;
  background: var(--card); color: var(--pa); border: .5px solid var(--nv-sep); box-shadow: 0 4px 14px rgba(0, 0, 0, .14); opacity: 0; }
.nv-edge .ion-ic { width: 22px; height: 22px; }
.nv-edge.go { background: var(--pa); color: var(--pa-ink); }
/* people who turn transparency down, or contrast up, get solid bars */
@media (prefers-reduced-transparency: reduce), (prefers-contrast: more) {
  :root { --nv-glass: var(--card); --nv-glass-top: var(--bg); --nv-blur: none; --nv-sep: color-mix(in srgb, var(--ink) 34%, transparent); }
}
@media (prefers-reduced-motion: reduce) { dialog#modal:not(.plusdlg)[open] { animation: none; } #navtitle { transition: none; } }
:root[data-motion="off"] dialog#modal:not(.plusdlg)[open] { animation: none; }
@media print { .nv-sheetbar, .nv-edge { display: none !important; } }

/* iPhone zooms the whole page when a field with text under 16px is tapped, and does not zoom back. */
input, select, textarea { font-size: max(16px, 1em); }

/* Finger-sized targets without changing the look: the tappable area reaches past the drawn button (Apple asks for 44 points) */
#inv .usebtn, .nv-sheetbar .nv-x { position: relative; }
#inv .usebtn::after { content: ""; position: absolute; inset: -6px -4px; }
.nv-sheetbar .nv-x::after { content: ""; position: absolute; inset: -7px; }

/* Larger text (the phone's Text Size setting): things that sit side by side stack, so words are never squeezed to a letter a line */
html.bigtext #inv li { flex-wrap: wrap; }
html.bigtext #inv li .grow { flex: 1 1 calc(100% - 44px - 2rem); }
html.bigtext #inv li .qty { margin-left: auto; }
html.bigtext .field-row { display: block; }
html.bigtext .field-row > div + div { margin-top: .5rem; }
html.bigtext .scan-pair { flex-direction: column; display: flex; }
html.bigtext .findrow { flex-wrap: wrap; }
html.bigtext select, html.bigtext input { text-overflow: ellipsis; }

/* ---- wide phone screens (iPhone Duo opened, phones held sideways): the tab bar stays a compact pill in the middle ---- */
@media (min-width: 600px) and (hover: none), (min-width: 600px) and (max-width: 899px) {
  nav.bottom { left: 50%; right: auto; width: min(520px, calc(100vw - 24px)); transform: translateX(-50%); }
}
