:root {
  --ink: #1c1b17;
  --paper: #ffefca;
  --paper-rgb: 255, 239, 202;
  --accent: #9169f4;
  --accent-rgb: 145, 105, 244;
  --accent-hover: #7c4dec;
  --terracotta: #c6552f;
  --olive: #5f7047;
  --azulejo: #2b6777;
  --ochre: #c98a1e;
  --line: rgba(28, 27, 23, 0.12);
  --shadow: 0 10px 30px rgba(28, 27, 23, 0.18);
  --radius: 18px;
  --font-sans: "Work Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--paper);
  overflow: hidden;
}

#app {
  position: relative;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
}

/* ---------- Topbar ---------- */

.topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: linear-gradient(to bottom, rgba(var(--paper-rgb), 0.92), rgba(var(--paper-rgb), 0.55));
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar__mark {
  width: 14px;
  height: 14px;
  border-radius: 50% 50% 50% 4px;
  background: var(--accent);
  transform: rotate(-45deg);
  box-shadow: 0 2px 4px rgba(28, 27, 23, 0.3);
  flex-shrink: 0;
}

.topbar__text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.topbar__title {
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
}

.topbar__place {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(28, 27, 23, 0.6);
}

.topbar__how {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
  color: var(--ink);
  transition: background 0.2s, border-color 0.2s;
}

.topbar__how:hover,
.topbar__how:focus-visible {
  background: rgba(28, 27, 23, 0.06);
  border-color: rgba(28, 27, 23, 0.25);
}

/* ---------- Map ---------- */

#map {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: var(--paper);
}

.leaflet-tile-pane {
  filter: sepia(10%) saturate(85%) brightness(1.03) contrast(0.97);
}

.leaflet-control-attribution {
  font-family: var(--font-sans);
  font-size: 10px;
  background: rgba(var(--paper-rgb), 0.75) !important;
}

.leaflet-control-zoom a {
  color: var(--ink) !important;
}

/* custom teardrop pins */

.patio-pin {
  width: var(--s, 28px);
  height: var(--s, 28px);
  position: relative;
  transition: width 0.25s ease, height 0.25s ease;
}

.patio-pin__head {
  position: absolute;
  inset: 0;
  border-radius: 50% 50% 50% 4px;
  transform: rotate(-45deg);
  box-shadow: 0 4px 10px rgba(28, 27, 23, 0.4);
  border: 2px solid rgba(var(--paper-rgb), 0.9);
}

.patio-pin__inner {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  background: rgba(var(--paper-rgb), 0.95);
  transform: translate(-50%, -50%) rotate(45deg);
}

.patio-pin--idea .patio-pin__head { background: var(--azulejo); }
.patio-pin--propuesta .patio-pin__head { background: var(--olive); }
.patio-pin--queja .patio-pin__head { background: var(--terracotta); }
.patio-pin--otro .patio-pin__head { background: var(--ochre); }

.patio-pin--idea .patio-pin__inner { border-radius: 50%; }
.patio-pin--propuesta .patio-pin__inner { border-radius: 1px; }
.patio-pin--queja .patio-pin__inner { clip-path: polygon(50% 15%, 90% 85%, 10% 85%); }
.patio-pin--otro .patio-pin__inner { border-radius: 1px; }

.patio-pin.is-dropping .patio-pin__head {
  animation: pin-drop 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes pin-drop {
  0% { transform: rotate(-45deg) translateY(-46px) scale(0.5); opacity: 0; }
  55% { transform: rotate(-45deg) translateY(6px) scale(1.06); opacity: 1; }
  100% { transform: rotate(-45deg) translateY(0) scale(1); opacity: 1; }
}

.patio-pin.is-draft .patio-pin__head {
  border-style: dashed;
}

.patio-pin__pulse {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 28px;
  height: 28px;
  margin: -14px 0 0 -14px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.35;
  animation: pin-pulse 0.7s ease-out;
  pointer-events: none;
}
.patio-pin--idea .patio-pin__pulse { color: var(--azulejo); }
.patio-pin--propuesta .patio-pin__pulse { color: var(--olive); }
.patio-pin--queja .patio-pin__pulse { color: var(--terracotta); }
.patio-pin--otro .patio-pin__pulse { color: var(--ochre); }

@keyframes pin-pulse {
  0% { transform: scale(0.4); opacity: 0.5; }
  100% { transform: scale(2.6); opacity: 0; }
}

.leaflet-popup-content-wrapper {
  background: var(--paper);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.leaflet-popup-tip {
  background: var(--paper);
}

.popup {
  font-family: var(--font-sans);
  max-width: 220px;
}

.popup__tipo {
  display: inline-block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  margin-bottom: 6px;
  color: var(--paper);
}
.popup__tipo--idea { background: var(--azulejo); }
.popup__tipo--propuesta { background: var(--olive); }
.popup__tipo--queja { background: var(--terracotta); }
.popup__tipo--otro { background: var(--ochre); }

.popup__zona {
  font-size: 0.72rem;
  color: rgba(28, 27, 23, 0.55);
  margin: 0 0 4px;
}

.popup__text {
  font-size: 0.85rem;
  margin: 0 0 4px;
  line-height: 1.4;
}

.popup__date {
  font-size: 0.68rem;
  color: rgba(28, 27, 23, 0.45);
}

/* ---------- Hint pill ---------- */

.hint {
  position: absolute;
  top: 78px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 400;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 9px 16px;
  background: rgba(var(--paper-rgb), 0.92);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.82rem;
  box-shadow: var(--shadow);
  transition: opacity 0.4s, transform 0.4s;
  pointer-events: none;
}

.hint.is-hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(-8px);
}

.hint__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: hint-pulse 1.6s ease-in-out infinite;
}

@keyframes hint-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0.45); }
  50% { box-shadow: 0 0 0 6px rgba(var(--accent-rgb), 0); }
}

/* ---------- Legend ---------- */

.legend {
  position: absolute;
  left: 20px;
  bottom: 20px;
  z-index: 400;
  background: rgba(var(--paper-rgb), 0.92);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 16px;
  box-shadow: var(--shadow);
  font-size: 0.78rem;
}

.legend__title {
  margin: 0 0 6px;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(28, 27, 23, 0.55);
}

.legend__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 5px;
}

.legend__list li {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legend__list b {
  margin-left: auto;
  font-weight: 700;
  color: rgba(28, 27, 23, 0.6);
}

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 50% 50% 50% 2px;
  transform: rotate(-45deg);
  flex-shrink: 0;
}
.swatch--idea { background: var(--azulejo); }
.swatch--propuesta { background: var(--olive); }
.swatch--queja { background: var(--terracotta); }
.swatch--otro { background: var(--ochre); }

/* ---------- Drawer ---------- */

.drawer {
  position: absolute;
  inset: 0;
  z-index: 900;
  pointer-events: none;
}

.drawer[aria-hidden="false"] { pointer-events: auto; }

.drawer__panel {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: min(420px, 100%);
  background: var(--paper);
  box-shadow: -14px 0 40px rgba(28, 27, 23, 0.22);
  transform: translateX(100%);
  transition: transform 0.38s cubic-bezier(0.22, 1, 0.36, 1);
  padding: 22px 22px 28px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.drawer[aria-hidden="false"] .drawer__panel {
  transform: translateX(0);
}

.drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.drawer__head h2 {
  font-family: var(--font-sans);
  font-size: 1.5rem;
  font-weight: 800;
  margin: 0;
}

.drawer__close {
  background: transparent;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--ink);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  transition: background 0.2s;
}
.drawer__close:hover { background: rgba(28, 27, 23, 0.08); }

.honeypot {
  position: absolute !important;
  left: -9999px !important;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.field {
  display: block;
  margin-bottom: 14px;
  border: none;
  padding: 0;
}

.field legend {
  padding: 0;
  margin-bottom: 8px;
  font-size: 0.78rem;
  font-weight: 600;
}

.field__label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.field__label small {
  font-weight: 400;
  color: rgba(28, 27, 23, 0.5);
}

.field input[type="text"],
.field input[type="email"],
.field textarea {
  width: 100%;
  font-family: var(--font-sans);
  font-size: 0.92rem;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  resize: vertical;
}

.field input:focus-visible,
.field textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.tipo-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.tipo-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}

.tipo-btn:hover { transform: translateY(-1px); }

.tipo-btn__shape {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--line);
}
.tipo-btn--idea .tipo-btn__shape { background: var(--azulejo); }
.tipo-btn--propuesta .tipo-btn__shape { background: var(--olive); border-radius: 2px; }
.tipo-btn--queja .tipo-btn__shape { clip-path: polygon(50% 10%, 90% 90%, 10% 90%); background: var(--terracotta); }
.tipo-btn--otro .tipo-btn__shape { background: var(--ochre); border-radius: 2px; transform: rotate(45deg); }

.tipo-btn.is-active { border-color: var(--accent); background: rgba(var(--accent-rgb), 0.1); }

.contact {
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}

.contact summary {
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
}
.contact summary small { font-weight: 400; color: rgba(28, 27, 23, 0.5); }
.contact .field { margin-top: 12px; }

.contact__note {
  font-size: 0.72rem;
  color: rgba(28, 27, 23, 0.5);
  margin: 4px 0 0;
}

.form-error {
  background: rgba(198, 85, 47, 0.1);
  border: 1px solid rgba(198, 85, 47, 0.4);
  color: var(--terracotta);
  font-size: 0.82rem;
  padding: 8px 12px;
  border-radius: 8px;
  margin-bottom: 12px;
}

.submit-btn {
  width: 100%;
  background: var(--accent);
  color: var(--ink);
  border: none;
  border-radius: 999px;
  padding: 13px 18px;
  font-family: var(--font-sans);
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, background 0.2s;
}
.submit-btn:hover { background: var(--accent-hover); }
.submit-btn:active { transform: scale(0.98); }
.submit-btn:disabled { opacity: 0.6; cursor: wait; }

.privacy-note {
  font-size: 0.72rem;
  color: rgba(28, 27, 23, 0.5);
  text-align: center;
  margin: 10px 0 0;
}

.thanks {
  margin: auto 0;
  text-align: center;
  padding: 20px 0;
}
.thanks__title {
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: 1.4rem;
  margin: 0 0 8px;
}
.thanks__body {
  font-size: 0.9rem;
  color: rgba(28, 27, 23, 0.65);
  margin: 0 0 20px;
}

/* ---------- How-it-works modal ---------- */

.modal {
  position: absolute;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(28, 27, 23, 0.4);
  backdrop-filter: blur(2px);
}

.modal[hidden] {
  display: none;
}

.modal__panel {
  position: relative;
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 26px;
  max-width: 420px;
  width: calc(100% - 40px);
}

.modal__panel h2 {
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: 1.4rem;
  margin: 0 0 16px;
}

.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 14px;
}

.steps li {
  display: flex;
  gap: 12px;
  align-items: baseline;
  font-size: 0.88rem;
  line-height: 1.4;
}

.steps__n {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--accent);
  flex-shrink: 0;
}

/* ---------- Toast ---------- */

.toast {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  z-index: 1100;
  background: var(--ink);
  color: var(--paper);
  padding: 11px 20px;
  border-radius: 999px;
  font-size: 0.84rem;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.is-error { background: var(--terracotta); }

/* ---------- Responsive ---------- */

@media (max-width: 720px) {
  .legend {
    left: 12px;
    right: 12px;
    bottom: 12px;
    padding: 10px 14px;
  }
  .legend__list { grid-template-columns: 1fr 1fr; }

  .drawer__panel {
    top: auto;
    right: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    height: auto;
    max-height: 88vh;
    border-radius: 20px 20px 0 0;
    transform: translateY(100%);
  }
  .drawer[aria-hidden="false"] .drawer__panel {
    transform: translateY(0);
  }

  .topbar__how { padding: 7px 12px; font-size: 0.78rem; }
  .hint { top: 70px; font-size: 0.76rem; padding: 7px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- Apoyos ---------- */

.patio-pin__badge {
  position: absolute;
  top: -6px;
  right: -8px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font: 700 0.62rem/18px var(--font-sans);
  text-align: center;
  box-shadow: 0 2px 6px rgba(28, 27, 23, 0.35);
  pointer-events: none;
}

.popup__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
}

.apoyo-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px 5px 6px;
  border: 1.5px solid var(--accent);
  border-radius: 999px;
  background: transparent;
  color: var(--accent-hover);
  font: 600 0.74rem/1 var(--font-sans);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.apoyo-btn:hover { background: rgba(var(--accent-rgb), 0.1); }
.apoyo-btn:active { transform: scale(0.96); }
.apoyo-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.apoyo-btn:disabled { opacity: 0.6; cursor: progress; }

.apoyo-btn__icon {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 800;
}

.apoyo-btn__n {
  font-weight: 800;
  color: var(--ink);
}

.apoyo-btn.is-on {
  background: var(--accent);
  color: #fff;
}
.apoyo-btn.is-on .apoyo-btn__icon { background: #fff; color: var(--accent); }
.apoyo-btn.is-on .apoyo-btn__n { color: #fff; }
