/* YouTube Video Cards - History-style appearance */

/* Base YouTube card styling */
.youtube-card {
  height: auto;
  min-height: 200px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  transition: all 0.35s cubic-bezier(0.2, 1, 0.3, 1);
  cursor: pointer;
  padding: 0;
  animation: fadeIn 0.5s ease-in-out;
  
  /* Cream/brown gradient theme for YouTube videos - paper-like historical feeling */
  background: linear-gradient(145deg, #5E3A3A 0%, #4a2a2a 50%, #3a1f1f 100%);
  border: 3px solid #9F733C;
  box-shadow: 
    0 4px 15px rgba(0, 0, 0, 0.4),
    0 0 20px rgba(159, 115, 60, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.youtube-card:hover {
  transform: translateY(-5px);
  box-shadow: 
    0 8px 25px rgba(0, 0, 0, 0.5),
    0 0 30px rgba(159, 115, 60, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

/* Add a subtle paper texture overlay */
.youtube-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: 
    radial-gradient(circle at 20% 80%, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.01) 1px, transparent 1px),
    radial-gradient(circle at 40% 40%, rgba(159, 115, 60, 0.03) 2px, transparent 2px);
  pointer-events: none;
  z-index: 1;
}

/* Add aged paper effect */
.youtube-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    45deg,
    rgba(159, 115, 60, 0.03) 0%,
    transparent 25%,
    transparent 75%,
    rgba(159, 115, 60, 0.03) 100%
  );
  pointer-events: none;
  border-radius: 9px;
  z-index: 1;
}

/* Thumbnail container for YouTube video preview */
.youtube-thumbnail-container {
  width: 100%;
  height: 160px;
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #4a2a2a, #3a1f1f);
  border-bottom: 2px solid rgba(159, 115, 60, 0.4);
  z-index: 2;
}

.youtube-thumbnail {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
  filter: sepia(0.1) contrast(1.1) brightness(0.95);
}

.youtube-card:hover .youtube-thumbnail {
  transform: scale(1.03);
}

/* Play button overlay on thumbnail */
.youtube-play-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60px;
  height: 60px;
  background: rgba(159, 115, 60, 0.9);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.youtube-play-overlay::after {
  content: '';
  width: 0;
  height: 0;
  border-left: 18px solid #f4e4c1;
  border-top: 12px solid transparent;
  border-bottom: 12px solid transparent;
  margin-left: 4px;
}

.youtube-card:hover .youtube-play-overlay {
  background: rgba(175, 135, 70, 0.95);
  transform: translate(-50%, -50%) scale(1.1);
}

/* Channel badge on thumbnail */
.youtube-channel-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(159, 115, 60, 0.9);
  color: #f4e4c1;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.75em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* Views count badge */
.youtube-views-badge {
  position: absolute;
  bottom: 8px;
  left: 8px;
  background: rgba(0, 0, 0, 0.7);
  color: #d4c4a1;
  padding: 3px 6px;
  border-radius: 3px;
  font-size: 0.7em;
  display: flex;
  align-items: center;
  gap: 4px;
}

.youtube-views-badge::before {
  content: '👁';
  font-size: 0.9em;
}

/* Content area */
.youtube-content {
  padding: 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 2;
}

.youtube-content h3 {
  margin: 0 0 8px 0;
  color: #f4e4c1;
  font-size: 1.2em;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.youtube-content .description {
  margin: 8px 0 12px 0;
  color: #d4c4a1;
  font-size: 0.85em;
  line-height: 1.5;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Meta section */
.youtube-meta {
  margin-top: auto;
  border-top: 1px solid rgba(159, 115, 60, 0.3);
  padding-top: 10px;
}

.youtube-meta span {
  display: block;
  margin-bottom: 4px;
  color: #d4c4a1;
  font-size: 0.8em;
}

.youtube-meta span strong {
  color: #9F733C;
  font-weight: 600;
  margin-right: 6px;
}

/* ========================================== */
/* YouTube Expanded Card Styling              */
/* ========================================== */

/* YouTube expanded card - COLUMN layout: video on top, content below */
.expanded-card.expanded.youtube-expanded {
  background: linear-gradient(145deg, #5E3A3A 0%, #4a2a2a 50%, #3a1f1f 100%);
  border: clamp(2px, 0.2vw, 4px) solid #9F733C;
  box-shadow: 
    0 clamp(0.7rem, 1.5vw, 2rem) clamp(1.8rem, 3vw, 4rem) rgba(0, 0, 0, 0.8),
    0 0 clamp(1rem, 2vw, 3rem) rgba(159, 115, 60, 0.3);
  /* Override the default row layout - we want column */
  flex-direction: column !important;
  overflow-y: auto;
  /* Ensure entire card is scrollable */
  max-height: 90vh;
}

/* Add paper texture to expanded YouTube cards */
.expanded-card.expanded.youtube-expanded::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: 
    radial-gradient(circle at 20% 80%, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.01) 1px, transparent 1px),
    radial-gradient(circle at 40% 40%, rgba(159, 115, 60, 0.03) 2px, transparent 2px);
  pointer-events: none;
  z-index: 1;
}

/* Add aged paper effect to expanded cards */
.expanded-card.expanded.youtube-expanded::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    45deg,
    rgba(159, 115, 60, 0.03) 0%,
    transparent 25%,
    transparent 75%,
    rgba(159, 115, 60, 0.03) 100%
  );
  pointer-events: none;
  border-radius: var(--border-radius);
  z-index: 1;
}

/* Video player section at TOP of expanded card - full width */
.youtube-expanded-video-section {
  width: 100%;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
  background: #000;
  border-bottom: 2px solid rgba(159, 115, 60, 0.4);
}

.youtube-expanded-video-section iframe {
  width: 100%;
  height: clamp(280px, 40vh, 450px);
  border: none;
  display: block;
}

/* Content area BELOW video - ROW layout with left/right sections */
.youtube-expanded-content {
  display: flex;
  flex-direction: row;
  position: relative;
  z-index: 2;
  flex: 1;
  min-height: clamp(300px, 40vh, 500px); /* Larger minimum height based on viewport */
  overflow: visible; /* Allow content to expand */
}

/* Left section - metadata (like history cards) - uses full available height */
.youtube-expanded-content .left-section {
  width: var(--left-section-width, clamp(180px, 25%, 280px));
  min-width: var(--left-section-width, clamp(180px, 25%, 280px));
  max-width: var(--left-section-width, clamp(180px, 25%, 280px));
  min-height: clamp(300px, 40vh, 500px); /* Match content area min-height */
  height: 100%; /* Fill full height */
  padding: clamp(12px, 2vw, 20px);
  background: rgba(0, 0, 0, 0.2);
  border-right: clamp(1px, 0.1vw, 2px) solid rgba(159, 115, 60, 0.4);
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  overflow-y: auto;
}

/* Right section - description, history button, and locations (like history cards) */
.youtube-expanded-content .right-section {
  flex: 1;
  padding: clamp(12px, 2vw, 20px);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  position: relative; /* For absolute positioning of history button */
}

.expanded-card.expanded.youtube-expanded .meta-container {
  flex: 1; /* Fill available height in left section */
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 1.5vw, 16px);
  min-height: clamp(300px, 40vh, 500px); /* Force minimum height */
}

.expanded-card.expanded.youtube-expanded .meta-container span {
  border-bottom: clamp(1px, 0.05vw, 2px) solid rgba(159, 115, 60, 0.3);
  color: #d4c4a1;
  padding-bottom: 4px;
  margin-bottom: 6px;
  display: block;
}

.expanded-card.expanded.youtube-expanded .meta-container span strong {
  color: #9F733C;
  font-weight: 600;
  display: block;
  margin-bottom: 2px;
}

.expanded-card.expanded.youtube-expanded h3 {
  color: #f4e4c1;
  text-shadow: 0 0 clamp(0.3rem, 1vw, 0.8rem) rgba(159, 115, 60, 0.4);
  font-weight: 600;
  margin: 0 0 12px 0;
  font-size: clamp(1.1rem, 2vw, 1.4rem);
  order: 0; /* After history button */
  flex-shrink: 0;
}

.expanded-card.expanded.youtube-expanded .description-container {
  margin-bottom: 16px;
  order: 1;
  flex-shrink: 0;
}

.expanded-card.expanded.youtube-expanded .description {
  color: #d4c4a1;
  line-height: 1.6;
  font-size: clamp(0.85rem, 1.4vw, 1rem);
}

/* History Button Styling for YouTube Cards - positioned at top-right of right section */
.expanded-card.expanded.youtube-expanded .history-btn {
  background: rgba(159, 115, 60, 0.6);
  box-shadow: 0 0 clamp(0.3rem, 1vw, 0.8rem) rgba(159, 115, 60, 0.4);
  color: #f4e4c1;
  border: 1px solid rgba(159, 115, 60, 0.5);
  width: clamp(2rem, 3vw, 2.5rem);
  height: clamp(2rem, 3vw, 2.5rem);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 1.2rem;
  /* Position at top-right corner */
  position: absolute;
  top: clamp(12px, 2vw, 20px);
  right: clamp(12px, 2vw, 20px);
  z-index: 10;
}

.expanded-card.expanded.youtube-expanded .history-btn:hover {
  background: rgba(159, 115, 60, 0.9);
  box-shadow: 0 0 clamp(0.5rem, 1.5vw, 1.2rem) rgba(159, 115, 60, 0.8);
  transform: scale(1.1);
  color: #fff;
}

/* Locations section styling (matches history cards exactly) */
.expanded-card.expanded.youtube-expanded .locations-heading {
  margin-top: clamp(1rem, 2vw, 1.5rem);
  margin-bottom: clamp(0.5rem, 1vw, 0.8rem);
  display: block;
  flex-shrink: 0;
  order: 2;
}

.expanded-card.expanded.youtube-expanded .locations-heading h4 {
  color: #f4e4c1;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  margin: 0;
  font-size: clamp(1rem, 1.8vw, 1.3rem);
}

.expanded-card.expanded.youtube-expanded .locations-list {
  min-height: clamp(8rem, 20vh, 12rem);
  max-height: clamp(12rem, 30vh, 18rem);
  height: auto;
  overflow-y: auto;
  margin-bottom: clamp(1rem, 2vw, 1.5rem);
  border-radius: clamp(0.2rem, 0.4vw, 0.3rem);
  padding: clamp(0.6rem, 1vw, 0.8rem);
  border: clamp(1px, 0.1vw, 2px) solid rgba(159, 115, 60, 0.3);
  background-color: rgba(0, 0, 0, 0.15);
  border-style: solid;
  flex-shrink: 0;
  order: 3;
}

.expanded-card.expanded.youtube-expanded .location-item {
  color: #d4c4a1;
  cursor: pointer;
  transition: background-color 0.2s;
  padding: clamp(0.3rem, 0.6vw, 0.5rem) clamp(0.4rem, 0.8vw, 0.6rem);
  border-radius: clamp(0.15rem, 0.3vw, 0.25rem);
  margin-bottom: clamp(0.3rem, 0.6vw, 0.4rem);
  font-size: var(--font-size-body, 0.9rem);
}

.expanded-card.expanded.youtube-expanded .location-item:hover {
  color: #f4e4c1;
  background: rgba(159, 115, 60, 0.15);
}

.expanded-card.expanded.youtube-expanded .no-locations {
  color: #888;
  font-style: italic;
  padding: 8px 0;
}

/* Highlight locations button (matches history cards) */
.expanded-card.expanded.youtube-expanded .highlight-locations-btn {
  background: linear-gradient(145deg, #9F733C, #8b6328);
  border: 1px solid #b3864a;
  color: #f4e4c1;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  margin-top: 12px;
  transition: all 0.3s ease;
  flex-shrink: 0;
  order: 4;
}

.expanded-card.expanded.youtube-expanded .highlight-locations-btn:hover {
  background: linear-gradient(145deg, #b3864a, #9F733C);
  border-color: #c89a1f;
  color: #ffffff;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
  .expanded-card.expanded.youtube-expanded {
    flex-direction: column !important;
  }
  
  .youtube-expanded-content {
    flex-direction: column;
  }
  
  .youtube-expanded-content .left-section {
    flex: none;
    border-right: none;
    border-bottom: 1px solid rgba(159, 115, 60, 0.4);
    max-height: 200px;
  }
  
  .youtube-expanded-video-section iframe {
    height: clamp(180px, 40vw, 250px);
  }
  
  .youtube-card {
    min-height: 180px;
  }
  
  .youtube-thumbnail-container {
    height: 140px;
  }
}

/* Animation for card appearance */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Video tab controls - horizontal layout */
#video-controls-container {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 12px 0;
  padding: 0 10px;
}

#video-sort-container {
  display: flex;
  align-items: center;
  gap: 8px;
  order: 1;
}

#video-filters-dropdown {
  position: relative;
  order: 2;
  margin-left: auto;
}

#video-sort-container label {
  font-size: 13px;
  color: #aaa;
  font-weight: 500;
  white-space: nowrap;
}

#video-sort-select {
  padding: 6px 10px;
  background: linear-gradient(145deg, #2a2a2a 0%, #3d3d3d 100%);
  color: #f0f0f0;
  border: 1px solid #9F733C;
  border-radius: 6px;
  font-size: 12px;
  outline: none;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

#video-sort-select:focus {
  border-color: #b3864a;
}

#video-sort-select option {
  background: #2a2a2a;
  color: #f0f0f0;
  padding: 8px;
}

/* Video results summary */
#video-results-summary {
  margin: 8px 0;
  padding: 0 10px;
  font-size: 13px;
  color: #aaa;
}

/* Video list container */
#video-list {
  display: flex;
  flex-direction: column;
  gap: 15px;
  padding: 0 10px;
}

/* No videos message */
#video-list .no-videos {
  text-align: center;
  padding: 40px 20px;
  color: #888;
  font-size: 14px;
}

/* Video info container */
#video-info-container {
  margin: 10px;
  padding: 10px;
  background: rgba(30, 30, 30, 0.5);
  border-radius: 8px;
  border: 1px solid rgba(100, 100, 100, 0.3);
}

