/* Styles for the D3.js Streamgraph */

#streamgraphContainer {
    position: relative;
    width: 100%;
    height: 100%;
    /* Default height for desktop */
    height: 350px;
}

.streamgraph-tooltip {
    position: absolute;
    text-align: center;
    padding: 6px 10px;
    font-size: 12px;
    background: #1f2937; /* slate-800 */
    color: #f8fafc; /* slate-50 */
    border: 0px;
    border-radius: 6px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    z-index: 9999; /* Ensure tooltip is on top */
}

.streamgraph-legend-item {
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: opacity 0.2s;
    font-size: 0.8rem;
    color: #334155; /* slate-700 */
    text-align: left;
}

.streamgraph-legend-item span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;      /* This prevents the text from wrapping */
}


/* This class is toggled by JS to create the fade effect */
.streamgraph-legend-item.faded {
    opacity: 0.3;
}

.streamgraph-legend-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    margin-right: 6px;
    flex-shrink: 0; /* Prevents the color box from shrinking */
}

#streamgraphContainer .axis path,
#streamgraphContainer .axis line {
    stroke: #e2e8f0; /* slate-200 */
}

#streamgraphContainer .axis text {
    fill: #64748b; /* slate-500 */
    font-size: 11px;
}

/* Fix for Narrative Intelligence filter overlap on mobile */
@media (max-width: 499px) {
    .filters-container {
        flex-direction: column; /* Stack filter groups vertically */
        align-items: center;    /* Center them horizontally */
        gap: 1rem;              /* Reduce the gap between them */
    }

    .segmented-control {
        width: 100%;            /* Allow each group to take full width */
        justify-content: center; /* Center the buttons within each group */
    }
}

/* Refinement for filter buttons on very narrow screens */
@media (max-width: 390px) {
    .segmented-control-btn {
        padding: 0.375rem 0.5rem; /* Reduces horizontal padding */
        font-size: 0.8rem;      /* Makes the font slightly smaller */
    }
    .segmented-control-label {
        font-size: 0.8rem;      /* Matches the button font size */
        margin-left: 0.5rem;    /* Reduces the space before the buttons */
    }
}

/* --- Mobile Device Adjustments --- */
@media (max-width: 768px) {
  
  /* Taller height for mobile devices to use vertical space */
  #streamgraphContainer {
      height: 500px;
  }
  
  /* Wrapper for the legend to apply the fade effect */
  #streamgraphLegendWrapper {
    position: relative; 
  }

  /* Horizontal Scrolling for Legend on Mobile */
  #streamgraphLegend {
    flex-wrap: nowrap;          
    overflow-x: auto;          
    justify-content: flex-start;
    -webkit-overflow-scrolling: touch; 
    padding-bottom: 8px;   
    padding-right: 20px; /* Ensures last item can scroll past the fade */
  }

  /* Visual Cue for Horizontal Scrolling */
  #streamgraphLegendWrapper::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 8px; 
    width: 50px; 
    background: linear-gradient(to right, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1) 80%);
    pointer-events: none; 
  }
  
  /* Hides the scrollbar for a cleaner look */
  #streamgraphLegend::-webkit-scrollbar {
    display: none; 
  }

  #streamgraphLegend {
    -ms-overflow-style: none;  
    scrollbar-width: none;     
  }
}

@media (max-width: 768px) and (orientation: landscape) {
  #streamgraphContainer {
      height: 280px;
  }
}