/* ============================================================
   Timeline Viewer - WYSIWYG Rendering (Matching Editor Structure)

   This CSS ensures the timeline viewer renders content exactly as it
   appears in the timeline editor. Uses the same item layout structure.
   ============================================================ */

/* ============================================================
   Hide fixed create button on viewer pages
   ============================================================ */

.timeline-viewer-mode .btn-create-fixed {
  display: none !important;
}

/* ============================================================
   Full Width Container
   ============================================================ */

.timeline-viewer-fullwidth {
  width: 100%;
  min-height: 100vh;
  background: transparent;
}

/* ============================================================
   Timeline Header - Topic-style with Background Image
   ============================================================ */

.timeline-header {
  position: relative;
  width: calc(100% - 160px);
  margin: 1.5rem auto 2rem;
  height: 360px;
  overflow: hidden;
  background: linear-gradient(135deg,
    var(--color-bg-secondary, #0c0c0e) 0%,
    var(--color-bg-tertiary, #16213e) 100%);
  border-radius: var(--radius-lg, 16px);
}

/* Background Image Layer */
.timeline-header-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center 35%;
  opacity: 0;
  transition: opacity 0.3s ease;
  border-radius: var(--radius-lg, 16px);
}

.timeline-header-image.loaded {
  opacity: 1;
}

/* Gradient Overlay */
.timeline-header-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.3) 0%,
    rgba(0, 0, 0, 0.7) 100%
  );
  display: flex;
  align-items: flex-end;
  padding: 2rem;
}

/* Content Container */
.timeline-header-content {
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.timeline-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.9);
}

.timeline-meta .author-link {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: white;
  transition: color 0.2s ease, text-shadow 0.2s ease;
}

.timeline-meta .author-link:hover {
  color: #33c4ff;
}

.timeline-meta .author-link:hover .author-name {
  text-shadow: 0 0 10px rgba(0, 168, 255, 0.6), 0 0 20px rgba(0, 168, 255, 0.4);
  text-decoration: none;
}

.timeline-meta .author-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.3);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.timeline-meta .author-link:hover .author-avatar {
  border-color: rgba(0, 168, 255, 0.6);
  box-shadow: 0 0 10px rgba(0, 168, 255, 0.5), 0 0 20px rgba(0, 168, 255, 0.3);
}

.timeline-meta .author-name {
  font-weight: 600;
  color: inherit;
}

.timeline-meta .separator {
  color: rgba(255, 255, 255, 0.5);
}

.timeline-meta time {
  color: rgba(255, 255, 255, 0.7);
}

.timeline-title {
  font-size: 3rem;
  font-weight: 800;
  color: white;
  margin: 0 0 0.75rem 0;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  line-height: 1.2;
}

.timeline-description {
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.85);
  margin-bottom: 1rem;
  line-height: 1.5;
  max-width: 600px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

/* Topics/Subjects Section */
.timeline-topics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 0.75rem;
}

.timeline-topics .topic-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.75rem;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  font-size: 0.75rem;
  color: white;
  transition: all 0.15s ease;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.timeline-topics .topic-pill:hover {
  background: rgba(0, 168, 255, 0.3);
  border-color: rgba(0, 168, 255, 0.5);
  color: white;
}

/* Action Buttons - Bottom Right (Matching Page Viewer Style) */
.timeline-header-actions {
  position: absolute;
  bottom: 1.5rem;
  right: 2rem;
  display: flex;
  gap: 0.5rem;
  z-index: 10;
}

.timeline-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.9);
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.timeline-action-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.35);
}

.timeline-action-btn svg {
  width: 18px;
  height: 18px;
}

/* Share button - blue accent on hover */
#btn-share.timeline-action-btn:hover {
  background: rgba(0, 168, 255, 0.4);
  border-color: rgba(0, 168, 255, 0.6);
  color: #fff;
}

/* Bookmark button - blue accent on hover */
#btn-bookmark.timeline-action-btn:hover {
  background: rgba(0, 168, 255, 0.4);
  border-color: rgba(0, 168, 255, 0.6);
  color: #fff;
}

/* Edit button - blue accent on hover */
.timeline-action-btn.btn-edit:hover {
  background: rgba(0, 168, 255, 0.4);
  border-color: rgba(0, 168, 255, 0.6);
  color: #fff;
}

/* Delete button - red accent on hover */
.timeline-action-btn.btn-delete:hover {
  background: rgba(239, 68, 68, 0.3);
  border-color: rgba(239, 68, 68, 0.5);
  color: #ff6b6b;
}

/* ============================================================
   Timeline Viewer Main Area (WYSIWYG with Editor)
   ============================================================ */

/* Base styles - overridden by legend section below for flex layout */

.timeline-items-container {
  background: transparent;
  overflow: visible; /* Allow nested timelines to extend beyond */
}

/* Timeline items list with vertical blue bar - matches editor sidebar-left mode */
.timeline-items-list {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 24px;
  width: 100%;
  max-width: 500px;
  padding: var(--spacing-lg);
  padding-left: 48px; /* Space for timeline ticks */
  margin: 0 auto;
  overflow: visible; /* Allow nested timelines to extend beyond */
}

/* Vertical timeline bar - glowing line on left */
.timeline-items-list::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 20px;
  width: 2px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 1px;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.15);
  z-index: 1;
}

/* Loading State */
.timeline-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-4xl, 64px);
  color: var(--color-text-muted, #888);
  gap: var(--spacing-md, 16px);
}

.timeline-loading .loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(0, 168, 255, 0.2);
  border-top-color: rgba(0, 168, 255, 0.8);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* ============================================================
   Timeline Slot Wrapper (WYSIWYG - matches editor structure)
   ============================================================ */

.timeline-slot-wrapper {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md, 16px);
  padding-top: 32px; /* Space for date indicator */
}

/* Timeline tick for each slot - horizontal line connecting to vertical bar */
.timeline-slot-wrapper::before {
  content: '';
  position: absolute;
  top: 50px;
  left: -27px;
  width: 16px;
  height: 3px;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 1px;
  z-index: 2;
  transition: all 0.2s ease;
}

/* Hover state - no change on view page */
.timeline-slot-wrapper:hover::before {
  /* Keep same as default - no hover effect on view page */
}

/* ============================================================
   Timeline Slot (Content Container) - matches editor styling
   ============================================================ */

.timeline-slot {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 250px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid transparent;
  border-radius: var(--radius-lg, 12px);
  overflow: hidden;
  transition: all 0.2s ease;
}

.timeline-slot.filled {
  min-height: auto;
  overflow: visible;
}

.timeline-slot.filled:hover {
  border-color: transparent;
  box-shadow: none;
}

/* Slot Content Container - reserve space to prevent layout shift */
.timeline-slot-content {
  min-height: 400px;
}

.timeline-slot-content.embed-loaded {
  min-height: 0;
}

/* ============================================================
   Timeline Caption - Positioned to the right of the slot
   (matches timeline-editor.css styling)
   ============================================================ */

.timeline-caption-wrapper {
  position: absolute;
  top: 32px; /* Align with top of slot (below date indicator padding) */
  left: calc(100% + 16px); /* Position to the right of the slot with 16px gap */
  width: 200px;
  max-height: 320px;
  overflow: hidden;
  z-index: 10;
  padding: 8px 0;
  background: transparent;
  border: none;
  box-shadow: none;
}

.timeline-caption-wrapper p {
  margin: 0;
  font-size: var(--font-size-sm, 0.875rem);
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.6);
}

/* Hide caption on smaller screens where it would overflow */
@media (max-width: 1200px) {
  .timeline-caption-wrapper {
    display: none;
  }
}

/* ============================================================
   Date Indicator (Read-Only in Viewer)
   ============================================================ */

.timeline-date-indicator {
  position: absolute;
  top: calc(32px + 4px); /* Wrapper padding + offset */
  left: 0;
  transform: translateX(-100%) translateX(-42px); /* Position to left of timeline bar */
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: transparent;
  border-radius: 4px;
  z-index: 5;
}

.timeline-date-indicator .date-text {
  font-size: 14px;
  font-weight: 600;
  color: #ffffff;
  white-space: nowrap;
}

/* ============================================================
   Loading State for Individual Items
   ============================================================ */

.timeline-slot .embed-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-xl, 32px);
  color: var(--color-text-muted, #888);
}

.timeline-slot .embed-loading .loading-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid rgba(0, 168, 255, 0.2);
  border-top-color: rgba(0, 168, 255, 0.8);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Embed Placeholder */
.timeline-slot .embed-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-xl, 32px);
  color: var(--color-text-muted, #888);
  text-align: center;
  gap: var(--spacing-sm, 8px);
}

.timeline-slot .embed-placeholder svg {
  opacity: 0.4;
}

.timeline-slot .embed-placeholder a {
  color: var(--color-primary, #00a8ff);
  text-decoration: none;
}

.timeline-slot .embed-placeholder a:hover {
  text-decoration: underline;
}

/* ============================================================
   Twitter/X Embed Styles (matches timeline-editor.css)
   ============================================================ */

/* Twitter slot - transparent background, allow overflow */
.timeline-slot.timeline-slot-twitter {
  background: transparent;
  overflow: visible !important;
}

.timeline-slot-twitter .timeline-slot-content {
  background: transparent !important;
  display: block;
  width: 100%;
  overflow: visible !important;
}

/* Tweet container styling - full width */
.timeline-slot-twitter .tweet-container {
  display: block;
  width: 100%;
  padding: 0;
  background: transparent;
}

/* Override Twitter widget styling - force full width.
   IMPORTANT: index-shared.css has global .twitter-tweet rules that scale(0.85)
   and set margin: 0 auto. These must be overridden for timeline slots. */
.timeline-slot-twitter .tweet-container .twitter-tweet,
.timeline-slot-twitter .tweet-container .twitter-tweet-rendered,
.timeline-slot-twitter .tweet-container .twitter-tweet-rendered-true,
.timeline-slot-twitter .tweet-container twitter-widget,
.timeline-slot-twitter .tweet-container > * {
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  border: none !important;
  outline: none !important;
  overflow: hidden !important;
  border-radius: 12px !important;
}

/* Tweet iframe - full width without scaling.
   Overrides index-shared.css global transform: scale(0.85) on .twitter-tweet iframe */
.timeline-slot-twitter .tweet-container iframe,
.timeline-slot-twitter .tweet-container .twitter-tweet iframe,
.timeline-slot-twitter .tweet-container .twitter-tweet-rendered-true iframe {
  width: 100% !important;
  max-width: 100% !important;
  transform: none !important;
  border-radius: 12px !important;
  border: none !important;
  outline: none !important;
  /* Critical: color-scheme: light prevents the browser from applying dark mode
     to the iframe content, which causes white background corners in Twitter embeds */
  color-scheme: light !important;
}

/* ============================================================
   YouTube Embed Styles
   ============================================================ */

.youtube-responsive-wrapper {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%; /* 16:9 aspect ratio */
  background: #000;
}

.youtube-responsive-wrapper iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* ============================================================
   Instagram Embed Styles
   ============================================================ */

.timeline-slot.timeline-slot-instagram {
  overflow: hidden;
  border-radius: 12px;
}

.timeline-slot-instagram .timeline-slot-content {
  background: transparent;
}

.instagram-embed-container {
  width: 100%;
}

.instagram-embed-container iframe {
  display: block;
  width: 100% !important;
  min-width: 100% !important;
  max-width: 100% !important;
  border: none;
  border-radius: 12px;
  background: #FFF;
}

/* Force Instagram blockquote and processed embeds to fill width */
.instagram-embed-container .instagram-media,
.instagram-embed-container .instagram-media-rendered {
  width: 100% !important;
  min-width: 100% !important;
  max-width: 100% !important;
  margin: 0 !important;
}

/* TikTok slot - match library tab styling (no white background) */
.timeline-slot.timeline-slot-tiktok {
  overflow: visible;
  background: transparent;
  border: none;
}

.timeline-slot-tiktok .timeline-slot-content {
  background: transparent;
}

.timeline-slot-tiktok .tiktok-embed-container {
  overflow: hidden;
  width: 325px;
  margin: 0 auto;
  border-radius: 12px;
  transform: scale(1.2);
  transform-origin: top center;
  margin-bottom: 155px;
}

.timeline-slot-tiktok .tiktok-embed-container iframe {
  border: none;
  border-radius: 0;
  margin: -1px;
  width: calc(100% + 2px);
  height: 782px;
}

/* ============================================================
   Image/Media Styles
   ============================================================ */

.timeline-image-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, 0.2);
}

.timeline-image-wrapper img {
  max-width: 100%;
  max-height: 600px;
  object-fit: contain;
}

.timeline-video-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  background: #000;
}

.timeline-video-wrapper video {
  max-width: 100%;
  max-height: 600px;
}

/* ============================================================
   Chart Styles
   ============================================================ */

.timeline-slot-chart .timeline-slot-content {
  padding: var(--spacing-md, 16px);
  background: rgba(255, 255, 255, 0.02);
}

.chart-embed-container {
  width: 100%;
  position: relative;
  min-height: 300px;
}

.chart-embed-container canvas {
  width: 100% !important;
  height: 100% !important;
  min-height: 300px;
}

/* ============================================================
   Data Table Styles
   ============================================================ */

.timeline-data-table-wrapper {
  overflow-x: auto;
  padding: var(--spacing-md, 16px);
}

.timeline-data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm, 14px);
}

.timeline-data-table th,
.timeline-data-table td {
  padding: var(--spacing-sm, 8px) var(--spacing-md, 12px);
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.timeline-data-table th {
  background: rgba(0, 168, 255, 0.1);
  font-weight: 600;
  color: var(--color-text-primary, #fff);
}

.timeline-data-table td {
  color: var(--color-text-secondary, #ccc);
}

.timeline-data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.table-more-rows {
  padding: var(--spacing-sm, 8px);
  text-align: center;
  font-size: var(--font-size-sm, 14px);
  color: var(--color-text-muted, #888);
  background: rgba(255, 255, 255, 0.03);
}

/* ============================================================
   Timeline Footer
   ============================================================ */

.timeline-footer {
  max-width: 800px;
  margin: var(--spacing-xl, 32px) auto;
  padding: var(--spacing-lg, 24px);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.timeline-footer .stats {
  display: flex;
  gap: var(--spacing-lg, 24px);
  color: var(--color-text-muted, #888);
  font-size: var(--font-size-sm, 14px);
}

.timeline-footer .stat {
  display: flex;
  align-items: center;
  gap: 6px;
}

.timeline-footer .stat svg {
  opacity: 0.6;
}

/* ============================================================
   Delete Modal
   ============================================================ */

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.modal-content {
  background: var(--color-bg-secondary, #0c0c0e);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg, 16px);
  position: relative;
  max-width: 90%;
}

.modal-small {
  width: 400px;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  color: var(--color-text-muted, #888);
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--color-text-primary, #fff);
}

.delete-confirm-body {
  padding: var(--spacing-xl, 32px);
  text-align: center;
}

.delete-confirm-body .delete-icon {
  color: #ef4444;
  margin-bottom: var(--spacing-md, 16px);
}

.delete-confirm-body h3 {
  font-size: var(--font-size-xl, 20px);
  margin-bottom: var(--spacing-sm, 8px);
  color: var(--color-text-primary, #fff);
}

.delete-confirm-body p {
  color: var(--color-text-muted, #888);
  margin-bottom: var(--spacing-lg, 24px);
}

.delete-confirm-actions {
  display: flex;
  gap: var(--spacing-md, 16px);
  justify-content: center;
}

.btn-secondary {
  padding: var(--spacing-sm, 8px) var(--spacing-lg, 24px);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-md, 8px);
  color: var(--color-text-primary, #fff);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

.btn-danger {
  padding: var(--spacing-sm, 8px) var(--spacing-lg, 24px);
  background: #ef4444;
  border: none;
  border-radius: var(--radius-md, 8px);
  color: white;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-danger:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ============================================================
   Responsive Adjustments
   ============================================================ */

@media (max-width: 1200px) {
  .timeline-header {
    width: calc(100% - 80px);
  }

  .timeline-viewer-main {
    width: calc(100% - 80px);
  }
}

@media (max-width: 768px) {
  .timeline-header {
    width: calc(100% - 32px);
    height: 270px;
    margin: 1rem auto 1.5rem;
  }

  .timeline-header-overlay {
    padding: 1.5rem;
  }

  .timeline-title {
    font-size: 2rem;
  }

  .timeline-viewer-main {
    flex-direction: column;
    width: calc(100% - 32px);
    padding: 0 0 var(--spacing-lg, 24px) 0;
  }

  .timeline-viewer-main .timeline-items-container {
    max-width: 100%;
  }

  .timeline-legend {
    display: none;
  }

  .timeline-items-list {
    padding-left: 48px;
    max-width: 100%;
  }

  .timeline-items-list::before {
    left: 16px;
  }

  .timeline-slot-wrapper::before {
    left: -20px;
    width: 12px;
  }

  .timeline-date-indicator {
    transform: translateX(-100%) translateX(-32px);
    font-size: 12px;
  }

  .timeline-header-actions {
    bottom: 1rem;
    right: 1.5rem;
  }
}

@media (max-width: 480px) {
  .timeline-header {
    width: calc(100% - 16px);
    height: 225px;
    border-radius: var(--radius-md, 8px);
  }

  .timeline-title {
    font-size: 1.5rem;
  }

  .timeline-meta {
    font-size: 12px;
  }

  .timeline-meta .author-avatar {
    width: 24px;
    height: 24px;
  }

  .timeline-header-actions {
    bottom: 0.75rem;
    right: 1rem;
    gap: 0.35rem;
  }

  .timeline-action-btn {
    width: 34px;
    height: 34px;
  }

  .timeline-action-btn svg {
    width: 16px;
    height: 16px;
  }

  /* Hide timeline bar and date indicators on mobile for cleaner display */
  .timeline-viewer-main {
    width: calc(100% - 16px);
    padding: 0;
  }

  .timeline-items-list {
    padding-left: 0;
  }

  .timeline-items-list::before {
    display: none;
  }

  .timeline-slot-wrapper::before {
    display: none;
  }

  .timeline-date-indicator {
    position: static;
    transform: none;
    margin-bottom: 8px;
  }

  .timeline-slot-wrapper {
    padding-top: 0;
  }
}

/* ============================================================
   Nested Timeline Expand/Collapse
   For timeline cards within a timeline, allows preview of nested content
   ============================================================ */

/* Slot wrapper needs relative positioning for nested expand */
.timeline-slot-wrapper {
  position: relative;
  overflow: visible; /* Allow nested timeline to extend beyond */
}

/* Ensure nested timeline slots don't clip horizontally */
.timeline-slot-wrapper.has-nested-timeline {
  overflow: visible;
}

/* The expandable container - in document flow, below the item */
.nested-timeline-expand {
  position: relative;
  z-index: 100;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.4s ease, opacity 0.3s ease;
  background: transparent;
  margin-top: var(--spacing-sm, 8px);
  /* Allow content to extend beyond parent width */
  width: calc(100vw - 400px); /* Extend to viewport width minus legend/margins */
  max-width: 800px;
  margin-left: 0;
}

/* Expanded state - fully expand to push content down */
.nested-timeline-expand.expanded {
  max-height: none;
  opacity: 1;
  overflow: visible;
}

@media (max-width: 900px) {
  .nested-timeline-expand {
    width: calc(100vw - 80px);
    max-width: none;
  }
}

@media (max-width: 480px) {
  .nested-timeline-expand {
    width: calc(100vw - 32px);
  }
}

/* Pinned state - visual indicator on the featured card itself (white glow matches card edges) */
.timeline-slot-wrapper.nested-timeline-pinned .timeline-featured-card {
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
}

/* Content wrapper inside expand - outline only */
.nested-timeline-content {
  padding: var(--spacing-md, 16px);
  padding-top: var(--spacing-sm, 8px);
  width: 100%;
  max-width: 480px; /* Slightly wider to account for padding */
  margin: 0 auto; /* Center the nested content */
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md, 8px);
}

/* Nested timeline header row */
.nested-timeline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-sm, 8px);
  padding-bottom: var(--spacing-sm, 8px);
  margin-bottom: var(--spacing-md, 16px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Author info (left side) */
.nested-timeline-author {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0; /* Allow shrinking */
}

.nested-timeline-author-avatar {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.nested-timeline-title {
  font-size: 0.7rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* View timeline link (right side) */
.nested-timeline-view-link {
  font-size: 0.65rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.2s ease, text-shadow 0.2s ease;
}

.nested-timeline-view-link:hover {
  color: #ffffff;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.4);
}

/* Items vertical layout in nested timeline with timeline bar */
.nested-timeline-items {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md, 16px);
  width: 100%;
  padding-left: 32px; /* Space for timeline bar and ticks */
}

/* Vertical timeline bar for nested timeline */
.nested-timeline-items::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 12px;
  width: 2px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 1px;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.1);
}

/* Individual nested item */
.nested-timeline-item {
  position: relative;
  width: 100%;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md, 8px);
  overflow: visible; /* Allow tick to extend outside */
  transition: all 0.2s ease;
}

/* Clip content inside the item */
.nested-timeline-item-embed {
  overflow: hidden;
  border-radius: var(--radius-md, 8px);
}

/* Horizontal tick connecting item to timeline bar */
.nested-timeline-item::before {
  content: '';
  position: absolute;
  top: 24px;
  left: -20px;
  width: 12px;
  height: 2px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 1px;
  z-index: 1;
}

.nested-timeline-item:hover {
  border-color: rgba(0, 168, 255, 0.3);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

/* Embed container inside nested item */
.nested-timeline-item-embed {
  width: 100%;
  min-height: 100px;
}

/* Caption below the embed - hidden in embedded timelines */
.nested-timeline-item-caption {
  display: none;
}

/* Featured card style for page/collection/timeline types in nested timelines */
/* Matches main timeline featured cards, just scaled down */
.nested-timeline-item .nested-timeline-featured-card {
  aspect-ratio: 16/9;
  min-height: 180px;
  border-radius: var(--radius-md, 8px);
}

/* Scaled down text for nested cards */
.nested-timeline-item .timeline-featured-title {
  font-size: 0.9rem;
  -webkit-line-clamp: 2;
}

.nested-timeline-item .timeline-featured-description {
  font-size: 0.7rem;
  -webkit-line-clamp: 2;
}

.nested-timeline-item .timeline-featured-content {
  padding: 1rem;
}

.nested-timeline-item .timeline-featured-info {
  gap: 0.35rem;
}

/* Type indicator - top left, same position as main card, just smaller */
.nested-timeline-item .timeline-featured-type-indicator {
  top: 6px;
  left: 6px;
  padding: 2px 5px;
  font-size: 0.5rem;
  gap: 2px;
}

.nested-timeline-item .timeline-featured-type-indicator svg {
  width: 8px;
  height: 8px;
}

/* Attribution - bottom right, same position as main card, just smaller */
.nested-timeline-item .timeline-featured-attribution {
  bottom: 12px;
  right: 10px;
  font-size: 0.7rem;
  gap: 0.3rem;
}

.nested-timeline-item .timeline-featured-attribution .attribution-avatar {
  width: 18px;
  height: 18px;
}

/* Disable expansion for timeline cards within embedded timelines */
.nested-timeline-item .nested-timeline-featured-card {
  cursor: default;
  pointer-events: none;
}

/* Re-enable pointer events for links inside the card */
.nested-timeline-item .nested-timeline-featured-card .attribution-author,
.nested-timeline-item .nested-timeline-featured-card .timeline-featured-topic-pill {
  pointer-events: auto;
  cursor: pointer;
}

/* Remove container styling for featured cards (timeline/page/collection) */
.nested-timeline-item:has(.timeline-featured-card) {
  background: transparent;
  border: none;
  box-shadow: none;
}

.nested-timeline-item:has(.timeline-featured-card):hover {
  background: transparent;
  border: none;
  box-shadow: none;
}

/* YouTube embed in nested timeline */
.nested-timeline-item .youtube-responsive-wrapper {
  border-radius: 0;
}

/* Twitter embed in nested timeline - remove container styling */
.nested-timeline-item:has(.twitter-tweet),
.nested-timeline-item:has(.tweet-container) {
  background: transparent;
  border: none;
  box-shadow: none;
}

.nested-timeline-item:has(.twitter-tweet):hover,
.nested-timeline-item:has(.tweet-container):hover {
  background: transparent;
  border: none;
  box-shadow: none;
}

/* Tweet container in nested timeline - full width */
.nested-timeline-item .tweet-container {
  display: block;
  width: 100%;
  padding: 0;
  background: transparent;
}

/* Override Twitter widget styling - force full width */
.nested-timeline-item .twitter-tweet,
.nested-timeline-item .twitter-tweet-rendered,
.nested-timeline-item twitter-widget {
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

.nested-timeline-item .twitter-tweet iframe {
  width: 100% !important;
  max-width: 100% !important;
  border-radius: 12px !important;
  color-scheme: light !important;
}

/* Image wrapper in nested timeline */
.nested-timeline-item .timeline-image-wrapper {
  display: flex;
  justify-content: center;
  padding: var(--spacing-sm, 8px);
}

.nested-timeline-item .timeline-image-wrapper img {
  max-width: 100%;
  max-height: 400px;
  border-radius: var(--radius-sm, 6px);
}

/* Loading state */
.nested-timeline-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-xl, 32px);
  gap: var(--spacing-sm, 8px);
  color: var(--color-text-muted, #718096);
  font-size: var(--font-size-sm, 14px);
}

.nested-timeline-loading .loading-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid rgba(0, 168, 255, 0.2);
  border-top-color: var(--color-primary, #00a8ff);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Empty state */
.nested-timeline-empty {
  text-align: center;
  padding: var(--spacing-xl, 32px);
  color: var(--color-text-muted, #718096);
  font-size: var(--font-size-sm, 14px);
}

/* Error state */
.nested-timeline-error {
  text-align: center;
  padding: var(--spacing-xl, 32px);
  color: #ef4444;
  font-size: var(--font-size-sm, 14px);
}

/* Hide scrollbar for nested content while allowing scroll */
.nested-timeline-expand {
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge */
}

.nested-timeline-expand::-webkit-scrollbar {
  display: none; /* Chrome/Safari/Opera */
}

/* ============================================================
   Featured Card Style for Page/Collection/Timeline
   (Matches explore page featured cards exactly)
   ============================================================ */

.timeline-featured-card {
  position: relative;
  width: 100%;
  /* height is controlled by aspect-ratio or parent context */
  border-radius: var(--radius-md, 8px);
  overflow: hidden;
  background: #000;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.timeline-featured-card:hover {
  /* Subtle hover - matches carousel style */
}

/* Background image */
.timeline-featured-media {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-color: rgba(0, 168, 255, 0.1);
  transition: transform 0.4s ease;
  mask-image: linear-gradient(to bottom, black 0%, black 50%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, black 0%, black 50%, transparent 100%);
}

.timeline-featured-card:hover .timeline-featured-media {
  transform: scale(1.05);
}

/* Legacy gradient overlay - now handled by mask-image */
.timeline-featured-overlay {
  display: none;
}

/* Type indicator (top left) - matches canonical featured-embed-type */
.timeline-featured-type-indicator {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 10;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.85);
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.timeline-featured-type-indicator svg {
  width: 14px;
  height: 14px;
}

.timeline-featured-card:hover .timeline-featured-type-indicator {
  transform: scale(1.05);
}

/* Content overlay */
.timeline-featured-content {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 1.25rem;
  box-sizing: border-box;
  z-index: 3;
  pointer-events: none;
}

/* Topic pill (top right - matches carousel style) */
.timeline-featured-topic-pill {
  position: absolute;
  top: 8px;
  right: 8px;
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.5rem;
  background: rgba(0, 168, 255, 0.12);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(0, 168, 255, 0.3);
  border-radius: 4px;
  font-size: 0.6rem;
  font-weight: 500;
  color: #00a8ff;
  z-index: 4;
  white-space: nowrap;
  text-decoration: none;
  transition: all 0.15s ease;
  pointer-events: auto;
}

.timeline-featured-topic-pill:hover {
  background: rgba(0, 168, 255, 0.15);
  border-color: rgba(0, 168, 255, 0.4);
  transform: scale(1.05);
}

/* Info section (bottom) */
.timeline-featured-info {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.timeline-featured-title {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 700;
  color: white;
  line-height: 1.25;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.timeline-featured-description {
  margin: 0;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.8);
  line-height: 1.45;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Author attribution (bottom right corner) */
.timeline-featured-attribution {
  position: absolute;
  bottom: 16px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.85);
  z-index: 5;
}

.timeline-featured-attribution .attribution-label {
  display: none; /* Hide "by" label to match carousel */
}

.timeline-featured-attribution .attribution-author {
  display: flex;
  align-items: center;
  gap: 6px;
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  transition: color 0.2s ease, text-shadow 0.2s ease;
  pointer-events: auto;
}

.timeline-featured-attribution .attribution-author:hover {
  color: #33c4ff;
}

.timeline-featured-attribution .attribution-author:hover .attribution-username {
  text-shadow: 0 0 10px rgba(0, 168, 255, 0.6), 0 0 20px rgba(0, 168, 255, 0.4);
  text-decoration: none;
}

.timeline-featured-attribution .attribution-avatar {
  width: 20px;
  height: 20px;
  min-width: 20px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.3);
  object-fit: cover;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.timeline-featured-attribution .attribution-author:hover .attribution-avatar {
  border-color: rgba(0, 168, 255, 0.6);
  box-shadow: 0 0 10px rgba(0, 168, 255, 0.5), 0 0 20px rgba(0, 168, 255, 0.3);
}

.timeline-featured-attribution .attribution-username {
  font-weight: 500;
  color: inherit;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Brand placeholder for cards without thumbnail image */
.featured-embed-brand-placeholder {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 2;
  pointer-events: none;
}

.featured-embed-brand-placeholder img {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  box-shadow: 0 0 12px rgba(0, 168, 255, 0.3);
}

.featured-embed-brand-placeholder span {
  font-size: 1.25rem;
  font-weight: 600;
  font-style: italic;
  color: rgba(255, 255, 255, 0.95);
  white-space: nowrap;
  text-shadow: 0 0 6px rgba(255, 255, 255, 0.15);
}

/* Featured card inside slot content - ensure proper sizing */
.timeline-slot-content:has(.timeline-featured-card) {
  display: block;
  position: relative;
}

/* Featured card uses aspect ratio for height */
.timeline-slot-content .timeline-featured-card {
  position: relative;
  width: 100%;
  height: auto;
  min-height: 280px;
  aspect-ratio: 16/9;
}

/* ============================================================
   Timeline Legend (Left Side Navigation)
   ============================================================ */

.timeline-viewer-main {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  width: calc(100% - 160px);
  margin: 0 auto;
  padding: 0 0 var(--spacing-xl, 32px) 0;
  overflow: visible; /* Allow nested timelines to extend beyond */
}

.timeline-legend {
  position: sticky;
  top: 100px;
  flex-shrink: 0;
  width: 200px;
  min-width: 200px;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 0;
  margin-right: 80px;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.timeline-legend::-webkit-scrollbar {
  display: none;
}

.timeline-legend-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.timeline-legend-items:empty {
  display: none;
}

/* Individual legend item */
.timeline-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s ease, opacity 0.15s ease;
  user-select: none;
}

.timeline-legend-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.timeline-legend-item.active {
  background: rgba(0, 168, 255, 0.12);
}

/* Post type icon */
.timeline-legend-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.5);
}

.timeline-legend-icon svg {
  width: 14px;
  height: 14px;
}

/* Title text */
.timeline-legend-title {
  flex: 1;
  font-size: 11px;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.7);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.timeline-legend-item:hover .timeline-legend-title {
  color: rgba(255, 255, 255, 0.9);
}

.timeline-legend-item.active .timeline-legend-title {
  color: rgba(0, 168, 255, 0.9);
}

/* Custom name indicator */
.timeline-legend-item.has-custom-name .timeline-legend-title {
  color: rgba(255, 255, 255, 0.85);
}

/* Connector line */
.timeline-legend-line {
  width: 20px;
  height: 1px;
  background: rgba(255, 255, 255, 0.15);
  flex-shrink: 0;
  transition: background 0.15s ease, width 0.15s ease;
}

.timeline-legend-item:hover .timeline-legend-line {
  background: rgba(255, 255, 255, 0.3);
  width: 28px;
}

.timeline-legend-item.active .timeline-legend-line {
  background: rgba(0, 168, 255, 0.5);
  width: 28px;
}

/* ============================================================
   Nested Legend Structure (Chunk-Based Timeline)
   ============================================================ */

/* Year container */
.timeline-legend-year {
  margin-bottom: 2px;
}

/* Expand icon for years with months */
.legend-expand-icon {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: rgba(255, 255, 255, 0.4);
  transition: transform 0.2s ease, color 0.15s ease;
  cursor: pointer;
}

.legend-expand-icon:hover {
  color: rgba(255, 255, 255, 0.7);
}

.timeline-legend-year.expanded .legend-expand-icon {
  transform: rotate(90deg);
}

/* Spacer for items without expand icon */
.legend-expand-spacer {
  width: 16px;
  flex-shrink: 0;
}

/* Post count badge */
.timeline-legend-count {
  margin-left: auto;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.35);
  font-weight: 500;
  min-width: 20px;
  text-align: right;
}

.timeline-legend-item:hover .timeline-legend-count {
  color: rgba(255, 255, 255, 0.5);
}

.timeline-legend-item.active .timeline-legend-count {
  color: rgba(0, 168, 255, 0.6);
}

/* Nested months container */
.timeline-legend-months {
  display: none;
  margin-left: 24px;
  margin-top: 2px;
  padding-left: 8px;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
}

.timeline-legend-year.expanded .timeline-legend-months {
  display: block;
}

/* Month items */
.timeline-legend-item.month {
  padding: 5px 10px;
  font-size: 11px;
}

.timeline-legend-item.month .timeline-legend-title {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.6);
}

.timeline-legend-item.month:hover .timeline-legend-title {
  color: rgba(255, 255, 255, 0.85);
}

.timeline-legend-item.month.active .timeline-legend-title {
  color: rgba(0, 168, 255, 0.85);
}

/* ============================================================
   Chunk Dividers (Between Time Periods)
   ============================================================ */

.chunk-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 0;
  margin: 12px 0;
}

.chunk-divider::before,
.chunk-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
}

.chunk-divider span {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.45);
  white-space: nowrap;
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* ============================================================
   Chunk Loading Indicator
   ============================================================ */

.chunk-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  gap: 12px;
  color: rgba(255, 255, 255, 0.5);
  font-size: 13px;
}

.chunk-loading .loading-spinner {
  width: 24px;
  height: 24px;
}

/* ============================================================
   Chunk Boundary Sentinel (Invisible Trigger)
   ============================================================ */

.chunk-boundary-sentinel {
  height: 1px;
  visibility: hidden;
  pointer-events: none;
}

/* Slot number indicator */
.timeline-legend-slot {
  font-size: 9px;
  color: rgba(255, 255, 255, 0.35);
  font-weight: 500;
  min-width: 14px;
  text-align: right;
  flex-shrink: 0;
}

/* Timeline items container adjustments */
.timeline-viewer-main .timeline-items-container {
  flex: 1;
  min-width: 0;
  max-width: 600px;
  overflow: visible; /* Allow nested timelines to extend beyond */
}

/* Highlight effect when clicking legend */
.timeline-slot-wrapper.legend-highlight {
  animation: legendHighlight 1.5s ease-out;
}

@keyframes legendHighlight {
  0% {
    box-shadow: 0 0 0 3px rgba(0, 168, 255, 0.6);
  }
  100% {
    box-shadow: 0 0 0 0px rgba(0, 168, 255, 0);
  }
}

/* Responsive - hide on smaller screens */
@media (max-width: 900px) {
  .timeline-legend {
    display: none;
  }

  .timeline-viewer-main {
    flex-direction: column;
    width: calc(100% - 80px);
    padding: 0;
  }

  .timeline-viewer-main .timeline-items-container {
    max-width: 100%;
  }
}

/* Embed mode - hide legend */
.embed-mode .timeline-legend {
  display: none;
}

.embed-mode .timeline-viewer-main {
  padding: 0;
}

/* ============================================================
   Timeline Filter Bar (Topic Page)
   ============================================================ */

#topicTimelineView .library-filters-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 2rem;
}

#topicTimelineView .library-filters-row {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

#topicTimelineView .library-filters-row .timeline-sort-toggle {
  margin-left: auto;
}

/* ============================================================
   Timeline Scroll Sentinels (auto-load triggers)
   ============================================================ */

.timeline-page-btn {
  display: block;
  margin: 16px auto;
  padding: 10px 24px;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.4);
  font-size: 13px;
  cursor: default;
  text-align: center;
}

#topicTimelineView .timeline-viewer-main {
  max-width: 1400px;
  width: 100%;
  padding-left: 2rem;
  padding-right: 2rem;
  box-sizing: border-box;
}
