/* Sundrie's buyer site. The app's palette (apps/mobile/src/lib/theme.ts):
   ink on the mark's warm paper, one green for the visitor's action, red
   only for what is gone. Spacing in steps of 4; 16 px side margins. */

:root {
  --bg: #f5f2ec;
  --card: #ffffff;
  --fg: #18181b;
  --dim: #57534e;
  --border: #d6d1c7;
  --tile: #e7e2d8;
  --green: #108038;
  --green-text: #108038;
  --red: #b91c1c;
  --scrim: rgba(24, 24, 27, 0.72);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1a1a;
    --card: #232323;
    --fg: #f4f4f5;
    --dim: #a1a1aa;
    --border: #3f3f46;
    --tile: #2a2a2a;
    --green-text: #22c55e;
    --red: #ff6b6b;
    --scrim: rgba(0, 0, 0, 0.72);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1a1a1a;
  --card: #232323;
  --fg: #f4f4f5;
  --dim: #a1a1aa;
  --border: #3f3f46;
  --tile: #2a2a2a;
  --green-text: #22c55e;
  --red: #ff6b6b;
  --scrim: rgba(0, 0, 0, 0.72);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
img { display: block; max-width: 100%; }
button, input { font: inherit; color: inherit; }
.wrap { max-width: 936px; margin: 0 auto; }
.pad { padding: 0 16px; }
.dim { color: var(--dim); }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ------------------------------------------------------------ top bar */
.bar {
  position: sticky; top: 0; z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.bar .wrap {
  display: grid; grid-template-columns: 44px 1fr 44px; align-items: center;
  min-height: 48px; padding: 0 8px;
}
.bar .title {
  text-align: center; font-weight: 600; font-size: 16px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-decoration: none;
}
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border: 0; background: none; padding: 0;
  text-decoration: none; position: relative; cursor: pointer;
}
.icon-btn svg { width: 24px; height: 24px; }
.badge {
  position: absolute; top: 6px; right: 4px;
  min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px;
  background: var(--green); color: #fff;
  font-size: 12px; font-weight: 600; line-height: 18px; text-align: center;
}
.badge[hidden] { display: none; }

/* ----------------------------------------------------------- sale head */
.head { padding: 16px 16px 12px; }
.head h1 { margin: 0; font-size: 20px; line-height: 1.2; font-weight: 700; }
.head .when { margin: 4px 0 0; color: var(--dim); font-size: 14px; }
.counts { display: flex; gap: 16px; margin: 12px 0 0; font-size: 14px; }
.counts b { font-weight: 600; }
.note {
  margin: 12px 0 0; padding: 8px 12px; border-radius: 8px;
  background: var(--card); border: 1px solid var(--border); font-size: 14px;
}
.note b { font-weight: 600; }
.tools { display: flex; gap: 8px; margin: 12px 0 0; }
.search {
  flex: 1; display: flex; align-items: center; gap: 8px;
  min-height: 40px; padding: 0 12px; border-radius: 10px;
  background: var(--card); border: 1px solid var(--border);
}
.search svg { width: 16px; height: 16px; flex: none; color: var(--dim); }
.search input {
  flex: 1; min-width: 0; border: 0; background: none; outline: none;
  font-size: 16px; padding: 8px 0;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--card);
  font-weight: 600; font-size: 15px; text-decoration: none; cursor: pointer;
}
.btn.small { min-height: 40px; padding: 0 12px; font-size: 14px; }
.btn svg { width: 20px; height: 20px; flex: none; }
.bar .mark { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; }
.bar .mark img { width: 28px; height: 28px; border-radius: 7px; }
.btn.go { background: var(--green); border-color: var(--green); color: #fff; }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: 0.5; cursor: default; }

/* ------------------------------------------------- profile row (sale) */
.profile { display: flex; align-items: center; gap: 16px; }
.avatar {
  flex: none; width: 72px; height: 72px; border-radius: 50%; overflow: hidden;
  background: var(--tile); border: 1px solid var(--border);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.who { flex: 1; min-width: 0; }
.who .counts { margin-top: 8px; }
.follow-slot:empty { display: none; }

/* ------------------------------------------------- front page and blocks */
.intro { padding: 24px 16px 8px; }
.intro h1 { margin: 0; font-size: 28px; line-height: 1.15; font-weight: 800; letter-spacing: -0.01em; }
.intro p { margin: 8px 0 0; color: var(--dim); font-size: 16px; }
.block { padding: 8px 0 0; }
.block-title { margin: 16px 16px 8px; font-size: 17px; font-weight: 700; }

/* Mixed sizes, rounded, photo first. Three across on a phone (the first
   tile two by two), six across on a wide screen (the first two). */
.mosaic {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  padding: 0 16px; grid-auto-flow: dense;
}
.m-tile {
  position: relative; display: block; aspect-ratio: 1; overflow: hidden;
  border-radius: 12px; background: var(--tile); text-decoration: none; color: #fff;
}
.m-tile img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.3s ease; }
.m-tile:hover img { transform: scale(1.03); }
.m-tile.big { grid-column: span 2; grid-row: span 2; aspect-ratio: auto; }
.m-label { display: none; }
.m-tile.big .m-label {
  display: flex; flex-direction: column; gap: 2px;
  position: absolute; left: 0; right: 0; bottom: 0; padding: 40px 12px 40px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.62));
}
.m-title { font-size: 15px; font-weight: 600; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.m-note { font-size: 13px; opacity: 0.85; }
.m-tile .chip { left: 8px; bottom: 8px; }
@media (min-width: 760px) {
  .mosaic { grid-template-columns: repeat(6, 1fr); }
  .m-tile.big-wide { grid-column: span 2; grid-row: span 2; aspect-ratio: auto; }
  .m-tile.big-wide .m-label {
    display: flex; flex-direction: column; gap: 2px;
    position: absolute; left: 0; right: 0; bottom: 0; padding: 40px 12px 40px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.62));
  }
}
@media (prefers-reduced-motion: reduce) { .m-tile img { transition: none; } }

.cards {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px 8px; padding: 0 16px;
}
@media (min-width: 760px) { .cards { grid-template-columns: repeat(4, 1fr); gap: 24px 16px; } }
.card { display: flex; flex-direction: column; gap: 4px; text-decoration: none; }
.card-img { display: block; aspect-ratio: 4 / 5; border-radius: 12px; overflow: hidden; background: var(--tile); }
.card-img img { width: 100%; height: 100%; object-fit: cover; }
.card-title { font-weight: 600; font-size: 15px; margin-top: 4px; }
.card-line { color: var(--dim); font-size: 13px; }

/* ----------------------------------------------------------------- grid */
.grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px;
  margin-top: 4px;
}
.tile {
  position: relative; display: block; aspect-ratio: 4 / 5;
  background: var(--tile); overflow: hidden; text-decoration: none;
}
.tile img { width: 100%; height: 100%; object-fit: cover; }
.tile .price, .chip {
  position: absolute; left: 4px; bottom: 4px;
  padding: 0 8px; border-radius: 12px; line-height: 22px;
  background: rgba(255, 255, 255, 0.94); color: #18181b;
  font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
}
.tile .price s, .chip s { color: #57534e; font-weight: 400; margin-right: 4px; }
.tile.sold img { opacity: 0.45; }
.tile .incart {
  position: absolute; right: 4px; top: 4px; width: 24px; height: 24px;
  border-radius: 12px; background: var(--green); color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.tile .incart svg { width: 14px; height: 14px; }
.tile .incart[hidden] { display: none; }
.more { padding: 16px; text-align: center; }
.empty { padding: 48px 16px; text-align: center; }
.empty h2 { margin: 0; font-size: 17px; font-weight: 600; }
.empty p { margin: 4px 0 0; color: var(--dim); font-size: 15px; }

/* ----------------------------------------------------------------- post */
.post { max-width: 600px; margin: 0 auto; }
.post-title { padding: 12px 16px; font-weight: 600; font-size: 15px; margin: 0; line-height: 1.3; }
.carousel {
  position: relative; display: flex; overflow-x: auto; scroll-snap-type: x mandatory;
  scrollbar-width: none; background: var(--tile);
}
.carousel::-webkit-scrollbar { display: none; }
.slide { flex: 0 0 100%; scroll-snap-align: center; }
.slide img { width: 100%; height: 100%; object-fit: contain; }
.dots { display: flex; justify-content: center; gap: 4px; padding: 8px 0 0; min-height: 14px; }
.dots i { width: 6px; height: 6px; border-radius: 3px; background: var(--border); }
.dots i.on { background: var(--fg); }
.icons { display: flex; align-items: center; padding: 0 8px; }
.icons .spacer { flex: 1; }
.caption { padding: 0 16px 24px; }
.price-line { margin: 4px 0 0; font-size: 22px; font-weight: 700; }
.price-line s { color: var(--dim); font-weight: 400; font-size: 17px; margin-right: 4px; }
.price-line .tag { font-size: 15px; font-weight: 400; color: var(--dim); }
.line { margin: 4px 0 0; font-size: 15px; }
.sold-mark { color: var(--red); font-weight: 700; }
.actions { margin: 16px 0 0; display: grid; gap: 8px; }
details.more-text { margin: 16px 0 0; font-size: 15px; }
details.more-text summary { color: var(--dim); cursor: pointer; list-style: none; min-height: 44px; display: flex; align-items: center; }
details.more-text summary::-webkit-details-marker { display: none; }
details.more-text p { margin: 0 0 8px; }
.facts { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 14px; }
.facts dt { color: var(--dim); }
.facts dd { margin: 0; }
@media (min-width: 900px) {
  .post.wide { max-width: 936px; display: grid; grid-template-columns: 1fr 360px; grid-template-rows: auto 1fr; gap: 0 24px; padding-top: 16px; align-items: start; }
  .post.wide .media { grid-row: 1 / span 2; }
  .post.wide .post-title { padding-top: 0; }
}

/* ----------------------------------------------------------------- cart */
.rows { background: var(--card); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.row { display: flex; gap: 12px; align-items: center; padding: 8px 16px; }
.row + .row { border-top: 1px solid var(--border); }
.row img, .row .ph { width: 48px; height: 60px; object-fit: cover; border-radius: 4px; background: var(--tile); flex: none; }
.row .txt { flex: 1; min-width: 0; }
.row .t { font-size: 15px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; text-decoration: none; }
.row .d { font-size: 13px; color: var(--dim); margin-top: 2px; }
.row .d.bad { color: var(--red); }
.row .amt { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.row .amt s { display: block; font-weight: 400; color: var(--dim); font-size: 13px; }
.qty { display: inline-flex; align-items: center; gap: 4px; margin-top: 4px; }
.qty button { width: 32px; height: 32px; border-radius: 16px; border: 1px solid var(--border); background: var(--bg); cursor: pointer; }
.total { display: flex; justify-content: space-between; align-items: baseline; padding: 16px; font-size: 17px; }
.total b { font-size: 22px; font-variant-numeric: tabular-nums; }
.code-view { text-align: center; padding: 16px; }
.code-view .qr { width: min(100%, 360px); margin: 0 auto; background: #fff; padding: 8px; border-radius: 12px; }
.code-view .qr svg { display: block; width: 100%; height: auto; }
.code-view h2 { margin: 16px 0 0; font-size: 20px; }
.code-view p { margin: 4px 0 0; color: var(--dim); }

/* ----------------------------------------------------------------- scan */
.scan-pick { display: grid; gap: 8px; padding: 16px; }
.scan-preview { width: 100%; max-height: 30vh; object-fit: contain; background: var(--tile); }

/* --------------------------------------------------------------- footer */
.foot { padding: 32px 16px 48px; text-align: center; color: var(--dim); font-size: 13px; }
.foot a { color: var(--dim); text-decoration: none; display: inline-flex; align-items: center; gap: 8px; }
.foot img { width: 24px; height: 24px; border-radius: 6px; }

:focus-visible { outline: 2px solid var(--green-text); outline-offset: 2px; }
