/* ============================================================
   DASHBOARD — topbar, toolbar, carrusel de tarjetas
   ============================================================ */

.app {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  display: grid;
  /* carrusel flexible (1fr) y panel con altura FIJA: las cards se
     dimensionan según la altura del carrusel y el panel no cambia de
     tamaño, así las flechas no se mueven al cambiar de proyecto */
  grid-template-rows: var(--topbar-h) auto 1fr auto auto;
  /* la columna DEBE limitarse al ancho del contenedor; sin esto el grid
     se auto-dimensiona al contenido más ancho (los chips) y desborda */
  grid-template-columns: minmax(0, 1fr);
  opacity: 0;
  transition: opacity 1s var(--ease-soft);
}
/* Permitir que las filas encojan su contenido en lugar de desbordar */
.topbar, .toolbar, .carousel-wrap, .panel, .hints { min-width: 0; }
.app.is-ready { opacity: 1; }
.app[aria-hidden="true"] { pointer-events: none; }

/* ---------------- Topbar ---------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(16px, 3vw, 40px);
  height: var(--topbar-h);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  background: linear-gradient(to bottom, rgba(5,7,13,0.55), transparent);
  z-index: 5;
}
.topbar__left, .topbar__right { display: flex; align-items: center; gap: 14px; }
.topbar__avatar {
  width: 36px; height: 36px; border-radius: 50%;
  object-fit: cover; border: 1px solid var(--stroke-strong);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.12);
}
.topbar__name { font-weight: 600; letter-spacing: .02em; font-size: .98rem; }
.topbar__role { color: var(--text-2); font-size: .74rem; letter-spacing: .04em; }
.topbar__clock {
  font-variant-numeric: tabular-nums;
  font-weight: 300; font-size: 1.15rem; letter-spacing: .04em;
  color: var(--text-0);
}
.topbar__date { color: var(--text-2); font-size: .72rem; text-align: right; }
.topbar__center { text-align: center; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 12px;
  display: grid; place-items: center;
  color: var(--text-1);
  border: 1px solid transparent;
  transition: background .25s, color .25s, transform .25s var(--ease-os), border-color .25s;
}
.icon-btn:hover { background: var(--glass); color: #fff; border-color: var(--stroke); transform: translateY(-2px); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn--accent {
  color: #fff;
  background: linear-gradient(120deg, rgba(var(--accent-rgb),0.85), var(--accent-deep));
  border-color: rgba(var(--accent-rgb),0.6);
}
.icon-btn--accent:hover { box-shadow: var(--shadow-glow); }

/* ---------------- Toolbar (buscador + filtros) ---------------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px clamp(16px, 3vw, 44px) 4px;
  flex-wrap: wrap;
  z-index: 4;
}
.search {
  position: relative;
  display: flex; align-items: center;
  gap: 8px;
  padding: 9px 14px;
  min-width: 220px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--stroke);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  transition: border-color .25s, box-shadow .25s;
}
.search:focus-within { border-color: rgba(var(--accent-rgb),0.6); box-shadow: 0 0 0 3px rgba(var(--accent-rgb),0.12); }
.search svg { width: 16px; height: 16px; color: var(--text-2); flex: none; }
.search input {
  background: none; border: none; outline: none; color: var(--text-0);
  font-size: .9rem; width: 100%;
}
.search input::placeholder { color: var(--text-2); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  white-space: nowrap;
  padding: 8px 15px;
  font-size: .8rem;
  border-radius: 999px;
  color: var(--text-1);
  background: var(--glass);
  border: 1px solid var(--stroke);
  transition: all .25s var(--ease-os);
}
.chip[data-active="true"] {
  color: #fff;
  background: linear-gradient(120deg, rgba(var(--accent-rgb),0.9), var(--accent-deep));
  border-color: rgba(var(--accent-rgb),0.7);
  box-shadow: var(--shadow-glow);
}
.chip:hover { color: #fff; border-color: var(--stroke-strong); transform: translateY(-2px); }
.chip__dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }

.toolbar__spacer { flex: 1; }
.toolbar__btn {
  padding: 8px 15px; font-size: .8rem; border-radius: 999px;
  color: var(--text-1); background: var(--glass); border: 1px solid var(--stroke);
  transition: all .25s var(--ease-os); display: inline-flex; align-items: center; gap: 7px;
}
.toolbar__btn:hover { color: #fff; border-color: var(--stroke-strong); transform: translateY(-2px); }
.toolbar__btn svg { width: 15px; height: 15px; }
.toolbar__btn--accent {
  color: #fff;
  background: linear-gradient(120deg, rgba(var(--accent-rgb),0.9), var(--accent-deep));
  border-color: rgba(var(--accent-rgb),0.7);
  box-shadow: var(--shadow-glow);
}
.toolbar__btn--accent:hover { box-shadow: 0 0 46px -4px rgba(var(--accent-rgb),0.7); }

/* ---------------- Carrusel ---------------- */
.carousel-wrap {
  position: relative;
  display: flex;
  align-items: center;
  overflow: hidden;
  padding: 4px 0;
  perspective: 1600px;
  z-index: 3;
}
.carousel {
  display: flex;
  align-items: center;
  gap: clamp(16px, 2vw, 30px);
  padding: 18px clamp(20px, 8vw, 120px);
  height: 100%;
  will-change: transform;
  transition: transform 0.62s var(--ease-os);
  transform-style: preserve-3d;
}

/* ---------------- Tarjeta ---------------- */
.card {
  position: relative;
  flex: 0 0 auto;
  /* tamaño según la altura disponible del carrusel (cuadradas) con un
     máximo generoso; así son lo más grandes posible sin invadir el panel */
  height: min(90%, 400px);
  width: auto;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-2);
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow-soft);
  transform: scale(0.8) translateY(8px);
  opacity: 0.62;
  transition:
    transform 0.55s var(--ease-os),
    opacity 0.5s var(--ease-soft),
    box-shadow 0.5s var(--ease-soft),
    filter 0.5s var(--ease-soft);
  filter: saturate(0.85) brightness(0.78);
  cursor: pointer;
  /* Sin will-change permanente: evita que el navegador rasterice la card
     a su tamaño natural y la estire al escalarla (causa del difuminado). */
  backface-visibility: hidden;
}
/* Animación de entrada escalonada */
.card { animation: cardIn 0.7s var(--ease-os) backwards; }
@keyframes cardIn {
  from { opacity: 0; transform: scale(0.6) translateY(60px); }
}

.card__media { position: absolute; inset: 0; }
.card__img {
  width: 100%; height: 100%; object-fit: cover;
  transform: none;
  transition: transform 1.1s var(--ease-os);
}
.card__gradient { position: absolute; inset: 0; }
.card__shine {
  position: absolute; inset: 0;
  background: linear-gradient(115deg, transparent 30%, rgba(255,255,255,0.18) 48%, transparent 62%);
  transform: translateX(-120%);
  opacity: 0;
}
.card__overlay {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(5,7,13,0.96) 4%, rgba(5,7,13,0.4) 40%, transparent 72%);
}
.card__body {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 16px 16px 18px;
  display: flex; flex-direction: column; gap: 8px;
}
.card__title {
  font-size: 1.05rem; font-weight: 600; line-height: 1.15;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card__desc {
  font-size: .78rem; color: var(--text-1); line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  max-height: 0; opacity: 0;
  transition: max-height .5s var(--ease-os), opacity .4s ease;
}
.card__meta { display: flex; align-items: center; gap: 12px; font-size: .72rem; color: var(--text-2); }
.card__meta b { color: var(--text-0); font-weight: 600; }
.card__lang { display: inline-flex; align-items: center; gap: 6px; }
.card__lang-dot { width: 9px; height: 9px; border-radius: 50%; box-shadow: 0 0 8px currentColor; }

.card__badges { position: absolute; top: 12px; left: 12px; display: flex; gap: 6px; }
.badge {
  font-size: .64rem; letter-spacing: .05em; text-transform: uppercase;
  padding: 4px 9px; border-radius: 999px;
  background: rgba(0,0,0,0.5); border: 1px solid var(--stroke-strong);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.badge--star { color: #ffd479; }
.badge--dev { color: #7dff9b; }
.badge--featured { color: var(--accent); border-color: rgba(var(--accent-rgb),0.5); }

/* ---- Estado seleccionado (foco) ---- */
.card.is-active {
  opacity: 1;
  filter: saturate(1.05) brightness(1);
  /* escala 1.0 = tamaño nativo → renderizado nítido, sin difuminado */
  transform: scale(1) translateY(-8px);
  border-color: rgba(var(--accent-rgb), 0.55);
  box-shadow:
    0 40px 80px -24px rgba(0,0,0,0.85),
    0 0 0 1px rgba(var(--accent-rgb),0.35),
    var(--shadow-glow);
  z-index: 5;
}
.card.is-active .card__img { transform: scale(1); }
.card.is-active .card__desc { max-height: 40px; opacity: 1; }
.card.is-active .card__shine {
  animation: shine 1.1s var(--ease-os) 0.15s;
}
/* Vecinos inmediatos un poco más grandes que los lejanos */
.card.is-near { opacity: 0.72; filter: saturate(0.9) brightness(0.82); transform: scale(0.88); }

@keyframes shine {
  to { transform: translateX(120%); opacity: 1; }
}

.card:hover:not(.is-active) { opacity: 0.9; filter: saturate(1) brightness(0.9); transform: scale(0.88) translateY(-4px); }

/* Flechas laterales */
.carousel-arrow {
  position: absolute; top: 50%; z-index: 6;
  width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center;
  transform: translateY(-50%);
  background: var(--glass-strong); border: 1px solid var(--stroke);
  color: var(--text-0);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  opacity: 0; transition: opacity .3s, background .25s, transform .25s var(--ease-os);
}
.carousel-wrap:hover .carousel-arrow { opacity: 1; }
.carousel-arrow:hover { background: rgba(var(--accent-rgb),0.25); }
.carousel-arrow--left { left: 18px; }
.carousel-arrow--right { right: 18px; }
.carousel-arrow svg { width: 22px; height: 22px; }

/* Empty state */
.empty-state {
  margin: auto; text-align: center; color: var(--text-2); padding: 40px;
}
.empty-state h3 { color: var(--text-0); font-weight: 500; margin-bottom: 8px; }

/* Hints de controles */
.hints {
  display: flex; gap: 18px; flex-wrap: wrap;
  padding: 8px clamp(16px, 3vw, 44px) 14px;
  color: var(--text-2); font-size: .74rem;
  align-items: center;
}
.hints kbd {
  display: inline-block; min-width: 22px; text-align: center;
  padding: 3px 7px; margin: 0 3px;
  font-family: inherit; font-size: .72rem;
  border-radius: 7px; background: var(--glass); border: 1px solid var(--stroke);
  color: var(--text-1);
}
.hints__group { display: inline-flex; align-items: center; gap: 4px; }

/* ============================================================
   MÓVIL — la página pasa a ser scrollable y todo se apila
   ============================================================ */
@media (max-width: 720px) {
  /* Scroll NATURAL del documento: nada de height:100% ni overflow:hidden,
     que es lo que recortaba el contenido por abajo en móvil. */
  html, body {
    height: auto;
    min-height: 100%;
    overflow-x: clip;      /* evita scroll horizontal sin crear scroller */
    overflow-y: visible;   /* el viewport scrollea de forma natural */
    position: static;
  }

  .app {
    height: auto;
    min-height: 100svh;
    grid-template-rows: auto auto auto auto;
    row-gap: 4px;
  }

  /* ---- Topbar ---- */
  .topbar {
    position: sticky; top: 0;
    height: auto;
    padding: 10px 14px;
    gap: 8px;
    background: linear-gradient(to bottom, rgba(5,7,13,0.85), rgba(5,7,13,0.4));
  }
  .topbar__center { display: none; }        /* reloj oculto en móvil */
  .topbar__role { display: none; }
  .topbar__name { font-size: .9rem; }
  .topbar__avatar { width: 32px; height: 32px; }
  .topbar__left, .topbar__right { gap: 8px; }
  .icon-btn { width: 36px; height: 36px; }

  /* ---- Toolbar apilada ---- */
  .toolbar { padding: 10px 14px 6px; gap: 10px; }
  .search { flex: 1 1 100%; width: 100%; min-width: 0; }
  .chips { flex: 1 1 100%; min-width: 0; }
  .toolbar__spacer { display: none; }
  .toolbar__btn { flex: 1 1 44%; justify-content: center; }

  /* ---- Carrusel ---- */
  .carousel-wrap { padding: 8px 0; }
  .carousel { padding: 14px clamp(16px, 8vw, 60px); gap: 16px; }
  .card { height: auto; width: min(74vw, 320px); }
  .carousel-arrow { display: none; }        /* en móvil se navega por swipe */

  .hints { display: none; }
}
