/* ─────────────────────────────────────────────────────────────────────────
 * property-modal.css
 *
 * "Editorial Split" (1A) layout — Claude Design project "Rediseño modal
 * residencias". Preview and detail are fused into a single view: a hero
 * column (image + location/title/tagline overlay) and a content column
 * (price/status bar, scrollable specs/description/amenities/highlights/
 * walkthrough/agent, fixed CTA row). Same markup at every breakpoint —
 * only the flex-direction and hero sizing change:
 *   < 900px   bottom sheet / centered dialog, panel stacks (hero on top)
 *   >= 900px  centered dialog, panel splits into two columns (hero left)
 * All values reference tokens from css/tokens.css.
 *
 * Architecture:
 *   .pm-overlay          fixed full-screen backdrop
 *     .pm-panel          the inner dialog (role=dialog)
 *       .pm-hero         image column/row with overlay text
 *       .pm-content      price/status bar + scroll area + CTA row
 *
 * States:
 *   .is-open              overlay is visible
 * ─────────────────────────────────────────────────────────────────── */

.pm-overlay {
  position: fixed;
  inset: 0;
  background: color-mix(in oklab, var(--ink), transparent 35%);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: var(--z-modal);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--motion-base) var(--ease-out);
  padding: var(--pad-x) var(--pad-x) 0;
}

.pm-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.pm-panel {
  position: relative;
  width: 100%;
  max-width: 100%;
  height: calc(100dvh - var(--pad-x));
  background: var(--surface);
  border-top-left-radius: var(--radius-2xl);
  border-top-right-radius: var(--radius-2xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform: translateY(100%);
  transition: transform var(--motion-slow) var(--ease-out);
  display: flex;
  flex-direction: column;
}

.pm-overlay.is-open .pm-panel {
  transform: translateY(0);
}

/* ─── Drag handle (visual, mobile bottom sheet only) ─────────────── */
.pm-panel::before {
  content: "";
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 38px;
  height: 4px;
  border-radius: var(--radius-pill);
  background: var(--line-soft);
  z-index: 4;
}

/* ─── Hero (image column/row) ────────────────────────────────────── */
.pm-hero {
  position: relative;
  flex: 0 0 auto;
  aspect-ratio: 16 / 9;
  background: linear-gradient(160deg, var(--bg-deep) 0%, var(--line-soft) 100%);
  overflow: hidden;
  transition: opacity 0.2s ease;
}

.pm-hero svg,
.pm-hero-img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.pm-hero--a { background: var(--grad-a); }
.pm-hero--b { background: var(--grad-b); }
.pm-hero--c { background: var(--grad-c); }

.pm-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgb(31 42 34 / 18%) 0%, rgb(31 42 34 / 0%) 32%, rgb(31 42 34 / 80%) 100%);
  pointer-events: none;
}

.pm-badge {
  position: absolute;
  top: var(--space-4);
  left: var(--space-4);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  font-weight: var(--fw-semibold);
  box-shadow: var(--shadow-sm);
  z-index: 3;
}

.pm-icon-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: none;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: transform var(--motion-fast) var(--ease-out),
              background var(--motion-fast) var(--ease-out);
}
.pm-icon-btn:active { transform: scale(0.95); }

@media (hover: hover) {
  .pm-icon-btn:hover { transform: scale(1.05); background: var(--bg); }
}

.pm-icon-btn:focus-visible {
  outline: 2px solid var(--surface);
  outline-offset: 2px;
  box-shadow: var(--focus-ring), var(--shadow-md);
}
.pm-icon-btn svg { width: 18px; height: 18px; }

.pm-hero .pm-close {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  z-index: 3;
}

/* ─── Header wrapper (hero + top bar, collapses on scroll) ───────── */
.pm-header {
  flex: 0 0 auto;
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.3s ease;
  max-height: 600px;
}

.pm-header.pm-header--collapsed {
  max-height: 0;
  opacity: 0;
}

/* ─── Hero overlay text (stays visible when bg fades) ────────────── */
.pm-hero-info {
  position: absolute;
  left: var(--space-5);
  right: var(--space-5);
  bottom: var(--space-5);
  z-index: 2;
  color: var(--surface);
  transition: color 0.3s ease;
}

.pm-hero-info .pm-kicker {
  color: rgb(255 252 247 / 82%);
  margin-bottom: 6px;
  transition: color 0.3s ease;
}

.pm-hero-info .pm-title {
  color: var(--surface);
  transition: color 0.3s ease;
}

.pm-hero-info .pm-tagline {
  color: rgb(255 252 247 / 88%);
  margin: 0;
  max-width: 440px;
  transition: color 0.3s ease;
}

.pm-kicker {
  display: inline-block;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--accent-2);
  font-weight: var(--fw-semibold);
  margin-bottom: var(--space-2);
}

.pm-title {
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-style: italic;
  font-size: 28px;
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--ink);
  margin: 0 0 var(--space-2);
}

.pm-tagline {
  font-size: var(--text-base);
  line-height: var(--leading-snug);
  color: var(--ink-mute);
  margin: 0;
}

/* ─── Content column ──────────────────────────────────────────────── */
.pm-content {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
}

.pm-top {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
  padding: var(--space-4) var(--pad-x);
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface);
  transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.3s ease;
  max-height: 120px;
  overflow: hidden;
}

.pm-top.pm-top--collapsed {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
}

.pm-top-price {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pm-price-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--ink-faint);
  font-weight: var(--fw-semibold);
}

.pm-price {
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: 26px;
  color: var(--accent);
  letter-spacing: var(--tracking-tight);
  line-height: 1;
}

.pm-top-status {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 12.5px;
  color: var(--ink-mute);
  background: var(--accent-soft);
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  transition: opacity 0.2s ease;
}

.pm-status-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in oklab, var(--accent), transparent 82%);
  flex-shrink: 0;
}

/* ─── Scroll area ─────────────────────────────────────────────────── */
.pm-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: var(--space-5) var(--pad-x) calc(var(--space-8) + env(safe-area-inset-bottom));
}

.pm-scroll::-webkit-scrollbar { width: 9px; }
.pm-scroll::-webkit-scrollbar-thumb { background: var(--line-soft); border-radius: 9px; }
.pm-scroll::-webkit-scrollbar-track { background: transparent; }

.pm-specs {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--space-5);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-2);
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  padding-block: var(--space-4);
}

.pm-specs li {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 2px;
}

.pm-specs b {
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: var(--text-lg);
  color: var(--accent);
  line-height: 1;
}

.pm-specs span {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--ink-faint);
  font-weight: var(--fw-medium);
}

.pm-section {
  padding-block: var(--space-5);
  border-bottom: 1px solid var(--line-soft);
}
.pm-section:last-of-type { border-bottom: none; }

.pm-section-kicker {
  display: inline-block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--accent-2);
  font-weight: var(--fw-semibold);
  font-style: italic;
  margin-bottom: var(--space-3);
  font-family: var(--font-display);
}

.pm-description {
  font-size: var(--text-base);
  line-height: var(--leading-body);
  color: var(--ink);
  margin: 0;
}

/* ─── Especificaciones grid ───────────────────────────────────────── */
.pm-specs-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-2);
}

.pm-spec-card {
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pm-spec-card-label {
  font-size: 10px;
  font-weight: var(--fw-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--ink-faint);
}

.pm-spec-card-value {
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  font-size: var(--text-md);
  color: var(--ink);
}

/* ─── Lo que incluye (amenidades agrupadas) ───────────────────────── */
.pm-amenities {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.pm-amenity-group-title {
  display: block;
  font-size: 12.5px;
  font-weight: var(--fw-bold);
  color: var(--accent);
  margin-bottom: var(--space-2);
}

.pm-features {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-2);
}

.pm-features li {
  position: relative;
  padding-left: 24px;
  font-size: 14.5px;
  line-height: var(--leading-snug);
  color: var(--ink);
}

.pm-features li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  width: 14px;
  height: 8px;
  border-left: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: rotate(-45deg);
  border-radius: 1px;
}

/* ─── Detalles (highlights) ───────────────────────────────────────── */
.pm-highlights {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
}

.pm-hl {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-3);
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
}

.pm-hl-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--ink-faint);
  font-weight: var(--fw-semibold);
}

.pm-hl-value {
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  font-size: var(--text-md);
  color: var(--ink);
}

/* ─── Recorrido ────────────────────────────────────────────────────── */
.pm-walkthrough {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.pm-walkthrough li {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: var(--space-3);
  align-items: start;
  font-size: 14.5px;
  line-height: var(--leading-snug);
  color: var(--ink);
}

.pm-walk-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--surface);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: var(--fw-semibold);
  box-shadow: var(--shadow-accent);
}

/* ─── Agente ───────────────────────────────────────────────────────── */
.pm-agent {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin-top: var(--space-2);
}

.pm-agent-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--surface);
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: 14px;
  letter-spacing: 0.05em;
  box-shadow: var(--shadow-accent);
  flex-shrink: 0;
}

.pm-agent-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pm-agent-text b {
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: var(--text-md);
  color: var(--ink);
}

.pm-agent-text span {
  font-size: 12.5px;
  color: var(--ink-mute);
}

.pm-agent-phone {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-faint);
}

/* ─── CTA row (fixed footer of the content column) ────────────────── */
.pm-cta-row {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-4) var(--pad-x) calc(var(--space-4) + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line-soft);
  background: var(--surface);
}

.pm-btn--full {
  width: 100%;
}

.pm-cta-secondary {
  display: flex;
  gap: var(--space-2);
  justify-content: flex-end;
  margin-left: auto;
}

.pm-cta-secondary .pm-btn {
  flex: 0 0 auto;
  padding: 8px 16px;
  font-size: 12px;
  min-height: 44px;
}

.pm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: var(--radius-pill);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: var(--fw-semibold);
  text-decoration: none;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: background var(--motion-fast) var(--ease-out),
              color var(--motion-fast) var(--ease-out),
              transform var(--motion-fast) var(--ease-out),
              border-color var(--motion-fast) var(--ease-out);
  flex: 1 1 auto;
  min-height: 40px;
  white-space: nowrap;
}

.pm-btn--primary {
  background: var(--accent);
  color: var(--surface);
  box-shadow: var(--shadow-accent);
}
.pm-btn--primary:active { background: var(--accent-active); transform: scale(0.98); }

.pm-btn--primary:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring), var(--shadow-accent);
}

.pm-btn--ghost {
  background: transparent;
  color: var(--accent);
  border-color: var(--accent);
}

.pm-btn--ghost:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* PDF button — matches pm-btn style with download icon */
.pm-btn--pdf {
  background: var(--bg);
  border-color: var(--line-soft);
  color: var(--ink);
  justify-content: center;
}

.pm-download-spinner { display: none; }

@media (hover: hover) {
  .pm-btn--primary:hover { background: var(--accent-hover); }
  .pm-btn--ghost:hover { background: var(--accent-soft); color: var(--accent-active); }
  .pm-btn--pdf:hover { background: var(--accent-soft); color: var(--accent-active); border-color: var(--accent); }
}

.pm-btn--pdf.is-loading .pm-download-icon,
.pm-btn--pdf.is-loading .pm-download-label { display: none; }

.pm-btn--pdf.is-loading .pm-download-spinner {
  display: block;
  animation: pm-spin 0.9s linear infinite;
}
.pm-btn--pdf.is-error { color: var(--danger); }

@keyframes pm-spin {
  to { transform: rotate(360deg); }
}

/* ─── Body scroll lock ───────────────────────────────────────────── */
body.pm-scroll-locked { overflow: hidden; }

/* ─── Tablet (≥ 600px) — centered dialog, still stacked ───────────── */
@media (width >= 600px) {
  .pm-overlay {
    align-items: center;
    padding: var(--space-6);
  }

  .pm-panel {
    max-width: 560px;
    width: 100%;
    height: auto;
    max-height: 90dvh;
    border-radius: var(--radius-2xl);
    transform: translateY(8px) scale(0.98);
  }

  .pm-overlay.is-open .pm-panel {
    transform: translateY(0) scale(1);
  }
  .pm-panel::before { display: none; }

  .pm-hero { aspect-ratio: 16 / 9; }
  .pm-hero-info .pm-title { font-size: 32px; }
  .pm-specs-grid { grid-template-columns: repeat(4, 1fr); }
  .pm-features { grid-template-columns: 1fr 1fr; }
}

/* ─── Desktop (≥ 900px) — Editorial Split: hero + content side by side ── */
@media (width >= 900px) {
  .pm-panel {
    flex-direction: row;
    max-width: 940px;
    height: min(660px, 88dvh);
    max-height: 88dvh;
  }

  .pm-header {
    flex: 0 0 400px;
    max-height: none;
    overflow: hidden;
  }

  .pm-header.pm-header--collapsed {
    max-height: none;
    opacity: 1;
  }

  .pm-hero {
    flex: 0 0 400px;
    aspect-ratio: auto;
    height: 100%;
  }

  .pm-content { min-width: 0; }

  .pm-top.pm-top--collapsed {
    max-height: 120px;
    opacity: 1;
    padding: var(--space-4) var(--pad-x);
  }

  .pm-hero-info { left: var(--space-6); right: var(--space-6); bottom: var(--space-6); }
  .pm-hero-info .pm-title { font-size: 38px; }
  .pm-hero-info .pm-tagline { font-size: 14.5px; }
}

/* ─── Wide desktop (≥ 1024px) ──────────────────────────────────────── */
@media (width >= 1024px) {
  .pm-panel { max-width: 980px; }
  .pm-hero { flex-basis: 420px; }
  .pm-top { padding: var(--space-4) var(--space-6); }
  .pm-scroll { padding: var(--space-5) var(--space-6) var(--space-8); }
  .pm-cta-row { padding: var(--space-4) var(--space-6); }
  .pm-price { font-size: 28px; }
  .pm-specs b { font-size: 20px; }
}

/* ─── Reduced motion ─────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .pm-overlay,
  .pm-panel,
  .pm-icon-btn,
  .pm-btn {
    transition: none;
  }
  .pm-overlay.is-open .pm-panel { transform: none; }
}
