/* SportSwapp-huisstijl: kleuren en logo van www.sportswapp.com; UI-uitwerking 020 ICT (feedback Frank volgt). */
:root {
  --purple: #382d64;
  --purple-soft: #5a4a8c;
  --purple-tint: #f0edf8;
  --green: #80c342;
  --green-dark: #5d9f2f;
  --green-tint: #edf6e5;
  --cream: #fbfaf4;

  --bg: var(--cream);
  --surface: #ffffff;
  --text: #302a42;
  --muted: #696476;
  --line: #e7e2d7;
  --accent: var(--purple);
  --accent-text: #ffffff;
  --danger: #b42318;
  --warn: #8a5a00;
  --warn-tint: #fdf3dc;
  --shadow: 0 1px 2px rgba(56, 45, 100, .06), 0 6px 18px rgba(56, 45, 100, .08);
  --radius: 16px;
  --tabs-h: 64px;
  --font-head: Montserrat, Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-body: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17132a;
    --surface: #221c3c;
    --text: #f2eef9;
    --muted: #b7b0c9;
    --line: #3a3358;
    --accent: var(--green);
    --accent-text: #17132a;
    --purple-tint: #2e2650;
    --green-tint: #233a1a;
    --danger: #f97066;
    --warn: #fbbf24;
    --warn-tint: #3a2e10;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font: 16px/1.5 var(--font-body);
  background: var(--bg);
  color: var(--text);
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 16px);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
img { max-width: 100%; display: block; }
h1, h2 { font-family: var(--font-head); letter-spacing: -.01em; }

/* ---------- kop ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; text-decoration: none; }
.brand img { height: 30px; width: auto; }
.club-name {
  margin-left: auto; color: var(--purple); background: var(--purple-tint);
  font-weight: 600; font-size: .8rem; padding: 4px 10px; border-radius: 999px;
  max-width: 50%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.club-name:empty { display: none; }
@media (prefers-color-scheme: dark) {
  .brand { background: var(--cream); border-radius: 10px; padding: 4px 8px; }
  .club-name { color: var(--text); }
}

main { max-width: 760px; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.5rem; font-weight: 800; margin: 4px 0 12px; color: var(--purple); }
h2 { font-size: 1.1rem; font-weight: 700; margin: 24px 0 10px; }
@media (prefers-color-scheme: dark) { h1 { color: var(--text); } }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow); }

/* ---------- welkom / inloggen ---------- */
.welcome { text-align: center; padding: 20px 0 8px; }
.welcome img { width: min(280px, 80%); margin: 0 auto 16px; }
.welcome p { color: var(--muted); max-width: 30em; margin: 0 auto 8px; }
@media (prefers-color-scheme: dark) { .welcome img { background: var(--cream); padding: 10px 14px; border-radius: 14px; } }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0 20px; text-align: center; font-size: .85rem; color: var(--muted); }
.steps b { display: grid; place-items: center; width: 34px; height: 34px; margin: 0 auto 6px; border-radius: 50%; background: var(--green-tint); color: var(--green-dark); font-family: var(--font-head); }

/* ---------- formulieren ---------- */
form .field { margin-bottom: 14px; }
label { display: block; font-weight: 600; margin-bottom: 6px; font-size: .95rem; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text);
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 12px;
  padding: 11px 12px; min-height: 46px;
}
input:focus, select:focus, textarea:focus { border-color: var(--purple-soft); outline: none; box-shadow: 0 0 0 3px var(--purple-tint); }
textarea { min-height: 100px; resize: vertical; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--green); outline-offset: 2px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 700; min-height: 46px; padding: 10px 18px;
  border-radius: 12px; border: 1.5px solid var(--accent);
  background: var(--accent); color: var(--accent-text); cursor: pointer; text-decoration: none;
  transition: transform .06s ease, filter .15s ease;
}
button:active, .btn:active { transform: scale(.98); }
button:hover, .btn:hover { filter: brightness(1.08); }
button.secondary, .btn.secondary { background: var(--surface); color: var(--text); border-color: var(--line); }
button.green, .btn.green { background: var(--green); border-color: var(--green); color: #1f2a12; }
button.danger { background: transparent; color: var(--danger); border-color: currentColor; }
button.block, .btn.block { width: 100%; }
button:disabled { opacity: .6; cursor: default; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.linkbtn { background: none; border: 0; padding: 0; min-height: 0; color: inherit; text-decoration: underline; font-weight: 500; }

.error { color: var(--danger); margin: 8px 0; }
.error:empty { display: none; }

/* ---------- aanbod ---------- */
.hero {
  background: var(--purple); color: #fff; border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 14px; display: flex; align-items: center; gap: 14px;
}
.hero .count { font-family: var(--font-head); font-weight: 800; font-size: 2.1rem; line-height: 1; color: var(--green); }
.hero p { margin: 0; }
.hero .sub { opacity: .8; font-size: .85rem; }
.hero .sub a { color: #fff; }
@media (prefers-color-scheme: dark) { .hero { background: var(--surface); border: 1px solid var(--line); } }

.search { display: flex; gap: 8px; margin-bottom: 10px; }
.search input { border-radius: 999px; padding-left: 16px; }
.search button { border-radius: 999px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1.5px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 999px; padding: 6px 14px; min-height: 38px; font-weight: 600; font-size: .875rem;
}
.chip[aria-pressed="true"] { background: var(--purple); color: #fff; border-color: var(--purple); }
@media (prefers-color-scheme: dark) { .chip[aria-pressed="true"] { background: var(--green); color: #17132a; border-color: var(--green); } }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 12px; }
.item {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; text-decoration: none; display: flex; flex-direction: column; box-shadow: var(--shadow);
  transition: transform .12s ease;
}
.item:hover { transform: translateY(-2px); }
.thumb { aspect-ratio: 1; background: var(--purple-tint); display: grid; place-items: center; color: var(--muted); font-size: .8rem; position: relative; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb img.ph { width: 42%; height: auto; object-fit: contain; opacity: .3; }
.item .body { padding: 10px 12px 12px; }
.item .title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: .82rem; color: var(--muted); margin-top: 6px; }
.tag { display: inline-block; font-size: .75rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--purple-tint); color: var(--purple); }
.tag.gratis { background: var(--green-tint); color: var(--green-dark); }
.tag.ruilen { background: var(--purple-tint); color: var(--purple-soft); }
.tag.verkoop { background: var(--surface); color: var(--text); border: 1px solid var(--line); }
.tag.reserved { background: var(--warn-tint); color: var(--warn); }
.tag.gone { background: var(--line); color: var(--muted); }
@media (prefers-color-scheme: dark) {
  .tag, .tag.ruilen { color: #d6d0e2; }
  .tag.gratis { color: var(--green); }
}
.thumb .tag { position: absolute; top: 8px; left: 8px; }

/* ---------- detail ---------- */
.detail-photo { border-radius: var(--radius); overflow: hidden; background: var(--purple-tint); margin-bottom: 12px; }
.detail-photo img { width: 100%; max-height: 60vh; object-fit: contain; }
.gallery { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; margin-bottom: 4px; scrollbar-width: none; }
.gallery .detail-photo { flex: 0 0 100%; scroll-snap-align: center; margin-bottom: 0; }
.price { font-family: var(--font-head); font-weight: 800; font-size: 1.25rem; margin: 0 0 12px; display: flex; gap: 8px; align-items: center; }
dl.props { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 12px 0; }
dl.props dt { color: var(--muted); }
dl.props dd { margin: 0; font-weight: 500; }

/* ---------- lijsten en berichten ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list.card { padding: 0 16px; }
.list li { border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list a, .list .li { display: flex; gap: 12px; align-items: center; padding: 12px 0; text-decoration: none; }
.list .mini { width: 52px; height: 52px; flex: none; border-radius: 12px; overflow: hidden; background: var(--purple-tint); display: grid; place-items: center; }
.list .mini img { width: 100%; height: 100%; object-fit: cover; }
.list .mini img.ph { width: 60%; height: auto; opacity: .3; }
.list .grow { flex: 1; min-width: 0; }
.list .ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.thread { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.bubble { max-width: 80%; padding: 9px 13px; border-radius: 18px 18px 18px 6px; background: var(--surface); border: 1px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.me { align-self: flex-end; background: var(--purple); color: #fff; border-color: var(--purple); border-radius: 18px 18px 6px 18px; }
@media (prefers-color-scheme: dark) { .bubble.me { background: var(--green); color: #17132a; border-color: var(--green); } }
.bubble time { display: block; font-size: .72rem; opacity: .7; margin-top: 2px; }

.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 999px; background: var(--green); color: #1f2a12; font-size: .72rem; font-weight: 800; line-height: 18px; text-align: center; }

/* ---------- tabbalk ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: var(--tabs-h); text-decoration: none; font-size: .75rem; color: var(--muted); font-weight: 600; position: relative;
}
.tabs svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tabs a[aria-current="page"] { color: var(--purple); }
.tabs a[aria-current="page"]::before { content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 3px; border-radius: 0 0 3px 3px; background: var(--green); }
@media (prefers-color-scheme: dark) { .tabs a[aria-current="page"] { color: var(--green); } }
.tabs .plus { width: 34px; height: 30px; border-radius: 10px; background: var(--green); display: grid; place-items: center; color: #1f2a12; }
.tabs .plus svg { width: 20px; height: 20px; stroke-width: 2.8; }
.tabs .badge { position: absolute; top: 6px; left: calc(50% + 4px); }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 12px);
  max-width: 480px; margin: 0 auto; z-index: 10;
  background: var(--purple); color: #fff; padding: 12px 16px; border-radius: 12px; text-align: center; font-weight: 600; box-shadow: var(--shadow);
}
.empty { text-align: center; padding: 32px 16px; color: var(--muted); }
.empty img { width: 90px; margin: 0 auto 12px; opacity: .45; }
.code { font: 800 1.8rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .18em; color: var(--purple); }
@media (prefers-color-scheme: dark) { .code { color: var(--green); } }
.photo-row { display: flex; flex-wrap: wrap; gap: 8px; }
.photo-preview { position: relative; width: 104px; height: 104px; border-radius: 12px; overflow: hidden; background: var(--purple-tint); margin-bottom: 8px; }
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.photo-tools { position: absolute; left: 4px; right: 4px; bottom: 4px; display: flex; justify-content: space-between; align-items: center; }
.photo-tools button { min-height: 30px; min-width: 30px; padding: 0 8px; border-radius: 8px; background: rgba(23, 19, 42, .65); border-color: transparent; color: #fff; }
.photo-tools .tag { background: rgba(23, 19, 42, .65); color: #fff; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; }
.stats strong { display: block; font-family: var(--font-head); font-size: 1.6rem; color: var(--purple); }
.stats div:first-child strong { color: var(--green-dark); }
@media (prefers-color-scheme: dark) { .stats strong { color: var(--text); } .stats div:first-child strong { color: var(--green); } }
.stats span { color: var(--muted); font-size: .85rem; }
details summary { cursor: pointer; font-weight: 600; }
.auth .topbar { display: none; }
