/* keyfoodsavings.com — the approved canvas (design/offers-site/Main.src.html) as classes.
   Mobile first; the artboard was 390 px wide, so the page is a 640 px column that simply
   grows more card columns on a bigger screen. Every tap target is at least 44 px. */

:root {
  --accent: #1D4FA6;
  --accent-dark: #163D82;
  --ink: #1B1F27;
  --muted: #5F6675;
  --line: #E4E7EC;
  --bg: #F5F6F8;
  --card: #FFFFFF;
  --red: #D62B1F;
  --red-dark: #B01F15;
  --warm-bg: #FFF1B8;
  --warm-fg: #7A5200;
  --warm-line: #F5D77A;
  --grey-bg: #EEF0F4;
  --grey-fg: #4B5262;
  --sel-bg: #EAF0FB;
  --sel-line: #BCD0F0;
  --pill-on-bg: #FDECEA;
  --radius: 12px;
}

* { box-sizing: border-box; }

/* Author `display:` rules beat the user agent's [hidden] rule, and half this page is
   flex. Everything the client hides — #results, #rail-wrap, #clear, the sheets — hides
   through this one line. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Schibsted Grotesk", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.4;
}

a { color: var(--accent); }
a:hover { color: var(--accent-dark); }
button { font-family: inherit; }
img { max-width: 100%; }
h1, h2 { margin: 0; font-weight: 800; letter-spacing: -0.01em; }

.scroll { scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.scroll::-webkit-scrollbar { display: none; }

input::placeholder { color: #8A958D; }
input:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@keyframes rise { from { transform: translateY(28px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.app {
  max-width: 640px;
  margin: 0 auto;
  background: var(--bg);
  min-height: 100vh;
  position: relative;
  /* `viewport-fit=cover` (every template's viewport meta) puts the page under the notch and the
     rounded corners. In landscape that is a real inset on the left or the right, so the column
     keeps clear of it here, once, rather than in every child. */
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

/* -- header ------------------------------------------------------------------ */

.hdr {
  background: var(--accent);
  color: #FFFFFF;
  /* The header is what sits under the status bar / notch, so the TOP inset is the one that
     matters; the bottom inset belongs to `.sheet`, which is the thing actually pinned to the
     bottom edge. (The old rule asked for the bottom inset and then threw it away on the very
     next line with a plain `padding-bottom`.) */
  padding: calc(16px + env(safe-area-inset-top, 0px)) 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.hdr-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
/* The marks are transparent cut-outs and sit straight on the bar: the Key Food oval carries its
   own white rim and the Super Fresh wordmark is light on the navy, so neither needs a plate. */
.logo { display: inline-flex; align-items: center; }
.logo img { height: 40px; width: auto; display: block; }
/* Super Fresh's mark is taller than it is wide; 48 px keeps its wordmark legible. */
.theme-superfresh .logo img { height: 48px; }
.logo-pair { gap: 16px; }
.logo-pair img:last-child { height: 48px; }

/* -- brand themes: everything that reads `--accent` follows the store's brand ---------- */
/* Super Fresh: its mark is sky blue and green, which vanishes on any blue bar, so its header
   is a pale sky plate with navy text — the logo sits in its own colours, everything else on the
   page (chips, buttons, links) takes the navy accent. */
.theme-superfresh {
  --accent: #075985;
  --accent-dark: #0C4A6E;
  --sel-bg: #E6F4FB;
  --sel-line: #B5DDF0;
}
.theme-superfresh .hdr { background: #EEF7FC; color: #0C4A6E; border-bottom: 1px solid #CFE6F2; }
.theme-superfresh .lang { background: rgba(7, 89, 133, 0.10); }
.theme-superfresh .langbtn { color: #075985; }
.theme-superfresh .langbtn.is-on { background: #075985; color: #FFFFFF; }
.theme-superfresh .storebtn { color: #0C4A6E; }
.theme-superfresh .change { background: rgba(7, 89, 133, 0.10); }
/* The group pages (chooser, 404) carry both marks, so they get the same pale plate. */
.theme-group .hdr { background: #EEF7FC; border-bottom: 1px solid #CFE6F2; }
.theme-group .chooser-head { color: #0C4A6E; }

.lang { display: flex; background: rgba(255, 255, 255, 0.16); border-radius: 999px; padding: 3px; gap: 2px; }
.langbtn {
  position: relative; border: 0; cursor: pointer; border-radius: 999px; padding: 0 14px;
  min-height: 34px; font-size: 12px; font-weight: 700; background: transparent; color: #FFFFFF;
}
/* The pill stays the canvas's size; the thumb gets its 44 px. */
.langbtn::before, .iconbtn-sm::before {
  content: ""; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 100%; min-width: 44px; height: 44px;
}
.langbtn.is-on { background: #FFFFFF; color: var(--accent); }

.storebtn {
  border: 0; background: transparent; color: #FFFFFF; text-align: left; padding: 0;
  cursor: pointer; display: flex; justify-content: space-between; align-items: center;
  gap: 12px; min-height: 44px; width: 100%;
}
.storebtn-txt { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.kicker { font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; opacity: 0.85; }
.store-name { font-size: 22px; font-weight: 800; line-height: 1.1; letter-spacing: -0.01em; }
.store-short { font-size: 13px; opacity: 0.85; }
.change {
  display: flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 700;
  background: rgba(255, 255, 255, 0.16); border-radius: 999px; padding: 8px 12px;
  white-space: nowrap; min-height: 36px;
}
.chooser-head { color: #FFFFFF; }

/* -- banner ------------------------------------------------------------------ */

.ended {
  margin: 0; padding: 12px 16px; background: var(--warm-bg); color: var(--warm-fg);
  font-size: 13px; font-weight: 700; line-height: 1.4;
}

/* -- sticky search + chips ---------------------------------------------------- */

.stick {
  position: sticky; top: 0; z-index: 5; background: var(--bg);
  padding: 12px 0 10px; display: flex; flex-direction: column; gap: 10px;
  border-bottom: 1.5px solid var(--line);
}
.searchbox {
  margin: 0 16px; display: flex; align-items: center; gap: 10px; background: var(--card);
  border: 1.5px solid var(--line); border-radius: var(--radius); padding: 0 12px; height: 46px;
}
.searchbox input {
  flex-grow: 1; border: 0; background: transparent; font-size: 16px; font-family: inherit;
  color: var(--ink); min-width: 0; appearance: none;
}
.searchbox input::-webkit-search-cancel-button { display: none; }

.iconbtn {
  border: 0; background: var(--grey-bg); border-radius: 999px; width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--ink);
  flex-shrink: 0;
}
.iconbtn-sm { position: relative; width: 28px; height: 28px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 0 16px; }
.chip {
  flex-shrink: 0; cursor: pointer; border-radius: 999px; padding: 0 14px; height: 44px;
  font-size: 13px; font-weight: 700; white-space: nowrap; background: var(--card);
  color: var(--ink); border: 1.5px solid var(--line);
}
.chip.is-on { background: var(--accent); color: #FFFFFF; border-color: var(--accent); }

/* -- week strip --------------------------------------------------------------- */

.week {
  margin: 12px 16px 0; display: flex; align-items: center; justify-content: space-between;
  gap: 8px; font-size: 13px; color: var(--muted);
}
.week-l { display: flex; align-items: center; gap: 6px; font-weight: 600; color: var(--ink); }

/* -- sections and cards -------------------------------------------------------- */

.results { padding: 16px 16px 24px; display: flex; flex-direction: column; gap: 12px; }
.result-line { font-size: 15px; font-weight: 700; }
.empty { margin: 16px; font-size: 14px; color: var(--muted); line-height: 1.5; }

.rail-wrap { margin-top: 18px; display: flex; flex-direction: column; gap: 10px; }
.sec { margin-top: 22px; display: flex; flex-direction: column; gap: 10px; }
.sec-head { margin: 0 16px; display: flex; align-items: baseline; gap: 8px; }
.sec-title { font-size: 20px; }
.sec-count { font-size: 13px; color: var(--muted); }
.sec-note { margin: -4px 16px 0; font-size: 13px; color: var(--muted); line-height: 1.45; }
.linkbtn {
  margin-left: auto; border: 0; background: transparent; cursor: pointer; font-size: 13px;
  font-weight: 700; color: var(--accent); padding: 8px 0; min-height: 44px;
}
.rail { display: flex; gap: 10px; overflow-x: auto; padding: 2px 16px 4px; }
.grid { margin: 0 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.results .grid { margin: 0; }

.card {
  background: var(--card); border: 1.5px solid var(--line); border-radius: var(--radius);
  padding: 12px; display: flex; flex-direction: column; gap: 5px; cursor: pointer;
  min-height: 148px; text-decoration: none; color: inherit;
}
.card:active { transform: scale(.985); }
.card-rail {
  flex-shrink: 0; width: 164px; border-color: var(--warm-line); min-height: 156px;
  box-shadow: 0 1px 2px rgba(20, 28, 48, 0.05);
}
.card-top { display: flex; gap: 8px; align-items: flex-start; flex-grow: 1; }
.card-txt { display: flex; flex-direction: column; gap: 4px; flex-grow: 1; min-width: 0; }
.brand {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); min-height: 14px;
}
.pname { font-size: 15px; font-weight: 700; line-height: 1.25; text-wrap: pretty; }
.thumb { width: 56px; height: 56px; object-fit: contain; flex-shrink: 0; }
.size { font-size: 12px; color: var(--muted); min-height: 15px; }

.price { display: flex; align-items: flex-end; gap: 2px; color: var(--red); margin-top: 2px; }
.p-pre { font-size: 13px; font-weight: 700; padding-bottom: 8px; }
.p-big { font-size: 30px; font-weight: 800; line-height: 1; letter-spacing: -0.02em; }
.p-sup { font-size: 14px; font-weight: 800; padding-bottom: 12px; }
.p-unit { font-size: 12px; font-weight: 600; color: var(--muted); padding-bottom: 2px; margin-left: 2px; }
.after { font-size: 11px; color: var(--muted); }

.badges { display: flex; flex-wrap: wrap; gap: 4px; }
.badge { font-size: 11px; font-weight: 700; border-radius: 6px; padding: 3px 7px; }
.badge-warm { background: var(--warm-bg); color: var(--warm-fg); }
.badge-grey { background: var(--grey-bg); color: var(--grey-fg); }

.pill { font-size: 11px; font-weight: 700; border-radius: 6px; padding: 3px 7px; align-self: flex-start; }
.pill-warm { background: var(--warm-bg); color: var(--warm-fg); font-size: 12px; }
.pill-on { background: var(--pill-on-bg); color: var(--red-dark); margin-top: 4px; }
.pill-off { background: var(--grey-bg); color: var(--grey-fg); margin-top: 4px; }

/* -- footer -------------------------------------------------------------------- */

.foot {
  margin: 28px 16px 24px; padding-top: 16px; border-top: 1.5px solid var(--line);
  display: flex; flex-direction: column; gap: 10px; font-size: 12px; line-height: 1.5;
  color: var(--muted);
}
.foot p { margin: 0; }
.pdf {
  font-weight: 700; font-size: 13px; text-decoration: none; display: inline-flex;
  align-items: center; gap: 6px; min-height: 44px;
}

/* -- empty state (404) ---------------------------------------------------------- */

.empty-state {
  padding: 48px 28px; display: flex; flex-direction: column; align-items: center;
  text-align: center; gap: 12px;
}
.empty-title { font-size: 18px; }
.empty-body { margin: 0; font-size: 14px; line-height: 1.5; color: var(--muted); }
.btn {
  margin-top: 8px; border: 0; cursor: pointer; background: var(--accent); color: #FFFFFF;
  font-size: 14px; font-weight: 700; border-radius: var(--radius); padding: 0 18px;
  min-height: 44px; display: inline-flex; align-items: center; text-decoration: none;
}

/* -- sheets --------------------------------------------------------------------- */

.scrim {
  position: fixed; inset: 0; background: rgba(20, 28, 48, 0.45); z-index: 20;
  animation: fade .18s ease-out;
}
.sheet {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: 100%;
  max-width: 640px; z-index: 21; background: var(--card); border-radius: 18px 18px 0 0;
  padding: 10px 16px calc(20px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: 12px; max-height: 86vh;
  box-shadow: 0 -8px 30px rgba(20, 28, 48, 0.18); animation: rise .22s ease-out;
}
.grab { width: 40px; height: 4px; border-radius: 999px; background: var(--line); align-self: center; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.sheet-title { font-size: 18px; }
.sheet-list { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; }
.chooser { padding: 16px; }

.storerow {
  text-align: left; cursor: pointer; background: var(--card); border: 1.5px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px; display: flex; gap: 12px;
  align-items: flex-start; color: var(--ink); text-decoration: none; min-height: 44px;
}
.storerow.is-current { background: var(--sel-bg); border-color: var(--sel-line); }
.storerow-txt { display: flex; flex-direction: column; gap: 3px; flex-grow: 1; min-width: 0; }
.storerow-name { font-size: 15px; font-weight: 800; }
.storerow-addr { font-size: 13px; color: var(--muted); line-height: 1.4; }
.tick { flex-shrink: 0; margin-top: 2px; }

.item-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.item-img { width: 84px; height: 84px; object-fit: contain; flex-shrink: 0; }
.item-txt { display: flex; flex-direction: column; gap: 4px; flex-grow: 1; min-width: 0; }
.item-name { font-size: 22px; line-height: 1.15; text-wrap: pretty; }
.item-price {
  display: flex; align-items: flex-end; gap: 3px; color: var(--warm-fg); background: var(--warm-bg);
  border-radius: var(--radius); padding: 14px 16px;
}
.item-price .p-pre { font-size: 16px; padding-bottom: 12px; }
.item-price .p-big { font-size: 44px; }
.item-price .p-sup { font-size: 18px; padding-bottom: 18px; }
.item-price .p-unit { font-size: 14px; padding-bottom: 4px; margin-left: 4px; }
.p-note {
  margin-left: auto; font-size: 13px; font-weight: 700; color: var(--red-dark);
  padding-bottom: 6px; text-align: right;
}
.item-desc { margin: 0; font-size: 14px; line-height: 1.5; color: var(--ink); }
.item-rows { margin: 0; display: flex; flex-direction: column; border-top: 1.5px solid var(--line); }
.item-row {
  display: flex; justify-content: space-between; gap: 12px; padding: 10px 0;
  border-bottom: 1.5px solid var(--line); font-size: 14px;
}
.item-row dt { color: var(--muted); }
.item-row dd { margin: 0; font-weight: 700; text-align: right; }
.foot-note { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.45; }

@media (prefers-reduced-motion: reduce) {
  .sheet, .scrim { animation: none; }
  .card:active { transform: none; }
}
