/* ============================================================================
   06-COMPONENTS -> #COLUMN-CHART
   ========================================================================= */

/**
 * 
 */


//
// SCSS imports
//

@use '../01-settings' as *;
@use '../02-tools' as *;


/**
 * Chart
 */

.chart {
    --chart-bar-bg: var(--form-option-active-bg);
    --chart-bar-border-radius: var(--rounded-md);
    --chart-heading-label-size: 1.5rem;
    --chart-label-color: color: var(--text-color-tertiary);
    --chart-label-size: #{$font-size-sm};
    --chart-axis-color: var(--border-color-secondary);
    --chart-primary-axis-style: solid;
    --chart-axis-width: var(--border-width);
    --chart-secondary-axes-color: var(--border-color-secondary);
    --chart-secondary-axes-style: solid;
    --chart-secondary-axes-width: var(--border-width);

    background-color: transparent;
    border-collapse: collapse;
    border-spacing: 0;
    empty-cells: show;
    height: 24rem;
    margin: 0 auto;
    overflow: initial;
    position: relative;
    width: 100%;
}


/**
 * Chart axis label
 */

.chart__axis-label {
    @include font-size('sm');
    color: var(--chart-label-color);
    position: absolute;

    &[data-axis=x] {
        bottom: 0;
        left: calc(50% + var(--chart-heading-label-size));
        transform: translateX(-50%);
    }
    
    &[data-axis=y] {
        left: calc((var(--chart-heading-label-size) * -1));
        top: calc(50% - var(--chart-heading-label-size));
        transform: rotate(-90deg) translateY(-50%);
    }
}


/**
 * Chart body
 */

.chart__body {
    align-items: stretch;
    display: flex;
    flex-direction: row;
    height: calc(100% - var(--chart-heading-label-size));
    justify-content: space-between;
    width: 100%;
}


/**
 * Chart point
 */

.chart__point {
    align-items: flex-end;
    border-bottom: var(--chart-axis-width) solid var(--chart-axis-color);
    display: flex;
    flex-basis: 0;
    flex-direction: row;
    flex-grow: 1;
    flex-shrink: 1;
    justify-content: flex-start;
    margin-bottom: calc(var(--chart-label-size) * 3);
    overflow-wrap: anywhere;
    padding-left: var(--space-2);
    padding-right: var(--space-2);
    position: relative;
    background-size: 100% 25%; // []
    background-image: linear-gradient(var(--chart-secondary-axes-color) var(--chart-secondary-axes-width), transparent var(--chart-secondary-axes-width));

    @include media-breakpoint-up('lg') {
        padding-left: var(--space-4);
        padding-right: var(--space-4);
    }
}


/**
 * Chart point data
 */

.chart__point-data {
    align-items: flex-start;
    background-color: var(--chart-bar-bg);
    border-top-left-radius: var(--chart-bar-border-radius);
    border-top-right-radius: var(--chart-bar-border-radius);
    display: flex;
    justify-content: center;
    width: 100%;
    height: calc(100% * var(--size, 1));
    position: relative;
    flex-grow: 1;
    flex-shrink: 1;
    flex-basis: 0;
}


/**
 * Column point label
 */

.chart__point-label {
    align-items: center;
    bottom: calc(var(--chart-label-size) * -3 - var(--chart-axis-width));
    color: var(--chart-label-color);
    display: flex;
    flex-direction: column;
    font-size: var(--chart-label-size);
    font-weight: var(--font-weight-light);
    height: var(--chart-label-size);
    justify-content: center;
    left: 0;
    position: absolute;
    right: 0;
}




/* MODIFIERS
   ========================================================================= */

/**
 * Modifier: X axis label
 */

.chart[data-label-y=true] {
    .chart__body {
        padding-bottom: var(--chart-heading-label-size);
    }
}


/**
 * Modifier: Y axis label
 */

.chart[data-label-x=true] {
    .chart__body {
        padding-left: var(--chart-heading-label-size);
    }
}