/* Statistics — the line view ("Linie"): the search box, the cards and the route table. */

/* Choosing a specific line in the statistics: a search box with the browser's own suggestion
   list (a `<datalist>`), because whoever knows their line types one character. The box is the
   mockups' one: a bordered field with a magnifier and, on a phone with a line open, the period. */
.stats-line-box {
    display: flex;
    align-items: center;
    gap: 10px;
    box-sizing: border-box;
    min-height: 48px;
    margin-top: 10px;
    padding: 0 14px;
    border: 1px solid var(--tint-14);
    /* 6 px, not the phone mockup's 14 px: the operator found the mockups "za okrągłe". */
    border-radius: 6px;
    background: var(--bg-card);
    color: var(--text-main);
}

/* The whole box is the focus ring (as in the mockup, whose input has `outline: none`); a second
   outline on the input itself drew a rectangle inside the box, around the native clear button. */
.stats-line-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

.stats-line-box svg { flex: 0 0 auto; }

.stats-line-search {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 1rem;
    outline: none;
}

/* Only the line view shows the period beside the box (on the list the header's switch is there). */
.stats-line-period {
    display: none;
    font-size: 0.75rem;
    color: var(--text-sec);
    white-space: nowrap;
}

.stats-panel--line-open .stats-line-period { display: inline; }

.stats-line-hint {
    margin: 6px 0 0;
    font-size: 0.8rem;
    color: var(--warn);
}

/* „Ostatnio" — the recently viewed lines in the wide line view's header (the desktop mockup
   alone). 13 px, secondary colour, the numbers as accent links separated by the mockup's „ · ".
   Wide only: the phone mockup has no such element, so the span carries `stats-only-wide` and the
   rules below only lay it out from 960 px. */
.stats-line-recent {
    font-size: 13px;
    color: var(--text-sec);
    white-space: nowrap;
}

.stats-line-recent-sep { color: var(--text-sec); }

.stats-line-recent-link {
    appearance: none;
    -webkit-appearance: none;
    margin: 0;
    padding: 0;
    background: none;
    border: 0;
    color: var(--accent);
    font: inherit;
    cursor: pointer;
}

.stats-line-recent-link:hover { color: var(--stats-link-hover); }

.stats-line-recent-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Line view ────────────────────────────────────────────────────────────
   Drawn to the approved mockups (StatsLine.dc.html at 390 px, StatsLineDesktop.dc.html at 1280 px);
   one DOM, the layouts picked by `.stats-only-phone` / `.stats-only-wide`. Radii stop at 6 px. */
.stats-panel--line-open {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.stats-line-crumb {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
    font-size: 0.8125rem;
    color: var(--text-sec);
}

.stats-line-crumb-link {
    appearance: none;
    -webkit-appearance: none;
    margin: 0;
    padding: 0;
    background: none;
    border: 0;
    color: var(--accent);
    font: inherit;
    cursor: pointer;
}

.stats-line-crumb-link:hover { color: var(--stats-link-hover); }

.stats-line-crumb-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.stats-line-crumb-here { color: var(--text-main); font-weight: 600; }

.stats-line-phone { display: flex; flex-direction: column; gap: 14px; }

.stats-line-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-sizing: border-box;
    padding: 16px;
    background: var(--stats-card-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
}

.stats-line-card h3 {
    margin: 0;
    font-size: 1.125rem;
    line-height: 1.35;
    font-weight: 700;
}

.stats-line-lead {
    margin: 0;
    font-size: 0.8125rem;
    line-height: 1.45;
    color: var(--text-sec);
}

.stats-line-lead strong { color: var(--stats-strong); }

/* The eight bars share `chart()`'s two views; `display` set here would beat the UA's `[hidden]`. */
.stats-line-card .stats-chart,
.stats-line-spread .stats-chart { display: flex; flex-direction: column; gap: 6px; margin: 0; }

.stats-line-card .stats-chart-plot,
.stats-line-spread .stats-chart-plot { display: flex; flex-direction: column; gap: 6px; }

.stats-line-card .stats-chart-plot[hidden],
.stats-line-card .stats-chart-data[hidden],
.stats-line-spread .stats-chart-plot[hidden],
.stats-line-spread .stats-chart-data[hidden] { display: none; }

.stats-line-bars {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 4px;
    align-items: end;
    height: 120px;
    border-bottom: 1px solid var(--stats-axis);
}

.stats-line-bar { display: block; border-radius: 4px 4px 0 0; }

.stats-line-bar--early { background: var(--stats-early); }

.stats-line-bar--ontime { background: var(--stats-ontime); }

.stats-line-bar--late { background: var(--stats-late); }

/* The labels and the caption ride in `chart()`'s axis slot; its own axis style is switched off. */
.stats-line-card .stats-axis-x,
.stats-line-spread .stats-axis-x {
    margin: 0;
    font-size: 0.75rem;
    text-align: left;
    letter-spacing: 0;
}

.stats-line-axis { display: flex; flex-direction: column; gap: 6px; }

.stats-line-labels {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 4px;
    font-size: 0.6875rem;
    color: var(--text-sec);
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.stats-line-caption { margin: 0; font-size: 0.75rem; color: var(--text-sec); }

.stats-line-cover {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 10px;
    border-top: 1px solid var(--stats-rule);
}

.stats-line-cover-title { font-size: 0.8125rem; color: var(--stats-strong); }

.stats-line-cover-hours {
    display: grid;
    grid-template-columns: repeat(24, minmax(0, 1fr));
    gap: 2px;
}

.stats-line-cover-hour { display: block; height: 10px; background: var(--stats-track); }

.stats-line-cover-hour--on { background: var(--stats-meter); }

.stats-line-cover-axis {
    display: flex;
    justify-content: space-between;
    font-size: 0.6875rem;
    color: var(--text-sec);
}

/* „Pokaż dane w tabeli": a `chart()`-style toggle button (a part of its own, at the bottom of the phone
   screen), restyled as the mockup's link-button with the table icon. */
.stats-panel--line-open .stats-line-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    margin: 0;
    padding: 0;
    background: none;
    border: 0;
    border-radius: 0;
    color: var(--accent);
    font: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    text-align: left;
}

.stats-panel--line-open .stats-line-toggle:hover { color: var(--stats-link-hover); }

.stats-line-toggle::before {
    content: '';
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Crect x='3' y='4' width='18' height='16' rx='2'/%3E%3Cpath d='M3 10h18M9 4v16'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Crect x='3' y='4' width='18' height='16' rx='2'/%3E%3Cpath d='M3 10h18M9 4v16'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* „Pora dnia". Phone: a heading, two columns of small cards, a caption. The bar is the middle half of
   the band's departures on the common −2…+10 min scale: the track is the whole scale, the fill spans
   p25..p75 (both set inline, in percent, already clamped to the scale), and `min-width` keeps a
   range narrower than a pixel or two visible as a tick. */
.stats-line-pora { display: flex; flex-direction: column; gap: 10px; }

.stats-line-pora h3,
.stats-line-pora-wide h3 { margin: 0; font-size: 0.9375rem; font-weight: 700; }

.stats-line-pora-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.stats-line-pora-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    box-sizing: border-box;
    padding: 12px;
    background: var(--stats-card-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
}

.stats-line-pora-label { font-size: 0.75rem; color: var(--text-sec); }

.stats-line-pora-card strong { font-size: 1.125rem; font-variant-numeric: tabular-nums; }

.stats-line-pora-caption { font-size: 0.75rem; color: var(--text-sec); }

.stats-line-range {
    display: flex;
    height: 6px;
    border-radius: 3px;
    background: var(--stats-track);
}

.stats-line-range-fill {
    display: block;
    min-width: 4px;
    border-radius: 3px;
    background: var(--stats-strong);
}

.stats-line-pora-table {
    border-collapse: collapse;
    font-size: 0.8125rem;
    font-variant-numeric: tabular-nums;
}

.stats-line-pora-table th {
    padding: 4px 8px;
    font-weight: 600;
    text-align: left;
    color: var(--text-sec);
}

.stats-line-pora-table td { padding: 8px; border-top: 1px solid var(--stats-rule); }

.stats-line-pora-table th:first-child,
.stats-line-pora-table td:first-child { padding-left: 0; }

.stats-line-pora-table th:last-child,
.stats-line-pora-table td:last-child { padding-right: 0; }

.stats-line-pora-table .stats-line-pora-num { text-align: right; }

.stats-line-pora-table .stats-line-pora-range { width: 40%; }

/* „Przystanki na trasie" (wide only): the „Pora dnia" table's look, one more column. The bar column
   is 34 % as on the mockup; the largest-increase row is semi-bold, its mark in the warning colour
   and its increase bold. The table scrolls sideways inside its card rather than squeezing the bars
   to nothing on a narrow desktop window. */
.stats-line-stops-head { display: flex; align-items: baseline; gap: 12px; }

.stats-line-stops-head h3 { flex-grow: 1; }

.stats-line-stops-scroll { overflow-x: auto; }

.stats-line-stops-table { width: 100%; }

.stats-line-stops-table .stats-line-pora-range { width: 34%; }

.stats-line-stops-table td { padding-top: 7px; padding-bottom: 7px; }

.stats-line-stops-table th:nth-child(4),
.stats-line-stops-table th:nth-child(5) { white-space: nowrap; }

.stats-line-stops-dim { color: var(--text-sec); }

.stats-line-stops-top td:first-child { font-weight: 600; }

.stats-line-stops-top td:nth-child(4) { font-weight: 700; }

.stats-line-stops-mark {
    margin-left: 4px;
    font-size: 0.6875rem;
    font-weight: 700;
    color: var(--warn-text);
}

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

.stats-line-tile {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px;
    border-radius: 4px;
    background: var(--stats-tile-bg);
}

.stats-line-tile-label,
.stats-line-tile-note { font-size: 0.75rem; color: var(--text-sec); }

.stats-line-tile strong { font-size: 1.375rem; font-variant-numeric: tabular-nums; }
