/* content/custom/css/charter-tracker.css
 *
 * UK Mainline Charter Tracker — public list + detail pages.
 * Uses the site's existing CSS custom properties so dark mode +
 * site palette flow through automatically.
 */

.ct {
    color: var(--text-color);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* ---------------------------------------------------------------- Hero / search */

.ct-hero {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 1.25rem 1.25rem 1rem;
    border-radius: 8px;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-sm);
}
.ct-hero h1 {
    margin: 0 0 .35rem;
    font-size: 1.4rem;
    line-height: 1.2;
    color: var(--text-color);
}
.ct-hero p {
    margin: 0 0 1rem;
    color: var(--text-light);
    font-size: .95rem;
}

.ct-search {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    align-items: stretch;
}
.ct-search-fields {
    display: flex;
    gap: .5rem;
    flex: 1 1 320px;
    flex-wrap: wrap;
}
.ct-search input[type="text"] {
    flex: 1 1 140px;
    padding: .55rem .75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font: inherit;
    font-size: 1rem;
    background: var(--background);
    color: var(--text-color);
    min-width: 0;
}
.ct-search select {
    padding: .55rem .65rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font: inherit;
    font-size: .9rem;
    background: var(--background);
    color: var(--text-color);
}

.ct-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    padding: .55rem .9rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--card-bg);
    color: var(--text-color);
    font: inherit;
    font-size: .9rem;
    cursor: pointer;
    text-decoration: none;
    line-height: 1.2;
}
.ct-btn:hover { background: var(--card-hover-bg, var(--background-alt)); }
/* Anchor-button colour lock — the site's global `a:hover { color }`
 * rule is more specific than `.ct-btn-primary:hover { background }`,
 * so without re-declaring colour on every link state the hovered text
 * goes blue, matches our hover background, and disappears. Locking
 * colour through link/visited/hover/active/focus on each variant
 * sidesteps the cascade ambiguity once and for all. */
.ct-btn-primary,
a.ct-btn-primary,
a.ct-btn-primary:link,
a.ct-btn-primary:visited,
a.ct-btn-primary:hover,
a.ct-btn-primary:active,
a.ct-btn-primary:focus {
    color: #fff;
}
.ct-btn-primary {
    background: var(--primary-color);
    border-color: var(--primary-color);
}
.ct-btn-primary:hover {
    background: var(--secondary-color, var(--primary-color));
    border-color: var(--secondary-color, var(--primary-color));
}
.ct-btn-lg {
    padding: .85rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
}

/* ---------------------------------------------------------------- Status banner */

.ct-status {
    margin-bottom: 1rem;
    padding: .65rem 1rem;
    border-radius: 6px;
    font-size: .9rem;
    background: var(--background-alt);
    color: var(--text-light);
    border-left: 3px solid var(--primary-color);
}
.ct-status.is-error {
    border-left-color: #dc2626;
    color: var(--text-color);
}

.ct-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-light);
    background: var(--card-bg);
    border: 2px dashed var(--border-color);
    border-radius: 10px;
}
.ct-empty strong {
    color: var(--text-color);
    display: block;
    margin-bottom: .35rem;
    font-size: 1.05rem;
}

/* ---------------------------------------------------------------- Charter list */

/* Target the data-attribute that the page actually uses on the list
 * container — `<div data-ct-list>`. Originally written as `.ct-list`
 * which never matched anything, so the cards stacked with zero gap. */
[data-ct-list] { display: grid; gap: .65rem; }
.ct-charter {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--primary-color);
    border-radius: 8px;
    padding: .9rem 1rem;
    cursor: pointer;
    transition: transform .12s, box-shadow .12s;
    box-shadow: var(--shadow-sm);
    color: inherit;
    display: block;
    text-decoration: none;
}
.ct-charter:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}
.ct-charter-head {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
    flex-wrap: wrap;
}
.ct-charter-route {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-color);
    margin-bottom: .15rem;
}
.ct-charter-route .ct-arrow {
    color: var(--primary-color);
    margin: 0 .35rem;
    font-weight: 400;
}
.ct-charter-date {
    font-size: .85rem;
    color: var(--text-light);
}
.ct-charter-pill {
    background: var(--primary-color);
    color: #fff;
    padding: .25rem .55rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
    white-space: nowrap;
}
.ct-charter-pill-distance { background: var(--background-alt); color: var(--text-color); border: 1px solid var(--border-color); }

/* ---------------------------------------------------------------- Type badges
 * Three working types, each with a distinct colour. The actual
 * passenger run is the headline (primary blue); supporting moves
 * (light engine, ECS) are visually softer so they don't compete.
 */
.ct-type-badge {
    display: inline-block;
    padding: .12rem .5rem;
    border-radius: 999px;
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    vertical-align: 1px;
    margin-left: .35rem;
}
.ct-type-passenger    { background: var(--primary-color); color: #fff; }
.ct-type-light_engine { background: #d97706; color: #fff; }   /* amber */
.ct-type-ecs          { background: #64748b; color: #fff; }   /* slate */
[data-theme="dark"] .ct-type-light_engine { background: #f59e0b; }
[data-theme="dark"] .ct-type-ecs          { background: #94a3b8; color: #0f172a; }

/* Card left-border colour echoes the badge so the type is readable
 * at a glance even before reading the label. */
.ct-charter.ct-charter-light_engine { border-left-color: #d97706; }
.ct-charter.ct-charter-ecs          { border-left-color: #64748b; }
[data-theme="dark"] .ct-charter.ct-charter-light_engine { border-left-color: #f59e0b; }
[data-theme="dark"] .ct-charter.ct-charter-ecs          { border-left-color: #94a3b8; }
.ct-charter.ct-charter-passenger    .ct-charter-num,
.ct-charter.ct-charter-light_engine .ct-charter-num,
.ct-charter.ct-charter-ecs          .ct-charter-num { color: inherit; }

/* ---------------------------------------------------------------- Live clock
 * Two-line block: big bold current time, smaller line below for the
 * "database last refreshed" freshness indicator. Sits to one side of
 * the hero / detail-head so it's visible without dominating the page.
 */

.ct-clock {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: .4rem .65rem;
    margin-top: .85rem;
    padding: .6rem .9rem;
    background: var(--background-alt);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-variant-numeric: tabular-nums;
    line-height: 1.3;
}
.ct-clock-now {
    font-size: .7rem;
    font-weight: 700;
    color: var(--primary-color);
    text-transform: uppercase;
    letter-spacing: .06em;
}
.ct-clock-time {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-color);
}
.ct-clock-date {
    font-size: .9rem;
    color: var(--text-light);
}
.ct-clock-sub {
    flex-basis: 100%;
    font-size: .78rem;
    color: var(--text-muted);
    margin-top: .15rem;
}

/* ---------------------------------------------------------------- Filter row */

.ct-filter-row {
    display: flex;
    align-items: center;
    gap: .65rem;
    margin: 0 0 .85rem;
    padding: .5rem .75rem;
    background: var(--background-alt);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: .85rem;
    color: var(--text-light);
}
.ct-filter-row label { display: flex; align-items: center; gap: .4rem; cursor: pointer; user-select: none; }
.ct-filter-row input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary-color); }
.ct-charter-meta {
    margin-top: .45rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: .35rem .75rem;
    font-size: .8rem;
    color: var(--text-muted);
}
.ct-charter-meta strong {
    color: var(--text-color);
    font-weight: 500;
    display: block;
    font-size: .85rem;
}
.ct-charter-headcode {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color: var(--primary-color);
    font-weight: 700;
}

/* ---------------------------------------------------------------- Detail view */

.ct-back {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    color: var(--primary-color);
    text-decoration: none;
    font-size: .9rem;
    margin-bottom: .85rem;
}
.ct-back:hover { text-decoration: underline; }

.ct-detail-head {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
}
.ct-detail-route {
    font-size: 1.4rem;
    font-weight: 600;
    margin: 0 0 .35rem;
    line-height: 1.2;
}
.ct-detail-subtitle {
    color: var(--text-light);
    margin: 0 0 1rem;
    font-size: .95rem;
}
.ct-detail-cta {
    margin-top: 1rem;
}

.ct-section {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
}
.ct-section h2 {
    margin: 0 0 .5rem;
    font-size: 1.1rem;
    color: var(--text-color);
}
.ct-section p {
    margin: 0 0 .75rem;
    color: var(--text-light);
    font-size: .9rem;
}

/* ---------------------------------------------------------------- Timetable
 *
 * Desktop: classic 4-column table.
 * Mobile (≤600px): the table reflows into stacked cards — each row
 * becomes a card with the station on top and the times/platform
 * inline below it. Pure CSS, no JS, no markup change required.
 */

.ct-timetable-wrap {
    margin: 0 -.5rem;
    padding: 0 .5rem;
}
.ct-timetable {
    width: 100%;
    border-collapse: collapse;
    font-size: .85rem;
}
.ct-timetable th, .ct-timetable td {
    text-align: left;
    padding: .45rem .5rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: top;
}
.ct-timetable th {
    background: var(--background-alt);
    color: var(--text-light);
    font-weight: 600;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.ct-timetable td.ct-time {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    white-space: nowrap;
}
.ct-timetable .ct-row-pass td { color: var(--text-muted); font-style: italic; }
.ct-timetable .ct-row-origin .ct-station,
.ct-timetable .ct-row-destination .ct-station { font-weight: 700; }
.ct-timetable .ct-station-meta {
    color: var(--text-muted);
    font-size: .75rem;
}
.ct-call-marker {
    display: inline-block;
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--primary-color);
    margin-right: .35rem;
    vertical-align: middle;
}
.ct-row-pass .ct-call-marker { background: transparent; border: 1px solid var(--text-muted); }

@media (max-width: 600px) {
    /* Hide the column headings — each cell will carry its own label. */
    .ct-timetable thead { display: none; }
    /* Reflow rows as stacked block cards. */
    .ct-timetable, .ct-timetable tbody, .ct-timetable tr {
        display: block;
        width: 100%;
    }
    .ct-timetable tr {
        background: var(--background-alt);
        border: 1px solid var(--border-color);
        border-radius: 6px;
        margin-bottom: .4rem;
        padding: .5rem .65rem;
    }
    .ct-timetable td {
        display: inline-block;
        border: 0;
        padding: 0;
    }
    /* Station cell takes the full first line of the card */
    .ct-timetable td:first-child {
        display: block;
        margin-bottom: .25rem;
        font-size: .92rem;
    }
    .ct-timetable .ct-station-meta { display: inline; margin-left: .35rem; }
    /* Time/platform cells share the second line, each labelled */
    .ct-timetable td.ct-time::before {
        color: var(--text-muted);
        font-family: inherit;
        font-size: .7rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: .03em;
        margin-right: .2rem;
    }
    .ct-timetable td.ct-time:nth-of-type(2)::before { content: "Arr "; }
    .ct-timetable td.ct-time:nth-of-type(3)::before { content: "Dep "; }
    .ct-timetable td:nth-of-type(4):not(:empty)::before {
        content: "Pf ";
        color: var(--text-muted);
        font-size: .7rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: .03em;
        margin-right: .2rem;
    }
    .ct-timetable td.ct-time + td.ct-time { margin-left: 1rem; }
    .ct-timetable td:nth-of-type(4) { margin-left: 1rem; }
    /* Hide times completely if both arr/dep are empty */
    .ct-timetable td.ct-time:empty { display: none; }
    .ct-timetable td.ct-time:empty + td.ct-time { margin-left: 0; }
}

/* ---------------------------------------------------------------- Disclaimer */

.ct-disclaimer {
    background: var(--background-alt);
    border-left: 3px solid var(--primary-color);
    padding: .75rem 1rem;
    border-radius: 6px;
    font-size: .85rem;
    color: var(--text-light);
    margin: 1rem 0;
}
.ct-disclaimer strong { color: var(--text-color); }

/* ---------------------------------------------------------------- OGL footer */

.ct-attribution {
    margin-top: 1.5rem;
    padding-top: .85rem;
    border-top: 1px solid var(--border-color);
    font-size: .75rem;
    color: var(--text-muted);
    text-align: center;
}
.ct-attribution a {
    color: var(--text-muted);
    text-decoration: underline;
}

/* ---------------------------------------------------------------- View toggle */

.ct-view { display: none; }
.ct-view.is-active { display: block; }

@media (max-width: 480px) {
    .ct-search-fields { flex-direction: column; }
    .ct-search input[type="text"], .ct-search select { width: 100%; flex: none; }
}

/* About-section bullet padding — same fix as the trainspotter about
   section. Default browser ul padding plus list-style-position: outside
   makes bullets touch the screen edge on mobile. */
.ct-about ul,
.ct-about ol {
    padding-left: 1.5rem;
}
@media (max-width: 480px) {
    .ct-about ul,
    .ct-about ol { padding-left: 1.25rem; }
    .ct-about ul li,
    .ct-about ol li { padding-left: .15rem; }
}

/* Secondary CTA — Add to Calendar (.ics download) */
.ct-detail-cta-secondary { margin-top: .5rem; }
.ct-btn-secondary,
a.ct-btn-secondary,
a.ct-btn-secondary:link,
a.ct-btn-secondary:visited {
    background: var(--background, #fff);
    color: var(--text-color, #1f2937);
    border: 1px solid var(--border-strong, #d1d5db);
    text-decoration: none;
}
a.ct-btn-secondary:hover { background: var(--card-hover-bg, #f3f4f6); }
a.ct-btn-secondary .icon {
    vertical-align: -3px;
    margin-right: .35rem;
    opacity: .85;
}
