/* ===================================================================
   Compare: on top of style/websites.css (the glass, the finder, the buttons, the table, the menu) and style/traffic.css (the chart).
   Here: the bar of comparisons, the table card (a sub-heading for each automatic record, the colour dots, the best value in bold),
   the inline cards (the row editor and "Add automatically"), the footer of the table, the empty state.
   Light + dark, phone width (16px gutter, no sideways scroll of the page: the table scrolls in its box, its first column stays),
   right-to-left through logical properties.
   =================================================================== */

/* ===== the bar: the comparisons, their menu, the period ===== */

.cmp-pick {
    flex: 1 1 280px;
    min-width: 0;
    max-width: 460px;
}

.cmp-pick[hidden] { display: none; }

.cmp-bar .ws-more { margin-bottom: 2px; }

/* ===== the table card (solid, without the blur of the glass: a blur would hold the filter popup of a card opened inside it) ===== */

.cmp-card {
    margin-bottom: 22px;
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    background: var(--glass-hover);
    box-shadow: var(--glass-shadow);
}

/* the table fits a wide screen (so a card in a row's place keeps its popups); on a narrow one it scrolls in its box */
.cmp-scroll { position: relative; }

.cmp-table thead th:first-child { border-start-start-radius: 16px; }
.cmp-table thead th:last-child { border-start-end-radius: 16px; }

.cmp-th-row { min-width: 220px; }

.cmp-name-c {
    min-width: 220px;
    font-weight: 500;
}

/* the dot, the favicon and the label, which takes what is left and ends in "…": a grid, so a long label (or a long language) never
   makes the table wider than its card (the max-width of a table cell holds nothing) */
.cmp-name {
    display: grid;
    grid-template-columns: auto auto minmax(0, max-content);
    justify-content: start;
    align-items: center;
    gap: 8px;
    max-width: 340px;
}

.cmp-name .tr-fav { width: 22px; height: 22px; }

/* the row's colour: the legend of the chart (a click hides or shows its line) */
.cmp-dot {
    display: grid;
    place-items: center;
    flex: none;
    width: 24px;
    height: 24px;
    margin-inline-start: -4px;
    border-radius: 50%;
    transition: background .15s;
}

.cmp-dot::before {
    content: "";
    width: 12px;
    height: 12px;
    border: 2px solid var(--c);
    border-radius: 50%;
    background: var(--c);
    transition: background .15s;
}

.cmp-dot.is-off::before { background: transparent; }
.cmp-dot:hover { background: color-mix(in srgb, var(--c) 14%, transparent); }
.cmp-dot:focus-visible { outline: 0; box-shadow: 0 0 0 2px var(--color-green); }

.cmp-dot.is-static {
    width: 14px;
    height: 14px;
    margin: 0;
}

.cmp-dot.is-static::before { width: 10px; height: 10px; }

.cmp-label {
    min-width: 0;
    overflow: hidden;
    color: var(--color-text);
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cmp-label:hover { text-decoration: underline; text-underline-offset: 2px; }

/* a number and its change under it; the best one of its column in bold */
.cmp-num { white-space: nowrap; }
.cmp-num .ws-cell-v { font-weight: 500; }
.cmp-num.is-best .ws-cell-v { font-weight: 800; color: var(--color-black); }

.cmp-num .ws-cell-v,
.cmp-num .ws-trend { transition: opacity .2s ease; }

/* the numbers of the period before stay, faded, until the new ones are here (nothing that pulses) */
.cmp-tr.is-stale .cmp-num .ws-cell-v,
.cmp-tr.is-stale .cmp-num .ws-trend { opacity: .5; }

/* an automatic record: a light sub-heading over its rows */
.cmp-sub > * {
    background: color-mix(in srgb, var(--color-text) 3.5%, var(--glass-hover));
    color: var(--color-text-soft);
    font-size: 12.5px;
    font-weight: 600;
}

.cmp-sub > th { padding-block: 8px; }

.cmp-sub-t {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.cmp-sub-t .material-symbols-outlined { font-size: 16px; color: var(--color-green-dark); }
:root[data-theme="dark"] .cmp-sub-t .material-symbols-outlined { color: var(--color-green); }

.cmp-sub-note > td {
    color: var(--color-text-muted);
    font-size: 13px;
}

/* the record that a card under the table is changing */
.cmp-table tr.is-editing > * { background: color-mix(in srgb, var(--color-green) 8%, var(--glass-hover)); }

.cmp-table tbody tr.cmp-sub:hover > * { background: color-mix(in srgb, var(--color-text) 3.5%, var(--glass-hover)); }
.cmp-table tbody tr.cmp-edit-row:hover > * { background: transparent; }
.cmp-edit-row > td { padding: 8px; }

/* "Arrows: change vs the previous 30 days" */
.cmp-caption {
    margin: 0;
    padding: 8px 14px 0;
    color: var(--color-text-muted);
    font-size: 12.5px;
}

/* ===== the inline cards: the row editor and "Add automatically" ===== */

.cmp-slot { padding: 0 14px; }
.cmp-slot > .cmp-edit { margin: 12px 0 4px; }

.cmp-edit {
    scroll-margin: 76px 0 16px;   /* (brought into view below the top bar) */
    padding: 14px 16px;
    border: 1px solid color-mix(in srgb, var(--color-green) 35%, var(--color-border));
    border-radius: 14px;
    background: color-mix(in srgb, var(--color-green) 4%, var(--glass-hover));
}

.cmp-edit-t {
    margin: 0 0 12px;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: -.01em;
}

.cmp-edit-grid {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 14px 20px;
}

.cmp-edit-site {
    flex: 0 1 300px;
    min-width: 0;
}

.cmp-gen-grid .cmp-edit-site { flex-basis: 340px; }

.cmp-edit-filters {
    flex: 1 1 320px;
    min-width: 0;
}

.cmp-edit .xselect-label,
.cmp-edit .ws-f-label {
    margin: 0 0 6px;
    color: var(--color-text);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
}

.cmp-edit .ws-fs legend {
    font-weight: 600;
    line-height: 1.2;
}

.cmp-gen-by { flex: 1 1 300px; }
.cmp-gen-chips { margin-bottom: 0; }
.cmp-gen-chips .ws-chip[aria-disabled="true"] { opacity: .45; cursor: default; }
.cmp-gen-top { flex: none; }

/* the label the row will have, in its colour */
.cmp-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 14px 0 0;
    font-size: 14px;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.cmp-preview:empty { display: none; }

.cmp-gen-say {
    margin: 14px 0 0;
    font-size: 13.5px;
    font-weight: 600;
}

.cmp-gen-say.is-over { color: var(--ws-bad); }
.cmp-gen-hint { margin-top: 4px; }
.cmp-edit-err { margin-top: 10px; }

.cmp-edit-acts {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 14px;
}

.cmp .ws-btn:disabled {
    opacity: .5;
    cursor: default;
    filter: none;
}

/* ===== under the table: "+ Add row", "Add automatically", "8 of 12 rows" ===== */

.cmp-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
    padding: 10px 14px 14px;
}

.cmp-count {
    margin-inline-start: auto;
    color: var(--color-text-muted);
    font-size: 12.5px;
    font-variant-numeric: tabular-nums;
}

.cmp-full {
    flex: 1 1 100%;
    color: var(--color-text-soft);
    font-size: 12.5px;
}

/* ===== nothing to compare yet ===== */

.cmp-empty { margin: 0 0 22px; }
.cmp-empty .ws-empty-ico { background: color-mix(in srgb, var(--color-green) 13%, transparent); color: var(--color-green-dark); }
:root[data-theme="dark"] .cmp-empty .ws-empty-ico { color: var(--color-green); }

.cmp-empty-acts {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.cmp-empty-acts[hidden] { display: none; }

/* ===== the chart ===== */

.cmp-zone {
    margin: 6px 0 0;
    color: var(--color-text-muted);
    font-size: 12.5px;
}

.cmp-tip-name {
    min-width: 0;
    max-width: 210px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===== narrow screens: the table scrolls inside its box, its first column stays in view ===== */

@media (max-width: 759px) {
    .cmp-scroll {
        overflow-x: auto;
        border-radius: 16px 16px 0 0;
        scrollbar-width: thin;
    }

    .cmp-table { min-width: 600px; }
    .cmp-th-row,
    .cmp-name-c { min-width: 170px; }
    .cmp-name { max-width: 180px; }
    .cmp-foot .cmp-count { flex: 1 1 100%; margin-inline-start: 0; }

    /* the sub-heading of an automatic record stays in view and wraps in the visible part of the box */
    .cmp-sub-t {
        position: sticky;
        inset-inline-start: 10px;
        max-width: calc(100vw - 100px);
    }
}

@media (max-width: 560px) {
    .cmp-slot { padding: 0 10px; }
    .cmp-edit { padding: 12px; }
    .cmp-edit-site,
    .cmp-edit-filters,
    .cmp-gen-by { flex-basis: 100%; }
    /* the comparison and its menu on one line, the period under them */
    .cmp-pick { flex: 1 1 0; max-width: none; }
    .cmp-bar .ws-f-range { flex-basis: 100%; margin-inline-start: 0; }
}

/* ===== the chart's Squares: one strip per row (its name on the left), one square per day ===== */

.cmp-chart .tr-chart-h { flex-wrap: wrap; }
.cmp-view { margin-inline-start: auto; }

.cmp-sq {
    position: relative;
    width: 100%;
}

.cmp-sq-svg {
    position: absolute;
    inset: 0;
    display: block;
}

.cmp-sq-none {
    fill: none;
    stroke: var(--color-border);
    stroke-dasharray: 2 2;
}

/* (the names sit over the left part of the drawing, where there are no squares) */
.cmp-sq-names {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    pointer-events: none;
}

.cmp-sq-name {
    position: absolute;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    overflow: hidden;
    color: var(--color-text-soft);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.cmp-sq-name span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
}

.cmp-sq-dot {
    flex: none;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

@media (max-width: 380px) {
    /* Bars | Lines | Squares go down to their icons; the word stays for screen readers (as on Traffic) */
    #CMP_VIEW button span:not(.material-symbols-outlined) {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }
}

/* ===== "Add automatically": the sum before anything is added (Websites 4 × Language top 3 = Rows 12) ===== */

.cmp-gen-sum {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin: 14px 0 4px;
    font-size: 14px;
}

.cmp-sum-t {
    display: inline-flex;
    align-items: baseline;
    gap: 5px;
    padding: 5px 10px;
    border-radius: 9px;
    background: color-mix(in srgb, var(--color-text) 6%, transparent);
    color: var(--color-text-soft);
    white-space: nowrap;
}

.cmp-sum-t b {
    color: var(--color-text);
    font-size: 15px;
    font-weight: 800;
}

.cmp-sum-t.is-total {
    background: color-mix(in srgb, var(--color-green) 14%, transparent);
    color: var(--color-green-dark);
}

:root[data-theme="dark"] .cmp-sum-t.is-total { color: var(--color-green); }
.cmp-gen-sum.is-over .cmp-sum-t.is-total { background: color-mix(in srgb, var(--ws-bad) 14%, transparent); color: var(--ws-bad); }
.cmp-gen-sum.is-over .cmp-sum-t.is-total b { color: var(--ws-bad); }

.cmp-sum-op {
    color: var(--color-text-muted);
    font-weight: 700;
}

