/**
 * Standalone Story Player - Core Styles
 * Modern, clean, and responsive story player with full element support
 */

/* Reset and base styles */
.story-player {
  position: relative;
  width: 100%;
  height: 100%;
  margin: 0 auto;
  padding: 0 70px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex;
  align-items: center;
  justify-content: center;

  /* StorifyMe approach: viewport-height based sizing */
  --max-story-width: 47;
  --max-story-height: 84;
  --max-story-width-vh: 47vh;
  --max-story-height-vh: 84vh;
}

.story-player * {
  box-sizing: border-box;
}

/* Story container */
.story-container {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: var(--max-story-width-vh);
  max-height: var(--max-story-height-vh);
  background: #000;
  border-radius: 20px;
  overflow: visible;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

/* Wrapper to clip story content but not controls */
.story-slides {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 20px;
}

/* Story header with progress bars */
.story-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: 15px 15px 10px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.5) 0%, transparent 100%);
  border-radius: 20px 20px 0 0;
}

.story-progress-bars {
  width: 100%;
  display: flex;
  gap: 4px;
  height: 3px;
}

.progress-bar-wrapper {
  flex: 1;
  height: 100%;
}

.progress-bar {
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: #ffffff;
  transition: width 0.1s linear;
}

.progress-bar.completed .progress-fill {
  width: 100%;
  transition: none;
}

/* Share button positioned below progress bars */
.story-share-btn {
  position: absolute;
  top: 24px;
  right: 5px;
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  z-index: 101;
  border-radius: 50%;
}

.story-share-btn:hover {
  background: rgba(0, 0, 0, 0.7);
}

/* Transcript button */
.story-transcript-btn {
  position: absolute;
  top: 24px;
  right: 50px;
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  z-index: 101;
  border-radius: 50%;
}

.story-transcript-btn:hover {
  background: rgba(0, 0, 0, 0.7);
}

/* Close button (if shown) */
.story-close {
  position: absolute;
  top: 35px;
  right: 100px;
  background: rgba(0, 0, 0, 0.5);
  border: none;
  color: white;
  font-size: 1.5em;
  line-height: 1;
  width: 35px;
  height: 35px;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s;
  z-index: 101;
}

.story-close:hover {
  background: rgba(0, 0, 0, 0.7);
}

/* Individual slide */
.story-slide {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  visibility: hidden;
  pointer-events: none;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  container-type: size; /* Enable container queries for font sizing */
}

.story-slide.active {
  visibility: visible;
  pointer-events: auto;
}

/* Slide overlay for better text readability */
.story-slide-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* Background video */
.story-slide-bg-video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
}

/* Background image container */
.story-slide-bg-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  z-index: 0;
}

/* Background animations */
.bg-animation-ken-burns {
  animation: ken-burns-effect 5s ease-in-out infinite alternate;
}

.bg-animation-pan-left {
  animation: pan-left-effect 5s linear infinite;
}

.bg-animation-pan-right {
  animation: pan-right-effect 5s linear infinite;
}

.bg-animation-zoom-in {
  animation: zoom-in-effect 5s ease-out forwards;
}

.bg-animation-zoom-out {
  animation: zoom-out-effect 5s ease-out forwards;
}

.bg-animation-fade {
  animation: fade-pulse-effect 5s ease-in-out infinite;
}

.bg-animation-pan-up {
  animation: pan-up-effect 5s linear infinite;
}

.bg-animation-pan-down {
  animation: pan-down-effect 5s linear infinite;
}

/* Ken Burns effect - slow zoom and pan */
@keyframes ken-burns-effect {
  0% {
    transform: scale(1) translate(0, 0);
  }
  100% {
    transform: scale(1.15) translate(-2%, -2%);
  }
}

/* Pan left effect */
@keyframes pan-left-effect {
  0% {
    background-position: 100% center;
  }
  100% {
    background-position: 0% center;
  }
}

/* Pan right effect */
@keyframes pan-right-effect {
  0% {
    background-position: 0% center;
  }
  100% {
    background-position: 100% center;
  }
}

/* Zoom in effect */
@keyframes zoom-in-effect {
  0% {
    transform: scale(1);
  }
  100% {
    transform: scale(1.2);
  }
}

/* Zoom out effect */
@keyframes zoom-out-effect {
  0% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}

/* Fade pulse effect */
@keyframes fade-pulse-effect {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.8;
  }
}

/* Pan up effect */
@keyframes pan-up-effect {
  0% {
    background-position: center 100%;
  }
  100% {
    background-position: center 0%;
  }
}

/* Pan down effect */
@keyframes pan-down-effect {
  0% {
    background-position: center 0%;
  }
  100% {
    background-position: center 100%;
  }
}

/* Slide elements container */
.story-slide-elements {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 5;
  pointer-events: none;
}

.story-slide-elements > * {
  pointer-events: auto;
}

/* Slide content wrapper */
.story-slide-content {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 60px 30px 40px;
  z-index: 10;
}

/* Media (video/image overlay) */
.story-slide-video,
.story-slide-image {
  max-width: 100%;
  max-height: 50%;
  border-radius: 10px;
  margin-bottom: 20px;
}

.story-slide-video {
  width: 100%;
}

/* Text content */
.story-text-wrapper {
  text-align: center;
  color: white;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  max-width: 100%;
}

.story-text-wrapper.position-top {
  align-self: flex-start;
  margin-top: 0;
  margin-bottom: auto;
}

.story-text-wrapper.position-bottom {
  align-self: flex-end;
  margin-top: auto;
  margin-bottom: 0;
}

.story-title {
  font-size: 2.5em;
  font-weight: 700;
  margin: 0 0 15px;
  line-height: 1.2;
}

.story-text {
  font-size: 1.2em;
  line-height: 1.6;
  margin: 0;
  opacity: 0.95;
}

/* CTA Button */
.story-cta {
  display: inline-block;
  padding: 15px 35px;
  margin-top: 25px;
  background: white;
  color: #333;
  text-decoration: none;
  border-radius: 30px;
  font-weight: 600;
  font-size: 1em;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.story-cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.story-cta:active {
  transform: translateY(0);
}

.story-cta.cta-outline {
  background: transparent;
  color: white;
  border: 2px solid white;
}

/* =====================================
   ELEMENT STYLES
   ===================================== */

.story-element {
  position: absolute;
  box-sizing: border-box;
}

/* Rotation wrapper - handles rotation transform separately from animation transforms */
.story-element-rotation {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  pointer-events: auto;
}

/* Content wrapper - handles animation, opacity, borders, box-shadow */
.story-element-content {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  pointer-events: inherit;
}

/* Animation base state for content wrapper - elements start hidden and animate in */
.story-element-content.story-element-animated {
  visibility: hidden;
}

.story-element-content.story-element-animated.animate-active {
  visibility: visible;
}

.story-element-text {
  /* No flex display - let text flow naturally from top-left like in editor */
  /* Use border-box to match editor (Tailwind) sizing behavior */
  box-sizing: border-box;
  overflow: visible;
  word-wrap: break-word;
}

.story-element-image {
  overflow: hidden;
}

.story-element-image img {
  display: block;
}

.story-element-video {
  overflow: hidden;
}

.story-element-video video {
  display: block;
}

.story-element-shape {
  overflow: visible;
}

.story-element-shape svg {
  display: block;
}

/* =====================================
   ELEMENT ANIMATIONS
   ===================================== */

.story-element-animated {
  visibility: hidden;
}

.story-element-animated.animate-active {
  visibility: visible;
}

/* Fade animations */
.story-element-animated.animate-fadeIn {
  animation: elementFadeIn var(--animation-duration, 500ms) ease-out forwards;
  animation-delay: var(--animation-delay, 0ms);
}

.story-element-animated.animate-fadeOut {
  animation: elementFadeOut var(--animation-duration, 500ms) ease-out forwards;
  animation-delay: var(--animation-delay, 0ms);
}

/* Slide animations */
.story-element-animated.animate-slideInLeft {
  animation: elementSlideInLeft var(--animation-duration, 500ms) ease-out forwards;
  animation-delay: var(--animation-delay, 0ms);
}

.story-element-animated.animate-slideInRight {
  animation: elementSlideInRight var(--animation-duration, 500ms) ease-out forwards;
  animation-delay: var(--animation-delay, 0ms);
}

.story-element-animated.animate-slideInUp {
  animation: elementSlideInUp var(--animation-duration, 500ms) ease-out forwards;
  animation-delay: var(--animation-delay, 0ms);
}

.story-element-animated.animate-slideInDown {
  animation: elementSlideInDown var(--animation-duration, 500ms) ease-out forwards;
  animation-delay: var(--animation-delay, 0ms);
}

/* Zoom animations */
.story-element-animated.animate-zoomIn {
  animation: elementZoomIn var(--animation-duration, 500ms) ease-out forwards;
  animation-delay: var(--animation-delay, 0ms);
}

.story-element-animated.animate-zoomOut {
  animation: elementZoomOut var(--animation-duration, 500ms) ease-out forwards;
  animation-delay: var(--animation-delay, 0ms);
}

/* Special animations */
.story-element-animated.animate-bounce {
  animation: elementBounce var(--animation-duration, 500ms) ease-out forwards;
  animation-delay: var(--animation-delay, 0ms);
}

.story-element-animated.animate-pulse {
  animation: elementPulse var(--animation-duration, 500ms) ease-in-out infinite;
  animation-delay: var(--animation-delay, 0ms);
}

.story-element-animated.animate-shake {
  animation: elementShake var(--animation-duration, 500ms) ease-out forwards;
  animation-delay: var(--animation-delay, 0ms);
}

/* Element keyframes - use CSS variable for target opacity to respect element's opacity setting */
@keyframes elementFadeIn {
  from { opacity: 0; }
  to { opacity: var(--element-opacity, 1); }
}

@keyframes elementFadeOut {
  from { opacity: var(--element-opacity, 1); }
  to { opacity: 0; }
}

@keyframes elementSlideInLeft {
  from { transform: translateX(-100%); opacity: 0; }
  to { transform: translateX(0); opacity: var(--element-opacity, 1); }
}

@keyframes elementSlideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: var(--element-opacity, 1); }
}

@keyframes elementSlideInUp {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: var(--element-opacity, 1); }
}

@keyframes elementSlideInDown {
  from { transform: translateY(-100%); opacity: 0; }
  to { transform: translateY(0); opacity: var(--element-opacity, 1); }
}

@keyframes elementZoomIn {
  from { transform: scale(0); opacity: 0; }
  to { transform: scale(1); opacity: var(--element-opacity, 1); }
}

@keyframes elementZoomOut {
  from { transform: scale(1.5); opacity: 0; }
  to { transform: scale(1); opacity: var(--element-opacity, 1); }
}

@keyframes elementBounce {
  0%, 100% { transform: translateY(0); }
  25% { transform: translateY(-20px); }
  50% { transform: translateY(0); }
  75% { transform: translateY(-10px); }
}

@keyframes elementPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes elementShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px); }
  40% { transform: translateX(10px); }
  60% { transform: translateX(-10px); }
  80% { transform: translateX(10px); }
}

/* Navigation controls - StorifyMe approach */
.story-controls {
  display: flex;
  justify-content: space-between;
  z-index: 50;
  pointer-events: none;
}

.story-nav-prev,
.story-nav-next {
  display: block;
  position: absolute;
  bottom: 0;
  top: 0;
  margin: auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background-color: #fff;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0.5;
  cursor: pointer;
  pointer-events: all;
  transition: opacity 150ms linear, transform 350ms linear;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

/* Previous arrow - positioned 72px to the left */
.story-nav-prev {
  left: -72px;
  right: auto;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg width='16' height='25' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M15.7 22l-9.5-9.5L15.7 3l-3-3L.4 12.6 12.8 25'/%3E%3C/svg%3E");
  background-position: 45% 50%;
  background-size: 12px 17px;
}

/* Next arrow - positioned 72px to the right */
.story-nav-next {
  left: auto;
  right: -72px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg width='16' height='25' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M.3 3l9.5 9.5L.3 22l3 3L15.6 12.4 3.2 0'/%3E%3C/svg%3E");
  background-position: 55% 50%;
  background-size: 12px 17px;
}

.story-nav-prev:hover,
.story-nav-next:hover {
  opacity: 1;
  transform: scale(1.1);
}

.story-nav-prev:active,
.story-nav-next:active {
  transform: scale(0.95);
}

.story-nav-prev:disabled,
.story-nav-next:disabled {
  opacity: 0.1;
  cursor: not-allowed;
}

/* Replay mode - shows reload icon instead of arrow */
.story-nav-next.replay-mode {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8'/%3E%3Cpath d='M21 3v5h-5'/%3E%3Cpath d='M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16'/%3E%3Cpath d='M8 16H3v5'/%3E%3C/svg%3E");
  background-size: 18px 18px;
  background-position: center;
}

/* =====================================
   SLIDE TRANSITION ANIMATIONS
   ===================================== */

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes slideInLeft {
  from { transform: translateX(-100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes zoomIn {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.story-slide.animate {
  animation-duration: 0.4s;
  animation-fill-mode: both;
  animation-timing-function: ease-out;
}

.story-slide.animation-fade-in {
  animation-name: fadeIn;
}

.story-slide.animation-fade-out {
  animation-name: fadeOut;
}

.story-slide.animation-slide-left {
  animation-name: slideInLeft;
}

.story-slide.animation-slide-right {
  animation-name: slideInRight;
}

.story-slide.animation-zoom-in {
  animation-name: zoomIn;
}

/* =====================================
   INSTRUCTION MODAL
   ===================================== */

.story-instruction-modal {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  opacity: 0;
  transition: opacity 0.3s ease;
  border-radius: 20px;
}

.story-instruction-modal.visible {
  opacity: 1;
}

.instruction-modal-content {
  text-align: center;
  color: white;
  padding: 40px 30px;
  max-width: 100%;
}

.instruction-items {
  display: flex;
  flex-direction: column;
  gap: 30px;
  margin-bottom: 40px;
}

.instruction-item {
  display: flex;
  align-items: center;
  gap: 20px;
  text-align: left;
}

.instruction-icon {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  opacity: 0.8;
}

.instruction-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.instruction-title {
  font-size: 1.2em;
  font-weight: 600;
}

.instruction-desc {
  font-size: 0.9em;
  opacity: 0.7;
}

.instruction-start-btn {
  background: white;
  color: #333;
  border: none;
  padding: 15px 40px;
  font-size: 1.1em;
  font-weight: 600;
  border-radius: 30px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.instruction-start-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.instruction-start-btn:active {
  transform: translateY(0);
}

/* =====================================
   TRANSCRIPT DRAWER
   ===================================== */

.story-transcript-drawer {
  position: absolute;
  top: 0;
  right: 0;
  width: 100%;
  height: 100%;
  background: white;
  z-index: 400;
  border-radius: 20px;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.story-transcript-drawer.open {
  transform: translateX(0);
}

.transcript-drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid #eee;
  flex-shrink: 0;
}

.transcript-drawer-header h3 {
  margin: 0;
  font-size: 1.2em;
  color: #333;
}

.transcript-drawer-close {
  background: none;
  border: none;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #666;
  border-radius: 50%;
  transition: background 0.2s;
}

.transcript-drawer-close:hover {
  background: #f0f0f0;
}

.transcript-drawer-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.transcript-slides {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.transcript-slide {
  padding: 15px;
  background: #f8f9fa;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
}

.transcript-slide:hover {
  background: #e9ecef;
}

.transcript-slide.active {
  background: #e3f2fd;
  box-shadow: 0 0 0 2px #2196f3;
}

.transcript-slide-header {
  font-size: 0.85em;
  color: #666;
  margin-bottom: 10px;
  font-weight: 600;
}

.transcript-slide-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.transcript-text {
  margin: 0;
  color: #333;
  font-size: 0.95em;
  line-height: 1.5;
}

.transcript-text-title {
  font-weight: 600;
  font-size: 1.05em;
}

.transcript-empty {
  text-align: center;
  padding: 40px 20px;
  color: #666;
}

/* Share Menu */
.story-share-menu {
  position: absolute;
  top: 75px;
  right: 15px;
  background: white;
  border-radius: 15px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  z-index: 200;
  width: 280px;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.3s ease;
}

.story-share-menu.active {
  max-height: 600px;
  opacity: 1;
  transform: translateY(0);
}

.share-menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid #eee;
}

.share-menu-header h3 {
  margin: 0;
  font-size: 1.2em;
  color: #333;
}

.share-menu-close {
  background: none;
  border: none;
  font-size: 2em;
  line-height: 1;
  width: 30px;
  height: 30px;
  cursor: pointer;
  color: #666;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s;
}

.share-menu-close:hover {
  background: #f0f0f0;
}

.share-menu-content {
  padding: 10px;
}

.share-option {
  display: flex;
  align-items: center;
  gap: 15px;
  width: 100%;
  padding: 15px;
  background: none;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s;
  text-align: left;
  font-size: 1em;
}

.share-option:hover {
  background: #f8f9fa;
}

.share-option svg {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.share-option span {
  color: #333;
  font-weight: 500;
}

/* Share option colors */
.share-native svg { color: #667eea; }
.share-copy svg { color: #6c757d; }
.share-twitter svg { color: #1DA1F2; }
.share-facebook svg { color: #4267B2; }
.share-linkedin svg { color: #0077B5; }
.share-whatsapp svg { color: #25D366; }
.share-email svg { color: #EA4335; }

/* Toast notification */
.story-toast {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(0, 0, 0, 0.85);
  color: white;
  padding: 12px 24px;
  border-radius: 25px;
  font-size: 0.9em;
  z-index: 300;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
  white-space: nowrap;
}

.story-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* =====================================
   RESPONSIVE
   ===================================== */

@media (max-width: 768px) {
  .story-player {
    padding: 0 60px;
  }

  .story-nav-prev {
    left: -60px;
  }

  .story-nav-next {
    right: -60px;
  }
}

@media (max-width: 480px) {
  .story-player {
    padding: 0;
    --max-story-width-vh: 100vw;
    --max-story-height-vh: 100vh;
  }

  .story-container {
    border-radius: 0;
    max-width: 100vw;
    max-height: 100vh;
  }

  .story-slides {
    border-radius: 0;
  }

  /* Hide arrows on mobile, use tap navigation */
  .story-nav-prev,
  .story-nav-next {
    display: none;
  }

  .story-title {
    font-size: 2em;
  }

  .story-text {
    font-size: 1em;
  }

  .story-instruction-modal {
    border-radius: 0;
  }

  .story-transcript-drawer {
    border-radius: 0;
  }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  .story-slide.animate,
  .progress-fill,
  .story-cta,
  .story-nav-prev,
  .story-nav-next,
  .story-element-animated,
  .story-instruction-modal,
  .story-transcript-drawer {
    animation: none !important;
    transition: none !important;
  }
}

/* Loading state */
.story-player.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Asset preload loading overlay */
.story-loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: inherit;
}

.story-loading-spinner {
  width: 44px;
  height: 44px;
  border: 4px solid rgba(255, 255, 255, 0.25);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

/* Focus styles for accessibility */
.story-cta:focus,
.story-nav-prev:focus,
.story-nav-next:focus,
.story-close:focus,
.story-share-btn:focus,
.story-transcript-btn:focus,
.instruction-start-btn:focus {
  outline: 2px solid white;
  outline-offset: 2px;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .story-player {
    background: #000;
  }
}

/* Link Popup Styles */
.story-link-popup {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 600;
  opacity: 0;
  transition: opacity 0.2s ease;
  border-radius: 20px;
}

.story-link-popup.visible {
  opacity: 1;
}

.link-popup-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  border-radius: 20px;
}

.link-popup-content {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: white;
  border-radius: 16px;
  padding: 20px 24px;
  min-width: 280px;
  max-width: 90%;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.link-popup-icon {
  width: 48px;
  height: 48px;
  background: #f0f0f0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #333;
}

.link-popup-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
}

.link-popup-title {
  font-size: 18px;
  font-weight: 600;
  color: #111;
}

.link-popup-url {
  font-size: 14px;
  color: #666;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-popup-buttons {
  display: flex;
  gap: 12px;
  width: 100%;
  margin-top: 8px;
}

.link-popup-btn {
  flex: 1;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
}

.link-popup-cancel {
  background: #f0f0f0;
  color: #333;
}

.link-popup-cancel:hover {
  background: #e0e0e0;
}

.link-popup-go {
  background: #007AFF;
  color: white;
}

.link-popup-go:hover {
  background: #0056CC;
}

/* Linked element indicator */
.story-element[data-has-link="true"] {
  cursor: pointer;
}

.story-element[data-has-link="true"]::after {
  content: '';
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  background: rgba(0, 122, 255, 0.9);
  border-radius: 50%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71'/%3E%3Cpath d='M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 12px;
  opacity: 0.8;
  transition: opacity 0.2s ease;
  z-index: 10;
}

.story-element[data-has-link="true"]:hover::after {
  opacity: 1;
}

/* Mobile responsive */
@media (max-width: 480px) {
  .link-popup-content {
    bottom: 60px;
    padding: 16px 20px;
    min-width: 260px;
  }
  
  .link-popup-title {
    font-size: 16px;
  }
  
  .link-popup-btn {
    padding: 10px 16px;
    font-size: 15px;
  }
}
