:root {
  --ink: #15110e;
  --ink-2: #1d1713;
  --ink-3: #2a221c;
  --line: #3a2f27;
  --paper: #f1e6d2;
  --paper-dim: #c2b49d;
  --muted: #8d7f6f;
  --gun: #ff5b23;
  --gun-ink: #220c03;
  --mint: #6fe0b8;
  --mustard: #f2c14e;
  --rose: #ff7a90;
  --cat: var(--paper);

  --f-display: "Big Shoulders Display", "Arial Narrow", sans-serif;
  --f-body: "Schibsted Grotesk", "Segoe UI", sans-serif;
  --f-mono: "Martian Mono", ui-monospace, monospace;

  --radius: 6px;
  --pad: clamp(16px, 4vw, 40px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(255, 91, 35, .14), transparent 60%),
    radial-gradient(900px 500px at -10% 30%, rgba(111, 224, 184, .07), transparent 60%),
    var(--ink);
  color: var(--paper);
  font: 400 15px/1.5 var(--f-body);
  padding-bottom: env(safe-area-inset-bottom);
}
.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 100; opacity: .07; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--mustard); outline-offset: 2px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── Masthead ─────────────────────────────── */
.masthead {
  padding: calc(var(--pad) + 8px) var(--pad) 18px;
  display: grid; gap: 22px;
  grid-template-columns: 1fr;
  max-width: 1440px; margin: 0 auto;
}
@media (min-width: 900px) { .masthead { grid-template-columns: 1fr auto; align-items: end; } }
.eyebrow { margin: 0 0 6px; font: 600 11px/1 var(--f-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.title {
  margin: 0; font: 900 clamp(64px, 14vw, 168px)/.8 var(--f-display); letter-spacing: -.01em; text-transform: uppercase;
  display: flex; align-items: baseline; gap: .12em; flex-wrap: wrap;
}
.title__list {
  color: var(--ink); background: var(--gun); padding: .02em .12em .06em; transform: rotate(-3deg) translateY(-.04em);
  display: inline-block; box-shadow: 6px 6px 0 rgba(0,0,0,.45);
  clip-path: polygon(0 0, 100% 0, 100% 72%, 92% 100%, 0 100%);
}
.lede { margin: 14px 0 0; max-width: 46ch; color: var(--paper-dim); }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin: 0; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
@media (min-width: 560px) { .stats { grid-template-columns: repeat(4, minmax(0, auto)); } }
.stats div { background: var(--ink-2); padding: 12px 16px; min-width: 120px; }
.stats dt { font: 600 10px/1 var(--f-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.stats dd { margin: 6px 0 0; font: 800 26px/1 var(--f-display); letter-spacing: .02em; }
.stats dd small { font: 500 12px var(--f-body); color: var(--paper-dim); letter-spacing: 0; }

/* ── Crate dividers (category tabs) ───────── */
.dividers {
  display: flex; gap: 10px; overflow-x: auto; scrollbar-width: none;
  padding: 18px var(--pad) 0; max-width: 1440px; margin: 0 auto;
  scroll-snap-type: x proximity;
}
.dividers::-webkit-scrollbar { display: none; }
.divider {
  --c: var(--paper);
  flex: 0 0 auto; scroll-snap-align: start; cursor: pointer; border: 0;
  position: relative; padding: 18px 22px 12px; min-width: 120px; text-align: left;
  background: var(--ink-3); color: var(--paper-dim);
  border-radius: 4px 4px 0 0; transform: translateY(10px);
  transition: transform .25s cubic-bezier(.2,.8,.2,1), background .2s, color .2s;
  clip-path: polygon(0 10px, 26px 10px, 34px 0, 82px 0, 90px 10px, 100% 10px, 100% 100%, 0 100%);
}
.divider:hover { transform: translateY(4px); color: var(--paper); }
.divider[aria-pressed="true"] { background: var(--c); color: var(--ink); transform: translateY(0); }
.divider__name { display: block; font: 900 26px/1 var(--f-display); text-transform: uppercase; letter-spacing: .03em; }
.divider__count { font: 600 11px/1 var(--f-mono); opacity: .75; }

/* ── Controls ─────────────────────────────── */
.controls {
  position: sticky; top: 0; z-index: 20;
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  padding: 12px var(--pad);
  background: rgba(21, 17, 14, .86); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 3px solid var(--cat); border-bottom: 1px solid var(--line);
  max-width: 1440px; margin: 0 auto;
}
@media (min-width: 1440px) { .controls { border-left: 1px solid var(--line); border-right: 1px solid var(--line); } }
.search { flex: 1 1 220px; display: flex; align-items: center; gap: 8px; background: var(--ink-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 0 12px; min-height: 42px; }
.search:focus-within { border-color: var(--mustard); }
.search svg { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2; flex: none; }
.search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; padding: 10px 0; font-size: 16px; }
.select { display: flex; align-items: center; gap: 8px; background: var(--ink-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 0 4px 0 12px; min-height: 42px; }
.select__label { font: 600 10px var(--f-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.select select { border: 0; background: none; padding: 10px 6px; font-weight: 600; cursor: pointer; font-size: 15px; }
.select select option { background: var(--ink-2); }
.chips { display: flex; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: var(--ink-2); border-radius: 999px; padding: 9px 14px; cursor: pointer;
  font-weight: 600; font-size: 13px; min-height: 42px; transition: background .15s, color .15s, border-color .15s;
}
.chip::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid currentColor; margin-right: 8px; vertical-align: 1px; }
.chip[aria-pressed="true"] { background: var(--mint); color: var(--ink); border-color: var(--mint); }
.chip[aria-pressed="true"]::before { background: currentColor; }
.viewtoggle { display: flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-left: auto; }
.viewtoggle button { border: 0; background: var(--ink-2); padding: 0 12px; min-height: 42px; cursor: pointer; display: grid; place-items: center; }
.viewtoggle button[aria-pressed="true"] { background: var(--paper); color: var(--ink); }
.viewtoggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }
.controls__row { flex: 10 1 auto; display: flex; gap: 10px; align-items: center; }
.select, .chip, .viewtoggle { flex: none; white-space: nowrap; }
@media (max-width: 639px) {
  .controls { position: static; gap: 10px; padding-top: 14px; }
  .search { flex-basis: 100%; }
  .controls__row { overflow-x: auto; scrollbar-width: none; margin: 0 calc(var(--pad) * -1); padding: 0 var(--pad) 2px; }
  .controls__row::-webkit-scrollbar { display: none; }
  .divider { min-width: 104px; padding: 16px 16px 10px; }
  .divider__name { font-size: 22px; }
  .stats dd small { display: block; margin-top: 4px; }
  .d__art { max-width: 240px; width: 70%; margin: 0 auto; }
}

.resultline { max-width: 1440px; margin: 0 auto; padding: 16px var(--pad) 0; font: 500 11px var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

/* ── Crate grid ───────────────────────────── */
.crate {
  max-width: 1440px; margin: 0 auto; padding: 14px var(--pad) 60px;
  display: grid; gap: 28px 18px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (min-width: 640px) { .crate { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 36px 24px; } }

.card {
  position: relative; display: flex; flex-direction: column; cursor: pointer; text-align: left;
  border: 0; padding: 0; background: none;
  animation: deal .55s cubic-bezier(.2,.8,.2,1) both; animation-delay: calc(var(--i, 0) * 35ms);
}
@keyframes deal { from { opacity: 0; transform: translateY(18px) rotate(.6deg); } }

.art { position: relative; aspect-ratio: 1; border-radius: var(--radius); background: linear-gradient(160deg, var(--ink-3), var(--ink-2)); overflow: hidden; isolation: isolate; }
.art img { display: block; }
.art--vinyl .sleeve {
  position: absolute; left: 4%; top: 6%; width: 82%; aspect-ratio: 1; z-index: 2;
  box-shadow: 0 10px 24px rgba(0,0,0,.55), inset 0 0 0 1px rgba(255,255,255,.06); border-radius: 2px; overflow: hidden; background: var(--ink-3);
  transition: transform .45s cubic-bezier(.2,.8,.2,1);
}
.art--vinyl .sleeve img { width: 100%; height: 100%; object-fit: cover; }
.disc {
  position: absolute; left: 8%; top: 8%; width: 78%; aspect-ratio: 1; border-radius: 50%; z-index: 1;
  background:
    radial-gradient(circle, var(--disc, var(--gun)) 0 15%, #0b0907 15.5% 17%, transparent 17.5%),
    repeating-radial-gradient(circle, #111 0 1.2px, #1c1815 1.6px 2.6px),
    #111;
  box-shadow: 0 6px 20px rgba(0,0,0,.6);
  transform: translateX(14%) rotate(0deg);
  transition: transform .6s cubic-bezier(.2,.8,.2,1);
}
.disc::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: conic-gradient(from 30deg, transparent 0 20%, rgba(255,255,255,.09) 25%, transparent 32% 70%, rgba(255,255,255,.06) 75%, transparent 82%); }
.card:hover .disc, .card:focus-visible .disc { transform: translateX(26%) rotate(140deg); }
.card:hover .sleeve, .card:focus-visible .sleeve { transform: translateX(-3%) rotate(-1.5deg); }

.art--book { display: grid; place-items: center; background: radial-gradient(70% 60% at 50% 40%, #33281f, var(--ink-2)); }
.art--book .cover {
  height: 86%; width: auto; max-width: 78%; object-fit: contain; border-radius: 1px 3px 3px 1px;
  box-shadow: 1px 0 0 #e9dfcb, 2px 0 0 #b9ad98, 3px 0 0 #e9dfcb, 4px 0 0 #a99d88, 5px 1px 0 #d7ccb6, 12px 14px 22px rgba(0,0,0,.6);
  transform: perspective(700px) rotateY(-8deg); transform-origin: left center;
  transition: transform .45s cubic-bezier(.2,.8,.2,1);
}
.card:hover .cover, .card:focus-visible .cover { transform: perspective(700px) rotateY(-22deg) translateX(-2%); }
.art--other img { width: 100%; height: 100%; object-fit: contain; padding: 10%; }
.art__ph { position: absolute; inset: 0; display: grid; place-items: center; font: 900 42px var(--f-display); color: var(--line); }

.tag {
  position: absolute; left: -4px; bottom: 12px; z-index: 5;
  background: var(--gun); color: var(--gun-ink); padding: 6px 12px 6px 18px;
  font: 800 16px/1 var(--f-mono); letter-spacing: -.02em;
  transform: rotate(-3deg); box-shadow: 3px 4px 0 rgba(0,0,0,.4);
  clip-path: polygon(8px 0, 100% 0, 100% 100%, 8px 100%, 0 50%);
}
.tag s { display: block; font: 600 10px/1 var(--f-mono); opacity: .7; margin-bottom: 3px; }
.tag--none { background: var(--ink-3); color: var(--paper-dim); }
.stamp {
  position: absolute; right: 8px; top: 8px; z-index: 5;
  width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; text-align: center;
  background: var(--mustard); color: var(--ink); font: 900 19px/0.9 var(--f-display); transform: rotate(10deg);
  box-shadow: 0 0 0 3px var(--ink), 0 0 0 4px var(--mustard);
}
.stamp small { display: block; font: 700 8px var(--f-mono); letter-spacing: .06em; }
.ribbon { position: absolute; left: 8px; top: 8px; z-index: 5; font: 700 9px/1 var(--f-mono); letter-spacing: .1em; text-transform: uppercase; padding: 5px 7px; border-radius: 3px; background: var(--ink); color: var(--rose); border: 1px solid currentColor; }
.ribbon--deal { color: var(--mint); }

.card__body { padding: 12px 2px 0; display: grid; gap: 6px; }
.card__title { margin: 0; font: 600 15px/1.25 var(--f-body); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card__meta { display: flex; flex-wrap: wrap; gap: 4px 10px; font: 500 11px/1.3 var(--f-mono); color: var(--muted); }
.avail { display: inline-flex; align-items: center; gap: 5px; }
.avail::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.avail--in_stock { color: var(--mint); }
.avail--preorder { color: var(--mustard); }
.avail--sold_out { color: var(--rose); }
.avail--unknown { color: var(--muted); }
.card:hover .card__title { text-decoration: underline; text-decoration-color: var(--gun); text-underline-offset: 3px; }

/* ── Ledger view ──────────────────────────── */
.crate.ledger { display: block; padding-top: 6px; }
.row {
  display: grid; align-items: center; gap: 4px 14px; width: 100%; text-align: left; cursor: pointer;
  grid-template-columns: 52px 1fr auto; grid-template-areas: "thumb title price" "thumb meta price";
  background: none; border: 0; border-bottom: 1px dashed var(--line); padding: 12px 4px;
  animation: deal .4s ease both; animation-delay: calc(var(--i, 0) * 20ms);
}
.row:hover { background: rgba(255,255,255,.03); }
.row__thumb { grid-area: thumb; width: 52px; height: 52px; object-fit: cover; border-radius: 3px; background: var(--ink-3); }
.row__title { grid-area: title; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__meta { grid-area: meta; font: 500 11px var(--f-mono); color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.row__price { grid-area: price; text-align: right; font: 800 17px var(--f-mono); }
.row__price small { display: block; font: 500 10px var(--f-mono); color: var(--muted); }
.row__off { color: var(--mustard); }
.row__meta > span:empty { display: none; }
@media (min-width: 900px) {
  .row { grid-template-columns: 52px minmax(0, 1fr) 90px 160px 110px 110px 120px; grid-template-areas: "thumb title cat store off avail price"; }
  .row__meta { display: contents; }
  .row__meta > span:nth-child(1) { grid-area: cat; } .row__meta > span:nth-child(2) { grid-area: store; }
  .row__meta > span:nth-child(3) { grid-area: off; } .row__meta > span:nth-child(4) { grid-area: avail; }
  .row__meta > span:nth-child(5) { display: none; }
}

.empty { grid-column: 1 / -1; text-align: center; padding: 60px 20px; color: var(--muted); }
.empty strong { display: block; font: 900 44px var(--f-display); color: var(--line); text-transform: uppercase; }

/* ── Detail dialog ────────────────────────── */
.detail {
  border: 0; padding: 0; color: var(--paper); background: var(--ink-2);
  width: min(920px, 100vw); max-width: 100vw; max-height: 92vh;
  border-radius: 10px; box-shadow: 0 30px 80px rgba(0,0,0,.7), 0 0 0 1px var(--line);
}
.detail::backdrop { background: rgba(8, 6, 5, .72); backdrop-filter: blur(3px); }
.detail[open] { animation: pop .3s cubic-bezier(.2,.8,.2,1); }
@keyframes pop { from { opacity: 0; transform: translateY(24px) scale(.98); } }
@media (max-width: 640px) {
  .detail { margin: auto 0 0; width: 100vw; max-height: 90vh; border-radius: 14px 14px 0 0; }
  .detail[open] { animation: sheet .35s cubic-bezier(.2,.8,.2,1); }
  @keyframes sheet { from { transform: translateY(100%); } }
}
.detail__close { position: sticky; top: 0; z-index: 3; display: flex; justify-content: flex-end; height: 0; }
.detail__close button { margin: 10px; width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: var(--ink); cursor: pointer; font-size: 15px; }
.d { display: grid; gap: 24px; padding: 24px; }
@media (min-width: 760px) { .d { grid-template-columns: 300px 1fr; padding: 32px; } }
.d__art { position: relative; }
.d__art .art { box-shadow: inset 0 0 0 1px var(--line); }
.d__cat { font: 600 10px var(--f-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--cat); }
.d h2 { margin: 6px 40px 8px 0; font: 800 clamp(28px, 4vw, 40px)/1 var(--f-display); text-transform: uppercase; letter-spacing: .01em; }
.d__sub { margin: 0 0 14px; color: var(--paper-dim); }
.d__facts { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 18px; padding: 0; list-style: none; }
.d__facts li { font: 500 11px var(--f-mono); padding: 5px 8px; border: 1px solid var(--line); border-radius: 3px; color: var(--paper-dim); }
.d__notes { margin: 0 0 18px; padding: 12px 14px; border: 1px dashed rgba(242,193,78,.45); border-radius: var(--radius); background: rgba(242,193,78,.05); color: var(--paper-dim); font-size: 14px; }
.d h3 { margin: 0 0 10px; font: 600 10px var(--f-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.offers { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.offer {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--ink);
}
.offer--best { border-color: var(--mint); background: rgba(111,224,184,.06); }
.offer__store { font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.offer__store a { text-decoration-color: var(--gun); text-underline-offset: 3px; }
.badge { font: 700 9px/1 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; padding: 4px 6px; border-radius: 3px; background: var(--ink-3); color: var(--paper-dim); }
.badge--best { background: var(--mint); color: var(--ink); }
.badge--warn { background: rgba(255,122,144,.12); color: var(--rose); }
.offer__price { text-align: right; font: 800 18px var(--f-mono); white-space: nowrap; }
.offer__price s { display: block; font: 500 11px var(--f-mono); color: var(--muted); }
.offer__meta { grid-column: 1 / -1; font: 500 11px/1.5 var(--f-mono); color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 12px; }
.collection { margin-top: 18px; }
.collection ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.collection li { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; border-bottom: 1px dashed var(--line); padding: 6px 0; }
.collection li span:last-child { font-family: var(--f-mono); white-space: nowrap; }

.foot { max-width: 1440px; margin: 0 auto; padding: 24px var(--pad) 40px; border-top: 1px solid var(--line); color: var(--muted); font: 500 11px var(--f-mono); }
.foot code { color: var(--paper-dim); }

@media (hover: none) {
  .disc { transform: translateX(20%); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
