/* einkauf — colours, font and sizes from design/mockups/*.dc.html. */

@font-face {
  font-family: "Outfit";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(/fonts/outfit-latin.woff2) format("woff2");
}

:root {
  color-scheme: light dark;
  --bg: #F2F4F3;
  --ink: #1E2A30;
  --muted: #56656E;
  --card: #FFFFFF;
  --soft: #EEF2F4;
  --line: #DDE4E8;
  --red: #C73E22;
  --red-glow: rgba(199, 62, 34, .18);
  --orange: #E09A1F;
  --link: #2F5D7C;
  --primary: #1E2A30;
  --on-primary: #FFFFFF;
  --fridge: #FBFDFE;
  --fridge-line: #C9D6DE;
  --drawer: #F6FAFC;
  --drawer-lip: #DCE7ED;
  --freezer: #E4EEF5;
  --glass-top: #EAF2F6;
  --glass-bottom: #CFDDE6;
  --glass-lip: #A9BFCC;
  --glass-shadow: rgba(30, 42, 48, .08);
  --dashed: #B7C4CC;
  --grabber: #CDD6DB;
  --backdrop: rgba(20, 30, 36, .45);
  --shadow: 0 1px 3px rgba(30, 42, 48, .12);
  --sheet: #FFFFFF;
  --field: #EEF2F4;
  --danger: #C73E22;

  --font: "Outfit", system-ui, -apple-system, sans-serif;
  /* One grid for every zone: 5 columns, 10 px gap, 64 px wide where it fits. */
  --gutter: 15px;
  --gap: 10px;
  --col: min(64px, calc((100vw - 2 * var(--gutter) - 4 * var(--gap)) / 5));
  --grid-w: calc(5 * var(--col) + 4 * var(--gap));
  --page-w: calc(var(--grid-w) + 2 * var(--gutter));
  --app-h: 100%;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12191D;
    --ink: #E6ECEF;
    --muted: #93A2AA;
    --card: #24323A;
    --soft: #1F2A30;
    --line: #2B3940;
    --red: #E2583B;
    --red-glow: rgba(226, 88, 59, .28);
    --orange: #F0A73A;
    --link: #7DB2D6;
    --primary: #E6ECEF;
    --on-primary: #12191D;
    --fridge: #1A2429;
    --fridge-line: #3A4A53;
    --drawer: #1E292F;
    --drawer-lip: #2A3940;
    --freezer: #192833;
    --glass-top: #2C3C45;
    --glass-bottom: #22313A;
    --glass-lip: #4C626E;
    --glass-shadow: rgba(0, 0, 0, .35);
    --dashed: #4A5B64;
    --grabber: #4A5960;
    --backdrop: rgba(0, 0, 0, .55);
    --shadow: 0 1px 3px rgba(0, 0, 0, .5);
    --sheet: #1A2429;
    --field: #24323A;
    --danger: #E2583B;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
body {
  font-family: var(--font);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; cursor: pointer; }
button:disabled { cursor: default; }
input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* App frame: header, scrolling middle, fixed footer. Height comes from
   visualViewport (app.js), never 100vh. */
#app {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--app-h);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

header.top {
  width: var(--page-w);
  max-width: 100%;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 12px) var(--gutter) 2px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
header.top h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -0.4px; }

.round {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 22px;
  background: var(--card);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
}

.scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

main#fridge {
  width: var(--page-w);
  max-width: 100%;
  margin: 0 auto;
  padding: 6px var(--gutter) 16px;
  display: flex;
  flex-direction: column;
}

footer.bar {
  flex: none;
  padding: 8px max(var(--gutter), calc((100vw - var(--page-w)) / 2 + var(--gutter))) max(var(--safe-bottom), 12px);
  background: var(--card);
  box-shadow: 0 -1px 0 var(--line);
  display: flex;
  gap: 10px;
}
.undo {
  flex: 1;
  min-width: 0;
  height: 50px;
  border: 0;
  border-radius: 16px;
  background: var(--soft);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  text-align: left;
}
.undo:disabled { opacity: .5; }
.undo-text { display: flex; flex-direction: column; min-width: 0; }
.undo-title { font-size: 15px; font-weight: 600; }
.undo-last { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.primary {
  border: 0;
  border-radius: 16px;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.add { width: 128px; height: 50px; flex: none; }

.banner {
  width: var(--page-w);
  max-width: 100%;
  margin: 6px auto 0;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--card);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  box-shadow: var(--shadow);
}

/* --- the fridge (design/mockups/Main.dc.html) ------------------------------
   Every tile sits in one of the same 5 columns, whatever box it is in: boxes
   reach outward with negative margins equal to their border + padding. */
.row {
  display: grid;
  grid-template-columns: repeat(5, var(--col));
  column-gap: var(--gap);
  row-gap: 8px;
  align-items: end;
  align-content: end;
}
.row.cols-2 { grid-template-columns: repeat(2, var(--col)); }
.row.cols-3 { grid-template-columns: repeat(3, var(--col)); }

.zone-top { min-height: 64px; padding-bottom: 2px; }

.fridge {
  margin: 0 -8px;
  background: var(--fridge);
  border: 2px solid var(--fridge-line);
  border-top-width: 5px;
  border-radius: 14px 14px 6px 6px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.shelf { display: flex; flex-direction: column; }
.shelf .row { min-height: 62px; }
.glass {
  height: 9px; /* 6 px glass + 3 px front lip */
  margin: 2px -6px 0;
  border-radius: 2px;
  background: linear-gradient(var(--glass-top), var(--glass-bottom));
  border-bottom: 3px solid var(--glass-lip);
  box-shadow: 0 4px 5px var(--glass-shadow);
}
.drawer {
  background: var(--drawer);
  border: 2px solid var(--fridge-line);
  border-radius: 8px 8px 14px 14px;
  box-shadow: inset 0 -5px 0 var(--drawer-lip);
}
.drawer .row { min-height: 62px; }
.drawer.veg { margin: 0 -5px; padding: 3px 3px 7px; }

.freezer {
  margin: 6px -8px 0;
  background: var(--freezer);
  border: 2px solid var(--fridge-line);
  border-radius: 6px 6px 18px 18px;
  padding: 4px 6px 8px;
  display: grid;
  grid-template-columns: repeat(5, var(--col));
  column-gap: var(--gap);
  align-items: stretch;
}
.drawer.f1, .drawer.f2 { margin: 0 -3px; padding: 1px 1px 7px; display: flex; flex-direction: column; justify-content: flex-end; }
.drawer.f1 { grid-column: 1 / span 2; }
.drawer.f2 { grid-column: 3 / span 3; }

.zone-also { margin-top: 10px; }

.ondemand {
  margin: 8px -5px 0;
  padding: 3px;
  border: 2px dashed var(--fridge-line);
  border-radius: 16px;
}

/* --- tiles ------------------------------------------------------------------ */
.tile {
  position: relative;
  width: var(--col);
  height: 62px;
  padding: 3px 0 0;
  border: 0;
  border-radius: 14px;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
  transition: transform .15s ease, background-color .15s ease, box-shadow .15s ease;
}
.tile img {
  width: 38px;
  height: 38px;
  opacity: .42;
  filter: grayscale(.85);
  pointer-events: none;
  -webkit-user-drag: none;
  object-fit: cover;
  border-radius: 6px;
}
.tile .name {
  font-size: 10.5px;
  font-weight: 500;
  white-space: nowrap;
  color: var(--muted);
  pointer-events: none;
}
.tile.on { background: var(--card); box-shadow: 0 0 0 2px var(--red), 0 4px 10px var(--red-glow); }
.tile.on img { opacity: 1; filter: none; }
.tile.on .name { color: var(--ink); }
.badge {
  position: absolute;
  top: -6px;
  right: -5px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--red);
  color: #FFFFFF;
  font-size: 11px;
  font-weight: 700;
  line-height: 20px;
  white-space: nowrap;
  text-align: center;
  pointer-events: none;
}
.due {
  position: absolute;
  top: 5px;
  left: 7px;
  width: 9px;
  height: 9px;
  border-radius: 5px;
  background: var(--orange);
  pointer-events: none;
}
/* Hold: shrinks while the finger stays (450 ms), pops when it counts. */
.tile.pressing { transform: scale(.9); transition: transform .45s cubic-bezier(.3, .6, .3, 1); }
.tile.held { animation: pop .25s ease-out; }
@keyframes pop { 0% { transform: scale(.9); } 55% { transform: scale(1.08); } 100% { transform: scale(1); } }
.tile:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
@media (max-width: 380px) { .tile .name { letter-spacing: -0.25px; } }
@media (prefers-color-scheme: dark) { .tile img { opacity: .55; } .tile.on img { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .tile, .tile.pressing { transition: none; } .tile.held { animation: none; } }
