/* UFY PHONE — Visor de historias · Diseño AA */

.ufy-story-viewer {
  --story-text: #f7f3ff;
  --story-border: rgba(205, 171, 255, 0.55);

  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;

  background: rgba(10, 6, 18, 0.94);
  color: var(--story-text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

.ufy-story-viewer::backdrop {
  background: rgba(10, 6, 18, 0.8);
}

.ufy-story-viewer,
.ufy-story-viewer *,
.ufy-story-viewer *::before,
.ufy-story-viewer *::after {
  box-sizing: border-box;
}

.ufy-story-viewer [hidden] {
  display: none !important;
}

.ufy-story-viewer-stage {
  position: relative;
  isolation: isolate;
  width: min(100%, 520px);
  height: 100%;
  margin-inline: auto;
  overflow: hidden;
  background: #140e1e;
}

.ufy-story-viewer-media {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.ufy-story-viewer-media img,
.ufy-story-viewer-media video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Información superior: su temporizador se conectará en JS. */

.ufy-story-viewer-header {
  position: absolute;
  z-index: 2;
  top: 0;
  right: 0;
  left: 0;

  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0px;
  padding: max(8px, env(safe-area-inset-top)) 12px 16px;

  background: linear-gradient(
    rgba(15, 8, 27, 0.5),
    transparent
  );

  opacity: 1;
  transition: opacity 180ms ease;
  pointer-events: none;
}

.ufy-story-viewer-header button,
.ufy-story-viewer-header a {
  pointer-events: auto;
}

.ufy-story-viewer-header.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.ufy-story-viewer button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.ufy-story-viewer button:disabled {
  cursor: default;
  opacity: 0.5;
}

.ufy-story-viewer :focus-visible {
  outline: 2px solid #c4a4ff;
  outline-offset: 4px;
}

.ufy-story-viewer-close {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;

  min-width: 60px;
  min-height: 44px;
  
  padding: 0 8px;
  border: 0;
  background: transparent;
  font-size: 12px;
  touch-action: none;
}

.ufy-story-viewer-close svg {
  width: 24px;
  height: 24px;
  
}

/* Cuadro del nombre, centrado y cuadrado. */

.ufy-story-viewer-identity {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;

  width: clamp(112px, 30vw, 142px);
  aspect-ratio: 1;
  padding: 10px 10px 15px;

  border: 1px solid var(--story-border);
  border-radius: 14px;
  background: rgba(42, 24, 65, 0.58);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.ufy-story-viewer-avatar {
  display: grid;
  place-items: center;
  flex-shrink: 0;

  width: 46px;
  height: 46px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 12px;
  background: #46325f;
}

.ufy-story-viewer-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ufy-story-viewer-name {
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
}

.ufy-story-viewer-time {
  color: #e0d4ed;
  font-size: 11px;
  text-align: center;
}

/* Segmentos que se llenarán con el avance real de la historia. */

.ufy-story-viewer-progress {
  position: absolute;
  right: 5px;
  bottom: 3px;
  left: 5px;

  display: flex;
  gap: 3px;
  height: 3px;
}

.ufy-story-viewer-progress-track {
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.25);
}

.ufy-story-viewer-progress-fill {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #bd40ff, #00c8ff);
  transform: scaleX(0);
  transform-origin: left center;
}

/* Pausa y sonido. */

.ufy-story-viewer-controls {
  position: absolute;
  top: max(8px, env(safe-area-inset-top));
  right: 8px;
  display: flex;
  gap: 4px;
}

.ufy-story-viewer-control {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 10px;
  border: 0;
  border-radius: 50%;
  background: rgba(30, 19, 45, 0.35);
}

.ufy-story-viewer-control svg {
  width: 24px;
  height: 24px;
}

/* Carga y errores: independientes del encabezado. */

.ufy-story-viewer-status {
  position: absolute;
  z-index: 3;
  top: 50%;
  left: 50%;
  width: min(85%, 340px);
  margin: 0;
  padding: 16px;
  transform: translate(-50%, -50%);

  border: 1px solid var(--story-border);
  border-radius: 16px;
  background: rgba(26, 16, 39, 0.9);
  text-align: center;
  font-size: 14px;
  line-height: 1.5;
}

@media (prefers-reduced-motion: reduce) {
  .ufy-story-viewer-header {
    transition: none;
  }
}


/* Me gusta de historias — corazón UFY */

.ufy-story-viewer-like-area {
  position: absolute;
  z-index: 2;
  right: 12px;
  bottom: max(14px, env(safe-area-inset-bottom));

  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;

  max-width: calc(100% - 24px);
}

.ufy-story-viewer-like-button {
  display: grid;
  place-items: center;

  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 6px;

  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;

  touch-action: manipulation;
}

.ufy-story-viewer-like-button img {
  display: block;
  width: 30px;
  height: 30px;
  object-fit: contain;
  pointer-events: none;
}

.ufy-story-viewer-like-message {
  max-width: 240px;
  margin: 0;
  padding: 8px 10px;

  border: 1px solid var(--story-border);
  border-radius: 12px;
  background: rgba(26, 16, 39, 0.92);

  color: var(--story-text);
  font-size: 12px;
  line-height: 1.4;
  text-align: right;
}


/* Actividad de historias propias — versión K */

.ufy-story-viewer-activity {
  position: absolute;
  z-index: 2;
  left: 12px;
  bottom: max(14px, env(safe-area-inset-bottom));
  max-width: calc(100% - 80px);
}

.ufy-story-viewer-activity-button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 2px;
  width: 96px;
  min-width: 44px;
  min-height: 58px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  touch-action: manipulation;
}

.ufy-story-viewer-activity-button > svg {
  align-self: center;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  transition:
    opacity 180ms ease,
    transform 180ms ease,
    visibility 180ms ease;
}

.ufy-story-viewer-activity-button > svg.is-hidden {
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
}

.ufy-story-viewer-activity-avatars {
  display: flex;
  align-items: center;
  width: 84px;
  min-height: 32px;
  overflow: hidden;
  padding: 1px;
}

.ufy-story-viewer-activity-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  overflow: hidden;
  border: 2px solid #8f69ff;
  border-radius: 50%;
  background: #46325f;
  color: #f7f3ff;
  font-size: 12px;
  font-weight: 600;
}

.ufy-story-viewer-activity-avatar + 
.ufy-story-viewer-activity-avatar {
  margin-left: -8px;
}

.ufy-story-viewer-activity-avatar:nth-child(even) {
  border-color: #20c8ff;
}

.ufy-story-viewer-activity-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@media (prefers-reduced-motion: reduce) {
  .ufy-story-viewer-activity-button > svg {
    transition: none;
  }
}