/* Reporting period control + the nightly per-entity diagram.
   Shared by the statistics hub (flights/statistics.php, eu261.es advanced stats) and the
   airline/airport pages, so the same control looks and behaves the same everywhere.
   Colours come from the theme tokens in flight-compensation.css — nothing here is
   site-specific and nothing is inline (strict CSP: no style attributes). */

/* --- the period picker: radios styled as a segmented control ---------------- */
/* Radios, not buttons: it is a single choice out of a small set, so the keyboard
   already works (arrow keys move between options) and the state is announced. */
.period-picker { border: 0; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.period-picker legend { height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; width: 1px; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.period-opt { position: relative; display: inline-flex; }
.period-opt input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.period-opt span { display: inline-block; padding: 8px 15px; border: 1px solid var(--fc-border); border-radius: 999px; background: var(--fc-panel); color: var(--fc-text); font-size: .9rem; line-height: 1.2; white-space: nowrap; transition: background-color .12s ease, border-color .12s ease, color .12s ease; }
.period-opt:hover span { border-color: var(--fc-primary); color: var(--fc-primary); }
.period-opt input:checked + span { background: var(--fc-primary); border-color: var(--fc-primary); color: var(--fc-on-primary); font-weight: 600; }
.period-opt input:checked:hover + span { color: var(--fc-on-primary); }
.period-opt input:focus-visible + span { outline: 2px solid var(--fc-primary); outline-offset: 2px; }
.period-opt input:disabled + span { opacity: .45; cursor: default; }

/* Period-aware headings ("Daily totals — 30 days") and the small caption under a control. */
.period-note { color: var(--fc-muted); font-size: .86rem; margin: 10px 0 0; min-height: 1.3em; }

/* Only the selected period's tiles are shown. The `hidden` attribute alone is not enough:
   `.stat-tiles { display: grid }` is an author rule of equal specificity to the UA's
   `[hidden] { display: none }`, so the grid wins and every period renders at once. */
.stat-tiles[hidden], [data-entity-stats] [hidden] { display: none; }

/* --- the nightly entity diagram -------------------------------------------- */
/* The image is a fixed-ratio bitmap with width/height on the tag, so the box is
   reserved before it loads and the page never shifts. */
.entity-chart { margin: 18px 0 0; }
.entity-chart img { display: block; width: 100%; height: auto; max-width: 780px; border: 1px solid var(--fc-border); border-radius: var(--fc-radius, 10px); background: var(--fc-panel); }
.entity-chart figcaption { color: var(--fc-muted); font-size: .84rem; margin-top: 8px; max-width: 78ch; }

/* Legend under the diagram: the words the bitmap cannot carry for screen readers. */
.entity-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 10px 0 0; color: var(--fc-muted); font-size: .84rem; }
.entity-legend__item { align-items: center; display: inline-flex; gap: 7px; }
.entity-legend i { border-radius: 3px; display: inline-block; flex: none; height: 12px; width: 12px; }
.entity-legend .sw-delayed { background: #e0a000; }
.entity-legend .sw-eu261 { background: #d03b3b; }
.entity-legend .sw-cancelled { background: #0066cc; }
:root[data-theme="dark"] .entity-legend .sw-delayed { background: #f2b134; }
:root[data-theme="dark"] .entity-legend .sw-eu261 { background: #e66767; }
:root[data-theme="dark"] .entity-legend .sw-cancelled { background: #3b82f6; }

/* A period with too few flights to publish: the tiles are replaced by this line. */
.stat-thin { color: var(--fc-muted); font-size: .92rem; margin: 8px 0 0; }

/* --- the daily trend (shared/js/entity-stats.js) ----------------------------- */
/* Canvas, not a bitmap: it re-slices itself when the period changes. The wrapper owns
   the width the script measures; the canvas gets its height from the script, so the
   min-height below only reserves the box until the first draw. */
.entity-trend { margin: 20px 0 0; }
.trend-canvas-wrap { max-width: 780px; }
.trend-canvas-wrap canvas { display: block; width: 100%; min-height: 210px; }
.entity-trend figcaption { color: var(--fc-muted); font-size: .84rem; margin-top: 8px; max-width: 78ch; }
.entity-trend .chart-status { color: var(--fc-muted); font-size: .84rem; margin: 6px 0 0; min-height: 1.3em; }

/* The series toggles ARE the legend — each carries its line's colour, so identity is
   never colour-alone and the two cannot drift (both are keyed by the series index). */
.trend-controls { border: 0; margin: 0 0 10px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; }
.trend-controls legend { height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; width: 1px; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.trend-controls label { align-items: center; color: var(--fc-text); cursor: pointer; display: inline-flex; font-size: .86rem; gap: 6px; }
.trend-sw { border-radius: 2px; display: inline-block; flex: none; height: 3px; width: 14px; }
.trend-sw--0 { background: #0f9d8e; }
.trend-sw--1 { background: #e0a000; }
.trend-sw--2 { background: #d03b3b; }
.trend-sw--3 { background: #0066cc; }
:root[data-theme="dark"] .trend-sw--0 { background: #22c3b0; }
:root[data-theme="dark"] .trend-sw--1 { background: #f2b134; }
:root[data-theme="dark"] .trend-sw--2 { background: #e66767; }
:root[data-theme="dark"] .trend-sw--3 { background: #3b82f6; }

/* Crosshair tooltip. Appended to <body> by the script so it is never clipped by the
   card's overflow; positioned in viewport coordinates. */
.trend-tip { position: fixed; z-index: 1200; pointer-events: none; max-width: 260px; padding: 8px 10px; border: 1px solid var(--fc-border); border-radius: 8px; background: var(--fc-panel); color: var(--fc-text); font-size: .82rem; line-height: 1.45; box-shadow: 0 6px 20px rgba(0, 0, 0, .25); }
.trend-tip[hidden] { display: none; }
.trend-tip__name { font-weight: 600; margin-bottom: 3px; }
.trend-tip__row { align-items: center; display: flex; gap: 7px; }
.trend-tip__row i { border-radius: 2px; display: inline-block; flex: none; height: 3px; width: 12px; }

@media (max-width: 620px) {
  .period-opt span { padding: 7px 12px; font-size: .85rem; }
}
