@import url('fonts.css');

/* ── Tokens ──────────────────────────────────────────────────────────────
   Un solo CSS sirve a las tres tarjetas. El HTML declara <html data-brand>
   y de ahi sale toda la paleta. Nada de duplicar hojas por marca.        */

:root {
  --ease-out: cubic-bezier(.23, 1, .32, 1);
  --ease-in-out: cubic-bezier(.77, 0, .175, 1);
  --ease-drawer: cubic-bezier(.32, .72, 0, 1);

  --press: 140ms;
  --card-w: 440px;

  --btn-fg: #fff;
  --grad: linear-gradient(100deg, #2563EB, #06B6D4 52%, #4F46E5);
  --accent: #2563EB;
  --card-bg: #0A0C10;
  --page-bg: #E9EBEF;
  --bg: #F7F8FA;
  --ink: #0A0C10;
  --ink-2: #4A5160;
  --line: #E0E3E8;
  --surface: #FFFFFF;
  --bar-bg: rgba(247, 248, 250, .88);
  --sheet-bg: #FFFFFF;
  --sheet-ink: #0A0C10;
  --sheet-line: #D5D9E0;
  --sheet-muted: #F1F3F6;
  --chip-on-bg: #0A0C10;
  --chip-on-fg: #fff;
}

:root[data-brand='ct'] {
  --grad: linear-gradient(100deg, #047857, #059669 52%, #0F766E);
  --accent: #047857;
  --card-bg: #0B231D;
  --page-bg: #E4EAE6;
  --bg: #F3F6F4;
  --line: #DDE5E0;
  --bar-bg: rgba(243, 246, 244, .88);
}

:root[data-brand='cp'] {
  --grad: linear-gradient(100deg, #F59E0B, #FCD34D 52%, #D97706);
  --btn-fg: #1A1206;
  --accent: #F59E0B;
  --card-bg: #17130D;
  --page-bg: #050504;
  --bg: #0E0D0B;
  --ink: #F5F1EA;
  --ink-2: #B7AE9F;
  --line: #2C2820;
  --surface: #17140F;
  --bar-bg: rgba(14, 13, 11, .86);
  /* En la tarjeta oscura el sheet tambien es oscuro: una hoja blanca a
     pantalla completa de noche es un golpe de luz, no una transicion. */
  --sheet-bg: #17140F;
  --sheet-ink: #F5F1EA;
  --sheet-line: #2C2820;
  --sheet-muted: #221E17;
  --chip-on-bg: #F5F1EA;
  --chip-on-fg: #0E0D0B;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ── Base ─────────────────────────────────────────────────────────────── */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body {
  font: 400 1rem/1.55 Inter, system-ui, -apple-system, sans-serif;
  background: var(--page-bg);
  color: var(--ink);
  display: flex;
  justify-content: center;
  min-height: 100dvh;
}

a { color: inherit; }

:where(button, a, input, textarea):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 8px;
}

.shell {
  position: relative;
  width: 100%;
  max-width: var(--card-w);
  min-height: 100dvh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

.body { flex: 1 0 auto; display: flex; flex-direction: column; justify-content: center; padding-bottom: 8px; }

/* ── Encabezado e idioma ──────────────────────────────────────────────── */

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: calc(18px + env(safe-area-inset-top, 0px)) 24px 0;
  animation: fade .5s var(--ease-out) both;
}

.brandline {
  font: 600 .8125rem Inter, sans-serif;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.lang { display: flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }

.lang button {
  border: 0;
  min-height: 36px;
  padding: 0 13px;
  font: 600 .78rem Inter, sans-serif;
  cursor: pointer;
  background: transparent;
  color: var(--ink-2);
  transition: background-color 180ms ease, color 180ms ease;
}

.lang button[aria-pressed='true'] { background: var(--chip-on-bg); color: var(--chip-on-fg); }

/* ── Tarjeta que gira ─────────────────────────────────────────────────── */

.card-wrap { padding: 20px 24px 0; perspective: 1100px; }
.card-rise { animation: cardIn .9s var(--ease-out) .1s both; transform-origin: 50% 100%; }

.card {
  position: relative;
  width: 100%;
  aspect-ratio: 1.586;
  cursor: pointer;
  transform-style: preserve-3d;
  /* El giro y la inclinacion viven en la misma propiedad: una sola
     transicion, interrumpible, en vez de keyframes que reinician. */
  transition: transform .55s var(--ease-out);
  border: 0;
  padding: 0;
  background: none;
  display: block;
  text-align: left;
}

.face {
  position: absolute;
  inset: 0;
  border-radius: 18px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
  transition: visibility 0s linear .14s;
}

.face-front {
  background: var(--card-bg);
  color: #fff;
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .08) inset, 0 18px 40px -14px rgba(10, 12, 16, .55);
}

.sheen { position: absolute; inset: 0; pointer-events: none; }

.face-back {
  background: #fff;
  color: #0A0C10;
  transform: rotateY(180deg);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  box-shadow: 0 18px 40px -14px rgba(10, 12, 16, .45);
  border: 1px solid #E6E8EC;
}

.card[aria-pressed='false'] .face-back,
.card[aria-pressed='true'] .face-front { visibility: hidden; }

.mono {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--grad);
  display: grid;
  place-items: center;
  font: 700 .94rem 'Inter Tight', sans-serif;
  color: var(--btn-fg);
}

.hint {
  font: 500 .69rem 'JetBrains Mono', monospace;
  letter-spacing: .06em;
  color: rgba(255, 255, 255, .62);
  text-transform: uppercase;
}

.card h1 {
  margin: 0;
  font: 700 1.625rem/1.05 'Inter Tight', sans-serif;
  letter-spacing: -.03em;
}

.card .role { font-size: .84rem; color: rgba(255, 255, 255, .72); margin-top: 4px; }
.rule { height: 2px; width: 56px; border-radius: 2px; background: var(--grad); margin-top: 12px; }

.qr { width: 150px; height: 150px; flex: none; max-width: 45%; }
.qr img, .qr canvas { width: 100%; height: auto; display: block; }
.face-back strong { font: 700 1.06rem/1.2 'Inter Tight', sans-serif; letter-spacing: -.02em; }
.face-back span { font-size: .81rem; color: #4A5160; line-height: 1.4; }

/* ── Titular ──────────────────────────────────────────────────────────── */

.tag {
  margin: 0;
  padding: 32px 24px 0;
  font: 700 2.125rem/1.06 'Inter Tight', sans-serif;
  letter-spacing: -.034em;
  text-wrap: balance;
  animation: rise .7s var(--ease-out) .35s both;
}

.tag mark {
  background: var(--grad);
  background-size: 100% 4px;
  background-repeat: no-repeat;
  background-position: 0 94%;
  padding-bottom: 2px;
  color: inherit;
}

/* ── Servicios ────────────────────────────────────────────────────────── */

.svc {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 24px 24px 4px;
  scrollbar-width: none;
  animation: rise .7s var(--ease-out) .46s both;
}

.svc::-webkit-scrollbar { display: none; }
.svc.dragging { cursor: grabbing; scroll-snap-type: none; }

.svc article {
  flex: none;
  width: 248px;
  scroll-snap-align: start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.svc .n { font: 500 .75rem 'JetBrains Mono', monospace; color: var(--accent); }
.svc strong { font-size: 1rem; line-height: 1.3; letter-spacing: -.012em; }
.svc p { margin: 0; font-size: .875rem; line-height: 1.45; color: var(--ink-2); text-wrap: pretty; }

.svc-rail { display: flex; align-items: center; gap: 12px; padding: 14px 24px 0; }
.svc-track { position: relative; flex: 1; height: 3px; border-radius: 3px; background: var(--line); overflow: hidden; }
.svc-thumb { position: absolute; top: 0; bottom: 0; border-radius: 3px; background: var(--accent); transition: width .2s ease, left .2s ease; }
.svc-count { font: 500 .75rem 'JetBrains Mono', monospace; color: var(--ink-2); min-width: 40px; text-align: right; }

/* ── Cuatro acciones ──────────────────────────────────────────────────── */

.actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 28px 24px 0;
}

.action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: var(--ink);
  font: 600 .78rem/1.2 Inter, sans-serif;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  animation: rise .7s var(--ease-out) both;
  transition: transform var(--press) var(--ease-out);
}

.action:nth-child(1) { animation-delay: .58s; }
.action:nth-child(2) { animation-delay: .62s; }
.action:nth-child(3) { animation-delay: .66s; }
.action:nth-child(4) { animation-delay: .70s; }

.action:active { transform: scale(.97); }

.action i {
  width: 52px; height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--surface);
  transition: border-color 180ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .action:hover i { border-color: var(--accent); }
}

.trust {
  margin: 24px 24px 0;
  padding: 10px 12px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  font: 500 .75rem/1.5 'JetBrains Mono', monospace;
  color: var(--ink-2);
}

.lead-cta {
  margin: 24px 24px 0;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 18px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font: 600 .94rem Inter, sans-serif;
  cursor: pointer;
  text-align: left;
  transition: transform var(--press) var(--ease-out), border-color 180ms ease;
}

.lead-cta:active { transform: scale(.985); }
.lead-cta .sub { font-weight: 500; font-size: .81rem; color: var(--ink-2); }
.lead-cta .arrow { font-size: 1.125rem; color: var(--accent); }

.foot { margin: 32px 24px 12px; text-align: center; color: var(--ink-2); font-size: .81rem; }

/* ── Barra inferior: material translucido, contenido pasando por debajo ── */

.bar {
  position: sticky;
  bottom: 0;
  padding: 12px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  background: var(--bar-bg);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(14px) saturate(180%);
  -webkit-backdrop-filter: blur(14px) saturate(180%);
}

.bar-grid { display: grid; grid-template-columns: 1.35fr 1fr; gap: 8px; }

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  border: 0;
  border-radius: 14px;
  font: 600 .94rem Inter, sans-serif;
  cursor: pointer;
  transition: transform var(--press) var(--ease-out);
}

.btn:active { transform: scale(.97); }
.btn-primary { background: var(--grad); color: var(--btn-fg); }
.btn-ghost { border: 1px solid var(--line); background: var(--surface); color: var(--ink); }

/* ── Sheets ───────────────────────────────────────────────────────────── */

.sheet-root {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  z-index: 20;
}

.sheet-root[hidden] { display: none; }

.scrim {
  position: absolute;
  inset: 0;
  background: rgba(10, 12, 16, .5);
  border: 0;
  opacity: 1;
  transition: opacity 260ms var(--ease-out);
}

.sheet-root[data-state='closed'] .scrim { opacity: 0; }

.sheet {
  position: relative;
  width: 100%;
  max-width: var(--card-w);
  background: var(--sheet-bg);
  color: var(--sheet-ink);
  border-radius: 24px 24px 0 0;
  padding: 10px 20px calc(22px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 88dvh;
  overflow-y: auto;
  box-shadow: 0 -18px 50px -20px rgba(0, 0, 0, .5);
  transform: translateY(0);
  transition: transform 320ms var(--ease-drawer);
  touch-action: pan-y;
}

.sheet-root[data-state='closed'] .sheet { transform: translateY(100%); }
.sheet-root[data-dragging='true'] .sheet { transition: none; }

.grabber {
  width: 40px; height: 5px;
  border-radius: 9px;
  background: var(--sheet-line);
  align-self: center;
  flex: none;
}

.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.sheet-head strong { font: 700 1.25rem/1.2 'Inter Tight', sans-serif; letter-spacing: -.02em; }

.sheet-close {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 0;
  background: var(--sheet-muted);
  color: var(--sheet-ink);
  cursor: pointer;
  font-size: 1rem;
  flex: none;
  transition: transform var(--press) var(--ease-out);
}

.sheet-close:active { transform: scale(.93); }
.sheet .label { font: 600 .78rem Inter, sans-serif; color: var(--ink-2); letter-spacing: .02em; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  min-height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--sheet-line);
  background: var(--sheet-bg);
  color: var(--sheet-ink);
  font: 600 .875rem Inter, sans-serif;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.15;
  transition: transform var(--press) var(--ease-out), background-color 180ms ease, border-color 180ms ease, color 180ms ease;
}

.chip:active { transform: scale(.96); }
.chip[aria-pressed='true'] { background: var(--chip-on-bg); border-color: var(--chip-on-bg); color: var(--chip-on-fg); }
.chip .sub { font: 500 .69rem 'JetBrains Mono', monospace; opacity: .7; }

.field {
  width: 100%;
  min-height: 48px;
  border-radius: 12px;
  border: 1px solid var(--sheet-line);
  background: var(--sheet-bg);
  color: var(--sheet-ink);
  padding: 12px 14px;
  font: 400 1rem Inter, sans-serif;
  transition: border-color 180ms ease;
}

.field:focus { border-color: var(--accent); }
.field::placeholder { color: var(--ink-2); opacity: .8; }
textarea.field { resize: none; min-height: 72px; }
.note { font-size: .81rem; color: var(--ink-2); text-align: center; margin: 0; }

/* ── Aviso ────────────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(110px + env(safe-area-inset-bottom, 0px));
  background: #0A0C10;
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: .875rem;
  white-space: nowrap;
  z-index: 30;
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  transition: opacity 240ms var(--ease-out), transform 240ms var(--ease-out);
}

.toast[data-state='hidden'] {
  opacity: 0;
  transform: translateX(-50%) translateY(8px);
  pointer-events: none;
}

/* ── Animaciones de entrada ───────────────────────────────────────────── */

@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes cardIn { from { opacity: 0; transform: rotateX(28deg) translateY(28px) scale(.94); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ── Preferencias del sistema ─────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  /* El giro de la tarjeta sigue existiendo, pero sin recorrido: cambia de
     cara sin rotacion vestibular. */
  .card { transition: none; }
  .scrim, .toast { transition: opacity 150ms ease !important; }
}

@media (prefers-reduced-transparency: reduce) {
  .bar { background: var(--bg); backdrop-filter: none; -webkit-backdrop-filter: none; }
}

@media (prefers-contrast: more) {
  :root { --line: var(--ink-2); }
  .action i, .svc article, .btn-ghost, .lead-cta { border-width: 2px; }
}

@media print {
  .bar, .lang, .svc-rail, .lead-cta { display: none; }
  body { background: #fff; }
}
