/* ================================================================
   page-detail-donut-chart.css
   The pie-chart "donut panel" used on detail pages that show a
   per-product breakdown chart inside the white card chrome:

     • Member state detail   "Key Import Products" tab
     • Commodity detail      "Producers" tab

   Changing the donut layout, header type, or legend style HERE
   updates both pages at once. The card chrome itself
   (background, border, radius-lg, soft shadow, overflow:hidden)
   stays shared with .cc-table-card / .table-section in table.css
   so all three tab-content surfaces read as the same white-card
   system; this file only carries the donut-specific layout +
   typography on top.

   What lives here
   ────────────────
     • .chart-section                  donut card (extras on top of
                                       .cc-table-card chrome — padding
                                       + lightblue info colour tokens)
     • .chart-section__heading         in-card section heading
     • .chart-stack                    per-chart column (header + donut)
     • .chart-header*                  product name + HS code above each donut
     • .chart-container-row /
       .chart-container /
       .chart-row                      donut grid + per-donut wrapper
     • .chart-wrapper                  positioned wrapper sized via clamp()
     • .chart-background               commodity photo behind the donut
     • .chart-canvas                   the Chart.js drawing surface
     • .chart-legend                   legend list under each donut
     • .legend-color-box               per-row swatch in the legend
   ================================================================ */


/* ================================================================
   1. PIE-CHART PANEL (card extras)
   ================================================================ */
.chart-section {
    padding: clamp(1.25rem, 2.2vw, 2rem);
    margin: 0;
    --info-bg: var(--ae-lightblue);
    --info-color: var(--white);
}

/* In-card section heading — sits inside the white chart-section
   card, above the donut grid. Section context lives outside the
   card via .cc-detail-heading; this is the in-card sub-heading
   that names what the donuts collectively show. */
.chart-section__heading {
    margin: 0 0 var(--space-lg);
    font-family: var(--font-heading);
    font-size: var(--fs-h4);
    font-weight: 700;
    color: var(--ae-darkblue);
    line-height: 1.25;
}


/* ================================================================
   2. PER-CHART COLUMN (header + donut stacked)
   .chart-stack wraps the per-chart header + the donut so the
   header centres over the donut itself, not over the donut+legend
   pair. The donut has a fixed clamp() width; the header inherits
   this column's natural width.
   ================================================================ */
.chart-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.chart-header {
    text-align: center;
    margin-bottom: 8px;
}
.chart-header__name {
    font-family: var(--font-body);
    font-size: var(--fs-md);
    font-weight: 600;
    color: var(--ae-black);
    line-height: 1.2;
}
.chart-header__hs {
    font-family: var(--font-body);
    font-size: var(--fs-xs);
    font-weight: 500;
    color: var(--color-muted);
    letter-spacing: 0.04em;
    margin-top: 2px;
}


/* ================================================================
   3. DONUT GRID + WRAPPER
   .chart-container-row wraps all donuts on the panel and lays
   them out in a flexing centred row. Each donut sits inside
   .chart-container (column) with the chart-row inside it carrying
   the donut + its legend side-by-side.
   ================================================================ */
.chart-container-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
    gap: clamp(1rem, 2vw, 2rem);
    margin: var(--space-md) auto;
    width: 100%;
}

.chart-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: fit-content;
    max-width: 100%;
    margin: 10px auto;
}

.chart-row {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    justify-content: center;
    flex-wrap: nowrap;
    gap: 10px;
    margin: 0 auto;
    width: 100%;
}

/* Pie diameter scales on ultrawide so the chart doesn't look like
   a postage stamp inside a 2400px-wide chart section. */
.chart-wrapper {
    position: relative;
    width: clamp(225px, 16vw, 360px);
    height: clamp(225px, 16vw, 360px);
}

/* Commodity photo behind the donut (acts as the centre fill). */
.chart-background {
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 1;
    z-index: 1;
    border-radius: 50%;
    object-fit: cover;
}

/* Chart.js canvas — painted on top of the photo. */
.chart-canvas {
    position: absolute;
    width: 100%;
    height: 100%;
    z-index: 2;
}


/* ================================================================
   4. LEGEND
   List of swatches + labels rendered to the right of each donut.
   Legend items are appended by JS (per chart instance).
   ================================================================ */
.chart-legend {
    list-style: none;
    margin: 0;
    padding: 0;
    text-align: left;
    align-self: flex-end;
}

.chart-legend li {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
    font-size: 12px;
}

.legend-color-box {
    width: 20px;
    height: 20px;
    margin-right: 5px;
}
