/* Variables base (Dark)  */
:root{
  --panel: #0f1420;
  --text: #eaf0ff;
  --muted: #d1e1ff;

  --glass: rgba(255,255,255,0.081);
  --border: rgba(255,255,255,0.179);

  --accent: #78e7ff;
  --accent2: #8b7bff;

  --radius: 24px;
  --max: 1120px;

  --blur: 18px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);

  --bp-tablet: 900px;
  --bp-mobile: 600px;
}

/*  Reset mínimo  */
*{ box-sizing: border-box; }
h3{ display:block; font-size:1.17em; margin:1em 0; font-weight:700; max-width:100%; }
a{ color:inherit; text-decoration:none; }
a:focus-visible{ outline:2px solid var(--accent); outline-offset:2px; }

/*  Fondo y tipografía (Dark)  */
body{
  margin: 0;
  color: var(--text);
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text",Inter,Segoe UI,Roboto,Arial,sans-serif;
  line-height: 1.6;

  background:
    radial-gradient(1000px 600px at 15% -10%, #1e3155 0%, transparent 60%),
    radial-gradient(900px 600px at 110% 30%, #15233c 0%, transparent 60%),
    linear-gradient(180deg, #151e38 0%, #0d1125 100%);
  background-attachment: fixed;

  transition: background .6s ease, color .3s ease;
}

/*  Modo claro (override)  */
:root[data-theme="light"]{
  --text: #0b0d12;
  --muted: #3f4c63;

  --glass: rgba(0,0,0,0.05);
  --border: rgba(0,18,132,0.10);

  --accent: #8700c1;
  --accent2:#6600ff;
}

/* Fondo claro aplicado al BODY */
[data-theme="light"] body{
  background:
    radial-gradient(1000px 600px at 15% -10%, #93aaf8 0%, transparent 60%),
    radial-gradient(900px 600px at 110% 30%, #a3d3ff 0%, transparent 60%),
    linear-gradient(180deg, #d5e1ff 0%, #b4c5fc 100%);
  background-attachment: fixed;
  color: var(--text);
  transition: background .6s ease, color .3s ease;
}

/* Dynamic Island NAV */
.island{
  position: sticky; top: 10px; z-index: 9999;
  display: flex; justify-content: center;
  padding: env(safe-area-inset-top) 12px 0;
  pointer-events: none;
}

.island .pill{
  --w-compact: 300px; --w-expanded: 820px;
  --h-compact: 44px;  --h-expanded: 76px;
  --logo: 28px;

  position: relative;
  pointer-events: auto;

  display: grid; grid-auto-flow: column; align-items: center; gap: 10px;
  grid-template-columns: auto 1fr auto;

  inline-size: var(--w-compact);
  block-size: var(--h-compact);
  padding: 8px 12px;

  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--border);
  backdrop-filter: saturate(140%) blur(var(--blur));
  box-shadow: var(--shadow);
  color: var(--text);
  cursor: pointer;

  transition:
    inline-size .30s cubic-bezier(.22,.9,.28,1),
    block-size  .30s cubic-bezier(.22,.9,.28,1),
    padding     .30s ease,
    border-radius .30s ease;
}

.island .pill:focus-visible{
  outline: none;
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--accent) 40%, transparent), var(--shadow);
}

/* Dot inicial */
.pill .dot{
  inline-size: 8px; block-size: 8px;
  border-radius: 50%;
  background: linear-gradient(45deg, var(--accent), var(--accent2));
  transition: opacity .25s ease, transform .25s ease;
}

/* Logo circular oculto en compacto */
.brand-logo{
  position: absolute; left: 10px; top: 50%;
  width: var(--logo); height: var(--logo);
  border-radius: 50%; object-fit: cover;
  opacity: 0; transform: translateY(-50%) scale(.8);
  transition: opacity .25s ease, transform .25s ease;
  box-shadow:
    0 0 0 1px color-mix(in oklab, var(--border) 85%, transparent),
    0 2px 6px rgba(0,0,0,.25);
}

/* Texto compacto centrado */
.label-compact{
  justify-self: center; white-space: nowrap;
  transition: opacity .15s ease;
  font-weight: 700;
}

/* Marca a la izquierda al expandir */
.brand-left{
  position: absolute; left: calc(10px + var(--logo) + 8px); top: 50%;
  transform: translateY(-50%) translateX(6px);
  opacity: 0; pointer-events: none; white-space: nowrap;
  transition: opacity .2s ease, transform .2s ease;

  font-size: 22px; font-weight: 700;
  background: linear-gradient(45deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* Nav oculto por defecto */
.label-expanded{
  display: grid; grid-auto-flow: column; align-items: center; gap: 8px;
  opacity: 0; max-width: 0; overflow: hidden;
  transition: opacity .25s ease, max-width .25s ease;
}

/* Enlaces del nav */
.pill-nav a{
  display: inline-block; padding: 8px 10px; border-radius: 12px;
  background: transparent; border: 1px solid transparent;
  transition: background .18s ease, box-shadow .18s ease, transform .08s ease;
}

/* Hover (desktop) */
@media (hover:hover){
  .island .pill:hover{
    inline-size: var(--w-expanded); block-size: var(--h-expanded);
    padding: 12px 16px; padding-left: calc(var(--logo) + 24px);
    border-radius: 24px;
  }
  .island .pill:hover .label-expanded{ opacity: 1; max-width: 1000px; }
  .island .pill:hover .label-compact{  opacity: 0; }
  .island .pill:hover .brand-left{     opacity: 1; transform: translateY(-50%) translateX(0); }
  .island .pill:hover .dot{            opacity: 0; transform: scale(.5); }
  .island .pill:hover .brand-logo{     opacity: 1; transform: translateY(-50%) scale(1); }

  .pill-nav a:hover{
    background: var(--glass);
    box-shadow: inset 0 0 0 1px var(--border);
    transform: translateY(-.5px);
  }
}

/* Táctil (.open) */
.island.open .pill{
  inline-size: var(--w-expanded); block-size: var(--h-expanded);
  padding: 12px 16px; padding-left: calc(var(--logo) + 24px);
  border-radius: 24px;
}
.island.open .label-expanded{ opacity: 1; max-width: 1000px; }
.island.open .label-compact{  opacity: 0; }
.island.open .brand-left{     opacity: 1; transform: translateY(-50%) translateX(0); }
.island.open .dot{            opacity: 0; transform: scale(.5); }
.island.open .brand-logo{     opacity: 1; transform: translateY(-50%) scale(1); }

/* Switch tema con icono dinámico */
.switch{
  position: relative;
  inline-size: 48px; block-size: 26px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--glass);
  backdrop-filter: blur(10px);
  margin-left: 4px; flex-shrink: 0;
  overflow: hidden;
}
.switch i{
  position: absolute; top: 50%; left: 3px;
  inline-size: 20px; block-size: 20px; border-radius: 50%;
  transform: translateY(-50%);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: #fff;
  background: linear-gradient(45deg, var(--accent), var(--accent2));
  transition: left .25s ease, background .25s ease;
}
:root[data-theme="light"] .switch i{
  left: 25px;
  color: #222;
  background: linear-gradient(45deg, #ffe600, #ddb100);
}

/* Layout general */
main{ max-width:var(--max); margin:20px auto 0; padding:0 16px; }
.section{ margin:28px 0; }
.section h2{ margin:0 0 12px; font-size:clamp(22px,3vw,28px); }

h1{ font-size:clamp(28px,5vw,52px); margin:0; }
.accent{
  background: linear-gradient(45deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.lead{ color:var(--muted); margin:8px 0 16px; }

.btn{
  display:inline-block; padding:12px 16px; border-radius:16px;
  background: linear-gradient(45deg, var(--accent), var(--accent2));
  color:#001; font-weight:700; text-decoration:none; box-shadow: var(--shadow);
  transition: transform .2s ease, box-shadow .2s ease, background .2s ease, color .2s ease, border-color .2s ease;
}
.btn:hover{
  transform: translateY(-2px);
  box-shadow: 0 14px 40px rgba(0,0,0,.35);
  color: var(--accent);
  border: 1px solid var(--accent);
  background: rgba(242,239,239,0.17);
  backdrop-filter: blur(12px);
}
.btn.ghost{
  color: var(--accent);
  border: 1px solid var(--accent);
  background: rgba(242,239,239,0.17);
  backdrop-filter: blur(12px);
}
.btn.ghost:hover{
  background: linear-gradient(45deg, var(--accent), var(--accent2));
  color:#001; transform: translateY(-2px);
  box-shadow: 0 14px 40px rgba(0,0,0,.35);
}

.row{ display:flex; gap:8px; flex-wrap:wrap; }

/* HERO */
.hero{ margin:24px 0 10px; }
.hero-grid{
  display:grid; gap:20px; align-items:center;
  grid-template-columns: 1.3fr 0.7fr;
}
.hero-text{ min-width:0; }

.hero-photo{
  display:block; overflow:hidden; border-radius:22px;
  border:1px solid var(--border); background:var(--glass);
  backdrop-filter:saturate(140%) blur(12px);
  transition: transform .4s ease, box-shadow .4s ease;
}
.hero-photo img{ display:block; width:100%; height:100%; object-fit:cover; }
.hero-photo:hover{ transform:scale(1.01); box-shadow:0 10px 35px rgba(0,0,0,.236); }

.logo-row{
  display:flex; gap:12px; flex-wrap:wrap; align-items:center;
  list-style:none; padding:0; margin:16px 0 0;
}
.logo-row li{ display:flex; align-items:center; }
.logo-row img{ width:35px; height:35px; object-fit:contain; }
.logo-row img:hover{ transform:translateY(-2px); transition:transform .12s ease; }

/*  Cards y grids */
.grid{ display:grid; gap:16px; grid-template-columns:repeat(auto-fit,minmax(260px,1fr)); }
.card{
  padding:12px; border-radius:22px; border:1px solid var(--border);
  background:var(--glass); backdrop-filter:saturate(140%) blur(12px);
  box-shadow: var(--shadow); transform: translateY(4px);
  transition: transform .25s ease, box-shadow .25s ease;
}
.card:hover{ transform:translateY(0); box-shadow:0 14px 35px rgba(0,0,0,.35); }

/*  Experiencia */
.exp-grid{ grid-template-columns:repeat(auto-fit,minmax(300px,1fr)); }
.exp .muted{ color:var(--muted); margin:2px 0 0; }
.exp-head{ display:flex; align-items:flex-start; justify-content:space-between; gap:12px; margin-bottom:8px; }
.badge{ padding:6px 10px; border-radius:999px; border:1px solid var(--border); background:var(--glass); font-size:.9rem; }
.tasks{ margin:8px 0 0; padding-left:18px; }
.tasks li{ margin:6px 0; }

.exp-role{ display:flex; flex-direction:column; align-items:center; gap:4px; }
.exp-logo{ width:100px; height:auto; object-fit:contain; opacity:.9; transition:opacity .25s ease; }
.exp-info{ max-width:150px; }

@media (max-width:600px){
  .exp-role{ flex-direction:row; gap:6px; }
  .exp-logo{ width:56px; }
}

/*    Skills (pill → cuadrado al hover/tap)  */
.skills-pills{ display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:16px; }

.skill-pill{
  --h:110px; --h-open:230px; --rad:22px;

  display:flex; align-items:center; justify-content:space-between; gap:12px;
  height:var(--h); padding:14px 16px;

  border-radius:calc(var(--rad) + 14px);
  border:1px solid var(--border);
  background:var(--glass);
  backdrop-filter:saturate(140%) blur(12px);
  box-shadow:0 8px 24px rgba(0,0,0,.28), inset 0 1px 0 rgba(255,255,255,.04);
  color:var(--text); cursor:pointer; overflow:hidden;

  transition: height .28s cubic-bezier(.22,.9,.28,1),
              border-radius .28s ease, padding .28s ease, box-shadow .28s ease;
}

.pill-left{ display:flex; align-items:center; gap:10px; min-width:140px; }
.pill-left img{ width:30px; height:30px; object-fit:contain; opacity:.9; }
.pill-title{ font-weight:700; white-space:nowrap; font-size:16px; }

.pill-body{
  display:flex; align-items:center; align-content:flex-start; flex-wrap:wrap;
  flex:1 1 auto; column-gap:10px; row-gap:6px;
  max-height:69px; overflow:hidden; gap:10px;
}
.pill-body img{
  width:30px; height:30px; object-fit:contain;
  opacity:.95; transition: width .22s ease, height .22s ease, transform .22s ease, opacity .22s ease;
}

@media (hover:hover){
  .skill-pill:hover{
    height:var(--h-open); border-radius:var(--rad);
    padding:16px; flex-direction:column; align-items:flex-start; justify-content:flex-start;
  }
  .skill-pill:hover .pill-body{ flex-wrap:wrap; gap:14px; margin-top:8px; max-height:none; }
  .skill-pill:hover .pill-body img{ width:65px; height:65px; }
}

.skill-pill.open{
  height:var(--h-open); border-radius:var(--rad);
  padding:16px; flex-direction:column; align-items:flex-start; justify-content:flex-start;
}
.skill-pill.open .pill-body{ flex-wrap:wrap; gap:14px; margin-top:8px; max-height:none; }
.skill-pill.open .pill-body img{ width:60px; height:60px; }

@media (max-width:900px){ .skills-pills{ grid-template-columns:repeat(2,minmax(0,1fr)); } }
@media (max-width:600px){
  .skills-pills{ grid-template-columns:1fr; }
  .pill-title{ font-size:15px; }
  .skill-pill{ --h:77px; --h-open:200px; }
  .skill-pill.open .pill-body img{ width:48px; height:48px; }
  .pill-left{ min-width:135px; }
}

/*    Proyectos  */
.proj-img{
  width:100%; height:auto; object-fit:cover; border-radius:16px;
  border:1px solid #262157;
  box-shadow:0 8px 24px rgba(0,0,0,.28), inset 0 1px 0 rgba(255,255,255,.04);
}
.project-body{ padding:10px 2px 2px; }

/* Botón "Made in" */
.made-in{
  display:flex; align-items:center; gap:10px;
  padding:10px 18px; border-radius:16px;
  border:1px solid var(--border);
  background: rgba(228,228,218,0.132);
  backdrop-filter: blur(12px);
  font-weight:600; color:var(--text);
  transition: transform .2s ease, box-shadow .25s ease, background .2s ease;
}
.made-in img{ width:100px; height:auto; object-fit:contain; }
.made-in:hover{
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  background: rgba(242,239,239,0.17);
}

/*    Contacto   */
.contact-card{
  position:relative; overflow:hidden;
  padding:14px 18px; min-height:64px;

  display:flex; align-items:center; justify-content:center;

  border-radius:24px; border:1px solid var(--border);
  background:var(--glass); backdrop-filter:saturate(140%) blur(12px);
  box-shadow: var(--shadow);

  transition: padding .28s ease, min-height .28s ease;
}
.contact-compact{ display:flex; gap:12px; align-items:center; justify-content:center; }
.contact-compact .ic img{ width:35px; height:35px; border-radius:8px; transition: opacity .18s ease, transform .18s ease; }

.contact-expanded{
  position:absolute; inset:0;
  display:flex; align-items:center; justify-content:center;
  gap:16px; padding:10px;
  opacity:0; pointer-events:none; transition:opacity .22s ease;
}
.contact-expanded a{
  display:flex; align-items:center; gap:8px;
  padding:10px 16px; border-radius:16px; font-weight:600;
  background:var(--glass); border:1px solid var(--border);
  color:var(--text); text-decoration:none;
  transition: background .2s ease, border-color .2s ease, transform .1s ease;
}
.contact-expanded img{ width:20px; height:20px; object-fit:contain; flex-shrink:0; }

@media (hover:hover){
  .contact-card:hover{ min-height:92px; padding:18px 20px; }
  .contact-card:hover .contact-compact .ic img{ opacity:0; transform:scale(.8); }
  .contact-card:hover .contact-expanded{ opacity:1; pointer-events:auto; }
  .contact-expanded a:hover{
    background: color-mix(in oklab, var(--glass) 70%, var(--accent));
    border-color: var(--accent);
    transform: translateY(-1px);
  }
}

/* Móvil: abre por tap */
@media (max-width:600px){
  .contact-expanded{ flex-wrap:wrap; gap:10px; }
  .contact-expanded a{ padding:8px 12px; border-radius:12px; font-size:14px; }
  .contact-expanded img{ width:18px; height:18px; }

  .contact-card.open{ min-height:auto; padding:16px; }
  .contact-card.open .contact-compact{ display:none; }
  .contact-card.open .contact-expanded{
    position:static; opacity:1; pointer-events:auto;
    flex-wrap:wrap; gap:12px;
  }
}

/*   Footer / Terminal  */
.terminal{
  border-radius:22px; overflow:auto; border:1px solid var(--border);
  background:#0a0f18; color:#cfe6ff; box-shadow: var(--shadow);
}
.terminal pre{ margin:0; padding:14px; }
.foot{ margin:40px 0 20px; text-align:center; color:var(--muted); }

/*    Selector de idioma  */
.lang{
  appearance:none; -webkit-appearance:none; -moz-appearance:none;
  height:26px; min-width:64px; padding:0 28px 0 10px;
  border-radius:999px;
  border:1px solid color-mix(in oklab, var(--border) 80%, transparent);
  background: var(--glass);
  backdrop-filter: saturate(140%) blur(10px);
  color: var(--text); font-weight:600; font-size:14px; cursor:pointer; margin-left:8px;
  transition: background .25s ease, border-color .25s ease, color .25s ease;

  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 10px 10px;
}
:root[data-theme='light'] .lang{
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3C/svg%3E");
}
@media (hover:hover){
  .lang:hover{
    background: color-mix(in oklab, var(--glass) 70%, var(--panel));
    border-color: color-mix(in oklab, var(--border) 70%, var(--accent));
  }
}
.lang:focus-visible{ outline:none; box-shadow:0 0 0 2px color-mix(in oklab, var(--accent) 35%, transparent); }
.lang option{ background: var(--panel); color: var(--text); }

/* Modo claro: opciones del menú blancas */
[data-theme="light"] .lang option{
  background: #ffffff;
  color: #0b0d12;
}

/*   Motion y Breakpoints  */
.reveal{ opacity:0; transform:translateY(8px); transition:opacity .5s ease, transform .5s ease; }
.reveal.show{ opacity:1; transform:none; }

@media (prefers-reduced-motion: reduce){
  .reveal, .card, .island .pill{ transition:none !important; }
}

/* Tablet / móvil */
@media (max-width:900px){
  .hero-grid{ grid-template-columns:1fr; }
  .hero-photo{
    order:-1; max-height:360px; max-width:280px; width:80%;
    margin-bottom:14px; margin-inline:auto;
  }
}

/* Móvil: compacta la island y oculta nav */
@media (max-width:600px){
  .island .pill .label-expanded{ display:none !important; }

  .island{ top:6px; padding:0 6px; }
  .island .pill{
    --w-compact: calc(100vw - 100px);
    --w-expanded: calc(100vw - 20px);
    inline-size: var(--w-compact);
    block-size: 46px;
    padding: 6px 12px;
    border-radius: 20px;
    gap: 10px; justify-content: space-between;
  }

  .brand-left{
    display:block !important; position:static; transform:none;
    opacity:1; font-weight:600; font-size:14px; white-space:nowrap;
  }
  .label-compact{ display:none !important; }

  .lang{ height:26px; min-width:60px; font-size:13px; }
  .switch{ transform:scale(.9); margin-left:6px; }
}

/* Proyectos: 2 por fila desktop, 1 en móvil */
#proyectos .grid{
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 18px;
}
@media (max-width:700px){
  #proyectos .grid{ grid-template-columns: 1fr !important; }
}
