#the-canvas {
  border: 1px solid black;
  direction: ltr;
}

/* Story View Layout */
.story-view-wrapper {
  display: flex;
  flex-direction: row;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

/* Sidebar Section */
.story-sidebar {
  width: 320px;
  background: #fff;
  border-right: 2px solid #e0e0e0;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  transition: width 0.3s ease;
  position: relative;
}

/* Collapsed Sidebar State */
.story-sidebar.collapsed {
  width: 50px;
  overflow: visible;
}

.story-sidebar.collapsed .sidebar-content,
.story-sidebar.collapsed .btn-back {
  display: none;
}

.sidebar-header {
  padding: 1rem;
  border-bottom: 1px solid #e0e0e0;
  position: relative;
}

/* Toggle Button */
.sidebar-toggle {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: #f5f5f5;
  border: 1px solid #ddd;
  border-radius: 4px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 1.2rem;
  color: #333;
  padding: 0;
  z-index: 10;
}

.sidebar-toggle:hover {
  background: #e8e8e8;
}

.story-sidebar.collapsed .sidebar-toggle {
  position: absolute;
  top: 0.5rem;
  left: 50%;
  transform: translateX(-50%);
  right: auto;
}

.story-sidebar.collapsed .sidebar-header {
  border-bottom: none;
  padding: 0.5rem;
}

.btn-back {
  display: inline-block;
  padding: 0.5rem 1rem;
  background: #f5f5f5;
  border: 1px solid #ddd;
  border-radius: 4px;
  text-decoration: none;
  color: #333;
  transition: background 0.2s;
}

.btn-back:hover {
  background: #e8e8e8;
}

.sidebar-content {
  padding: 1.5rem;
  flex: 1;
}

.story-title {
  margin: 0 0 1.5rem 0;
  font-size: 1.5rem;
  font-weight: 600;
  color: #333;
  line-height: 1.3;
}

.story-details {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.detail-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #999;
  font-weight: 600;
}

.detail-value {
  font-size: 0.9rem;
  color: #333;
}

/* PDF Viewer Section */
.pdf-viewer-section {
  flex: 1;
  overflow: hidden;
  background: #f5f5f5;
  position: relative;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* YouTube-style floating controls */
.viewer-controls {
  position: absolute;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 100;
  display: flex;
  gap: 0.5rem;
  opacity: 0.85;
  transition: opacity 0.2s ease;
}

.viewer-controls:hover {
  opacity: 1;
}

.viewer-control-btn {
  background: rgba(28, 28, 28, 0.8);
  border: none;
  border-radius: 8px;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 1.4rem;
  color: #fff;
  padding: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
}

.viewer-control-btn:hover {
  background: rgba(28, 28, 28, 0.95);
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.viewer-control-btn:active {
  transform: scale(0.95);
}

#viewerContainer {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  /* padding: 20px; */
}

#viewer {
  width: auto;
  height: auto;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.pdfViewer {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
}

/* Fullscreen mode styles */
.pdf-viewer-section:fullscreen {
  background: #525252;
}

.pdf-viewer-section:-webkit-full-screen {
  background: #525252;
}

.pdf-viewer-section:-moz-full-screen {
  background: #525252;
}

.pdf-viewer-section:-ms-fullscreen {
  background: #525252;
}

.pdf-viewer-section:fullscreen #viewerContainer {
  padding: 40px;
}

.pdf-viewer-section:fullscreen .viewer-controls {
  bottom: 2rem;
  right: 2rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .story-view-wrapper {
    flex-direction: column;
  }

  .story-sidebar {
    width: 100%;
    max-height: 40vh;
    border-right: none;
    border-bottom: 2px solid #e0e0e0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
  }

  .story-sidebar.collapsed {
    max-height: 50px;
    width: 100%;
  }

  .sidebar-content {
    padding: 1rem;
  }

  .story-title {
    font-size: 1.25rem;
    margin-bottom: 1rem;
  }

  .pdf-viewer-section {
    flex: 1;
    min-height: 60vh;
  }

  /* Improve touch targets on mobile */
  .btn-back {
    padding: 0.75rem 1.25rem;
    font-size: 1rem;
    min-height: 44px; /* iOS recommended touch target size */
  }

  /* Better spacing for hints widget on mobile */
  .hints-widget {
    margin-top: 1rem;
  }

  .hints-close {
    min-width: 44px;
    min-height: 44px;
  }
}

/* Portrait mode specific optimizations */
@media (max-width: 768px) and (orientation: portrait) {
  .story-sidebar {
    max-height: 35vh; /* Give more space to PDF in portrait */
  }

  .pdf-viewer-section {
    min-height: 65vh;
  }

  /* Compact sidebar content in portrait */
  .sidebar-header {
    padding: 0.75rem;
  }

  .sidebar-content {
    padding: 0.75rem;
  }

  .story-title {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
  }

  .detail-item {
    gap: 0.15rem;
  }

  .detail-label {
    font-size: 0.7rem;
  }

  .detail-value {
    font-size: 0.85rem;
  }

  /* Make hints more compact in portrait */
  .hints-widget {
    margin-top: 0.75rem;
  }

  .hint-text {
    font-size: 0.85rem;
  }
}

/* Landscape mode specific optimizations */
@media (max-width: 768px) and (orientation: landscape) {
  .story-sidebar {
    max-height: 45vh; /* More space for sidebar in landscape */
  }

  .pdf-viewer-section {
    min-height: 55vh;
  }
}

/* Ensure PDF viewer container uses full available space */
@media (max-width: 768px) {
  #viewerContainer {
    overflow: auto;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
  }

  .pdfViewer {
    width: 100%;
    height: 100%;
  }

  /* Prevent text selection on touch drag */
  .pdf-viewer-section {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
  }
}