/* Paper, ink, and one colour: thrift-sticker orange, used only for prices, the find sticker and what
   you've picked. The canvas reads --bg, --tile, --accent and --text too. */
:root {
  --bg: #f2efe9;
  --paper: #faf8f4;
  --tile: #e4e0d8;
  --text: #1c1b19;
  --soft: #4a4740;
  --muted: #7a756c;
  --faint: #aaa498;
  --hair: rgba(28, 27, 25, 0.1);
  --hair-strong: rgba(28, 27, 25, 0.22);
  --accent: #f2541b;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", "URW Palladio L", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --spring: cubic-bezier(0.34, 1.4, 0.5, 1);
  --edge: max(22px, env(safe-area-inset-left));
  --edge-r: max(22px, env(safe-area-inset-right));
  --edge-b: max(22px, env(safe-area-inset-bottom));
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
::selection { background: var(--accent); color: #fff; }

button { font: inherit; color: inherit; padding: 0; border: 0; background: none; cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.round {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--hair-strong);
  background: rgba(250, 248, 244, 0.7);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: var(--text);
  transition: transform 0.3s var(--spring), background 0.2s ease, border-color 0.2s ease;
}
.round:hover { background: var(--paper); border-color: var(--text); transform: rotate(90deg); }

/* ---- the wall ---------------------------------------------------------- */
#grid {
  position: fixed;
  inset: 0;
  display: block;
  touch-action: none;
  outline: none;
  opacity: 0;
  transition: opacity 0.4s ease;
}
[data-state="ready"] #grid { opacity: 1; }
[data-state="ready"] #grid.is-switching { opacity: 0; transition-duration: 0.18s; }

/* ---- loading, error and no results ------------------------------------- */
.loader { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); transition: opacity 0.3s ease; }
.loader span { display: block; width: 14px; height: 14px; border-radius: 50%; background: var(--accent); animation: breathe 1.1s var(--ease) infinite alternate; }
@keyframes breathe { from { transform: scale(0.6); opacity: 0.5; } to { transform: scale(1); opacity: 1; } }
html:not([data-state="loading"]) .loader { opacity: 0; visibility: hidden; pointer-events: none; transition: opacity 0.3s ease, visibility 0s 0.3s; }
html:not([data-state="loading"]) .loader span { animation: none; }

.state, .no-results {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 24px;
  text-align: center;
  pointer-events: none;
}
.state > *, .no-results > * { pointer-events: auto; }
.state { display: none; }
.no-results[hidden] { display: none; }
.no-results p, .state__text {
  margin: 0;
  padding: 18px 26px;
  background: var(--paper);
  font-family: var(--serif);
  font-size: 26px;
  line-height: 1.2;
  box-shadow: 0 20px 50px -30px rgba(40, 30, 20, 0.5);
}
[data-state="error"] .state, [data-state="empty"] .state { display: flex; }
.state__text { display: none; }
[data-state="error"] .state__text--error, [data-state="empty"] .state__text--empty { display: block; }
[data-state="empty"] .state__retry { display: none; }
.state__retry, .no-results__clear { font-size: 15px; padding: 4px 0; border-bottom: 1.5px solid var(--accent); }
.state__retry:hover, .no-results__clear:hover { color: var(--accent); }

.noscript { position: fixed; inset: 0; display: grid; place-items: center; margin: 0; font-family: var(--serif); font-size: 22px; }

/* ---- the corner: find sticker and what you're looking at ------------------ */
.corner {
  position: fixed;
  right: var(--edge-r);
  bottom: var(--edge-b);
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: opacity 0.3s ease, transform 0.4s var(--ease);
}
html:not([data-state="ready"]) .corner, .index-open .corner { opacity: 0; transform: translateY(10px); pointer-events: none; }

.find {
  width: 68px;
  height: 68px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-family: var(--serif);
  font-style: italic;
  font-size: 21px;
  line-height: 1;
  transform: rotate(-9deg);
  box-shadow: 0 10px 22px -8px rgba(140, 40, 0, 0.55), inset 0 0 0 4px rgba(255, 255, 255, 0.14);
  transition: transform 0.45s var(--spring), box-shadow 0.3s ease;
  animation: arrive 0.7s var(--spring) 0.9s backwards;
}
.find span { transform: translateY(-1px); }
.find:hover { transform: rotate(0deg) scale(1.07); box-shadow: 0 14px 28px -10px rgba(140, 40, 0, 0.6), inset 0 0 0 4px rgba(255, 255, 255, 0.18); }
.find:active { transform: rotate(-4deg) scale(0.96); }
@keyframes arrive { from { transform: rotate(-40deg) scale(0); } }

.tag {
  display: flex;
  align-items: center;
  margin: 0;
  max-width: min(46vw, 420px);
  height: 38px;
  background: var(--paper);
  box-shadow: 0 12px 30px -16px rgba(40, 30, 20, 0.45), 0 0 0 1px var(--hair);
  animation: tag-in 0.4s var(--ease);
}
.tag[hidden] { display: none; }
@keyframes tag-in { from { opacity: 0; transform: translateX(10px); } }
.tag__text {
  min-width: 0;
  height: 100%;
  padding: 0 4px 0 14px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-family: var(--serif);
  font-size: 17px;
}
.tag__clear { flex: none; width: 34px; height: 100%; display: grid; place-items: center; color: var(--muted); }
.tag__clear:hover { color: var(--accent); }

.hint {
  position: fixed;
  left: var(--edge);
  bottom: var(--edge-b);
  z-index: 5;
  max-width: calc(100vw - 140px);
  margin: 0;
  padding: 11px 15px;
  background: var(--text);
  color: var(--bg);
  font-size: 13px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.5s var(--ease), transform 0.5s var(--ease);
}
.hint.is-visible { opacity: 1; transform: none; }

/* ---- the index ------------------------------------------------------------- */
.index {
  position: fixed;
  inset: 0;
  z-index: 15;
  background: rgba(242, 239, 233, 0.9);
  -webkit-backdrop-filter: blur(28px) saturate(0.7);
  backdrop-filter: blur(28px) saturate(0.7);
}
.index[hidden] { display: none; }

.index__scroll {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: max(9vh, 64px) clamp(24px, 7vw, 120px) 150px;
  scrollbar-width: none;
}
.index__scroll::-webkit-scrollbar { display: none; }

.index__search { display: block; border-bottom: 1px solid var(--hair-strong); }
.index__search:focus-within { border-bottom-color: var(--text); }
.index__input {
  width: 100%;
  padding: 0 0 14px;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font-family: var(--serif);
  font-size: clamp(36px, 5vw, 76px);
  letter-spacing: -0.02em;
  line-height: 1.1;
  -webkit-user-select: text;
  user-select: text;
}
.index__input::placeholder { color: var(--faint); font-style: italic; }
.index__input::-webkit-search-cancel-button { display: none; }

.index__body {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(260px, 0.8fr);
  gap: clamp(40px, 7vw, 120px);
  margin-top: clamp(36px, 7vh, 80px);
}
.index__big { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: clamp(32px, 5vw, 90px); align-items: start; }
.index__col { display: flex; flex-direction: column; align-items: flex-start; }

.big {
  display: inline-flex;
  align-items: flex-start;
  gap: 6px;
  padding: 1px 0;
  font-family: var(--serif);
  font-size: clamp(30px, 3.3vw, 52px);
  line-height: 1.12;
  letter-spacing: -0.02em;
  text-align: left;
  color: var(--text);
  transition: color 0.2s ease, transform 0.35s var(--ease), opacity 0.2s ease;
}
.big:hover:not(:disabled) { transform: translateX(8px); }
.big.is-on { color: var(--accent); }
.big:disabled { color: var(--faint); opacity: 0.45; }
.big__count { margin-top: 0.35em; font-family: var(--sans); font-size: 12px; letter-spacing: 0; color: var(--muted); font-variant-numeric: tabular-nums; }
.big.is-on .big__count { color: var(--accent); }

.index__small { display: flex; flex-direction: column; gap: 34px; }
.facet__title { margin: 0 0 10px; color: var(--muted); font-size: 12px; font-weight: 500; letter-spacing: 0.04em; }

.facet__options--list { display: flex; flex-direction: column; align-items: flex-start; }
.opt--list {
  position: relative;
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 5px 0 5px 0;
  font-size: 16px;
  text-align: left;
  transition: color 0.15s ease, padding 0.3s var(--ease);
}
.opt--list::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 7px;
  height: 7px;
  margin-top: -3px;
  border-radius: 50%;
  background: var(--accent);
  transform: scale(0);
  transition: transform 0.3s var(--spring);
}
.opt--list:hover:not(:disabled) { color: var(--accent); }
.opt--list.is-on { padding-left: 16px; color: var(--text); }
.opt--list.is-on::before { transform: scale(1); }
.opt__count { color: var(--faint); font-size: 12px; font-variant-numeric: tabular-nums; }
.opt.is-extra { display: none; }
.facet.is-expanded .opt.is-extra, .opt.is-extra.is-pinned { display: inline-flex; }
.facet__more { margin-top: 6px; padding: 3px 0; color: var(--muted); font-size: 13px; border-bottom: 1px solid var(--hair-strong); }
.facet__more:hover { color: var(--text); border-bottom-color: currentColor; }

.facet__options--grid { display: flex; flex-wrap: wrap; gap: 6px; }
.opt--grid {
  min-width: 48px;
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--hair-strong);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.opt--grid:hover:not(:disabled) { border-color: var(--text); }
.opt--grid.is-on { background: var(--accent); border-color: var(--accent); color: #fff; }

.facet__options--swatch { display: flex; flex-wrap: wrap; gap: 10px; }
.opt--swatch { position: relative; width: 30px; height: 30px; }
.opt--swatch .opt__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.opt__swatch {
  display: block;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(28, 27, 25, 0.14);
  transition: box-shadow 0.25s var(--ease), transform 0.3s var(--spring);
}
.opt--swatch:hover:not(:disabled) .opt__swatch { transform: scale(1.12); }
.opt--swatch.is-on .opt__swatch { box-shadow: inset 0 0 0 1px rgba(28, 27, 25, 0.14), 0 0 0 3px var(--bg), 0 0 0 5px var(--accent); }

.opt[hidden] { display: none !important; }

.index__foot {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 40px clamp(24px, 7vw, 120px) max(26px, env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, rgba(242, 239, 233, 0), rgba(242, 239, 233, 0.96) 45%);
  pointer-events: none;
}
.index__foot > * { pointer-events: auto; }
.index__reset { font-size: 15px; color: var(--muted); padding: 4px 0; border-bottom: 1px solid transparent; }
.index__reset:hover:not(:disabled) { color: var(--text); border-bottom-color: currentColor; }
.index__reset:disabled { opacity: 0; pointer-events: none; }
.index__show {
  height: 54px;
  padding: 0 28px;
  background: var(--text);
  color: var(--bg);
  font-size: 15px;
  transition: background 0.2s ease, transform 0.3s var(--spring);
}
.index__show:hover:not(:disabled) { background: var(--accent); transform: translateY(-2px); }
.index__show:disabled { opacity: 0.4; }

.index__close { position: absolute; top: max(22px, env(safe-area-inset-top)); right: var(--edge-r); }

@media (max-width: 760px) {
  .index__body { grid-template-columns: 1fr; }
  .index__big { gap: 36px; }
  .big { font-size: 27px; white-space: nowrap; }
  .index__foot { padding-left: 22px; padding-right: 22px; }
  .index__show { flex: 1; }
}

/* ---- item page ------------------------------------------------------------ */
.viewer {
  --tint: 242, 239, 233;
  position: fixed;
  inset: 0;
  z-index: 20;
  touch-action: none;
}
.viewer[hidden] { display: none; }
.viewer:focus { outline: none; }

.viewer__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(var(--tint), 0.88);
  -webkit-backdrop-filter: blur(30px) saturate(0.75);
  backdrop-filter: blur(30px) saturate(0.75);
}

.viewer__layout {
  --info: 360px;
  --gap: clamp(56px, 6vw, 112px);
  --pad-x: clamp(110px, 11vw, 200px);
  --pad-y: max(9vh, 64px);
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: auto var(--info);
  align-items: center;
  justify-content: center;
  gap: var(--gap);
  padding: var(--pad-y) var(--pad-x);
}

.viewer__frame { position: relative; }
.viewer__photo {
  --size: min(calc(100vh - var(--pad-y) * 2), calc(100vw - var(--pad-x) * 2 - var(--info) - var(--gap)), 820px);
  position: relative;
  width: var(--size);
  height: var(--size);
  overflow: hidden;
  background: var(--tile);
  box-shadow: 0 60px 100px -60px rgba(40, 30, 20, 0.6);
  transform-origin: 0 0;
  will-change: transform;
  touch-action: none;
  cursor: grab;
}
.viewer__photo:active { cursor: grabbing; }
.viewer__photo canvas, .viewer__photo img { position: absolute; inset: 0; width: 100%; height: 100%; }
.viewer__photo img { object-fit: contain; opacity: 0; transition: opacity 0.35s ease; -webkit-user-drag: none; }
.viewer__photo img.is-loaded { opacity: 1; }

.sticker {
  --tilt: -8deg;
  --len: 3;
  position: absolute;
  top: -30px;
  right: -30px;
  z-index: 2;
  width: 104px;
  height: 104px;
  margin: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-family: var(--sans);
  font-weight: 700;
  font-size: calc(30px - var(--len) * 1.4px);
  letter-spacing: -0.02em;
  font-variant-numeric: lining-nums;
  transform: rotate(var(--tilt));
  box-shadow: 0 10px 20px -8px rgba(140, 40, 0, 0.5), inset 0 0 0 4px rgba(255, 255, 255, 0.15);
  pointer-events: none;
}
.sticker[hidden] { display: none; }

.viewer__info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  max-height: calc(100vh - var(--pad-y) * 2);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  touch-action: pan-y;
  -webkit-user-select: text;
  user-select: text;
}
.viewer__info::-webkit-scrollbar { display: none; }

.viewer__title {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(42px, 4.3vw, 70px);
  font-weight: 400;
  line-height: 0.98;
  letter-spacing: -0.03em;
  overflow-wrap: anywhere;
}
.viewer__brand { margin: 14px 0 0; color: var(--muted); font-family: var(--serif); font-style: italic; font-size: 21px; }
.viewer__brand[hidden], .viewer__line[hidden] { display: none; }
.viewer__line { margin: 28px 0 0; max-width: 30ch; color: var(--soft); font-size: 16px; line-height: 1.6; }

.viewer__links { margin-top: 44px; }
.buy {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 8px;
  border-bottom: 1.5px solid var(--text);
  color: var(--text);
  text-decoration: none;
  font-family: var(--serif);
  font-size: 30px;
  letter-spacing: -0.015em;
  -webkit-user-select: none;
  user-select: none;
}
.buy__arrow {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  transition: transform 0.4s var(--spring);
}
.buy:hover .buy__arrow, .buy:focus-visible .buy__arrow { transform: translateX(6px) rotate(-45deg); }
.also { margin: 18px 0 0; color: var(--muted); font-size: 14px; }
.also__link { color: var(--text); text-decoration: underline; text-decoration-color: var(--hair-strong); text-underline-offset: 3px; }
.also__link:hover { color: var(--accent); text-decoration-color: currentColor; }
.viewer__gone { margin: 0; font-family: var(--serif); font-style: italic; font-size: 22px; color: var(--muted); }

.viewer__share { margin-top: 46px; padding: 3px 0; color: var(--muted); font-size: 13px; border-bottom: 1px solid var(--hair-strong); -webkit-user-select: none; user-select: none; }
.viewer__share:hover { color: var(--text); border-bottom-color: currentColor; }

.peek {
  position: absolute;
  top: 50%;
  z-index: 1;
  width: clamp(110px, 12vw, 190px);
  aspect-ratio: 1;
  margin-top: calc(clamp(110px, 12vw, 190px) / -2);
  box-shadow: 0 30px 50px -30px rgba(40, 30, 20, 0.5);
  opacity: 0.5;
  transition: transform 0.55s var(--ease), opacity 0.3s ease;
}
.peek canvas { display: block; width: 100%; height: 100%; }
.peek--prev { left: 0; transform: translateX(-64%); }
.peek--next { right: 0; transform: translateX(64%); }
.peek--prev:hover, .peek--prev:focus-visible { transform: translateX(-38%); opacity: 1; }
.peek--next:hover, .peek--next:focus-visible { transform: translateX(38%); opacity: 1; }
.peek[hidden] { display: none; }

.viewer__close { position: absolute; top: max(24px, env(safe-area-inset-top)); right: var(--edge-r); z-index: 3; }

/* Phones and narrow windows: the photo edge to edge on top, the page underneath (scrolls). Swipe to step. */
@media (max-width: 960px), (max-aspect-ratio: 1/1) {
  .viewer__layout {
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
    justify-items: center;
    gap: 0;
    padding: 0 0 max(48px, env(safe-area-inset-bottom));
    overflow-y: auto;
    overscroll-behavior: contain;
    touch-action: pan-y;
    scrollbar-width: none;
  }
  .viewer__layout::-webkit-scrollbar { display: none; }
  .viewer__frame { width: 100%; display: flex; justify-content: center; }
  .viewer__photo { --size: min(100vw, 72vh); box-shadow: none; }
  .sticker { top: auto; bottom: -36px; right: 18px; width: 88px; height: 88px; font-size: calc(26px - var(--len) * 1.2px); }
  .viewer__info { width: min(100%, 640px); max-height: none; overflow: visible; padding: 34px 24px 0; }
  .viewer__title { font-size: 42px; padding-right: 76px; }
  .viewer__links { margin-top: 34px; }
  .buy { font-size: 26px; }
  .viewer__share { margin-top: 36px; }
  .peek { display: none; }
  .viewer__close { top: max(14px, env(safe-area-inset-top)); right: 14px; }
}

/* ---- 404 page ------------------------------------------------------------- */
.page-404 { overflow: auto; }
.notfound { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 24px; text-align: center; }
.notfound__code { margin: 0; color: var(--accent); font-weight: 700; font-size: 14px; }
.notfound__title { margin: 0; font-family: var(--serif); font-size: 34px; font-weight: 400; letter-spacing: -0.015em; }
.notfound__link { color: var(--text); text-decoration: none; padding: 4px 0; border-bottom: 1.5px solid var(--accent); }
.notfound__link:hover { color: var(--accent); }
