/* CoasterQuest design system — dark, mobile-first, accent pulled from logo.png */

:root {
  --bg: #0b0a0f;
  --bg-elev: #16141d;
  --surface: #1c1926;
  --surface-2: #241f31;
  --border: #2f2a3d;

  --text: #f5f3f8;
  --muted: #a49dba;
  --faint: #6f6885;

  --accent: #a855f7;
  --accent-strong: #8b2fe8;
  --accent-soft: rgba(168, 85, 247, 0.14);
  --xp: #22d3ee;
  --success: #4ade80;
  --warn: #fbbf24;
  --danger: #f87171;

  --radius: 14px;
  --radius-sm: 9px;
  --gap: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --nav-h: 58px;
  --tabbar-h: 62px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 12px);
}

body.no-tabbar { padding-bottom: 24px; }

a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { margin: 0 0 8px; line-height: 1.2; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 10px; }

.container {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 16px;
}

.muted { color: var(--muted); }
.faint { color: var(--faint); font-size: 0.85rem; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.stack > * + * { margin-top: var(--gap); }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------------------------------------------ navbar */

.navbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  background: rgba(11, 10, 15, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.navbar img { height: 34px; width: 34px; object-fit: contain; }

.navbar .brand {
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
  font-size: 1.05rem;
}

.navbar .level-chip {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid rgba(168, 85, 247, 0.35);
  font-size: 0.82rem;
  font-weight: 600;
  color: #e9d5ff;
}

/* --------------------------------------------------------------- tab bar */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: rgba(22, 20, 29, 0.96);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
}

.tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--faint);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.tabbar a span.icon { font-size: 1.25rem; line-height: 1; }
.tabbar a.active { color: var(--accent); }

/* ------------------------------------------------------- offline banner */

.offline-banner {
  position: sticky;
  top: var(--nav-h);
  z-index: 39;
  padding: 8px 14px;
  text-align: center;
  font-size: 0.83rem;
  font-weight: 600;
  color: #fde68a;
  background: rgba(251, 191, 36, 0.14);
  border-bottom: 1px solid rgba(251, 191, 36, 0.35);
}

/* --------------------------------------------------------- install hint */

.install-hint {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  border: 1px solid rgba(168, 85, 247, 0.35);
  font-size: 0.88rem;
}

.install-hint .grow { min-width: 0; }
.install-hint button { flex: 0 0 auto; }

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.card.tight { padding: 11px 12px; }
.card.clickable { cursor: pointer; transition: border-color 0.15s, transform 0.1s; }
.card.clickable:active { transform: scale(0.995); }
.card.clickable:hover { border-color: var(--accent); }

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 22px 0 10px;
}

.section-title h2 { margin: 0; }

/* ------------------------------------------------------------ stat tiles */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

@media (min-width: 620px) {
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
}

.stat .value {
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
}

.stat .label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-top: 3px;
}

/* ------------------------------------------------------------ level ring */

.level-ring-wrap {
  display: flex;
  align-items: center;
  gap: 18px;
}

.level-ring {
  --pct: 0;
  position: relative;
  flex: 0 0 auto;
  width: 116px;
  height: 116px;
  border-radius: 50%;
  background:
    conic-gradient(var(--accent) calc(var(--pct) * 1%), rgba(255, 255, 255, 0.07) 0);
  display: grid;
  place-items: center;
  transition: background 0.6s ease;
}

.level-ring::after {
  content: "";
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  background: var(--surface);
}

.level-ring .inner {
  position: relative;
  z-index: 1;
  text-align: center;
}

.level-ring .lvl-label {
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.level-ring .lvl-value {
  font-size: 2.1rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text);
}

/* ------------------------------------------------------------- progress */

.bar {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.bar > i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-strong), var(--accent));
  transition: width 0.5s ease;
}

.bar.xp > i { background: linear-gradient(90deg, #0891b2, var(--xp)); }
.bar.done > i { background: linear-gradient(90deg, #16a34a, var(--success)); }

/* -------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s, transform 0.08s;
}

.btn:hover { filter: brightness(1.15); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn.primary {
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
  border-color: transparent;
  color: #fff;
}

.btn.ghost { background: transparent; }
.btn.small { padding: 7px 11px; font-size: 0.85rem; }
.btn.block { width: 100%; }
.btn.danger { color: var(--danger); }

.fab-log {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 17px;
  font-size: 1.1rem;
  font-weight: 700;
  border: none;
  border-radius: var(--radius);
  color: #fff;
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
  box-shadow: 0 8px 24px rgba(168, 85, 247, 0.35);
  cursor: pointer;
}

.fab-log:active { transform: scale(0.99); }

/* --------------------------------------------------------------- inputs */

label { display: block; font-size: 0.82rem; color: var(--muted); margin-bottom: 5px; }

input, select, textarea {
  width: 100%;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  font: inherit;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field + .field { margin-top: 12px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.chip.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: #e9d5ff;
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
}

.tag.ridden { background: rgba(74, 222, 128, 0.14); border-color: rgba(74, 222, 128, 0.4); color: #bbf7d0; }
.tag.accent { background: var(--accent-soft); border-color: rgba(168, 85, 247, 0.4); color: #e9d5ff; }

/* ---------------------------------------------------------------- lists */

.list { display: flex; flex-direction: column; gap: 8px; }

.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.list-item:hover { border-color: var(--accent); }
.list-item .title { font-weight: 600; }
.list-item .sub { font-size: 0.82rem; color: var(--muted); }
.list-item .right { margin-left: auto; text-align: right; flex: 0 0 auto; }

/* --------------------------------------------------------------- modal */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(5, 4, 8, 0.72);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

@media (min-width: 620px) { .modal-backdrop { align-items: center; } }

.modal {
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 16px;
  box-shadow: var(--shadow);
  animation: slide-up 0.18s ease-out;
}

@media (min-width: 620px) { .modal { border-radius: var(--radius); } }

@keyframes slide-up {
  from { transform: translateY(16px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal .modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
}

/* -------------------------------------------------------------- toasts */

.toast-stack {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + 16px);
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(92vw, 460px);
  pointer-events: none;
}

.toast {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  animation: toast-in 0.22s ease-out;
}

.toast.xp {
  border-color: rgba(34, 211, 238, 0.45);
  background: linear-gradient(135deg, rgba(8, 145, 178, 0.28), var(--surface-2));
}

.toast.quest {
  border-color: rgba(168, 85, 247, 0.5);
  background: linear-gradient(135deg, rgba(139, 47, 232, 0.3), var(--surface-2));
}

.toast.error { border-color: rgba(248, 113, 113, 0.5); }

.toast .toast-title { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.toast .toast-sub { font-size: 0.83rem; color: var(--muted); }
.toast .xp-amount { font-size: 1.35rem; font-weight: 800; color: var(--xp); }
.toast .badge-emoji { font-size: 1.6rem; }

.toast.leaveup { animation: toast-out 0.25s ease-in forwards; }

@keyframes toast-in {
  from { transform: translateY(14px) scale(0.97); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

@keyframes toast-out {
  to { transform: translateY(-8px); opacity: 0; }
}

/* confetti-lite: pure CSS, no library */
.confetti {
  position: fixed;
  inset: 0;
  z-index: 79;
  pointer-events: none;
  overflow: hidden;
}

.confetti i {
  position: absolute;
  top: -12px;
  width: 8px;
  height: 14px;
  border-radius: 2px;
  opacity: 0.95;
  animation: confetti-fall linear forwards;
}

@keyframes confetti-fall {
  to { transform: translateY(105vh) rotate(720deg); opacity: 0; }
}

/* ------------------------------------------------------------ level-up */

.levelup-flash {
  position: fixed;
  inset: 0;
  z-index: 78;
  pointer-events: none;
  background: radial-gradient(circle at 50% 60%, var(--accent-soft), transparent 65%);
  animation: flash 1.1s ease-out forwards;
}

@keyframes flash {
  0% { opacity: 0; }
  25% { opacity: 1; }
  100% { opacity: 0; }
}

/* --------------------------------------------------------------- login */

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}

.auth-card img { display: block; width: 84px; margin: 0 auto 10px; }
.auth-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.auth-tabs .chip { flex: 1; text-align: center; }

.form-error {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.4);
  color: #fecaca;
  font-size: 0.88rem;
}

/* --------------------------------------------------------------- quests */

.quest {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.quest.completed { border-color: rgba(74, 222, 128, 0.42); background: rgba(74, 222, 128, 0.06); }
.quest.secret { border-style: dashed; }
.quest .badge-emoji { font-size: 1.8rem; line-height: 1; flex: 0 0 auto; }
.quest .quest-body { flex: 1 1 auto; min-width: 0; }
.quest .quest-title { font-weight: 600; }
.quest .quest-desc { font-size: 0.83rem; color: var(--muted); margin: 2px 0 8px; }
.quest .quest-meta { display: flex; justify-content: space-between; font-size: 0.76rem; color: var(--faint); margin-top: 5px; }

.badge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
}

.badge-tile {
  text-align: center;
  padding: 12px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.badge-tile .emoji { font-size: 2rem; line-height: 1.1; }
.badge-tile .name { font-size: 0.78rem; font-weight: 600; margin-top: 4px; }
.badge-tile .date { font-size: 0.68rem; color: var(--faint); }

/* ----------------------------------------------------------------- map */

#map {
  height: min(70vh, 560px);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--bg-elev);
}

.map-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.82rem; color: var(--muted); }
.map-legend .dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 5px; }
.dot.visited { background: var(--success); }
.dot.unvisited { background: #6b7280; }

.leaflet-popup-content-wrapper,
.leaflet-popup-tip { background: var(--surface); color: var(--text); }
.leaflet-popup-content { margin: 10px 12px; }

/* -------------------------------------------------------------- states */

.empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.skeleton {
  height: 62px;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--surface), var(--surface-2), var(--surface));
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite linear;
}

@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

.placeholder { display: grid; place-items: center; min-height: 100vh; text-align: center; }

/* ------------------------------------------------------------- ratings */

.stars { display: inline-flex; gap: 3px; font-size: 1.35rem; cursor: pointer; }
.stars .star { color: var(--faint); }
.stars .star.on { color: var(--warn); }

/* Half-star rating (Bible §7: 0,5 tot 5 sterren). Two stacked copies of the
   same glyphs; the coloured one is clipped to the score, which is what makes
   half stars possible without half-star characters. */
.star-rating {
  position: relative;
  display: inline-block;
  font-size: 1.7rem;
  line-height: 1;
  letter-spacing: 2px;
  white-space: nowrap;
  user-select: none;
}

.star-rating .track { color: rgba(255, 255, 255, 0.16); }

.star-rating .fill {
  position: absolute;
  inset: 0;
  overflow: hidden;
  color: var(--warn);
  white-space: nowrap;
  width: 0;
  transition: width 0.12s ease-out;
}

.star-rating.input { cursor: pointer; touch-action: none; }
.star-rating.input:hover .fill { filter: brightness(1.15); }
.star-rating.small { font-size: 1.15rem; }

.rating-value {
  margin-left: 10px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  vertical-align: super;
}

/* ---------------------------------------------------------------- photos */

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.photo-thumb {
  position: relative;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  aspect-ratio: 1;
  background: var(--bg-elev);
  cursor: pointer;
}

.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-thumb:hover { border-color: var(--accent); }

.photo-picker {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  cursor: pointer;
  background: var(--bg-elev);
}

.photo-picker:hover { border-color: var(--accent); color: var(--text); }
.photo-picker input[type="file"] { display: none; }

.photo-pending {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.photo-pending img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(4, 3, 7, 0.94);
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: 1fr auto;
  align-items: center;
  justify-items: center;
  gap: 8px;
  padding: 16px;
}

.lightbox img {
  grid-column: 2;
  grid-row: 1;
  max-width: 100%;
  max-height: 82vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
}

.lightbox-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text);
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
}

.lightbox-nav {
  background: none;
  border: none;
  color: var(--text);
  font-size: 2.6rem;
  line-height: 1;
  padding: 8px 12px;
  cursor: pointer;
  opacity: 0.75;
}

.lightbox-nav:hover { opacity: 1; }
.lightbox-nav.prev { grid-column: 1; grid-row: 1; }
.lightbox-nav.next { grid-column: 3; grid-row: 1; }

.lightbox-caption {
  grid-column: 1 / -1;
  grid-row: 2;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: center;
}

/* --------------------------------------------------------------- reviews */

.review {
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.review + .review { margin-top: 8px; }
.review .review-head { display: flex; align-items: center; gap: 10px; }
.review .review-author { font-weight: 600; }
.review .review-body { margin-top: 8px; white-space: pre-wrap; line-height: 1.5; }

.community-score {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.community-score .big {
  font-size: 1.9rem;
  font-weight: 800;
  line-height: 1;
}

textarea {
  min-height: 92px;
  resize: vertical;
  font-family: inherit;
}

/* Installed to the home screen: the status bar is translucent on iOS, so the
   navbar has to reserve room for it. */
@media (display-mode: standalone) {
  .navbar {
    height: calc(var(--nav-h) + env(safe-area-inset-top, 0px));
    padding-top: env(safe-area-inset-top, 0px);
  }

  .offline-banner {
    top: calc(var(--nav-h) + env(safe-area-inset-top, 0px));
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
