/* ============ TECHFLOW — landing monocromática con iridiscencia ============ */
:root {
  --bg: #0a0a0b;
  --ink: #f4f4f5;
  --ink-dim: #9a9aa0;
  --card-bg: #121214;
  --line: rgba(255, 255, 255, 0.08);
  /* hue iridiscente, lo controla JS según el cursor */
  --hue: 200;
  --glow-x: 50vw;
  --glow-y: 50vh;
  --glare-x: 50%;
  --glare-y: 50%;
  --glare-o: 0;
  /* intensidad extra del brillo en el "burst" de clic (0..1) */
  --burst: 0;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden; /* sin scroll: solo la vista inicial */
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Space Grotesk", system-ui, sans-serif;
  display: grid;
  place-items: center;
  cursor: crosshair;
}

/* fuente serif itálica que contrasta con la grotesk */
.serif {
  font-family: "Fraunces", Georgia, serif;
  font-style: italic;
  font-weight: 600;
  letter-spacing: 0;
}

/* ---------- glow que sigue al cursor ---------- */
.cursor-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(
    600px circle at var(--glow-x) var(--glow-y),
    hsla(var(--hue), 80%, 70%, calc(0.10 + var(--burst) * 0.35)),
    hsla(calc(var(--hue) + 60), 80%, 60%, calc(0.05 + var(--burst) * 0.2)) 40%,
    transparent 70%
  );
  transition: background 0.05s linear;
}

/* ---------- textura de grano ---------- */
.grain {
  position: fixed;
  inset: -50%;
  z-index: 1;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain-shift 0.6s steps(4) infinite;
}
@keyframes grain-shift {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-2%, 3%); }
  50% { transform: translate(3%, -2%); }
  75% { transform: translate(-3%, -3%); }
  100% { transform: translate(2%, 2%); }
}

/* ---------- escena con perspectiva ---------- */
.scene {
  perspective: 1400px;
  z-index: 2;
}

.card {
  position: relative;
  width: min(880px, 92vw);
  height: min(580px, 86vh);
  transform-style: preserve-3d;
  will-change: transform;
  user-select: none;
}

/* contenedor que se voltea */
.card-inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 0.9s cubic-bezier(0.4, 0.2, 0.2, 1);
}
.card.flipped .card-inner { transform: rotateY(180deg); }

.card-face {
  position: absolute;
  inset: 0;
  padding: clamp(24px, 4vw, 48px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background:
    linear-gradient(160deg, rgba(255,255,255,0.04), transparent 40%),
    var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 24px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transform-style: preserve-3d;
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(255, 255, 255, 0.03) inset;
  transition: box-shadow 0.4s ease;
}
.card-back {
  transform: rotateY(180deg);
  justify-content: flex-start;
  gap: 12px;
}

.card:hover .card-face {
  box-shadow:
    0 40px 100px rgba(0, 0, 0, 0.7),
    0 0 60px hsla(var(--hue), 70%, 60%, calc(0.12 + var(--burst) * 0.4)),
    0 0 0 1px rgba(255, 255, 255, 0.06) inset;
}

/* reflejo especular sobre la tarjeta */
.card-glare {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(
    500px circle at var(--glare-x) var(--glare-y),
    hsla(var(--hue), 90%, 85%, calc((var(--glare-o) * 0.14) + var(--burst) * 0.25)),
    hsla(calc(var(--hue) + 90), 90%, 75%, calc((var(--glare-o) * 0.06) + var(--burst) * 0.12)) 45%,
    transparent 70%
  );
  mix-blend-mode: screen;
  z-index: 10;
}

/* elementos con profundidad propia (parallax via JS) */
[data-depth] {
  will-change: transform;
  transform-style: preserve-3d;
}

/* ---------- iridiscencia en zonas brillantes ---------- */
.iridescent {
  background: linear-gradient(
    115deg,
    hsl(var(--hue), 85%, 80%),
    hsl(calc(var(--hue) + 45), 90%, 75%) 25%,
    hsl(calc(var(--hue) + 100), 85%, 80%) 50%,
    hsl(calc(var(--hue) + 160), 90%, 78%) 75%,
    hsl(calc(var(--hue) + 220), 85%, 82%)
  );
  background-size: 300% 300%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  animation: shimmer 6s ease-in-out infinite;
  filter: drop-shadow(0 0 calc(18px + var(--burst) * 30px) hsla(var(--hue), 90%, 70%, calc(0.35 + var(--burst) * 0.5)));
}
@keyframes shimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

/* ---------- nav ---------- */
.nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.logo {
  font-weight: 700;
  font-size: 1.3rem;
  letter-spacing: 0.18em;
  cursor: pointer;
}
.logo .dot { -webkit-text-fill-color: initial; color: var(--ink); }
.links { display: flex; gap: clamp(16px, 3vw, 36px); }
.links a {
  color: var(--ink-dim);
  text-decoration: none;
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  position: relative;
  transition: color 0.25s, text-shadow 0.25s;
}
.links a:hover {
  color: hsl(var(--hue), 80%, 80%);
  text-shadow: 0 0 14px hsla(var(--hue), 90%, 70%, 0.7);
}
.links a::after {
  content: "";
  position: absolute;
  left: 0; bottom: -5px;
  width: 0; height: 1px;
  background: hsl(var(--hue), 85%, 75%);
  box-shadow: 0 0 8px hsla(var(--hue), 90%, 70%, 0.8);
  transition: width 0.3s ease;
}
.links a:hover::after { width: 100%; }

/* ---------- hero ---------- */
.hero { text-align: left; }
.eyebrow {
  color: var(--ink-dim);
  font-size: 0.8rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  margin-bottom: 14px;
}
.title {
  font-weight: 700;
  font-size: clamp(2.2rem, 6.2vw, 4.2rem);
  line-height: 1.06;
  letter-spacing: -0.02em;
}
.title .line { display: block; }
.title .serif { font-size: 1.08em; }
.title #fidgetWord {
  cursor: pointer;
  display: inline-block;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.title #fidgetWord:hover { transform: scale(1.04) skewX(-3deg); }
.title #fidgetWord:active { transform: scale(0.96); }

.subtitle {
  margin-top: 18px;
  max-width: 50ch;
  color: var(--ink-dim);
  font-weight: 300;
  font-size: clamp(0.95rem, 1.6vw, 1.1rem);
  line-height: 1.6;
}

/* ---------- botones ---------- */
.cta-row { display: flex; gap: 16px; margin-top: 28px; flex-wrap: wrap; }
.btn {
  font-family: inherit;
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  padding: 14px 28px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.25s, background 0.25s, color 0.25s;
}
.btn:active { transform: scale(0.94); }

.btn-primary {
  border: none;
  background: var(--ink);
  color: var(--bg);
  font-weight: 500;
  position: relative;
  overflow: hidden;
}
.btn-primary:hover {
  transform: translateY(-3px);
  box-shadow:
    0 8px 30px hsla(var(--hue), 80%, 65%, 0.45),
    0 0 0 1px hsla(var(--hue), 80%, 80%, 0.6);
  background: linear-gradient(
    115deg,
    hsl(var(--hue), 70%, 88%),
    hsl(calc(var(--hue) + 80), 75%, 85%),
    hsl(calc(var(--hue) + 160), 70%, 88%)
  );
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-dim);
}
.btn-ghost:hover {
  transform: translateY(-3px);
  color: var(--ink);
  border-color: hsla(var(--hue), 70%, 70%, 0.5);
  box-shadow: 0 0 24px hsla(var(--hue), 80%, 65%, 0.2);
}

.btn-back { padding: 10px 20px; font-size: 0.8rem; }

/* ---------- footer meta ---------- */
.meta {
  display: flex;
  justify-content: space-between;
  color: var(--ink-dim);
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}
.meta-item { cursor: pointer; transition: color 0.25s, text-shadow 0.25s; }
.meta-item:not(.iridescent):hover {
  color: hsl(var(--hue), 80%, 80%);
  text-shadow: 0 0 12px hsla(var(--hue), 90%, 70%, 0.6);
}

/* ---------- paneles del reverso ---------- */
.panel {
  display: none;
  flex: 1;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  min-height: 0;
}
.panel.active { display: flex; }

.panel-title {
  font-weight: 700;
  font-size: clamp(1.6rem, 3.6vw, 2.4rem);
  letter-spacing: -0.02em;
}
.panel-title .serif { font-size: 1.08em; }

/* contacto */
.panel-contacto { align-items: flex-start; }
.email-pill {
  margin-top: 10px;
  font-size: clamp(1rem, 2.4vw, 1.5rem);
  font-weight: 500;
  text-decoration: none;
  padding: 16px 28px;
  border: 1px solid hsla(var(--hue), 70%, 70%, 0.35);
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.3s;
  word-break: break-all;
}
.email-pill:hover {
  transform: scale(1.03);
  border-color: hsla(var(--hue), 80%, 75%, 0.8);
}
.hint {
  color: var(--ink-dim);
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

/* proyectos */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-top: 6px;
}
.project {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
              border-color 0.3s, box-shadow 0.3s, background 0.3s;
}
.project:hover {
  transform: translateY(-4px) scale(1.02);
  border-color: hsla(var(--hue), 75%, 70%, 0.5);
  background: rgba(255, 255, 255, 0.04);
  box-shadow: 0 12px 30px hsla(var(--hue), 80%, 60%, 0.18);
}
.project-icon { font-size: 1.4rem; }
.project h3 {
  margin-top: 8px;
  font-size: clamp(0.85rem, 1.6vw, 1rem);
  font-weight: 500;
}
.project p {
  margin-top: 6px;
  color: var(--ink-dim);
  font-size: 0.8rem;
  font-weight: 300;
  line-height: 1.45;
}

/* formulario */
.contact-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 380px;
  margin-top: 6px;
}
.contact-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--ink-dim);
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.contact-form input {
  font-family: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 16px;
  outline: none;
  transition: border-color 0.3s, box-shadow 0.3s;
}
.contact-form input::placeholder { color: rgba(255,255,255,0.25); }
.contact-form input:focus {
  border-color: hsla(var(--hue), 80%, 75%, 0.7);
  box-shadow: 0 0 18px hsla(var(--hue), 85%, 65%, 0.25);
}
.contact-form .btn { align-self: flex-start; }
.form-success {
  display: none;
  margin-top: 10px;
  color: hsl(var(--hue), 80%, 80%);
  text-shadow: 0 0 14px hsla(var(--hue), 90%, 70%, 0.6);
  letter-spacing: 0.08em;
}
.form-success.show { display: block; }

/* ---------- orbes flotantes ---------- */
.orb {
  position: absolute;
  border-radius: 50%;
  cursor: pointer;
  background: radial-gradient(
    circle at 32% 30%,
    hsla(var(--hue), 90%, 90%, 0.9),
    hsla(calc(var(--hue) + 70), 85%, 70%, 0.5) 45%,
    hsla(calc(var(--hue) + 140), 80%, 55%, 0.15) 75%,
    transparent
  );
  box-shadow:
    0 0 30px hsla(var(--hue), 90%, 70%, 0.4),
    0 0 60px hsla(calc(var(--hue) + 80), 90%, 65%, 0.2);
  animation: float 7s ease-in-out infinite;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.orb:hover { transform: scale(1.35); }
.orb:active { transform: scale(0.7); }

.orb-1 { width: 70px; height: 70px; top: 16%; right: 9%; }
.orb-2 { width: 34px; height: 34px; bottom: 26%; right: 20%; animation-delay: -2.5s; }
.orb-3 { width: 20px; height: 20px; top: 42%; right: 30%; animation-delay: -5s; }

@keyframes float {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -16px; }
}

/* ---------- burst de clic: chispas + onda iridiscente ---------- */
.spark {
  position: fixed;
  width: 6px; height: 6px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 50;
  background: hsl(var(--hue), 90%, 80%);
  box-shadow: 0 0 10px hsl(var(--hue), 90%, 70%);
}

.shockwave {
  position: fixed;
  pointer-events: none;
  z-index: 49;
  border-radius: 50%;
  border: 2px solid hsla(var(--hue), 90%, 75%, 0.9);
  box-shadow:
    0 0 30px hsla(var(--hue), 90%, 70%, 0.8),
    0 0 60px hsla(calc(var(--hue) + 90), 90%, 65%, 0.5) inset;
  mix-blend-mode: screen;
}

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

@media (prefers-reduced-motion: reduce) {
  .grain, .orb, .iridescent { animation: none; }
}
