/* =========================================================================================
 * 📱 9:16 FACEBOOK / INSTAGRAM STORIES 3D OVERLAY VIEWER
 * ========================================================================================= */
.story-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: var(--app-height);
  background: rgba(4, 2, 10, 0.94);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.35s ease;
}

.story-overlay.active {
  display: flex;
  opacity: 1;
}

.story-container {
  position: relative;
  width: 100%;
  max-width: 420px;
  height: 100%;
  max-height: 840px;
  aspect-ratio: 9 / 16;
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 15px 50px rgba(0, 0, 0, 0.8), 0 0 30px rgba(255, 64, 129, 0.3);
  background: #11091d;
  display: flex;
  flex-direction: column;
}

@media (max-width: 480px) {
  .story-container {
    max-width: 100vw;
    max-height: 100dvh;
    border-radius: 0;
  }
}

/* THANH PROGRESS BARS TRÊN ĐỈNH */
.story-progress-bar-container {
  position: absolute;
  top: 10px;
  left: 14px;
  right: 14px;
  display: flex;
  gap: 5px;
  z-index: 22;
}

.story-bar {
  flex: 1;
  height: 3px;
  background: rgba(255, 255, 255, 0.35);
  border-radius: 3px;
  overflow: hidden;
}

.story-bar-fill {
  width: 0%;
  height: 100%;
  background: #ffffff;
  border-radius: 3px;
  transition: width 0.1s linear;
}

/* HEADER CỦA STORY */
.story-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 24px 16px 20px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.82) 0%, rgba(0, 0, 0, 0.4) 65%, transparent 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 20;
}

.story-author {
  display: flex;
  align-items: center;
  gap: 10px;
}

.story-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid #ff4081;
  background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.story-name {
  font-weight: 700;
  font-size: 14.5px;
  color: #ffffff;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.95), 0 2px 10px rgba(0, 0, 0, 0.8);
}

.story-time {
  font-size: 11.5px;
  color: #eeeeee;
  opacity: 0.92;
  margin-top: 1px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9);
}

.story-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.story-sound-btn,
.story-close-btn {
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s, background 0.2s, border-color 0.2s;
}
.story-sound-btn:active,
.story-close-btn:active {
  transform: scale(0.9);
}
.story-sound-btn:hover,
.story-close-btn:hover {
  background: rgba(255, 64, 129, 0.5);
  border-color: rgba(255, 64, 129, 0.8);
}
.story-sound-btn.muted {
  color: #ef9a9a;
}

/* MEDIA CHÍNH & VÙNG CHẠM TIẾP / LÙI */
.story-media-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  overflow: hidden;
}

.story-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #000;
}

.story-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.story-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #ff4081;
  font-size: 32px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 15;
}
.story-spinner.active {
  opacity: 1;
}

.story-touch-left, .story-touch-right {
  position: absolute;
  top: 70px;
  bottom: 120px;
  width: 45%;
  z-index: 10;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.story-touch-left { left: 0; }
.story-touch-right { right: 0; }

/* PHẦN DƯỚI CÙNG: CAPTION & REACTIONS */
.story-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 30px 18px 22px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.88) 0%, rgba(0, 0, 0, 0.4) 65%, transparent 100%);
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.story-tag {
  display: inline-block;
  align-self: flex-start;
  background: rgba(255, 64, 129, 0.4);
  border: 1px solid rgba(255, 64, 129, 0.8);
  color: #ffd54f;
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 12px;
}

.story-caption {
  font-size: 14.5px;
  line-height: 1.55;
  color: #ffffff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.9);
}

.story-reactions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.reaction-btn {
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 16px;
  cursor: pointer;
  transition: transform 0.2s, background 0.2s;
}
.reaction-btn:active {
  transform: scale(1.3);
  background: rgba(255, 64, 129, 0.5);
}

/* =========================================================================================
 * 💫 BỘ ĐIỀU KHIỂN XOAY VÒNG ORBIT (ISLAND 2 SPIN CONTROLS)
 * ========================================================================================= */
.island2-spin-controls {
  position: fixed;
  bottom: 84px;
  right: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(18, 10, 32, 0.78);
  border: 1px solid rgba(255, 64, 129, 0.4);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  padding: 6px 10px;
  border-radius: 30px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), 0 0 16px rgba(255, 64, 129, 0.25);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.island2-spin-controls.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.spin-control-btn {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s ease;
}

.spin-control-btn:hover {
  background: rgba(255, 64, 129, 0.5);
  border-color: #ff4081;
  transform: scale(1.08);
}

.spin-control-btn:active {
  transform: scale(0.92);
}

.spin-control-label {
  font-size: 11.5px;
  font-weight: 700;
  color: #ff80ab;
  padding: 0 4px;
  letter-spacing: 0.3px;
  user-select: none;
  white-space: nowrap;
}

/* Màn hình hẹp: nút "Ghé thăm đảo kế" chiếm gần hết bề ngang nên đặt thanh xoay lên phía trên nút,
   thông báo (toast) lên thêm một nấc nữa cho khỏi đè thanh xoay */
@media (max-width: 600px) {
  .island2-spin-controls {
    bottom: 140px;
    left: 50%;
    right: auto;
    transform: translate(-50%, 10px);
  }
  .island2-spin-controls.active {
    transform: translate(-50%, 0);
  }
  body:has(.island2-spin-controls.active) .toast-msg {
    bottom: 186px;
  }
}

@media (max-width: 480px) {
  .island2-spin-controls {
    padding: 5px 8px;
  }
  .spin-control-btn {
    width: 30px;
    height: 30px;
    font-size: 12px;
  }
  .spin-control-label {
    font-size: 11px;
  }
}

