/*
 * NH Size Chart — shared base styles for WPC Product Size Chart, loaded on
 * every store by mu-plugins/nh-size-chart-styles.php.
 *
 * This file handles layout and spacing only; colors are neutral defaults.
 * To brand a store, set any of these variables in that store's CSS
 * (Divi Theme Options > Custom CSS, or Customizer > Additional CSS):
 *
 *   :root {
 *       --nh-sc-title-bg:     #eeeeee;   chart title bar background
 *       --nh-sc-title-color:  inherit;   chart title text
 *       --nh-sc-header-bg:    #f4f4f4;   table header row background
 *       --nh-sc-header-color: inherit;   table header row text
 *       --nh-sc-first-col-bg: transparent;  first (label) column background
 *       --nh-sc-stripe-bg:    #fafafa;   every other body row
 *       --nh-sc-hover-bg:     #f0f0f0;   row under the cursor
 *       --nh-sc-border:       #dddddd;   all table borders
 *       --nh-sc-text:         inherit;   table body text
 *       --nh-sc-font-size:    14px;      table text size (desktop)
 *   }
 *
 * Selectors use two classes so they outrank Divi's generic table rules
 * (.entry-content tr td etc.) without needing !important. A store's own
 * overrides need the same specificity or higher, e.g.
 * .wpcsc-size-chart .wpcsc-size-chart-content th { ... }
 */

/* Chart block */

.wpcsc-size-charts .wpcsc-size-chart {
    margin-bottom: 32px;
}

.wpcsc-size-charts .wpcsc-size-chart:last-child {
    margin-bottom: 0;
}

.wpcsc-size-chart .wpcsc-size-chart-title {
    margin: 0 0 16px;
    padding: 10px 16px;
    line-height: 1.3;
    background-color: var(--nh-sc-title-bg, #eeeeee);
    color: var(--nh-sc-title-color, inherit);
}

.wpcsc-size-chart .wpcsc-size-chart-content {
    padding: 0;
}

/* Text above / below the table */

.wpcsc-size-chart .wpcsc-size-chart-above-text,
.wpcsc-size-chart .wpcsc-size-chart-under-text {
    font-size: 0.9em;
    line-height: 1.5;
}

.wpcsc-size-chart .wpcsc-size-chart-above-text {
    margin: 0 0 12px;
}

.wpcsc-size-chart .wpcsc-size-chart-under-text {
    margin: 12px 0 0;
}

/* Divi gives every <p> bottom padding; keep the spacing set above instead. */
.wpcsc-size-chart .wpcsc-size-chart-above-text p,
.wpcsc-size-chart .wpcsc-size-chart-under-text p {
    margin: 0 0 0.5em;
    padding: 0;
}

.wpcsc-size-chart .wpcsc-size-chart-above-text > :last-child,
.wpcsc-size-chart .wpcsc-size-chart-under-text > :last-child {
    margin-bottom: 0;
}

/* Table */

.wpcsc-size-chart .nh-size-chart-scroll {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.wpcsc-size-chart .wpcsc-size-chart-content table {
    width: 100%;
    margin: 0;
    border: 1px solid var(--nh-sc-border, #dddddd);
    border-collapse: collapse;
    border-spacing: 0;
    table-layout: auto;
    font-size: var(--nh-sc-font-size, 14px);
    line-height: 1.4;
    color: var(--nh-sc-text, inherit);
}

.wpcsc-size-chart .wpcsc-size-chart-content th,
.wpcsc-size-chart .wpcsc-size-chart-content td {
    min-width: 3.5em;
    padding: 8px 12px;
    border: 1px solid var(--nh-sc-border, #dddddd);
    text-align: center;
    vertical-align: middle;
    white-space: nowrap;
}

.wpcsc-size-chart .wpcsc-size-chart-content th {
    font-weight: 700;
    background-color: var(--nh-sc-header-bg, #f4f4f4);
    color: var(--nh-sc-header-color, inherit);
}

/* First column holds the row labels (Size, Chest, Waist...). */
.wpcsc-size-chart .wpcsc-size-chart-content th:first-child,
.wpcsc-size-chart .wpcsc-size-chart-content td:first-child {
    text-align: left;
}

.wpcsc-size-chart .wpcsc-size-chart-content td:first-child {
    font-weight: 600;
    background-color: var(--nh-sc-first-col-bg, transparent);
}

.wpcsc-size-chart .wpcsc-size-chart-content tbody tr:nth-child(even) td {
    background-color: var(--nh-sc-stripe-bg, #fafafa);
}

.wpcsc-size-chart .wpcsc-size-chart-content tbody tr:hover td {
    background-color: var(--nh-sc-hover-bg, #f0f0f0);
}

/* Popup — keep the chart off the popup edges and allow it to use the width. */

.featherlight .featherlight-content .wpcsc-size-charts,
.mfp-wpcsc .wpcsc-popup .wpcsc-size-charts {
    min-width: min(600px, 80vw);
}

/* Phones */

@media (max-width: 600px) {
    .wpcsc-size-chart .wpcsc-size-chart-title {
        padding: 8px 12px;
    }

    .wpcsc-size-chart .wpcsc-size-chart-content table {
        font-size: calc(var(--nh-sc-font-size, 14px) - 1px);
    }

    .wpcsc-size-chart .wpcsc-size-chart-content th,
    .wpcsc-size-chart .wpcsc-size-chart-content td {
        min-width: 3em;
        padding: 6px 8px;
    }
}
