/* Tokens & Setup */
:root {
  --ink: #0b2340;
  --ink-2: #0f2e52;
  --ink-3: #14395f;
  --line-faint: rgba(255, 255, 255, 0.06);
  --line: rgba(255, 255, 255, 0.16);
  --line-strong: rgba(255, 255, 255, 0.32);
  --paper: #eaf0f6;
  --muted: #93a9c2;
  --accent: #ff6b35;
  --accent-soft: rgba(255, 107, 53, 0.14);
  --cyan: #6fb8e8;

  --display: "Space Grotesk", sans-serif;
  --body: "Inter", sans-serif;
  --mono: "JetBrains Mono", monospace;

  --max-w: 1180px;
  --edge: clamp(1.25rem, 4vw, 3rem);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

body {
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--display);
  color: var(--paper);
  margin: 0;
  line-height: 1.05;
}

p { margin: 0 0 1em; color: var(--muted); }
a { color: inherit; text-decoration: none; }

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

.section {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: clamp(4rem, 10vw, 7rem) var(--edge);
}

/* i18n handling */
html:not([lang="en"]) [data-i18n="en"] { display: none !important; }
html[lang="en"] [data-i18n="es"] { display: none !important; }

/* Navbar */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem var(--edge);
  background: rgba(11, 35, 64, 0.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-faint);
}

.nav-logo {
  font-family: var(--mono);
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  color: var(--paper);
}
.nav-logo span { color: var(--accent); }

.nav-links {
  display: flex;
  gap: clamp(1rem, 3vw, 2.25rem);
}

.nav-link {
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  color: var(--muted);
  position: relative;
  padding-bottom: 3px;
  transition: color 0.2s ease;
}
.nav-link:hover, .nav-link.active { color: var(--paper); }
.nav-link::after {
  content: "";
  position: absolute;
  left: 0; bottom: 0;
  width: 0; height: 1px;
  background: var(--accent);
  transition: width 0.25s ease;
}
.nav-link:hover::after, .nav-link.active::after { width: 100%; }

.nav-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.lang-toggle {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: none;
  border: 1px solid var(--line);
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  transition: all 0.2s ease;
}
.lang-toggle:hover { color: var(--accent); border-color: var(--accent); }

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 32px; height: 32px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}
.nav-toggle span {
  display: block;
  width: 100%;
  height: 1.5px;
  background: var(--paper);
  transition: transform 0.25s ease, opacity 0.25s ease;
}
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }

/* Hero Section */
.hero {
  position: relative;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 7rem var(--edge) 2rem;
  overflow: hidden;
}

/* Moving background grid animation */
@keyframes grid-scroll {
  0% { background-position: 0 0, 0 0, 0 0, 0 0; }
  100% { background-position: 24px 24px, 24px 24px, 120px 120px, 120px 120px; }
}

.grid-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-image:
    linear-gradient(var(--line-faint) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-faint) 1px, transparent 1px),
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 24px 24px, 24px 24px, 120px 120px, 120px 120px;
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 35%, #000 40%, transparent 90%);
  mask-image: radial-gradient(ellipse 80% 60% at 50% 35%, #000 40%, transparent 90%);
  opacity: 0;
  animation: grid-in 1.4s ease forwards 0.15s, grid-scroll 45s linear infinite;
}
@keyframes grid-in { to { opacity: 1; } }

.hero-content { position: relative; z-index: 1; max-width: 760px; }

.eyebrow {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  color: var(--cyan);
  text-transform: uppercase;
  margin-bottom: 1.25rem;
}

.hero-title {
  font-size: clamp(2.4rem, 7vw, 4.6rem);
  font-weight: 700;
  color: var(--paper);
}
.hero-title .highlight { color: var(--accent); }

.hero-role {
  font-family: var(--mono);
  font-size: clamp(0.95rem, 2vw, 1.15rem);
  color: var(--muted);
  margin: 1.5rem 0 2.25rem;
  min-height: 1.5em;
}
.cursor {
  color: var(--accent);
  animation: blink 1s step-end infinite;
}
@media (prefers-reduced-motion: reduce) { .cursor { animation: none; } }
@keyframes blink { 50% { opacity: 0; } }

.btn-primary {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.9rem;
  letter-spacing: 0.03em;
  color: var(--ink);
  background: var(--accent);
  padding: 0.85rem 1.6rem;
  border-radius: 2px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px -8px var(--accent-soft), 0 0 0 2px var(--accent);
}

/* Interactive Title Block (Cajetín) */
.title-block {
  position: relative;
  z-index: 10;
  align-self: flex-end;
  margin-top: 3.5rem;
  margin-left: auto;
  width: min(100%, 420px);
  border: 1px solid var(--line);
  background: rgba(15, 46, 82, 0.65);
  backdrop-filter: blur(8px);
  /* Hover animation properties */
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.4s ease, background 0.4s ease;
  transform-origin: bottom right;
}

.title-block:hover {
  transform: scale(1.5) translateY(-5px);
  box-shadow: -15px 20px 40px rgba(0,0,0,0.4), 0 0 0 1px var(--cyan);
  background: rgba(11, 35, 64, 0.95);
}

.tb-photo-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 0.75rem;
  border-bottom: 1px solid var(--line);
}

.tb-photo {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--line-strong);
  flex-shrink: 0;
  transition: transform 0.4s ease, border-color 0.4s ease;
}

.title-block:hover .tb-photo {
  transform: scale(1.2) rotate(-5deg);
  border-color: var(--accent);
}

.tb-signature {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.7rem;
  font-style: italic;
  color: var(--muted);
}

.tb-row {
  display: grid;
  grid-template-columns: 100px 1fr;
  border-bottom: 1px solid var(--line-faint);
}
.tb-row:last-child { border-bottom: none; }

.tb-key {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.65rem 0.75rem;
  border-right: 1px solid var(--line-faint);
}

.tb-value {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--paper);
  padding: 0.65rem 0.75rem;
  display: flex;
  align-items: center;
}
.tb-status::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #6fe89a;
  margin-right: 0.5rem;
  flex-shrink: 0;
}
.tb-link:hover { color: var(--accent); }

/* Section Headers */
.section-head {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  margin-bottom: clamp(2.5rem, 6vw, 4rem);
}

.idx {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--ink);
  background: var(--accent);
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.section-head h2 {
  font-size: clamp(1.5rem, 3.5vw, 2.1rem);
  white-space: nowrap;
}

.dim-line {
  flex: 1;
  height: 1px;
  background: var(--line);
  position: relative;
}
.dim-line::before, .dim-line::after {
  content: "";
  position: absolute;
  top: -5px;
  width: 1px;
  height: 11px;
  background: var(--line);
}
.dim-line::before { left: 0; }
.dim-line::after { right: 0; }
.dim-line-full { margin: 0 var(--edge) 1.75rem; }

/* About Section */
.about-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: clamp(2rem, 5vw, 4rem);
  align-items: start;
}

.bio { font-size: 1.05rem; color: var(--paper); }
.stack-label {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--cyan);
  letter-spacing: 0.04em;
  margin-bottom: 0.9rem;
}

.tags {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  padding: 0;
  margin: 0;
}

.tag {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 0.35rem 0.65rem;
  transition: all 0.2s ease;
}
.tag::before { content: "["; margin-right: 0.3em; color: var(--line-strong); }
.tag::after { content: "]"; margin-left: 0.3em; color: var(--line-strong); }
.tag:hover { 
  color: var(--ink); 
  background-color: var(--cyan); 
  border-color: var(--cyan); 
  transform: translateY(-2px);
}
.tag:hover::before, .tag:hover::after { color: var(--ink); }

/* Projects Section */
.work-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.75rem;
}

.project-sheet {
  border: 1px solid var(--line);
  background: var(--ink-2);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.6s ease, transform 0.4s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}
.project-sheet.is-visible { opacity: 1; transform: translateY(0); }
.project-sheet:hover { 
  border-color: var(--cyan); 
  transform: translateY(-6px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.sheet-head {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 1rem;
}
.sheet-num { color: var(--accent); }

/* Updated Preview with B&W to Color effect */
.sheet-preview {
  position: relative;
  height: 160px;
  border: 1px solid var(--line);
  margin-bottom: 1.25rem;
  background: var(--ink-3);
  overflow: hidden; /* Keeps scaled images inside */
}

.preview-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(100%) contrast(1.1) brightness(0.7);
  transition: filter 0.5s ease, transform 0.5s ease;
}

.project-sheet:hover .preview-img {
  filter: grayscale(0%) contrast(1) brightness(1);
  transform: scale(1.05);
}

.preview-label {
  position: absolute;
  bottom: 8px; right: 10px;
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  color: var(--paper);
  background: rgba(11, 35, 64, 0.8);
  padding: 2px 6px;
  border-radius: 2px;
}

.project-sheet h3 { font-size: 1.15rem; margin-bottom: 0.5rem; }
.project-sheet p { font-size: 0.92rem; }
.project-sheet .tags { margin-bottom: 1.1rem; }

.sheet-links {
  display: flex;
  gap: 1.25rem;
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line-faint);
}
.link-btn {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--cyan);
  transition: color 0.2s ease;
}
.link-btn:hover { color: var(--accent); }

/* Contact Section */
.contact-wrap {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: clamp(2rem, 5vw, 4rem);
  align-items: center;
}

.contact-cta {
  font-size: clamp(2rem, 5vw, 3.2rem);
  color: var(--paper);
}

.contact-block { 
  width: 100%; 
  margin: 0; 
  transition: none; /* Disable hover animation for this specific block */
}
.contact-block:hover {
  transform: none;
  box-shadow: none;
  background: rgba(15, 46, 82, 0.65);
}
.contact-block .tb-row { grid-template-columns: 110px 1fr; }

/* Footer */
.footer { padding-top: 3rem; padding-bottom: 2.5rem; }
.footer p {
  text-align: center;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: var(--muted);
}

/* Scroll reveal utility */
.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.reveal.is-visible { opacity: 1; transform: translateY(0); }

/* Responsive */
@media (max-width: 860px) {
  .about-grid, .contact-wrap { grid-template-columns: 1fr; }
  .title-block { width: 100%; margin-left: 0; align-self: stretch; }
}

@media (max-width: 700px) {
  .nav-toggle { display: flex; }
  .nav-links {
    position: fixed;
    top: 60px; left: 0; right: 0;
    flex-direction: column;
    gap: 0;
    background: var(--ink);
    border-bottom: 1px solid var(--line);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
  }
  .nav-links.is-open { max-height: 300px; }
  .nav-link {
    padding: 1rem var(--edge);
    border-bottom: 1px solid var(--line-faint);
  }
  .nav-link::after { display: none; }
}