/* ============================================================
   CHD CONSTRUCCIONES - CONTACTO (pages/contacto.php)
   Se carga después de chd-base.css (tokens, header, tema, footer
   y apariciones). Aquí va solo lo propio de la página.

   - Encabezado: título, estado de atención en vivo y canales
     directos a la izquierda; una obra real a la derecha.
   - Formulario guiado sobre una franja tintada, con la vista
     previa del mensaje fija al costado.
   - Mapa a todo el ancho con la tarjeta "Visítenos" encima.
   ============================================================ */

.page-contacto main { padding-top: var(--h-header-h); }

/* ══════════════════════════════════════════
   ENCABEZADO
══════════════════════════════════════════ */
.ct-intro {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 40px;
  align-items: start;
  padding-top: clamp(48px, 6vw, 88px);
  padding-bottom: clamp(72px, 9vw, 128px);
}
.ct-intro__text { grid-column: 1 / 7; }
.ct-intro__title {
  font-size: clamp(2.75rem, 6vw, 5.25rem);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.045em;
  color: var(--h-heading);
  max-width: 11ch;
  text-wrap: balance;
}
.ct-intro .ch-lead { margin-top: clamp(24px, 2.6vw, 32px); max-width: 44ch; }

.ct-intro__media {
  grid-column: 8 / 13;
  margin: 0;
  aspect-ratio: 4 / 5;
  border-radius: var(--h-r-media);
  background: var(--h-tint);
}
.ct-intro__media img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ── Estado de atención (real: depende de la hora en Costa Rica) ── */
.ct-status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 28px;
  font-size: 15px;
  font-weight: 500;
  color: var(--h-text);
}
.ct-status__dot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: var(--h-line-strong);
}
.ct-status.is-open .ct-status__dot {
  background: var(--h-accent);
  box-shadow: 0 0 0 0 var(--h-accent);
  animation: ctPulse 2.4s var(--h-ease-out) infinite;
}
.ct-status.is-open { color: var(--h-heading); }
@keyframes ctPulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--h-accent) 45%, transparent); }
  70%  { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* ── Canales directos ── */
.ct-channels {
  list-style: none;
  margin-top: clamp(36px, 4vw, 52px);
  border-top: 1px solid var(--h-line);
}
.ct-channels li { border-bottom: 1px solid var(--h-line); }
.ct-channel {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 18px 4px;
  color: inherit;
  text-decoration: none;
}
.ct-channel > i:first-child { font-size: 18px; color: var(--h-accent-text); text-align: center; }
.ct-channel__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ct-channel__label { font-size: 13px; color: var(--h-muted); }
.ct-channel__value {
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--h-heading);
  font-variant-numeric: tabular-nums;
  text-decoration: none;
  overflow-wrap: anywhere;
}
.ct-channel__go {
  font-size: 14px;
  color: var(--h-muted);
  transition: transform 0.3s var(--h-ease-out), color 0.2s;
}
a.ct-channel:hover .ct-channel__go { transform: translateX(4px); color: var(--h-heading); }
a.ct-channel:hover .ct-channel__value,
.ct-channel--mail a.ct-channel__value:hover {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
}

.ct-copy {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--h-line);
  border-radius: var(--h-r-control);
  background: var(--h-surface);
  color: var(--h-heading);
  font-family: var(--h-font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}
.ct-copy i { font-size: 13px; color: var(--h-muted); }
.ct-copy:hover { border-color: var(--h-line-strong); }
.ct-copy:active { transform: scale(0.98); }
.ct-copy.is-done { color: var(--h-accent-text); border-color: var(--h-accent); }
.ct-copy.is-done i { color: var(--h-accent-text); }

/* ══════════════════════════════════════════
   FORMULARIO GUIADO
══════════════════════════════════════════ */
.ct-form-section {
  background: var(--h-tint);
  padding-block: var(--h-space-t) var(--h-space-b);
  transition: background-color 0.3s;
}
.ct-form-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 40px;
  align-items: start;
}
.ct-form-side {
  grid-column: 1 / 6;
  position: sticky;
  top: calc(var(--h-header-h) + 32px);
}
.ct-form-side .ch-h2 { max-width: 12ch; }
.ct-form-side__text {
  margin-top: 20px;
  font-size: 16px;
  line-height: 1.65;
  color: var(--h-text);
  max-width: 42ch;
}

/* Vista previa: burbuja de chat con el texto final */
.ct-preview { margin-top: clamp(32px, 4vw, 48px); }
.ct-preview__label { font-size: 13px; font-weight: 500; color: var(--h-muted); margin-bottom: 10px; }
.ct-preview__bubble {
  max-width: 420px;
  padding: 16px 18px;
  border: 1px solid var(--h-line);
  border-radius: var(--h-r-media) var(--h-r-media) var(--h-r-media) 4px;
  background: var(--h-surface);
  transition: background-color 0.3s;
}
.ct-preview__empty { font-size: 15px; color: var(--h-muted); }
.ct-preview__from { font-size: 13px; font-weight: 600; color: var(--h-accent-text); margin-bottom: 4px; }
.ct-preview__text {
  font-size: 15px;
  line-height: 1.55;
  color: var(--h-heading);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  animation: fadeIn 0.2s both;
}

.ct-form {
  grid-column: 7 / 13;
  display: grid;
  gap: 28px;
  padding: clamp(24px, 3vw, 40px);
  border: 1px solid var(--h-line);
  border-radius: var(--h-r-media);
  background: var(--h-surface);
  transition: background-color 0.3s;
}

/* ── Preguntas con opciones ── */
.ct-q { border: 0; padding: 0; margin: 0; min-width: 0; }
.ct-q[hidden] { display: none; }
.ct-q__title {
  padding: 0;
  margin-bottom: 12px;
  font-size: 15px;
  font-weight: 600;
  color: var(--h-heading);
}
.ct-options { display: flex; flex-wrap: wrap; gap: 8px; }
.ct-option { position: relative; display: flex; cursor: pointer; }
.ct-option input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.ct-option span {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--h-line);
  border-radius: var(--h-r-control);
  background: var(--h-bg);
  color: var(--h-text);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.15s;
}
.ct-option:hover span { border-color: var(--h-line-strong); color: var(--h-heading); }
.ct-option:active span { transform: scale(0.98); }
.ct-option input:checked + span { background: var(--h-btn-bg); border-color: var(--h-btn-bg); color: var(--h-btn-fg); }
.ct-option input:focus-visible + span { outline: 2px solid var(--h-accent); outline-offset: 2px; }
.ct-options--seg .ct-option { flex: 1 1 auto; }
.ct-options--seg .ct-option span { flex: 1; justify-content: center; }
.ct-q#qTerreno:not([hidden]) { animation: fadeUp 0.35s var(--h-ease-out) both; }

/* ── Campos ── */
.ct-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.ct-field { display: grid; gap: 6px; align-content: start; }
.ct-field--full { grid-column: 1 / -1; }
.ct-field label { font-size: 13px; font-weight: 500; color: var(--h-text); }
.ct-field__optional { font-weight: 400; color: var(--h-muted); }
.ct-field input,
.ct-field textarea {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--h-line);
  border-radius: var(--h-r-control);
  background: var(--h-bg);
  color: var(--h-heading);
  font-family: var(--h-font);
  font-size: 15px;
  transition: border-color 0.2s;
}
.ct-field textarea {
  height: auto;
  min-height: 132px;
  padding: 12px 14px;
  line-height: 1.5;
  resize: vertical;
}
.ct-field input::placeholder,
.ct-field textarea::placeholder { color: var(--h-muted); }
.ct-field input:hover,
.ct-field textarea:hover { border-color: var(--h-line-strong); }
.ct-field input:focus,
.ct-field textarea:focus { border-color: var(--h-heading); outline: none; }
.ct-field input:focus-visible,
.ct-field textarea:focus-visible { outline: 2px solid var(--h-accent); outline-offset: 1px; }
.ct-field [aria-invalid="true"] { border-color: var(--h-danger); }
.ct-field__error { font-size: 13px; color: var(--h-danger); }
.ct-field__error[hidden] { display: none; }

.ct-form__status {
  padding: 12px 14px;
  border-radius: var(--h-r-control);
  background: var(--h-tint);
  font-size: 14px;
  line-height: 1.5;
}
.ct-form__status[hidden] { display: none; }
.ct-form__status.is-success { color: var(--h-accent-text); }
.ct-form__status.is-error { color: var(--h-danger); }

.ct-form__actions { display: flex; flex-wrap: wrap; gap: 12px; }
.ct-form__actions .ch-btn { flex: 1 1 200px; }
.ct-form__actions .ch-btn:disabled { opacity: 0.7; cursor: progress; }
.ct-form__legal { font-size: 13px; line-height: 1.5; color: var(--h-muted); }
.ct-form__legal a { color: var(--h-text); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.ct-form__legal a:hover { color: var(--h-heading); }
.ct-wa-btn {
  flex: 1 1 200px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 52px;
  padding: 0 24px;
  border: 1px solid var(--h-line-strong);
  border-radius: var(--h-r-control);
  background: transparent;
  color: var(--h-heading);
  font-family: var(--h-font);
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
}
.ct-wa-btn i { font-size: 18px; color: var(--h-accent-text); }
.ct-wa-btn:hover { border-color: var(--h-heading); background: var(--h-tint); }
.ct-wa-btn:active { transform: scale(0.98); }

/* ══════════════════════════════════════════
   UBICACIÓN
══════════════════════════════════════════ */
.ct-map-section { padding-block: var(--h-space-t) var(--h-space-b); }
.ct-map {
  position: relative;
  height: clamp(440px, 46vw, 600px);
  border: 1px solid var(--h-line);
  border-radius: var(--h-r-media);
  overflow: hidden;
  background: var(--h-tint);
}
.ct-map iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  filter: grayscale(0.35) contrast(1.02);
}
.ct-map__card {
  position: absolute;
  left: 24px;
  bottom: 24px;
  width: min(360px, calc(100% - 48px));
  display: grid;
  gap: 8px;
  padding: 24px;
  border: 1px solid var(--h-line);
  border-radius: var(--h-r-media);
  background: var(--h-surface);
  box-shadow: 0 16px 40px rgba(var(--h-shadow), 0.1);
}
.ct-map__title {
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--h-heading);
}
.ct-map__address { font-size: 16px; color: var(--h-text); }
.ct-map__hours { font-size: 14px; color: var(--h-muted); }
.ct-map__card .ch-btn { margin-top: 12px; justify-self: start; }

/* Mapa en tema oscuro: se invierte para no encandilar */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ct-map iframe { filter: invert(0.9) hue-rotate(180deg) saturate(0.6) brightness(0.95); }
}
:root[data-theme="dark"] .ct-map iframe { filter: invert(0.9) hue-rotate(180deg) saturate(0.6) brightness(0.95); }

/* ══════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════ */
@media (max-width: 1024px) {
  .ct-intro__text { grid-column: 1 / 8; }
  .ct-intro__media { grid-column: 8 / 13; }
}

@media (max-width: 900px) {
  .ct-form-side { grid-column: 1 / -1; position: static; }
  .ct-form { grid-column: 1 / -1; }
  .ct-form-side .ch-h2 { max-width: 16ch; }
  .ct-form-grid { gap: 32px; }
  /* Sin columna lateral la vista previa quedaría lejos del formulario;
     el mensaje igual se arma solo al enviarlo */
  .ct-preview { display: none; }
}

@media (max-width: 768px) {
  .ct-intro { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  .ct-intro__text,
  .ct-intro__media { grid-column: auto; }
  .ct-intro__media { aspect-ratio: 4 / 3; order: -1; }
  .ct-intro__title { max-width: 12ch; }

  .ct-fields { grid-template-columns: minmax(0, 1fr); }
  .ct-form { padding: 20px; }

  .ct-map { height: auto; }
  .ct-map__card {
    position: static;
    width: auto;
    border: 0;
    border-top: 1px solid var(--h-line);
    border-radius: 0;
    box-shadow: none;
  }
  .ct-map iframe { height: 320px; }
}

@media (max-width: 560px) {
  .ct-channel__value { font-size: 16px; }
  .ct-channel--mail { grid-template-columns: 24px minmax(0, 1fr); }
  .ct-channel--mail .ct-copy { grid-column: 2; justify-self: start; }
  .ct-options--seg { display: grid; grid-template-columns: minmax(0, 1fr); }
  .ct-form__actions { flex-direction: column; }
  .ct-form__actions .ch-btn,
  .ct-wa-btn { flex: none; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .ct-status.is-open .ct-status__dot { animation: none; }
}
