/* Wer kann's brauchen – a neighbourhood flea market.
   One loud element: the yellow price tag stuck onto each photo. Everything else stays calm. */

@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("fonts/atkinson-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("fonts/atkinson-700.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "Bricolage Grotesque";
  src: url("fonts/bricolage.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}

:root {
  --bg: #eef2ec;
  --surface: #ffffff;
  --sunken: #e2e8e0;
  --ink: #1c2b24;
  --muted: #4f5d55;
  --line: #ccd6cb;
  --primary: #245c4a;
  --on-primary: #ffffff;
  --tag: #f5c84c;
  --tag-ink: #33260a;
  --gift: #d9452f;
  --gift-ink: #ffffff;
  --held-bg: #fbe5c8;
  --held-ink: #7a3d07;
  --danger: #b3261e;
  --focus: #1f6feb;
  --shadow: 0 1px 2px rgb(28 43 36 / 0.08), 0 4px 14px rgb(28 43 36 / 0.06);

  --font-body: "Atkinson Hyperlegible", system-ui, sans-serif;
  --font-display: "Bricolage Grotesque", "Atkinson Hyperlegible", system-ui, sans-serif;
  --radius-sm: 10px;
  --radius: 18px;
  --nav-height: 72px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111915;
    --surface: #1a2520;
    --sunken: #0c120f;
    --ink: #e6eee8;
    --muted: #a3b3a9;
    --line: #2e3d35;
    --primary: #84d3b2;
    --on-primary: #0d261c;
    --tag: #f5c84c;
    --tag-ink: #33260a;
    --gift: #ff7d66;
    --gift-ink: #2b0a04;
    --held-bg: #3d2a14;
    --held-ink: #ffcf96;
    --danger: #ff8a80;
    --focus: #8ab4ff;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4);
    color-scheme: dark;
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 400 1.125rem/1.5 var(--font-body);
}

img {
  display: block;
  max-width: 100%;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  line-height: 1.1;
  margin: 0;
  text-wrap: balance;
}

p {
  margin: 0;
}

a {
  color: var(--primary);
  text-underline-offset: 3px;
}

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

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- Buttons and fields ---------- */

button,
.button {
  font: 700 1rem/1.2 var(--font-body);
  min-height: 48px;
  padding: 0 18px;
  border-radius: 999px;
  border: 2px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  touch-action: manipulation;
}

button:disabled {
  opacity: 0.55;
  cursor: progress;
}

.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}

.danger {
  color: var(--danger);
  border-color: currentColor;
  background: transparent;
}

.danger.armed {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--surface);
}

.quiet {
  border-color: transparent;
  background: transparent;
  color: var(--primary);
  padding: 0 8px;
}

.wide {
  width: 100%;
}

.field {
  display: grid;
  gap: 6px;
}

.field > span {
  font-weight: 700;
}

.field small,
.hint {
  color: var(--muted);
  font-size: 0.95rem;
}

input,
textarea,
select {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  width: 100%;
  min-height: 52px;
}

input:focus,
textarea:focus {
  border-color: var(--primary);
}

textarea {
  resize: vertical;
  min-height: 110px;
}

.check {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 1rem;
}

.check input {
  width: 22px;
  height: 22px;
  min-height: 0;
  accent-color: var(--primary);
}

.error {
  color: var(--danger);
  font-weight: 700;
  min-height: 1.5em;
}

.error:empty {
  min-height: 0;
}

form {
  display: grid;
  gap: 18px;
}

/* Two big choices that look like buttons: "Verkaufen" / "Verschenken". */
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  border: 0;
  padding: 0;
  margin: 0;
}

.segmented legend {
  font-weight: 700;
  margin-bottom: 6px;
}

.segmented label {
  position: relative;
}

.segmented input {
  position: absolute;
  opacity: 0;
}

.segmented span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  font-weight: 700;
  background: var(--surface);
  cursor: pointer;
}

.segmented input:checked + span {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--on-primary);
}

.segmented input:focus-visible + span {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* ---------- Start screens (login, register) ---------- */

.gate {
  min-height: 100dvh;
  display: grid;
  align-content: center;
  padding: 32px 16px 24px;
}

.gate-inner {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  display: grid;
  gap: 28px;
}

.gate .wordmark {
  font-size: clamp(2.6rem, 11vw, 3.4rem);
}

.gate-intro {
  color: var(--muted);
  max-width: 34ch;
}

.gate footer {
  display: flex;
  gap: 16px;
  font-size: 0.95rem;
}

/* The wordmark leans on a small price tag, the same object as on every photo. */
.wordmark {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.7rem, 6.5vw, 2.2rem);
  letter-spacing: -0.02em;
  line-height: 0.95;
}

.wordmark .tag {
  position: relative;
  vertical-align: 0.25em;
  margin-left: 0.15em;
  font-size: 0.32em;
  inset: auto;
}

/* ---------- App shell ---------- */

.shell {
  max-width: 1080px;
  margin: 0 auto;
  padding: 20px 16px calc(var(--nav-height) + 96px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.avatar {
  flex: none;
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 50%;
  font-family: var(--font-display);
  font-size: 1.2rem;
  background: var(--sunken);
  border-color: var(--sunken);
}

.search {
  position: relative;
  margin-bottom: 20px;
}

.search svg {
  position: absolute;
  left: 14px;
  top: 50%;
  translate: 0 -50%;
  color: var(--muted);
  pointer-events: none;
}

.search input {
  padding-left: 46px;
  border-radius: 999px;
}

.section-title {
  font-size: 1.5rem;
  margin: 4px 0 14px;
}

.empty {
  padding: 32px 20px;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  display: grid;
  gap: 14px;
  justify-items: start;
}

.empty strong {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.3rem;
}

/* ---------- Offer cards ---------- */

.grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr));
  margin: 0;
  padding: 0;
  list-style: none;
}

.card {
  display: block;
  width: 100%;
  padding: 0;
  min-height: 0;
  border: 0;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: left;
  font-weight: 400;
  overflow: hidden;
  position: relative;
}

.card .photo {
  aspect-ratio: 4 / 3;
  width: 100%;
  object-fit: cover;
  background: var(--sunken);
}

.card .body {
  padding: 14px 16px 16px;
  display: grid;
  gap: 4px;
}

.card .title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 650;
  line-height: 1.15;
}

.card .meta {
  color: var(--muted);
  font-size: 1rem;
}

.card.is-gone .photo {
  filter: grayscale(1) opacity(0.6);
}

.no-photo {
  display: grid;
  place-items: center;
  color: var(--muted);
}

.status {
  justify-self: start;
  margin-top: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 700;
  background: var(--held-bg);
  color: var(--held-ink);
}

.status.gone {
  background: var(--sunken);
  color: var(--muted);
}

.new-flag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--primary);
  font-weight: 700;
  font-size: 0.95rem;
}

.new-flag::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: currentColor;
}

/* The price tag: a slightly crooked paper tag with a punched hole. */
.tag {
  position: absolute;
  top: 14px;
  left: 12px;
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.35em 0.8em 0.35em 0.6em;
  border-radius: 0.35em 0.6em 0.6em 0.35em;
  background: var(--tag);
  color: var(--tag-ink);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.3rem;
  line-height: 1;
  rotate: -5deg;
  box-shadow: 0 2px 0 rgb(0 0 0 / 0.12), 0 6px 14px rgb(0 0 0 / 0.18);
  font-variant-numeric: tabular-nums;
}

.tag::before {
  content: "";
  width: 0.38em;
  height: 0.38em;
  border-radius: 50%;
  background: var(--bg);
  box-shadow: inset 0 1px 1px rgb(0 0 0 / 0.25);
}

.tag.gift {
  background: var(--gift);
  color: var(--gift-ink);
  rotate: 4deg;
}

.card:nth-child(3n + 2) .tag:not(.gift) {
  rotate: -2deg;
}

.card:nth-child(3n) .tag:not(.gift) {
  rotate: -7deg;
}

.card.is-gone .tag {
  filter: grayscale(1);
}

/* ---------- Wanted ads ---------- */

.wants {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.want {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  display: grid;
  gap: 6px;
  box-shadow: var(--shadow);
  border-left: 6px solid var(--tag);
}

.want.found {
  border-left-color: var(--line);
  color: var(--muted);
}

.want h3 {
  font-size: 1.2rem;
}

.want .row {
  margin-top: 6px;
}

.panel {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

/* ---------- Bottom navigation and the "offer something" button ---------- */

.tabs {
  position: fixed;
  inset: auto 0 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  height: calc(var(--nav-height) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.tabs button {
  border: 0;
  border-radius: 0;
  background: transparent;
  height: 100%;
  min-height: 0;
  flex-direction: column;
  gap: 4px;
  font-size: 0.9rem;
  color: var(--muted);
  padding: 0 4px;
}

.tabs button[aria-current="page"] {
  color: var(--primary);
}

.tabs button[aria-current="page"] svg {
  background: color-mix(in srgb, var(--primary) 16%, transparent);
}

.tabs svg {
  width: 56px;
  height: 30px;
  padding: 3px 16px;
  border-radius: 999px;
}

.tabs .count {
  font-variant-numeric: tabular-nums;
}

.offer-button {
  position: fixed;
  z-index: 11;
  right: max(16px, calc((100vw - 1080px) / 2 + 16px));
  bottom: calc(var(--nav-height) + 16px + env(safe-area-inset-bottom));
  min-height: 60px;
  padding: 0 24px 0 18px;
  font-size: 1.1rem;
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.25);
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

/* ---------- Dialogs (bottom sheets on phones) ---------- */

dialog {
  width: min(100%, 620px);
  max-width: 100%;
  max-height: 94dvh;
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: 24px 24px 0 0;
  background: var(--bg);
  color: var(--ink);
  overscroll-behavior: contain;
}

dialog::backdrop {
  background: rgb(10 18 14 / 0.6);
}

dialog[open] {
  animation: sheet-in 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes sheet-in {
  from {
    translate: 0 40px;
    opacity: 0;
  }
}

@media (min-width: 700px) {
  dialog {
    margin: auto;
    border-radius: 24px;
  }
}

.sheet-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 10px 20px;
  background: var(--bg);
}

.sheet-head h2 {
  font-size: 1.35rem;
}

.close {
  width: 48px;
  padding: 0;
  flex: none;
}

.sheet-body {
  padding: 4px 20px calc(24px + env(safe-area-inset-bottom));
  display: grid;
  gap: 20px;
}

/* Item detail */
.detail-photo {
  position: relative;
  margin: 0 -20px;
}

.detail-photo img {
  width: 100%;
  max-height: 60dvh;
  object-fit: contain;
  background: var(--sunken);
}

.detail-photo .tag {
  font-size: 1.6rem;
  top: 16px;
  left: 16px;
}

.inline-tag {
  padding: 6px 0 0 4px;
}

.inline-tag .tag {
  position: relative;
  inset: auto;
  font-size: 1.6rem;
}

.detail-title {
  display: grid;
  gap: 6px;
}

.detail-title h3 {
  font-size: 1.7rem;
}

.description {
  white-space: pre-line;
}

.contact {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.owner-tools {
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.comments {
  display: grid;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.comments h4 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.2rem;
}

.comment {
  background: var(--surface);
  border-radius: 4px var(--radius) var(--radius) var(--radius);
  padding: 10px 14px;
  display: grid;
  gap: 2px;
}

.comment.by-owner {
  background: color-mix(in srgb, var(--primary) 14%, var(--surface));
}

.comment header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.95rem;
  color: var(--muted);
}

.comment header strong {
  color: var(--ink);
}

.comment p {
  white-space: pre-line;
}

.comment .quiet {
  min-height: 36px;
  font-size: 0.95rem;
}

/* Photo picker in the form */
.photo-pick {
  display: grid;
  gap: 10px;
}

.photo-pick img {
  border-radius: var(--radius-sm);
  aspect-ratio: 4 / 3;
  object-fit: cover;
  width: 100%;
}

/* Account and admin lists */
.list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.list li {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: grid;
  gap: 8px;
}

.list .row {
  justify-content: space-between;
}

.link-box {
  display: grid;
  gap: 10px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
}

.link-box code {
  font-size: 0.95rem;
  word-break: break-all;
  color: var(--muted);
}

.menu {
  display: grid;
  gap: 10px;
}

.menu button,
.menu .button {
  justify-content: flex-start;
  border-radius: var(--radius-sm);
}

.faq details {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}

.faq details + details {
  margin-top: 8px;
}

.faq summary {
  font-weight: 700;
  cursor: pointer;
}

.faq details p {
  margin-top: 8px;
  color: var(--muted);
}

.legal {
  display: grid;
  gap: 14px;
}

.legal h3 {
  font-size: 1.15rem;
  margin-top: 6px;
}

.footer-links {
  display: flex;
  gap: 18px;
  justify-content: center;
  margin-top: 40px;
  font-size: 0.95rem;
}

.footer-links button {
  min-height: 44px;
}

/* Short confirmation at the bottom of the screen */
.toast {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: calc(var(--nav-height) + 24px + env(safe-area-inset-bottom));
  translate: -50% 0;
  max-width: calc(100% - 32px);
  padding: 12px 20px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-weight: 700;
  box-shadow: var(--shadow);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
