/* Reserva dos Pássaros — mapa de vendas
   Direção: cartografia editorial · papel creme, verde-mata, terracota */

@font-face {
  font-family: "Fraunces";
  src: url("../fonts/fraunces-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Figtree";
  src: url("../fonts/figtree-latin.woff2") format("woff2");
  font-weight: 300 900;
  font-display: swap;
}

:root {
  --paper: #f5efe2;
  --paper-deep: #ede4d1;
  --ink: #2c3a2e;
  --ink-soft: #5c6b5e;
  --brand: #3e5c41;
  --brand-deep: #2c452f;
  --terracotta: #c24e33;

  --st-disponivel: #3a7d4e;
  --st-disponivel-fill: rgba(74, 156, 99, 0.38);
  --st-reservado: #99680f;
  --st-reservado-fill: rgba(224, 166, 54, 0.48);
  --st-vendido: #b0442b;
  --st-vendido-fill: rgba(178, 70, 45, 0.42);

  --font-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --font-ui: "Figtree", "Avenir Next", "Segoe UI", sans-serif;

  --shadow-card: 0 18px 50px -12px rgba(44, 58, 46, 0.35);
  --radius: 14px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --header-h: 92px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

/* atributo hidden vence qualquer display definido em classe */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  font-family: var(--font-ui);
  color: var(--ink);
  background:
    radial-gradient(120% 90% at 15% 0%, #faf5ea 0%, var(--paper) 55%, var(--paper-deep) 100%);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* grão de papel */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: 5;
}

/* ------------------------------------------------------------- header -- */

.site-header {
  min-height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem clamp(1rem, 3vw, 2.2rem);
  border-bottom: 1px solid rgba(62, 92, 65, 0.18);
  position: relative;
  z-index: 6;
}

.brand { display: flex; align-items: center; gap: 0.9rem; }

.brand-logo { width: 86px; height: auto; }

.brand-eyebrow {
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--terracotta);
  font-weight: 600;
}

.brand-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.25rem, 2.6vw, 1.7rem);
  line-height: 1.05;
  color: var(--brand-deep);
}

.brand-sub {
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin-top: 2px;
}

.live-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--st-disponivel);
  margin: 0 3px;
  animation: pulse 2.4s infinite;
  vertical-align: 1px;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(58, 125, 78, 0.5); }
  60% { box-shadow: 0 0 0 6px rgba(58, 125, 78, 0); }
}

.stats { display: flex; gap: clamp(0.5rem, 2vw, 1.4rem); list-style: none; }

.stat {
  text-align: center;
  padding: 0.45rem 0.9rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(62, 92, 65, 0.14);
  min-width: 84px;
}

.stat-number {
  display: block;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.1;
}

.stat--disponivel .stat-number { color: var(--st-disponivel); }
.stat--reservado .stat-number { color: var(--st-reservado); }
.stat--vendido .stat-number { color: var(--st-vendido); }

.stat-label {
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* -------------------------------------------------------------- stage -- */

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

.map-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
}
.map-stage:active { cursor: grabbing; }

.map-canvas {
  position: absolute;
  transform-origin: 0 0;
  filter: drop-shadow(0 24px 48px rgba(44, 58, 46, 0.28));
}
.map-canvas.is-dragging { will-change: transform; }

.map-canvas picture, .map-canvas img {
  display: block;
  width: 100%;
  height: 100%;
  user-select: none;
  -webkit-user-drag: none;
}

.lots-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* o polígono é só a área de clique (invisível); quem mostra o status é o
   círculo central — assim o desenho do render fica intacto */
.lot {
  cursor: pointer;
  fill: rgb(0 0 0 / 0);
  stroke: none;
  outline: none;
}

.lot-dot {
  pointer-events: none;
  stroke: #fdfaf3;
  transform-box: fill-box;
  transform-origin: center;
  transition: transform 160ms var(--ease-out), fill 160ms;
  filter: drop-shadow(0 2px 4px rgba(44, 58, 46, 0.45));
}
.lot--disponivel + .lot-dot { fill: var(--st-disponivel); }
.lot--reservado  + .lot-dot { fill: var(--st-reservado); }
.lot--vendido    + .lot-dot { fill: var(--st-vendido); }

.lot:hover + .lot-dot,
.lot:focus-visible + .lot-dot { transform: scale(1.35); }
.lot.is-selected + .lot-dot {
  transform: scale(1.5);
  stroke: #fff;
}

/* --------------------------------------------------- controles & legenda -- */

.zoom-controls {
  position: absolute;
  right: 1rem;
  bottom: 5rem;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 4;
}

.zoom-controls button {
  width: 44px; height: 44px;
  border-radius: 12px;
  border: 1px solid rgba(62, 92, 65, 0.25);
  background: rgba(255, 255, 255, 0.9);
  color: var(--brand-deep);
  font-size: 1.25rem;
  font-family: var(--font-ui);
  cursor: pointer;
  box-shadow: 0 6px 18px -6px rgba(44, 58, 46, 0.35);
  transition: transform 140ms var(--ease-out), background 140ms;
}
.zoom-controls button:hover { background: #fff; transform: translateY(-1px); }
.zoom-controls button:active { transform: translateY(0) scale(0.96); }
.zoom-controls button:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.legend {
  position: absolute;
  left: 1rem;
  bottom: 1rem;
  display: flex;
  gap: 0.4rem;
  list-style: none;
  z-index: 4;
}

.legend-item {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0.4rem 0.75rem 0.4rem 1.55rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(62, 92, 65, 0.16);
  position: relative;
}
.legend-item::before {
  content: "";
  position: absolute;
  left: 0.6rem; top: 50%;
  translate: 0 -50%;
  width: 10px; height: 10px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1.5px rgba(253, 250, 243, 0.9);
}
.legend-item--disponivel::before { background: var(--st-disponivel); }
.legend-item--reservado::before { background: var(--st-reservado); }
.legend-item--vendido::before { background: var(--st-vendido); }

.map-hint {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  translate: -50% 0;
  font-size: 0.72rem;
  color: var(--ink-soft);
  background: rgba(245, 239, 226, 0.85);
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  z-index: 4;
  animation: hint-fade 1ms linear;
}

/* ---------------------------------------------------------------- card -- */

.lot-card {
  position: absolute;
  top: calc(var(--header-h) + 1rem);
  right: 1.25rem;
  width: min(340px, calc(100vw - 2.5rem));
  background: linear-gradient(160deg, #fdfaf3 0%, #f6efdf 100%);
  border: 1px solid rgba(62, 92, 65, 0.2);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 1.4rem 1.5rem 1.2rem;
  z-index: 7;
  animation: card-in 320ms var(--ease-out);
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.card-close {
  position: absolute;
  top: 0.65rem; right: 0.75rem;
  width: 34px; height: 34px;
  border: none;
  border-radius: 50%;
  background: rgba(62, 92, 65, 0.08);
  color: var(--ink-soft);
  font-size: 1.15rem;
  cursor: pointer;
  transition: background 140ms;
}
.card-close:hover { background: rgba(62, 92, 65, 0.16); }
.card-close:focus-visible { outline: 2px solid var(--brand); }

.card-eyebrow {
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--terracotta);
  font-weight: 600;
}

.card-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 600;
  color: var(--brand-deep);
  margin: 0.15rem 0 0.6rem;
}

.status-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.34rem 0.85rem;
  border-radius: 999px;
  color: #fff;
}
.status-badge--disponivel { background: var(--st-disponivel); }
.status-badge--reservado { background: var(--st-reservado); }
.status-badge--vendido { background: var(--st-vendido); }

.card-facts { margin: 1.1rem 0 0.4rem; }
.card-facts > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.55rem 0;
  border-top: 1px dashed rgba(62, 92, 65, 0.25);
}
.card-facts dt {
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.card-facts dd {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--ink);
  text-align: right;
  white-space: nowrap;
}
.card-facts dd.card-dims { font-size: 1rem; white-space: normal; max-width: 60%; }
.card-facts dd.card-valor { color: var(--brand-deep); font-size: 1.3rem; }
.card-facts dd.card-valor--consulta {
  font-size: 0.95rem;
  font-style: italic;
  color: var(--ink-soft);
}

.card-note {
  font-size: 0.7rem;
  color: var(--ink-soft);
  margin-top: 0.9rem;
}

/* admin dentro do card */
.card-admin {
  margin-top: 1rem;
  padding-top: 0.9rem;
  border-top: 1px solid rgba(62, 92, 65, 0.2);
}
.card-admin-label {
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 0.5rem;
}
.card-admin-buttons { display: flex; gap: 6px; }
.status-button {
  flex: 1;
  padding: 0.5rem 0.25rem;
  font-size: 0.74rem;
  font-weight: 600;
  font-family: var(--font-ui);
  border-radius: 9px;
  border: 1.5px solid transparent;
  cursor: pointer;
  background: rgba(62, 92, 65, 0.07);
  color: var(--ink);
  transition: transform 120ms var(--ease-out);
}
.status-button:hover:not(:disabled) { transform: translateY(-1px); }
.status-button--disponivel:hover:not(:disabled),
.status-button--disponivel.is-current { background: var(--st-disponivel); color: #fff; }
.status-button--reservado:hover:not(:disabled),
.status-button--reservado.is-current { background: var(--st-reservado); color: #fff; }
.status-button--vendido:hover:not(:disabled),
.status-button--vendido.is-current { background: var(--st-vendido); color: #fff; }
.status-button.is-current { cursor: default; }

/* --------------------------------------------------------------- avisos -- */

.error-banner {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  translate: -50% 0;
  background: var(--terracotta);
  color: #fff;
  font-size: 0.8rem;
  padding: 0.6rem 1.1rem;
  border-radius: 999px;
  box-shadow: var(--shadow-card);
  z-index: 20;
}

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

.login-screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(100% 80% at 50% 0%, #faf5ea 0%, var(--paper-deep) 100%);
  z-index: 30;
  padding: 1rem;
}

.login-box {
  width: min(380px, 100%);
  background: linear-gradient(160deg, #fdfaf3, #f6efdf);
  border: 1px solid rgba(62, 92, 65, 0.2);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 2rem;
  text-align: center;
}

.login-box .brand-logo { width: 110px; margin-bottom: 0.5rem; }

.login-box h1 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: var(--brand-deep);
  margin-bottom: 0.2rem;
}

.login-box p { font-size: 0.82rem; color: var(--ink-soft); margin-bottom: 1.4rem; }

.login-box label {
  display: block;
  text-align: left;
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0.9rem 0 0.3rem;
}

.login-box input {
  width: 100%;
  padding: 0.7rem 0.9rem;
  font-size: 0.95rem;
  font-family: var(--font-ui);
  border: 1px solid rgba(62, 92, 65, 0.3);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}
.login-box input:focus-visible { outline: 2px solid var(--brand); }

.login-box button[type="submit"] {
  width: 100%;
  margin-top: 1.4rem;
  padding: 0.8rem;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: var(--font-ui);
  color: #fff;
  background: var(--brand);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background 140ms;
}
.login-box button[type="submit"]:hover { background: var(--brand-deep); }

.login-error {
  color: var(--terracotta);
  font-size: 0.8rem;
  margin-top: 0.8rem;
  min-height: 1.2em;
}

.admin-bar {
  position: absolute;
  top: calc(var(--header-h) + 1rem);
  left: 1.25rem;
  z-index: 7;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--brand-deep);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 0.5rem 0.6rem 0.5rem 1rem;
  border-radius: 999px;
  box-shadow: var(--shadow-card);
}
.admin-bar button {
  border: none;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  cursor: pointer;
}
.admin-bar button:hover { background: rgba(255, 255, 255, 0.3); }

/* ------------------------------------------------------------ responsivo -- */

@media (max-width: 760px) {
  :root { --header-h: 132px; }

  .site-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    padding-bottom: 0.7rem;
  }
  .brand-logo { width: 60px; }
  .stats { width: 100%; justify-content: space-between; }
  .stat { flex: 1; min-width: 0; padding: 0.35rem 0.3rem; }
  .stat-number { font-size: 1.25rem; }
  .stat-label {
    font-size: 0.56rem;
    letter-spacing: 0.06em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
  }

  .lot-card {
    top: auto;
    right: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    border-radius: 20px 20px 0 0;
    animation: sheet-in 300ms var(--ease-out);
    padding-bottom: max(1.2rem, env(safe-area-inset-bottom));
  }
  @keyframes sheet-in {
    from { transform: translateY(40%); opacity: 0.5; }
    to { transform: none; opacity: 1; }
  }

  .zoom-controls { bottom: 4.5rem; }
  .map-hint { display: none; }
  .legend { flex-wrap: wrap; right: 4.5rem; }
}

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