/* Public site. Mobile first; the card becomes a side panel from 900px. */

html,
body {
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.skip-link {
  position: absolute;
  left: var(--space-3);
  top: -100px;
  z-index: 50;
  padding: var(--space-2) var(--space-3);
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius-s);
}
.skip-link:focus {
  top: var(--space-3);
}

/* ---------- Top bar ---------- */

.topbar {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  padding-top: max(var(--space-2), env(safe-area-inset-top));
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
  color: inherit;
  text-decoration: none;
}
.brand-mark {
  flex: none;
  width: 36px;
  height: 36px;
}
.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.brand-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  line-height: 1.05;
}
.brand-tag {
  font-size: var(--text-xs);
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  gap: var(--space-2);
  flex: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 var(--space-3);
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: 600 var(--text-s) / 1 var(--font-body);
  cursor: pointer;
  transition:
    background var(--dur-fast),
    color var(--dur-fast),
    transform var(--dur-fast);
}
.chip svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}
.chip:hover {
  background: var(--ink);
  color: var(--paper);
}
.chip:active {
  transform: scale(0.96);
}
.chip--quiet {
  border-color: transparent;
  background: transparent;
}
.chip--quiet:hover {
  background: var(--paper-2);
  color: var(--ink);
}

/* ---------- Stage: map / list ---------- */

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
}

.map-pane,
.map-pane > .map {
  /* .map-pane > .map beats MapLibre's own `.maplibregl-map { position: relative }`. */
  position: absolute;
  inset: 0;
}
.map {
  background:
    radial-gradient(circle at 30% 20%, rgb(255 255 255 / 0.7), transparent 60%),
    repeating-linear-gradient(45deg, var(--paper-2) 0 1px, transparent 1px 14px), var(--paper);
}

.map-status {
  position: absolute;
  left: 50%;
  top: var(--space-4);
  transform: translateX(-50%);
  margin: 0;
  padding: var(--space-2) var(--space-4);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-1);
  font-size: var(--text-s);
  color: var(--ink-2);
  white-space: nowrap;
  z-index: 5;
}
.map-status:empty {
  display: none;
}

/* Markers: brand pins only. They never show vote results. */
.pin {
  width: 34px;
  height: 42px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  transform-origin: 50% 100%;
  transition: transform var(--dur-fast) var(--ease-out);
}
.pin svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 2px 2px rgb(23 19 31 / 0.35));
}
.pin .pin-body {
  fill: var(--accent);
  stroke: #fff;
  stroke-width: 2;
}
.pin .pin-dot {
  fill: #fff;
}
.pin:hover {
  transform: scale(1.12);
}
.pin:focus-visible {
  outline: none;
}
.pin:focus-visible .pin-body {
  stroke: var(--ink);
  stroke-width: 3;
}
.pin[aria-pressed='true'] {
  transform: scale(1.3);
  z-index: 2;
}
.pin[aria-pressed='true'] .pin-body {
  fill: var(--ink);
}
.pin[aria-pressed='true'] .pin-dot {
  fill: var(--accent);
}

.maplibregl-ctrl-attrib {
  font-size: 11px;
}

/* List view */
.list-pane {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  background: var(--paper);
  padding: var(--space-4) var(--space-4) calc(var(--space-6) + env(safe-area-inset-bottom));
}
.list-head {
  max-width: 720px;
  margin: 0 auto var(--space-4);
}
.list-title {
  margin: var(--space-2) 0 var(--space-3);
  font-size: var(--text-xl);
  font-weight: 800;
}

.search {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-3);
  min-height: var(--tap);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-m);
}
.search:focus-within {
  border-color: var(--ink);
}
.search svg {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: var(--ink-3);
  stroke-width: 2;
  stroke-linecap: round;
}
.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  font: inherit;
  font-size: 16px; /* prevents iOS zoom */
  color: var(--ink);
}

.mall-list {
  max-width: 720px;
  margin: 0 auto;
}
.mall-list:focus {
  outline: none;
}
.district-group h2 {
  margin: var(--space-5) 0 var(--space-2);
  font-size: var(--text-xs);
  font-family: var(--font-body);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.district-group ul {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line);
}
.mall-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: 60px;
  padding: var(--space-2) var(--space-1);
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: inherit;
  text-align: left;
  font: inherit;
  cursor: pointer;
}
.mall-item:hover {
  background: var(--paper-2);
}
.mall-item-name {
  display: block;
  font-weight: 650;
}
.mall-item-zh {
  display: block;
  font-size: var(--text-s);
  color: var(--ink-3);
}
.mall-item-go {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.list-empty {
  max-width: 720px;
  margin: var(--space-5) auto;
  color: var(--ink-3);
}

/* ---------- Mall card: bottom sheet on phones ---------- */

.sheet {
  position: absolute;
  z-index: 30;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: calc(100% - var(--space-5));
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface);
  border-radius: var(--radius-l) var(--radius-l) 0 0;
  box-shadow: var(--shadow-2);
  animation: sheet-in var(--dur) var(--ease-out);
}
@keyframes sheet-in {
  from {
    transform: translateY(24px);
    opacity: 0;
  }
}
.sheet-grip {
  position: absolute;
  top: 8px;
  left: 50%;
  width: 40px;
  height: 4px;
  margin-left: -20px;
  border-radius: 2px;
  background: rgb(255 255 255 / 0.85);
  z-index: 2;
}

.sheet-close {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  z-index: 3;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgb(23 19 31 / 0.6);
  color: #fff;
  cursor: pointer;
  backdrop-filter: blur(6px);
}
.sheet-close:hover {
  background: var(--ink);
}
.sheet-close svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
}

.photo {
  position: relative;
  margin: 0;
  aspect-ratio: 16 / 9;
  max-height: 34vh;
  width: 100%;
  overflow: hidden;
  background: var(--paper-2);
  border-radius: var(--radius-l) var(--radius-l) 0 0;
}
.photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.credit {
  position: absolute;
  right: 0;
  bottom: 0;
  max-width: 100%;
  padding: 2px var(--space-2);
  background: rgb(23 19 31 / 0.62);
  color: #fff;
  font-size: 11px;
  line-height: 1.4;
  border-top-left-radius: var(--radius-s);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.credit a {
  color: #fff;
}
.credit:empty {
  display: none;
}

.sheet-body {
  padding: var(--space-4) var(--space-4) calc(var(--space-5) + env(safe-area-inset-bottom));
}
.eyebrow {
  margin: 0 0 var(--space-1);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-strong);
}
.card-title {
  margin: 0;
  font-size: var(--text-xl);
  font-weight: 800;
}
.card-title:focus {
  outline: none;
}
.card-zh {
  margin: var(--space-1) 0 0;
  font-size: var(--text-l);
  color: var(--ink-2);
}
.question {
  margin: var(--space-5) 0 var(--space-3);
  font-weight: 600;
}

.votes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
}
.vote {
  --c: var(--ink);
  --soft: var(--paper-2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 92px;
  padding: var(--space-3) var(--space-2);
  border: 2px solid var(--c);
  border-radius: var(--radius-m);
  background: var(--soft);
  color: var(--c);
  font: 800 1.1rem / 1 var(--font-display);
  cursor: pointer;
  transition:
    background var(--dur-fast),
    color var(--dur-fast),
    transform var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast);
  touch-action: manipulation;
}
.vote svg {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.vote--cold {
  --c: var(--cold);
  --soft: var(--cold-soft);
}
.vote--ok {
  --c: var(--ok);
  --soft: var(--ok-soft);
}
.vote--hot {
  --c: var(--hot);
  --soft: var(--hot-soft);
}
.vote:hover:not(:disabled) {
  background: var(--c);
  color: #fff;
  box-shadow: 0 8px 18px -10px var(--c);
}
.vote:active:not(:disabled) {
  transform: scale(0.95);
}
.vote:focus-visible {
  outline-color: var(--c);
  outline-offset: 3px;
}
.vote:disabled {
  cursor: default;
  opacity: 0.45;
}
.vote.is-chosen {
  background: var(--c);
  color: #fff;
  opacity: 1;
}

.status {
  margin-top: var(--space-4);
  min-height: 1.5em;
}
.status:focus {
  outline: none;
}
.status-thanks {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-m);
  background: var(--ink);
  color: var(--paper);
  animation: pop var(--dur) var(--ease-out);
}
.status-thanks strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.15rem;
}
.status-thanks span {
  font-size: var(--text-s);
  opacity: 0.85;
}
.status-wait {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-m);
  background: var(--paper-2);
  color: var(--ink-2);
  font-size: var(--text-s);
}
.status-error {
  color: var(--danger);
  font-weight: 600;
  font-size: var(--text-s);
}
@keyframes pop {
  from {
    transform: scale(0.96);
    opacity: 0;
  }
}

.fineprint {
  margin: var(--space-4) 0 0;
  font-size: var(--text-xs);
  color: var(--ink-3);
}

/* ---------- About dialog ---------- */

.about {
  width: min(560px, calc(100% - 2 * var(--space-4)));
  max-height: calc(100% - 2 * var(--space-4));
  padding: var(--space-5);
  border: 0;
  border-radius: var(--radius-l);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-2);
}
.about::backdrop {
  background: rgb(23 19 31 / 0.5);
}
.about h2 {
  margin-top: 0;
  font-size: var(--text-l);
}
.about h3 {
  margin-bottom: var(--space-1);
  font-size: var(--text-m);
}
.about-credits {
  font-size: var(--text-s);
  color: var(--ink-3);
}
.btn {
  min-height: var(--tap);
  padding: 0 var(--space-5);
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font: 700 var(--text-m) / 1 var(--font-body);
  cursor: pointer;
}
.btn:hover {
  background: var(--accent-strong);
}

.noscript {
  margin: var(--space-4);
  padding: var(--space-4);
  background: var(--accent-soft);
  border-radius: var(--radius-m);
}

/* ---------- Larger screens: side panel ---------- */

@media (min-width: 900px) {
  .sheet {
    top: var(--space-4);
    bottom: var(--space-4);
    left: var(--space-4);
    right: auto;
    width: 400px;
    max-height: none;
    border-radius: var(--radius-l);
    animation-name: panel-in;
  }
  .sheet-grip {
    display: none;
  }
  @keyframes panel-in {
    from {
      transform: translateX(-16px);
      opacity: 0;
    }
  }
  .brand-tag {
    font-size: var(--text-s);
  }
}
