/* =========================================================
   Tokens de diseño
   ========================================================= */
:root {
  --paper: #ffffff;
  --surface: #f3f7fc;
  --ink: #0a1b36;
  --muted: #56637a;
  --line: #dbe3ee;
  --accent: #1256c4;
  --accent-soft: #e6eefb;
  --sky: #4e93e8;
}

.dark {
  --paper: #060f1e;
  --surface: #0d1c33;
  --ink: #e9f0fa;
  --muted: #9fb0c8;
  --line: #1d2e4a;
  --accent: #6ba4f5;
  --accent-soft: #102544;
  --sky: #8fbdf8;
}

html {
  scroll-behavior: smooth;
}

body {
  text-wrap: pretty;
}

section[id] {
  scroll-margin-top: 84px;
}

.wrap {
  width: 100%;
  max-width: 72rem;
  margin-inline: auto;
  padding-inline: 1.25rem;
}

@media (min-width: 640px) {
  .wrap {
    padding-inline: 2rem;
  }
}

/* =========================================================
   Accesibilidad base
   ========================================================= */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 100;
  padding: 0.65rem 1rem;
  background: var(--accent);
  color: var(--paper);
  font-weight: 600;
  border-radius: 4px;
  transform: translateY(-180%);
  transition: transform 0.2s ease;
}

.skip-link:focus {
  transform: none;
}

/* =========================================================
   Cabecera y navegación
   ========================================================= */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--paper);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.25s ease;
}

.site-header.is-scrolled {
  border-bottom-color: var(--line);
}

.nav {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 68px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  min-height: 44px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  transition: background 0.2s ease, color 0.2s ease;
}

.brand:hover .brand-mark {
  background: var(--accent-soft);
}

.brand-name {
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-weight: 600;
  font-size: 1rem;
}

.menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
}

.nav-menu {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  display: none;
  flex-direction: column;
  gap: 1.25rem;
  padding: 1rem 1.25rem 1.5rem;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.nav-menu.open {
  display: flex;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-list a {
  display: block;
  padding: 0.6rem 0;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.nav-list a:hover {
  color: var(--ink);
}

.nav-list a[aria-current="location"] {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.nav-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-width: 44px;
  min-height: 44px;
  padding-inline: 0.5rem;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.icon-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.icon-btn .icon-sun {
  display: none;
}

.dark .icon-btn .icon-sun {
  display: block;
}

.dark .icon-btn .icon-moon {
  display: none;
}

@media (max-width: 767px) {
  .lang-menu {
    left: 0;
    right: auto;
    max-width: calc(100vw - 2.5rem);
  }
}

/* Selector de idioma */
.lang {
  position: relative;
}

.flag {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
}

.flag svg {
  display: block;
}

html[lang="es"] .flag[data-flag="en"] {
  display: none;
}

html[lang="en"] .flag[data-flag="es"] {
  display: none;
}

.lang-menu {
  position: absolute;
  top: calc(100% + 0.4rem);
  right: 0;
  z-index: 60;
  min-width: 11rem;
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 4px;
}

.lang-menu[hidden] {
  display: none;
}

.lang-menu button {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  min-height: 40px;
  padding: 0.4rem 0.6rem;
  color: var(--ink);
  font-size: 0.9rem;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 3px;
  cursor: pointer;
}

.lang-menu button:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.lang-menu button[aria-selected="true"] {
  color: var(--accent);
  font-weight: 600;
}

.nav-sep {
  display: block;
  align-self: stretch;
  width: 100%;
  height: 1px;
  background: var(--line);
}

@media (min-width: 768px) {
  .menu-toggle {
    display: none;
  }

  .nav-sep {
    width: 1px;
    height: 26px;
    align-self: center;
    margin-inline: 0.25rem;
  }

  .nav-menu {
    position: static;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: 2rem;
    padding: 0;
    background: transparent;
    border: 0;
  }

  .nav-list {
    flex-direction: row;
    align-items: center;
    gap: 1.75rem;
  }

  .nav-list a {
    padding: 0.35rem 0;
  }
}

/* =========================================================
   Secciones
   ---------------------------------------------------------
   El ritmo vertical de las secciones, el filete de los
   encabezados y la tipografia de bloques se resuelven con
   utilidades de Tailwind en el HTML.
   ========================================================= */

/* =========================================================
   Fondo animado (Plexus / Constelación)
   ========================================================= */
.hero-canvas-host {
  position: relative;
  overflow: hidden;
}

#bg-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.hero-canvas-host .wrap {
  position: relative;
  z-index: 1;
}

/* =========================================================
   Inicio (hero)
   ========================================================= */
.hero {
  display: grid;
  gap: 3rem;
  align-items: center;
  padding-block: 3rem;
}

@media (min-width: 768px) {
  .hero {
    padding-block: 5rem;
  }
}

@media (min-width: 1024px) {
  .hero {
    grid-template-columns: minmax(0, 1fr) minmax(0, 0.85fr);
    gap: 4rem;
  }
}

.hero-role {
  color: var(--accent);
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.hero-name {
  margin-top: 0.4rem;
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-size: clamp(2.5rem, 8vw, 4.5rem);
  font-weight: 700;
  line-height: 0.98;
  letter-spacing: -0.03em;
}

.hero-text {
  margin-top: 1.4rem;
  max-width: 46ch;
  color: var(--muted);
  font-size: 1.075rem;
  line-height: 1.65;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 2rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0.7rem 1.4rem;
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: 4px;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.btn-primary {
  background: var(--accent);
  color: var(--paper);
}

.btn-primary:hover {
  background: var(--sky);
  color: var(--paper);
}

.btn-ghost {
  color: var(--ink);
  border-color: var(--line);
}

.btn-ghost:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* Diagrama del stack */
.schematic {
  width: 100%;
  height: auto;
  overflow: visible;
}

.schematic .box {
  fill: var(--surface);
  stroke: var(--line);
  stroke-width: 1;
}

.schematic .bar {
  fill: var(--accent);
}

.schematic .layer-ai .box {
  fill: var(--accent-soft);
  stroke: var(--accent);
  stroke-dasharray: 6 5;
}

.schematic .layer-ai .bar {
  fill: var(--sky);
}

.schematic .wire {
  fill: none;
  stroke: var(--line);
  stroke-width: 1.5;
}

.schematic .wire-ai {
  stroke: var(--accent);
  stroke-dasharray: 5 5;
}

.schematic .dot {
  fill: var(--sky);
}

.schematic text {
  fill: var(--ink);
  font-family: "IBM Plex Sans", system-ui, sans-serif;
}

.schematic .layer-title {
  font-size: 15px;
  font-weight: 600;
}

.schematic .layer-sub {
  fill: var(--muted);
  font-size: 11px;
}

/* =========================================================
   Sobre mí
   ========================================================= */
.about-grid {
  display: grid;
  gap: 2rem;
  margin-top: 3rem;
}

@media (min-width: 900px) {
  .about-grid {
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    gap: 3.5rem;
  }

  .about-list {
    padding-left: 3.5rem;
    border-left: 1px solid var(--line);
  }
}

.about-list {
  display: grid;
  gap: 1.75rem;
}

/* =========================================================
   Tecnologías y herramientas
   ========================================================= */
.tech-categories {
  display: grid;
  gap: 2.5rem;
  margin-top: 3rem;
}

@media (min-width: 900px) {
  .tech-categories {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 3rem 3.5rem;
  }
}

.tech-category {
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}

.tech-category-title {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-size: 1rem;
  font-weight: 600;
}

.tech-category-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.tech-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 0.6rem;
  margin: 1.1rem 0 0;
  padding: 0;
  list-style: none;
}

.tech-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.tech-item:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.tech-badge {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  color: var(--accent);
}

.tech-badge svg {
  display: block;
  overflow: visible;
}

.tech-badge text {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10px;
  font-weight: 500;
  fill: currentColor;
}

.tech-badge .tech-icon {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.dark .tech-badge .tech-icon-mono {
  filter: invert(1) brightness(1.6);
}

.tech-name {
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.25;
}

.tech-item-sm {
  gap: 0.5rem;
  padding: 0.4rem 0.55rem;
}

.tech-item-sm .tech-badge {
  width: 26px;
  height: 26px;
}

.tech-item-sm .tech-badge text {
  font-size: 8px;
}

.tech-item-sm .tech-name {
  font-size: 0.8125rem;
}

/* =========================================================
   Proyectos
   ========================================================= */
.tabs {
  display: inline-flex;
  margin-top: 2.5rem;
  padding: 0.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.tab {
  min-height: 44px;
  padding: 0.6rem 1.1rem;
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.tab:hover {
  color: var(--ink);
}

.tab[aria-selected="true"] {
  color: var(--paper);
  background: var(--accent);
}

#projects-panel {
  margin-top: 2rem;
}

#projects-panel:focus {
  outline: none;
}

#projects-panel:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.project-list {
  display: grid;
}

.project {
  display: grid;
  gap: 1.5rem;
  padding-block: 2rem;
  border-top: 1px solid var(--line);
}

.project:first-child {
  border-top: 0;
}

@media (min-width: 860px) {
  .project {
    grid-template-columns: minmax(0, 45%) minmax(0, 1fr);
    gap: 2.75rem;
    align-items: center;
    padding-block: 2.5rem;
  }
}

.project-media {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface);
  aspect-ratio: 16 / 10;
}

.project-media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: -webkit-optimize-contrast;
  transition: transform 0.5s ease;
}

.project:hover .project-media img {
  transform: scale(1.02);
}

.project-cue {
  position: absolute;
  left: 0;
  bottom: 0;
  padding: 0.4rem 0.8rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--paper);
  background: var(--accent);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.project:hover .project-cue,
.project:focus-within .project-cue {
  opacity: 1;
  transform: none;
}

.project-body {
  display: grid;
  gap: 0.85rem;
  align-content: start;
}

.project-name {
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.project-summary {
  max-width: 60ch;
  color: var(--muted);
  font-size: 0.975rem;
  line-height: 1.65;
}

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

.detail-block .project-tags {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
  padding-left: 0;
}

.detail-block .project-tags .tech-item {
  width: 100%;
}

@media (max-width: 640px) {
  .detail-block .project-tags {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.project-actions {
  margin-top: 0.5rem;
}

.empty-state {
  padding: 3rem 1.5rem;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 4px;
}

.empty-state h3 {
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-size: 1.15rem;
  font-weight: 600;
}

.empty-state p {
  max-width: 46ch;
  margin: 0.6rem auto 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.6;
}

/* Vista de detalle */
.project-detail {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 2px solid var(--accent);
}

.project-detail[hidden] {
  display: none;
}

.project-detail:focus {
  outline: none;
}

.detail-back {
  margin-bottom: 1.75rem;
}

.detail-title {
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-size: clamp(1.6rem, 4vw, 2.25rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.detail-summary {
  max-width: 62ch;
  margin-top: 0.85rem;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.65;
}

.detail-gallery {
  margin-top: 2rem;
  max-width: 589px;
}

.detail-main-image {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  background: var(--surface);
  image-rendering: -webkit-optimize-contrast;
}

.detail-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 0.75rem 0 0;
  padding: 0;
  list-style: none;
}

.detail-thumb {
  padding: 0;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  line-height: 0;
  transition: border-color 0.2s ease;
}

.detail-thumb img {
  width: 96px;
  height: 60px;
  object-fit: contain;
  background: var(--surface);
}

.detail-thumb:hover {
  border-color: var(--accent);
}

.detail-thumb[aria-current="true"] {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.detail-content {
  display: grid;
  gap: 2rem;
  margin-top: 2.5rem;
}

@media (min-width: 900px) {
  .detail-content {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 2rem 3.5rem;
  }

  .detail-block-wide {
    grid-column: 1 / -1;
  }
}

.detail-block {
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.detail-block h4 {
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-size: 1rem;
  font-weight: 600;
}

.detail-block p,
.detail-block li {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.65;
}

.detail-block p {
  margin-top: 0.6rem;
  max-width: 64ch;
}

.detail-block ul {
  display: grid;
  gap: 0.4rem;
  margin: 0.75rem 0 0;
  padding-left: 1.1rem;
}

.detail-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.9rem;
}

.pending {
  font-style: italic;
}

/* =========================================================
   Contacto
   ========================================================= */
.contact-list {
  display: grid;
  gap: 1rem;
  margin: 3rem 0 0;
  padding: 0;
  list-style: none;
}

@media (min-width: 780px) {
  .contact-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.contact-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 88px;
  padding: 1.25rem;
  color: var(--ink);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 4px;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.contact-item:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.contact-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  color: var(--accent);
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--paper);
}

.contact-icon-img {
  display: block;
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.dark .contact-icon-img.contact-icon-mono {
  filter: invert(1) brightness(1.6);
}

.contact-body {
  display: grid;
  gap: 0.15rem;
  min-width: 0;
}

.contact-name {
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
}

.contact-value {
  color: var(--muted);
  font-size: 0.875rem;
  overflow-wrap: anywhere;
}

.contact-item {
  position: relative;
}

/* =========================================================
   Pie de página
   ========================================================= */
.site-footer {
  margin-top: 4rem;
  border-top: 1px solid var(--line);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-block: 2rem;
  color: var(--muted);
  font-size: 0.875rem;
}

.footer-top {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.footer-top:hover {
  text-decoration: underline;
}

/* =========================================================
   Movimiento
   ========================================================= */
@media (prefers-reduced-motion: no-preference) {
  .reveal {
    opacity: 0;
    animation: reveal 0.7s cubic-bezier(0.22, 0.61, 0.36, 1) var(--delay, 0s) forwards;
  }

  .schematic .layer {
    opacity: 0;
    animation: layer-in 0.5s ease calc(0.3s + var(--i) * 0.1s) forwards;
  }

  .schematic .wire {
    stroke-dasharray: 60;
    stroke-dashoffset: 60;
    animation: wire-draw 0.6s ease 0.55s forwards;
  }

  .nav-menu.open {
    animation: menu-in 0.22s ease both;
  }
}

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

  html {
    scroll-behavior: auto;
  }
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes layer-in {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes wire-draw {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes menu-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
