/* =========================================================
   RESET Y BASE
   Normaliza márgenes/paddings y fija la tipografía monoespaciada
   (estilo "código") para toda la página.
   ========================================================= */
:root {
  color-scheme: dark light;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
}

body {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
  overflow-x: hidden;
}

/* =========================================================
   TOGGLE DE TEMA (checkbox oculto, sin JS)
   El checkbox no se ve; su estado ":checked" se usa más abajo
   junto al selector "~" para cambiar las variables de color.
   ========================================================= */
#theme-toggle {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

/* =========================================================
   VARIABLES DE TEMA — MODO OSCURO (valor por defecto)
   Todos los colores del sitio salen de estas variables.
   ========================================================= */
.page {
  --bg-0: #05070a;
  --bg-1: #0b0f16;
  --bg-2: #10151d;
  --text-0: #e6edf3;
  --text-1: #8b96a3;
  --accent: #39ff88;
  --accent-2: #4fd1ff;
  --card-border: rgba(255, 255, 255, 0.10);
  --card-bg: rgba(255, 255, 255, 0.03);
  --code-color: rgba(57, 255, 136, 0.16);
  --shadow: rgba(0, 0, 0, 0.5);

  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg-0);
  color: var(--text-0);
  position: relative;
  isolation: isolate;
  transition: background .5s ease, color .5s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
}

/* =========================================================
   VARIABLES DE TEMA — MODO CLARO
   Se activan cuando el checkbox #theme-toggle está marcado.
   ========================================================= */
#theme-toggle:checked ~ .page {
  --bg-0: #f4f6f8;
  --bg-1: #ffffff;
  --bg-2: #eef1f4;
  --text-0: #0d1117;
  --text-1: #4b5563;
  --accent: #0a8f4a;
  --accent-2: #0969da;
  --card-border: rgba(0, 0, 0, 0.10);
  --card-bg: rgba(0, 0, 0, 0.025);
  --code-color: rgba(10, 143, 74, 0.10);
  --shadow: rgba(0, 0, 0, 0.12);
}

/* =========================================================
   FONDO ANIMADO (lluvia de código)
   Grilla estática + columnas de texto que caen en loop
   con @keyframes. Puramente decorativo (aria-hidden en HTML).
   ========================================================= */
.matrix-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background: var(--bg-0);
  transition: background .5s ease;
  -webkit-mask-image: linear-gradient(to bottom, transparent, black 12%, black 88%, transparent);
          mask-image: linear-gradient(to bottom, transparent, black 12%, black 88%, transparent);
}

/* Grilla de fondo tipo "editor de código" */
.matrix-bg::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--card-border) 1px, transparent 1px),
    linear-gradient(90deg, var(--card-border) 1px, transparent 1px);
  background-size: 42px 42px;
  opacity: .35;
}

/* Cada columna de caracteres que cae */
.stream {
  position: absolute;
  top: -50%;
  width: 20px;
  line-height: 1.15;
  font-size: 14px;
  font-weight: 700;
  color: var(--code-color);
  white-space: pre;
  text-align: center;
  animation-name: fall;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  transition: color .5s ease;
}

@keyframes fall {
  0%   { transform: translateY(0); }
  100% { transform: translateY(160vh); }
}

/* En pantallas chicas se muestran menos columnas para aliviar el render */
@media (max-width: 480px) {
  .stream { display: none; }
  .stream:nth-child(-n+14) { display: block; }
}

/* =========================================================
   TARJETA PRINCIPAL (layout mobile-first)
   ========================================================= */
.container {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 40px 24px 32px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 24px 60px var(--shadow);
  text-align: center;
  transition: background .5s ease, border-color .5s ease, box-shadow .5s ease;
}

/* =========================================================
   SWITCH VISUAL DEL TOGGLE (sol / luna)
   El <label for="theme-toggle"> es lo que el usuario clickea;
   el estado del checkbox mueve la "perilla" y cambia el ícono.
   ========================================================= */
.toggle-label {
  position: absolute;
  top: -18px;
  right: 16px;
  width: 54px;
  height: 30px;
  background: var(--bg-2);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  display: flex;
  align-items: center;
  padding: 3px;
  cursor: pointer;
  transition: background .4s ease, border-color .4s ease;
}

.toggle-knob {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translateX(0);
  transition: transform .35s ease, background .4s ease;
}

/* Desliza la perilla hacia la derecha en modo claro */
#theme-toggle:checked ~ .page .toggle-knob {
  transform: translateX(24px);
}

.toggle-knob svg {
  width: 13px;
  height: 13px;
}

/* Intercambia ícono de luna (oscuro) por sol (claro) */
.icon-moon { display: block; }
.icon-sun { display: none; }
#theme-toggle:checked ~ .page .icon-moon { display: none; }
#theme-toggle:checked ~ .page .icon-sun { display: block; }

/* =========================================================
   FOTO DE PERFIL
   Borde circular con degradado fijo (sin rotación).
   ========================================================= */
.avatar-wrap {
  width: 120px;
  height: 120px;
  margin: 0 auto 20px;
  border-radius: 50%;
  padding: 3px;
  background: conic-gradient(from 0deg, var(--accent), var(--accent-2), var(--accent));
}

.avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  border: 3px solid var(--bg-1);
  background: var(--bg-1);
}

/* =========================================================
   TÍTULO Y SUBTÍTULO
   ========================================================= */
h1 {
  margin: 0 0 4px;
  font-size: 1.7rem;
  letter-spacing: .5px;
  color: var(--text-0);
}

/* Prefijo tipo prompt de terminal: "> " */
h1::before {
  content: "> ";
  color: var(--accent);
}

/* Cursor parpadeante tipo terminal: "_" */
h1::after {
  content: "_";
  color: var(--accent);
  animation: blink 1s step-end infinite;
}

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

.subtitle {
  margin: 0 0 24px;
  font-size: .85rem;
  color: var(--text-1);
  line-height: 1.6;
  word-spacing: 1px;
}

/* =========================================================
   REDES SOCIALES (GitHub, Twitter/X, Partner)
   ========================================================= */
.socials {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.social-link {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: var(--bg-2);
  border: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-0);
  transition: transform .25s ease, border-color .25s ease, color .25s ease;
}

.social-link svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.social-link:hover,
.social-link:focus-visible {
  transform: translateY(-4px);
  border-color: var(--accent);
  color: var(--accent);
}

/* =========================================================
   CONTACTO (email)
   ========================================================= */
.contact {
  display: inline-block;
  font-size: .82rem;
  color: var(--text-1);
  text-decoration: none;
  border-bottom: 1px dashed var(--card-border);
  padding-bottom: 2px;
  transition: color .25s ease, border-color .25s ease;
  word-break: break-all;
}

.contact:hover,
.contact:focus-visible {
  color: var(--accent-2);
  border-color: var(--accent-2);
}

/* =========================================================
   RESPONSIVE — a partir de tablets/desktop
   Mobile-first: los estilos base ya cubren el celular,
   acá solo se agranda lo necesario.
   ========================================================= */
@media (min-width: 480px) {
  .container { padding: 48px 40px 40px; }
  h1 { font-size: 2rem; }
  .subtitle { font-size: .9rem; }
}
