@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600&family=Inter:wght@400;500;600&display=swap');

:root {
  --sillar: #EAE4D8;
  --paper: #F8F6F1;
  --ink: #2B2A28;
  --ink-deep: #1C231F;
  --ink-soft: #5B5750;
  --cantera: #A64B2A;
  --cantera-dark: #7F3A20;
  --cantera-wash: #F1E2D6;
  --sierra: #3F4A3D;
  --sierra-dark: #2C352E;
  --sierra-wash: #E3E8E1;
  --line: #D8D0C0;
  --line-dark: rgba(248,246,241,0.16);
  --radius: 4px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--sillar);
  color: var(--ink);
  font-family: 'Inter', sans-serif;
  line-height: 1.5;
}

h1, h2, h3, .display {
  font-family: 'Fraunces', serif;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0;
}

a { color: inherit; }

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---- Header ---- */
header.site {
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}
header.site .wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 18px;
  padding-bottom: 18px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand .mark {
  width: 38px;
  height: 38px;
  border-radius: 2px;
  background: var(--sierra);
  color: var(--paper);
  font-family: 'Fraunces', serif;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.brand .info { display: flex; flex-direction: column; }
.brand .name {
  font-family: 'Fraunces', serif;
  font-size: 1.25rem;
  line-height: 1.1;
}
.brand .tagline {
  font-size: 0.8rem;
  color: var(--ink-soft);
}
.cta-header {
  background: var(--cantera);
  color: var(--paper);
  padding: 11px 20px;
  border-radius: var(--radius);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
}
.cta-header:hover { background: var(--cantera-dark); }

/* ---- Hero ---- */
.hero {
  position: relative;
  background: linear-gradient(160deg, var(--ink-deep) 0%, var(--sierra-dark) 100%);
  color: var(--paper);
  padding: 72px 0 0;
  overflow: hidden;
}
.hero .wrap { position: relative; z-index: 2; }
.hero .skyline {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: auto;
  z-index: 1;
  opacity: 0.5;
}
.hero h1 {
  font-size: clamp(2.1rem, 4.4vw, 3.4rem);
  max-width: 15ch;
  line-height: 1.08;
  color: var(--paper);
}
.hero p.lede {
  margin-top: 18px;
  max-width: 50ch;
  color: rgba(248,246,241,0.75);
  font-size: 1.08rem;
}

/* ---- Filters ---- */
.filters {
  display: flex;
  gap: 10px;
  margin-top: 30px;
  flex-wrap: wrap;
  position: relative;
  z-index: 2;
}
.filters button {
  font-family: 'Inter', sans-serif;
  background: transparent;
  border: 1px solid var(--line-dark);
  color: rgba(248,246,241,0.85);
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 0.85rem;
  cursor: pointer;
}
.filters button.active {
  background: var(--cantera);
  border-color: var(--cantera);
  color: var(--paper);
}

/* ---- Filtros secundarios (tipo, ciudad, orden) ---- */
.filters-extra {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
  position: relative;
  z-index: 2;
}
.filters-extra select {
  font-family: 'Inter', sans-serif;
  background: rgba(248,246,241,0.08);
  border: 1px solid var(--line-dark);
  color: var(--paper);
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  cursor: pointer;
}
.filters-extra select option { color: var(--ink); }

/* ---- Trust strip ---- */
.trust-strip {
  position: relative;
  z-index: 2;
  margin-top: 44px;
  padding: 22px 0;
  border-top: 1px solid var(--line-dark);
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
}
.trust-strip .item {
  font-size: 0.85rem;
  color: rgba(248,246,241,0.75);
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.trust-strip .item strong {
  font-family: 'Fraunces', serif;
  font-size: 1.3rem;
  color: var(--paper);
  font-weight: 500;
}

/* ---- Property grid ---- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 26px;
  padding: 48px 0 80px;
}
.grid > * { min-width: 0; }
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 28px rgba(28,35,32,0.12);
  border-color: transparent;
}
.card .photo {
  position: relative;
  width: 100%;
  padding-top: 75%; /* fuerza proporción 4:3 sin importar el tamaño real de la foto */
  overflow: hidden;
}
.card .photo > img,
.card .photo > svg {
  position: absolute;
}
.card .photo img {
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.card .photo.wash-venta { background: var(--cantera-wash); }
.card .photo.wash-renta { background: var(--sierra-wash); }
.card .photo svg {
  top: 50%;
  left: 50%;
  width: 46%;
  height: 46%;
  transform: translate(-50%, -50%);
  transition: transform 0.25s ease;
}
.card:hover .photo svg { transform: translate(-50%, -50%) scale(1.06); }
.card .photo.wash-venta svg { color: var(--cantera-dark); }
.card .photo.wash-renta svg { color: var(--sierra-dark); }
.card .badge {
  position: absolute;
  top: 12px;
  left: 12px;
  color: var(--paper);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 4px 11px;
  border-radius: 999px;
  text-transform: lowercase;
  letter-spacing: 0.02em;
}
.card .badge.venta { background: var(--cantera); }
.card .badge.renta { background: var(--sierra); }
.card .body { padding: 20px; flex: 1; display: flex; flex-direction: column; }
.card .zona { font-size: 0.8rem; color: var(--ink-soft); }
.card h3 { font-size: 1.15rem; margin-top: 5px; }
.card .precio-row {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.card .precio {
  font-family: 'Fraunces', serif;
  font-size: 1.25rem;
  color: var(--cantera-dark);
}
.card .precio .unidad { font-family: 'Inter', sans-serif; font-size: 0.72rem; color: var(--ink-soft); font-weight: 400; }
.card .specs {
  font-size: 0.8rem;
  color: var(--ink-soft);
  margin-top: 6px;
}

/* ---- Property detail ---- */
.detail {
  padding: 40px 0 80px;
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 48px;
}
.detail > * {
  /* Por defecto, un item de grid no se encoge más allá del ancho de su
     contenido (min-width: auto) — si la descripción trae una palabra o
     URL muy larga sin espacios, esto puede inflar toda la columna y con
     ella la foto que está al 100% de su ancho. Esto lo desactiva. */
  min-width: 0;
}
@media (max-width: 820px) {
  .detail { grid-template-columns: 1fr; }
}
.gallery-wrap { position: relative; }
.gallery-arrow {
  display: none;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(28,35,32,0.55);
  color: var(--paper);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  z-index: 3;
  transition: background 0.15s ease;
}
.gallery-arrow:hover { background: rgba(28,35,32,0.8); }
.gallery-arrow.prev { left: 12px; }
.gallery-arrow.next { right: 12px; }

.detail .gallery-main {
  position: relative;
  width: 100%;
  padding-top: 75%; /* fuerza proporción 4:3 sin importar el tamaño real de la foto */
  border-radius: var(--radius);
  overflow: hidden;
}
.detail .gallery-main.wash-venta { background: var(--cantera-wash); }
.detail .gallery-main.wash-renta { background: var(--sierra-wash); }
.detail .gallery-main img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.detail .gallery-main svg {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 34%;
  height: 34%;
  transform: translate(-50%, -50%);
}
.detail .gallery-main.wash-venta svg { color: var(--cantera-dark); }
.detail .gallery-main.wash-renta svg { color: var(--sierra-dark); }
.detail .thumbs {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  margin-top: 8px;
  overflow-x: auto;
  padding-bottom: 4px; /* espacio para que la barra de scroll no tape las fotos */
}
.detail .thumbs img {
  width: 64px;
  height: 48px;
  flex-shrink: 0;
  object-fit: cover;
  border-radius: 2px;
  cursor: pointer;
  outline: 2px solid transparent;
  outline-offset: 2px;
  transition: outline-color 0.15s ease, opacity 0.15s ease;
  opacity: 0.75;
}
.detail .thumbs img:hover { opacity: 1; }
.detail .thumbs img.active {
  outline-color: var(--cantera);
  opacity: 1;
}
.detail .zona { color: var(--ink-soft); }
.detail h1 { font-size: 1.9rem; margin-top: 6px; }
.detail .precio {
  font-family: 'Fraunces', serif;
  font-size: 2rem;
  color: var(--cantera-dark);
  margin-top: 12px;
}
.info-card {
  margin-top: 20px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 24px;
}
.detail .specs-row {
  display: flex;
  gap: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.detail .specs-row div { font-size: 0.9rem; }
.detail .specs-row strong { display: block; font-size: 1.1rem; }
.detail .descripcion {
  margin-top: 20px;
  color: var(--ink-soft);
  overflow-wrap: break-word;
  word-break: break-word;
}
.detail .amenidades {
  margin-top: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0;
  list-style: none;
}
.detail .amenidades li {
  border: 1px solid var(--line);
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
}
.disclosure {
  margin-top: 24px;
  font-size: 0.78rem;
  color: var(--ink-soft);
}

/* ---- Contact panel ---- */
.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  height: fit-content;
  position: sticky;
  top: 24px;
}
.panel h3 { font-size: 1.1rem; }
.panel .wa-btn {
  display: block;
  text-align: center;
  margin-top: 16px;
  background: var(--sierra);
  color: var(--paper);
  padding: 13px;
  border-radius: var(--radius);
  text-decoration: none;
  font-weight: 500;
}
.panel .wa-btn:hover { background: var(--ink); }
.panel .or {
  text-align: center;
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin: 16px 0;
}

/* ---- Chat widget ---- */
#chat-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 40;
  background: var(--cantera);
  color: var(--paper);
  border: none;
  border-radius: 999px;
  padding: 14px 20px;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  font-size: 0.9rem;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,0.18);
}
#chat-panel {
  position: fixed;
  bottom: 90px;
  right: 24px;
  z-index: 50;
  width: min(340px, 90vw);
  max-height: 480px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: none;
  flex-direction: column;
  box-shadow: 0 12px 28px rgba(0,0,0,0.2);
  overflow: hidden;
}
#chat-panel.open { display: flex; }
#chat-panel .chat-head {
  background: var(--sierra);
  color: var(--paper);
  padding: 14px 16px;
  font-size: 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
#chat-close {
  background: none;
  border: none;
  color: var(--paper);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0 0 12px;
}
#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  font-size: 0.88rem;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.msg { max-width: 85%; padding: 8px 12px; border-radius: 10px; line-height: 1.35; }
.msg.bot { background: var(--sillar); align-self: flex-start; }
.msg.user { background: var(--sierra); color: var(--paper); align-self: flex-end; }
.msg.bot p { margin: 0 0 8px; }
.msg.bot p:last-child { margin-bottom: 0; }
.msg.bot ul { margin: 4px 0 8px; padding-left: 18px; }
.msg.bot ul:last-child { margin-bottom: 0; }
.msg.bot li { margin-bottom: 6px; }
.msg.bot li:last-child { margin-bottom: 0; }
.msg-link {
  display: inline-block;
  margin-left: 4px;
  color: var(--cantera-dark);
  font-weight: 600;
  text-decoration: underline;
  white-space: nowrap;
}
#chat-form {
  display: flex;
  border-top: 1px solid var(--line);
}
#chat-input {
  flex: 1;
  border: none;
  padding: 12px;
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  background: transparent;
}
#chat-input:focus { outline: none; }
#chat-form button {
  border: none;
  background: var(--cantera);
  color: var(--paper);
  padding: 0 18px;
  cursor: pointer;
  font-weight: 500;
}

footer.site {
  border-top: 1px solid var(--line);
  padding: 24px 0;
  font-size: 0.82rem;
  color: var(--ink-soft);
}
