/* Entity Detail Page Styles */

/* Hero Table Layout */
.hero-table {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

/* Desktop table layout */
@media (min-width: 769px) {
  .hero-table {
    display: table;
    width: 100%;
    table-layout: fixed;
  }
  
  .hero-image-column {
    display: table-cell;
    width: 300px;
    vertical-align: middle;
    text-align: center;
    padding-right: 2rem;
    height: 100%;
  }
  
  .hero-content-column {
    display: table-cell;
    vertical-align: middle;
    text-align: center;
  }
}

/* Hero Image */
.hero-image-container {
  display: flex;
  justify-content: center;
  margin-bottom: 0;
  height: 100%;
}

.hero-image {
  width: 100%;
  max-width: 280px;
  height: 100%;
  min-height: 300px;
  object-fit: cover;
}

/* Mobile layout */
@media (max-width: 768px) {
  .hero-table {
    flex-direction: column;
    text-align: center;
  }
  
  .hero-image-container {
    height: auto;
    margin-bottom: 1.25rem;
    margin-top: -12px; /* move image up on mobile */
  }
  
  .hero-image {
    max-width: 224px; /* 20% smaller than 280px desktop */
    height: auto;
    min-height: auto;
  }
}

@media (max-width: 480px) {
  .hero-image { max-width: 200px; }
  
  .hero-image-container {
    margin-bottom: 1rem;
  }
}

/* Mobile Layout Reordering */
@media (max-width: 768px) {
  .hero-overlay { background-size: 50%; opacity: 0.12; }
  .hero-summary { display: none; }
  .mobile-layout-container {
    display: flex;
    flex-direction: column;
  }
  
  /* Age bands appear first */
  .mobile-age-bands {
    order: 1;
  }
  
  /* Main content appears second (right after age bands) */
  .mobile-main-content {
    order: 2;
  }
  
  /* Individual sidebar sections ordered separately (now direct children) */
  .entity-facts {
    order: 3; /* Associated Topics */
  }
  
  .related-entities {
    order: 4; /* Related Topics */
  }
  
  .recommendations-section {
    order: 5; /* Recommended for You */
  }
  
  .browse-more {
    order: 6; /* Explore More */
  }
  
  /* Keep lighter padding on mobile for sidebar sections */
  .entity-facts,
  .related-entities,
  .recommendations-section,
  .browse-more {
    padding: 1.5rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  }
}

/* Desktop Layout - Match hero container styling with CSS Grid */
@media (min-width: 769px) {
  .hero-summary {
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    max-height: calc(1.5em * 4);
  }
  /* Wrapper container matches hero styling exactly */
  .mobile-layout-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
    display: grid;
    grid-template-columns: 1fr 320px;
    grid-gap: 2rem;
    grid-template-areas: 
      "age-bands age-bands"
      "main-content sidebar-1"
      "main-content sidebar-2" 
      "main-content sidebar-3"
      "main-content sidebar-4";
    align-items: start;
  }
  
  /* Grid areas */
  .mobile-age-bands {
    grid-area: age-bands;
  }
  
  .mobile-main-content {
    grid-area: main-content;
  }
  
  /* Content wrapper is single column - override the 2-column grid */
  .mobile-main-content .content-wrapper {
    width: 100%;
    max-width: none;
    display: block !important; /* Override grid layout */
    grid-template-columns: unset !important;
    gap: unset !important;
  }
  
  /* Ensure main content takes full width within wrapper */
  .mobile-main-content .main-content {
    width: 100%;
    max-width: none;
  }
  
  .entity-facts {
    grid-area: sidebar-1;
  }
  
  .related-entities {
    grid-area: sidebar-2;
  }
  
  .recommendations-section {
    grid-area: sidebar-3;
  }
  
  .browse-more {
    grid-area: sidebar-4;
  }
  
  /* Add margin around sidebar sections to match main content wrapper spacing */
  .entity-facts,
  .related-entities,
  .recommendations-section,
  .browse-more {
    /* Reset base styling */
    padding: 2.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    /* Add wrapper-style margin around each section */
    margin: 1rem 0; /* Top/bottom margin like a wrapper would provide */
  }
  
  /* First sidebar section to align with main content */
  .entity-facts {
    margin-top: 0;
  }
  
  /* Reset mobile orders */
  .mobile-age-bands,
  .mobile-main-content,
  .entity-facts,
  .related-entities, 
  .recommendations-section,
  .browse-more {
    order: unset;
  }
}

/* Tag Links */
.entity-detail-page .tag-link {
  display: inline-block;
  padding: 0.375rem 0.75rem;
  margin: 0.25rem 0.25rem 0.25rem 0;
  background: var(--kind, #8B5CF6);
  color: white;
  text-decoration: none;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  transition: all 0.2s ease;
}

.entity-detail-page .tag-link:hover {
  background: color-mix(in srgb, var(--kind, #8B5CF6) 85%, black);
  color: white;
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Content Title Header */
.content-title-header {
  font-size: 2rem;
  font-weight: 700;
  color: #212529;
  margin: 0 0 1.5rem 0;
  line-height: 1.2;
  border-bottom: 3px solid var(--kind, #8B5CF6);
  padding-bottom: 0.75rem;
}

/* Age Band Navigation */
.age-band-navigation {
  background: #f8f9fa;
  border-bottom: 1px solid #e9ecef;
  padding: 1rem 0;
}

.age-band-nav-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.age-band-label {
  font-weight: 600;
  color: #495057;
  font-size: 0.9rem;
}

.age-band-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.age-band-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.625rem 1.25rem;
  border-radius: 25px;
  background: #343a40;
  border: none;
  color: white;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 700;
  transition: all 0.2s ease;
}

.age-band-btn:hover {
  background: #495057;
  color: white;
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.age-band-btn.active {
  background: var(--kind, #8B5CF6);
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.12);
}

.age-band-btn.active:hover {
  background: color-mix(in srgb, var(--kind, #8B5CF6) 85%, black);
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.18);
}

@media (max-width: 768px) {
  .age-band-nav-content {
    justify-content: center;
    text-align: center;
  }
  
  .age-band-label {
    margin: 0;
  }
}

/* Hero Section */
.entity-hero {
  position: relative;
  min-height: 500px;
  display: flex;
  align-items: center;
  color: white;
  overflow: hidden;
}

.hero-background {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  background: color-mix(in srgb, var(--kind, #8B5CF6) 92%, transparent);
}

.hero-background-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.8;
}

.hero-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url('/images/patterns/scribble-bg.png') center center repeat;
  background-size: 30%;
  opacity: 0.14;
  z-index: 2;
}

.hero-content {
  position: relative;
  z-index: 3;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.language-dropdown-header-container {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 10;
}

.language-dropdown-header-container .language-dropdown .dropdown-toggle {
  color: white !important;
  border-color: rgba(255, 255, 255, 0.3) !important;
  background-color: rgba(255, 255, 255, 0.1) !important;
}

.language-dropdown-header-container .language-dropdown .dropdown-toggle:hover {
  background-color: rgba(255, 255, 255, 0.2) !important;
  border-color: rgba(255, 255, 255, 0.5) !important;
}

.hero-text {
  margin-top: 3rem;
  text-align: center;
}

.entity-type-badge {
  display: inline-block;
  padding: 0.5rem 1rem;
  border-radius: 25px;
  font-size: 0.875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 1rem;
  color: white;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.entity-type-badge.person { background: rgba(231, 76, 60, 0.9); }
.entity-type-badge.place { background: rgba(46, 204, 113, 0.9); }
.entity-type-badge.event { background: rgba(243, 156, 18, 0.9); }
.entity-type-badge.invention { background: rgba(155, 89, 182, 0.9); }
.entity-type-badge.concept { background: rgba(52, 152, 219, 0.9); }
.entity-type-badge.myth { background: rgba(230, 126, 34, 0.9); }

.hero-title {
  font-size: 3.5rem;
  font-weight: 900;
  margin-bottom: 1rem;
  text-shadow: none;
  line-height: 1.1;
}

.entity-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 1.125rem;
  margin-bottom: 1.5rem;
  opacity: 0.9;
  flex-wrap: wrap;
}

.entity-name {
  font-weight: 600;
}

.meta-separator {
  opacity: 0.6;
}

.hero-summary {
  font-size: 1.25rem;
  font-weight: 300;
  max-width: 800px;
  margin: 0 auto 2rem;
  line-height: 1.5;
  opacity: 0.95;
}

.key-dates {
  display: flex;
  gap: 2rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 2rem;
}

.date-item {
  text-align: center;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  backdrop-filter: blur(10px);
  min-width: 120px;
}

.date-label {
  display: block;
  font-size: 0.875rem;
  opacity: 0.8;
  margin-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.date-value {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
}

/* Main Content */
.entity-content {
  background: #f8f9fa;
  padding: 3rem 1rem;
}

.content-wrapper {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 3rem;
}

/* Main Content Area */
.main-content {
  background: white;
  border-radius: 12px;
  padding: 2.5rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.story-sections {
  margin-bottom: 3rem;
}

.story-section {
  margin-bottom: 2.5rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid #e9ecef;
}

.story-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.section-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: #2c3e50;
  margin-bottom: 1rem;
}

.section-content {
  font-size: 1.125rem;
  line-height: 1.7;
  color: #4a5568;
  margin-bottom: 1.5rem;
}

.section-content p {
  margin-bottom: 1rem;
}

.section-image {
  margin: 2rem 0;
  text-align: center;
}

.section-image img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

/* Learning Activities */
.learning-activities {
  margin-bottom: 3rem;
}

.activities-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: #2c3e50;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.activities-title::before {
  content: '🎯';
  font-size: 1.5rem;
}

.activities-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}

.activity-card {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 1.5rem;
  border-radius: 12px;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  transition: transform 0.2s ease;
}

.activity-card:hover {
  transform: translateY(-2px);
}

.activity-icon {
  font-size: 2rem;
  opacity: 0.9;
  flex-shrink: 0;
}

.activity-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: white;
}

.activity-description {
  font-size: 0.975rem;
  opacity: 0.9;
  line-height: 1.4;
  margin: 0;
}

/* Educational Resources */
.educational-resources {
  margin-bottom: 2rem;
}

.resources-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: #2c3e50;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.resources-title::before {
  content: '📚';
  font-size: 1.5rem;
}

.resources-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.resource-card {
  background: white;
  border: 2px solid #e9ecef;
  border-radius: 10px;
  padding: 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  transition: all 0.2s ease;
}

.resource-card:hover {
  border-color: #667eea;
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.1);
}

.resource-icon {
  font-size: 1.5rem;
  color: #667eea;
  flex-shrink: 0;
  margin-top: 0.25rem;
}

.resource-title {
  font-size: 1rem;
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 0.5rem;
}

.resource-description {
  font-size: 0.875rem;
  color: #6c757d;
  margin-bottom: 0.75rem;
  line-height: 1.4;
}

.resource-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: #6c757d;
  margin-bottom: 0.75rem;
}

.resource-link {
  color: #667eea;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.875rem;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.resource-link:hover {
  color: #5a6fd8;
  text-decoration: none;
}

/* Sidebar */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.entity-facts,
.related-entities,
.recommendations-section,
.browse-more {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.facts-title,
.related-title,
.browse-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #2c3e50;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}


.facts-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

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

.fact-label {
  font-size: 0.8rem;
  color: #6c757d;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.fact-value {
  font-size: 0.925rem;
  color: #2c3e50;
  font-weight: 500;
}

.tags-item {
  margin-top: 0.5rem;
}

.tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.tag {
  padding: 0.25rem 0.6rem;
  background: #667eea;
  color: white;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
}

/* Related Entities */
.related-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.related-item {
  padding: 0.75rem;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.related-item:hover {
  border-color: #667eea;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
}

.related-link {
  text-decoration: none;
  color: inherit;
}

.related-link:hover {
  color: inherit;
  text-decoration: none;
}

.related-name {
  font-size: 0.925rem;
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 0.25rem;
}

.related-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: #6c757d;
}

.related-type {
  background: #e9ecef;
  padding: 0.2rem 0.5rem;
  border-radius: 10px;
  text-transform: uppercase;
  font-weight: 600;
}

/* Recommendations Section */
.recommendations-section {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.recommendations-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: white;
}

.recommendations-subtitle {
  font-size: 0.875rem;
  opacity: 0.9;
  margin-bottom: 1rem;
  font-style: italic;
}

.recommendations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

.recommendation-card {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  overflow: hidden;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.recommendation-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
  background: rgba(255, 255, 255, 0.15);
}

.recommendation-link {
  display: block;
  text-decoration: none;
  color: inherit;
  height: 100%;
}

.recommendation-link:hover {
  text-decoration: none;
  color: inherit;
}

.recommendation-image {
  position: relative;
  height: 180px; /* Increased from 120px for desktop */
  overflow: hidden;
  background: rgba(255, 255, 255, 0.1);
}

/* Mobile - 2x taller as requested */
@media (max-width: 768px) {
  .recommendation-image {
    height: 240px; /* 2x the original 120px */
  }
}

.recommendation-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.recommendation-card:hover .recommendation-image img {
  transform: scale(1.1);
}

.recommendation-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  opacity: 0.6;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
}

.reason-badge {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.2rem 0.5rem;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
}

.reason-badge.related { background: rgba(46, 204, 113, 0.9); }
.reason-badge.similar { background: rgba(52, 152, 219, 0.9); }
.reason-badge.age_appropriate { background: rgba(155, 89, 182, 0.9); }
.reason-badge.popular { background: rgba(243, 156, 18, 0.9); }

.recommendation-info {
  padding: 1rem;
}

.recommendation-title {
  font-size: 0.925rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  line-height: 1.3;
  color: white;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.recommendation-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  opacity: 0.8;
  color: white;
}

.recommendation-debug {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  opacity: 0.7;
  font-size: 0.75rem;
}

/* Browse More */
.browse-links {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.browse-link {
  padding: 0.75rem 1rem;
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  text-decoration: none;
  color: #495057;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transition: all 0.2s ease;
}

.browse-link:hover {
  background: #667eea;
  color: white;
  text-decoration: none;
  transform: translateY(-1px);
}

/* Responsive Design */
@media (max-width: 992px) {
  .content-wrapper {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
  
  .sidebar {
    order: -1;
  }
}

@media (max-width: 768px) {
  .hero-title {
    font-size: 2.5rem;
  }
  
  .hero-summary {
    font-size: 1.125rem;
  }
  
  .entity-info {
    font-size: 1rem;
    flex-direction: column;
    gap: 0.25rem;
  }
  
  .key-dates {
    gap: 1rem;
  }
  
  .main-content {
    padding: 1.5rem;
  }
  
  .activities-grid {
    grid-template-columns: 1fr;
  }
  
  .date-item {
    min-width: 100px;
    padding: 0.75rem;
  }
  
  .language-dropdown-header-container {
    top: 0.5rem;
    right: 0.5rem;
  }
}

@media (max-width: 480px) {
  .entity-content {
    padding: 2rem 1rem;
  }
  
  .hero-title {
    font-size: 2rem;
  }
  
  .hero-summary {
    font-size: 1rem;
  }
  
  .main-content {
    padding: 1rem;
  }
  
  .key-dates {
    flex-direction: column;
    gap: 0.75rem;
  }
  
  .activity-card {
    padding: 1rem;
  }
  
  .sidebar {
    gap: 1.5rem;
  }
}
