@font-face {
  font-family: "Schibsted Grotesk";
  src: url("/fonts/schibsted-grotesk.woff2") format("woff2");
  font-weight: 400 900;
  font-display: swap;
}

:root {
  color-scheme: light dark;
  --paper: #ffffff;
  --wash: #f2f4f5;
  --ink: #14171a;
  --ink-2: #5c646c;
  --ink-3: #8b939b;
  --line: #e2e6e9;
  --accent: #2b50e8;
  --good: #0b7a53;
  --good-wash: #e2f3eb;
  --bad: #c8372d;
  --bad-wash: #fbe9e7;
  --warn: #8f5600;
  --warn-wash: #faefd9;
  --photo: var(--wash);
  --blend: multiply; /* product photos have white backgrounds; multiply lets them sit on the grey */
  --rail: 264px;
  --tabs: 58px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #131517;
    --wash: #1c1f22;
    --ink: #eceef0;
    --ink-2: #a5adb5;
    --ink-3: #7b838b;
    --line: #2b2f33;
    --accent: #8ea2ff;
    --good: #4cc79a;
    --good-wash: #12332a;
    --bad: #ff8a7d;
    --bad-wash: #3a1d1a;
    --warn: #e3ad55;
    --warn-wash: #33290f;
    --photo: #ffffff; /* the photos stay on white; a dark tile would show their white boxes */
    --blend: normal;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.45 "Schibsted Grotesk", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, p, ul, figure { margin: 0; }
ul { padding: 0; list-style: none; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; text-align: inherit; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------- controls ---------- */

.button, select, .search, .range input {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--paper);
}
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  font-weight: 550;
  text-decoration: none;
  white-space: nowrap;
}
.button:hover, select:hover { border-color: var(--ink-3); }
.button:disabled { color: var(--ink-3); cursor: default; }
.primary {
  height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 9px;
  background: var(--ink);
  color: var(--paper);
  font-weight: 600;
}
.button.primary { height: 40px; }
.link { color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; }
.icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; color: var(--ink-2); }
.icon:hover { background: var(--wash); color: var(--ink); }
select { padding: 0 30px 0 12px; appearance: none; background: var(--paper) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b939b' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3C/svg%3E") no-repeat right 8px center / 18px; }

.dot {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--ink);
  color: var(--paper);
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

/* ---------- frame: tabs at the thumb on a phone, a rail on a wide screen ---------- */

.app { padding-bottom: calc(var(--tabs) + env(safe-area-inset-bottom)); }

.masthead {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 20;
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--paper);
  border-top: 1px solid var(--line);
}
.wordmark { display: none; }
.views { display: flex; height: var(--tabs); }
.views a {
  flex: 1;
  display: grid;
  grid-template-columns: auto auto;
  justify-content: center;
  align-content: center;
  column-gap: 6px;
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 550;
  text-decoration: none;
}
.views svg { grid-column: 1 / -1; justify-self: center; width: 22px; height: 22px; }
.views small { font-size: 11px; font-weight: 500; font-variant-numeric: tabular-nums; }
.views a.current { color: var(--ink); }

main { padding: 0 16px 24px; min-width: 0; }

.toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 -16px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--paper);
}
.search { flex: 1 1 100%; display: flex; align-items: center; gap: 8px; padding: 0 12px; color: var(--ink-3); }
.search:focus-within { border-color: var(--ink); }
.search input { flex: 1; min-width: 0; height: 100%; border: 0; background: none; color: var(--ink); outline: 0; font-size: 16px; }
.search input::placeholder { color: var(--ink-3); }
.toolbar select { flex: 1; min-width: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 10px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 30px;
  padding: 0 6px 0 11px;
  border-radius: 15px;
  background: var(--wash);
  font-size: 13px;
  font-weight: 550;
}
.chip svg { width: 15px; height: 15px; color: var(--ink-2); }

.summary { min-height: 22px; padding: 2px 0 12px; color: var(--ink-2); font-size: 13px; font-variant-numeric: tabular-nums; }

.empty { display: grid; justify-items: center; gap: 14px; padding: 56px 16px; color: var(--ink-2); text-align: center; text-wrap: balance; }

body[data-view="liked"] .toolbar, body[data-view="liked"] .filters, body[data-view="liked"] .scrim { display: none; }

/* ---------- filter panel: a sheet on a phone, part of the rail on a wide screen ---------- */

.filters {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  max-height: 88dvh;
  background: var(--paper);
  border-radius: 16px 16px 0 0;
  transform: translateY(105%);
  transition: transform 0.22s ease;
}
.filters.open { transform: none; }
.scrim { position: fixed; inset: 0; z-index: 30; background: rgb(10 12 14 / 0.4); }
.filters-head { display: flex; align-items: center; gap: 12px; padding: 14px 12px 6px 20px; }
.filters-head h2 { flex: 1; font-size: 17px; font-weight: 650; }
.filters-body { overflow-y: auto; padding: 0 20px 8px; overscroll-behavior: contain; }
.filters-foot { padding: 12px 20px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.filters-foot .primary { width: 100%; }
.filters section { padding: 14px 0; }
.filters section + section { border-top: 1px solid var(--line); }
.filters h3 { padding-bottom: 8px; color: var(--ink-2); font-size: 13px; font-weight: 550; }

.options button {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 7px 10px;
  margin: 0 -10px;
  width: calc(100% + 20px);
  border-radius: 8px;
}
.options button:hover { background: var(--wash); }
.options small { color: var(--ink-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.options .on { background: var(--wash); font-weight: 650; }
.options .sub button { padding-left: 24px; font-size: 14px; }
.options .more { color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; }

.range { display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 13px; }
.range input { flex: 1; min-width: 0; padding: 0 10px; font-size: 16px; }
.segments { display: flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.segments button { flex: 1; height: 38px; font-size: 13px; font-weight: 550; text-align: center; }
.segments button + button { border-left: 1px solid var(--line); }
.segments .on { background: var(--ink); color: var(--paper); }
.toggles label { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.toggles input { width: 18px; height: 18px; accent-color: var(--ink); }

/* ---------- an offer, wherever it is shown ---------- */

.photo { position: relative; display: grid; place-items: center; background: var(--photo); overflow: hidden; }
.photo img { width: 100%; height: 100%; padding: 9%; object-fit: contain; mix-blend-mode: var(--blend); }

.pct {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--ink);
  color: var(--paper);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.prices { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; font-variant-numeric: tabular-nums; }
.prices b { font-size: 16px; font-weight: 700; }
.prices s { color: var(--ink-3); font-size: 13px; }
.prices .save { color: var(--good); font-size: 13px; font-weight: 650; }
.prices.big b { font-size: 28px; letter-spacing: -0.01em; }
.prices.big s, .prices.big .save { font-size: 15px; }

.where { display: flex; flex-wrap: wrap; gap: 0 8px; color: var(--ink-2); font-size: 12px; }
.where em { color: var(--warn); font-style: normal; }
.name { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; font-size: 14px; font-weight: 500; line-height: 1.3; }

.points { display: grid; gap: 3px; padding-left: 16px; color: var(--ink-2); font-size: 14px; list-style: disc; }

/* ---------- list of all offers ---------- */

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 22px 12px; }
.tile { position: relative; min-width: 0; }
.tile .open { display: grid; gap: 4px; width: 100%; }
.tile .photo { aspect-ratio: 1; margin-bottom: 4px; border-radius: 12px; }
.tile[data-verdict="nope"] .open { opacity: 0.4; }

.marks { position: absolute; top: 8px; right: 8px; display: flex; gap: 6px; }
.mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--paper);
  color: var(--ink-2);
}
.mark svg { width: 16px; height: 16px; stroke-width: 2.2; }
.mark:hover { border-color: var(--ink-3); color: var(--ink); }
.tile[data-verdict="like"] .mark.like { border-color: var(--good); background: var(--good); color: var(--paper); }
.tile[data-verdict="nope"] .mark.nope { border-color: var(--bad); background: var(--bad); color: var(--paper); }

@media (hover: hover) {
  .tile:not([data-verdict="like"], [data-verdict="nope"]) .marks { opacity: 0; }
  .tile:hover .marks, .tile:focus-within .marks { opacity: 1; }
  .tile[data-verdict="like"] .mark.nope:not(:hover), .tile[data-verdict="nope"] .mark.like:not(:hover) { opacity: 0; }
  .tile:hover .mark, .tile:focus-within .mark { opacity: 1 !important; }
}

/* ---------- swipe deck ---------- */

.deck { position: relative; width: min(100%, 420px); height: min(640px, calc(100dvh - 290px - env(safe-area-inset-bottom))); min-height: 340px; margin: 0 auto; touch-action: pan-y; }
.card {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--paper);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  cursor: grab;
}
.card.behind { transform: scale(0.96) translateY(10px); }
.card.settle, .card.fly, .card.behind { transition: transform 0.26s ease, opacity 0.26s ease; }
.card .photo { flex: 1; min-height: 0; }
.card .photo img { pointer-events: none; }
.card .pct { top: 14px; left: 14px; padding: 4px 10px; border-radius: 8px; font-size: 15px; }
.card-text { display: grid; gap: 6px; padding: 16px 18px 18px; border-top: 1px solid var(--line); }
.card h2 { font-size: 18px; font-weight: 650; line-height: 1.25; text-wrap: balance; }
.card .prices b { font-size: 24px; letter-spacing: -0.01em; }
.card .points { font-size: 13px; }
.stamp {
  position: absolute;
  top: 16px;
  padding: 5px 12px;
  border-radius: 9px;
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  opacity: 0;
}
.stamp.like { right: 14px; background: var(--good); }
.stamp.nope { right: 14px; background: var(--bad); }
@media (prefers-color-scheme: dark) { .stamp { color: #111; } }

.deck-actions { display: flex; justify-content: center; align-items: center; gap: 16px; padding-top: 18px; }
.round { display: grid; place-items: center; width: 60px; height: 60px; border: 1px solid var(--line); border-radius: 50%; background: var(--paper); }
.round svg { width: 26px; height: 26px; stroke-width: 2.2; }
.round.small { width: 46px; height: 46px; color: var(--ink-2); }
.round.small svg { width: 20px; height: 20px; }
.round.like { color: var(--good); }
.round.nope { color: var(--bad); }
.round:hover { border-color: var(--ink-3); }
.round:active { transform: scale(0.94); }
.round:disabled { opacity: 0.35; cursor: default; }
body[data-view="swipe"] .summary { text-align: center; }

/* ---------- shortlist ---------- */

.liked-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: calc(14px + env(safe-area-inset-top)) 0 6px; }
.liked-bar .summary { flex: 1 1 100%; padding: 0; color: var(--ink); font-size: 17px; font-weight: 650; }
.rows { max-width: 760px; }
.rows .group { padding: 22px 0 6px; color: var(--ink-2); font-size: 13px; font-weight: 550; }
.row { display: flex; align-items: center; gap: 4px; border-bottom: 1px solid var(--line); }
.row .open { flex: 1; min-width: 0; display: flex; align-items: center; gap: 14px; padding: 12px 0; }
.row .photo { flex: none; width: 68px; height: 68px; border-radius: 10px; }
.row-text { flex: 1; min-width: 0; display: grid; gap: 3px; }
.row-price { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.row.ended .open { opacity: 0.5; }

.pill { padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 650; white-space: nowrap; }
.pill.great { background: var(--good); color: var(--paper); }
.pill.ok { background: var(--good-wash); color: var(--good); }
.pill.none { background: var(--warn-wash); color: var(--warn); }
.pill.worse { background: var(--bad-wash); color: var(--bad); }
.pill.unknown { background: var(--wash); color: var(--ink-2); }

/* ---------- one offer: a sheet on a phone, a side panel on a wide screen ---------- */

.detail {
  width: 100vw;
  max-width: none;
  height: 94dvh;
  max-height: none;
  margin: auto 0 0;
  padding: 0;
  border: 0;
  border-radius: 18px 18px 0 0;
  background: var(--paper);
  color: var(--ink);
  overscroll-behavior: contain;
}
.detail::backdrop { background: rgb(10 12 14 / 0.4); }
.detail-close { position: sticky; top: 10px; z-index: 2; float: right; margin: 10px 10px -46px 0; background: var(--paper); border: 1px solid var(--line); border-radius: 50%; }
.detail .photo { aspect-ratio: 4 / 3; }
.detail .photo img { padding: 6%; }
.detail-text { display: grid; gap: 12px; padding: 20px 20px calc(28px + env(safe-area-inset-bottom)); }
.detail h2 { font-size: 21px; font-weight: 650; line-height: 1.25; text-wrap: balance; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 0; }
.detail-actions .primary { flex: 1 1 100%; }
.mark-wide { flex: 1; }
.mark-wide svg { width: 17px; height: 17px; stroke-width: 2.2; }
.mark-wide.like.on { border-color: var(--good); background: var(--good); color: var(--paper); }
.mark-wide.nope.on { border-color: var(--bad); background: var(--bad); color: var(--paper); }
.note { color: var(--ink-2); font-size: 13px; }

.history { display: grid; gap: 8px; padding: 18px 0 6px; border-top: 1px solid var(--line); font-size: 14px; }
.history.loading { color: var(--ink-2); }
.verdict { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.verdict.great, .verdict.ok { color: var(--good); }
.verdict.none { color: var(--warn); }
.verdict.worse { color: var(--bad); }
.verdict.unknown { color: var(--ink-2); }
.source { color: var(--ink-2); font-size: 12px; }

.chart { padding-top: 8px; }
.chart svg { display: block; width: 100%; height: auto; stroke: none; touch-action: pan-y; }
.chart text { fill: var(--ink-2); font-size: 13px; font-variant-numeric: tabular-nums; paint-order: stroke; stroke: var(--paper); stroke-width: 4px; stroke-linejoin: round; }
.chart .base, .chart .tick { stroke: var(--line); stroke-width: 1; }
.chart .line { fill: none; stroke-linejoin: miter; stroke-linecap: butt; }
.chart .line.lowest { stroke: var(--ink); stroke-width: 2; }
.chart .line.store { stroke: var(--ink-3); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart .ref { stroke-width: 1; stroke-dasharray: 2 4; }
.chart .ref.prev { stroke: var(--bad); }
.chart .ref.normal { stroke: var(--good); }
.chart .ref-label.prev { fill: var(--bad); }
.chart .ref-label.normal { fill: var(--good); }
.chart .now { fill: var(--accent); stroke: var(--paper); stroke-width: 2; }
.chart .now-label { fill: var(--accent); font-weight: 650; }
.chart .cursor { stroke: var(--ink-3); stroke-width: 1; }
.chart .readout { fill: var(--ink); font-weight: 550; }
.chart figcaption { display: flex; flex-wrap: wrap; gap: 4px 18px; padding-top: 6px; color: var(--ink-2); font-size: 12px; }
.key::before { content: ""; display: inline-block; width: 18px; margin-right: 6px; vertical-align: middle; border-top: 2px solid var(--ink); }
.key.store::before { border-top: 2px dashed var(--ink-3); }

/* ---------- login ---------- */

body.login { display: grid; place-items: center; min-height: 100dvh; padding: 24px; }
.login form { display: grid; gap: 10px; width: min(100%, 320px); }
.login h1 { padding-bottom: 14px; font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.login label { color: var(--ink-2); font-size: 13px; font-weight: 550; }
.login input { height: 46px; padding: 0 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--paper); font-size: 16px; }
.login input:focus { border-color: var(--ink); outline: 0; }
.login .primary { height: 46px; margin-top: 6px; text-align: center; }
.error { color: var(--bad); font-size: 14px; }

/* ---------- wide screens ---------- */

@media (min-width: 960px) {
  .app { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); grid-template-rows: auto 1fr; padding-bottom: 0; }
  .masthead { position: sticky; top: 0; inset: auto; z-index: 5; grid-column: 1; padding: 22px 16px 10px; border-top: 0; }
  .wordmark { display: block; padding: 0 10px 18px; font-size: 21px; font-weight: 700; letter-spacing: -0.02em; text-decoration: none; }
  .views { flex-direction: column; gap: 2px; height: auto; }
  .views a { grid-template-columns: 22px 1fr auto; justify-content: stretch; align-items: center; column-gap: 12px; padding: 9px 10px; border-radius: 8px; color: var(--ink-2); font-size: 15px; }
  .views svg { grid-column: auto; width: 20px; height: 20px; }
  .views small { font-size: 12px; color: var(--ink-3); }
  .views a:hover { background: var(--wash); }
  .views a.current { background: var(--wash); font-weight: 650; }

  .filters {
    position: sticky;
    top: 188px;
    inset: auto;
    z-index: 4;
    grid-column: 1;
    grid-row: 2;
    align-self: start;
    max-height: calc(100dvh - 188px);
    border-radius: 0;
    transform: none;
    transition: none;
  }
  .masthead { height: 188px; }
  .filters-body { padding: 0 26px 24px; }
  .filters-head { padding: 8px 26px 0; }
  .filters-head h2 { color: var(--ink-2); font-size: 13px; font-weight: 550; visibility: hidden; }
  #filters-close, .filters-foot, .scrim, #filters-open { display: none; }

  main { grid-column: 2; grid-row: 1 / span 2; min-height: 100dvh; padding: 0 32px 48px; border-left: 1px solid var(--line); }
  .toolbar { flex-wrap: nowrap; margin: 0 -32px; padding: 20px 32px 12px; }
  .search { flex: 1 1 auto; max-width: 560px; }
  .toolbar select { flex: none; margin-left: auto; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: 30px 18px; }
  .liked-bar { padding-top: 24px; }
  .liked-bar .summary { flex: 1; font-size: 21px; }
  .deck { height: min(660px, calc(100dvh - 230px)); }

  .detail { width: min(540px, 100vw); height: 100dvh; margin: 0 0 0 auto; border-radius: 0; border-left: 1px solid var(--line); }
  .detail-text { padding: 24px 28px 40px; }
  .detail-actions .primary { flex: 1 1 auto; }
}

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