/* --- SLIDESHOW BASE LAYOUT & OVERLAY (from slideshow.css) --- */

/* Full-screen slideshow overlay */
.slideshow-overlay {
  position: fixed; 
  inset: 0; 
  z-index: 30000;
  background: var(--primary-color); /* Theme primary color background */
  display: flex; 
  flex-direction: column;
  justify-content: flex-start; 
  align-items: center;
  overflow-y: auto; 
  padding: 4vh 4vw; 
}

/* NEW: Transparency toggle (outer background) */
:root[data-ss-transparency="true"] .slideshow-overlay {
  background-color: rgba(var(--primary-color-rgb), 0.2);
}

/* When off: opaque */
:root[data-ss-transparency="false"] .slideshow-overlay {
  background-color: var(--primary-color);
}

/* Header for close button and theme toggle */
.slideshow-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    padding: 2vh 2vw;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    pointer-events: none; 
    z-index: 30001;
}

/* Hide the close icon in the slideshow's upper-right corner */
.slideshow-close-button {
    display: none !important;
}

/* Theme Toggle (Replicating color ball look) */
.slideshow-theme-toggle { 
    position: absolute; 
    top: 2vh; 
    right: 2vw; 
    width: 56px; 
    height: 56px;
    border-radius: 50%; 
    background: var(--primary-color); 
    color: var(--text-color); 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    cursor: pointer; 
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    pointer-events: auto; 
}

.slideshow-theme-toggle:hover {
    box-shadow: 0 0 15px var(--lighter-primary-color);
    transform: scale(1.1);
}

[data-theme]:not([data-theme^="light"]) .slideshow-theme-toggle:hover {
    background: var(--background-color) !important;
    color: var(--text-color) !important;
}

[data-theme^="light"] .slideshow-theme-toggle:hover {
    background: var(--background-color) !important; /* Use background color on hover */
    color: var(--primary-color) !important;        /* Text color should be primary color for contrast */
}

/* Main Content Area */
.slideshow-description-container {
    width: 90%;
    max-width: 1200px;
    background-color: rgba(20, 20, 20, 0.7); /* Match modal background */
    backdrop-filter: blur(10px); /* Match modal blur */
    -webkit-backdrop-filter: blur(10px);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
    padding: 30px; 
    margin-top: 10px; 
    padding-bottom: 120px; 
    color: #fff !important; 
    flex-shrink: 0;
    position: relative;
}

/* NEW: Transparency toggle (inner background window) */
:root[data-ss-transparency="true"] .slideshow-description-container {
    background-color: rgba(20, 20, 20, 0.2);
}

/* When off: opaque */
:root[data-ss-transparency="false"] .slideshow-description-container {
    background-color: rgba(20, 20, 20, 1);
}

/* --- SLIDESHOW CONTROLS (from slideshow.css) --- */

.slideshow-controls-container {
    position: absolute;
    top: 100px; 
    right: -100px;
    z-index: 30001;
    display: flex;
    flex-direction: column;
    gap: 10px; 
    pointer-events: none;
}

.slideshow-control-button {
    width: 85px;
    height: 85px;
    border-radius: 50%;
    background: var(--hover-color); /* Change initial BG to hover color */
    color: var(--text-color);       /* Change initial text/icon color to text color */
    border: 1px solid var(--primary-color);
    
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    pointer-events: auto;
    transition: transform 0.2s, opacity 0.2s, background-color 0.2s;
    line-height: 1; 
    user-select: none;
    
    position: relative; 
    overflow: visible; 
    
    /* NEW: Add text shadow for cutout effect on text content (Play/Pause, R, S, Prev/Next) */
    text-shadow: 1px 1px 3px rgba(255, 255, 255, 0.4);
}

.slideshow-control-button svg {
    /* NEW: Add filter drop-shadow for cutout effect on SVG icon (Home) */
    filter: drop-shadow(1px 1px 3px rgba(255, 255, 255, 0.4));
}

/* NEW: Increase size of Home icon by 50% (20px -> 30px) */
#ssHomeButton svg {
    width: 30px;
    height: 30px;
}

.slideshow-control-button:hover {
    transform: scale(1.1);
    background: var(--background-color); /* Change hover BG to background color */
    color: var(--text-color);            /* Change hover text/icon color to text color */
}

/* Style for the pulsing circle when paused */
.slideshow-control-button.paused-pulse::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 85px; 
    height: 85px;
    border-radius: 50%;
    
    background: var(--primary-color); 
    
    animation: pulseExpand 3s ease-out infinite;
    z-index: 0; 
    pointer-events: none;
}

/* NEW: oval preview button styles (matches control sizing but oval and placed under vertical controls) */
.slideshow-control-button.preview-oval {
  width: 85px;
  height: 85px;
  border-radius: 50%;
  padding: 0;
  font-size: 2rem;
  background: var(--hover-color);
  color: var(--text-color);
  border: 2px solid var(--primary-color);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}

/* Ensure the preview image fills the round button cleanly */
.slideshow-control-button.preview-oval img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: contain;
  display: block;
}

.slideshow-control-button.speaker-round {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--hover-color); color: var(--text-color);
  border: 1px solid var(--primary-color);
  font-size: 1.4rem; line-height: 1; pointer-events: auto;
}

/* Ensure the listen button image fills the round speaker button cleanly */
.slideshow-control-button.speaker-round img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: contain;
  display: block;
}

/* place speaker just under preview button */
#ssSpeakerButton { margin-top: 6px; }

/* Small countdown bubble next to speaker */
.ss-audio-countdown {
  position: absolute;
  right: -100px; /* floats near controls on desktop */
  top: 100px;    /* aligns roughly with preview/speaker */
  background: rgba(0,0,0,0.85);
  color: #fff;
  border: 1px solid var(--primary-color);
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 0.95rem;
  display: none;
  align-items: center;
  gap: 6px;
  z-index: 30002;
}
.ss-audio-countdown .hourglass { display: inline-block; animation: hourPulse 1s infinite; }
@keyframes hourPulse { 0%{transform:scale(1)} 50%{transform:scale(1.15)} 100%{transform:scale(1)} }

/* NEW: Mobile audio popup overlay */
.ss-audio-popup {
  position: fixed;
  inset: 0;
  z-index: 30005;
  background: rgba(0,0,0,0.6);
  display: none;
  align-items: center;
  justify-content: center;
}
.ss-audio-popup .ss-audio-popup-inner {
  background: rgba(20,20,20,0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--primary-color);
  border-radius: 12px;
  padding: 20px 28px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.ss-audio-popup .popup-speaker {
  font-size: 2.2rem;
  line-height: 1;
}
.ss-audio-popup .popup-count {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--primary-color) !important;
}

/* Mobile adjustments */
@media (max-width: 768px) {
  /* Smaller speaker icon button on mobile */
  .slideshow-control-button.speaker-round {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }

  /* Use popup (hide bubble by default on mobile) */
  .ss-audio-countdown {
    display: none !important;
  }
}

/* Mobile position tweak */
@media (max-width: 768px) {
  .ss-audio-countdown { right: 10px; top: 60px; }
}

/* Specific styling for the timing display feedback */
.slideshow-duration-feedback {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 20px 40px;
    border-radius: 10px;
    font-family: 'Abril Fatface', cursive; 
    font-size: 3rem;
    font-weight: bold;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 40000;
}

/* --- SLIDESHOW INFO BAR (from slideshow.css) --- */

.slideshow-info-bar {
    position: fixed;
    top: 20px; 
    left: var(--slideshow-poster-center-x, 50%); 
    transform: translateX(-50%);
    z-index: 30001; 
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px; 
    max-width: 90%;
    flex-wrap: nowrap; /* Force single-line layout */
    pointer-events: none;
}

/* Explicit order to ensure: [thumb] [info box] [date box] */
.slideshow-info-bar #ssThumbWrapper { order: 1; }
.slideshow-info-bar #ssSearchSummary { order: 2; }
.slideshow-info-bar #ssRelease { order: 3; }

/* Match date box size to thumbnail (desktop default 90x90) */
.slideshow-info-bar .ss-release {
    width: 90px;
    height: 90px;
    min-width: 90px;  /* lock size */
    min-height: 90px; /* lock size */
    padding: 2px;     /* match visual density of the thumb */
    box-sizing: border-box;
}

/* Thumbnail wrapper (already 90x90) - kept for clarity */
.slideshow-info-bar .ss-thumb-wrapper {
  width: 90px;
  height: 90px;
  border-radius: 8px;
  border: 1px solid var(--primary-color); 
  display: none; 
  position: relative;
  z-index: 30002; 
  overflow: hidden; 
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  flex-shrink: 0; 
  
  padding: 5px; 
  background-color: rgba(255, 255, 255, 0.1); 
}

.slideshow-info-bar .ss-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top; 
  
  border: none;
  border-radius: 5px;
  display: block;
}

.slideshow-info-bar .ss-search-summary .result-count {
    font-size: calc(2.15em + 5.33px);
    font-weight: bold;
    opacity: 1; 
}

/* Enforce white color for all search summary text regardless of theme */
.slideshow-info-bar .ss-search-summary, 
.slideshow-info-bar .ss-search-summary *,
.slideshow-info-bar .ss-search-summary .ss-search-prefix,
.slideshow-info-bar .ss-search-summary .ss-search-term {
    color: #ffffff !important;
}

.ss-search-summary{
  position: static;
  top: auto;
  right: auto;
  font-size: 1.2rem;
  font-weight: 700;
  z-index: 2;
  padding: 8px 10px;
  border-radius: 12px;
  color: var(--text-color) !important;
  display: flex;
  flex-direction: row;      /* place children on same row */
  align-items: center;     /* vertically center the count and badge */
  justify-content: center; /* horizontally center content within container */
  white-space: nowrap;
  gap: 10px;               /* space between count and badge */
  transition: opacity 0.5s ease;
  opacity: 0;
  min-width: 300px;
}

.ss-search-summary::before{
  content:""; position:absolute; inset:0; background:var(--primary-color); opacity:.5; backdrop-filter:blur(10px); -webkit-backdrop-filter:blur(10px); border-radius:inherit; z-index:-1;
}

.ss-search-prefix{ 
    opacity:.9; 
    font-size: 0.8em; 
}

.ss-search-term{ 
    font-size: 1em; 
    line-height:1.1; 
    margin-bottom: 2px; 
}

/* Style for the dynamically inserted character/role name */
.ss-subject-role {
    color: var(--primary-color) !important; 
    font-size: 1.05rem; 
    font-weight: 500;
    text-align: center;
    white-space: nowrap;
    opacity: 0.9;
    margin-top: -4px; 
}

.ss-release {
  position: static; 
  top: auto;
  right: auto;
  font-size: 1.2rem; 
  font-weight: 700;
  z-index: 2;
  display: flex; /* ensure visible and flex layout */
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px;
  border-radius: 12px;
  color: var(--text-color) !important;
  transition: opacity 0.5s ease; 
  opacity: 1; 
  
}

/* Responsive adjustments for controls and header elements (from slideshow.css) */
@media (max-width: 768px) {
    .slideshow-description-container {
        width: 100%;
        margin-top: 70px; /* was 50px */
        padding: 15px;
        padding-bottom: 0; /* Reduce bottom padding so window ends closer to cast slider */
    }
    
    /* NEW: Enforce white icon color for pause/play button on mobile */
    .slideshow-control-button#ssPauseButton {
        color: #ffffff !important;
    }
    
    .slideshow-info-bar {
        gap: 10px;
        top: 15px;
        flex-wrap: nowrap; /* Keep single-line on mobile per requirement */
    }
    
    .slideshow-info-bar .ss-thumb-wrapper {
        width: 70px; 
        height: 70px;
        padding: 5px;
    }
    
    /* Match date box to mobile thumb size (70x70) */
    .slideshow-info-bar .ss-release {
        width: 70px;
        height: 70px;
        min-width: 70px;
        min-height: 70px;
        padding: 5px;
    }
    
    .ss-search-summary,
    .ss-release {
        font-size: 1rem; 
        padding: 6px 8px;
    }
    
    .slideshow-info-bar .ss-search-summary .result-count {
        font-size: 1.875em; 
    }
    
    .slideshow-theme-toggle {
        width: 30px;
        height: 30px;
    }
    .slideshow-controls-container {
        top: 20px; 
        right: 15px;
        gap: 10px;
    }
    .slideshow-control-button {
        width: 42px; 
        height: 42px;
        font-size: 1rem;
    }
    
    /* Ensure oval button matches standard control button size on mobile */
    .slideshow-control-button.preview-oval {
        width: 42px; 
        height: 42px;
        font-size: 1rem;
    }
    
    .ss-search-summary {
        gap: 1px; 
    }
    
    .ss-subject-role {
        font-size: 0.9rem; 
        margin-top: -2px;
    }
    
    .ss-release .release-month { font-size: calc(1.35rem - 6px - 4pt); }
    .ss-release .release-year { font-size: calc(1.55rem + 4px - 4pt); }
}

/* Desktop: Increase movie count number size by approx 6 points (~8px) */
@media (min-width: 769px) {
    .slideshow-info-bar .ss-search-prefix .result-count {
        /* This rule exists in base and is repeated here for desktop specificity */
        font-size: 2.15em; 
    }
}

@media (min-width: 769px) {
  :root[data-bg-desktop-hidden="false"] .slideshow-overlay {
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
  }
}

.slideshow-close-button {
    font-size: 2rem;
    right: calc(2vw + 36px + 5px); 
}

/* Add styles and animation for the remaining credits badge */
.ss-search-prefix .credits-remaining-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--primary-color);
  color: #ffffff !important;
  /* Increased font-size by additional 8 points */
  font-size: calc(1.2em + 8px + 20pt);
  border: none;
  font-weight: 800;
  margin-left: 8px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
  line-height: 1;
  vertical-align: middle;
}

/* Subtle bump animation on change */
@keyframes countBump {
  0% { transform: scale(1); opacity: 0.95; }
  40% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.credits-remaining-badge.count-bump {
  animation: countBump 300ms ease-in-out;
}