/* ==========================================================================
   Cotiza: la libreta de cuero se abre sobre el escritorio y sus hojas
   son el formulario. Solo se carga en cotiza.html.
   ========================================================================== */

.cotiza {
  position: fixed; z-index: 25;
  inset: 4.9rem 0 calc(var(--barra) + env(safe-area-inset-bottom, 0px) + 1.1rem) 0;
  display: grid; place-items: center;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  perspective: 2200px;
  pointer-events: none;
}
.cotiza:focus { outline: none; }

/* ---------- La libreta ---------- */
.libreta {
  --renglon: 1.875rem;
  --papel-hoja: #f5eedc;
  --papel-hoja-2: #efe5cd;
  --linea: rgba(64, 92, 128, .17);
  position: relative;
  width: min(max(44rem, 60vw), 68rem, calc(100vw - 2rem));
  height: min(100%, 47rem);
  pointer-events: auto;
  /* tapa de cuero negro, como la de la foto */
  padding: .7rem;
  border-radius: 10px 12px 12px 10px;
  background:
    radial-gradient(120% 80% at 30% 0%, rgba(255, 255, 255, .07), transparent 60%),
    linear-gradient(180deg, #23262c, #15171b);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, .08) inset,
    0 0 0 1px rgba(0, 0, 0, .55),
    0 38px 60px -26px rgba(0, 0, 0, .85),
    0 12px 24px -10px rgba(0, 0, 0, .55);
  transform: rotateX(4deg);
  transform-origin: 50% 100%;
  animation: libreta-abre .9s cubic-bezier(.2, .7, .2, 1) both;
}
@keyframes libreta-abre {
  from { opacity: 0; transform: rotateX(18deg) translateY(30px) scale(.94); }
}

.libreta__hojas {
  position: relative; height: 100%;
  display: grid; grid-template-columns: 1fr 1fr;
  border-radius: 3px;
  /* canto de las hojas apiladas */
  box-shadow: 0 2px 0 #e3d8bd, 0 4px 0 #d8ccaf, 0 5px 0 #c9bc9d, 0 7px 6px -2px rgba(0, 0, 0, .5);
}

.hoja {
  position: relative; min-height: 0;
  overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: rgba(27, 42, 65, .3) transparent;
  padding: calc(var(--renglon) * 1.2) clamp(1.3rem, 2.6vw, 2.4rem) calc(var(--renglon) * 1.4);
  color: var(--tinta);
  /* renglones suaves que avanzan con el texto */
  background:
    repeating-linear-gradient(to bottom, transparent 0 calc(var(--renglon) - 1px), var(--linea) calc(var(--renglon) - 1px) var(--renglon)) 0 calc(var(--renglon) * 1.2) / 100% 100% local,
    linear-gradient(var(--papel-hoja), var(--papel-hoja-2)) local;
}
.hoja--izq {
  border-radius: 3px 0 0 3px;
  box-shadow: inset -26px 0 30px -22px rgba(60, 40, 15, .38), inset 0 0 40px rgba(120, 90, 40, .08);
}
.hoja--der {
  border-radius: 0 3px 3px 0;
  box-shadow: inset 26px 0 30px -22px rgba(60, 40, 15, .38), inset 0 0 40px rgba(120, 90, 40, .08);
  perspective: 1600px;
}
/* lomo: el pliegue central */
.libreta__hojas::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; margin-left: -1px;
  background: linear-gradient(rgba(70, 50, 25, .35), rgba(70, 50, 25, .2));
  pointer-events: none;
}

/* Cinta marcapáginas */
.libreta__cinta {
  position: absolute; z-index: 3; top: -.2rem; right: 1.35rem;
  width: .62rem; height: calc(100% + 2.6rem);
  background: linear-gradient(90deg, #5d1b25, #8a2b38 45%, #6c2029);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% calc(100% - .55rem), 0 100%);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .1);
  filter: drop-shadow(1px 2px 2px rgba(0, 0, 0, .35));
  pointer-events: none;
}

/* Lápiz al costado */
.libreta__lapiz {
  position: absolute; z-index: 3;
  right: -3.4rem; top: 8%;
  width: 1.55rem; height: auto;
  transform: rotate(5deg);
  filter: drop-shadow(-4px 10px 6px rgba(0, 0, 0, .45));
  pointer-events: none;
}

/* ---------- Hoja izquierda ---------- */
.hoja h1 { font-size: clamp(2rem, 1.5rem + 1.3vw, 2.6rem); line-height: var(--renglon); padding-top: .35rem; margin-bottom: calc(var(--renglon) * .5); }
.hoja .panel__volver { margin-bottom: calc(var(--renglon) * .5); }
.hoja__entrada { font-size: 1.08rem; line-height: var(--renglon); color: var(--tinta-suave); }
.pasos { list-style: none; margin: var(--renglon) 0 0; padding: 0; }
.pasos li { display: flex; align-items: center; gap: .7rem; line-height: var(--renglon); }
.pasos span {
  flex: none; display: grid; place-items: center;
  width: 1.45rem; height: 1.45rem; border-radius: 50%;
  border: 1.5px solid var(--verde); color: var(--verde);
  font-size: .78rem; font-weight: 700;
}
.hoja__otra { margin-top: var(--renglon); font-family: var(--serif); font-size: 1.25rem; line-height: var(--renglon); }
.hoja__contactos { display: grid; line-height: var(--renglon); }
.hoja__contactos a { color: var(--verde); font-weight: 600; text-decoration: none; justify-self: start; }
.hoja__contactos a:hover { text-decoration: underline; }
.hoja__firma {
  display: flex; align-items: center; gap: .8rem;
  margin-top: calc(var(--renglon) * 1.5);
  color: var(--tinta-suave); font-size: .92rem; line-height: 1.35;
}
.hoja__firma span[data-sello] { flex: none; width: 3.3rem; color: var(--tinta); opacity: .85; }
.hoja__firma svg { width: 100%; height: auto; }
.hoja__firma small { font-size: .82rem; }

/* ---------- Paso 1: teclas ---------- */
.paso1 {
  position: absolute; inset: 0; z-index: 2;
  overflow-y: auto;
  padding: calc(var(--renglon) * 1.2) clamp(1.3rem, 2.6vw, 2.4rem) var(--renglon);
  background: inherit;
  background-attachment: local;
  box-shadow: inherit;
  border-radius: inherit;
  transform-origin: 0 50%;
  backface-visibility: hidden;
}
.paso1 h2, .formulario h2, .recibo h2 { font-size: clamp(1.45rem, 1.15rem + .8vw, 1.8rem); line-height: var(--renglon); padding-top: .35rem; margin-bottom: calc(var(--renglon) * .6); }
.teclas { display: grid; gap: .7rem; }
.tecla {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  min-height: 3.3rem; padding: .7rem 1.1rem;
  border: 0; border-radius: 7px; cursor: pointer; text-align: left;
  font-size: 1.03rem; font-weight: 600; line-height: 1.2;
  color: #eef0f3;
  background: linear-gradient(180deg, #343841, #22252b);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, .14) inset,
    0 -2px 0 rgba(0, 0, 0, .35) inset,
    0 3px 0 #0d0f12,
    0 7px 12px -6px rgba(0, 0, 0, .55);
  transition: transform .12s ease, box-shadow .12s ease, background .2s;
}
.tecla::after { content: "→"; content: "→" / ""; color: var(--laton-claro); font-weight: 400; transition: transform .2s; }
.tecla:hover { background: linear-gradient(180deg, #3c414b, #272a31); }
.tecla:hover::after { transform: translateX(3px); }
.tecla:active, .tecla.es-pulsada {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .1) inset, 0 0 0 #0d0f12, 0 3px 6px -4px rgba(0, 0, 0, .5);
}
.tecla:focus-visible { box-shadow: var(--foco); }
.lema {
  margin-top: calc(var(--renglon) * 1.1);
  font-family: var(--serif); font-size: 1.28rem; line-height: var(--renglon);
  color: var(--verde);
}

/* La hoja se pasa hacia la izquierda */
.paso1.es-pasada { animation: hoja-pasa .85s cubic-bezier(.45, .05, .35, 1) forwards; pointer-events: none; }
@keyframes hoja-pasa {
  0%   { transform: rotateY(0); box-shadow: inset 26px 0 30px -22px rgba(60, 40, 15, .38); }
  60%  { opacity: 1; }
  100% { transform: rotateY(-100deg); opacity: 0; box-shadow: -30px 0 40px rgba(0, 0, 0, .25); }
}
.paso1.es-oculta { display: none; }
/* Mientras está la hoja del paso 1, la del formulario (debajo) no se desplaza */
.hoja--der:has(> .paso1:not(.es-oculta)) { overflow: hidden; }

/* ---------- Paso 2: formulario ---------- */
.formulario__nota { font-size: .85rem; color: var(--tinta-suave); line-height: var(--renglon); }
.req { color: #8e2433; }
.opc { font-weight: 400; color: var(--tinta-suave); font-size: .85em; }

.campo { margin: 0 0 .55rem; padding: 0; border: 0; min-width: 0; }
.campo label, .campo legend {
  display: block; padding: 0;
  font-size: .86rem; font-weight: 700; letter-spacing: .01em; line-height: 1.3;
  margin-bottom: .1rem; padding-top: .45rem;
}
.campo input[type="text"], .campo input[type="tel"], .campo input[type="email"], .campo select, .campo textarea {
  display: block; width: 100%;
  padding: .3rem .1rem .25rem;
  border: 0; border-bottom: 1.5px solid rgba(27, 42, 65, .38);
  border-radius: 0;
  background: transparent;
  font: 500 1.02rem/1.4 var(--sans); color: var(--tinta);
  transition: border-color .2s, background-color .2s;
}
.campo textarea { resize: vertical; min-height: 5.5rem; line-height: var(--renglon); padding-top: 0; background: transparent; }
.campo select { cursor: pointer; appearance: auto; }
.campo input::placeholder, .campo textarea::placeholder { color: rgba(60, 76, 102, .5); }
.campo input:focus, .campo select:focus, .campo textarea:focus {
  outline: none; box-shadow: none;
  border-bottom-color: var(--verde); background: rgba(46, 94, 78, .06);
}
.campo.es-invalido input, .campo.es-invalido select { border-bottom-color: #8e2433; }
.campo__error { min-height: 0; font-size: .84rem; line-height: 1.35; color: #8e2433; }
.campo__error:not(:empty) { margin-top: .2rem; }

.fichas { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .35rem; }
.fichas label { margin: 0; padding: 0; font-weight: 500; }
.fichas input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.fichas span {
  display: inline-block; padding: .38rem .75rem; border-radius: 999px; cursor: pointer;
  border: 1.5px solid rgba(27, 42, 65, .3); font-size: .88rem; line-height: 1.2;
  background: rgba(255, 255, 255, .35);
  transition: background .2s, color .2s, border-color .2s;
}
.fichas span:hover { border-color: var(--tinta); }
.fichas input:checked + span { background: var(--tinta); border-color: var(--tinta); color: var(--papel-claro); }
.fichas input:focus-visible + span { box-shadow: var(--foco); }

.casillas { display: grid; gap: .15rem; margin-top: .3rem; }
.casillas label {
  display: flex; align-items: flex-start; gap: .55rem;
  margin: 0; padding: .2rem 0; font-size: .96rem; font-weight: 500; line-height: 1.35; cursor: pointer;
}
.casillas input { flex: none; width: 1.05rem; height: 1.05rem; margin: .12rem 0 0; accent-color: var(--verde); }

.trampa { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.privacidad { margin-top: .9rem; font-size: .85rem; color: var(--tinta-suave); line-height: 1.4; }
.formulario__acciones { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: .8rem; }
.formulario__acciones .boton { flex: 1 1 auto; }
.formulario__acciones .boton[disabled] { opacity: .65; cursor: progress; }
.formulario__falla {
  margin-top: 1rem; padding: .8rem .9rem;
  border-left: 3px solid #8e2433; background: rgba(142, 36, 51, .07);
  font-size: .93rem; line-height: 1.45;
}
.formulario__falla .boton { margin-top: .6rem; }

/* ---------- Recibo y timbre ---------- */
.recibo { position: relative; }
.recibo:focus { outline: none; }
.recibo__fecha { font-size: .85rem; color: var(--tinta-suave); line-height: var(--renglon); text-align: right; }
.recibo__datos { margin: 0; display: grid; grid-template-columns: auto 1fr; column-gap: .9rem; }
.recibo__datos dt { font-size: .8rem; font-weight: 700; color: var(--tinta-suave); line-height: var(--renglon); }
.recibo__datos dd { margin: 0; font-size: .95rem; line-height: var(--renglon); overflow-wrap: anywhere; }
.recibo__gracias { margin-top: var(--renglon); font-family: var(--serif); font-size: 1.3rem; line-height: var(--renglon); }
.recibo__correo { margin-top: .6rem; font-size: .88rem; color: var(--tinta-suave); line-height: 1.45; }
.recibo__correo a { color: var(--verde); font-weight: 600; }
.recibo > .boton { margin-top: 1.1rem; }

.timbre {
  position: relative; z-index: 2;
  width: min(17rem, 82%);
  margin: -.4rem auto -.6rem;
  color: #8a1f30;
  opacity: .9;
  mix-blend-mode: multiply;
  transform: rotate(-7deg);
  pointer-events: none;
}
.timbre svg { width: 100%; height: auto; overflow: visible; }
.timbre.es-estampado { animation: timbre-golpe .55s cubic-bezier(.3, 1.4, .5, 1) both; }
@keyframes timbre-golpe {
  0%   { opacity: 0; transform: rotate(-11deg) scale(1.9); }
  55%  { opacity: .95; transform: rotate(-11deg) scale(.93); }
  100% { opacity: .9; transform: rotate(-7deg) scale(1); }
}
.libreta.es-golpe { animation: libreta-golpe .35s ease .28s; }
@keyframes libreta-golpe {
  0%, 100% { transform: rotateX(4deg); }
  35% { transform: rotateX(4deg) translateY(3px); }
}

/* ---------- Celular y pantallas angostas: una sola hoja ---------- */
@media (max-width: 56rem) {
  .libreta__hojas { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .libreta__hojas::after { display: none; }
  .hoja--izq {
    overflow: visible;
    padding: .9rem 1.2rem .4rem;
    border-radius: 3px 3px 0 0;
    box-shadow: inset 0 -1px 0 rgba(70, 50, 25, .2);
  }
  .hoja--izq .panel__volver { margin-bottom: .2rem; }
  .hoja--izq h1 { font-size: 1.65rem; margin: 0; padding: 0; }
  .hoja__extra { display: none; }
  .hoja--der { border-radius: 0 0 3px 3px; box-shadow: inset 0 0 40px rgba(120, 90, 40, .08); padding-left: 1.2rem; padding-right: 1.2rem; }
  .paso1 { padding-left: 1.2rem; padding-right: 1.2rem; }
  .libreta__lapiz { display: none; }
  .libreta__cinta { right: .75rem; height: calc(100% + 1rem); }
}
[data-disposicion="retrato"] .cotiza {
  /* una franja del escritorio queda visible arriba */
  inset: max(8.5rem, 22dvh) 0 calc(var(--barra) + env(safe-area-inset-bottom, 0px) + .4rem) 0;
  align-items: stretch;
}
[data-disposicion="retrato"] .libreta {
  width: calc(100vw - 1rem); height: 100%;
  padding: .45rem;
  transform: none;
  transform-origin: 50% 100%;
}
[data-disposicion="retrato"] .libreta.es-golpe { animation: none; }
@media (max-height: 40rem) and (min-width: 56.01rem) {
  .cotiza { inset-block-start: 4.2rem; }
  .libreta { height: 100%; }
}

/* ---------- Salida y versión quieta ---------- */
.saliendo .cotiza { opacity: 0; transition: opacity .3s; }
[data-movimiento="no"] .libreta { animation: none; }
[data-movimiento="no"] .paso1.es-pasada { animation: none; display: none; }
[data-movimiento="no"] .timbre.es-estampado { animation: none; }
[data-movimiento="no"] .libreta.es-golpe { animation: none; }
[data-movimiento="no"] .tecla { transition: none; }
