/* =============================================================
   Dos Teclas — hoja única
   Construida sobre el Manual de Identidad Visual v2.0
   ============================================================= */

/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  /* Paleta (manual §07) */
  --ink:        #000000;   /* negro · 60 % */
  --cream:      #F4EFE6;   /* crema · 30 % */
  --red:        #E32424;   /* rojo tecla · 10 % */
  --red-edge:   #8C1010;   /* canto de la tecla roja */

  /* Luz de escena: el negro con un foco central (manual §07, entornos digitales) */
  --scene: radial-gradient(ellipse 75% 70% at 50% 42%, #1a1a1a 0%, #0b0b0b 48%, #000 100%);

  /* Texto: crema sólida o secundaria (80 % / 62 %). Translúcidas bajas: solo filetes */
  --cream-80: rgba(244, 239, 230, .80);
  --cream-62: rgba(244, 239, 230, .62);
  --cream-30: rgba(244, 239, 230, .30);
  --cream-17: rgba(244, 239, 230, .17);
  --cream-08: rgba(244, 239, 230, .08);

  /* Tipografía (manual §08) */
  --sans: "Sora", Arial, sans-serif;
  --mono: "JetBrains Mono", "Courier New", ui-monospace, monospace;

  /* Movimiento: pulsación de 120–180 ms (manual §10) */
  --press: 150ms;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
}

/* =============================================================
   2. Base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }

html { -webkit-text-size-adjust: 100%; overflow-x: clip; background: var(--ink); }

body {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--scene) fixed, var(--ink);
  color: var(--cream);
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
  overscroll-behavior-y: none;
  isolation: isolate;
}

/* Grano de película sobre el foco: quita las franjas del degradado y da textura de foto.
   En «overlay» el negro puro sigue siendo negro; solo vibra donde hay luz. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='.33 .33 .33 0 0 .33 .33 .33 0 0 .33 .33 .33 0 0 0 0 0 0 1'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E") 0 0 / 240px;
  mix-blend-mode: overlay;
  opacity: .7;
}

img, svg { display: block; max-width: 100%; }
img { height: auto; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }
p { text-wrap: pretty; }

::selection { background: var(--cream); color: var(--ink); }

:focus-visible { outline: 2px solid var(--cream); outline-offset: 3px; border-radius: 6px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap; border: 0;
}

.skip-link {
  position: fixed; top: -100px; left: 1rem; z-index: 999;
  padding: .6rem 1rem; border-radius: 8px;
  background: var(--cream); color: var(--ink);
  font-family: var(--mono); font-size: 14px; font-weight: 700; letter-spacing: .02em;
}
.skip-link:focus { top: 1rem; }

/* =============================================================
   3. Escenario — una pantalla, sin scroll
   ============================================================= */
.stage {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: clamp(1.5rem, 4vh, 3rem) 1.25rem clamp(1.25rem, 3vh, 2rem);
  gap: 2rem;
}

.stage__center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
}

/* =============================================================
   4. Logotipo — teclas 3D + nombre (manual §03)
   ============================================================= */
.lockup {
  /* W = ancho de la imagen de las teclas. El nombre mide 1,15 veces las teclas visibles (manual §04). */
  --w: clamp(250px, 24vw, 380px);
  display: flex;
  flex-direction: column;
  align-items: center;
  /* Área de respeto: X = media tecla ≈ 0,2 W (manual §05) */
  margin-block: calc(var(--w) * .2);
}

/* Las dos teclas se apilan en la misma celda; cada copia recorta su mitad.
   En la imagen, el hueco transparente entre teclas va de 382 a 414 px (de 800): el corte cae en 49,5 %. */
.lockup__teclas { position: relative; display: grid; width: var(--w); }
.lockup__teclas picture { display: block; }

/* Luz de la tecla roja: tiñe el fondo a su alrededor. Se enciende cuando la tecla aterriza */
.lockup__teclas::before {
  content: "";
  position: absolute;
  left: 76%; top: 52%;
  width: calc(var(--w) * 1.25);
  aspect-ratio: 1;
  z-index: -2;
  pointer-events: none;
  background: radial-gradient(closest-side, rgba(227, 36, 36, .09), rgba(227, 36, 36, .035) 55%, transparent);
  transform: translate(-50%, -50%);
  animation: fade 1.2s ease-out .6s both;
}

.tecla { grid-area: 1 / 1; display: block; animation: drop 540ms both; }
.tecla--cierre   { --origen: 24% 97%; }
.tecla--apertura { --origen: 76% 97%; animation-delay: 140ms; }

.tecla, .tecla__img { transform-origin: var(--origen); }
.tecla--cierre .tecla__img   { clip-path: inset(0 50.5% 0 0); }
.tecla--apertura .tecla__img { clip-path: inset(0 0 0 49.5%); }

/* Entrada: la tecla cae y, al tocar, se pulsa (manual §10: 120–180 ms) */
@keyframes drop {
  0%   { opacity: 0; transform: translateY(-30%); animation-timing-function: cubic-bezier(.55, 0, .9, .5); }
  30%  { opacity: 1; }
  70%  { transform: none; filter: brightness(1); animation-timing-function: ease-in; }
  84%  { transform: translateY(2.5%) scale(.985); filter: brightness(.86); animation-timing-function: var(--ease-out); }
  100% { opacity: 1; transform: none; filter: brightness(1); }
}

/* Nombre en trazos (logotipo oficial): 1,15 × las teclas visibles, que ocupan el 98,6 % de W (manual §04).
   Los márgenes reproducen la posición que tenía cuando era texto. */
.lockup__nombre {
  width: calc(var(--w) * 1.134);
  max-width: none;
  height: auto;
  margin-top: calc(var(--w) * .042);
  margin-bottom: calc(var(--w) * .023);
  color: var(--cream);
  animation: rise 1s var(--ease-out) .48s both;
}

/* Subtítulo (manual §08): Sora 400, 20–24 px */
.claim {
  max-width: 24ch;
  margin-bottom: clamp(1.75rem, 4.5vh, 2.75rem);
  text-align: center;
  font-size: clamp(20px, 1.6vw, 23px);
  font-weight: 400;
  line-height: 1.35;
  color: var(--cream-80);
  text-wrap: balance;
  animation: rise 1s var(--ease-out) .58s both;
}
.claim__sub { color: var(--cream-62); }

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

/* =============================================================
   5. Caja de consulta
   ============================================================= */
.ask {
  display: flex;
  align-items: center;
  gap: .5rem;
  width: min(100%, 550px);
  height: 60px;
  padding: 0 7px 0 22px;
  border: 1px solid transparent;
  border-radius: 14px;
  background:
    linear-gradient(#0a0a0a, #0a0a0a) padding-box,
    linear-gradient(90deg, var(--cream-17) 0%, var(--cream-17) 55%, rgba(227, 36, 36, .6) 100%) border-box;
  box-shadow: 14px 0 40px -24px rgba(227, 36, 36, .45);
  transition: box-shadow 320ms var(--ease-out);
  animation: rise 1s var(--ease-out) .68s both;
}
.ask:focus-within { box-shadow: 14px 0 44px -18px rgba(227, 36, 36, .6); }

/* Campo de formulario (manual §08): Sora 400 */
.ask__field {
  position: relative;
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  font-family: var(--sans);
  font-size: 18px;
  font-weight: 400;
}

.ask__input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  background: none;
  color: var(--cream);
  caret-color: var(--red);
  font: inherit;
}
.ask__input::placeholder { color: var(--cream-62); }
.ask__input:focus { outline: none; }

/* Frase de ejemplo: se escribe sola encima del campo vacío, con su propio cursor rojo */
.ask__hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  overflow: hidden;
  white-space: pre;
  color: var(--cream-62);
  pointer-events: none;
}
.ask__hint[hidden] { display: none; }
.ask__hint::after {
  content: "";
  flex: none;
  width: 2px;
  height: 1.15em;
  margin-left: 2px;
  border-radius: 1px;
  background: var(--red);
  animation: blink 1.05s steps(1) infinite;
}
.ask__hint.is-typing::after { animation: none; }
/* Con el foco dentro ya parpadea el cursor de verdad */
.ask:focus-within .ask__hint::after { visibility: hidden; }

@keyframes blink { 50% { opacity: 0; } }

/* La tecla roja: pulsación de 150 ms (manual §10). Crema sobre rojo: icono */
.key {
  flex: 0 0 auto;
  width: 46px; height: 46px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--red);
  box-shadow: 0 2px 0 0 var(--red-edge);
  transition: transform var(--press) var(--ease-out), box-shadow var(--press) var(--ease-out);
}
/* Al pasar por encima baja 1 px; al pulsar, hasta el fondo */
.key:focus-visible { transform: translateY(1px); box-shadow: 0 1px 0 0 var(--red-edge); }
@media (hover: hover) {
  .key:hover { transform: translateY(1px); box-shadow: 0 1px 0 0 var(--red-edge); }
}
.key:active { transform: translateY(2px); box-shadow: 0 0 0 0 var(--red-edge); }

.key__svg {
  width: 24px; height: 24px;
  fill: none; stroke: var(--cream);
  stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round;
}

/* =============================================================
   6. Pie
   ============================================================= */
.foot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  animation: rise 1s var(--ease-out) .78s both;
}

.foot__social { display: flex; align-items: center; gap: 1.1rem; list-style: none; padding: 0; }

.foot__social svg {
  width: 22px; height: 22px;
  fill: none; stroke: var(--cream-80);
  stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round;
  transition: stroke var(--press) var(--ease-out), transform var(--press) var(--ease-out);
}
.foot__social .dot { fill: var(--cream-80); stroke: none; }
.foot__social a:hover svg { stroke: var(--cream); transform: translateY(-1px); }
.foot__social a:hover .dot { fill: var(--cream); }

.foot__sep { width: 1px; height: 20px; background: var(--cream-30); }

/* Etiqueta (manual §08): JetBrains Mono 700, mayúsculas, +20 % */
.foot__legal, .foot__copy {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--cream-62);
}
.foot__legal { display: flex; align-items: center; gap: .7rem; }
.foot__legal span { color: var(--cream-30); }
.foot__legal a { transition: color var(--press) var(--ease-out); }
.foot__legal a:hover { color: var(--cream); }

/* =============================================================
   7. Hoja de contacto
   ============================================================= */
.sheet {
  width: min(92vw, 440px);
  margin: auto;
  padding: 0;
  border: 1px solid var(--cream-17);
  border-radius: 18px;
  background: #0a0a0a;
  color: var(--cream);
  box-shadow: 0 60px 140px -50px rgba(0, 0, 0, .9);
}
.sheet::backdrop { background: rgba(0, 0, 0, .9); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.sheet[open] { animation: sheetIn 320ms var(--ease-out) both; }
.sheet[open]::backdrop { animation: fade 320ms var(--ease-out) both; }
@keyframes sheetIn { from { opacity: 0; transform: translateY(18px) scale(.985); } }
@keyframes sheetUp { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

.sheet__body {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: .9rem;
  padding: 2rem 1.75rem 1.4rem;
  max-height: 86dvh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--cream-17) transparent;
}

.sheet__close {
  position: absolute; top: .85rem; right: .85rem;
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 8px;
  transition: background-color var(--press) var(--ease-out);
}
.sheet__close:hover { background: var(--cream-08); }
.sheet__close svg { width: 15px; height: 15px; fill: none; stroke: var(--cream-62); stroke-width: 1.7; stroke-linecap: round; }
.sheet__close:hover svg { stroke: var(--cream); }

.sheet__kicker, .quote__label, .field__label, .done__title {
  font-family: var(--mono);
  font-size: 12px; font-weight: 700;
  letter-spacing: .2em; text-transform: uppercase;
}
.sheet__kicker { color: var(--cream); }
.quote__label, .field__label { color: var(--cream-62); }

/* Titular de apartado (manual §08): Sora 800, 20–24 px, −2 % */
.sheet__lead { margin-top: -.5rem; font-size: 22px; font-weight: 800; letter-spacing: -.02em; line-height: 1.25; }

.quote {
  padding: .85rem 1rem;
  border: 1px solid var(--cream-17);
  border-radius: 12px;
  background: var(--ink);
}
.quote__label { display: block; margin-bottom: .3rem; }
.quote__text { font-size: 16px; color: var(--cream); overflow-wrap: anywhere; }

.field { display: flex; flex-direction: column; gap: .4rem; }
.field__label i { color: var(--cream-62); font-style: normal; }

.field__input {
  height: 48px;
  padding: 0 .95rem;
  border: 1px solid var(--cream-17);
  border-radius: 12px;
  background: var(--ink);
  color: var(--cream);
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 400;
  transition: border-color var(--press) var(--ease-out);
}
.field__input::placeholder { color: var(--cream-62); }
.field__input:hover { border-color: var(--cream-30); }
.field__input:focus { outline: none; border-color: var(--cream-62); }
.field__input[aria-invalid="true"] { border-color: var(--red); }

/* Botón (manual §08): JetBrains Mono 700. Crema sobre rojo solo en tamaño grande: 19 px en negrita */
.send {
  position: relative;
  height: 54px;
  margin-top: .35rem;
  display: grid; place-items: center;
  border-radius: 12px;
  background: var(--red);
  box-shadow: 0 3px 0 0 var(--red-edge);
  color: var(--cream);
  font-family: var(--mono);
  font-size: 19px; font-weight: 700;
  line-height: 1.2;
  letter-spacing: .02em; text-transform: uppercase;
  transition: transform var(--press) var(--ease-out), box-shadow var(--press) var(--ease-out);
}
.send:focus-visible { transform: translateY(1px); box-shadow: 0 2px 0 0 var(--red-edge); }
@media (hover: hover) {
  .send:hover { transform: translateY(1px); box-shadow: 0 2px 0 0 var(--red-edge); }
}
.send:active { transform: translateY(3px); box-shadow: 0 0 0 0 var(--red-edge); }
.send[disabled] { cursor: progress; opacity: .8; }
.send.is-sending .send__label { opacity: 0; }
/* Siempre fuera del flujo: si no, el spinner vacío crea una segunda fila en el grid y sube el texto */
.send__spin { position: absolute; }
.send.is-sending .send__spin {
  width: 16px; height: 16px;
  border: 2px solid rgba(244, 239, 230, .3); border-top-color: var(--cream);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.sheet__note {
  min-height: 1.2em;
  font-family: var(--mono);
  font-size: 14px; font-weight: 700;
  line-height: 1.2; letter-spacing: .02em;
  color: var(--cream-62);
}
.sheet__note.is-error, .sheet__note.is-ok { color: var(--cream); }
/* Sin mensaje no ocupa sitio: el margen negativo anula el hueco del flex */
.sheet__note:empty { min-height: 0; margin-top: -.9rem; }

.sheet__legal { font-size: 16px; line-height: 1.5; color: var(--cream-62); }
.sheet__legal a { text-decoration: underline; text-underline-offset: 2px; }
.sheet__legal a:hover { color: var(--cream); }

.sheet.is-done .sheet__body > *:not(.sheet__close):not(.done) { display: none; }
.done { display: flex; flex-direction: column; align-items: center; gap: .6rem; padding: 1.5rem 0 1rem; text-align: center; }
.done__key { width: 46px; height: 46px; }
.done__text { font-size: 16px; color: var(--cream-62); max-width: 26ch; }

/* =============================================================
   8. Páginas legales
   ============================================================= */
body.is-doc { min-height: auto; }

.doc { width: min(92vw, 680px); margin-inline: auto; padding: clamp(3rem, 9vh, 6rem) 0 5rem; }

.doc__back {
  display: inline-flex; align-items: center; gap: .6rem;
  margin-bottom: 3rem;
  font-family: var(--mono);
  font-size: 12px; font-weight: 700;
  letter-spacing: .2em; text-transform: uppercase;
  color: var(--cream-62);
  transition: color var(--press) var(--ease-out);
}
.doc__back:hover { color: var(--cream); }
.doc__back img { width: 34px; }

/* Titular de sección (manual §08): Sora 800, 32–40 px, −3 % */
.doc h1 { font-size: clamp(32px, 5vw, 40px); font-weight: 800; line-height: 1.05; letter-spacing: -.03em; margin-bottom: .75rem; }

.doc .doc__meta, .doc .doc__foot, .doc .todo {
  font-family: var(--mono);
  font-size: 12px; font-weight: 700;
  line-height: 1.2;
  letter-spacing: .2em; text-transform: uppercase;
}
.doc .doc__meta { color: var(--cream-62); margin-bottom: 3rem; }

/* Titular de apartado (manual §08): Sora 800, 20–24 px, −2 % */
.doc h2 { margin-top: 2.75rem; margin-bottom: .75rem; font-size: 21px; font-weight: 800; line-height: 1.25; letter-spacing: -.02em; }

/* Texto de lectura (manual §08): Sora 400, 16–18 px, interlineado 1,6 */
.doc p, .doc li { font-size: 16px; line-height: 1.6; color: var(--cream-80); }
.doc p + p { margin-top: .9rem; }
.doc ul { margin: .9rem 0 0 1.1rem; display: flex; flex-direction: column; gap: .45rem; }
.doc a { color: var(--cream); text-decoration: underline; text-underline-offset: 3px; }

.doc .todo { display: inline-block; padding: .1rem .45rem; border: 1px solid var(--red); border-radius: 4px; color: var(--cream); }

.doc .doc__foot { margin-top: 4rem; padding-top: 1.5rem; border-top: 1px solid var(--cream-08); color: var(--cream-62); }

/* =============================================================
   9. Responsive
   ============================================================= */
@media (max-width: 539px) {
  .lockup { --w: min(64vw, 270px); }
  .ask { height: 56px; padding-left: 18px; }
  .ask__field { font-size: 16px; }
  .key { width: 42px; height: 42px; }

  /* La hoja sube desde abajo, al alcance del pulgar */
  .sheet {
    width: 100%;
    max-width: 100%;
    margin: auto 0 0;
    border-width: 1px 0 0;
    border-radius: 20px 20px 0 0;
  }
  .sheet[open] { animation-name: sheetUp; animation-duration: 380ms; }
  .sheet__body { max-height: 90dvh; padding: 2rem 1.35rem calc(1.35rem + env(safe-area-inset-bottom)); }
}

/* Pie en una sola línea: © a la izquierda, redes en el centro, legales a la derecha */
@media (min-width: 768px) {
  .foot {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 1.5rem;
    width: 100%;
  }
  .foot__copy   { grid-area: 1 / 1; justify-self: start; }
  .foot__social { grid-area: 1 / 2; }
  .foot__legal  { grid-area: 1 / 3; justify-self: end; }
}

@media (min-width: 960px) { .stage { padding-inline: 2rem; } }

/* Movimiento reducido: todo aparece ya colocado */
@media (prefers-reduced-motion: reduce) {
  .tecla, .lockup__teclas::before, .lockup__nombre, .claim, .ask, .foot, .ask__hint::after { animation: none; }
  .sheet[open], .sheet[open]::backdrop { animation: none; }
}

/* Pantallas bajas: la portada no debe hacer scroll */
@media (max-height: 760px) {
  .lockup { --w: clamp(220px, 21vw, 300px); }
  .claim { margin-bottom: 1.5rem; }
}

/* Móvil en horizontal: se permite scroll antes que comprimir la marca */
@media (max-height: 520px) {
  .stage { min-height: 0; padding-block: 1.2rem 1rem; gap: 1rem; }
  .lockup { --w: 190px; }
  .claim { margin-bottom: .9rem; }
  .ask { height: 50px; padding-left: 16px; }
  .key { width: 38px; height: 38px; }
  .foot { gap: .55rem; }
  .foot__social svg { width: 18px; height: 18px; }
}
