@import url('https://fonts.googleapis.com/css2?family=Abril+Fatface&display=swap');

* {
  box-sizing: border-box;
}

body {
  font-family: "Roboto", sans-serif;
  margin: 0;
  padding: 0;
  background-color: var(--background-color);
  color: var(--text-color);
  -ms-overflow-style: none;
  scrollbar-width: none;
  /* Added background image for sky */
  /* Replaced background-image with background to layer the semi-transparent color overlay */
  background:
    linear-gradient(rgba(var(--primary-color-rgb, 0, 0, 0), 0.3), rgba(var(--primary-color-rgb, 0, 0, 0), 0.3)),
    url('/sky-back-b2.png');
  background-size: 100% auto;
  background-position: top center;
  background-repeat: no-repeat;
  background-attachment: fixed; /* Keep background fixed during scroll */
}

/* Desktop: If bg-desktop-hidden is true, hide it for >= 769px */
@media (min-width: 769px) {
    [data-bg-desktop-hidden="true"] body {
        background: var(--background-color);
        background-attachment: scroll;
    }
}

/* Mobile: If bg-mobile-hidden is true, hide it for <= 768px */
@media (max-width: 768px) {
    [data-bg-mobile-hidden="true"] body {
        background: var(--background-color);
        background-attachment: scroll;
    }
}

body::-webkit-scrollbar {
  display: none;
}

.container {
  max-width: 90%;
  margin: 0 auto;
  padding: 2vh 2vw;
  display: flex;
  flex-direction: column;
  align-items: center;
}

header {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 2vh;
  width: 100%;
}

.header-top {
  width: 100%;
  /* add 20px above the logo and subtract 20px from bottom so content below moves up */
  padding: calc(2vh + 20px) 0 calc(2vh - 20px) 0;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 2vh;
}

/* New wrapper to support layered logo shadow */
.logo-wrapper {
  position: relative;
  display: inline-block;
  width: 620px; /* match larger desktop logo width */
  height: 160px; /* match larger desktop logo height */
  line-height: 0;
}

/* The underlying layer (7hw) positioned 2px up and 2px left relative to main logo */
.logo-shadow {
  position: absolute;
  top: 1px;   /* 1px down */
  left: 1px;  /* 1px right */
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: 1;
  background-image: url('/6db (3).png'); /* updated to use larger 620x160 logo shadow */
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

/* Main logo sits above the shadow */
.logo {
  position: relative;
  z-index: 1;
  width: 620px;  /* updated to match larger desktop logo width */
  height: 160px; /* updated to match larger desktop logo height */
  opacity: 1;

  /* Use theme color fill with the white logo as a mask */
  background-color: var(--primary-color);
  -webkit-mask-image: url('/6d (3).png'); /* updated to use larger 620x160 mask */
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  -webkit-mask-size: contain;
  mask-image: url('/6d (3).png'); /* updated to use larger 620x160 mask */
  mask-repeat: no-repeat;
  mask-position: center;
  mask-size: contain;
}

/* Responsive overrides keep the wrapper sizing consistent with existing responsive rules */
@media (max-width: 768px) {
  .logo-wrapper {
    width: 200px;
    height: 75px;
  }
  .logo, .logo-shadow {
    width: 100%;
    height: 100%;
  }
}

/* New wrapper to handle centering of category display and positioning of sort ball */
.category-header-wrapper {
    position: relative; /* For absolute positioning of the ball */
    width: 100%; /* Spans the width of .container */
    max-width: 800px; /* Should match max-width of search-container and top-category-header */
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 2vh; 
    min-height: 40px; 
}

h1 {
  color: var(--primary-color);
  margin: 0;
  display: none;
}

.search-container {
  width: 90%;
  max-width: 800px;
  margin: 0 auto 4vh;
  display: flex;
  gap: 1vw;
  justify-content: center;
  padding: 0 2vw;
  box-sizing: border-box;
}

#searchInput {
  padding: 1.5vh 2vw;
  font-size: 1rem;
  border-radius: 5px;
  background-color: rgba(0, 0, 0, 0.75);
  color: #ffffff !important;
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: all 0.3s ease;
  flex-grow: 1;
}

#searchInput::placeholder {
  color: #ffffff !important;
}

#searchInput:focus {
  background-color: rgba(0, 0, 0, 0.9);
  border-color: var(--primary-color);
  outline: none;
}

/* Desktop View Adjustments (min-width: 769px) */
@media (min-width: 769px) {
    #searchInput {
        /* 1. Make 30% smaller: reduce flexibility and set explicit width */
        flex-grow: 0; 
        width: 70%; 
        
        /* 2. Center the placeholder text */
        text-align: center;
    }
    
    /* 2b. Placeholder centering */
    #searchInput::placeholder {
        text-align: center;
    }
}

/* Light theme search overrides */
[data-theme^="light"] #searchInput {
  background-color: #ffffff !important;
  color: #000000 !important;
  border-color: rgba(0,0,0,0.12) !important;
}

[data-theme^="light"] #searchInput::placeholder {
  color: #666666 !important;
}

.media-section {
  margin-bottom: 4vh;
  width: 100%;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 2vw;
  padding: 2vh 0;
  width: 100%;
}

.media-item {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: transform 0.3s ease, box-shadow 0.3s ease, filter 0.5s ease, opacity 0.5s ease;
  cursor: pointer;
  aspect-ratio: 2/3;
}

/* New rule for person items hover effect (Search Grid) */
.media-item.person-item:hover img {
    animation: floatSlow 3s ease-in-out infinite;
}

/* Click effect: press in slightly (scale down) */
.media-item.person-item:active img {
    transform: scale(0.98);
    transition: transform 0.1s ease;
    animation: none; /* Stop float animation when pressed */
}

/* Class to apply the requested blur when modal is open (50% blur interpreted as noticeable blur and reduced opacity) */
.media-item.blurred-on-open {
    filter: blur(8px);
    opacity: 0.5;
}

/* Quick Links Buttons */
.quick-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-bottom: 2vh;
}

.quick-link-btn {
  background-color: var(--primary-color);
  color: var(--text-color);
  border: 1px solid transparent;
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.3s ease;
  opacity: 0.85;
}

.quick-link-btn:hover {
}

[data-theme^="light"] .quick-link-btn {
    color: #000 !important;
}

[data-theme^="light"] .quick-link-btn:hover {
    color: #000 !important;
}


.media-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-info {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0);
  padding: 1vh;
  display: none;
}

/* Apply Roboto font face for search bar results (media items titles, ratings, and known-for descriptions) */
.media-item .media-title,
.media-item .media-rating,
.media-item .media-known-for {
  font-family: 'Roboto', sans-serif;
}

.media-title {
  margin: 0;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--primary-color);
}

/* New style for the second part of a split title */
.media-title .title-part-secondary {
    color: var(--lighter-primary-color) !important;
}

.media-rating {
  font-size: 0.8rem;
  color: #ffd700;
  margin: 0.3vh 0;
}

.media-rating-badge {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: bold;
  z-index: 10;
}

.media-year-badge {
  position: absolute;
  bottom: 8px;
  left: 8px;
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: bold;
  z-index: 10;
}

/* New element definition for the top, centered category/search text */
.top-category-header {
  font-family: 'Roboto', cursive;
  font-size: 1.2rem; 
  padding: 8px 16px;
  margin: 0; 
  background: none;
  color: var(--text-color) !important; 
  border-radius: 5px;
  text-transform: uppercase;
  display: none; 
  align-items: center;
  justify-content: center;
  max-width: 90%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 1; 
  font-weight: bold; 
}

/* Idle carousel lines when no category/button titles are displayed */
.category-idle-carousel {
  font-family: 'Roboto', cursive; /* match top-category-header font */
  font-size: 1.2rem;
  padding: 8px 16px;
  margin: 0;
  background: none;
  color: var(--text-color) !important;
  border-radius: 5px;
  text-transform: uppercase;
  display: none;
  align-items: center;
  justify-content: center;
  max-width: 90%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.85;
  font-weight: bold;
  letter-spacing: 0.12em;
}

/* Light theme adjustment: keep text readable against light backgrounds */
[data-theme^="light"] .category-idle-carousel {
  color: var(--text-color) !important;
}

/* New style for the sort rating ball */
.sort-rating-ball {
    width: 36px; 
    height: 36px;
    border-radius: 50%;
    background: var(--primary-color);
    color: var(--text-color);
    
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem; 
    font-weight: bold;
    cursor: pointer;
    z-index: 500; 
    
    transition: transform 0.2s, opacity 0.3s;
    user-select: none;
    
    position: absolute;
    right: -20px; 
    top: 50%;
    transform: translateY(-50%); 

    opacity: 0;
    pointer-events: none; 
}

.sort-rating-ball.visible {
    opacity: 1;
    pointer-events: auto;
}

.sort-rating-ball:hover {
    transform: translateY(-50%) scale(1.1);
}

/* Specific styling for light themes to ensure text/border visibility */
[data-theme^="light"] .sort-rating-ball {
    color: #000000 !important;
}

/* Default content: Descending (highest first) */
.sort-rating-ball::after {
    content: '▼'; 
    font-size: 0.8em; 
}

/* Ascending content: Lowest first */
.sort-rating-ball.asc::after {
    content: '▲'; 
}

.top-category-header .category-prefix,
.category-display .category-prefix {
  font-size: 0.6875em; 
  opacity: 0.8;
  margin-right: 0.5em;
  white-space: nowrap;
}

/* New style for the result count number */
.category-prefix .result-count {
    font-size: 1.6em; 
    font-weight: bold;
    opacity: 1; 
}

.top-category-header .category-main-term,
.category-display .category-main-term {
    font-size: 1em; 
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.category-display {
  font-family: 'Abril Fatface', cursive;
  font-size: 1.2rem;
  padding: 8px 16px;
  margin: 20px;
  background: none;
  color: var(--text-color);
  border-radius: 5px;
  text-transform: uppercase;
  display: none;
  align-items: center;
  position: sticky;
  top: 2vh;
  z-index: 999;
  opacity: 1; 
  transition: opacity 0.5s;
  font-weight: bold; 
}

.category-display.visible {
  display: flex;
  opacity: 0.85; 
}

.category-display.fade {
  opacity: 0;
}

@media (max-width: 768px) {
  .search-container {
    padding: 0 2vw;
    width: 96vw;
  }

  .container {
    margin-left: 0;
    padding: 2vh 2vw;
  }
}

@media (max-width: 480px) {
  .media-grid {
    grid-template-columns: repeat(auto-fill, minmax(45%, 1fr));
    gap: 2vw;
  }
}

/* light theme color overrides for search */
[data-theme^="light"] #searchButton,
[data-theme^="light"] .sidebar-toggle {
  color: #000 !important;
}

[data-theme^="light"] #searchButton:hover,
[data-theme^="light"] #searchButton:focus,
[data-theme^="light"] #searchButton:active {
  color: #ffffff !important;
}

[data-theme^="light"] .category-display {
  color: #000 !important;
}

.save-checkmark {
    position: fixed;
    width: 90px; /* Increased size */
    height: 90px; /* Increased size */
    border-radius: 50%;
    background-color: var(--primary-color); /* Use theme primary color */
    color: var(--text-color); /* Adapt text color to theme */
    font-size: 48px; /* Larger checkmark */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 60000;
    pointer-events: none;
    opacity: 0;
    transform: scale(0.5);
    transition: opacity 0.2s ease-out, transform 0.2s ease-out;
    box-shadow: 0 0 20px rgba(var(--primary-color-rgb), 0.6); /* Themed glow */
}

.save-checkmark.visible {
    opacity: 1;
    transform: scale(1);
    animation: snap-pop 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

/* New snappy pop animation */
@keyframes snap-pop {
    0% { opacity: 0; transform: scale(0.5); }
    50% { opacity: 1; transform: scale(1.15); }
    80% { opacity: 1; transform: scale(0.98); }
    100% { opacity: 0; transform: scale(0.6); }
}