/* STACK primitives — bar, card, tile, chip, stack meter, category tag. README §1, §5, §8. */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--char);
  color: var(--bone);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  /* Android/iOS: default tap flash and native pull-to-refresh/rubber-banding
     fight our own tap states and fixed nav — this app supplies its own
     feedback (colour changes, land animation) so the native ones just get
     in the way. */
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  /* iOS notch/home-indicator: keep content clear of the safe area on the
     sides (notch in landscape, rounded corners) — top/bottom are handled by
     the header spacing and #app's nav clearance below. */
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  padding-bottom: calc(84px + env(safe-area-inset-bottom)); /* bottom nav clearance, notch-aware */
}

img, svg { display: block; max-width: 100%; }

button {
  font-family: inherit;
  border: none;
  background: none;
  cursor: pointer;
  color: inherit;
}

input, select, textarea {
  font-family: inherit;
  color: var(--bone);
  background: var(--char-raised);
  border: none;
  /* iOS Safari auto-zooms the page on focusing any field under 16px — several
     screens set smaller sizes for inline editors (13px price fields etc.).
     Forcing 16px here (it wins over those inline styles) keeps the visual
     size via each field's own height/padding, so nothing looks bigger, but
     stops the zoom-in-then-you-have-to-zoom-back-out annoyance on iPhone. */
  font-size: 16px !important;
}

.tabular { font-variant-numeric: tabular-nums; }

/* ---- Type scale (README §1) ---- */
.display-xl {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(44px, 6vw, 80px);
  letter-spacing: -0.045em;
  line-height: 0.82;
}
.display-l {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 44px;
  letter-spacing: -0.035em;
  line-height: 0.85;
}
.display-m {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 26px;
  letter-spacing: -0.02em;
}
.body-l { font-size: 18px; font-weight: 400; line-height: 1.55; }
.body { font-size: 15px; font-weight: 400; line-height: 1.5; }
.label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.numeric { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---- Primitives ---- */
.bar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  height: 52px;
  border-radius: var(--r-tile);
  padding: 0 20px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 17px;
  width: 100%;
}
/* Always dark text on Volt, in both themes — --char means "dark ink" in dark
   mode but becomes the light ground colour in light mode, so it can't be used
   here. --ink is a fixed value, deliberately never overridden per theme. */
.bar-primary { background: var(--volt); color: var(--ink); }

.card {
  background: var(--char-raised);
  border-radius: var(--r-card);
  padding: 18px;
}

.tile { border-radius: var(--r-tile); }

.chip {
  display: inline-flex;
  align-items: center;
  border-radius: var(--r-chip);
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--char);
}

.category-pantry { color: var(--haze); }
.category-fridge, .category-freezer { color: var(--chill); }
.category-budget { color: var(--beam); }
.category-expiring { color: var(--ember); }

/* ---- Stack meter — five pills, fills upward (README §5) ---- */
.stack-meter {
  display: flex;
  flex-direction: column-reverse;
  gap: 4px;
}
.stack-meter .pip {
  width: 12px;
  height: 14px;
  border-radius: var(--r-container);
  background: var(--slate);
}
.stack-meter .pip.filled { background: var(--volt); }

/* ---- Landing motion (README §6): everything lands, no fades ---- */
@keyframes land {
  from { transform: translateY(-16px); opacity: 0; }
  60% { transform: translateY(3px); opacity: 1; }
  to { transform: translateY(0); opacity: 1; }
}
.land {
  animation: land 240ms cubic-bezier(0.2, 0.9, 0.3, 1.3) both;
}

/* ---- Undo toast (#18) ---- */
.toast {
  display: none;
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: calc(100% - 40px);
  max-width: 440px;
  background: var(--char-raised);
  color: var(--bone);
  border-radius: var(--r-tile);
  padding: 14px 16px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  z-index: 50;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.toast button {
  color: var(--volt-text);
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

/* ---- Sync status dot (#17) — quiet, corner-only, no text ---- */
.sync-dot {
  display: none;
  position: fixed;
  top: calc(14px + env(safe-area-inset-top));
  right: calc(14px + env(safe-area-inset-right));
  width: 8px;
  height: 8px;
  border-radius: 50%;
  z-index: 60;
}

/* ---- Bottom nav ---- */
.bottom-nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 480px;
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: calc(68px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--char-raised);
  border-top: 2px solid var(--slate);
}
.bottom-nav button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  color: var(--slate-mid);
}
.bottom-nav button.active { color: var(--volt-text); }

.screen {
  padding: 26px 20px 20px;
}
