/* =========================================================
   ZARIA · Contact (CONTACT.pdf)
   1. Escena fijada: titular, sobre que se abre con el scroll,
      postal y formulario (contact.js calcula las posiciones).
   2. Postal.
   3. Formulario.
   4. Cierre terracota con la firma trazada.
   Medidas en unidades de diseño (--u, tokens.css).
   ========================================================= */

.page-contact {
  --ct-bg: var(--c-rose);              /* fondo de la portada (#f3e3d8) */
  --ct-bg-final: var(--c-linen);       /* fondo con postal y formulario (#f0e4d9) */
  --ct-ink: #3a1a0e;
  --ct-brown: #4a3026;                 /* títulos de la postal y del formulario */
  --ct-paper: #f5ede5;                 /* papel de la postal */
  --ct-field: #f3e9e0;                 /* fondo de los campos */
  --ct-line: #8f7466;                  /* línea inferior de los campos */
  --ct-btn: #8b4735;                   /* botón del formulario */
  background: var(--ct-bg);
}

/* =========================================================
   1 · ESCENA
   ========================================================= */
.ct-scene {
  position: relative;
  background: var(--ct-bg);
  color: var(--ct-ink);
}

/* ---------- Titular ---------- */
.ct-title {
  display: flex; flex-direction: column; align-items: center;
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 700;
  font-size: calc(68 * var(--u));
  line-height: 1.04;
  letter-spacing: -.005em;
  text-align: center;
  color: var(--ct-ink);
}
.ct-title__line--em { color: var(--c-terracotta); }

/* ---------- Indicación ---------- */
.ct-hint {
  display: flex; align-items: center; justify-content: center; gap: calc(14 * var(--u));
  font-size: calc(19 * var(--u));
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--c-terracotta);
}
.ct-hint__arrow { font-weight: 300; font-size: 1.25em; line-height: 1; }

/* ---------- Sobre ---------- */
.ct-env { display: none; }
.ct-env__layer { position: absolute; left: 0; top: 0; width: 100%; height: 100%; max-width: none; }
.ct-env__flap {
  height: calc(100% * 790 / 928);
  transform-origin: 50% 0;
  backface-visibility: visible;
}
.ct-env__flap > img { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; }
.ct-env__flap-in { visibility: hidden; }
.ct-env.is-flipped .ct-env__flap-out { visibility: hidden; }
.ct-env.is-flipped .ct-env__flap-in { visibility: visible; }

/* ---------- Estado final: postal | formulario ---------- */
.ct-final {
  display: grid;
  grid-template-columns: calc(423 * var(--u)) calc(408 * var(--u));
  column-gap: calc(107 * var(--u));
  align-items: start;
  padding-left: calc(234 * var(--u));
}
.ct-card-slot { position: relative; }
.ct-form-wrap { padding-top: calc(43 * var(--u)); }

/* ---------- Sin animación (sin JS o movimiento reducido) ---------- */
html:not(.ct-motion) .ct-intro { padding: calc(150 * var(--u)) 0 calc(72 * var(--u)); }
html:not(.ct-motion) .ct-env-slot,
html:not(.ct-motion) .ct-hint { display: none; }
html:not(.ct-motion) .ct-final { padding-bottom: calc(110 * var(--u)); }

/* ---------- Con animación: escena fijada ----------
   La sección mide una pantalla más el recorrido de la apertura
   (--ct-run). Su contenido queda fijo mientras dura. */
.ct-motion .ct-scene { --ct-run: 150vh; height: calc(100vh + var(--ct-run)); }
.ct-motion .ct-scene__pin {
  position: sticky; top: 0;
  height: 100vh;
  overflow: hidden;
  background: var(--ct-bg);
}
.ct-motion .ct-intro {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  /* Sobre: ocupa el alto que deja el resto (con tope en el tamaño del PDF) */
  --ct-fixed: calc(339 * var(--u));
  padding-bottom: calc(6 * var(--u));
}
.ct-motion .ct-env-slot {
  width: min(calc(858 * var(--u)), calc((100vh - var(--ct-fixed)) * 1440 / 928));
  aspect-ratio: 1440 / 928;
  margin: calc(36 * var(--u)) 0 calc(26 * var(--u));
}
.ct-motion .ct-env { display: block; position: absolute; left: 0; top: 0; }
.ct-motion .ct-final {
  position: absolute; inset: 0;
  align-content: center;
}
/* El JS coloca la postal; hasta entonces no se ve */
.ct-motion .ct-card { visibility: hidden; transform-origin: 0 0; will-change: transform; }
.ct-motion .ct-form-wrap { opacity: 0; pointer-events: none; will-change: opacity, transform; }
.ct-motion .ct-form-wrap.is-ready { pointer-events: auto; }
.ct-motion .ct-env__layer { will-change: transform, opacity; }

/* =========================================================
   2 · POSTAL
   ========================================================= */
.ct-card {
  position: relative;
  width: calc(423 * var(--u));
  padding: calc(30 * var(--u)) calc(31 * var(--u)) calc(30 * var(--u));
  background: var(--ct-paper);
  border: 1px solid rgba(114, 87, 75, .16);
  box-shadow: 0 calc(14 * var(--u)) calc(34 * var(--u)) rgba(70, 36, 20, .13),
              0 calc(2 * var(--u)) calc(5 * var(--u)) rgba(70, 36, 20, .07);
  color: var(--ct-brown);
}
.ct-card__head {
  display: flex; justify-content: space-between;
  padding-bottom: calc(10 * var(--u));
  border-bottom: 1px solid #dfd2c7;
  font-size: calc(9 * var(--u));
  font-weight: 700;
  letter-spacing: .16em;
  line-height: calc(13 * var(--u));
  text-transform: uppercase;
  color: #72574b;
}
.ct-card__photo {
  margin: calc(14 * var(--u)) calc(17 * var(--u)) 0;
  aspect-ratio: 1050 / 1312;
  overflow: hidden;
  background: #e6d3c3;
}
.ct-card__photo img { width: 100%; height: 100%; object-fit: cover; }
.ct-card__title {
  margin: calc(22 * var(--u)) calc(17 * var(--u)) 0;
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: calc(44 * var(--u));
  line-height: 1.05;
  letter-spacing: -.05em;
  white-space: nowrap;
  color: var(--ct-brown);
}
.ct-card__title em {
  font-style: italic;
  font-weight: 500;
  letter-spacing: -.02em;
  color: var(--c-terracotta);
}
.ct-card__link {
  display: inline-flex; align-items: center; gap: calc(12 * var(--u));
  margin: calc(10 * var(--u)) calc(17 * var(--u)) 0;
  font-size: calc(13 * var(--u));
  font-weight: 700;
  line-height: calc(18 * var(--u));
  color: var(--ct-ink);
}
.ct-card__link span {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: calc(4 * var(--u));
}
.ct-card__arrow {
  width: calc(14 * var(--u)); height: calc(14 * var(--u));
  fill: none; stroke: currentColor; stroke-width: 1.1;
  border-bottom: 1px solid currentColor;
  padding-bottom: calc(1 * var(--u));
  box-sizing: content-box;
  transition: transform .25s ease;
}
.ct-card__link:hover .ct-card__arrow { transform: translate(calc(2 * var(--u)), calc(-2 * var(--u))); }
.ct-card__link:focus-visible { outline: 2px solid var(--c-terracotta); outline-offset: calc(5 * var(--u)); }

/* =========================================================
   3 · FORMULARIO
   ========================================================= */
.ct-form__kicker {
  font-size: calc(9 * var(--u));
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--c-terracotta);
}
.ct-form__title {
  margin-top: calc(10 * var(--u));
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: calc(64 * var(--u));
  line-height: .95;
  letter-spacing: -.05em;
  color: var(--ct-brown);
}
.ct-form__intro {
  max-width: calc(320 * var(--u));
  margin-top: calc(18 * var(--u));
  font-size: calc(13 * var(--u));
  line-height: calc(20 * var(--u));
  color: rgba(74, 48, 38, .85);
}
.ct-form {
  display: grid;
  grid-template-columns: 214fr 177fr;
  column-gap: calc(17 * var(--u));
  margin-top: calc(14 * var(--u));
}
.ct-field { display: flex; flex-direction: column; min-width: 0; }
.ct-field--full { grid-column: 1 / -1; }
.ct-field label {
  font-size: calc(10.5 * var(--u));
  font-weight: 700;
  line-height: calc(14 * var(--u));
  color: #3d2419;
}
.ct-field input,
.ct-field textarea {
  width: 100%;
  margin-top: calc(6 * var(--u));
  padding: 0 calc(8 * var(--u));
  border: 0;
  border-bottom: 1px solid var(--ct-line);
  border-radius: 0;
  background: var(--ct-field);
  font-family: var(--font-sans);
  font-size: calc(13 * var(--u));
  color: var(--ct-ink);
  transition: border-color .2s ease, background-color .2s ease, box-shadow .2s ease;
}
.ct-field input { height: calc(36 * var(--u)); }
.ct-field textarea {
  height: calc(68 * var(--u));
  padding-top: calc(9 * var(--u));
  line-height: calc(18 * var(--u));
  resize: vertical;
}
.ct-field input::placeholder,
.ct-field textarea::placeholder { color: rgba(74, 48, 38, .6); opacity: 1; }
.ct-field input:focus,
.ct-field textarea:focus {
  outline: none;
  background: #f7efe8;
  border-bottom-color: var(--c-terracotta);
  box-shadow: 0 1px 0 var(--c-terracotta);
}
/* Error: línea y mensaje en terracota */
.ct-field__err {
  min-height: calc(13 * var(--u));
  margin-top: calc(3 * var(--u));
  font-size: calc(9.5 * var(--u));
  font-weight: 500;
  line-height: calc(13 * var(--u));
  color: #a0361a;
}
.ct-field.is-invalid input,
.ct-field.is-invalid textarea { border-bottom-color: #a0361a; box-shadow: 0 1px 0 #a0361a; }

.ct-form__actions { grid-column: 1 / -1; margin-top: calc(4 * var(--u)); }
.ct-form__btn {
  display: inline-flex; align-items: center; gap: calc(26 * var(--u));
  height: calc(38 * var(--u));
  padding: 0 calc(15 * var(--u));
  border: 0;
  border-radius: 0;
  background: var(--ct-btn);
  font-family: var(--font-sans);
  font-size: calc(12 * var(--u));
  font-weight: 700;
  color: #fbf4ee;
  cursor: pointer;
  transition: opacity .2s ease;
}
.ct-form__btn:hover { opacity: .9; }
.ct-form__btn:focus-visible { outline: 2px solid var(--c-terracotta); outline-offset: calc(4 * var(--u)); }
.ct-form__arrow { width: calc(14 * var(--u)); height: calc(14 * var(--u)); fill: none; stroke: currentColor; stroke-width: 1.1; }
/* Información básica de protección de datos (11 nov., 2.ª versión)
   Mínimo 14 px en todos los anchos, texto sólido (contraste ≥ 7:1 sobre
   la postal) e interlineado 1.55. Va en el flujo de la columna del
   formulario: la cuadrícula postal | formulario crece y sigue centrada,
   y contact.js lleva la postal a su hueco como siempre. */
.ct-form__privacy {
  grid-column: 1 / -1;
  margin-top: max(10px, calc(12 * var(--u)));
  font-size: max(14px, calc(14 * var(--u)));
  font-style: italic;
  font-weight: 400;
  line-height: 1.55;
  color: #6b4d3f;   /* marrón apagado de la paleta; contraste ≥ 6:1 sobre el fondo */
}
.ct-form__privacy a { color: #8a3a1c; text-decoration: underline; text-underline-offset: .18em; text-decoration-thickness: 1px; }
.ct-form__privacy a:hover { color: var(--ct-brown); }
.ct-form__privacy a:focus-visible { outline: 2px solid var(--c-terracotta); outline-offset: 2px; }
.ct-form__note {
  margin-top: calc(10 * var(--u));
  font-size: calc(11 * var(--u));
  line-height: calc(14 * var(--u));
  color: rgba(74, 48, 38, .85);
}

/* =========================================================
   4 · CIERRE CON LA FIRMA
   ========================================================= */
.ct-closing {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  column-gap: calc(40 * var(--u));
  min-height: calc(444 * var(--u));
  padding: calc(70 * var(--u)) calc(150 * var(--u)) calc(70 * var(--u)) var(--nav-clear);
  background: var(--c-terracotta);
  color: var(--c-linen);
}
.ct-closing__title {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  font-size: calc(64 * var(--u));
  line-height: 1.12;
  letter-spacing: -.005em;
  color: #f0e4d9;
}
.ct-closing__sig { display: flex; justify-content: flex-end; }
.ct-sig {
  display: block;
  width: calc(600 * var(--u));
  height: auto;
  overflow: visible;
}
.ct-sig__ink { fill: #ecdccd; }

/* =========================================================
   BASE MÓVIL PROVISIONAL (≤ 820 px)
   ========================================================= */
@media (max-width: 1023px) {
  .ct-motion .ct-scene { --ct-run: 120vh; }
  .ct-title { font-size: 36px; }
  .ct-hint { font-size: 13px; }
  .ct-motion .ct-intro { --ct-fixed: 230px; padding: 70px 20px 0; }
  .ct-motion .ct-env-slot { width: min(calc(100vw - 40px), calc((100vh - var(--ct-fixed)) * 1440 / 928)); margin: 24px 0 18px; }

  html:not(.ct-motion) .ct-intro { padding: 96px 20px 40px; }
  .ct-final { grid-template-columns: 1fr; row-gap: 40px; padding: 0 20px 64px; }
  .ct-motion .ct-final { padding-bottom: 0; }
  .ct-card { width: min(100%, 360px); padding: 22px 22px 24px; }
  .ct-card__head { font-size: 9px; }
  .ct-card__photo { margin: 12px 10px 0; }
  .ct-card__title { margin: 18px 10px 0; font-size: 34px; }
  .ct-card__link { margin: 8px 10px 0; font-size: 13px; }
  .ct-form-wrap { padding-top: 0; }
  .ct-form__title { font-size: 44px; }
  .ct-form__intro { font-size: 15px; line-height: 1.5; max-width: none; }
  .ct-form { grid-template-columns: 1fr; }
  .ct-field label { font-size: 13px; }
  .ct-field input { height: 44px; font-size: 16px; }
  .ct-field textarea { height: 96px; font-size: 16px; }
  .ct-field__err { font-size: 12px; min-height: 16px; }
  .ct-form__btn { height: 46px; font-size: 14px; }
  .ct-form__note { font-size: 12px; }
  .ct-form__privacy { margin-top: 12px; font-size: 14px; line-height: 1.55; }

  .ct-closing { grid-template-columns: 1fr; row-gap: 28px; padding: 64px 20px; min-height: 0; }
  .ct-closing__title { font-size: 38px; }
  .ct-sig { width: min(100%, 360px); }
}

/* Movimiento reducido: la firma aparece completa (contact.js no la anima) */
@media (prefers-reduced-motion: reduce) {
  .ct-card__arrow { transition: none; }
}

/* =========================================================
   Revisión 10 nov.: acceso directo al formulario y confirmación
   ========================================================= */
.ct-scene { position: relative; }
.ct-form__status { grid-column: 1 / -1; font-size: max(14px, calc(15 * var(--u))); font-weight: 600; line-height: 1.5; }
.ct-form__status:empty { display: none; }
.ct-form__status:not(:empty) { margin-top: 10px; }

/* =========================================================
   MÓVIL (11 nov.): sobre → postal → pausa → giro → formulario
   contact.js (ct-motion-m): la apertura va ligada al scroll y la
   escena se fija; con la postal fuera y quieta, a los 1,5 s gira
   (estética de las tarjetas de Home: 550–700 ms, sin rebote) y la
   escena se libera (ct-settled): la tarjeta pasa al flujo y su
   reverso es el formulario existente, a la altura de su contenido.
   ========================================================= */
.ct-flip { position: relative; }
@media (max-width: 1023px) {
  .ct-motion-m {
    /* Ancho de la postal: cabe a lo ancho y a lo alto (proporción ≈ 1 : 1,5) */
    --ct-cw: min(calc(100vw - 40px), 360px, calc((100svh - 120px) / 1.5));
  }
  .ct-motion-m .ct-scene { --ct-run: 160svh; height: calc(100svh + var(--ct-run)); }
  .ct-motion-m .ct-scene__pin { height: 100svh; }
  .ct-motion-m .ct-intro { --ct-fixed: 220px; padding: 64px 16px 0; }
  .ct-motion-m .ct-env-slot { width: min(calc(100vw - 32px), calc((100svh - var(--ct-fixed)) * 1440 / 928)); margin: 22px 0 16px; }
  .ct-motion-m .ct-final { grid-template-columns: 1fr; justify-items: center; align-content: center; padding: 48px 20px 16px; }
  .ct-motion-m .ct-card-slot { width: var(--ct-cw); }
  .ct-motion-m .ct-card { width: 100%; }
  .ct-motion-m .ct-card__title { font-size: min(34px, calc(var(--ct-cw) * .095)); }

  /* Tarjeta que gira */
  .ct-motion-m .ct-flip { width: 100%; perspective: 2600px; }
  .ct-motion-m .ct-flip__inner {
    position: relative;
    transform-style: preserve-3d;
    transition: transform 400ms cubic-bezier(.33, 0, .2, 1);   /* 12 nov.: giro ágil (antes 700 ms) */
  }
  .ct-motion-m .ct-flip.is-flipped .ct-flip__inner { transform: rotateY(180deg); }
  .ct-motion-m .ct-flip__inner > .ct-card { -webkit-backface-visibility: hidden; backface-visibility: hidden; }
  .ct-motion-m .ct-flip__back {
    position: absolute; left: 0; top: 0; width: 100%;
    visibility: hidden;
    padding: 26px 22px 28px;
    background: var(--ct-paper);
    border: 1px solid rgba(114, 87, 75, .16);
    box-shadow: 0 14px 34px rgba(70, 36, 20, .13), 0 2px 5px rgba(70, 36, 20, .07);
    transform: rotateY(180deg);
    -webkit-backface-visibility: hidden; backface-visibility: hidden;
  }
  .ct-motion-m .ct-flip__back .ct-form-wrap { opacity: 1; transform: none; pointer-events: auto; padding-top: 0; }
  .ct-motion-m .ct-flip__back .ct-form__title { font-size: min(40px, calc(var(--ct-cw) * .11)); }

  /* Girada (12 nov., 2.ª versión): en el mismo sitio. El reverso
     (formulario) marca la altura de la tarjeta; la postal queda encima,
     en su posición, y desaparece solo por el propio giro. */
  .ct-flipped .ct-flip.is-flipped .ct-flip__back { position: relative; visibility: visible; }
  .ct-flipped .ct-flip.is-flipped .ct-flip__inner > .ct-card { position: absolute; left: 0; top: 0; visibility: visible; }
}
@media (max-width: 1023px) and (prefers-reduced-motion: reduce) {
  .ct-motion-m .ct-flip__inner { transition: none; }
}


/* =========================================================
   TABLET HORIZONTAL Y PORTÁTIL PEQUEÑO (1024–1279 px, 12 nov.)
   La composición de escritorio se escala con la ventana (--u); aquí
   solo se fijan tamaños mínimos legibles y zonas táctiles cómodas
   para textos y controles pequeños. No cambia la composición.
   ========================================================= */
@media (min-width: 1024px) and (max-width: 1279px) {
  .ct-card__link { font-size: max(12.5px, calc(13 * var(--u))); line-height: 1.4; }
  .ct-form__kicker { font-size: max(10.5px, calc(9 * var(--u))); }
  .ct-form__intro { font-size: max(13px, calc(13 * var(--u))); line-height: 1.5; }
  .ct-field label { font-size: max(12px, calc(10.5 * var(--u))); line-height: 1.3; }
  .ct-field input, .ct-field textarea { font-size: max(15px, calc(13 * var(--u))); }
  .ct-field input { height: max(40px, calc(36 * var(--u))); }
  .ct-field__err { font-size: max(11px, calc(9.5 * var(--u))); }
  .ct-form__btn { height: max(42px, calc(38 * var(--u))); font-size: max(13px, calc(12 * var(--u))); }
  .ct-form__note { font-size: max(11.5px, calc(11 * var(--u))); }
}

/* =========================================================
   13 nov. · Logo superior en Contact (escritorio)
   La escena del sobre está centrada en vertical: se reserva arriba el
   hueco del logo y el sobre se reduce en la misma medida (contact.js
   mide las posiciones, así que la animación no cambia).
   ========================================================= */
@media (min-width: 1024px) {
  .ct-motion .ct-intro { padding-top: max(126px, calc(126 * var(--u))); --ct-fixed: calc(339 * var(--u) + max(126px, calc(126 * var(--u)))); }
  html:not(.ct-motion) .ct-intro { padding-top: calc(190 * var(--u)); }
}

/* 13 nov. · Campo trampa del antispam (lo añade contact.js en modo live
   con left:-9999px). Esa posición hacía saltar la página arriba en móvil
   al girar la postal; aquí se coloca en 0,0 recortado a nada: sigue sin
   verse, sin foco (tabindex -1) y oculto a lectores (aria-hidden). */
#ct-form input[name="website"] {
  position: absolute !important;
  left: 0 !important; top: 0 !important;
  width: 1px !important; height: 1px !important;
  padding: 0 !important; border: 0 !important; margin: 0 !important;
  clip-path: inset(50%) !important;
  overflow: hidden !important;
}
