/**
 * Appearance for the E8.S3 day-tab component (`pt_gtfs_timetable`).
 *
 * WHY THIS FILE EXISTS. pt-gtfs ships STRUCTURAL day-tab CSS only — the
 * visually-hidden radio, `.gtfs-day-pane{display:none}`, the
 * `:checked + label + pane` reveal, and the focus-visible outline (see
 * `pt_gtfs_day_tab_css()`). Nothing anywhere styled `.gtfs-day-tab` as a TAB, so
 * the labels rendered as bare words. The child theme's tab styling targets the
 * OLD Avada `fusion_tabs` component (`ul.nav-tabs > li > a`), which is entirely
 * different markup, so none of it applied. This was a gap, never a regression.
 *
 * WHY HERE AND NOT IN pt-gtfs. These are Pierce Transit / Avada theme colours
 * (#026cb6, #cce2f0), not GTFS-domain values, and `pt_gtfs_day_tab_css()` is
 * shared with pt-gtfs's own admin preview and its byte-identical shortcode
 * contract — appearance added there would leak into both. Everything below is
 * scoped to `.pt-gtfs-timetable-v2`, the v2 element's own wrapper, so it can
 * only ever affect this element (issue #249's direction: appearance lives with
 * the plugin that renders the surface).
 *
 * WHY IT IS RESPONSIVE. The legacy route page renders the day groups as a
 * horizontal TAB BAR on desktop and as a stacked ACCORDION on narrow screens;
 * this element must match. Both looks are pure CSS on ONE markup, because
 * `gtfs_render_day_tab()` already emits `radio, label, pane, radio, label,
 * pane, …` in that order — so the mobile-first BASE below does nothing special
 * and natural block flow already reads as an accordion (each label directly
 * above its own pane, and pt-gtfs's `:checked + label + pane` reveal shows only
 * the open day's pane). The desktop tab bar is the one that needs work: the
 * `@media screen and (min-width:768px)` block regroups the labels into one row via
 * flex `order` and pushes the open pane onto its own full-width line below them.
 * 768px matches the child theme's surviving detours-grid switch point.
 *
 * WHY FLEX AND NOT `display:table-cell` (desktop). The old tabs get equal widths
 * from `li{display:table-cell}` inside `ul.nav-tabs`, where the only children are
 * the tabs. That cannot be copied here: the PANES are siblings of the labels
 * inside `.gtfs-day-tabs`, so making the container a table would turn the panes
 * into cells too. Flex fits: the labels are `flex:1 1 0` (equal widths), the
 * visible pane is pushed onto its own full-width line with `order` +
 * `flex-basis:100%`, and the radios are already `position:absolute` so they are
 * out of flow and never become flex items.
 *
 * Flex changes LAYOUT ONLY, never the DOM, so pt-gtfs's adjacent-sibling
 * selectors (`+`) keep matching exactly as before at both widths — which is what
 * lets this file add appearance without touching the tab mechanism or the a11y
 * outline.
 *
 * Deliberately does NOT set `display` on `.gtfs-day-pane`: that property is
 * pt-gtfs's show/hide mechanism and must stay its alone.
 */

/* ── Shared appearance (both breakpoints) ─────────────────────────────────── */

.pt-gtfs-timetable-v2 .gtfs-day-tabs {
    width: 100%;
    background: #fff;
    border: 1px solid #cce2f0;
}

/* One day header. Colours, type and the selected top-border cue are identical in
   the accordion and the tab bar — only the box's layout (stacked vs. row) differs
   by breakpoint below. */
.pt-gtfs-timetable-v2 .gtfs-day-tab {
    box-sizing: border-box;
    background: #cce2f0;
    border-top: 3px solid #cce2f0;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 1.875rem; /* 30px */
    font-weight: 700;
    letter-spacing: -0.75px;
    line-height: normal;
    /* PT blue #026cb6. This is LARGE text (30px/700), so the WCAG 2.1 AA bar is
       3:1, not 4.5:1 — it clears it on both grounds: 4.11:1 on the #cce2f0
       unselected header and 5.49:1 on the #fff selected header (measured). The
       earlier #626262 existed only because the previous 16px/400 label was NORMAL
       text and needed 4.5:1; the larger, bolder header no longer does. Keep this
       text large and bold, or restore a darker colour, if the size is ever
       reduced. */
    color: #026cb6;
    text-align: center;
    cursor: pointer;
}

/* Hover previews the selected look (white ground). Background only — the #026cb6
   top border stays the selected header's own cue. */
.pt-gtfs-timetable-v2 .gtfs-day-tab:hover {
    background: #fff;
}

/* The selected/open day. White ground plus the blue top border, at both widths.
   Specificity (0,4,0) beats the base rule's (0,2,0), so only the two properties
   that differ are set and the base rule keeps owning everything else. */
.pt-gtfs-timetable-v2 .gtfs-day-radio:checked + .gtfs-day-tab {
    background: #fff;
    border-top-color: #026cb6;
}

/* The open pane. `min-width:0` lets a wide timetable's own overflow container
   scroll instead of forcing the line wider than the page; border-box keeps the
   15px padding inside its width. */
.pt-gtfs-timetable-v2 .gtfs-day-pane {
    min-width: 0;
    box-sizing: border-box;
    padding: 15px;
}

/* ── Mobile-first base = ACCORDION ────────────────────────────────────────── */
/* No flex: each label is a full-width block stacked above its own pane, and
   pt-gtfs's `:checked + label + pane` reveal opens only the selected day — a true
   accordion with zero extra markup, matching the legacy route page on narrow
   screens. `width`/`padding` here are deliberately overridden by the ≥768px media
   query below (same specificity, later source order), so keep that block after this
   one. */
.pt-gtfs-timetable-v2 .gtfs-day-tab {
    display: block;
    width: 100%;
    padding: 12px;
}

/* ── Desktop ≥768px = horizontal TAB BAR ──────────────────────────────────── */
@media screen and (min-width: 768px) {
    /* Wrap is required: it is what lets the open pane start a new line once the
       labels have filled the first one. The -1px pulls the pane up over the
       container's bottom border. */
    .pt-gtfs-timetable-v2 .gtfs-day-tabs {
        display: flex;
        flex-wrap: wrap;
        margin: 0 0 -1px;
    }

    /* `flex:1 1 0` gives every tab an equal share of the row regardless of label
       length — the flex equivalent of the old `display:table-cell`. */
    .pt-gtfs-timetable-v2 .gtfs-day-tab {
        order: 0;
        flex: 1 1 0;
        width: auto;
        padding: 11px 0;
        margin: 0 1px 0 0;
    }

    /* The 1px gutter is between tabs, not after the last one. */
    .pt-gtfs-timetable-v2 .gtfs-day-tab:last-of-type {
        margin-right: 0;
    }

    /* `order:1` is load-bearing: in DOM order the first pane sits BETWEEN the
       first and second labels, so without it the open pane would break the tab
       bar in half. `flex-basis:100%` puts it on its own line. */
    .pt-gtfs-timetable-v2 .gtfs-day-pane {
        order: 1;
        flex-basis: 100%;
    }
}

/* The per-day heading, visually hidden — NEVER removed.
 *
 * The seam emits `<h3 class="gtfs-day-heading">Tuesday</h3>` as the first child
 * of the open pane, so on THIS surface the day name appears twice: once in its
 * tab and again as a heading directly beneath the tab bar. The legacy design has
 * no such heading, and it is the last visible difference from it.
 *
 * It is hidden rather than removed because it is load-bearing for assistive
 * technology: `WeekHtmlBuilder::day_section()` wraps each day in
 * `<div class="gtfs-day" role="region" aria-labelledby="<this h3's id>">`, so
 * this heading IS the region's accessible name. Deleting it from the DOM (or
 * asking pt-gtfs to stop emitting it) would leave a dangling `aria-labelledby`
 * and an unnamed region.
 *
 * `display:none` is equally wrong here, and that is why this uses the clip
 * pattern instead: a `display:none` element is removed from the accessibility
 * tree, so the name it provides becomes unreliable. The declarations below are
 * pt-gtfs's own visually-hidden pattern (the one it already applies to
 * `.gtfs-day-radio`), reused verbatim so there is one such pattern to reason
 * about, not two.
 *
 * Scoped to the v2 element ON PURPOSE: this duplication only exists because the
 * TAB already names the day. pt-gtfs's own week-stack surface has no tabs, so
 * there the heading is the only thing naming the day and must stay visible —
 * which is exactly why this rule belongs here and not in pt-gtfs.
 */
.pt-gtfs-timetable-v2 .gtfs-day-heading {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    /* Both, deliberately: `clip` is deprecated but still honoured, and is the
       idiom pt-gtfs uses on this component's adjacent `.gtfs-day-radio`
       (scripts.php:204); `clip-path` is the current property. */
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}
