/* ===========================================================================
   SPEELBUDDIES - opmaak
   Mobiel eerst. Alle kleuren staan bovenaan als variabelen: wil je een andere
   huisstijl, pas dan enkel dat blokje aan.
   =========================================================================== */

:root {
  --brand:        #f59f4a;
  --brand-dark:   #d97d21;
  --bg:           #fbf7f2;
  --surface:      #ffffff;
  --text:         #23201d;
  --muted:        #7c736a;
  --line:         #e8e0d6;
  --ok:           #2f8f5b;
  --ok-bg:        #e6f4ec;
  --warn:         #c2410c;
  --danger:       #c0392b;
  --radius:       14px;
  --shadow:       0 1px 3px rgba(0,0,0,.06), 0 6px 20px rgba(0,0,0,.05);
  --tabbar-h:     64px;
  --topbar-h:     52px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:      #171513;
    --surface: #211e1b;
    --text:    #f2ede7;
    --muted:   #a89e93;
    --line:    #362f2a;
    --ok-bg:   #163023;
    --shadow:  0 1px 3px rgba(0,0,0,.4);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}

h1, h2, h3 { margin: 0 0 .4em; line-height: 1.25; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: .95rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
p  { margin: 0 0 .6em; }

.muted  { color: var(--muted); }
.center { text-align: center; }
.hint   { font-size: .8rem; color: var(--muted); margin: .5em 0 0; }
small   { font-weight: 400; color: var(--muted); }

/* ── laadscherm ─────────────────────────────────────────────────────── */
.boot {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 22px; padding: 0 26px;
  background: var(--bg);
}

/* Altijd zichtbaar, zonder animatie of vertraging. Bij een normale start zie je
   dit maar een fractie van een seconde. Start de app NIET - bijvoorbeeld omdat
   de browser geen JavaScript uitvoert - dan blijft deze uitleg staan. Bewust
   geen CSS-animatie: die wordt door browsers vertraagd of uitgeschakeld, en dan
   zou net in het geval waarin je uitleg nodig hebt niets verschijnen. */
.boot-traag { max-width: 360px; text-align: center; line-height: 1.5; }
.boot-traag p { margin: 0 0 .6em; font-size: .92rem; color: var(--muted); }
.boot-traag b { color: var(--text); }
.boot-traag .klein { font-size: .82rem; }
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--brand);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── vangnet: uitleg als de app niet kan starten ────────────────────── */
.fatal {
  max-width: 480px; margin: 0 auto; padding: 34px 20px; line-height: 1.6;
}
.fatal h2 { font-size: 1.25rem; margin-bottom: .7em; }
.fatal code {
  background: var(--line); padding: 2px 6px; border-radius: 5px;
  font-family: ui-monospace, Consolas, monospace; font-size: .88em;
}
.fatal .klein { font-size: .85rem; color: var(--muted); }

/* ── inlogscherm ────────────────────────────────────────────────────── */
.auth-screen { display: grid; place-items: center; min-height: 100dvh; padding: 24px 16px; }
.auth-box { width: 100%; max-width: 420px; text-align: center; }
.logo { font-size: 3rem; line-height: 1; }
.tagline { color: var(--muted); margin-bottom: 1.4em; }

.tabs { display: flex; gap: 6px; background: var(--line); padding: 4px; border-radius: 12px; margin-bottom: 14px; }
.tab {
  flex: 1; border: 0; padding: 9px; border-radius: 9px; background: transparent;
  font: inherit; font-weight: 600; color: var(--muted); cursor: pointer;
}
.tab.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ── structuur van de app ───────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: calc(var(--topbar-h) + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  display: flex; align-items: center; gap: 4px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.topbar h1 { flex: 1; margin: 0; font-size: 1.05rem; text-align: center; }
.icon-btn {
  width: 44px; height: 44px; border: 0; background: transparent;
  font-size: 1.4rem; color: var(--text); cursor: pointer; border-radius: 10px;
}
.icon-btn:active { background: var(--line); }

main { padding: 12px 12px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 20px); }
.screen[hidden] { display: none; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex; background: var(--surface); border-top: 1px solid var(--line);
}
.tabbar button {
  flex: 1; border: 0; background: transparent; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font: inherit; font-size: .68rem; font-weight: 600; color: var(--muted);
}
.tabbar button span { font-size: 1.3rem; line-height: 1; }
.tabbar button.is-active { color: var(--brand-dark); }

/* ── kaarten & formulieren ──────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow); text-align: left;
}
.collapsible summary { font-weight: 600; cursor: pointer; list-style: none; }
.collapsible summary::-webkit-details-marker { display: none; }
.collapsible[open] summary { margin-bottom: 12px; }

label { display: block; margin-bottom: 12px; font-weight: 600; font-size: .88rem; }
.row  { display: flex; gap: 10px; }
.row > label { flex: 1; }

input, select, textarea {
  width: 100%; margin-top: 5px; padding: 11px 12px;
  font: inherit; font-weight: 400; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--brand); outline-offset: 1px; border-color: transparent;
}
textarea { resize: vertical; }

fieldset.field { border: 0; padding: 0; margin: 0 0 12px; }
legend { font-weight: 600; font-size: .88rem; padding: 0; margin-bottom: 6px; }

.cat-grid { display: grid; gap: 8px; }
.cat { margin: 0; font-weight: 400; }
.cat input { position: absolute; opacity: 0; pointer-events: none; }
.cat span {
  display: block; padding: 11px 13px; border: 2px solid var(--line);
  border-radius: 12px; background: var(--bg); cursor: pointer;
}
.cat b { display: block; font-size: .95rem; }
.cat small { display: block; font-size: .78rem; }
.cat input:checked + span { border-color: var(--brand); background: var(--surface); }
.cat input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }

.btn {
  display: block; width: 100%; padding: 13px; margin-top: 4px;
  font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid var(--line); border-radius: 11px;
  background: var(--surface); color: var(--text);
}
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #2b1a05; }
.btn-primary:active:not(:disabled) { background: var(--brand-dark); }
.btn-ghost { color: var(--danger); }
.btn-sm { width: auto; padding: 8px 14px; font-size: .85rem; margin: 0; display: inline-block; }

/* ── filterknoppen ──────────────────────────────────────────────────── */
.chips { display: flex; gap: 7px; overflow-x: auto; padding: 2px 0 12px; -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; padding: 7px 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface);
  font: inherit; font-size: .84rem; font-weight: 600; color: var(--muted); white-space: nowrap;
}
.chip.is-active { background: var(--brand); border-color: var(--brand); color: #2b1a05; }

/* ── lijst met aanbiedingen ─────────────────────────────────────────── */
.list { display: grid; gap: 10px; }

.offer {
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--brand);
  border-radius: var(--radius); padding: 12px 13px; box-shadow: var(--shadow);
}
.offer.seeking { border-left-color: var(--warn); }
.offer.is-closed { opacity: .62; border-left-color: var(--muted); }

.offer-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.offer-who  { font-weight: 700; }
.offer-cat  { font-size: .84rem; color: var(--muted); }
.offer-when { font-weight: 600; font-size: .9rem; margin: 4px 0 0; }
.offer-note { margin: 6px 0 0; font-size: .92rem; white-space: pre-wrap; }
.offer-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 9px; align-items: center; }
.offer-actions { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }

.tag {
  font-size: .72rem; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  background: var(--line); color: var(--muted); white-space: nowrap;
}
.tag.ok     { background: var(--ok-bg); color: var(--ok); }
.tag.closed { background: var(--line); color: var(--muted); }
.tag.group  { background: transparent; border: 1px solid var(--line); }

/* ── interesses ─────────────────────────────────────────────────────── */
.interests { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 9px; display: grid; gap: 7px; }
.interest { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .9rem; }
.interest-name { flex: 1; min-width: 120px; }
.interest .btn-sm { padding: 6px 11px; font-size: .8rem; }

/* ── lege toestand ──────────────────────────────────────────────────── */
.empty { text-align: center; padding: 34px 18px; color: var(--muted); }
.empty .big { font-size: 2.4rem; display: block; margin-bottom: 8px; }

/* ── melding onderaan ───────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 14px);
  z-index: 60; max-width: 90vw;
  background: #23201d; color: #fff; padding: 11px 17px; border-radius: 11px;
  font-size: .88rem; box-shadow: 0 8px 26px rgba(0,0,0,.3);
}
.toast.error { background: var(--danger); }

/* ── code om te delen ───────────────────────────────────────────────── */
.code-box {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 1.5rem; font-weight: 700; letter-spacing: .18em;
  background: var(--bg); border: 1px dashed var(--line); border-radius: 11px;
  padding: 13px; text-align: center; margin: 8px 0;
}

.member { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: .92rem; }
.member:last-child { border-bottom: 0; }
.member-name { flex: 1; }

@media (min-width: 720px) {
  main { max-width: 660px; margin: 0 auto; }
  .cat-grid { grid-template-columns: 1fr 1fr; }
}
