@import url('https://fonts.googleapis.com/css2?family=Geist:wght@100..900&display=swap');
@import url('https://unpkg.com/normalize.css') layer(normalize);

/* Corregido un pequeño typo en el nombre de la capa (scrollbar) */
@layer normalize, base, demo, stick, effect, scrollbar, debug;

@layer debug {
  [data-debug='true'] li {
    outline: 0.05em dashed currentColor;
  }
  [data-debug='true'] :is(h2, li:last-of-type) {
    outline: 0.05em dashed canvasText;
  }
}

@layer scrollbar {
  @property --hue {
    initial-value: 0;
    syntax: '<number>';
    inherits: false;
  }
  @property --chroma {
    initial-value: 0;
    syntax: '<number>';
    inherits: true;
  }

  [data-sync-scrollbar='true'] {
    scrollbar-color: oklch(var(--lightness) var(--chroma) var(--hue)) #0000;
  }
  @supports (animation-timeline: scroll()) and (animation-range: 0% 100%) {
    [data-sync-scrollbar='true'][data-animate='true'] {
      timeline-scope: --list;
      scrollbar-color: oklch(var(--lightness) var(--chroma, 0) var(--hue)) #0000;
      animation-name: change, chroma-on, chroma-off;
      animation-fill-mode: both;
      animation-timing-function: linear;
      animation-range: entry 50% exit 50%, entry 40% entry 50%,
        exit 30% exit 40%;
      animation-timeline: --list;
      ul {
        view-timeline: --list;
      }
    }
  }

  @keyframes change {
    to {
      --hue: var(--end);
    }
  }
  @keyframes chroma-on {
    to {
      --chroma: 0.3;
    }
  }
  @keyframes chroma-off {
    to {
      --chroma: 0;
    }
  }
}

@layer effect {
  :root {
    --start: 0;
    --end: 360;
    --lightness: 65%;
    --base-chroma: 0.3;
  }
  [data-theme='dark'] {
    --lightness: 75%;
  }
  [data-theme='light'] {
    --lightness: 65%;
  }
  @media (prefers-color-scheme: dark) {
    --lightness: 75%;
  }
  ul {
    --step: calc((var(--end) - var(--start)) / (var(--count) - 1));
  }
  li:not(:last-of-type) {
    color: oklch(
      var(--lightness) var(--base-chroma)
        calc(var(--start) + (var(--step) * var(--i)))
    );
  }

  @supports (animation-timeline: scroll()) and (animation-range: 0% 100%) {
    [data-animate='true'] {
      li {
        opacity: 0.2;
        animation-name: brighten;

        &:first-of-type {
          --start-opacity: 1;
        }
        &:last-of-type {
          --brightness: 1;
          --end-opacity: 1;
        }
        animation-fill-mode: both;
        animation-timing-function: linear;
        animation-range: cover calc(50% - 1lh) calc(50% + 1lh);
        animation-timeline: view();
      }
    }

    @keyframes brighten {
      0% {
        opacity: var(--start-opacity, 0.2);
      }
      50% {
        opacity: 1;
        filter: brightness(var(--brightness, 1.2));
      }
      100% {
        opacity: var(--end-opacity, 0.2);
      }
    }
  }
}

@layer stick {
  section:first-of-type {
    --font-level: 6;
    display: flex;
    line-height: 1.25;
    width: 100%;
    padding-left: 5rem;
  }
  section:last-of-type {
    min-height: 10vh;
    display: flex;
    place-items: center;
    width: 100%;
    justify-content: center;

    h2 {
      --font-level: 6;
    }
  }
  main {
    width: 100%;
    min-width: 0;
  }
  section:first-of-type h2 {
    --font-level: 4;
    position: sticky;
    top: calc(40% - 0.5lh);
    font-size: inherit;
    margin: 0;
    display: inline-block;
    height: fit-content;
    font-weight: 600;
  }
  ul {
    font-weight: 600;
    padding-inline: 0;
    margin: 0;
    list-style-type: none;
  }

  [data-snap='true'] {
    scroll-snap-type: y proximity;

    li {
      scroll-snap-align: center;
    }
  }

  h2,
  li:last-of-type {
    color: var(--canvasText);
  
  }
}

@layer base {
  :root {
    --font-size-min: 14;
    --font-size-max: 20;
    --font-ratio-min: 1.1;
    --font-ratio-max: 1.33;
    --font-width-min: 375;
    --font-width-max: 1500;
    
    /* Variables de color personalizadas y blindadas */
    --canvas: #000000;
    --canvasText: #ffffff;
  }

  /* Si el usuario cambia el tema con el panel, invertimos colores */
  [data-theme='light'] {
    --canvas: #ffffff;
    --canvasText: #000000;
  }

  html, body {
    overflow-x: clip; 
    width: 100%;
  }

  html {
    color-scheme: light dark;
  }

  :where(.fluid) {
    --fluid-min: calc(
      var(--font-size-min) * pow(var(--font-ratio-min), var(--font-level, 0))
    );
    --fluid-max: calc(
      var(--font-size-max) * pow(var(--font-ratio-max), var(--font-level, 0))
    );
    --fluid-preferred: calc(
      (var(--fluid-max) - var(--fluid-min)) /
        (var(--font-width-max) - var(--font-width-min))
    );
    --fluid-type: clamp(
      (var(--fluid-min) / 16) * 1rem,
      ((var(--fluid-min) / 16) * 1rem) -
        (((var(--fluid-preferred) * var(--font-width-min)) / 16) * 1rem) +
        (var(--fluid-preferred) * var(--variable-unit, 100vi)),
      (var(--fluid-max) / 16) * 1rem
    );
    font-size: var(--fluid-type);
  }

  *,
  *:after,
  *:before {
    box-sizing: border-box;
  }

  /* Blindamos el fondo usando nuestras variables exactas */
  body {
    display: grid;
    background-color: var(--canvas) !important;
    color: var(--canvasText);
    min-height: 100vh;
    font-family: 'Geist', 'SF Pro Text', 'SF Pro Icons', 'AOS Icons',
      'Helvetica Neue', Helvetica, Arial, sans-serif, system-ui;
  }

  body::before {
    --size: 45px;
    --line: color-mix(in hsl, canvasText, transparent 70%);
    content: '';
    position: fixed;
    inset: 0; 
    background: linear-gradient(
          90deg,
          var(--line) 1px,
          transparent 1px var(--size)
        )
        50% 50% / var(--size) var(--size),
      linear-gradient(var(--line) 1px, transparent 1px var(--size)) 50% 50% /
        var(--size) var(--size);
    mask: linear-gradient(-20deg, transparent 50%, white);
    transform-style: flat;
    pointer-events: none;
    z-index: -1;
  }

  :where(.x-link):is(:hover, :focus-visible) {
    opacity: 1;
  }

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

/* Configuraciones de Tweakpane externas a layers */
div.tp-dfwv {
  position: fixed;
}


/* =========================================
   CAPA DEMO (Todo el diseño y responsive)
   ========================================= */
@layer demo {
  header {
    min-height: 80vh;
    display: flex;
    align-items: center;
    width: 100%;
    padding-inline: 5rem;
  }

  .content {
    padding-bottom: 6rem;
  }
  
  .user-img {
    width: 30%;
  }

  footer {
    padding-block: 2rem;
    opacity: 0.5;
    text-align: center;
    background-color: #ffde00;
    color: #000;
  }

  h1 {
    --font-size-min: 24;
    --font-level: 8;
    text-wrap: pretty;
    line-height: 0.8;
    margin: 0;
    
    
    color: var(--canvasText);
  }

  .header-wrapper {
    display: flex;
    flex-direction: column; 
    align-items: flex-start; 
    gap: 3rem; 
  }

  .header-tot {
    display: flex;
    align-items: center;
    gap: 10rem;
  }

  .header-subtitle {
    font-family: 'Geist', sans-serif; 
    font-size: clamp(1rem, 1.5vw, 1.3rem); 
    color: var(--canvasText); 
    opacity: 0.8; 
    margin: 0;
    max-width: 50ch; 
    line-height: 1.5;
  }

  /* --- SECCIÓN DE TRABAJOS --- */
  .works-section {
    width: 100%;
    padding-inline: 5rem; 
    margin-bottom: 5rem;
    display: flex;
    flex-direction: column; 
    gap: 3rem; 
    margin-top: 15vh;
    align-items: flex-start; 
    text-align: left;
  }

  .works-title {
    font-size: 2rem;
    color: var(--canvasText);
    border-left: 5px solid #ffde00;
    padding-left: 1rem;
    line-height: 1;
    width: 100%;            
    text-align: left;       
    align-self: flex-start; 
  }

  .works-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr); 
    gap: 2.5rem;
    width: 100%;
  }

  /* --- TARJETA --- */
  .work-card {
    background: color-mix(in srgb, var(--canvasText), transparent 95%);
    border: 1px solid color-mix(in srgb, var(--canvasText), transparent 85%);
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
  }

  .work-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    border-color: #ffde00; 
  }

  .card-image {
    width: 100%;
    height: 200px;
    overflow: hidden;
    border-bottom: 1px solid color-mix(in srgb, var(--canvasText), transparent 90%);
  }

  .card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
  }

  .work-card:hover .card-image img {
    transform: scale(1.05); 
  }

  .card-content {
    padding: 1.5rem;
    flex-grow: 1; 
    display: flex;
    flex-direction: column;
  }

  .card-content h3 {
    margin: 0 0 0.5rem 0;
    color: var(--canvasText);
    font-size: 1.4rem;
  }

  .card-content p {
    font-size: 0.95rem;
    color: color-mix(in srgb, var(--canvasText), transparent 30%);
    margin-bottom: 1.5rem;
    line-height: 1.4;
  }

  .card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
  }

  .card-tags span {
    font-size: 0.75rem;
    background: color-mix(in srgb, var(--canvasText), transparent 90%);
    padding-right: 0.2rem;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }

  .card-links {
    margin-top: auto; 
    display: flex;
    gap: 1rem;
  }

  .btn-link {
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: bold;
    color: #ffde00;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: color 0.2s;
  }

  .btn-link:hover {
    color: #10ce4f;
  }

  /* --- MÁQUINA DE ESCRIBIR --- */
  .typewriter-text, 
  .works-typewriter {
    font-family: 'Geist', monospace;
    color: var(--canvasText);
    overflow: hidden; 
    white-space: nowrap; 
    margin: 0;
    width: 0; 
    border-right: .15em solid #ffde00;
  }

  .typewriter-text {
    padding-left: 5rem;
    font-size: clamp(2rem, 4vw, 1.3rem); 
  }

  .works-typewriter { 
    font-size: 2rem; 
  }

  .typewriter-text.active {
    animation: 
      typing-tools 3s steps(15, end) forwards, 
      blink-caret .75s step-end infinite; 
  }

  .works-typewriter.active {
    animation: 
      typing-works 3s steps(14, end) forwards, 
      blink-caret .75s step-end infinite; 
  }

  @keyframes typing-tools {
    from { width: 0; }
    to { width: 15.5ch; } 
  }

  @keyframes typing-works {
    from { width: 0; }
    to { width: 14.3ch; } 
  }

  @keyframes typing-infinite {
    0%, 10% { width: 0; }
    50%, 80% { width: 18ch; } 
    90%, 100% { width: 0; }
  }

  @keyframes blink-caret {
    from, to { border-color: transparent }
    50% { border-color: #ffde00; }
  }

  @keyframes scroll-left {
    from { transform: translateX(0); }
    to { transform: translateX(calc(-50% - 1.5rem)); }
  }

  /* --- BANNER DE HERRAMIENTAS --- */
  .tools-banner {
    background: #ffde00;
    color: #000;
    width: 100%; 
    padding: 3rem 0;
    margin-block: 5vh 10vh;
    border-top: 1px solid #000;
    border-bottom: 1px solid #000;
    overflow: hidden; 
    position: relative;
    left: 0;
    contain: paint; 
  }

  .tools-banner-inner {
    display: flex;
    white-space: nowrap;
    gap: 3rem;
    width: max-content; 
    animation: scroll-left 25s linear infinite;
    will-change: transform; 
  }

  .tool-icon {
    font-size: 2rem; 
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-transform: uppercase;
  }

  .tool-icon i {
    font-size: 2rem; 
  }

  .tools-banner:hover .tools-banner-inner {
    animation-play-state: paused;
  }

  /* --- SECCIÓN DE ESTUDIOS --- */
  .estudios-section {
    width: 100%;
    padding-inline: 5rem;
    box-sizing: border-box;
    display: flex;
    justify-content: space-around; 
    align-items: flex-start;      
    flex-wrap: wrap;              
    gap: 2rem;                    
    padding-top: 10vh;
  }

  .estudios-details {
    position: relative; 
    width: 30%;
    min-width: 300px;
  }

  .estudios-summary {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    width: 100%;
    color: var(--canvasText);
    cursor: pointer;
  }

  .estudios-summary span {
    font-size: 2rem;
    font-weight: 700;
  }

  /* FIX: Se añadió la llave de cierre faltante en esta clase */
  .icon-plus {
    color: #ffde00 !important;
    font-size: 1.5rem;
    flex-shrink: 0; 
    margin-left: 1rem;
  }

  .estudios-details[open] .icon-plus {
    transform: rotate(45deg); 
  }

  .estudios-content {
    position: absolute; 
    top: 100%; 
    left: 0;
    z-index: 100; 
    width: 100%; 
    margin-top: 0.5rem; 
    padding: 1.5rem;
    background-color: #111 !important; /* Un negro un poco más claro para distinguir la caja */
    border: 1px solid #333 !important; 
    box-shadow: 0 10px 20px rgba(0,0,0,0.8); 
    border-left: 5px solid #ffde00 !important;
    animation: slide-down 0.3s ease-out;
  }

  .estudios-content ul {
    --count: 1; 
    padding: 0;
    opacity: 1;
  }

  .estudios-content li {
    margin-bottom: 1rem;
    font-size: 1.1rem;
    /* Usamos !important para anular cualquier opacidad de la animación */
    opacity: 1 !important; 
    color: var(--canvasText) !important;
    animation: none !important; 
    filter: none !important;
  }

  @keyframes slide-down {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
  }


  /* =========================================
     FOOTER STYLES (2 COLUMNAS)
     ========================================= */
  .main-footer {
    background-color: #111; 
    color: #f1f1f1;
    padding: 3rem 1rem;
    border-top: 1px solid #333;
    font-family: inherit;
  }

  .footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 2.5rem; 
  }

  .footer-left {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
  }

  .footer-name {
    font-size: 1.5rem;
    font-weight: bold;
    margin: 0 0 0.5rem 0;
    color: #fff;
  }

  .footer-contact {
    color: #aaa;
    font-size: 1rem;
    text-decoration: none !important;
    border: none !important;
    box-shadow: none !important;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: color 0.3s ease;
    width: fit-content;
  }

  .footer-contact:hover {
    color: #4CAF50; 
  }

  .copyright {
    margin-top: 1rem;
    font-size: 0.85rem;
    color: #666;
  }

  .footer-right {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
  }

  .social-icons {
    display: flex;
    gap: 1.2rem;
  }

  .social-icons a {
    color: #f1f1f1;
    font-size: 1.5rem;
    transition: color 0.3s ease, transform 0.3s ease;
    text-decoration: none !important;
    border: none !important;
    box-shadow: none !important;
  }

  .social-icons a:hover {
    color: #f4da14;
    transform: translateY(-3px);
  }

  .btn-download-cv {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.95rem !important;
    background-color: #222;
    color: #f1f1f1 !important;
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    border: 1px solid #444 !important;
    text-decoration: none !important;
    box-shadow: none !important;
    transition: all 0.3s ease;
    width: fit-content;
  }

  .btn-download-cv i {
    color: #e2574c; 
  }

  .btn-download-cv:hover {
    background-color: #f4da14;
    border-color: #f4da14 !important;
    color: #fff !important;
  }

  .btn-download-cv:hover i {
    color: #fff;
  }


  /* =========================================
     SECCIÓN DE DESPEDIDA (CTA)
     ========================================= */
  .farewell-section {
    width: 100%;
    padding-inline: 5rem;
    margin-block: 10vh 15vh; /* Mucho espacio para que respire */
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1.5rem;
  }

  .farewell-title {
    font-family: 'Geist', monospace;
    color: var(--canvasText);
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    margin: 0;
  }

  .farewell-text {
    font-size: 1.1rem;
    color: color-mix(in srgb, var(--canvasText), transparent 20%);
    max-width: 60ch; /* Limita el ancho para que se lea bien */
    line-height: 1.6;
    margin: 0;
  }

  /* --- ESTILOS PARA LAS SOFT SKILLS --- */
  .soft-skills-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    margin-block: 1rem; /* Espacio arriba y abajo */
    max-width: 800px;
  }

  .soft-skill {
    background-color: color-mix(in srgb, var(--canvasText), transparent 95%);
    border: 1px solid color-mix(in srgb, var(--canvasText), transparent 80%);
    color: var(--canvasText);
    padding: 0.6rem 1.2rem;
    border-radius: 50px; /* Bordes redondeados tipo píldora */
    font-size: 0.95rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
  }

  .soft-skill i {
    color: #ffde00; /* El icono en amarillo para que destaque sutilmente */
    font-size: 1.1rem;
  }

  .soft-skill:hover {
    border-color: #ffde00;
    transform: translateY(-3px);
    background-color: color-mix(in srgb, var(--canvasText), transparent 90%);
  }

  

  .btn-contact {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background-color: #ffde00;
    color: #000 !important; /* Letra negra para contrastar con el amarillo */
    font-weight: bold;
    font-size: 1.1rem;
    padding: 0.8rem 2.5rem;
    border-radius: 8px;
    text-decoration: none;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    margin-top: 1rem;
  }

  .btn-contact:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(255, 222, 0, 0.4); /* Resplandor amarillo */
  }

  /* =========================================
     RESPONSIVE FINAL CORREGIDO
     ========================================= */
  
  /* --- AJUSTES INTERMEDIOS (Tablets) --- */
  @media screen and (min-width: 768px) {
    .footer-content {
      flex-direction: row;
      justify-content: space-between;
      align-items: center; 
    }
    .footer-right {
      align-items: flex-end; 
    }
  }

  @media (max-width: 1024px) and (min-width: 769px) {
    .works-grid {
      grid-template-columns: repeat(2, 1fr); 
    }
    .header-tot {
      gap: 3rem; 
    }
    .user-img {
      width: 40%;
    }
  }

  /* --- AJUSTES PARA MÓVIL (Teléfonos) --- */
  @media (max-width: 768px) {
    header, 
    section:first-of-type, 
    .typewriter-container, 
    .works-section,
    .estudios-section,
    .farewell-section {
      padding-inline: 1.5rem !important;
      padding-top: 0rem;
    }

    header {
      min-height: auto;
      padding-top: 6rem;
      padding-bottom: 3rem;
    }

    .header-tot {
      gap: 2rem;
    }

    .user-img {
      display: none;
    }

    .typewriter-text {
      font-size: 1.5rem; 
      letter-spacing: 0.05em;
      max-width: 100%; 
      padding-left: 0;
    }

    .works-typewriter {
      font-size: 1.8rem;
    }

    /* Sobrescribimos el keyframe para que en móvil ocupe el 100% */
    @keyframes typing-infinite {
      0%, 10% { width: 0; }
      50%, 80% { width: 100%; } 
      95%, 100% { width: 0; }
    }

    .works-grid {
      grid-template-columns: 1fr; 
      gap: 2rem;
    }

    .tools-banner {
      margin-block: 3vh 6vh; 
      padding: 1.2rem;
    }

    .tools-banner-inner {
      gap: 2rem; 
    }

    .tool-icon {
      font-size: 1.2rem; 
    }

    .tool-icon i {
      font-size: 1.8rem;
    }

    .estudios-section {
      flex-direction: column;
      align-items: center;
      gap: 1.5rem;
    }
    
    .estudios-details {
      width: 100%; 
    }

    .estudios-summary {
      font-size: 1.2rem; 
    }

    .footer-right {
      align-items: center; 
    }
  }
}