/* =====================================================
   Matías — Hoja de estilos responsive y accesible (v2)
   - Mobile first
   - Mejoras de accesibilidad y rendimiento
   - Animaciones discretas (con resp. a reduced-motion)
   - Soporte claro/oscuro y gestos táctiles
   ===================================================== */

/* ========= Variables (tema) ========= */
:root{
  --bg: #0b1220;
  --bg-soft: #0f182b;
  --card:#121a30;
  --text:#e8edf8;
  --muted:#a9b4c7;
  --brand:#7c9cff;
  --brand-2:#98f5e1;
  --ring: 0 0 0 2px color-mix(in oklab, var(--brand) 45%, transparent);
  --radius: 16px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --section-space: clamp(48px, 7vw, 96px);
  --container: 980px;
  --gap: 22px;
}

@media (prefers-color-scheme: light) {
  :root{
    --bg:#f7f9fc; --bg-soft:#eef2f8; --card:#ffffff; --text:#0b1220; --muted:#54607a; --brand:#375de6; --brand-2:#0db; --shadow: 0 10px 24px rgba(20,30,60,.10);
  }
  .badge{ box-shadow: inset 0 0 0 1px rgba(20,30,60,.06); }
}

/* Ayuda a los navegadores a elegir paleta de formularios/scrollbars */
:root { color-scheme: light dark; }

/* ========= Reset razonable ========= */
*{ box-sizing: border-box }
html,body{ height:100% }

/* Evita zoom molesto, mejora scroll pero respeta reduced-motion */
html{ scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce){ html{ scroll-behavior: auto } }

body{
  margin:0;
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Cantarell, Ubuntu, 'Helvetica Neue', Arial, sans-serif;
  color:var(--text);
  background:
    radial-gradient(1200px 700px at 50% -10%, color-mix(in oklab, var(--brand) 10%, var(--bg)) 0%, var(--bg) 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-soft) 100%);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}

img, video { max-width: 100%; height: auto; display:block }

/* ========= Contenedor y layout base ========= */
.container{ max-width: var(--container); margin: 0 auto; padding: clamp(16px, 3vw, 24px); }
header{ display:flex; align-items:center; justify-content:space-between; gap:12px; padding: 8px 0; }
.logo{ font-weight:800; letter-spacing:.2px; font-size: clamp(18px, 2.4vw, 22px); }
.logo span{ color: var(--brand); }

/* ========= HERO (texto izq / foto der) ========= */
.hero{
  display:grid; gap: clamp(18px, 3vw, 28px); align-items:center;
  grid-template-columns: 1fr;           /* móvil primero */
  padding: clamp(36px, 6vw, 56px) 0 var(--section-space);
  text-align:left;
}
.hero-content{ order:2; }
.hero-photo{ order:1; position:relative; justify-self:center; }

/* Foto grande + glow sutil */
.hero img{
  width: clamp(200px, 40vw, 360px);
  height: clamp(200px, 40vw, 360px);
  border-radius: 50%; object-fit: cover;
  border:4px solid var(--brand);
  box-shadow: var(--shadow);
}
.hero-photo::after{
  content:""; position:absolute; inset:-14px; z-index:-1; border-radius:50%;
  background: radial-gradient(closest-side, color-mix(in oklab,var(--brand) 35%, transparent), transparent 70%);
  filter: blur(18px); opacity:.55;
}

@media (min-width: 880px){
  .hero{ grid-template-columns: 1.2fr .9fr; }
  .hero-content{ order:1; }
  .hero-photo{ order:2; justify-self:end; }
}

.hero-photo {
  position: relative;
  perspective: 1200px;
}

.coin {
  width: clamp(200px, 40vw, 360px);
  aspect-ratio: 1;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.8s ease-in-out;
  border-radius: 50%;
}

.coin:hover {
  transform: rotateY(180deg);
}

.coin img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  border: 4px solid var(--brand);
  box-shadow: var(--shadow);
  backface-visibility: hidden; /* 🔥 oculta la cara trasera */
}

.coin .back {
  transform: rotateY(180deg);
}

/* Titular/subtítulo */
.title{ font-size: clamp(28px, 6vw, 56px); line-height:1.05; margin: 0 0 8px; letter-spacing:-.02em; }
.subtitle{ font-size: clamp(15px, 2.4vw, 21px); color:var(--muted); margin: 0 0 14px; max-width: 72ch; line-height: 1.65; }

/* CTA */
.cta-row{ display:flex; flex-wrap:wrap; gap:14px; margin-top: 10px; justify-content:flex-start; }
.btn{
  --_bg:var(--brand); --_fg:#0b1220;
  display:inline-flex; align-items:center; gap:.6rem;
  padding:.9rem 1.1rem; border-radius: 999px;
  text-decoration:none; font-weight:700;
  background: var(--_bg); color: var(--_fg);
  box-shadow: var(--shadow); border: none; outline: none;
  transition: transform .08s ease, box-shadow .2s ease, background .2s ease;
}
.btn:hover{ transform: translateY(-1px); }
.btn:active{ transform: translateY(0); filter: saturate(1.05) }
.btn:focus-visible{ box-shadow: var(--shadow), var(--ring); }
.btn.ghost{
  --_bg: color-mix(in oklab, var(--card) 60%, transparent);
  --_fg:var(--text);
  border: 1px solid color-mix(in oklab, var(--brand) 18%, transparent);
  box-shadow:none;
}
.btn.small{ padding:.65rem .9rem; font-weight:600 }

/* En móvil centra las CTAs y haz que quepan bien */
@media (max-width: 520px){ .cta-row{ justify-content:center; } .btn.small{ flex: 1 1 auto; } }

/* Badge */
.badge{
  display:inline-flex; align-items:center; gap:.5rem; font-size:.92rem; padding:.38rem .7rem;
  border-radius: 999px; background: color-mix(in oklab, var(--brand) 10%, transparent); color:var(--text);
}

/* ========= Grid principal ========= */
.grid{ display:grid; gap:var(--gap); grid-template-columns: 1fr; margin-top: var(--section-space); }
@media (min-width: 760px){ .grid{ grid-template-columns: 1.45fr .95fr; } }

/* ========= Cards ========= */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: clamp(20px, 3.4vw, 28px);
  box-shadow: var(--shadow);
  border: 1px solid color-mix(in oklab, var(--brand) 14%, transparent);
  content-visibility: auto; /* rendimiento */
  
  /* ✨ para animaciones suaves */
  transition: transform .15s ease, box-shadow .2s ease, background .2s ease;
}

.card:hover {
  background: color-mix(in oklab, var(--brand) 10%, var(--card));
  transform: translateY(-4px);
  box-shadow: 0 14px 28px rgba(0,0,0,.35);
}

/* ========= Listas de enlaces ========= */
.list{ display:grid; gap:12px; margin:0; padding:0; list-style:none; }
.list a{
  color:inherit; text-decoration:none; display:flex; align-items:center; gap:.7rem;
  padding:.75rem .85rem; border-radius: 12px; border: 1px solid transparent;
  transition: background .15s ease, border-color .15s ease, transform .06s ease;
}
@media (hover:hover){
  .list a:hover{ background: color-mix(in oklab, var(--brand) 10%, transparent); border-color: color-mix(in oklab, var(--brand) 18%, transparent); transform: translateY(-1px); }
}

.card:hover {
  transform: translateY(-4px) scale(1.02);
}

/* ========= Features ========= */
.features{ display:grid; grid-template-columns:repeat(3,1fr); gap:16px; }
.features article{
  background:color-mix(in oklab,var(--brand) 6%,var(--card));
  border:1px solid color-mix(in oklab,var(--brand) 16%,transparent);
  padding:18px; border-radius:14px;
}
.features h3{ margin:.2rem 0 .4rem; font-size:1.05rem }
@media(max-width:900px){ .features{ grid-template-columns:1fr } }

/* ========= Artículos ========= */
.articles { 
  display: grid; 
  grid-template-columns: 1fr; 
  gap: 14px; 
}

.article-card {
  display: block; 
  text-decoration: none; 
  color: inherit;
  background: color-mix(in oklab,var(--brand) 6%,var(--card));
  border: 1px solid color-mix(in oklab,var(--brand) 16%,transparent);
  padding: 18px; 
  border-radius: 14px; 
  transition: transform .18s ease, background .2s ease, box-shadow .2s ease;
}

@media (hover:hover) {
  .article-card:hover {
    transform: translateY(-3px) scale(1.03);  /* ✨ efecto agrandar */
    background: color-mix(in oklab,var(--brand) 10%,var(--card));
    box-shadow: 0 10px 28px rgba(0,0,0,.35);
  }
}

.article-card h3 { 
  margin:.2rem 0 .35rem; 
  font-size:1.05rem 
}

.article-card .pill { 
  display:inline-block; 
  font-size:.78rem; 
  padding:.18rem .5rem; 
  border-radius:999px; 
  border:1px solid color-mix(in oklab,var(--brand) 24%,transparent); 
}


/* ========= Proyectos ========= */
.projects { 
  display: grid; 
  grid-template-columns: repeat(3,1fr); 
  gap: 16px; 
}

.proj { 
  display: block; 
  text-decoration: none; 
  color: inherit; 
  background: var(--card); 
  border: 1px solid color-mix(in oklab,var(--brand) 16%,transparent); 
  padding: 18px; 
  border-radius: 14px; 
  transition: transform .18s ease, background .2s ease, box-shadow .2s ease;
}

@media (hover:hover) {
  .proj:hover { 
    background: color-mix(in oklab,var(--brand) 10%,var(--card)); 
    transform: translateY(-3px) scale(1.03);  /* ✨ efecto agrandar */
    box-shadow: 0 12px 30px rgba(0,0,0,.35);
  }
}

.proj h3 { 
  margin:.2rem 0 .4rem; 
  font-size:1.05rem 
}

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

.tags li { 
  font-size: .8rem; 
  padding: .2rem .5rem; 
  border-radius: 999px; 
  border: 1px solid color-mix(in oklab,var(--brand) 24%,transparent) 
}

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

/* ========= Timeline (CV corto) ========= */
.timeline {
  --rail: 84px;
  position: relative;
  display: grid;
  gap: 18px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline::before {
  content: "";
  position: absolute;
  left: var(--rail);
  top: .5rem;
  bottom: .5rem;
  width: 2px;
  background: color-mix(in oklab, var(--brand) 26%, transparent);
  border-radius: 2px;
}

.timeline li {
  position: relative;
  padding-left: calc(var(--rail) + 24px);
  background: color-mix(in oklab, var(--brand) 6%, var(--card));
  border: 1px solid color-mix(in oklab, var(--brand) 16%, transparent);
  border-radius: 12px;
  padding-block: 12px;

  /* ✨ añadimos transición para suavizar */
  transition: transform .18s ease, background .2s ease, box-shadow .2s ease;
}

.timeline li::before {
  content: "";
  position: absolute;
  left: calc(var(--rail) - 6px);
  top: .9rem;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--brand);
  border: 2px solid color-mix(in oklab, var(--card) 80%, transparent);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--brand) 25%, transparent);
  transition: transform .12s ease, box-shadow .12s ease;
}

.timeline li > span {
  position: absolute;
  left: 0;
  top: 10px;
  width: var(--rail);
  text-align: right;
  color: var(--brand);
  font-weight: 800;
  letter-spacing: .2px;
  padding-right: 16px;
}

.timeline li strong { display: inline-block; margin-bottom: 2px; }
.timeline li small  { color: var(--muted); display:block; margin-top:.35rem; font-size:.9em; opacity:.85 }

@media (hover:hover) {
  .timeline li:hover {
    background: color-mix(in oklab, var(--brand) 10%, var(--card));
    transform: scale(1.03);        /* 👈 hace que crezca un poco */
    box-shadow: 0 8px 24px rgba(0,0,0,.35); /* opcional: sombra extra */
  }
  .timeline li:hover::before {
    transform: scale(1.15);
    box-shadow: 0 0 0 5px color-mix(in oklab, var(--brand) 32%, transparent);
  }
}

/* Responsive timeline */
@media (max-width: 640px){
  .timeline{ --rail: 0; }
  .timeline::before{ display:none }
  .timeline li{ padding-left: 22px; }
  .timeline li::before{ left: 0; top: 1rem; }
  .timeline li > span{
    position: static;
    display: inline-block;
    font-weight: 800;
    color: var(--brand);
    margin: 0 8px 4px 0;
    padding: 0;
    width: auto;
    text-align: left;
  }
}

/* ========= Logos (social proof) ========= */
.logos { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 28px; justify-items: center; align-items: center; margin-top: 18px; }
.logos img { max-width: 140px; max-height: 60px; object-fit: contain; filter: grayscale(100%) brightness(0.9); opacity: 0.85; transition: filter .3s ease, opacity .3s ease; }
@media (hover:hover){ .logos img:hover { filter: grayscale(0%) brightness(1); opacity: 1; } }

/* ========= Contacto ========= */
.contact{ display:grid; gap:12px }
.contact input,.contact textarea{ background:color-mix(in oklab,var(--brand) 6%,var(--card)); border:1px solid color-mix(in oklab,var(--brand) 18%,transparent); color:var(--text); padding:.9rem 1rem; border-radius:12px }
.contact input:focus,.contact textarea:focus{ outline:none; box-shadow:var(--ring) }

/* ========= Galería de videos ========= */
#charlas .video-grid { display: grid; grid-template-columns: 1fr; gap: 18px; }
@media(min-width:620px) { #charlas .video-grid { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media(min-width:980px) { #charlas .video-grid { grid-template-columns: repeat(4, minmax(0,1fr)); } }

#charlas .video-card { position: relative; border-radius: 14px; overflow: hidden; background: var(--card); border: 1px solid color-mix(in oklab, var(--brand) 16%, transparent); box-shadow: var(--shadow); transition: transform .2s ease, box-shadow .2s ease; }
@media (hover:hover){ #charlas .video-card:hover { transform: translateY(-4px); box-shadow: 0 12px 32px rgba(0,0,0,.45); } }

#charlas .video-thumb { width: 100%; aspect-ratio: 16/9; object-fit: cover; object-position: center; display: block; filter: saturate(1.1) contrast(1.05); transition: transform .35s ease; }
@media (hover:hover){ #charlas .video-card:hover .video-thumb { transform: scale(1.06); } }

#charlas .video-overlay { position: absolute; inset: 0; display: grid; place-items: center; background: linear-gradient(180deg, rgba(0,0,0,.1) 30%, rgba(0,0,0,.55)); opacity: 0; transition: opacity .25s ease; }
@media (hover:hover){ #charlas .video-card:hover .video-overlay { opacity: 1; } }

#charlas .play { width: 60px; height: 60px; border-radius: 999px; display: grid; place-items: center; backdrop-filter: blur(6px); background: rgba(0,0,0,.55); border: 1px solid rgba(255,255,255,.25); transition: transform .2s ease; }
@media (hover:hover){ #charlas .video-card:hover .play { transform: scale(1.1); } }
#charlas .play svg { width: 26px; height: 26px; fill: #fff; }

#charlas .video-meta { position: absolute; left: 14px; right: 14px; bottom: 12px; color: #fff; font-weight: 700; text-shadow: 0 2px 10px rgba(0,0,0,.65); font-size: 1rem; line-height: 1.3; }

/* ========= Footer ========= */
footer{ opacity:.85; color:var(--muted); font-size:.98rem; text-align:center; padding: calc(var(--section-space) + 8px) 0 44px; }

/* ========= Utilidades ========= */
.icons svg{ width:20px; height:20px; flex:0 0 20px; }
.sep{ height:1px; background: color-mix(in oklab, var(--brand) 14%, transparent); margin: 20px 0; }
.nu{ text-decoration: none; background: linear-gradient(transparent 65%, color-mix(in oklab, var(--brand) 24%, transparent) 0); }

/* ========= Skills Badges ========= */
.skills-badges { display: flex; flex-wrap: wrap; gap: 18px; justify-content: center; margin-top: 20px; }
.badge-skill { display: flex; flex-direction: column; align-items: center; width: 90px; text-align: center; padding: 10px; border-radius: 50%; background: color-mix(in oklab, var(--brand) 10%, var(--card)); box-shadow: var(--shadow); transition: transform 0.15s ease, background 0.15s ease; }
@media (hover:hover){ .badge-skill:hover { transform: scale(1.08); background: color-mix(in oklab, var(--brand) 25%, var(--card)); } }
.badge-skill img { width: 40px; height: 40px; margin-bottom: 6px; }
.badge-skill span { font-size: 0.85rem; font-weight: 600; color: var(--text); }

/* ========= Contact links con colores de marca ========= */
.contact-links a { display: flex; align-items: center; gap: 10px; padding: .9rem 1rem; border-radius: 12px; font-weight: 600; transition: background .2s ease, transform .1s ease; text-decoration: none; color: inherit }
.contact-links a svg { width: 22px; height: 22px; flex-shrink: 0; }
@media (hover:hover){
  .contact-links a[href*="mailto"]:hover { background: rgba(124,156,255,.15); }
  .contact-links a[href*="linkedin"]:hover { background: #0077b533; }
  .contact-links a[href*="github"]:hover { background: #6e768133; }
  .contact-links a[href*="youtube"]:hover { background: #ff000033; }
  .contact-links a:hover { transform: translateY(-2px); }
}

/* ========= Carrusel móvil (charlas) ========= */
@media (max-width: 620px){
  #charlas .video-grid{ display: flex; gap: 14px; overflow-x: auto; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; padding-bottom: 6px; }
  #charlas .video-card{ flex: 0 0 85%; scroll-snap-align: start; }
}

/* ========= Ajustes responsivos progresivos ========= */
@media (max-width: 900px){ .projects { grid-template-columns: 1fr; } .features { grid-template-columns: 1fr; } }
@media (max-width: 700px){ .skills-badges { justify-content: center; gap: 14px; } .badge-skill { width: 88px; } }
@media (max-width: 520px){ .title { font-size: clamp(26px, 7vw, 40px); } .subtitle { font-size: 0.98rem; } .card { padding: 18px; } }

/* ========= Foco y targets táctiles ========= */
a, button { min-height: 44px; }
a:focus-visible, button:focus-visible { box-shadow: var(--ring); outline: none; }

/* ========= Hover sólo en dispositivos con puntero ========= */
@media (hover:none){
  .btn, .list a, .proj, .article-card, #charlas .video-card { transition: none; }
}

/* ========= Utilidades extra ========= */
.visually-hidden{ position:absolute !important; height:1px; width:1px; overflow:hidden; clip:rect(1px,1px,1px,1px); white-space:nowrap; }
.max-w-prose{ max-width: 72ch }
.center{ display:grid; place-items:center }

/* ========= Pequeñas mejoras de contraste en título cabecera ========= */
.header-title h1 {
  margin: 0;
  font-size: clamp(1.6rem, 3.5vw, 2.4rem);
  font-weight: 900;
  text-shadow: 0 4px 8px rgba(0,0,0,.26);
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #ffffff 0%, #eaf2ff 100%);
  -webkit-background-clip: text; 
  background-clip: text; 
  -webkit-text-fill-color: transparent;
  display:flex; align-items:center; justify-content:center; gap:.75rem;
}

/* ========= Subtítulos de secciones ========= */
.section h2 {
  font-size: clamp(20px, 2.4vw, 26px);
  margin: 0 0 12px;
  letter-spacing: -.015em;
  position: relative;
  padding-bottom: .35rem; /* espacio para el subrayado */
}

.section h2::after {
  content:"";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 72px; 
  height: 3px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--brand), color-mix(in oklab, var(--accent) 60%, var(--brand)));
  opacity: .95;
}

/* Subtítulos con subrayado degradado */
:where(.section, .card) h2{
  font-size: clamp(20px, 2.4vw, 26px);
  margin: 0 0 12px;
  letter-spacing: -.015em;
  position: relative;        /* necesario para el ::after */
  padding-bottom: .35rem;    /* espacio para la rayita */
}

:where(.section, .card) h2::after{
  content:"";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 72px;
  height: 3px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--brand), color-mix(in oklab, var(--accent, var(--brand-2)) 60%, var(--brand)));
  opacity: .95;
}
