/* ============================================================
   Generic Responsive Data-Table System
   ------------------------------------------------------------
   Reusable by ANY page that uses .data-table.responsive tables
   (big-table2 / big-table / graph / graph-2 / benchmark shapes).

   Mobile column labels are read live from each cell's own
   data-label="..." attribute rather than hard-coded here, so
   this file never needs editing when a page's table content,
   years, or column labels change \u2014 only the HTML does.

   This file assumes the site's global stylesheet already
   provides the base "collapse table to stacked rows on mobile"
   behaviour (display:block on tr/td, thead hidden, etc.) for
   .responsive tables. Only the parts that were previously
   page-specific inline CSS are included here.

   Structural note: every @media override in this file is placed
   at the END, after the base (non-media) rules they override.
   CSS resolves ties between rules of equal specificity by
   document order, not by whether a media condition is active \u2014
   a later unconditional rule beats an earlier media-scoped one
   even when that media query matches. Keeping all overrides last
   is what makes them actually win when their condition is true.
   ============================================================ */

.toggle_container_basic {
    padding: 0;
}

table.responsive {
    font-size: 14px;
}


/* ============================================================
   Generic Chart Component
   ------------------------------------------------------------
   Pairs with data-charts.js. Renders above a .data-table.responsive
   table referenced via data-chart-table="<table id>". Reusable by
   any future page \u2014 nothing below is specific to this page's
   content, years, or categories. Series colours are assigned from a
   fixed palette in data-charts.js, not set here or read from the
   page's own CSS.
   ============================================================ */

.chart-widget {
    margin: 12px 0 4px;
    padding-bottom: 2.4rem;
}

/* No font-size/font-weight here on purpose: the element itself is a real
   <h4> now (see addTitle in data-charts.js), so it inherits the site's own
   h4 styling directly \u2014 this class only adds the spacing a chart needs
   that a plain h4 wouldn't already have. */
.chart-title {
    margin: 0 0 8px;
}

.chart-plot {
    position: relative;
}

.chart-svg {
    display: block;
    width: 100%;
    height: auto;
}

.chart-gridline {
    stroke: #e3e3e3;
    stroke-width: 1;
}

/* Axis labels are plain HTML, not SVG text \u2014 deliberately. An SVG's
   internal viewBox coordinate system stretches to fill its container,
   and anything sized inside it (including SVG text font-size) stretches
   with it. HTML text has no such scaling, so this is what keeps axis
   labels at their true, correct size regardless of chart width. */
.chart-axis-label {
    position: absolute;
    font-size: 1.6rem; /* matches .section_wrapper p */
    line-height: 1;
    color: #6b6b6b;
    white-space: nowrap;
    pointer-events: none;
}

/* Left-gutter width here (9%) must match MARGIN.left in data-charts.js */
.chart-axis-label-y {
    left: 0;
    width: 9%;
    text-align: right;
    padding-right: 8px;
    transform: translateY(-50%);
}

/* top:80% matches (1 - MARGIN.bottom) in data-charts.js (currently 0.20) \u2014
   i.e. the plot's bottom edge / 0-baseline. The small padding-top is the
   actual visual gap between the bars and the label; the rest of the
   reserved bottom margin stays free for the mobile rotation rule below. */
.chart-axis-label-x {
    top: 80%;
    padding-top: 6px;
    transform: translateX(-50%); /* middle labels; first/last set below */
}

.chart-axis-label-x.chart-axis-label-first {
    transform: translateX(0);
}

.chart-axis-label-x.chart-axis-label-last {
    transform: translateX(-100%);
}

.chart-series-line {
    fill: none;
    stroke-width: 2.25;
}

.chart-series-dot {
    stroke: #fff;
    stroke-width: 1.5;
}

.chart-series-dot:hover {
    r: 5.5;
    cursor: pointer;
}

/* Grouped bar chart (vertical columns) */
.chart-bar {
    transition: opacity 0.1s;
}

.chart-bar:hover {
    opacity: 0.85;
    cursor: pointer;
}

/* Value + % label above each bar. Hidden on mobile (see the media query
   below) rather than shrunk further \u2014 with several bars per category
   cluster, a legible label doesn't fit a narrow mobile column without
   colliding with its neighbours; the real numbers are always in the table
   underneath and in the on-hover tooltip regardless. */
.chart-bar-label {
    position: absolute;
    transform: translate(-50%, calc(-100% - 4px));
    text-align: center;
    white-space: nowrap;
    pointer-events: none;
    line-height: 1.2;
}

.chart-bar-label-value {
    display: block;
    font-size: 1.3rem;
    font-weight: 700;
    color: #333;
}

.chart-bar-label-pct {
    display: block;
    font-size: 1.1rem;
    color: #6b6b6b;
}

/* Round charts (donut / ring) sit in a square box centred in the widget,
   rather than stretching full-width like the line/bar plot area \u2014 a
   full-bleed circle on a wide page would be awkwardly huge. */
.chart-plot-round {
    max-width: 320px;
    margin: 0 auto;
}

.chart-donut-segment {
    transition: opacity 0.1s;
}

.chart-donut-segment:hover {
    opacity: 0.85;
    cursor: pointer;
}

.chart-pie-slice {
    stroke: #fff;
    stroke-width: 1;
    transition: opacity 0.1s;
}

.chart-pie-slice:hover {
    opacity: 0.85;
    cursor: pointer;
}

.chart-pie-label {
    position: absolute;
    transform: translate(-50%, -50%);
    font-size: 1.6rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
    pointer-events: none;
    white-space: nowrap;
}

/* Year/column label centred inside each ring of a nested ring chart.
   White + shadow for contrast against whatever colour the ring segment
   underneath happens to be \u2014 same treatment as .chart-pie-label. */
.chart-ring-label {
    position: absolute;
    transform: translate(-50%, -50%);
    font-size: 1.6rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
    pointer-events: none;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    justify-content: center;
    margin-top: 12px;
    font-size: 1.6rem;
    color: #6b6b6b;
}

.chart-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.chart-legend-swatch {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    flex: none;
}

/* Segmented bar (e.g. a single-row proportional overview, in place of a
   treemap) \u2014 pure HTML/CSS, no SVG needed for this shape at all. */
.chart-segbar {
    display: flex;
    width: 100%;
    height: 40px;
    border-radius: 4px;
    overflow: hidden;
}

.chart-segbar-segment {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.4rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
}

/* Horizontal grouped bar chart \u2014 pure HTML/CSS, no SVG. Used instead of
   the vertical grouped bar chart whenever category names are too long to
   fit in a narrow per-category column at any screen width (e.g. "Heterosexual
   or straight"). Horizontal orientation puts the label in the left margin,
   where it has as much width as it needs, rather than squeezed under a
   1/Nth-width vertical bar. Labels are allowed to wrap to two lines as a
   safety net at very narrow widths \u2014 never truncated, never shrunk. */
.chart-hbar-row {
    display: flex;
    align-items: center;
    min-height: 34px;
    margin: 6px 0;
}

.chart-hbar-label {
    flex: 0 0 38%;
    max-width: 38%;
    padding-right: 10px;
    text-align: right;
    font-size: 1.4rem;
    color: #333;
    white-space: normal;
    line-height: 1.25;
}

.chart-hbar-bars {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
}

.chart-hbar-bar {
    position: relative;
    height: 9px;
    border-radius: 2px;
    min-width: 2px;
    transition: opacity 0.1s;
}

.chart-hbar-bar:hover {
    opacity: 0.85;
    cursor: pointer;
}

/* Value label sitting just past the end of its own bar, vertically
   centred on it \u2014 anchored to the bar itself (not the row), so it always
   sits at the right place regardless of that bar's own length. */
.chart-hbar-bar-value {
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 5px;
    white-space: nowrap;
    font-size: 1.1rem;
    font-weight: 700;
    color: #333;
    pointer-events: none;
}

.chart-hbar-axis {
    display: flex;
    margin: 8px 0 0 38%;
    font-size: 1.3rem;
    color: #6b6b6b;
}

.chart-hbar-axis span {
    flex: 1;
    text-align: center;
}

.chart-hbar-axis span:first-child {
    text-align: left;
}

.chart-hbar-axis span:last-child {
    text-align: right;
}


/* ============================================================
   Mobile overrides (max-width: 760px, or tablet device range).
   Placed last in the file so they win the cascade \u2014 see the note
   at the top of this file.
   ============================================================ */
@media only screen and (max-width: 760px), (min-device-width: 768px) and (max-device-width: 1024px) {

    table.mobile td,
    table.responsive td {
        padding-left: 60% !important;
    }

    /* The entire mobile-label system, for every table on every page: */
    table.responsive td:before {
        content: attr(data-label);
    }

    /* The site's own base.css sets white-space:nowrap on this label with a
       fixed width:45% (see table.responsive td:before there) \u2014 fine for
       short labels ("2024", "Full time"), but a genuinely long one (e.g.
       "A long standing illness or health condition") can't wrap and
       overflows straight past that width into the value column. Allowing
       it to wrap is strictly safer everywhere: short labels that already
       fit on one line are completely unaffected, long ones wrap instead
       of overflowing.
       This alone isn't quite enough though: the label is position:absolute
       (per that same site rule), so it doesn't push its own <td> taller to
       fit a now-multi-line label \u2014 without the row itself gaining height,
       a wrapped label still visually spills into the row below it instead
       of sideways into the value. See .disability-classification below,
       which is the first table with labels long enough to need that room. */
    table.responsive td:before {
        white-space: normal;
    }

    /* Comfortable room for this table's category-name labels (up to ~45
       characters) to wrap to two or three lines without spilling into the
       next row. Scoped to this table specifically, rather than applied to
       every .responsive table, since most existing tables have short
       labels that don't need the extra height and would just look
       needlessly spaced out. */
    .disability-classification td {
        min-height: 56px;
    }

    table.responsive {
        font-size: 12px;
    }

    .chart-widget {
        padding-bottom: 1.6rem;
    }

    /* Rotate x-axis category labels on narrow screens so several (or long)
       category names don't overlap each other \u2014 the bottom plot margin
       (MARGIN.bottom in data-charts.js) is sized generously enough at
       every width to fit this without the JS needing to know the
       viewport size.

       Position is reset to the original bottom-anchored spacing here,
       deliberately DIFFERENT from the tighter desktop rule above: rotating
       a label swings part of it upward around its own anchor point, so an
       anchor placed close to the bars (correct for horizontal desktop
       text) sends rotated mobile text straight into the bars above it.
       This restores the wider gap the rotated case actually needs. */
    .chart-axis-label-x {
        top: auto;
        bottom: 0;
        padding-top: 0;
        font-size: 1.3rem;
        transform: translateX(-50%) rotate(-40deg);
        transform-origin: top center;
    }

    .chart-axis-label-x.chart-axis-label-first {
        transform: translateX(0) rotate(-40deg);
        transform-origin: top left;
    }

    .chart-axis-label-x.chart-axis-label-last {
        transform: translateX(-100%) rotate(-40deg);
        transform-origin: top right;
    }

    .chart-bar-label {
        display: none;
    }

    .chart-hbar-label {
        flex-basis: 34%;
        max-width: 34%;
        font-size: 1.2rem;
    }

    .chart-hbar-axis {
        margin-left: 34%;
        font-size: 1.1rem;
    }
}
