/* ================================================================
   page-country.css  –  Compliance Checker
   Styles specific to /country (EU member state page).
   Extends page-country-shared.css with the orange import summary,
   dual-bar commodity rows, risk highlighting, pie-chart section,
   table section, download button and modal.
   ================================================================ */


/* === PAGE HEADER ================================================
   Header banner styles are fully shared with /country-export and
   live in page-country-shared.css. No page-specific overrides. */


/* === LAYOUT =====================================================
   Per-page token + grid overrides on top of the shared base. */

.commodity-row {
    grid-template-columns: 7% 22% 1fr;
}

.shipment-filter-icon {
    width: 40px;
    height: 40px;
}

.data-freshness-card {
    margin: var(--space-2xl) auto;
}

/* Orange-framed import summary. --summary-color + --info-bg scope
   the title colour and tooltips to orange inside this panel. */
.import-summary {
    background-color: var(--white);
    border: 4px solid var(--ae-orange);
    border-radius: var(--radius-dropdown);
    box-shadow: var(--shadow);
    padding: var(--space-xl);
    margin: var(--space-2xl) auto;
    max-width: var(--page-max);
    --summary-color: var(--ae-orange);
    --info-bg: var(--ae-orange);
    --info-color: var(--white);
}


/* === COMPONENTS =================================================
   Dual-bar commodity summary (country-page shows two bars per row:
   country share + EU share) and deforestation-risk cell highlight. */

.bar-row {
    display: flex;
    flex-direction: column;
    position: relative;
    gap: 4px;
}

.bar-wrapper {
    position: relative;
    height: 20px;
    display: flex;
    align-items: center;
}

.bar {
    height: 25%;
    border-radius: var(--radius-sm);
}

.bar-primary { background-color: var(--ae-orange); }
.bar-eu      { background-color: var(--ae-darkblue); opacity: 0.7; }

/* Country-page label colours — scoped to the percentage span so the
   shared .bar-label__suffix stays muted grey regardless. */
.primary-label .commodity-percentage { color: var(--ae-orange); }
.eu-label      .commodity-percentage { color: var(--ae-darkblue); }

/* Country-page variant: the bar track is a vertical stack of two
   bar-wrappers (primary + EU), each in its own .bar-wrapper. */
.commodity-bar-track {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
    height: auto;
}

/* Risk highlighting (applied by JS to deforestation-risk cells) */
.risk-highlight {
    border-radius: var(--radius-dropdown);
    box-shadow: inset 0 0 0 2px var(--ae-orange);
    background-color: color-mix(in srgb, var(--ae-orange) 12%, transparent);
}

.highlight.risk-highlight {
    background-color: var(--ae-orange) !important;
    box-shadow: inset 0 0 0 2px var(--ae-orange);
}


/* === CHART + TABLE SECTION CONTAINERS ==========================
   Each section gets a coloured frame, title, and a local --info-bg
   so tooltips inside pick up the section's accent. */

.chart-section {
    background-color: var(--ae-white);
    border: 4px solid var(--ae-lightblue);
    border-radius: var(--radius-lg);
    padding: clamp(1.5rem, 2.5vw, 2.5rem);
    margin: var(--space-2xl) auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    max-width: var(--page-max);
    --info-bg: var(--ae-lightblue);
    --info-color: var(--white);
}

.chart-section-title {
    text-align: left;
    font-size: var(--fs-h3);
    font-weight: 600;
    color: var(--ae-lightblue);
    margin-bottom: clamp(1.5rem, 2.5vw, 2.5rem);
    border-bottom: 2px dashed var(--ae-lightblue);
    padding-bottom: 10px;
}

.table-section {
    background-color: var(--ae-white);
    border: 4px solid var(--ae-darkblue);
    border-radius: var(--radius-lg);
    padding: clamp(1.5rem, 2.5vw, 2.5rem);
    margin: var(--space-2xl) auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    max-width: var(--page-max);
    --info-bg: var(--ae-darkblue);
    --info-color: var(--white);
}

.table-section-title {
    text-align: left;
    font-size: var(--fs-h3);
    font-weight: 600;
    color: var(--ae-darkblue);
    margin-bottom: clamp(1.5rem, 2.5vw, 2.5rem);
    border-bottom: 2px dashed var(--ae-darkblue);
    padding-bottom: 10px;
}

/* Pie chart grid (inside .chart-section) */
.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%;
}

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

.chart-background {
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 1;
    z-index: 1;
    border-radius: 50%;
    object-fit: cover;
}

.chart-canvas {
    position: absolute;
    width: 100%;
    height: 100%;
    z-index: 2;
}

.chart-title {
    font-size: 12px;
    font-weight: bold;
    text-align: center;
    margin-bottom: 5px;
}

.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;
}

/* Applied dynamically by JS to each legend row's colour swatch. */
.legend-color-box {
    width: 20px;
    height: 20px;
    margin-right: 5px;
}


/* === INTERACTION ================================================
   Download button (corner-cut conic-gradient outline) and the
   confirmation modal it opens. */

.button-download {
    --b: 3px;
    --s: .45em;
    --color: var(--ae-darkblue);
    --_p: var(--s);
    padding: calc(.5em + var(--s)) calc(.9em + var(--s));
    color: var(--color);
    background:
        conic-gradient(from 90deg at var(--b) var(--b), transparent 90deg, var(--color) 0)
        var(--_p) var(--_p) /
        calc(100% - var(--b) - 2 * var(--_p))
        calc(100% - var(--b) - 2 * var(--_p));
    transition: .3s linear, color 0s, background-color 0s;
    outline: var(--b) solid transparent;
    outline-offset: .6em;
    font-size: 16px;
    border: 0;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

.button-download:hover,
.button-download:focus-visible {
    --_p: 0px;
    outline-color: var(--color);
    outline-offset: .05em;
}

.button-download:active {
    background: var(--color);
    color: var(--ae-white);
}


/* === MODAL (HTML / PDF download confirmation) =================== */

.modal__overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: color-mix(in srgb, var(--ae-black) 65%, transparent);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
}

.modal__content {
    background: var(--ae-black);
    color: var(--ae-white);
    padding: 2rem;
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    box-shadow: 0 0 30px color-mix(in srgb, var(--ae-lightblue) 30%, transparent);
    text-align: center;
}

.modal__content h2 {
    margin-top: 0;
    color: var(--ae-orange);
}

.modal__actions {
    margin-top: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
}

.modal__btn {
    padding: 0.75rem 1.5rem;
    font-size: 16px;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-weight: bold;
    transition: 0.3s ease;
}

.modal__btn--cancel { background-color: var(--ae-sun-lite);    color: var(--ae-black); }
.modal__btn--html   { background-color: var(--ae-lightblue);        color: var(--ae-black); }
.modal__btn--pdf    { background-color: var(--ae-jungle-dark); color: var(--ae-white); }

.modal__btn:hover {
    transform: scale(1.05);
}


/* === RESPONSIVE (tablet) =======================================
   to do */
@media (max-width: 1400px) {
    /* TODO */
}

/* === RESPONSIVE (mobile) =======================================
   to do */
@media (max-width: 768px) {
    /* TODO */
}
