:root {
  --bg: #f6f7fb;
  --ink: #59595b;
  --brand: #6885bc;
  --muted: #8f97a8;
  /* Color (r,g,b) y opacidad base de la rejilla de caracteres del fondo */
  --field: 104, 133, 188;
  --field-alpha: 0.13;
  --surface: #ffffff;
  --line: rgba(104, 133, 188, 0.3);
  --danger: #b4443c;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c1019;
    --ink: #d7dbe4;
    --brand: #8aa4d8;
    --muted: #5d6678;
    --field: 138, 164, 216;
    --field-alpha: 0.09;
    --surface: #121826;
    --line: rgba(138, 164, 216, 0.25);
    --danger: #e8837b;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
}

html,
body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--brand);
  color: var(--bg);
}

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

/* Fondo: rejilla de caracteres que reacciona al puntero */
.field {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
}

/* Halo que despeja la rejilla detrás del logo */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse min(46vw, 420px) min(36vh, 300px) at 50% 50%, var(--bg) 35%, transparent 100%);
  z-index: 1;
  pointer-events: none;
}

.stage {
  position: relative;
  z-index: 2;
  min-height: 100svh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: clamp(1.75rem, 5vh, 3rem);
  padding: 2rem 16px 5rem;
  text-align: center;
  pointer-events: none;
}

/* Logo: es un botón que abre el formulario de contacto */
.brand {
  width: min(80vw, 470px);
  pointer-events: auto;
}

.brand__button {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.brand__button:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 12px;
  border-radius: 8px;
}

.logo {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.logo__hat,
.logo__digital {
  fill: var(--brand);
}

.logo__desarrollo {
  fill: var(--ink);
}

/* El logo aparece en su sitio, sin desplazarse: se enfoca y gana opacidad */
.logo__hat {
  animation: materialize 0.9s ease-out both;
}

/* La barra del birrete parpadea como un cursor antes de empezar a escribir */
.logo__slash {
  animation: blink 0.5s steps(1) 0.95s 3 both;
}

.logo__desarrollo,
.logo__digital {
  animation: materialize 0.9s ease-out both;
}

.logo__desarrollo { animation-delay: 0.35s; }
.logo__digital { animation-delay: 0.5s; }

@keyframes materialize {
  from { opacity: 0; filter: blur(10px); }
  to { opacity: 1; filter: none; }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(35%); filter: blur(6px); }
  to { opacity: 1; transform: none; filter: none; }
}

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

/* Eslogan tecleado */
.tagline {
  font-family: var(--mono);
  font-size: clamp(1rem, 2.6vw, 1.45rem);
  line-height: 1.4;
  letter-spacing: -0.01em;
  white-space: nowrap;
  min-height: 1.4em;
  animation: rise 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) 0.8s both;
}

.tag {
  color: var(--brand);
  opacity: 0.75;
}

.tag:first-child {
  margin-right: 0.6ch;
}

.tag:last-child {
  margin-left: 0.6ch;
}

.typed mark {
  background: var(--brand);
  color: var(--bg);
}

.caret {
  display: inline-block;
  width: 0.55ch;
  height: 1.15em;
  margin-left: 1px;
  vertical-align: -0.2em;
  background: var(--brand);
  animation: blink 1s steps(1) infinite;
}

.tagline.is-typing .caret {
  animation: none;
}

/* Pie */
.foot {
  position: fixed;
  z-index: 2;
  inset: auto 0 0;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem max(16px, 2.5vw) max(1.1rem, env(safe-area-inset-bottom));
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: var(--muted);
  animation: rise 0.8s ease 1.4s both;
}

.status i {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  margin-right: 0.6rem;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 0 rgba(var(--field), 0.6);
  animation: pulse 2.2s ease-out infinite;
}

/* Puntos suspensivos que se escriben de uno en uno */
.dots {
  display: inline-block;
  width: 3ch;
}

.dots::after {
  content: "...";
  display: inline-block;
  width: 0;
  overflow: hidden;
  vertical-align: bottom;
  animation: dots 1.6s steps(4, end) infinite;
}

@keyframes dots {
  to { width: 4ch; }
}

@keyframes pulse {
  70% { box-shadow: 0 0 0 0.6rem rgba(var(--field), 0); }
  100% { box-shadow: 0 0 0 0 rgba(var(--field), 0); }
}

.foot__link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--brand);
  font: inherit;
  letter-spacing: inherit;
  cursor: pointer;
}

.foot__link:hover,
.foot__link:focus-visible {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Formulario de contacto */
.contact {
  width: min(560px, calc(100% - 32px));
  max-height: calc(100svh - 32px);
  margin: auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 30px 80px -20px rgba(var(--field), 0.45);
  overflow: auto;
}

.contact[open] {
  animation: pop 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.15);
}

.contact::backdrop {
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  backdrop-filter: blur(6px);
}

@keyframes pop {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
}

.contact__form {
  padding: clamp(1.25rem, 4vw, 2rem);
}

.contact__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.4rem;
}

.contact__head h2 {
  font-family: var(--mono);
  font-size: clamp(1.15rem, 3vw, 1.4rem);
  font-weight: 500;
  letter-spacing: -0.01em;
}

.contact__head .tag:first-child {
  margin-right: 0.5ch;
}

.contact__head .tag:last-child {
  margin-left: 0.5ch;
}

.contact__close {
  width: 2.25rem;
  height: 2.25rem;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--muted);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}

.contact__close:hover,
.contact__close:focus-visible {
  background: rgba(var(--field), 0.12);
  color: var(--ink);
}

.contact__intro {
  color: var(--muted);
  font-size: 0.95rem;
}

.contact__body {
  display: grid;
  gap: 1.1rem;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  min-width: 0;
  padding: 0;
  border: 0;
}

.chips legend,
.input > span {
  margin-bottom: 0.5rem;
  padding: 0;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.chip {
  position: relative;
}

.chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.chip span {
  display: inline-block;
  padding: 0.38rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.chip span:hover {
  border-color: var(--brand);
}

.chip input:checked + span {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--surface);
}

.chip input:focus-visible + span {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.input {
  display: grid;
}

.input input,
.input textarea {
  width: 100%;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input textarea {
  resize: vertical;
  min-height: 6.5rem;
}

.input input:focus,
.input textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(var(--field), 0.2);
}

.hp {
  position: absolute;
  left: -9999px;
}

.consent {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  font-size: 0.82rem;
  color: var(--muted);
  cursor: pointer;
}

.consent input {
  flex: none;
  width: 1rem;
  height: 1rem;
  margin-top: 0.1rem;
  accent-color: var(--brand);
}

.contact__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.3rem;
}

.contact__status {
  font-size: 0.85rem;
  color: var(--danger);
}

.btn {
  flex: none;
  padding: 0.7rem 1.4rem;
  border: 0;
  border-radius: 999px;
  background: var(--brand);
  color: var(--surface);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, filter 0.15s;
}

.btn:hover {
  filter: brightness(1.08);
}

.btn:active {
  transform: scale(0.97);
}

.btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 3px;
}

.btn[disabled] {
  opacity: 0.6;
  cursor: progress;
}

.contact__done {
  display: grid;
  justify-items: center;
  gap: 0.4rem;
  padding: 2rem 0 0.5rem;
  text-align: center;
  color: var(--muted);
}

.contact__done[hidden],
.contact__body[hidden] {
  display: none;
}

.contact__done-title {
  font-family: var(--mono);
  font-size: 1.2rem;
  color: var(--brand);
}

.contact__done .btn {
  margin-top: 1rem;
}

@media (max-width: 480px) {
  .foot {
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  .dots::after {
    width: 3ch;
  }
}
