/**
 * The stats page (dashboard/stats.html and partials/stats/): what the shared components in
 * static/css/tailwind-input.css (card, card-title, btn-*, help) do not already draw.
 *
 * Since 2026-10-24: one segmented control for every choice of a few (the range, Day/Week/Month),
 * one bar list for every ranked list, skeletons inside each card while it loads (no overlay over
 * the page), and no hover-only tooltips (a help button beside a card's title says the rest).
 */

/* ==========================================================================
   Tabs
   ========================================================================== */

.tab-content { display: none; }
.tab-content.active { display: block; }

/* hidden means hidden, also on an element whose classes give it a display (a button, a flex row) */
[hidden] { display: none !important; }

/* A test reads its own dates and goals: the page's range and conversions do nothing on that tab */
body[data-tab="experiments"] [data-page-filter] { display: none !important; }

/* ==========================================================================
   A segmented control: the range, Day/Week/Month. Where you are is a quiet slate pill in the
   heading colour, as in the sidebar, since the accent means "you can act on this".
   ========================================================================== */

.seg {
    display: inline-flex;
    flex: none;
    gap: 2px;
    padding: 3px;
    border-radius: 0.625rem;
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.12);
}
.seg > button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    min-height: 2rem;
    min-width: 2.25rem;
    padding: 0 0.625rem;
    border-radius: 0.4375rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #cbd5e1;  /* slate-300 */
    white-space: nowrap;
    transition: background-color 0.15s, color 0.15s;
}
.seg > button:hover { color: #f8fafc; background: rgba(255, 255, 255, 0.05); }
.seg > button[aria-pressed="true"] {
    color: #f8fafc;
    font-weight: 600;
    background: rgba(148, 163, 184, 0.2);
}
.seg > button:focus-visible { outline: 2px solid #818cf8; outline-offset: 1px; }

/* A control in the bar: the same height as the segmented control */
.bar-control {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 2.5rem;
    max-width: 100%;
    padding: 0 0.75rem;
    border-radius: 0.625rem;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: #0f172a;
    font-size: 0.875rem;
    font-weight: 500;
    color: #e2e8f0;  /* slate-200 */
    white-space: nowrap;
    transition: background-color 0.15s, border-color 0.15s;
}
.bar-control:hover { background: rgba(255, 255, 255, 0.05); border-color: rgba(255, 255, 255, 0.22); }
.bar-control:focus-visible { outline: 2px solid #818cf8; outline-offset: 2px; }

.event-status-popover.active { display: block !important; }

/* ==========================================================================
   Ranked data as a list of bars: full names, the figure beside them, and the
   colour of what they measure: events indigo (the default), time violet,
   converting emerald, sessions lost rose, and in Segments each segment its own
   hue (stats.html, SEGMENT_HUES)
   ========================================================================== */

.bar-track {
    display: flex;
    height: 0.5rem;
    width: 100%;
    overflow: hidden;
    border-radius: 9999px;
    background: rgba(148, 163, 184, 0.14);
}
.bar-fill {
    height: 100%;
    flex: none;
    background: #6366f1;  /* brand-500 */
    transition: width 0.3s cubic-bezier(0.4, 0, 0.6, 1);
}
.bar-fill + .bar-fill { box-shadow: inset 2px 0 0 #1e293b; }  /* a hairline between a group's events */
.bar-fill.is-quiet { background: #475569; }
.bar-fill.is-time { background: #a78bfa; }     /* violet-400 */
.bar-fill.is-convert { background: #34d399; }  /* emerald-400 */
.bar-fill.is-lost { background: #fb7185; }     /* rose-400 */
.bar-fill.is-without { background: #64748b; }  /* slate-500: the sessions without an event */

/* ==========================================================================
   Waiting: each card shows its own skeleton while it loads
   ========================================================================== */

@keyframes stats-shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.skeleton {
    display: block;
    border-radius: 0.5rem;
    background: linear-gradient(90deg, #273449 25%, #31405a 50%, #273449 75%);
    background-size: 200% 100%;
    animation: stats-shimmer 1.5s ease-in-out infinite;
}

/* An Overview card that is loading: its figures keep their place under a skeleton */
.loads { position: relative; }
.is-loading .loads::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 0.5rem;
    background: linear-gradient(90deg, #273449 25%, #31405a 50%, #273449 75%);
    background-size: 200% 100%;
    animation: stats-shimmer 1.5s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
    .skeleton, .is-loading .loads::after { animation: none; }
}

/* ==========================================================================
   Charts: the plot area, 200 px on a phone and 240 px from 768 px
   ========================================================================== */

.chart-box { position: relative; height: 200px; }
@media (min-width: 768px) { .chart-box { height: 240px; } }

/* ==========================================================================
   Tables. :where() keeps these defaults below any utility a cell carries (a colour, a weight).
   ========================================================================== */

.stats-table { width: 100%; font-size: 0.875rem; border-collapse: collapse; }
:where(.stats-table) th {
    padding: 0.5rem;
    font-weight: 500;
    color: #94a3b8;  /* slate-400 */
    white-space: nowrap;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
:where(.stats-table) td {
    padding: 0.625rem 0.5rem;
    color: #e2e8f0;  /* slate-200 */
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    white-space: nowrap;
}
/* a row's name, when the row has one */
:where(.stats-table) tbody th {
    padding-top: 0.625rem;
    padding-bottom: 0.625rem;
    font-weight: 400;
    color: #f1f5f9;
    text-align: left;
    border-bottom-color: rgba(255, 255, 255, 0.06);
}
:where(.stats-table) tbody tr:last-child > * { border-bottom: 0; }
@media (min-width: 640px) {
    :where(.stats-table) th, :where(.stats-table) td { padding-left: 0.75rem; padding-right: 0.75rem; }
}
:where(.stats-table) tr > :first-child { padding-left: 0; }
:where(.stats-table) tr > :last-child { padding-right: 0; }

/* A column that sorts: its header is a button */
.sort-button {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    border-radius: 0.375rem;
    font-weight: 500;
    color: inherit;
}
.sort-button:hover, .sort-button[data-sorted] { color: #f8fafc; }
.sort-button:focus-visible { outline: 2px solid #818cf8; outline-offset: 2px; }
.sort-button svg { width: 0.875rem; height: 0.875rem; opacity: 0.35; }
.sort-button[data-sorted] svg { opacity: 1; }

/* ==========================================================================
   The Countries card's map
   ========================================================================== */

#globeViz { aspect-ratio: 2 / 1; width: 100%; }
#globeSection.map-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    margin: 0;
    padding: 1rem;
    border-radius: 0;
    background: #0f172a;
}
#globeSection.map-fullscreen #globeViz { aspect-ratio: auto; height: calc(100vh - 2rem); }

/* The way out of the full screen map, there only while it is full screen */
.map-close { display: none !important; }
.map-fullscreen .map-close { display: inline-flex !important; position: absolute; top: 1rem; right: 1rem; z-index: 1; }

/* ==========================================================================
   The calendar for days chosen by hand (flatpickr), on the page's dark surfaces
   ========================================================================== */

.flatpickr-calendar {
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 0.875rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
}
.flatpickr-calendar.arrowTop::before { border-bottom-color: rgba(255, 255, 255, 0.15); }
.flatpickr-calendar.arrowTop::after { border-bottom-color: #1e293b; }
.flatpickr-calendar.arrowBottom::before { border-top-color: rgba(255, 255, 255, 0.15); }
.flatpickr-calendar.arrowBottom::after { border-top-color: #1e293b; }
.flatpickr-months .flatpickr-month,
.flatpickr-current-month .flatpickr-monthDropdown-months,
.flatpickr-current-month input.cur-year { color: #f8fafc; fill: #f8fafc; background: transparent; }
.flatpickr-current-month .flatpickr-monthDropdown-months option { background: #1e293b; }
.flatpickr-current-month .flatpickr-monthDropdown-months:hover,
.flatpickr-current-month span.cur-month:hover { background: rgba(255, 255, 255, 0.06); }
.flatpickr-months .flatpickr-prev-month,
.flatpickr-months .flatpickr-next-month { color: #cbd5e1; fill: #cbd5e1; }
.flatpickr-months .flatpickr-prev-month:hover svg,
.flatpickr-months .flatpickr-next-month:hover svg { fill: #f8fafc; }
.numInputWrapper span.arrowUp::after { border-bottom-color: #cbd5e1; }
.numInputWrapper span.arrowDown::after { border-top-color: #cbd5e1; }
span.flatpickr-weekday { color: #94a3b8; }
.flatpickr-day { color: #e2e8f0; }
.flatpickr-day:hover, .flatpickr-day:focus { background: rgba(255, 255, 255, 0.08); border-color: transparent; }
.flatpickr-day.today { border-color: #818cf8; }
.flatpickr-day.today:hover, .flatpickr-day.today:focus { background: rgba(129, 140, 248, 0.2); border-color: #818cf8; color: #f8fafc; }
.flatpickr-day.prevMonthDay, .flatpickr-day.nextMonthDay { color: #8492a8; }
.flatpickr-day.flatpickr-disabled, .flatpickr-day.flatpickr-disabled:hover { color: #475569; background: none; }
.flatpickr-day.inRange,
.flatpickr-day.inRange:hover {
    background: rgba(99, 102, 241, 0.25);
    border-color: transparent;
    box-shadow: -5px 0 0 rgba(99, 102, 241, 0.25), 5px 0 0 rgba(99, 102, 241, 0.25);
    color: #f8fafc;
}
.flatpickr-day.selected, .flatpickr-day.startRange, .flatpickr-day.endRange,
.flatpickr-day.selected:hover, .flatpickr-day.startRange:hover, .flatpickr-day.endRange:hover {
    background: #4f46e5;
    border-color: #4f46e5;
    color: #ffffff;
}
.flatpickr-day.selected.startRange + .endRange:not(:nth-child(7n+1)),
.flatpickr-day.startRange.startRange + .endRange:not(:nth-child(7n+1)),
.flatpickr-day.endRange.startRange + .endRange:not(:nth-child(7n+1)) { box-shadow: -10px 0 0 #4f46e5; }
