@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;
}

/* Desktop Background Styling */
@media (min-width: 769px) {
    [data-bg-desktop-hidden="false"] body {
        background-attachment: fixed;
        background-repeat: no-repeat;
        background-size: cover;
        background-position: center center;
    }
    /* If bg-desktop-hidden is true, hide it for >= 769px */
    [data-bg-desktop-hidden="true"] body {
        background: var(--background-color);
        background-attachment: scroll;
    }
}

/* Mobile Background Styling */
@media (max-width: 768px) {
    [data-bg-mobile-hidden="false"] body {
        background-attachment: fixed;
        background-repeat: no-repeat;
        background-size: cover;
        background-position: center center;
    }
    /* If bg-mobile-hidden is true, hide it for <= 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%;
  /* reduce top padding by 120px so the logo sits higher */
  padding: calc(2vh + 20px - 120px) 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: 300px; /* reduced desktop logo width */
  height: 80px;  /* proportionally reduced 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: 300px;  /* reduced desktop logo width */
  height: 80px;  /* reduced desktop logo height */
  opacity: 1;

  /* Default: theme color fill with original mask */
  background-color: var(--primary-color);
  -webkit-mask-image: url('6d (3).png');
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  -webkit-mask-size: contain;
  mask-image: url('6d (3).png');
  mask-repeat: no-repeat;
  mask-position: center;
  mask-size: contain;

  /* NEW: ensure shine is clipped to the logo shape on all viewports */
  overflow: hidden;
}

/* For all non-light (dark) themes, use the white 6d-300.png logo
   and tint it with the lighter active theme color */
[data-theme="dark"] .logo,
[data-theme="blue"] .logo,
[data-theme="green"] .logo,
[data-theme="purple"] .logo,
[data-theme="orange"] .logo,
[data-theme="red"] .logo,
[data-theme="teal"] .logo,
[data-theme="brown"] .logo,
[data-theme="gray"] .logo {
  background-color: var(--lighter-primary-color);
  -webkit-mask-image: url('6d-300.png');
  mask-image: url('6d-300.png');
}

/* NEW: Diagonal reflection/shine over logo shape for all viewports */
@keyframes logoDiagonalShine {
  0% {
    transform: translate(-150%, -150%) rotate(25deg);
    opacity: 0;
  }
  10% {
    opacity: 0.6;
  }
  90% {
    opacity: 0.6;
  }
  100% {
    transform: translate(150%, 150%) rotate(25deg);
    opacity: 0;
  }
}

/* NEW: Reverse diagonal reflection (right-to-left) */
@keyframes logoDiagonalShineReverse {
  0% {
    transform: translate(150%, 150%) rotate(25deg);
    opacity: 0;
  }
  10% {
    opacity: 0.6;
  }
  90% {
    opacity: 0.6;
  }
  100% {
    transform: translate(-150%, -150%) rotate(25deg);
    opacity: 0;
  }
}

/* Shared shine layer for desktop and mobile */
.logo::after {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  pointer-events: none;
  /* narrow diagonal gradient band for the shine */
  background: linear-gradient(
    120deg,
    rgba(255, 255, 255, 0) 40%,
    rgba(255, 255, 255, 0.75) 50%,
    rgba(255, 255, 255, 0) 60%
  );
  opacity: 0;
  transform: translate(-150%, -150%) rotate(25deg);
}

/* When active, run a single diagonal sweep across the logo at 50% speed (duration doubled) */
.logo.logo-reflect-active::after {
  animation: logoDiagonalShine 2.8s ease-out forwards;
}

/* NEW: Explicit mobile/right-direction shine class */
.logo.logo-reflect-right::after {
  animation: logoDiagonalShine 2.8s ease-out forwards;
}

/* NEW: Explicit mobile/left-direction shine class */
.logo.logo-reflect-left::after {
  animation: logoDiagonalShineReverse 2.8s ease-out forwards;
}

/* 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: enable outer glow around main page images when setting is ON */
:root[data-main-page-glow="true"] .media-item {
  overflow: visible;
}

:root[data-main-page-glow="true"] .media-item::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image: var(--media-thumb);
  background-size: cover;
  background-position: center;
  border-radius: inherit;
  filter: blur(var(--media-thumb-glow-blur)) saturate(1.4) brightness(1.15);
  opacity: 0.7;
  transform: scale(var(--media-thumb-glow-scale));
  transition: opacity 0.3s ease, filter 0.3s ease, transform 0.3s ease;
}

/* Slightly intensify glow on hover for desktop */
@media (min-width: 769px) {
  :root[data-main-page-glow="true"] .media-item:hover::before {
    opacity: 0.85;
    filter: blur(calc(var(--media-thumb-glow-blur) + 1px)) saturate(1.6) brightness(1.2);
    transform: scale(calc(var(--media-thumb-glow-scale) + 0.01));
    /* Add subtle horizontal depth pulse on hover */
    animation: sideGlowPulse 3s ease-in-out infinite;
  }
}

/* New: Desktop hover lift + shadow for main grid movie images */
@media (min-width: 769px) {
  .media-item:hover {
    transform: translateY(-6px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.45);
  }
}

/* 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-weight: bold;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* Top two digits: smaller */
.media-year-badge .media-year-top {
  font-size: 0.6rem; /* ~10 points smaller than the bottom line */
}

/* Bottom two digits (or "NA"): larger */
.media-year-badge .media-year-bot {
  font-size: 1.0rem; /* ~4 points larger than typical badge text */
}

/* New element definition for the top, centered category/search text */
.top-category-header {
  font-family: 'Cinzel Decorative', 'Abril Fatface', 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; 
}

/* Center entrance animation for movie/category titles */
@keyframes categoryCenterIn {
  0% {
    opacity: 0;
    transform: translateY(20px) scale(0.96);
  }
  60% {
    opacity: 1;
    transform: translateY(-4px) scale(1.04);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.top-category-header.category-animate-in,
.category-display.category-animate-in {
  animation: categoryCenterIn 0.65s ease-out;
}

/* Category Icon for the main header */
.category-header-icon {
    width: 40px;
    height: 40px;
    background-color: currentColor; /* Inherit text color (white or colored) */
    -webkit-mask-image: var(--cat-header-icon);
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-position: center;
    -webkit-mask-size: contain;
    mask-image: var(--cat-header-icon);
    mask-repeat: no-repeat;
    mask-position: center;
    mask-size: contain;
    display: inline-block;
    margin-right: 20px; /* Centered 20 pixels in front of title */
    flex-shrink: 0;
}

/* Idle carousel lines when no category/button titles are displayed */
.category-idle-carousel {
  /* Hollywood-style display font for front-page idle messages */
  font-family: 'Cinzel Decorative', 'Abril Fatface', 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: 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;
}

/* When a desktop background image is active, force category titles/idle text to white */
@media (min-width: 769px) {
  [data-bg-desktop-hidden="false"] .category-idle-carousel,
  [data-bg-desktop-hidden="false"] .category-display,
  [data-bg-desktop-hidden="false"] .top-category-header {
    color: #ffffff !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); }
}