@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,700&family=Source+Sans+3:wght@400;600;700&display=swap");

:root {
  --bg: #f3efe6;
  --panel: #faf7f0;
  --ink: #1c1914;
  --muted: #5f574c;
  --line: #d9d0c0;
  --accent: #0f6b5c;
  --accent-ink: #ffffff;
  --warm: #c45c26;
  --cluster: #0f6b5c;
  --pin: #c45c26;
  --shadow: 0 12px 40px rgba(28, 25, 20, 0.12);
  --font-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --font-body: "Source Sans 3", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  color: var(--ink);
  background: var(--bg);
  font-family: var(--font-body);
}

#app {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  height: 100%;
}

.sidebar-toggle {
  display: none;
  position: fixed;
  z-index: 1003;
  left: 12px;
  top: 12px;
  padding: 0.55rem;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  backdrop-filter: blur(6px);
}

.sidebar-toggle .hamburger {
  display: block;
  width: 18px;
  height: 12px;
  position: relative;
  margin: 0 auto;
}

.sidebar-toggle .hamburger::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  border-radius: 2px;
  top: 0;
  background: var(--ink);
  box-shadow: 0 5px 0 var(--ink), 0 10px 0 var(--ink);
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1002;
  background: rgba(0, 0, 0, 0.25);
}

.panel {
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding: 1.25rem 1.2rem 1rem;
  background:
    radial-gradient(ellipse at 0% 0%, rgba(196, 92, 38, 0.08), transparent 50%),
    linear-gradient(180deg, #fffaf2 0%, var(--panel) 100%);
  border-right: 1px solid var(--line);
  overflow: auto;
}

.panel-header h1 {
  margin: 0.15rem 0 0.35rem;
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.brand {
  margin: 0;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.4;
}

.stat {
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.7);
  font-size: 0.95rem;
  font-weight: 600;
}

.stat strong {
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 1.25rem;
}

.community-stat {
  position: relative;
  padding: 0.85rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(
    180deg,
    rgba(15, 107, 92, 0.1),
    rgba(255, 255, 255, 0.72)
  );
  perspective: 900px;
}

.community-stat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.community-stat-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.community-stat-flip {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.85);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.community-stat-flip:hover {
  filter: brightness(1.03);
}

.community-stat-flip-icon {
  width: 14px;
  height: 14px;
  display: block;
}

.community-stat-flipper {
  position: relative;
  margin-top: 0.35rem;
  transition: transform 0.45s ease;
  transform-style: preserve-3d;
}

.community-stat.is-flipped .community-stat-flipper {
  transform: rotateY(180deg);
}

.community-stat-face {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.community-stat-face--back {
  position: absolute;
  inset: 0;
  transform: rotateY(180deg);
  display: flex;
  align-items: center;
}

.community-stat-value {
  margin-top: 0.2rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.community-stat-value strong {
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 1.45rem;
}

.community-stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 0.2rem;
  width: 100%;
}

.community-stat-grid[hidden] {
  display: none !important;
}

.community-stat-signin {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.community-stat-signin[hidden] {
  display: none !important;
}

.community-mini {
  padding: 0.35rem 0.2rem;
}

.community-mini-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.community-mini-value {
  margin-top: 0.2rem;
  font-weight: 800;
}

.community-mini-value strong {
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 1.25rem;
}

.field {
  display: grid;
  gap: 0.35rem;
}

.field span,
.check span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.field input,
.field select {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.field input:focus,
.field select:focus {
  outline: 2px solid rgba(15, 107, 92, 0.35);
  border-color: var(--accent);
}

.check {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  cursor: pointer;
}

.check input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
}

.actions {
  display: flex;
  gap: 0.5rem;
}

.btn {
  flex: 1;
  padding: 0.65rem 0.8rem;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.btn:hover {
  filter: brightness(1.05);
}

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.sidebar-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
  padding: 0.9rem;
}

.sidebar-card-header h2 {
  margin: 0 0 0.2rem;
  font-size: 1rem;
}

.sidebar-card-header p,
.card-manager-copy,
.cards-empty,
.auth-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.35;
}

.auth-actions,
.user-summary {
  display: flex;
  gap: 0.55rem;
  margin-top: 0.8rem;
}

.auth-actions[hidden],
.user-summary[hidden],
.card-manager[hidden] {
  display: none !important;
}

.user-summary {
  align-items: center;
  justify-content: space-between;
}

.user-summary-text {
  min-width: 0;
  font-size: 0.85rem;
  font-weight: 700;
}

.card-manager {
  margin-top: 0.85rem;
}

.cards-list {
  display: grid;
  gap: 0.65rem;
  margin-top: 0.85rem;
}

.saved-card {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 0.75rem;
  text-align: left;
}

.saved-card.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 107, 92, 0.18);
}

.saved-card-select {
  display: block;
  width: 100%;
  padding: 0;
  border: none;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.saved-card-top {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.saved-card-copy {
  min-width: 0;
}

.saved-card-label {
  display: block;
  font-weight: 800;
}

.saved-card-bank,
.saved-card-remaining {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
}

.saved-card-actions {
  display: flex;
  gap: 0.45rem;
  margin-top: 0.7rem;
}

.saved-card-actions .btn {
  flex: 1;
  padding: 0.45rem 0.55rem;
  font-size: 0.82rem;
}

.history-modal-card {
  max-height: min(80vh, 720px);
  overflow: auto;
}

.history-list {
  display: grid;
  gap: 0.65rem;
}

.history-row {
  display: grid;
  grid-template-columns: 54px 1fr auto;
  gap: 0.7rem;
  align-items: center;
  padding: 0.7rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.history-promo-num {
  width: 54px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #1d3a35);
}

.history-meta {
  min-width: 0;
}

.history-meta strong {
  display: block;
  font-size: 0.9rem;
}

.history-meta span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 0.15rem;
}

.history-actions {
  display: grid;
  gap: 0.35rem;
  min-width: 120px;
}

.history-actions .btn {
  flex: 0;
  padding: 0.4rem 0.5rem;
  font-size: 0.78rem;
}

.history-actions input[type="date"] {
  width: 100%;
  padding: 0.3rem 0.35rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-size: 0.75rem;
}

.history-empty {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.history-status-received {
  color: var(--accent);
  font-weight: 800;
  font-size: 0.8rem;
}

.results {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 40vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.results li {
  padding: 0.7rem 0.8rem;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.results li:last-child {
  border-bottom: none;
}

.results li:hover,
.results li:focus {
  background: #f4ebe0;
  outline: none;
}

.results .name {
  display: block;
  font-weight: 700;
}

.results .meta {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.results-row {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.results-preview {
  display: grid;
  gap: 6px;
}

.results-thumb {
  width: 76px;
  height: 58px;
  display: block;
  border-radius: 8px;
  object-fit: cover;
  background: #ece7df;
}

.results-thumb--placeholder {
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(15, 107, 92, 0.08), rgba(196, 92, 38, 0.08)),
    #f4eee4;
}

.results-copy {
  min-width: 0;
}

.results-preview-meta {
  display: flex;
  align-items: center;
  gap: 6px;
}

.results-rating {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--accent);
}

.results-rating--muted {
  color: var(--muted);
}

.panel-footer {
  margin-top: auto;
  padding-top: 0.5rem;
}

.panel-footer p {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.4;
}

#map {
  min-height: 100%;
}

.maplibregl-popup-content {
  padding: 0;
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
  font-family: var(--font-body);
}

.maplibregl-popup-close-button {
  font-size: 1.2rem;
  color: var(--muted);
}

.popup {
  min-width: 240px;
  max-width: 300px;
  padding: 0;
}

.popup-body {
  padding: 0.85rem 1rem 1rem;
}

.popup-gallery {
  border-bottom: 1px solid var(--line);
  background: #111;
}

.popup-gallery--loading,
.popup-gallery--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 88px;
  padding: 0.75rem;
  background: #f0ebe3;
  color: var(--muted);
  font-size: 0.82rem;
}

.popup-gallery-note {
  color: var(--muted);
}

.popup-hero {
  width: 100%;
  height: 168px;
  background: #1a1a1a;
}

.popup-hero-img {
  display: block;
  width: 100%;
  height: 168px;
  object-fit: cover;
}

.popup-thumbs {
  display: flex;
  gap: 0.35rem;
  padding: 0.45rem 0.5rem;
  overflow-x: auto;
  background: #fff;
  scrollbar-width: thin;
}

.popup-thumb {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  background: #eee;
}

.popup-thumb.is-active {
  border-color: var(--accent);
}

.popup-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.popup-photos-credit {
  margin: 0;
  padding: 0.35rem 0.5rem 0.5rem;
  font-size: 0.68rem;
  color: var(--muted);
  text-align: right;
  background: #fff;
}

.popup h2 {
  margin: 0 0 0.35rem;
  font-family: var(--font-display);
  font-size: 1.15rem;
  line-height: 1.2;
}

.popup p {
  margin: 0 0 0.45rem;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.35;
}

.popup .badge {
  display: inline-block;
  margin: 0 0.35rem 0.55rem 0;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: #e8f3ef;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.popup .badge.warn {
  background: #f7ebe3;
  color: var(--warm);
}

.popup a {
  display: inline-flex;
  margin-top: 0.25rem;
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.popup a:hover {
  text-decoration: underline;
}

@media (max-width: 860px) {
  #app {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
  }

  .panel {
    border-right: none;
    border-bottom: none;
    max-height: none;
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: min(92vw, 380px);
    box-shadow: var(--shadow);
  }

  .panel.is-open {
    display: flex;
  }

  .sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  #sidebarBackdrop[hidden] {
    display: none;
  }

  #map {
    min-height: 100vh;
  }
}

/* Order tracking modal (Yelp-like prompt on return to pazetracker tab) */
.order-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.order-modal[hidden] {
  display: none !important;
}

.order-modal-card {
  width: min(640px, 100%);
  background: #fffaf2;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 18px 18px 16px;
  position: relative;
}

.order-modal-close {
  position: absolute;
  right: 12px;
  top: 10px;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
}

.order-modal-close:hover {
  filter: brightness(1.02);
}

.order-modal-header {
  padding-right: 36px;
}

.order-modal-header h2 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  letter-spacing: -0.01em;
}

.order-modal-subtitle {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.35;
}

.order-step {
  margin-top: 6px;
}

.order-question {
  margin: 0 0 12px;
  font-weight: 700;
  color: var(--ink);
}

.order-actions {
  display: flex;
  gap: 10px;
}

.order-actions .btn {
  flex: 1;
}

.order-bank-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.order-bank-choice {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-width: 0;
  min-height: 52px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #ffffff;
  cursor: pointer;
  user-select: none;
  overflow: hidden;
}

.order-bank-choice.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 107, 92, 0.18);
}

.order-bank-choice--full {
  grid-column: 1 / -1;
}

.order-bank-simulated-card {
  width: 56px;
  min-height: 40px;
  height: 100%;
  max-height: 44px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 5px;
  box-sizing: border-box;
  font-weight: 900;
  color: #ffffff;
  letter-spacing: -0.02em;
  font-size: 11px;
  line-height: 1.15;
  text-align: center;
  text-wrap: balance;
  background: linear-gradient(135deg, var(--accent), #1d3a35);
}

.order-bank-name {
  min-width: 0;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.25;
  font-size: 0.82rem;
  overflow-wrap: anywhere;
  word-break: break-word;
  hyphens: auto;
}

.order-remaining {
  margin-top: 8px;
  font-weight: 800;
  color: var(--muted);
}

@media (max-width: 560px) {
  .order-actions {
    flex-direction: column;
  }
  .order-bank-grid {
    grid-template-columns: 1fr;
  }
}
