/* ==========================================================================
   Componentes
   ========================================================================== */

/* Vidrio ------------------------------------------------------------------
   Superficie compartida por la ventana, el header, el selector de idioma,
   los paneles, el visor de certificados y la tarjeta de cierre.
   ------------------------------------------------------------------------- */

.window,
.site-header,
.lang-switch,
.panel,
.lightbox,
.outro {
  background: var(--glass-shine), var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-highlight), var(--glass-shadow);
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .window,
  .site-header,
  .lang-switch,
  .panel,
  .lightbox,
  .outro { background: var(--glass-shine), var(--glass-fallback); }
}

/* Header ------------------------------------------------------------------ */

/* Barra flotante: se despega de los bordes como en la referencia */
.site-header {
  position: sticky;
  top: 12px;
  z-index: 100;
  width: min(var(--max), 100% - 2 * var(--gutter));
  height: var(--header-h);
  margin: 12px auto 0;
  border-radius: 16px;
}

.site-header .container {
  width: 100%;
  height: 100%;
  padding-inline: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  font: 600 15px/1 var(--font-mono);
  white-space: nowrap;
}
.brand__path { color: var(--muted); margin-right: 2px; }

.nav {
  display: flex;
  align-items: center;
  gap: 28px;
}

.nav__links {
  display: flex;
  gap: 24px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 14px;
}
.nav__links a {
  color: var(--muted);
  transition: color var(--dur) var(--ease);
}
.nav__links a:hover { color: var(--text); }

.nav__toggle {
  display: none;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
}

/* Menú móvil: los links se despliegan en un panel bajo el header */
@media (max-width: 900px) {
  .nav { gap: 10px; }
  .nav__toggle { display: grid; }
  .nav__links {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    display: none;
    flex-direction: column;
    gap: 2px;
    padding: 8px;
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    background: rgba(10, 15, 12, .96);   /* casi opaco: el menú no compite con la página (sin blur, no hace falta) */
    box-shadow: var(--glass-highlight), var(--glass-shadow);
    font-size: 16px;
  }
  .site-header.is-open .nav__links { display: flex; }
  .nav__links a { display: block; padding: 12px 14px; border-radius: 10px; }
  .nav__links a:hover { background: rgba(255, 255, 255, .05); }
  .nav__toggle[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }   /* estado activo */
}

/* Pantallas angostas: logo, idioma y menú tienen que entrar en ~320px */
@media (max-width: 420px) {
  .site-header .container { padding-inline: 12px; gap: 8px; }
  .brand { font-size: 14px; }
  .nav { gap: 6px; }
  .lang-switch button { min-width: 30px; padding-inline: 6px; }
  .nav__toggle { width: 36px; height: 36px; }
}

/* Selector de idioma ------------------------------------------------------ */

.lang-switch {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: var(--glass-bg);       /* ya está sobre el vidrio del header: sin segundo brillo */
  box-shadow: none;
}

.lang-switch button {
  min-width: 38px;
  padding: 5px 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: 500 12px/1 var(--font-mono);
  cursor: pointer;
  transition: color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.lang-switch button:hover { color: var(--text); }
.lang-switch button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--on-accent);
}

/* Ventana macOS -----------------------------------------------------------
   <div class="window">
     <div class="window__bar">
       <span class="window__dots" aria-hidden="true"><i></i><i></i><i></i></span>
       <span class="window__title">archivo.ext</span>
     </div>
     <div class="window__body">…</div>
   </div>
   ------------------------------------------------------------------------- */

.window {
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  overflow: hidden;
}

.window__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 38px;
  padding-inline: 14px;
  background: var(--glass-bg);
  border-bottom: 1px solid var(--glass-border-soft);
  flex-shrink: 0;
}

.window__dots { display: flex; gap: 8px; }
.window__dots i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ff5f57;
}
.window__dots i:nth-child(2) { background: #febc2e; }
.window__dots i:nth-child(3) { background: #28c840; }

.window__title {
  font: 400 12px/1 var(--font-mono);
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.window__body {
  flex: 1;
  padding: 20px;
}

/* Variante: bloque de código */
.window--code .window__body {
  padding: 20px 22px;
  overflow-x: auto;
}
.window--code pre {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.75;
  tab-size: 2;
}

/* Variante interactiva (tarjetas de proyecto) */
.window--link {
  transition: border-color var(--dur) var(--ease);
}
.window--link:hover,
.window--link:focus-within { border-color: rgba(255, 255, 255, .22); }

/* Resaltado de sintaxis — sólo --text y --muted (el lima queda para el cursor) */
.tok-kw   { color: var(--muted); }
.tok-var  { color: var(--text); font-weight: 600; }
.tok-key  { color: var(--muted); }
.tok-str  { color: var(--text); }
.tok-punc { color: var(--muted); }
.tok-com  { color: var(--muted); font-style: italic; }

.cursor {
  display: inline-block;
  width: .55em;
  height: 1.1em;
  margin-left: 2px;
  vertical-align: text-bottom;
  background: var(--accent);
  animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* Botones ----------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding-inline: 18px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 500;
  transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.btn:hover { border-color: rgba(255, 255, 255, .28); }

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn--sm {
  height: 34px;
  padding-inline: 12px;
  font-size: 13px;
  font-weight: 600;
}

/* Chat ------------------------------------------------------------------
   Ventana con historial, chips de preguntas rápidas y campo de texto.
   ------------------------------------------------------------------------- */

.chat__log {
  height: 360px;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overscroll-behavior: contain;
}

.chat__msg {
  max-width: 85%;
  padding: 11px 14px;
  border-radius: 14px;
  font-size: 14.5px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}
.chat__msg strong { font-weight: 600; }
.chat__msg--bot {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--glass-border-soft);
  border-bottom-left-radius: 4px;
}
.chat__msg--user {
  align-self: flex-end;
  background: rgba(255, 255, 255, .10);
  border: 1px solid var(--glass-border);
  border-bottom-right-radius: 4px;
}

.chat__cards {
  display: grid;
  gap: 8px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}
.chat__card {
  padding: 10px 12px;
  border: 1px solid var(--glass-border-soft);
  border-radius: 10px;
  background: rgba(255, 255, 255, .02);
}
.chat__card strong { display: block; font-size: 14px; }
.chat__card span { font-size: 13px; color: var(--muted); }

.chat__msg .tags { margin-top: 10px; }

.chat__links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.chat__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 18px 14px;
}

.chip {
  padding: 7px 13px;
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.chip:hover { color: var(--text); border-color: rgba(255, 255, 255, .28); }
.chip[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }   /* estado activo */

.chat__form {
  display: flex;
  gap: 8px;
  padding: 12px 18px 18px;
  border-top: 1px solid var(--glass-border-soft);
}

.chat__input {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding-inline: 14px;
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  background: rgba(0, 0, 0, .25);
  color: var(--text);
  font: inherit;
  font-size: 14.5px;
}
.chat__input::placeholder { color: var(--muted); opacity: 1; }
.chat__input:focus { outline: none; border-color: var(--accent); }   /* estado activo */

.chat__send {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: var(--on-accent);
  cursor: pointer;
  transition: background-color var(--dur) var(--ease);
}
.chat__send:hover { background: var(--accent-hover); }

.typing { display: inline-flex; gap: 4px; padding-block: 6px; }
.typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: typing 1s infinite;
}
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 50% { opacity: .25; } }

/* Tags -------------------------------------------------------------------- */

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}
.tags li {
  padding: 3px 9px;
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  font: 400 12px/1.4 var(--font-mono);
  color: var(--muted);
}

/* Avatar y estado --------------------------------------------------------- */

.avatar {
  position: relative;
  width: 112px;
  height: 112px;
  margin-inline: auto;
}
.avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--glass-border);
  box-shadow: 0 0 0 6px rgba(255, 255, 255, .03), 0 12px 40px rgba(0, 0, 0, .5);
}
.avatar__status {
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--ok);
  border: 3px solid var(--bg);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: 400 12px/1.4 var(--font-mono);
  color: var(--muted);
}
.status i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 4px rgba(61, 220, 132, .12);
}

/* Panel genérico (servicios, datos de "sobre mí") ------------------------- */

.panel { border-radius: var(--radius); }

/* Punto de estado: verde = publicado / en uso, gris = demo */
.dot {
  display: inline-block;
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}
.dot--live { background: var(--ok); box-shadow: 0 0 0 4px rgba(61, 220, 132, .12); }

/* Tarjeta de proyecto (ventana) ------------------------------------------- */

.project__body {
  display: grid;
  gap: 24px;
  padding: 24px;
}
.project--media .project__body { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); align-items: start; }

.project__media {
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--glass-border-soft);
  border-radius: 10px;
  aspect-ratio: 16 / 10;
  background: var(--bg);
}
.project__media img { width: 100%; height: 100%; object-fit: cover; }

.project__text { display: grid; gap: 12px; justify-items: start; }
.project__title { font-size: 1.35rem; line-height: 1.2; letter-spacing: -.01em; }
.project__meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: 400 12px/1.4 var(--font-mono);
  color: var(--muted);
}
.project__short { font-size: 16px; }
.project__detail { color: var(--muted); font-size: 15px; line-height: 1.65; max-width: 70ch; }

.project__stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin: 0;
  padding: 0;
  list-style: none;
  font: 500 13px/1.4 var(--font-mono);
}
.project__stats li::before { content: "▸ "; color: var(--muted); }

.project__role { font-size: 14px; color: var(--muted); }
.project__role strong { color: var(--text); font-weight: 600; }
.project__text .tags { margin-top: 2px; }

.project__links { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 4px; }
.project__note { font: 400 12px/1.4 var(--font-mono); color: var(--muted); }

@media (max-width: 760px) {
  .project--media .project__body { grid-template-columns: 1fr; }
  .project__body { padding: 20px; }
}

/* Stack: grupos de etiquetas ---------------------------------------------- */

.stack { display: grid; gap: 20px; margin: 0; }
.stack__group { display: grid; gap: 8px; }
.stack dt {
  font: 500 12px/1.4 var(--font-mono);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.stack dd { margin: 0; }
.stack .tags { margin: 0; }
.stack .tags li { color: var(--text); font-size: 13px; padding: 4px 10px; }
.stack__group--learning {
  padding: 14px 16px;
  border: 1px dashed var(--glass-border);
  border-radius: var(--radius);
}
.stack__note { margin-top: 8px; font-size: 13px; color: var(--muted); }

/* Versión compacta dentro del chat */
.chat-stack { display: grid; gap: 10px; margin: 10px 0 0; }
.chat-stack dt { font: 500 11px/1.4 var(--font-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.chat-stack dd { margin: 0; }
.chat-stack .tags { margin: 4px 0 0; }
.chat-stack__note { margin-top: 4px; font-size: 12px; color: var(--muted); }

/* Datos de "sobre mí" ----------------------------------------------------- */

.facts { display: grid; gap: 18px; margin: 0; padding: 22px 24px; }
.facts dt {
  font: 500 12px/1.4 var(--font-mono);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.facts dd { margin: 4px 0 0; font-size: 15px; }

/* Formación --------------------------------------------------------------- */

.courses { display: grid; gap: 10px; margin: 0 0 24px; padding: 0; list-style: none; }
.course {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  padding: 14px 18px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  background: var(--glass-bg);
}
.course strong { font-size: 16px; }
.course__issuer { color: var(--muted); font-size: 14px; }
.course__status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  font: 400 12px/1.4 var(--font-mono);
  color: var(--muted);
}

.certs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.cert {
  display: grid;
  align-content: start;
  gap: 10px;
  width: 100%;
  height: 100%;
  padding: 10px;
  border: 1px solid var(--glass-border-soft);
  border-radius: var(--radius);
  background: var(--glass-bg);
  text-align: left;
  cursor: zoom-in;
  transition: border-color var(--dur) var(--ease);
}
.cert:hover { border-color: rgba(255, 255, 255, .22); }
.cert img {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  object-position: top;
  border-radius: 6px;
}
.cert__text { display: grid; gap: 2px; padding: 0 4px 4px; }
.cert__text strong { font-size: 14px; font-weight: 600; }
.cert__text span { font-size: 12.5px; color: var(--muted); }

/* Visor de certificados (<dialog>) ---------------------------------------- */

.lightbox {
  width: min(960px, 100% - 32px);
  max-height: calc(100% - 32px);
  padding: 16px;
  border-radius: 16px;
  color: var(--text);
}
.lightbox::backdrop { background: rgba(5, 8, 6, .78); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.lightbox figure { margin: 0; display: grid; gap: 12px; }
.lightbox img {
  width: 100%;
  height: auto;
  max-height: calc(100vh - 140px);
  object-fit: contain;
  border-radius: 8px;
}
.lightbox figcaption { padding-right: 48px; font-size: 14px; color: var(--muted); }
.lightbox__close {
  position: absolute;
  right: 12px;
  bottom: 10px;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  background: rgba(10, 15, 12, .6);
  cursor: pointer;
}
.lightbox__close:hover { border-color: rgba(255, 255, 255, .28); }

/* Servicios --------------------------------------------------------------- */

.services {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr));
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.service { display: grid; gap: 10px; align-content: start; justify-items: start; padding: 22px; }
.service h3 { font-size: 1.1rem; }
.service p { color: var(--muted); font-size: 14.5px; line-height: 1.6; }
.service .btn { margin-top: 6px; }

/* Chat con IA: párrafos y estado de espera */
.chat__msg p + p { margin-top: 8px; }
.chat[aria-busy="true"] .chip,
.chat[aria-busy="true"] .chat__input,
.chat[aria-busy="true"] .chat__send { opacity: .55; cursor: wait; }
