/* Historical Bubble Charts - Styles
 * Prefix: hbs- (Historical Bubble Scenarios)
 * Follows FMG Calculator UI/UX Standards
 */

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --hbs-radius-sm: 4px;
    --hbs-radius-md: 6px;
    --hbs-radius-lg: 8px;
    --hbs-shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --hbs-shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --hbs-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    
    /* Chart colors matching the FT-style reference */
    --hbs-line-color: #2c5282;           /* Historical bubble (blue) */
    --hbs-line-color-rgb: 44, 82, 130;
    --hbs-nasdaq-color: #c23d28;          /* Nasdaq 100 current (red) */
    --hbs-nasdaq-color-rgb: 194, 61, 40;
    
    /* Background colors */
    --hbs-bg-cream: #f5f0e8;
    --hbs-bg-card: #ffffff;
    --hbs-border-color: #e8e4dc;
    --hbs-text-primary: #1a1a1a;
    --hbs-text-secondary: #6b7280;
}

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.page-rc-nasdaq-100-vs-historical-series{
    background-color: #f5f0e8;
}

/* CMS Content Width Override - Forces 1170px container */
.c-matter--article .c-matter__body {
    max-width: 1170px;
    width: 1170px;
}

@media (max-width: 950px) {
    .c-matter--article .c-matter__body {
        width: 100%;
        max-width: 750px;
        padding: 0;
    }
}

@media (max-width: 750px) {
    .c-matter--article .c-matter__body {
        width: 100%;
        max-width: 100%;
        margin: 0;
        padding: 0.5rem;
        border-radius: 8px;
    }
}

/* Main Container */
.hbs-body {
    background: transparent;
    min-height: 100%;
}

.hbs-container {
    width: 1170px;
    max-width: 1170px;
    margin: 0 auto;
    padding: 2rem;
    background: transparent;
    box-sizing: border-box;
}

/* Header Section */
.hbs-header {
    text-align: center;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--hbs-border-color);
}

.hbs-title {
    margin: 0 0 0.75rem 0;
    line-height: 1.2;
}

.hbs-title--nasdaq {
    color: var(--hbs-nasdaq-color);
}

.hbs-title--historical {
    color: var(--hbs-line-color);
}

.hbs-subtitle {
    margin: 0;
    opacity: 0.7;
}

/* Introduction Text */
.hbs-intro {
    max-width: 800px;
    margin: 0 auto 2rem auto;
    text-align: center;
    opacity: 0.85;
    line-height: 1.6;
}

/* Chart Grid - 2x3 Layout */
.hbs-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* Individual Chart Card */
.hbs-card {
    background: var(--hbs-bg-card);
    border: 1px solid var(--hbs-border-color);
    border-radius: var(--hbs-radius-lg);
    padding: 1.25rem;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.hbs-card:hover {
    box-shadow: var(--hbs-shadow-md);
    transform: translateY(-2px);
}

/* Card Header */
.hbs-card-header {
    margin-bottom: 0.75rem;
}

.hbs-card-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 0.25rem 0;
    color: var(--hbs-text-primary);
    line-height: 1.3;
}

.hbs-card-subtitle {
    font-size: 0.8125rem;
    font-style: italic;
    margin: 0;
    color: var(--hbs-text-secondary);
    opacity: 0.8;
}

/* Chart Container */
.hbs-chart-wrapper {
    position: relative;
    width: 100%;
    height: 180px;
    margin-top: 0.5rem;
}

.hbs-chart {
    width: 100%;
    height: 100%;
}

/* Axis Labels */
.hbs-axis-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--hbs-text-secondary);
    opacity: 0.7;
}

/* Simple Legend */
.hbs-legend-simple {
    text-align: center;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--hbs-bg-card);
    border: 1px solid var(--hbs-border-color);
    border-radius: var(--hbs-radius-md);
    font-size: 0.9rem;
}

/* Footnote / Sources */
.hbs-footnote {
    text-align: center;
    font-size: 0.8125rem;
    color: var(--hbs-text-secondary);
    opacity: 0.7;
    padding-top: 1.5rem;
    border-top: 1px solid var(--hbs-border-color);
    line-height: 1.6;
}

/* Loading State */
.hbs-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 180px;
    color: var(--hbs-text-secondary);
}

.hbs-loading-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--hbs-border-color);
    border-top-color: var(--hbs-line-color);
    border-radius: 50%;
    animation: hbs-spin 0.8s linear infinite;
}

@keyframes hbs-spin {
    to { transform: rotate(360deg); }
}

/* =====================
   Responsive Breakpoints
   ===================== */

/* Tablet */
@media (max-width: 950px) {
    .hbs-container {
        width: 100%;
        max-width: 750px;
        padding: 1.5rem;
    }
    
    .hbs-grid {
        gap: 1.25rem;
    }
    
    .hbs-chart-wrapper {
        height: 160px;
    }
}

/* Mobile - Switch to single column */
@media (max-width: 750px) {
    .hbs-container {
        max-width: 100%;
        padding: 1rem;
    }
    
    .hbs-header {
        margin-bottom: 1.5rem;
        padding-bottom: 1rem;
    }
    
    .hbs-title {
        font-size: 1.5rem;
    }
    
    .hbs-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .hbs-card {
        padding: 1rem;
    }
    
    .hbs-chart-wrapper {
        height: 200px;
    }
    
    .hbs-legend-simple {
        padding: 0.75rem;
        font-size: 0.85rem;
    }
    
    .hbs-footnote {
        font-size: 0.75rem;
        padding-top: 1rem;
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    .hbs-container {
        padding: 0.75rem;
    }
    
    .hbs-card {
        padding: 0.875rem;
    }
    
    .hbs-card-title {
        font-size: 0.9375rem;
    }
    
    .hbs-chart-wrapper {
        height: 180px;
    }
}

/* =====================
   Print Styles
   ===================== */
@media print {
    * {
        -webkit-print-color-adjust: exact !important;
        color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    .hbs-body {
        background: white !important;
    }
    
    .hbs-container {
        max-width: 100% !important;
        width: 100% !important;
        padding: 0 !important;
    }
    
    .hbs-card {
        break-inside: avoid;
        page-break-inside: avoid;
        box-shadow: none !important;
        border: 1pt solid #ddd !important;
    }
    
    .hbs-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12pt;
    }
    
    @page {
        margin: 0.5in;
        size: letter landscape;
    }
}

/* =====================
   Chart.js Overrides
   ===================== */

/* Ensure canvas doesn't overflow */
.hbs-chart-wrapper canvas {
    max-width: 100%;
}

/* Custom tooltip styling (applied via JS) */
.hbs-tooltip {
    background: rgba(255, 255, 255, 0.95) !important;
    border: 1px solid var(--hbs-border-color) !important;
    border-radius: var(--hbs-radius-md) !important;
    box-shadow: var(--hbs-shadow-md) !important;
    padding: 8px 12px !important;
    font-size: 0.8125rem !important;
}

/* Accessibility - Focus States */
.hbs-card:focus-within {
    outline: 2px solid var(--hbs-line-color);
    outline-offset: 2px;
}

/* Screen reader only class */
.hbs-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
