/* ==========================================================
   RETRO PORTFOLIO — Estética inspirada en Amstrad, C64 y ZX
   ========================================================== */

/* ---------- Variables de paleta retro ---------- */
:root {
  /* Colores base inspirados en los 8 bits */
  --c-bg: #0a0a1a;          /* Fondo casi negro azulado (C64) */
  --c-bg-alt: #11112b;      /* Fondo alternativo (Amstrad) */
  --c-panel: #15153a;       /* Paneles */
  --c-border: #2d2d6e;      /* Bordes sutiles */

  /* Colores de marca (Spectrum) */
  --c-cyan: #00ffff;        /* Cyan C64/Spectrum */
  --c-magenta: #ff00ff;     /* Magenta Spectrum */
  --c-yellow: #ffe600;      /* Amarillo Spectrum */
  --c-green: #00ff7f;       /* Verde Spectrum */
  --c-red: #ff4040;         /* Rojo alerta */
  --c-text: #d6d6e7;        /* Texto principal */
  --c-text-dim: #8a8ab0;    /* Texto secundario */

  /* Tipografías */
  --f-pixel: 'Press Start 2P', monospace;
  --f-mono: 'VT323', 'Courier New', monospace;

  /* Sombras y efectos */
  --glow-cyan: 0 0 6px rgba(0, 255, 255, 0.6), 0 0 16px rgba(0, 255, 255, 0.3);
  --glow-magenta: 0 0 6px rgba(255, 0, 255, 0.6), 0 0 16px rgba(255, 0, 255, 0.3);
}

/* ---------- Reset suave ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; scroll-padding-top: 80px; }

body {
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--f-mono);
  font-size: 1.15rem;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  /* Patrón de cuadrícula sutil como una pantalla CRT */
  background-image:
    radial-gradient(ellipse at center, #11112b 0%, #0a0a1a 100%);
}

/* Imagen pixelada por defecto para todos los elementos */
img { image-rendering: pixelated; }

/* ---------- Efectos CRT ---------- */
.crt-overlay {
  position: fixed; inset: 0;
  background:
    radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.6) 100%);
  pointer-events: none; z-index: 100;
}
.crt-scanlines {
  position: fixed; inset: 0;
  background: repeating-linear-gradient(
    0deg,
    rgba(0,0,0,0.15) 0px,
    rgba(0,0,0,0.15) 1px,
    transparent 1px,
    transparent 3px
  );
  pointer-events: none; z-index: 101;
  mix-blend-mode: multiply;
  opacity: 0.4;
}
.crt-flicker {
  position: fixed; inset: 0;
  background: rgba(0, 255, 255, 0.02);
  pointer-events: none; z-index: 102;
  animation: flicker 0.15s infinite;
}
@keyframes flicker {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.5; }
}

/* ---------- Header / Navegación ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.5rem;
  background: rgba(10, 10, 26, 0.92);
  border-bottom: 2px solid var(--c-border);
  backdrop-filter: blur(4px);
}

.logo {
  font-family: var(--f-pixel);
  font-size: 0.85rem;
  color: var(--c-cyan);
  text-shadow: var(--glow-cyan);
  letter-spacing: 1px;
}
.logo-bracket { color: var(--c-magenta); }
.logo-text { margin: 0 0.4rem; }
.cursor-blink {
  display: inline-block;
  color: var(--c-cyan);
  animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.main-nav {
  display: flex; gap: 0.5rem;
}
.nav-link {
  font-family: var(--f-pixel);
  font-size: 0.7rem;
  color: var(--c-text-dim);
  text-decoration: none;
  padding: 0.6rem 0.9rem;
  border: 1px solid transparent;
  position: relative;
  transition: all 0.15s;
  letter-spacing: 1px;
}
.nav-link:hover, .nav-link:focus-visible {
  color: var(--c-cyan);
  border-color: var(--c-cyan);
  text-shadow: var(--glow-cyan);
  outline: none;
}
.nav-link::before { content: '> '; opacity: 0; transition: opacity 0.15s; }
.nav-link:hover::before, .nav-link:focus-visible::before { opacity: 1; }

/* Menú hamburguesa */
.menu-toggle {
  display: none;
  background: none; border: 1px solid var(--c-cyan);
  width: 40px; height: 36px;
  cursor: pointer;
  flex-direction: column; justify-content: center; align-items: center; gap: 4px;
}
.menu-toggle span {
  display: block; width: 18px; height: 2px;
  background: var(--c-cyan);
  transition: 0.2s;
}
.menu-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.menu-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.menu-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

@media (max-width: 720px) {
  .menu-toggle { display: flex; }
  .main-nav {
    position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; gap: 0;
    background: var(--c-bg-alt);
    border-bottom: 2px solid var(--c-cyan);
    transform: scaleY(0); transform-origin: top;
    transition: transform 0.2s;
  }
  .main-nav.is-open { transform: scaleY(1); }
  .nav-link { padding: 1rem; border: none; border-bottom: 1px solid var(--c-border); }
}

/* ---------- Secciones ---------- */
.section {
  padding: 4rem 1.5rem;
  max-width: 1100px;
  margin: 0 auto;
  border-bottom: 1px dashed var(--c-border);
}
.section:last-of-type { border-bottom: none; }

.contact-intro {
  font-size: 1.3rem;
  color: var(--c-text);
  border-left: 3px solid var(--c-cyan);
  padding-left: 1rem;
  margin-bottom: 2.5rem;
  max-width: 720px;
}

.section-header { margin-bottom: 2.5rem; }
.section-title {
  font-family: var(--f-pixel);
  font-size: 1.4rem;
  color: var(--c-cyan);
  text-shadow: var(--glow-cyan);
  letter-spacing: 2px;
  margin-bottom: 0.5rem;
}
.section-title .hash { color: var(--c-magenta); margin-right: 0.5rem; }
.section-sub {
  font-family: var(--f-mono);
  font-size: 1.2rem;
  color: var(--c-text-dim);
}

/* ---------- HERO ---------- */
.hero {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 2rem;
  align-items: center;
  min-height: calc(100vh - 80px);
  padding-top: 5rem;
  padding-bottom: 5rem;
}
.hero-boot {
  font-family: var(--f-pixel);
  font-size: 0.7rem;
  color: var(--c-green);
  margin-bottom: 1.5rem;
  animation: boot 1.5s ease-out;
}
@keyframes boot {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}

.hero-title {
  font-family: var(--f-pixel);
  font-weight: normal;
  line-height: 1.6;
  margin-bottom: 1.5rem;
}
.hero-title .line { display: block; }
.hero-title .line-1 { font-size: 0.9rem; color: var(--c-text); opacity: 0.8; }
.hero-title .line-2 {
  font-size: 2.2rem;
  color: var(--c-magenta);
  text-shadow: var(--glow-magenta);
  margin: 0.8rem 0;
  position: relative;
}
.hero-title .line-3 {
  font-size: 0.75rem;
  color: var(--c-cyan);
  text-shadow: var(--glow-cyan);
}

.hero-tagline {
  font-size: 1.3rem;
  color: var(--c-text);
  max-width: 480px;
  margin-bottom: 2rem;
}

.hero-actions { display: flex; flex-wrap: wrap; gap: 1rem; margin-bottom: 3rem; }

.hero-stats { display: flex; gap: 2rem; flex-wrap: wrap; }
.stat {
  display: flex; flex-direction: column;
  border: 1px solid var(--c-cyan);
  padding: 0.8rem 1.2rem;
  background: rgba(0, 255, 255, 0.04);
}
.stat-num {
  font-family: var(--f-pixel);
  font-size: 1.3rem;
  color: var(--c-cyan);
  text-shadow: var(--glow-cyan);
}
.stat-label {
  font-family: var(--f-pixel);
  font-size: 0.55rem;
  color: var(--c-text-dim);
  letter-spacing: 1px;
  margin-top: 0.4rem;
}

/* ASCII art */
.ascii-art {
  font-family: var(--f-mono);
  font-size: 0.95rem;
  color: var(--c-cyan);
  text-shadow: var(--glow-cyan);
  line-height: 1.1;
  white-space: pre;
  text-align: center;
  animation: float 4s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* Marco de foto de perfil estilo pantalla CRT */
.hero-art {
  display: flex; align-items: center; justify-content: center;
}
.profile-frame {
  position: relative;
  padding: 14px;
  background: var(--c-bg-alt);
  border: 2px solid var(--c-cyan);
  box-shadow: var(--glow-cyan), inset 0 0 0 1px var(--c-bg);
  animation: float 4s ease-in-out infinite;
}
/* Esquinas decorativas tipo Amstrad/C64 */
.profile-frame::before,
.profile-frame::after {
  content: '';
  position: absolute;
  width: 12px; height: 12px;
  border: 2px solid var(--c-magenta);
}
.profile-frame::before {
  top: -2px; left: -2px;
  border-right: none; border-bottom: none;
}
.profile-frame::after {
  bottom: -2px; right: -2px;
  border-left: none; border-top: none;
}

.profile-screen {
  position: relative;
  width: 280px; height: 280px;
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  overflow: hidden;
}
/* Scanlines y curvatura sutil sobre la foto */
.profile-screen::after {
  content: '';
  position: absolute; inset: 0;
  background: repeating-linear-gradient(
    0deg,
    rgba(0,0,0,0.25) 0px,
    rgba(0,0,0,0.25) 1px,
    transparent 1px,
    transparent 3px
  );
  pointer-events: none;
  mix-blend-mode: multiply;
}

.profile-photo {
  display: block;
  width: 100%; height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
  filter: contrast(1.05) saturate(1.1);
}

.profile-label {
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--f-pixel);
  font-size: 0.6rem;
  color: var(--c-cyan);
  text-shadow: var(--glow-cyan);
  margin-top: 0.8rem;
  letter-spacing: 1px;
}

@media (max-width: 820px) {
  .hero { grid-template-columns: 1fr; padding-top: 3rem; }
  .hero-art { order: -1; }
  .hero-title .line-2 { font-size: 1.6rem; }
}

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 0.6rem;
  font-family: var(--f-pixel);
  font-size: 0.7rem;
  text-decoration: none;
  padding: 0.9rem 1.4rem;
  border: 2px solid var(--c-cyan);
  background: var(--c-cyan);
  color: var(--c-bg);
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}
.btn span { font-family: var(--f-mono); font-size: 1.1rem; }
.btn:hover, .btn:focus-visible {
  background: transparent;
  color: var(--c-cyan);
  text-shadow: var(--glow-cyan);
  box-shadow: var(--glow-cyan);
  outline: none;
}
.btn:active { transform: translate(2px, 2px); }

.btn-ghost {
  background: transparent;
  color: var(--c-magenta);
  border-color: var(--c-magenta);
}
.btn-ghost:hover, .btn-ghost:focus-visible {
  background: var(--c-magenta);
  color: var(--c-bg);
  text-shadow: none;
  box-shadow: var(--glow-magenta);
}

/* ---------- ACERCA DE ---------- */
.about-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 2.5rem;
}
.about-bio p { margin-bottom: 1.2rem; }
.about-subtitle {
  font-family: var(--f-pixel);
  font-size: 0.85rem;
  color: var(--c-yellow);
  margin: 2rem 0 1rem;
  text-shadow: 0 0 6px rgba(255, 230, 0, 0.5);
}
.skills { list-style: none; }
.skills li {
  display: flex; align-items: center; gap: 1rem;
  margin-bottom: 0.8rem;
  font-family: var(--f-mono);
}
.skill-name { width: 220px; color: var(--c-text); }
.bar {
  flex: 1; height: 12px;
  background: var(--c-bg-alt);
  border: 1px solid var(--c-border);
  position: relative;
  overflow: hidden;
}
.bar span {
  display: block; height: 100%;
  width: var(--w, 50%);
  background: linear-gradient(90deg, var(--c-cyan), var(--c-magenta));
  animation: fillBar 1.5s ease-out;
  box-shadow: var(--glow-cyan);
}
@keyframes fillBar { from { width: 0; } }

.about-card, .contact-aside {
  background: var(--c-panel);
  border: 1px solid var(--c-border);
  padding: 1.5rem;
  position: relative;
}
.about-card::before, .contact-aside::before {
  /* etiqueta tipo ventana */
  content: '';
  position: absolute; top: -1px; left: -1px; right: -1px; height: 18px;
  background: var(--c-cyan);
}
.card-title {
  font-family: var(--f-pixel);
  font-size: 0.8rem;
  color: var(--c-bg);
  background: var(--c-cyan);
  display: inline-block;
  padding: 0.3rem 0.6rem;
  margin: -0.3rem 0 1rem;
  position: relative; z-index: 1;
}

.system-info {
  display: grid; grid-template-columns: auto 1fr; gap: 0.4rem 1rem;
  margin-bottom: 1.5rem;
}
.system-info dt {
  font-family: var(--f-pixel);
  font-size: 0.6rem;
  color: var(--c-magenta);
}
.system-info dd { color: var(--c-text); }

.status-online { color: var(--c-green); animation: pulse 1.5s infinite; }
@keyframes pulse { 50% { opacity: 0.4; } }

.timeline { list-style: none; }
.timeline li {
  display: grid; grid-template-columns: 60px 1fr;
  gap: 0.8rem;
  padding: 0.5rem 0;
  border-bottom: 1px dashed var(--c-border);
}
.timeline li:last-child { border-bottom: none; }
.year {
  font-family: var(--f-pixel);
  font-size: 0.65rem;
  color: var(--c-yellow);
}

.interests {
  font-family: var(--f-mono);
  color: var(--c-text);
  border-left: 3px solid var(--c-magenta);
  padding-left: 0.8rem;
}

@media (max-width: 820px) {
  .about-grid { grid-template-columns: 1fr; }
  .skill-name { width: 150px; font-size: 1rem; }
}

/* ---------- PORFOLIO ---------- */
.filters {
  display: flex; flex-wrap: wrap; gap: 0.6rem;
  margin-bottom: 2rem;
}
.filter-btn {
  font-family: var(--f-pixel);
  font-size: 0.7rem;
  background: transparent;
  color: var(--c-text-dim);
  border: 1px solid var(--c-border);
  padding: 0.6rem 1rem;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 1px;
}
.filter-btn:hover, .filter-btn:focus-visible {
  color: var(--c-cyan);
  border-color: var(--c-cyan);
  outline: none;
}
.filter-btn.is-active {
  color: var(--c-bg);
  background: var(--c-cyan);
  border-color: var(--c-cyan);
  box-shadow: var(--glow-cyan);
}

.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}

.project-card {
  background: var(--c-panel);
  border: 1px solid var(--c-border);
  padding: 0;
  position: relative;
  transition: all 0.2s;
  display: flex; flex-direction: column;
}
.project-card:hover {
  border-color: var(--c-cyan);
  transform: translateY(-4px);
  box-shadow: 0 0 0 1px var(--c-cyan), 0 0 24px rgba(0, 255, 255, 0.2);
}

/* "Captura" del proyecto estilo pantalla retro */
.project-thumb {
  height: 160px;
  background: var(--c-bg);
  border-bottom: 1px solid var(--c-border);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--f-pixel);
  font-size: 0.9rem;
  color: var(--c-cyan);
  text-shadow: var(--glow-cyan);
  position: relative;
  overflow: hidden;
}
/* Bandas de color estilo atributo ZX Spectrum */
.project-thumb::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg,
    rgba(255,0,255,0.08) 0%,
    rgba(0,255,255,0.08) 50%,
    rgba(255,230,0,0.08) 100%);
}

.project-body { padding: 1.2rem; flex: 1; display: flex; flex-direction: column; }
.project-title {
  font-family: var(--f-pixel);
  font-size: 0.85rem;
  color: var(--c-cyan);
  text-shadow: var(--glow-cyan);
  margin-bottom: 0.6rem;
}
.project-desc {
  color: var(--c-text);
  font-size: 1.05rem;
  margin-bottom: 1rem;
  flex: 1;
}
.project-tags {
  display: flex; flex-wrap: wrap; gap: 0.4rem;
  margin-bottom: 1.2rem;
}
.project-tags span {
  font-family: var(--f-pixel);
  font-size: 0.55rem;
  color: var(--c-yellow);
  border: 1px solid var(--c-yellow);
  padding: 0.2rem 0.5rem;
  letter-spacing: 1px;
}

.project-actions {
  display: flex; gap: 0.6rem;
}
.project-btn {
  flex: 1;
  font-family: var(--f-pixel);
  font-size: 0.65rem;
  text-align: center;
  padding: 0.7rem 0.5rem;
  text-decoration: none;
  border: 1px solid var(--c-cyan);
  color: var(--c-cyan);
  background: transparent;
  letter-spacing: 1px;
  transition: all 0.15s;
}
.project-btn:hover, .project-btn:focus-visible {
  background: var(--c-cyan);
  color: var(--c-bg);
  text-shadow: none;
  outline: none;
  box-shadow: var(--glow-cyan);
}
.project-btn.is-secondary {
  border-color: var(--c-magenta);
  color: var(--c-magenta);
}
.project-btn.is-secondary:hover, .project-btn.is-secondary:focus-visible {
  background: var(--c-magenta);
  color: var(--c-bg);
  box-shadow: var(--glow-magenta);
}

.portfolio-empty {
  font-family: var(--f-mono);
  font-size: 1.2rem;
  color: var(--c-text-dim);
  text-align: center;
  padding: 2rem;
}

/* ---------- CONTACTO ---------- */
.contact-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 2.5rem;
}
.contact-form { display: flex; flex-direction: column; gap: 1.2rem; }
.form-row { display: flex; flex-direction: column; gap: 0.4rem; }
.form-row label {
  font-family: var(--f-pixel);
  font-size: 0.65rem;
  color: var(--c-cyan);
  letter-spacing: 1px;
}
.form-row input, .form-row textarea {
  font-family: var(--f-mono);
  font-size: 1.1rem;
  background: var(--c-bg-alt);
  color: var(--c-text);
  border: 1px solid var(--c-border);
  padding: 0.7rem;
  outline: none;
  resize: vertical;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-row input:focus, .form-row textarea:focus {
  border-color: var(--c-cyan);
  box-shadow: var(--glow-cyan);
}
.form-row.has-error input, .form-row.has-error textarea {
  border-color: var(--c-red);
  box-shadow: 0 0 8px rgba(255, 64, 64, 0.5);
}

.form-status {
  font-family: var(--f-mono);
  font-size: 1.1rem;
  min-height: 1.4em;
}
.form-status.is-success { color: var(--c-green); }
.form-status.is-error { color: var(--c-red); }

.social-links { list-style: none; margin-bottom: 1.5rem; }
.social-links li { margin-bottom: 0.6rem; }
.social-links a {
  font-family: var(--f-pixel);
  font-size: 0.7rem;
  color: var(--c-text);
  text-decoration: none;
  letter-spacing: 1px;
  transition: color 0.15s;
}
.social-links a:hover, .social-links a:focus-visible {
  color: var(--c-cyan);
  text-shadow: var(--glow-cyan);
  outline: none;
}

.availability {
  color: var(--c-text);
  margin-bottom: 1.5rem;
}

.ascii-small {
  font-family: var(--f-mono);
  color: var(--c-magenta);
  text-shadow: var(--glow-magenta);
  font-size: 0.9rem;
  line-height: 1.1;
  text-align: center;
  white-space: pre;
}

@media (max-width: 820px) {
  .contact-grid { grid-template-columns: 1fr; }
}

/* ---------- Footer ---------- */
.site-footer {
  text-align: center;
  padding: 2rem 1rem;
  border-top: 2px solid var(--c-border);
  background: var(--c-bg-alt);
  font-family: var(--f-mono);
  color: var(--c-text-dim);
  font-size: 1rem;
}

/* ---------- Utilidades / accesibilidad ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .crt-flicker, .cursor-blink { animation: none; }
}

/* Highlight de la sección activa al hacer scroll */
.nav-link.is-active {
  color: var(--c-magenta);
  border-color: var(--c-magenta);
  text-shadow: var(--glow-magenta);
}
.nav-link.is-active::before { opacity: 1; }