/* ============================================================
   Die Kunstwand — playful infinite art board
   ============================================================ */

:root {
  --paper: #e3d3b8;
  --ink: #2a2420;
  --accent: #ff5e5b;
  --accent-2: #ffb703;
  --tag-bg: #fffdf6;
  --shadow: 0 12px 26px -8px rgba(50, 34, 16, 0.4), 0 2px 6px -2px rgba(50, 34, 16, 0.3);
  --dot: rgba(86, 64, 40, 0.12);
}

* { box-sizing: border-box; }

/* Screen-reader / keyboard only, visually removed */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%);
  white-space: nowrap;
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* ---- Stage: captures all gestures -------------------------- */
#stage {
  position: fixed;
  inset: 0;
  touch-action: none;       /* we own pan + pinch */
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
#stage.grabbing { cursor: grabbing; }

/* Parallax dotted grid (Miro feel). Panned/zoomed via JS.
   No permanent will-change: a large promoted layer pinned for the whole
   session costs idle memory on mobile; the inset is shrunk in JS to keep the
   painted surface small. */
#grid {
  position: absolute;
  inset: -50vmax;           /* overscan so edges never show (shrunk in JS) */
  background-image: radial-gradient(var(--dot) 2px, transparent 2px);
  background-size: 40px 40px;
  pointer-events: none;
}

/* The world holds the (culled) artwork nodes, transformed as one. */
#world {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  will-change: transform;
}

/* ---- Artwork card ------------------------------------------ */
.card {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 50% 50%;
  border-radius: 10px;
  background: #fff;
  padding: 10px 10px 14px;  /* white mat, polaroid-ish */
  box-shadow: var(--shadow);
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}
.card::after {
  /* pin */
  content: "";
  position: absolute;
  top: -6px;
  left: 50%;
  width: 14px;
  height: 14px;
  margin-left: -7px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ff9a9a, var(--accent) 70%);
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.3);
}
.card .frame {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 4px;
  overflow: hidden;
  background-size: cover;
  background-position: center;
}
.card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.45s ease;
  -webkit-user-drag: none;
  user-select: none;
  pointer-events: none; /* clicks/drags pass through to the card/stage */
}
.card img.loaded { opacity: 1; }

/* Floating name tag at the corner */
.card .tag {
  position: absolute;
  left: -8px;
  bottom: -12px;
  max-width: 80%;
  padding: 5px 11px;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--ink);
  background: var(--tag-bg);
  border-radius: 999px;
  box-shadow: 0 4px 10px -3px rgba(0, 0, 0, 0.35);
  transform: rotate(-5deg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card .tag::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--accent-2);
  vertical-align: middle;
}
.card .like-badge {
  position: absolute;
  right: 4px;
  top: 4px;
  display: none;            /* shown only when liked */
  align-items: center;
  gap: 3px;
  padding: 3px 8px;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  border-radius: 999px;
  box-shadow: 0 3px 8px -2px rgba(0, 0, 0, 0.4);
}
.card.liked .like-badge { display: inline-flex; }

/* ---- Floating chrome --------------------------------------- */
#topbar {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
  z-index: 10;
}
#topbar .brand {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  font-weight: 800;
  font-size: 16px;
  background: rgba(255, 253, 246, 0.86);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-radius: 999px;
  box-shadow: var(--shadow);
}
.topbar-actions {
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
#newsletter-btn,
#info-btn,
#clock-btn {
  pointer-events: auto;
  width: 42px;
  height: 42px;
  line-height: 1;
  color: var(--ink);
  background: rgba(255, 253, 246, 0.86);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: none;
  border-radius: 50%;
  box-shadow: var(--shadow);
  cursor: pointer;
}
#info-btn {
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  font-weight: 700;
  font-size: 21px;
}
#clock-btn { font-size: 19px; }
#newsletter-btn { display: grid; place-items: center; }
#newsletter-btn svg { display: block; }
#newsletter-btn:active,
#info-btn:active,
#clock-btn:active { transform: scale(0.94); }

/* Search by image number */
.search-wrap {
  pointer-events: none;
  flex: 1 1 auto;
  min-width: 0;
  max-width: 240px;
}
#search {
  pointer-events: auto;
  width: 100%;
  height: 40px;
  padding: 0 16px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  background: rgba(255, 253, 246, 0.86);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: none;
  border-radius: 999px;
  box-shadow: var(--shadow);
  outline: none;
}
#search::placeholder { color: #a3937f; font-weight: 500; }
#search:focus { box-shadow: var(--shadow), 0 0 0 2px var(--accent-2); }
#search.notfound { box-shadow: var(--shadow), 0 0 0 2px var(--accent); }
/* On narrow screens, drop the brand wordmark so the search has room. */
@media (max-width: 560px) {
  #topbar .brand span { display: none; }
  #topbar .brand { gap: 0; }
}

#hint {
  position: fixed;
  left: 50%;
  top: calc(max(12px, env(safe-area-inset-top)) + 58px);
  transform: translateX(-50%);
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: rgba(42, 36, 32, 0.82);
  border-radius: 999px;
  z-index: 10;
  pointer-events: none;
  transition: opacity 0.6s ease;
}
#hint.fade { opacity: 0; }

/* Transient toast (vote feedback / limit reached) */
#toast {
  position: fixed;
  left: 50%;
  bottom: max(96px, calc(env(safe-area-inset-bottom) + 96px));
  transform: translate(-50%, 12px);
  z-index: 60; /* above the lightbox/results/info overlays — voting happens inside them */
  max-width: 86vw;
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  color: #fff;
  background: rgba(42, 36, 32, 0.94);
  border-radius: 999px;
  box-shadow: 0 14px 30px -10px rgba(0, 0, 0, 0.55);
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
  white-space: nowrap;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast[hidden] { display: none; }

/* ---- Sponsor badge (discreet) ------------------------------ */
#sponsor {
  position: fixed;
  left: 12px;
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 10;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 13px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
  line-height: 1.2;
  color: #6b5d4f;
  cursor: pointer;
  border: none;
  white-space: nowrap;
  background: rgba(255, 253, 246, 0.78);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-radius: 999px;
  box-shadow: 0 4px 12px -6px rgba(60, 40, 20, 0.3);
  transition: color 0.2s ease, background 0.2s ease;
}
#sponsor strong { font-weight: 800; color: var(--ink); }
#sponsor .sp-heart { color: var(--accent); }
#sponsor:hover { color: var(--ink); background: rgba(255, 253, 246, 0.95); }
@media (max-width: 480px) {
  #sponsor { font-size: 11.5px; padding: 5px 11px; }
}

/* ---- Minimap (bottom-right) -------------------------------- */
#minimap {
  position: fixed;
  right: 12px;
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 10;
  padding: 4px;
  background: rgba(255, 253, 246, 0.82);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-radius: 12px;
  box-shadow: var(--shadow);
  cursor: pointer;
  touch-action: none;
}
#minimap canvas {
  display: block;
  border-radius: 8px;
}

/* ---- Search results grid (multiple name matches) ----------- */
#results {
  position: fixed;
  inset: 0;
  z-index: 42;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(22, 16, 12, 0.78);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.22s ease;
}
#results.open { opacity: 1; }
#results[hidden] { display: none; }
.results-card {
  width: min(94vw, 640px);
  max-height: 84vh;
  display: flex;
  flex-direction: column;
  background: var(--tag-bg);
  border-radius: 18px;
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.6);
  transform: scale(0.97);
  transition: transform 0.22s ease;
  overflow: hidden;
}
#results.open .results-card { transform: scale(1); }
.results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 16px 12px;
  font-weight: 800;
  font-size: 16px;
}
#results-close {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  font-size: 16px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.06);
  cursor: pointer;
}
#results-grid {
  overflow-y: auto;
  padding: 4px 16px 18px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
}
.result {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  text-align: center;
}
.result img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 10px;
  background: #d9cdb8;
  box-shadow: var(--shadow);
}
.result span {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
}
.result:active { transform: scale(0.97); }

/* ---- Lightbox ---------------------------------------------- */
#lightbox {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px;
  background: rgba(22, 16, 12, 0.86);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.22s ease;
}
/* CRITICAL: #lightbox's `display:flex` overrides the [hidden] UA rule, so the
   attribute alone would leave an invisible full-screen overlay swallowing every
   pointer/wheel event. This makes `hidden` actually hide it. */
#lightbox[hidden] {
  display: none;
}
#lightbox.open { opacity: 1; }
#lb-figure {
  margin: 0;
  max-width: min(92vw, 720px);
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #fff;
  padding: 12px 12px 16px;
  border-radius: 14px;
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.6);
  transform: scale(0.96);
  transition: transform 0.22s ease;
}
#lightbox.open #lb-figure { transform: scale(1); }
#lb-img {
  display: block;
  max-width: 100%;
  max-height: calc(70vh - 60px);
  object-fit: contain;
  border-radius: 6px;
  background: #f0e6d6;
}
#lb-name {
  margin-top: 12px;
  font-size: 19px;
  font-weight: 800;
}
#lb-close {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  right: 16px;
  width: 44px;
  height: 44px;
  font-size: 20px;
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
  border: none;
  border-radius: 50%;
  cursor: pointer;
}

.like-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 13px 26px;
  font-size: 19px;
  font-weight: 800;
  color: var(--ink);
  background: #fff;
  border: none;
  border-radius: 999px;
  box-shadow: 0 12px 24px -10px rgba(0, 0, 0, 0.6);
  cursor: pointer;
  transition: transform 0.12s ease, background 0.2s ease, color 0.2s ease;
}
.like-btn .heart { font-size: 22px; color: var(--accent); line-height: 1; }
.like-btn:active { transform: scale(0.95); }
.like-btn.liked { background: var(--accent); color: #fff; cursor: default; }
.like-btn.liked .heart { color: #fff; }
.like-btn.pulse { animation: pop 0.35s ease; }
@keyframes pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

/* Prev/next arrows flanking the like button (compact cluster, thumb-friendly) */
#lb-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}
.lb-nav {
  width: 52px;
  height: 52px;
  font-size: 30px;
  line-height: 1;
  color: var(--ink);
  background: #fff;
  border: none;
  border-radius: 50%;
  box-shadow: 0 12px 24px -10px rgba(0, 0, 0, 0.6);
  cursor: pointer;
  display: grid;
  place-items: center;
  padding-bottom: 4px; /* optically centre the chevron */
  transition: transform 0.12s ease;
}
.lb-nav:active { transform: scale(0.9); }

/* ---- Info popup (Aktion / Sponsor) ------------------------- */
#infobox {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(22, 16, 12, 0.7);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.22s ease;
}
#infobox.open { opacity: 1; }
/* CRITICAL: make `hidden` actually hide it (the display:flex above would
   otherwise leave an invisible full-screen overlay swallowing every event). */
#infobox[hidden] { display: none; }
.infobox-card {
  position: relative;
  max-width: min(92vw, 440px);
  max-height: 86vh;
  overflow-y: auto;
  background: var(--tag-bg);
  color: var(--ink);
  border-radius: 20px;
  padding: 30px 26px 26px;
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.6);
  transform: scale(0.96);
  transition: transform 0.22s ease;
}
#infobox.open .infobox-card { transform: scale(1); }
#infobox-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  font-size: 16px;
  line-height: 1;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.06);
  border: none;
  border-radius: 50%;
  cursor: pointer;
}
#infobox-close:active { transform: scale(0.94); }
#infobox-body h2 {
  margin: 0 0 14px;
  font-size: 21px;
  font-weight: 800;
  padding-right: 28px;
}
#infobox-body p {
  margin: 0 0 14px;
  font-size: 15.5px;
  line-height: 1.55;
  color: #4a4038;
}
#infobox-body p:last-child { margin-bottom: 0; }
.info-link {
  display: inline-flex;
  align-items: center;
  margin-top: 6px;
  padding: 11px 20px;
  font-size: 15px;
  font-weight: 800;
  color: #fff;
  text-decoration: none;
  background: var(--accent);
  border-radius: 999px;
  box-shadow: 0 8px 18px -8px rgba(255, 94, 91, 0.8);
}
.info-link:active { transform: scale(0.97); }

/* ---- Countdown / Voting popup ------------------------------ */
#countdown {
  position: fixed;
  inset: 0;
  z-index: 46;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(22, 16, 12, 0.7);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.22s ease;
}
#countdown.open { opacity: 1; }
#countdown[hidden] { display: none; }
.cd-card {
  position: relative;
  max-width: min(92vw, 440px);
  max-height: 86vh;
  overflow-y: auto;
  background: var(--tag-bg);
  color: var(--ink);
  border-radius: 20px;
  padding: 30px 26px 26px;
  text-align: center;
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.6);
  transform: scale(0.96);
  transition: transform 0.22s ease;
}
#countdown.open .cd-card { transform: scale(1); }
#cd-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  font-size: 16px;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.06);
  border: none;
  border-radius: 50%;
  cursor: pointer;
}
#cd-title { margin: 0 0 16px; font-size: 21px; font-weight: 800; }
#cd-time {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: rgba(255, 94, 91, 0.12);
  border-radius: 16px;
  padding: 16px 16px 14px;
  margin-bottom: 16px;
}
.cd-label { font-size: 13px; font-weight: 700; color: #6b5d4f; }
.cd-clock {
  font-size: 46px;
  font-weight: 800;
  line-height: 1.02;
  color: var(--accent);
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}
.cd-units { font-size: 10.5px; font-weight: 700; letter-spacing: 0.12em; color: #a3937f; text-transform: uppercase; }
.cd-explain { margin: 0; font-size: 14.5px; line-height: 1.55; color: #4a4038; }
.cd-test {
  margin-top: 18px;
  padding: 10px 18px;
  font-size: 13.5px;
  font-weight: 800;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.05);
  border: 1px dashed rgba(0, 0, 0, 0.28);
  border-radius: 999px;
  cursor: pointer;
}
.cd-test:active { transform: scale(0.97); }

/* ---- Newsletter / E-Mail-Capture --------------------------- */
#newsletter {
  position: fixed;
  inset: 0;
  z-index: 47;
  display: flex;
  align-items: flex-end;          /* Bottom-Sheet auf Mobil */
  justify-content: center;
  background: rgba(22, 16, 12, 0.7);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.24s ease;
}
#newsletter.open { opacity: 1; }
#newsletter[hidden] { display: none; }
.nl-card {
  position: relative;
  width: 100%;
  max-width: 460px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--tag-bg);
  color: var(--ink);
  border-radius: 24px 24px 0 0;
  padding: 30px 26px calc(24px + env(safe-area-inset-bottom));
  text-align: center;
  box-shadow: 0 -24px 60px -20px rgba(0, 0, 0, 0.6);
  transform: translateY(20px);
  transition: transform 0.28s cubic-bezier(0.2, 0.85, 0.25, 1);
}
#newsletter.open .nl-card { transform: translateY(0); }
@media (min-width: 600px) {
  #newsletter { align-items: center; padding: 24px; }
  .nl-card { border-radius: 22px; transform: scale(0.96); }
  #newsletter.open .nl-card { transform: scale(1); }
}
#nl-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  font-size: 16px;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.06);
  border: none;
  border-radius: 50%;
  cursor: pointer;
}
.nl-emoji { font-size: 40px; line-height: 1; margin-bottom: 8px; }
#nl-title { margin: 0 0 8px; font-size: 22px; font-weight: 800; }
.nl-text { margin: 0 auto 18px; max-width: 22em; font-size: 14.5px; line-height: 1.55; color: #4a4038; }
#nl-form { display: flex; flex-direction: column; gap: 10px; }
#nl-email {
  width: 100%;
  box-sizing: border-box;
  padding: 14px 16px;
  font-size: 16px;                /* ≥16px verhindert iOS-Auto-Zoom */
  border: 1.5px solid rgba(0, 0, 0, 0.14);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}
#nl-email:focus { border-color: var(--accent); }
#nl-email.invalid { border-color: var(--accent); background: rgba(255, 94, 91, 0.06); }
#nl-submit {
  padding: 14px 16px;
  font-size: 16px;
  font-weight: 800;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 14px;
  cursor: pointer;
  transition: transform 0.1s ease, opacity 0.15s ease;
}
#nl-submit:active { transform: scale(0.98); }
#nl-submit[disabled] { opacity: 0.6; cursor: default; }
.nl-consent { margin: 14px auto 0; max-width: 24em; font-size: 11.5px; line-height: 1.5; color: #8a7c6b; }
.nl-consent a { color: #6b5d4f; }
#nl-done h3 { margin: 6px 0 6px; font-size: 19px; font-weight: 800; }
#nl-done p { margin: 0 auto; max-width: 22em; font-size: 14px; line-height: 1.55; color: #4a4038; }

@media (prefers-reduced-motion: reduce) {
  .card img,
  #lightbox,
  #lb-figure,
  #infobox,
  .infobox-card,
  #results,
  .results-card,
  #countdown,
  .cd-card,
  #newsletter,
  .nl-card,
  #hint,
  .like-btn { transition: none; }
  .like-btn.pulse { animation: none; }
}
