/* ============================================================
   Einkaufsradar Nürnberg — "Premium-Marktblatt"
   ============================================================ */
:root {
  --bg: #F4F1EA;
  --surface: #FBFAF6;
  --surface-2: #FFFFFF;
  --ink: #1A1A1A;
  --ink-2: #57534C;
  --ink-3: #8C867B;
  --accent: #FF5722;
  --accent-deep: #D8431C;
  --good: #2F7D4F;
  --line: rgba(26, 26, 26, 0.10);
  --line-2: rgba(26, 26, 26, 0.16);
  --rule: rgba(26, 26, 26, 0.88);
  --shadow: 0 1px 0 rgba(26,26,26,.04), 0 8px 24px -16px rgba(26,26,26,.30);
  --shadow-lift: 0 2px 0 rgba(26,26,26,.05), 0 18px 40px -22px rgba(26,26,26,.45);
  --font-display: "Bricolage Grotesque", Georgia, serif;
  --font-body: "Hanken Grotesk", system-ui, sans-serif;
  --font-mono: "Spline Sans Mono", ui-monospace, monospace;
  --r: 14px;
  --r-sm: 10px;
  --maxw: 1160px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.45;
  padding-bottom: 100px; /* Platz für die schwebende Tab-Leiste */
  overflow-x: hidden;
}

/* Papier-Körnung */
.grain {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: .55;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
}
main, .masthead, .tabbar, .toast { position: relative; z-index: 1; }

/* ---------- Masthead ---------- */
.masthead { padding: 22px 18px 0; }
.masthead__inner { max-width: var(--maxw); margin: 0 auto; }
.masthead__top {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--ink-2);
}
.masthead__live { color: var(--accent-deep); white-space: nowrap; }
.masthead__title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.6rem, 11vw, 5.4rem);
  line-height: .92; letter-spacing: -.03em;
  margin: 6px 0 0; text-transform: uppercase;
}
.masthead__title span { color: var(--accent); }
.masthead__rule {
  height: 0; border-top: 2px solid var(--rule);
  box-shadow: 0 3px 0 var(--rule); /* Doppellinie */
  margin: 12px 0 0;
}
/* ---------- Wochen-Umschalter ---------- */
.weekbar {
  max-width: var(--maxw); margin: 14px auto 0; padding: 0 18px;
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.weekbar::-webkit-scrollbar { display: none; }
.weekbar__btn {
  flex: none; cursor: pointer; text-align: left;
  border: 1.5px solid var(--line-2); background: var(--surface-2); color: var(--ink);
  border-radius: var(--r-sm); padding: 9px 14px;
  display: flex; flex-direction: column; gap: 2px; transition: all .14s ease;
}
.weekbar__btn:hover { border-color: var(--ink); }
.weekbar__btn--active { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.weekbar__btn b { font-family: var(--font-body); font-weight: 700; font-size: 14px; white-space: nowrap; }
.weekbar__btn small { font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); white-space: nowrap; }
.weekbar__btn--active small { color: rgba(251,250,246,.72); }

/* Hinweis für leere/künftige Wochen */
.li__soon { color: var(--accent-deep); font-family: var(--font-mono); font-size: 10.5px; font-weight: 600; }

/* ---------- Views ---------- */
main { max-width: var(--maxw); margin: 0 auto; padding: 0 18px; }
.view { display: none; animation: fade .25s ease both; }
.view--active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- Controls ---------- */
.controls {
  position: sticky; top: 0; z-index: 5;
  padding: 16px 0 12px;
  margin-bottom: 6px;
  background: linear-gradient(var(--bg) 78%, rgba(244,241,234,0));
  backdrop-filter: blur(2px);
}
.searchbar {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-2);
  border: 1.5px solid var(--ink); border-radius: 999px;
  padding: 0 16px; height: 50px;
  box-shadow: var(--shadow);
}
.searchbar__icon { width: 19px; height: 19px; fill: none; stroke: var(--ink-2); stroke-width: 2; stroke-linecap: round; flex: none; }
.searchbar input {
  border: 0; outline: 0; background: transparent; width: 100%;
  font-family: var(--font-body); font-size: 16px; color: var(--ink);
}
.searchbar input::placeholder { color: var(--ink-3); }

.chips {
  display: flex; gap: 8px; margin-top: 12px;
  overflow-x: auto; scrollbar-width: none; padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; cursor: pointer; white-space: nowrap;
  font-family: var(--font-mono); font-size: 12px; letter-spacing: .03em;
  padding: 7px 13px; border-radius: 999px;
  border: 1.5px solid var(--line-2); background: transparent; color: var(--ink-2);
  display: inline-flex; align-items: center; gap: 7px;
  transition: all .14s ease;
}
.chip:hover { border-color: var(--ink); color: var(--ink); }
.chip__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); flex: none; }
.chip--active { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.chip--active .chip__dot { box-shadow: 0 0 0 2px rgba(255,255,255,.5); }

.controls__row { display: flex; gap: 10px; margin-top: 12px; }
.select { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.select span {
  font-family: var(--font-mono); font-size: 10px; text-transform: uppercase;
  letter-spacing: .12em; color: var(--ink-3); padding-left: 2px;
}
.select select {
  font-family: var(--font-body); font-size: 14px; color: var(--ink);
  background: var(--surface-2); border: 1.5px solid var(--line-2); border-radius: var(--r-sm);
  padding: 11px 12px; cursor: pointer; -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%231A1A1A' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.select select:focus { outline: 0; border-color: var(--ink); }
.resultcount {
  font-family: var(--font-mono); font-size: 12px; color: var(--ink-2);
  margin: 12px 2px 0; letter-spacing: .02em;
}

/* ---------- Angebots-Grid ---------- */
.offer-grid {
  display: grid; gap: 12px; margin: 6px 0 24px;
  grid-template-columns: 1fr;
}
@media (min-width: 540px) { .offer-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 820px) { .offer-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1080px){ .offer-grid { grid-template-columns: repeat(4, 1fr); } }

.card {
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r);
  padding: 14px 14px 12px; display: flex; flex-direction: column; gap: 2px;
  box-shadow: var(--shadow); position: relative; overflow: hidden;
  animation: cardin .4s cubic-bezier(.2,.7,.3,1) both;
  animation-delay: calc(var(--i, 0) * 22ms);
}
@keyframes cardin { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (hover: hover) { .card:hover { box-shadow: var(--shadow-lift); transform: translateY(-2px); transition: all .18s ease; } }
.card--deal { border-color: rgba(255,87,34,.45); }
.card--deal::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent);
}

.card__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.card__store {
  font-family: var(--font-mono); font-size: 11px; font-weight: 600; letter-spacing: .02em;
  color: var(--ink); display: inline-flex; align-items: center; gap: 6px;
  text-transform: uppercase;
}
.card__store::before {
  content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--store, var(--ink-3));
  box-shadow: 0 0 0 1px rgba(0,0,0,.08);
}
.card__cat {
  font-family: var(--font-mono); font-size: 10px; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: .08em; text-align: right;
  max-width: 48%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card__title {
  font-family: var(--font-display); font-weight: 600; font-size: 17px; line-height: 1.18;
  margin: 2px 0 0; letter-spacing: -.01em;
}
.card__brand { font-size: 12.5px; color: var(--ink-2); margin: 2px 0 0; min-height: 1px; }
.card__price { display: flex; align-items: baseline; gap: 9px; margin-top: 10px; flex-wrap: wrap; }
.card__amount {
  font-family: var(--font-mono); font-weight: 600; font-size: 26px; letter-spacing: -.02em;
  color: var(--accent-deep);
}
.card__old { font-family: var(--font-mono); font-size: 13px; color: var(--ink-3); text-decoration: line-through; }
.card__save {
  font-family: var(--font-mono); font-size: 11px; font-weight: 600; color: #fff; background: var(--accent);
  padding: 2px 6px; border-radius: 6px; letter-spacing: .02em;
}
.card__base { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-2); margin: 3px 0 0; }
.card__foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; }
.card__valid { font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); letter-spacing: .01em; }
.card__add {
  font-family: var(--font-body); font-weight: 600; font-size: 13px; cursor: pointer;
  border: 1.5px solid var(--ink); background: transparent; color: var(--ink);
  border-radius: 999px; padding: 7px 14px; transition: all .14s ease; white-space: nowrap;
}
.card__add:hover { background: var(--ink); color: var(--surface); }
.card__add--on { background: var(--good); border-color: var(--good); color: #fff; }
.card__add--on:hover { background: var(--good); color: #fff; }
@keyframes pop { 0%{transform:scale(1)} 40%{transform:scale(.9)} 100%{transform:scale(1)} }
.card__add--pop { animation: pop .28s ease; }

/* ---------- Empty ---------- */
.empty {
  text-align: center; color: var(--ink-2); font-size: 15px; padding: 48px 20px; line-height: 1.6;
}
.empty span { color: var(--ink-3); font-size: 13px; }

/* ---------- Matcher (Liste → Angebote) ---------- */
.matcher {
  background: var(--ink); color: var(--surface); border-radius: var(--r);
  margin: 16px 0 18px; overflow: hidden; box-shadow: var(--shadow);
}
.matcher__summary {
  list-style: none; cursor: pointer; padding: 16px 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-size: 15px;
}
.matcher__summary::-webkit-details-marker { display: none; }
.matcher__summary strong { color: var(--surface); }
.matcher__summary span:first-child { color: rgba(251,250,246,.72); }
.matcher__chevron { font-size: 22px; transition: transform .2s ease; color: var(--accent); }
.matcher[open] .matcher__chevron { transform: rotate(90deg); }
.matcher__body { padding: 0 18px 18px; }
.matcher__body textarea {
  width: 100%; font-family: var(--font-body); font-size: 15px; line-height: 1.6;
  background: rgba(255,255,255,.06); color: var(--surface);
  border: 1.5px solid rgba(255,255,255,.18); border-radius: var(--r-sm);
  padding: 12px 14px; resize: vertical;
}
.matcher__body textarea::placeholder { color: rgba(251,250,246,.4); }
.matcher__body textarea:focus { outline: 0; border-color: var(--accent); }
.matcher__results { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.mr-item { border-top: 1px solid rgba(255,255,255,.12); padding-top: 10px; }
.mr-item__q {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: .04em;
  text-transform: uppercase; color: rgba(251,250,246,.6); margin-bottom: 6px;
}
.mr-item__none { color: rgba(251,250,246,.5); font-size: 13px; }
.mr-hit {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 7px 0; font-size: 14px;
}
.mr-hit__txt b { font-weight: 600; }
.mr-hit__meta { font-family: var(--font-mono); font-size: 12px; color: rgba(251,250,246,.7); }
.mr-hit__price { color: var(--accent); font-weight: 600; }
.mr-hit__add {
  flex: none; cursor: pointer; border: 1.5px solid rgba(255,255,255,.3); background: transparent;
  color: var(--surface); border-radius: 999px; width: 30px; height: 30px; font-size: 18px; line-height: 1;
}
.mr-hit__add:hover { background: var(--accent); border-color: var(--accent); }

/* ---------- Liste ---------- */
.list-groups { display: flex; flex-direction: column; gap: 16px; margin-bottom: 18px; }
.lg { background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow); }
.lg__head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2);
}
.lg__store { font-family: var(--font-mono); font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: .03em; display: inline-flex; align-items: center; gap: 8px; }
.lg__store::before { content:""; width: 10px; height: 10px; border-radius: 50%; background: var(--store, var(--ink-3)); box-shadow: 0 0 0 1px rgba(0,0,0,.08); }
.lg__sum { font-family: var(--font-mono); font-size: 13px; color: var(--accent-deep); font-weight: 600; }
.li { display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--line); }
.li:last-child { border-bottom: 0; }
.li__check {
  flex: none; width: 22px; height: 22px; border-radius: 6px; border: 1.5px solid var(--ink-2);
  cursor: pointer; display: grid; place-items: center; background: var(--surface-2); transition: all .12s ease;
}
.li__check svg { width: 13px; height: 13px; stroke: #fff; stroke-width: 3; fill: none; opacity: 0; }
.li--done .li__check { background: var(--good); border-color: var(--good); }
.li--done .li__check svg { opacity: 1; }
.li__body { flex: 1; min-width: 0; }
.li__title { font-size: 14.5px; font-weight: 500; }
.li--done .li__title { text-decoration: line-through; color: var(--ink-3); }
.li__sub { font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); }
.li__price { font-family: var(--font-mono); font-size: 14px; color: var(--accent-deep); font-weight: 600; white-space: nowrap; }
.li--done .li__price { color: var(--ink-3); }
.li__del { flex: none; cursor: pointer; border: 0; background: transparent; color: var(--ink-3); font-size: 20px; line-height: 1; padding: 4px; border-radius: 6px; }
.li__del:hover { color: var(--accent-deep); }

.list-summary { margin: 4px 0 30px; border-top: 2px solid var(--rule); padding-top: 16px; }
.list-summary__total { display: flex; align-items: baseline; justify-content: space-between; }
.list-summary__total span { font-family: var(--font-mono); font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-2); }
.list-summary__total strong { font-family: var(--font-mono); font-size: 28px; color: var(--ink); letter-spacing: -.02em; }
.list-summary__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.list-summary__hint { font-size: 11.5px; color: var(--ink-3); margin: 12px 0 0; line-height: 1.5; }

.btn {
  font-family: var(--font-body); font-weight: 600; font-size: 13.5px; cursor: pointer;
  border: 1.5px solid var(--ink); background: var(--surface-2); color: var(--ink);
  border-radius: 999px; padding: 10px 16px; transition: all .14s ease;
}
.btn:hover { background: var(--ink); color: var(--surface); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; width: 100%; margin-top: 12px; padding: 13px; font-size: 15px; }
.btn--primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); color: #fff; }
.btn--ghost { border-color: var(--line-2); color: var(--ink-2); background: transparent; }
.btn--ghost:hover { background: transparent; border-color: var(--accent-deep); color: var(--accent-deep); }

/* ---------- Tab-Leiste ---------- */
.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  display: flex; gap: 4px; padding: 6px;
  background: var(--ink); border-radius: 999px;
  box-shadow: 0 12px 36px -10px rgba(26,26,26,.6);
}
@media (min-width: 760px) { .tabbar { bottom: 24px; } }
.tabbar__btn {
  position: relative; cursor: pointer; border: 0; background: transparent;
  color: rgba(251,250,246,.6); font-family: var(--font-body); font-weight: 600; font-size: 13px;
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 20px; border-radius: 999px;
  transition: all .16s ease;
}
.tabbar__btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.tabbar__btn--active { background: var(--surface); color: var(--ink); }
.tabbar__btn span { white-space: nowrap; }
.tabbar__badge {
  font-family: var(--font-mono); font-style: normal; font-size: 11px; font-weight: 600;
  background: var(--accent); color: #fff; min-width: 19px; height: 19px; padding: 0 5px;
  border-radius: 999px; display: grid; place-items: center;
}
.tabbar__badge[hidden] { display: none; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%) translateY(8px);
  background: var(--ink); color: var(--surface); font-size: 14px; font-weight: 500;
  padding: 11px 18px; border-radius: 999px; box-shadow: var(--shadow-lift);
  opacity: 0; transition: all .22s ease; pointer-events: none; z-index: 20; white-space: nowrap;
}
.toast--show { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (min-width: 760px) { .toast { bottom: 28px; } }

/* ---------- Store-Farbtupfer (nur Erkennung, kein Logo) ---------- */
[data-store="REWE"], [data-store="REWE Center"] { --store: #cc1417; }
[data-store="Lidl"] { --store: #0050aa; }
[data-store="ALDI SÜD"] { --store: #00497b; }
[data-store="Netto Marken-Discount"] { --store: #ffd400; }
[data-store="EDEKA"] { --store: #ffcc00; }
[data-store="PENNY"] { --store: #d4021d; }
[data-store="Kaufland"] { --store: #e10915; }
[data-store="ROSSMANN"] { --store: #c8102e; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
