/* ===================================================================
   The traffic page (src/pages/traffic.html). Shared building blocks are in style/pages.css; only this page's own parts go here.

   stage ........... .tr-stage (the big working example under the head): .tr-top .tr-finder .tr-fchip (filter chips) .tr-kpis
                     .tr-chart (.tr-prev .tr-seg .tr-keys .tr-svg: bars, lines, dashed period before, squares) .tr-table (.tr-tabs
                     .tr-rows .tr-row) .tr-cursor
   rows ............ .tr-mini (a small app frame): .tr-sort (channels), .tr-logic (filters), .tr-zoom (a day opens its hours)
   more ............ .tr-utm (campaign tags, in a split row), .tr-dims (the collapsed list of every table)
   One-off moves are transitions (never paused half way); scripts/traffic.js drives them through StaseeAnim.
   =================================================================== */

.tr-sprite {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

.tr-stage,
.tr-mini {
    --tr-red: #dc2626;
    --tr-vis: #3b82f6;
    --tr-ses: #06b6d4;
    --tr-pv: #10b981;
}

:root[data-theme="dark"] :is(.tr-stage, .tr-mini) {
    --tr-red: #f87171;
}

/* the squares: from pale to full green (the same steps as the app) */
:root {
    --tr-lv0: color-mix(in srgb, var(--color-green) 7%, var(--color-bg-soft));
    --tr-lv1: color-mix(in srgb, var(--color-green) 22%, var(--color-bg));
    --tr-lv2: color-mix(in srgb, var(--color-green) 42%, var(--color-bg));
    --tr-lv3: color-mix(in srgb, var(--color-green) 66%, var(--color-bg));
    --tr-lv4: var(--color-green);
}

:root[data-theme="dark"] {
    --tr-lv0: color-mix(in srgb, var(--color-green) 6%, var(--color-bg-soft));
    --tr-lv1: color-mix(in srgb, var(--color-green) 20%, var(--color-bg-soft));
    --tr-lv2: color-mix(in srgb, var(--color-green) 40%, var(--color-bg-soft));
    --tr-lv3: color-mix(in srgb, var(--color-green) 65%, var(--color-bg-soft));
    --tr-lv4: var(--color-green);
}

/* ===================================================================
   The stage: a small working copy of the Traffic screen
   =================================================================== */

.tr-app {
    display: grid;
    gap: 14px;
}

.tr-h {
    font-size: clamp(18px, 1.8vw, 22px);
    font-weight: 800;
    letter-spacing: -.02em;
    line-height: 1.2;
}

.tr-sub {
    font-size: 13px;
    color: var(--color-text-soft);
}

/* ----- the websites, the dates and the filter chips ----- */

.tr-finder {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    min-height: 32px;
}

.tr-pick > svg {
    color: var(--color-text-quiet);
}

.tr-dots {
    display: inline-flex;
    padding-inline-start: 2px;
}

.tr-dots .site-dot {
    width: 9px;
    height: 9px;
    margin-inline-start: -2px;
    box-shadow: 0 0 0 2px var(--color-bg);
}

:root[data-theme="dark"] .tr-dots .site-dot {
    box-shadow: 0 0 0 2px var(--color-bg-soft);
}

.tr-filters {
    display: contents;
}

.tr-fchip {
    padding-inline-end: 4px;
    transition: opacity .3s ease, transform .35s var(--ease);
}

.tr-fchip.is-new,
.tr-fchip.is-gone {
    opacity: 0;
    transform: scale(.7);
}

.tr-fchip svg.tr-fchip-i {
    color: var(--green-text);
}

.tr-x {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;

    border-radius: 50%;
    color: var(--color-text-soft);
    transition: background-color .15s var(--ease), color .15s var(--ease);
}

.tr-x:hover {
    background: color-mix(in srgb, var(--color-green) 22%, transparent);
    color: var(--color-text);
}

.tr-x svg {
    width: 12px;
    height: 12px;
}

.tr-add {
    border-style: dashed;
    color: var(--color-text-quiet);
}

/* ----- the headline numbers ----- */

.tr-kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.tr-kpi {
    padding: 12px 14px;
    transition: border-color .5s ease, box-shadow .5s ease;
}

.tr-kpi.is-changed {
    border-color: color-mix(in srgb, var(--color-green) 60%, var(--color-border));
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-green) 16%, transparent);
}

.tr-trend {
    margin-top: 3px;
    overflow: hidden;

    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-quiet);
    white-space: nowrap;
    text-overflow: ellipsis;
}

.tr-chg {
    font-weight: 800;
    color: var(--green-text);
    font-variant-numeric: tabular-nums;
}

.tr-chg.is-bad {
    color: var(--tr-red);
}

/* ----- the chart and the table side by side ----- */

.tr-main {
    display: grid;
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
    gap: 12px;
}

/* the chart takes the height of the table next to it */
.tr-chart {
    display: flex;
    flex-direction: column;
}

.tr-chart,
.tr-table {
    padding: 14px 14px 12px;
}

.tr-chart-h {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 12px;
}

.tr-chart-t {
    font-size: 15px;
    font-weight: 800;
}

.tr-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.tr-prev {
    display: inline-flex;
    align-items: center;
    gap: 7px;

    height: 32px;
    padding-inline: 11px;

    border: 1px solid var(--color-border);
    border-radius: 999px;
    background: var(--color-bg);

    font-size: 12.5px;
    font-weight: 700;
    color: var(--color-text-soft);
    transition: background-color .25s var(--ease), border-color .25s var(--ease), color .25s var(--ease);
}

:root[data-theme="dark"] .tr-prev {
    background: var(--color-bg-soft);
}

.tr-prev[aria-pressed="true"] {
    border-color: color-mix(in srgb, var(--color-text) 30%, var(--color-border));
    background: var(--color-bg-soft);
    color: var(--color-text);
}

:root[data-theme="dark"] .tr-prev[aria-pressed="true"] {
    background: var(--color-border);
}

.tr-dash {
    width: 16px;
    height: 0;
    border-top: 2px dashed currentColor;
}

/* Bars | Lines | Squares */
.tr-seg {
    display: inline-flex;
    padding: 3px;

    border: 1px solid var(--color-border);
    border-radius: 11px;
    background: var(--color-bg);
}

:root[data-theme="dark"] .tr-seg {
    background: var(--color-bg-soft);
}

.tr-seg button {
    display: inline-flex;
    align-items: center;
    gap: 6px;

    height: 26px;
    padding-inline: 9px;

    border-radius: 8px;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--color-text-soft);
    transition: background-color .25s var(--ease), color .25s var(--ease);
}

.tr-seg button:hover {
    color: var(--color-text);
}

.tr-seg button[aria-pressed="true"] {
    background: var(--color-green);
    color: var(--color-green-ink);
}

.tr-seg svg {
    width: 14px;
    height: 14px;
}

.tr-keys {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
    margin-top: 10px;

    font-size: 12.5px;
    font-weight: 700;
    color: var(--color-text-soft);
    transition: opacity .3s ease;
}

.tr-keys li {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.tr-key-i {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--c);
}

.tr-chart.is-sq .tr-keys {
    opacity: .35;
}

.tr-plot {
    position: relative;
    flex: 1;
    min-height: 230px;
    margin-top: 8px;
}

.tr-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.tr-svg text {
    font-size: 10.5px;
    font-weight: 600;
    fill: var(--color-text-quiet);
    font-variant-numeric: tabular-nums;
}

.tr-grid line {
    stroke: var(--color-border-soft);
    stroke-width: 1;
}

:root[data-theme="dark"] .tr-grid line {
    stroke: var(--color-border);
}

.tr-grid line.is-base {
    stroke: var(--color-border);
}

.tr-bars rect {
    fill: var(--c);
}

.tr-lines path {
    fill: none;
    stroke: var(--c);
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.tr-prevs path {
    fill: none;
    stroke: var(--c);
    stroke-width: 1.8;
    stroke-dasharray: 5 4;
    opacity: .75;
}

/* the parts of the bars and lines fade while the squares fill, and the other way round */
.tr-grid,
.tr-xl,
.tr-bars,
.tr-lines,
.tr-prevs {
    transition: opacity .35s ease;
}

.tr-svg.is-sq :is(.tr-grid, .tr-xl, .tr-bars, .tr-lines, .tr-prevs) {
    opacity: 0;
}

.tr-sq rect {
    opacity: 0;
    transform: scale(.3);
    transform-box: fill-box;
    transform-origin: center;
    transition: opacity .3s ease, transform .4s var(--ease), fill .6s ease;
}

.tr-svg.is-sq .tr-sq rect {
    opacity: 1;
    transform: none;
}

.tr-sq rect.lv0 { fill: var(--tr-lv0); }
.tr-sq rect.lv1 { fill: var(--tr-lv1); }
.tr-sq rect.lv2 { fill: var(--tr-lv2); }
.tr-sq rect.lv3 { fill: var(--tr-lv3); }
.tr-sq rect.lv4 { fill: var(--tr-lv4); }

.tr-sq rect.is-best {
    stroke: var(--color-text);
    stroke-width: 1.5;
}

.tr-sq text {
    opacity: 0;
    transition: opacity .3s ease;
}

.tr-svg.is-sq .tr-sq text {
    opacity: 1;
}

.tr-cap {
    min-height: 1.5em;
    margin-top: 6px;

    font-size: 12.5px;
    font-weight: 600;
    color: var(--color-text-soft);
}

/* ----- the table ----- */

.tr-tabs {
    display: flex;
    gap: 4px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--color-border-soft);
}

:root[data-theme="dark"] .tr-tabs {
    border-bottom-color: var(--color-border);
}

.tr-tabs button {
    position: relative;
    height: 30px;
    padding-inline: 10px;

    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    color: var(--color-text-soft);
    transition: background-color .2s var(--ease), color .2s var(--ease);
}

.tr-tabs button:hover {
    background: var(--color-bg-soft);
    color: var(--color-text);
}

:root[data-theme="dark"] .tr-tabs button:hover {
    background: var(--color-bg);
}

.tr-tabs button[aria-pressed="true"] {
    color: var(--green-text);
}

.tr-tabs button[aria-pressed="true"]::after {
    content: "";
    position: absolute;
    inset-inline: 8px;
    bottom: -9px;
    height: 2px;
    border-radius: 2px;
    background: var(--color-green);
}

.tr-hint {
    margin-top: 10px;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-quiet);
}

.tr-head,
.tr-row {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr) 62px 60px;
    align-items: center;
    column-gap: 10px;
}

.tr-head {
    margin-top: 8px;
    padding: 0 8px 6px;

    font-size: 11px;
    font-weight: 700;
    color: var(--color-text-quiet);
    text-align: end;
}

.tr-rows {
    display: grid;
    align-content: start;
    min-height: calc(6 * 48px);
}

.tr-rows[hidden] {
    display: none;
}

.tr-rows > li {
    transition: transform .5s var(--ease), opacity .3s ease;
}

.tr-rows > li[hidden] {
    display: none;
}

.tr-rows > li.is-new {
    opacity: 0;
    transform: translateY(8px);
}

.tr-row {
    width: 100%;
    min-height: 48px;
    padding: 6px 8px;

    border-top: 1px solid var(--color-border-soft);
    font-size: 13px;
    font-weight: 600;
    text-align: start;
    transition: background-color .25s var(--ease);
}

:root[data-theme="dark"] .tr-row {
    border-top-color: var(--color-border);
}

.tr-row:hover {
    background: var(--color-bg-soft);
}

:root[data-theme="dark"] .tr-row:hover {
    background: var(--color-bg);
}

.tr-row[aria-checked="true"] {
    background: var(--color-green-soft);
}

:root[data-theme="dark"] .tr-row[aria-checked="true"] {
    background: var(--color-green-soft);
}

.tr-box {
    position: relative;
    width: 16px;
    height: 16px;

    border: 1.5px solid var(--color-border);
    border-radius: 5px;
    background: var(--color-bg);
    transition: background-color .2s ease, border-color .2s ease;
}

:root[data-theme="dark"] .tr-box {
    background: var(--color-bg-soft);
}

.tr-row[aria-checked="true"] .tr-box,
.tr-logic-list li.is-on .tr-box {
    border-color: var(--color-green);
    background: var(--color-green) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23052e16' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 11px no-repeat;
}

.tr-name {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    column-gap: 8px;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.tr-rows[data-dim="channel"] .tr-name {
    display: block;
}

.tr-badge,
.tr-code {
    grid-row: span 2;
    display: grid;
    place-items: center;
    width: 24px;
    height: 22px;

    border-radius: 6px;
    font-size: 9.5px;
    font-weight: 800;
    letter-spacing: .03em;
}

.tr-badge {
    background: color-mix(in srgb, var(--dot) 16%, transparent);
    color: color-mix(in srgb, var(--dot) 75%, var(--color-text));
}

.tr-code {
    grid-row: auto;
    background: var(--color-bg-soft);
    color: var(--color-text-soft);
}

:root[data-theme="dark"] .tr-code {
    background: var(--color-border);
}

.tr-path,
.tr-host {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tr-path {
    font-weight: 700;
    text-align: start;
}

.tr-host {
    font-size: 11px;
    color: var(--color-text-quiet);
    text-align: start;
}

.tr-row .tr-num {
    font-weight: 700;
    text-align: end;
    font-variant-numeric: tabular-nums;
}

.tr-row .tr-chg {
    font-size: 12px;
    text-align: end;
}

.tr-share {
    grid-column: 2 / -1;
    display: block;
    height: 3px;
    margin-top: 4px;
    overflow: hidden;

    border-radius: 2px;
    background: var(--color-border-soft);
}

:root[data-theme="dark"] .tr-share {
    background: var(--color-border);
}

.tr-share i {
    display: block;
    width: var(--w, 0%);
    height: 100%;
    border-radius: inherit;
    background: color-mix(in srgb, var(--color-green) 75%, transparent);
    transition: width .7s var(--ease);
}

/* before the example plays in, the numbers wait at nought (scripts/traffic.js counts them up) */
.tr-stage.is-pre .tr-share i {
    width: 0;
}

/* ----- the pointer of the playing example (positions are measured from the frame's left edge, so "left" is right here) ----- */

.tr-cursor {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 6;

    width: 22px;
    height: 22px;

    opacity: 0;
    pointer-events: none;
    transition: transform .8s cubic-bezier(.45, .05, .25, 1), opacity .35s ease;
}

.tr-cursor.is-on {
    opacity: 1;
}

.tr-cursor svg {
    width: 100%;
    height: 100%;
    overflow: visible;
    transform-origin: 30% 20%;
    transition: transform .12s ease;
}

.tr-cursor path {
    fill: var(--color-text);
    stroke: var(--color-bg);
    stroke-width: 1.6;
    stroke-linejoin: round;
}

.tr-cursor.is-down svg {
    transform: scale(.8);
}

.tr-cursor::before {
    content: "";
    position: absolute;
    top: -10px;
    left: -10px;
    width: 26px;
    height: 26px;

    border: 2px solid var(--color-green);
    border-radius: 50%;
    opacity: 0;
}

.tr-cursor.is-click::before {
    animation: tr-click .6s ease-out;
}

@keyframes tr-click {
    0% { opacity: .9; transform: scale(.4); }
    100% { opacity: 0; transform: scale(1.5); }
}

/* ===================================================================
   The small app frames of the rows
   =================================================================== */

.tr-mini {
    max-width: 640px;
    margin-inline: auto;
}

.tr-mini .app-body {
    padding: clamp(14px, 2vw, 20px);
}

/* the dot where an example "clicks" */
.tr-tap {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;

    border: 2px solid var(--color-green);
    border-radius: 50%;
    background: color-mix(in srgb, var(--color-green) 22%, transparent);
    opacity: 0;
    pointer-events: none;
}

.tr-tap.is-go {
    animation: tr-tap .7s ease-out;
}

@keyframes tr-tap {
    0% { opacity: 0; transform: scale(.4); }
    30% { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(1.5); }
}

/* ----- channels: each visit is sorted into its channel ----- */

.tr-sort-in {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    min-height: 34px;
}

.tr-sort-l {
    font-size: 13px;
    font-weight: 700;
    color: var(--color-text-soft);
}

.tr-sort-slot {
    flex: 1;
    min-width: 120px;
    height: 34px;

    border: 1.5px dashed var(--color-border);
    border-radius: 10px;
}

.tr-sort-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 14px;
}

.tr-sort-list li {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 8px;
    padding: 8px 10px 9px;

    border: 1px solid var(--color-border-soft);
    border-radius: 11px;
    background: var(--color-bg);
    transition: border-color .35s ease, box-shadow .35s ease;
}

:root[data-theme="dark"] .tr-sort-list li {
    border-color: var(--color-border);
    background: var(--color-bg-soft);
}

.tr-sort-list li.is-hit {
    border-color: color-mix(in srgb, var(--color-green) 60%, var(--color-border));
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-green) 16%, transparent);
}

.tr-sort-n {
    overflow: hidden;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.tr-sort-list b {
    font-size: 14px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.tr-sort-bar {
    grid-column: 1 / -1;
    display: block;
    height: 4px;
    margin-top: 6px;
    overflow: hidden;
    border-radius: 2px;
    background: var(--color-border-soft);
}

:root[data-theme="dark"] .tr-sort-bar {
    background: var(--color-border);
}

.tr-sort-bar i {
    display: block;
    width: var(--w, 0%);
    height: 100%;
    border-radius: inherit;
    background: var(--color-green);
    transition: width .6s var(--ease);
}

/* the place a visit came from: a chip that travels to its channel */
.tr-token {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;

    display: inline-flex;
    align-items: center;
    height: 30px;
    padding-inline: 12px;

    border: 1px solid color-mix(in srgb, var(--color-green) 55%, var(--color-border));
    border-radius: 999px;
    background: var(--color-bg);
    box-shadow: var(--shadow-md);

    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12.5px;
    font-weight: 700;
    white-space: nowrap;

    opacity: 0;
    pointer-events: none;
    transition: transform .8s cubic-bezier(.45, .05, .25, 1), opacity .3s ease;
}

:root[data-theme="dark"] .tr-token {
    background: var(--color-bg-soft);
}

.tr-token.is-on {
    opacity: 1;
}

.tr-token.is-plain {
    font-family: var(--font-sans);
}

.tr-sort-none[hidden] {
    display: none;
}

/* ----- filters: one kind = any of them, two kinds = both ----- */

.tr-logic-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    min-height: 32px;
}

.tr-logic-none {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-quiet);
}

.tr-logic-chips .chip {
    transition: opacity .3s ease, transform .35s var(--ease);
}

.tr-logic-chips .chip.is-new,
.tr-logic-chips .chip.is-gone {
    opacity: 0;
    transform: scale(.7);
}

.tr-logic-chips .chip svg {
    width: 13px;
    height: 13px;
    color: var(--green-text);
}

.tr-logic-and {
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--color-text-quiet);
}

.tr-logic-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.tr-logic-grid .app-card {
    padding: 12px;
}

.tr-logic-t {
    font-size: 13.5px;
    font-weight: 800;
}

.tr-logic-list {
    display: grid;
    gap: 2px;
    margin-top: 6px;
}

.tr-logic-list li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 6px;

    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    transition: background-color .3s ease;
}

.tr-logic-list li.is-on {
    background: var(--color-green-soft);
}

.tr-logic-out {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 14px;
    margin-top: 12px;
    padding: 12px 14px;

    border-radius: 12px;
    background: var(--color-green-soft);
}

.tr-logic-n {
    font-size: 14px;
    font-weight: 700;
    color: var(--color-text-soft);
}

.tr-logic-n b {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -.02em;
    color: var(--color-text);
    font-variant-numeric: tabular-nums;
}

.tr-logic-say {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-soft);
}

/* ----- the chart: a day opens its hours ----- */

.tr-zoom-top {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 32px;
}

.tr-zoom-top .chip > svg {
    color: var(--color-text-quiet);
}

.tr-zoom-back {
    transition: opacity .3s ease, transform .35s var(--ease);
}

.tr-zoom-back.is-off {
    opacity: 0;
    transform: scale(.8);
}

.tr-zoom-back.is-touch {
    border-color: color-mix(in srgb, var(--color-green) 55%, var(--color-border));
}

.tr-zoom-plot {
    position: relative;
    height: 150px;
    margin-top: 14px;
    border-bottom: 1px solid var(--color-border);
}

.tr-zoom-days,
.tr-zoom-hours {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-end;
}

.tr-zoom-days {
    gap: 8%;
    padding-inline: 3%;
}

.tr-zoom-hours {
    gap: 2px;
}

.tr-zoom-days i,
.tr-zoom-hours i {
    flex: 1;
    height: var(--h);
    border-radius: 4px 4px 0 0;
}

.tr-zoom-days i {
    background: var(--tr-vis);
    transform-origin: left bottom;
    transition: transform .6s var(--ease), opacity .35s ease, background-color .3s ease;
}

[dir="rtl"] .tr-zoom-days i {
    transform-origin: right bottom;
}

.tr-zoom-days i.is-pick {
    background: color-mix(in srgb, var(--tr-vis) 70%, var(--color-text));
}

.tr-zoom-days.is-zoom i:not(.is-pick),
.tr-zoom-days.is-gone i {
    opacity: 0;
}

.tr-zoom-hours i {
    background: #22d3ee;
    transform: scaleY(0);
    transform-origin: bottom;
    transition: transform .45s var(--ease);
}

.tr-zoom-hours.is-on i {
    transform: none;
}

.tr-zoom-axis {
    position: relative;
    height: 18px;
    margin-top: 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-quiet);
}

.tr-zoom-dl,
.tr-zoom-hl {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: space-between;
    transition: opacity .3s ease;
}

.tr-zoom-dl {
    gap: 8%;
    padding-inline: 3%;
}

.tr-zoom-dl span {
    flex: 1;
    text-align: center;
}

.tr-zoom-hl,
.tr-zoom-axis.is-hours .tr-zoom-dl {
    opacity: 0;
}

.tr-zoom-axis.is-hours .tr-zoom-hl {
    opacity: 1;
}

/* ===================================================================
   More: when they come, campaign tags, search a list
   =================================================================== */

/* ----- campaign tags ----- */

.tr-utm {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 12px;
    padding: 16px;
}

.tr-utm-url {
    min-height: 64px;
    padding: 9px 12px;

    border: 1px solid var(--color-border);
    border-radius: 10px;
    background: var(--color-bg);

    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    line-height: 1.5;
    overflow-wrap: anywhere;
    text-align: left; /* an address reads left to right in every language */
}

:root[data-theme="dark"] .tr-utm-url {
    background: var(--color-bg-soft);
}

.tr-utm-url .is-tag {
    color: var(--green-text);
    font-weight: 700;
}

.tr-caret {
    display: inline-block;
    width: 2px;
    height: 1.1em;
    margin-inline-start: 1px;
    vertical-align: text-bottom;
    background: var(--color-green);
    animation: tr-blink 1.1s steps(1) infinite;
}

@keyframes tr-blink {
    50% { opacity: 0; }
}

.tr-utm-out {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
}

.tr-utm-out li {
    display: grid;
    min-width: 0;
    padding: 6px 10px;

    border: 1px solid var(--color-border-soft);
    border-radius: 9px;
    background: var(--color-bg);
    transition: opacity .35s ease, transform .4s var(--ease);
}

:root[data-theme="dark"] .tr-utm-out li {
    border-color: var(--color-border);
    background: var(--color-bg-soft);
}

.tr-utm-out li.is-off {
    opacity: 0;
    transform: translateY(6px);
}

.tr-utm-out li.is-channel {
    border-color: color-mix(in srgb, var(--color-green) 50%, var(--color-border));
    background: var(--color-green-soft);
}

.tr-utm-out span {
    font-size: 11px;
    font-weight: 700;
    color: var(--color-text-quiet);
}

.tr-utm-out b {
    overflow: hidden;
    font-size: 13px;
    font-weight: 800;
    white-space: nowrap;
    text-overflow: ellipsis;
    text-align: start;
}

/* ----- every table ----- */

.tr-dims {
    max-width: 980px;
    margin: clamp(36px, 5vw, 56px) auto 0;
    text-align: center;
}

/* the picture of the campaign row: a calm card like the other pictures of the page */
.split-media > .tr-utm {
    max-width: 560px;
    margin-inline: auto;

    border: 1px solid var(--color-border-soft);
    box-shadow: var(--shadow-lg);
}

:root[data-theme="dark"] .split-media > .tr-utm {
    border-color: var(--color-border);
}

.tr-dims-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 16px;
}

.tr-dims-list .chip {
    min-height: 34px;
    font-size: 13.5px;
    color: var(--color-text);
}

.tr-next {
    margin-top: 28px;
    text-align: center;
}

/* ===================================================================
   Narrower screens
   =================================================================== */

@media (max-width: 1080px) {

    .tr-trend .tr-vs {
        display: none;
    }
}

@media (max-width: 999px) {

    .tr-main {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 640px) {

    .tr-sub,
    .tr-add {
        display: none;
    }

    .tr-kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .tr-kpi {
        padding: 10px 12px;
    }

    .tr-chart,
    .tr-table {
        padding: 12px 10px 10px;
    }

    .tr-prev {
        padding-inline: 9px;
    }

    /* the chart types as icons only (their names stay for screen readers) */
    .tr-seg button {
        padding-inline: 8px;
    }

    .tr-seg button span {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

    .tr-plot {
        min-height: 190px;
    }

    .tr-head,
    .tr-row {
        grid-template-columns: 16px minmax(0, 1fr) 50px 52px;
        column-gap: 8px;
    }

    .tr-rows {
        min-height: calc(5 * 48px);
    }

    .tr-sort-list {
        gap: 6px;
    }

    .tr-sort-list li {
        padding: 7px 8px 8px;
    }

    .tr-sort-n {
        font-size: 12px;
    }

    .tr-logic-grid {
        gap: 8px;
    }

    .tr-logic-grid .app-card {
        padding: 10px;
    }

    .tr-zoom-plot {
        height: 120px;
    }
}

/* ===================================================================
   Less motion: everything is simply there (scripts/traffic.js draws the final state)
   =================================================================== */

@media (prefers-reduced-motion: reduce) {

    .tr-cursor,
    .tr-caret {
        display: none;
    }

    .tr-tap.is-go,
    .tr-cursor.is-click::before,
    .tr-caret {
        animation: none;
    }
}
