/* Tokens ---------------------------------------------------------------- */
:root {
  --senf: #FFC629;
  --ketchup: #D3271B;
  --ink: #2A1F17;
  --ink-soft: #6F655C;
  --surface: #FFFFFF;
  --surface-2: #F5F2EE;
  --line: #E6E0D8;
  --shadow: 0 6px 24px rgba(42, 31, 23, 0.16);
  --focus: #2F7ED8;

  --tier-S: #F5B300;
  --tier-A: #22A05A;
  --tier-B: #2F7ED8;
  --tier-C: #9A938A;
  --tier-D: #EC7A1C;
  --tier-F: #D3271B;
  --tier-none: #CFC8BF;

  --font: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --peek: 172px;
  --panel: 420px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #F4EEE7;
    --ink-soft: #ABA095;
    --surface: #1D1A17;
    --surface-2: #27231F;
    --line: #3A342E;
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
    --focus: #7DB3F5;
    --tier-none: #5A534C;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ink: #F4EEE7;
  --ink-soft: #ABA095;
  --surface: #1D1A17;
  --surface-2: #27231F;
  --line: #3A342E;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
  --focus: #7DB3F5;
  --tier-none: #5A534C;
  color-scheme: dark;
}

/* Base ------------------------------------------------------------------ */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--surface);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

#map { position: fixed; inset: 0; z-index: 0; background: var(--surface-2); }
.base-tiles { filter: grayscale(1) contrast(0.85) brightness(1.06); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .base-tiles { filter: grayscale(1) invert(1) contrast(0.8) brightness(0.85); }
}
:root[data-theme="dark"] .base-tiles { filter: grayscale(1) invert(1) contrast(0.8) brightness(0.85); }
.leaflet-container { font-family: var(--font); }
.leaflet-control-attribution { font-size: 11px; }

/* Top bar ---------------------------------------------------------------- */
.topbar {
  position: fixed; z-index: 500;
  top: calc(12px + env(safe-area-inset-top)); left: 12px; right: 12px;
  display: flex; gap: 8px; align-items: center;
}
.search {
  flex: 1; position: relative; min-width: 0;
}
.search input {
  width: 100%; height: 48px; padding: 0 16px 0 44px;
  border: 0; border-radius: 24px; background: var(--surface); box-shadow: var(--shadow);
  font-size: 16px; outline-offset: 0;
}
.search input::placeholder { color: var(--ink-soft); }
.search-icon {
  position: absolute; left: 15px; top: 50%; width: 20px; height: 20px; translate: 0 -50%;
  fill: none; stroke: var(--ink-soft); stroke-width: 2.2; stroke-linecap: round; pointer-events: none;
}
.round-btn {
  flex: none; width: 48px; height: 48px; border: 0; border-radius: 50%;
  display: grid; place-items: center; background: var(--surface); box-shadow: var(--shadow);
}
.round-btn svg { width: 22px; height: 22px; fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; }
.round-btn[aria-pressed="true"] svg { stroke: var(--focus); }
.following-btn { padding: 0; overflow: hidden; }
.following-btn .stack { display: flex; }
.following-btn img { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--surface); margin-left: -12px; object-fit: cover; }
.following-btn img:first-child { margin-left: 0; }

/* Influencer chips --------------------------------------------------------- */
.chips {
  position: fixed; z-index: 500;
  top: calc(70px + env(safe-area-inset-top)); left: 0; right: 0;
  display: flex; gap: 8px; padding: 0 12px 6px; overflow-x: auto; scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 14px 0 4px; border-radius: 19px; border: 0;
  background: var(--surface); box-shadow: var(--shadow); font-weight: 600; font-size: 15px;
}
.chip img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }
.chip[aria-pressed="false"] { opacity: 0.55; box-shadow: none; background: var(--surface-2); }
.chip[aria-pressed="false"] img { filter: grayscale(1); }
.chip-count { color: var(--ink-soft); font-weight: 500; }

/* Map pins --------------------------------------------------------------------- */
.pin-icon { background: none; border: 0; }
.pin { display: flex; flex-direction: column; align-items: center; transition: transform 0.15s ease; transform-origin: 50% 100%; }
.pin-faces { display: flex; }
.face {
  --ring: var(--tier-none);
  position: relative; display: block; width: 46px; height: 46px; border-radius: 50%;
  background: var(--surface-2); border: 4px solid var(--ring);
  box-shadow: 0 0 0 2px var(--surface), 0 3px 10px rgba(0, 0, 0, 0.28);
  overflow: hidden; flex: none;
}
.pin-faces .face + .face { margin-left: -16px; }
.face img { width: 100%; height: 100%; object-fit: cover; display: block; }
.face .initials { display: grid; place-items: center; width: 100%; height: 100%; font-weight: 800; font-size: 15px; }
/* initials stand in for a missing picture (plan 1.5): same circle, no broken image */
.initials { display: grid; place-items: center; aspect-ratio: 1; border-radius: 50%; background: var(--senf); color: #2A1F17; font-weight: 800; }
.chip .initials { width: 30px; height: 30px; font-size: 12px; }
.chip[aria-pressed="false"] .initials { opacity: 0.4; }
.following-btn .initials { width: 30px; height: 30px; font-size: 12px; border: 2px solid var(--surface); margin-left: -12px; }
.following-btn .initials:first-child { margin-left: 0; }
.ob-card .initials { width: 96px; height: 96px; font-size: 30px; border: 4px solid #fff; }
.spot-faces .initials { width: 40px; height: 40px; font-size: 14px; }

.face[data-tier="S"] {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 5px var(--tier-S), 0 3px 12px rgba(245, 179, 0, 0.55);
}
.pin-tag {
  margin-top: -9px; position: relative; z-index: 1;
  min-width: 24px; height: 20px; padding: 0 6px; border-radius: 6px;
  display: grid; place-items: center;
  font-stretch: 75%; font-weight: 900; font-size: 14px; line-height: 1;
  border: 2px solid var(--surface);
}
.pin.is-selected { transform: scale(1.18); }
.pin.is-group .face { --ring: var(--ink); }
.pin.is-group .pin-faces .face + .face { margin-left: -22px; }
.pin-count {
  margin-top: -9px; position: relative; z-index: 1; height: 22px; padding: 0 8px; border-radius: 11px;
  display: grid; place-items: center; white-space: nowrap;
  background: var(--ink); color: var(--surface); border: 2px solid var(--surface);
  font-weight: 800; font-size: 13px; line-height: 1;
}

/* Tier colours (badges, rings, tags) */
[data-tier="S"] { --ring: var(--tier-S); }
[data-tier="A"] { --ring: var(--tier-A); }
[data-tier="B"] { --ring: var(--tier-B); }
[data-tier="C"] { --ring: var(--tier-C); }
[data-tier="D"] { --ring: var(--tier-D); }
[data-tier="F"] { --ring: var(--tier-F); }
.pin-tag, .tier-badge { background: var(--ring, var(--tier-none)); color: #fff; }
.pin-tag[data-tier="S"], .tier-badge[data-tier="S"], .pin-tag[data-tier="C"], .tier-badge[data-tier="C"] { color: #2A1F17; }

.tier-badge {
  flex: none; display: inline-grid; place-items: center;
  width: 30px; height: 30px; border-radius: 8px;
  font-stretch: 75%; font-weight: 900; font-size: 18px; line-height: 1;
}
.tier-badge.is-empty { background: var(--surface-2); color: var(--ink-soft); }
.tier-badge.lg { width: 44px; height: 44px; font-size: 28px; border-radius: 10px; }

.user-dot {
  width: 18px; height: 18px; border-radius: 50%; background: var(--focus);
  border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(47, 126, 216, 0.25);
}

/* Bottom sheet / side panel --------------------------------------------------- */
.sheet {
  position: fixed; z-index: 600; left: 0; right: 0; bottom: 0;
  height: min(64dvh, 640px);
  display: flex; flex-direction: column;
  background: var(--surface); border-radius: 20px 20px 0 0; box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.18);
  transform: translateY(calc(100% - var(--peek)));
  transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.sheet[data-state="open"] { transform: translateY(0); }
.sheet-handle {
  flex: none; height: 26px; border: 0; background: none; display: grid; place-items: center; touch-action: none;
}
.sheet-handle span { width: 44px; height: 5px; border-radius: 3px; background: var(--line); }
.sheet-body {
  flex: 1; overflow-y: auto; overscroll-behavior: contain;
  padding: 0 16px calc(24px + env(safe-area-inset-bottom));
}
.sheet[data-state="peek"] .sheet-body { overflow: hidden; }

@media (min-width: 900px) {
  #map { left: var(--panel); }
  .sheet {
    top: 0; right: auto; width: var(--panel); height: auto;
    border-radius: 0; transform: none; box-shadow: 4px 0 24px rgba(0, 0, 0, 0.1);
    border-right: 1px solid var(--line);
  }
  .sheet-handle { display: none; }
  .sheet-body { padding-top: 20px; }
  .sheet[data-state="peek"] .sheet-body { overflow-y: auto; }
  .topbar { left: calc(var(--panel) + 16px); right: 16px; max-width: 560px; }
  .chips { left: var(--panel); padding-left: 16px; }
}

/* List view -------------------------------------------------------------------- */
.list-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 2px 0 10px; }
.list-head h2, .place-name {
  margin: 0; font-stretch: 75%; font-weight: 800; letter-spacing: -0.01em; line-height: 1.05;
}
.list-head h2 { font-size: 30px; }
.list-sub { margin: 0; color: var(--ink-soft); font-size: 14px; text-align: right; }

.spot-list { list-style: none; margin: 0; padding: 0; }
.spot {
  width: 100%; display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center;
  padding: 12px 0; border: 0; border-top: 1px solid var(--line); background: none; text-align: left;
}
.spot-list li:first-child .spot { border-top: 0; }
.spot-faces { display: flex; }
.spot-faces .face { width: 40px; height: 40px; border-width: 3px; box-shadow: 0 0 0 2px var(--surface); }
.spot-faces .face + .face { margin-left: -14px; }
.spot-name { display: block; font-weight: 700; font-size: 17px; line-height: 1.2; }
.spot-meta { display: block; color: var(--ink-soft); font-size: 14px; }
.spot-tip { display: block; font-size: 14px; margin-top: 2px; }

.legend {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px 10px;
  margin: 18px 0 8px; padding: 12px; border-radius: 12px; background: var(--surface-2); font-size: 13px;
}
.legend div { display: flex; align-items: center; gap: 8px; }
.legend .tier-badge { width: 22px; height: 22px; font-size: 14px; border-radius: 6px; }

.pending { margin-top: 14px; font-size: 14px; color: var(--ink-soft); }
.pending summary { cursor: pointer; font-weight: 600; color: var(--ink); padding: 6px 0; }
.pending ul { margin: 6px 0 0; padding-left: 18px; }
.pending li { margin-bottom: 6px; }

.empty { padding: 16px 0; color: var(--ink-soft); }
.info-open { margin: 18px 0 4px; }
.info-view { font-size: 15px; color: var(--ink); }
.info-view p { margin: 10px 0; }
.info-view h3 { margin: 16px 0 4px; font-size: 15px; }
.info-view ul { margin: 0; padding-left: 18px; color: var(--ink-soft); }
.info-view a { color: var(--ink); }
.info-links { font-size: 14px; color: var(--ink-soft); }

/* Detail view ------------------------------------------------------------------- */
.back {
  display: inline-flex; align-items: center; gap: 6px; margin: 0 0 10px -4px; padding: 6px 8px;
  border: 0; border-radius: 8px; background: none; font-weight: 600; color: var(--ink-soft);
}
.back svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.place-name { font-size: clamp(32px, 9vw, 40px); }
.place-addr { margin: 8px 0 0; color: var(--ink-soft); font-size: 15px; }
.place-note { margin: 10px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); font-size: 14px; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 6px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border-radius: 23px; border: 2px solid var(--ink);
  background: none; font-weight: 700; text-decoration: none; font-size: 15px;
}
.btn-senf { background: var(--senf); border-color: var(--senf); color: #2A1F17; }
.btn-ink { background: #2A1F17; border-color: #2A1F17; color: #fff; }
.btn[disabled] { opacity: 0.4; cursor: not-allowed; }

.review { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.review-head { display: flex; align-items: center; gap: 12px; }
.review-head .face { width: 52px; height: 52px; }
.review-who { flex: 1; min-width: 0; }
.review-who strong { font-size: 18px; }
.review-with { color: var(--ink-soft); }
.review-date { display: block; font-size: 14px; color: var(--ink-soft); }
.verdict { margin: 12px 0 0; font-size: 18px; font-weight: 600; line-height: 1.3; }

/* The menu board: dishes as the place's own menu, best first */
.menu-title { margin: 20px 0 6px; font-size: 15px; font-weight: 700; color: var(--ink-soft); }
.menu { list-style: none; margin: 0; padding: 0; border-radius: 14px; background: var(--surface-2); }
.dish { display: flex; gap: 12px; padding: 14px 14px; border-top: 1px solid var(--line); }
.dish:first-child { border-top: 0; }
.dish-body { flex: 1; min-width: 0; }
.dish-line { display: flex; align-items: baseline; gap: 8px; }
.dish-name { font-stretch: 85%; font-weight: 750; font-size: 18px; line-height: 1.2; }
.dish-dots { flex: 1; border-bottom: 2px dotted var(--line); translate: 0 -4px; min-width: 12px; }
.dish-price { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.dish-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.tag { font-size: 12.5px; font-weight: 700; padding: 2px 8px; border-radius: 6px; background: var(--surface); }
.tag-must { background: var(--senf); color: #2A1F17; }
.dish-note { margin: 4px 0 0; font-size: 15px; }

.flags { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; font-size: 14px; }
.flags li { display: flex; gap: 8px; align-items: baseline; color: var(--ink-soft); }
.flags li::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--tier-D); translate: 0 -1px; }
.flags li.info::before { background: var(--tier-B); }

/* Toast ---------------------------------------------------------------------------- */
.toast {
  position: fixed; z-index: 900; left: 50%; top: calc(124px + env(safe-area-inset-top)); translate: -50% 0;
  max-width: min(92vw, 420px); padding: 12px 16px; border-radius: 12px;
  background: #2A1F17; color: #fff; font-size: 15px; box-shadow: var(--shadow);
}
@media (min-width: 900px) { .toast { left: calc(50% + var(--panel) / 2); } }

/* Onboarding: the Imbiss light box ------------------------------------------------- */
.onboarding {
  position: fixed; inset: 0; z-index: 1000; overflow-y: auto;
  background: var(--senf); color: #2A1F17;
}
.ob-inner {
  max-width: 560px; margin: 0 auto; min-height: 100%;
  padding: calc(48px + env(safe-area-inset-top)) 20px calc(32px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column;
}
.onboarding h1 {
  margin: 0; font-stretch: 62%; font-weight: 900; font-size: clamp(64px, 20vw, 112px);
  line-height: 0.88; letter-spacing: -0.02em;
}
.ob-lead { margin: 18px 0 28px; font-size: 18px; max-width: 34ch; }
.ob-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.ob-card {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 20px 12px 16px; border-radius: 18px; border: 3px solid transparent;
  background: rgba(255, 255, 255, 0.55); color: #2A1F17; text-align: center;
}
.ob-card img { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; border: 4px solid #fff; }
.ob-card strong { font-stretch: 75%; font-weight: 800; font-size: 26px; line-height: 1; }
.ob-card span { font-size: 14px; }
.ob-card[aria-pressed="true"] { background: #fff; border-color: #2A1F17; }
.ob-card[aria-pressed="true"]::after {
  content: ""; position: absolute; top: 12px; right: 12px; width: 26px; height: 26px; border-radius: 50%;
  background: #2A1F17 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12 5 5 9-10'/%3E%3C/svg%3E") center / 16px no-repeat;
}
.ob-more { margin: 18px 0 0; font-size: 14px; opacity: 0.8; }
.ob-go { margin-top: auto; align-self: stretch; min-height: 56px; font-size: 17px; border-radius: 28px; }
.ob-grid + .ob-more { margin-bottom: 28px; }

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