/* The shared calendar: a row per route, a column per searched departure day.
 *
 * Standalone (tokens.css only) so the grid can own the whole width instead of
 * inheriting the answer screen's phone-width column. Colour carries the
 * verdict, never the absolute price: the reader is hunting a deal, not the
 * smallest number. Fills are mixed from the same semantic tokens the rest of
 * the product uses, so light and dark both follow; a flat fallback comes first
 * for browsers without color-mix(). No scripts: every control is a link. */

*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0; background: var(--page); color: var(--ink);
  font-size: var(--t-body); -webkit-text-size-adjust: 100%;
}
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}
.cal-wrap {
  max-width: 1180px; margin: 0 auto;
  padding: 14px 16px calc(28px + env(safe-area-inset-bottom));
}

/* --- header: one line, three things ------------------------------------- */
.cal-top { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 14px; }
.cal-top h1 { flex: 1 1 auto; min-width: 0; }
.cal-top h1 { font-size: var(--t-lead); margin: 0; }
.cal-brand { font-size: var(--t-eyebrow); color: var(--ink-2); text-decoration: none; letter-spacing: .04em; }
.cal-lang {
  margin-left: auto; font-size: var(--t-eyebrow); color: var(--ink-2);
  text-decoration: none; border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 10px; min-height: 28px; display: inline-flex; align-items: center;
}

/* --- filters ------------------------------------------------------------- */
.cal-filters { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 0 0 14px; }
.cal-filters .grp { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; min-height: 34px; padding: 0 13px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--card);
  color: var(--ink-2); font-size: var(--t-meta); text-decoration: none; white-space: nowrap;
}
.chip.on { background: var(--ink); color: var(--page); border-color: var(--ink); font-weight: 600; }

/* --- the grid ------------------------------------------------------------ */
.cal-scroll {
  overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line); border-radius: var(--r); background: var(--card);
  box-shadow: var(--shadow);
}
.cal-scroll:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cal-grid { border-collapse: separate; border-spacing: 0; width: max-content; }
.cal-grid th, .cal-grid td { padding: 0; font-weight: 400; }

/* Sticky route column. A fixed width with hidden overflow is what stops the
 * long labels printing over the prices. */
.cal-grid .corner, .cal-grid .r {
  position: sticky; left: 0; z-index: 2; width: 116px; min-width: 116px; max-width: 116px;
  background: var(--card); text-align: left; overflow: hidden;
  box-shadow: 1px 0 0 var(--line);
}
.cal-grid .corner { z-index: 4; }
.cal-grid .r { padding: 0 10px; height: 46px; }
.r-code { display: block; font-size: var(--t-meta); font-weight: 600; white-space: nowrap; letter-spacing: .01em; }
.r-full { display: none; }
.r-age { display: block; font-size: 13px; line-height: 1.2; color: var(--ink-2); white-space: nowrap; }

.cal-grid thead th { position: sticky; top: 0; background: var(--card); z-index: 1; }
.cal-grid .m-row .m {
  text-align: left; padding: 6px 8px 2px; font-size: var(--t-eyebrow); color: var(--ink-2);
  letter-spacing: .05em; text-transform: uppercase; border-left: 1px solid var(--line);
  z-index: 3;
}
.cal-grid .m-row .m:first-of-type { border-left: 0; }
.cal-grid .d-row .d {
  min-width: 56px; padding: 2px 0 6px; font-size: 15px; color: var(--ink-2);
  font-variant-numeric: tabular-nums; text-align: center; z-index: 3;
}
.cal-grid .we { background: color-mix(in srgb, var(--ink) 3%, var(--card)); }

.cal-grid td.c { width: 56px; height: 46px; border-top: 1px solid var(--page); }
.cal-grid td.c a {
  display: flex; align-items: center; justify-content: center; height: 100%;
  font-size: var(--t-meta); font-variant-numeric: tabular-nums; letter-spacing: -.01em;
  text-decoration: none; color: inherit;
}
.cal-grid td.c a:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.cal-grid td.none {
  background: var(--sunken);
  background-image: repeating-linear-gradient(135deg,
    color-mix(in srgb, var(--ink) 7%, transparent) 0 1px, transparent 1px 5px);
}
/* The same fares the list below names, ringed where they sit. */
.cal-grid td.best { box-shadow: inset 0 0 0 2px var(--ink); }

/* Colour = verdict. Flat fallback, then the mixed tint. */
.v-book   { background: #1B6B3A; color: #fff; }
.v-good   { background: #BFE3CD; color: #10301F; }
.v-normal { background: transparent; color: var(--ink-2); }
.v-wait   { background: #F2E2CE; color: #4A3721; }
.v-unknown{ background: transparent; color: var(--ink-2); }
@supports (background: color-mix(in srgb, red, white)) {
  .cal-grid td.v-book   { background: var(--good); color: var(--on-accent); font-weight: 600; }
  .cal-grid td.v-good   { background: color-mix(in srgb, var(--good) 34%, var(--card)); color: var(--ink); }
  .cal-grid td.v-normal { background: var(--card); color: var(--ink-2); }
  .cal-grid td.v-wait   { background: color-mix(in srgb, var(--wait) 26%, var(--card)); color: var(--ink); }
  .cal-grid td.v-unknown{ background: var(--card); color: color-mix(in srgb, var(--ink-2) 55%, transparent); }
  .cal-grid td.v-book.we, .cal-grid td.v-good.we, .cal-grid td.v-wait.we { background-blend-mode: multiply; }
}

/* --- key: swatch plus one word ------------------------------------------ */
.cal-key { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 12px 0 0; font-size: 15px; color: var(--ink-2); }
.cal-key .k { display: inline-flex; align-items: center; gap: 5px; background: none; color: inherit; }
.cal-key .k::before {
  content: ""; width: 12px; height: 12px; border-radius: 3px; border: 1px solid var(--line);
  background: var(--card);
}
.cal-key .v-book::before { background: var(--good); border-color: var(--good); }
.cal-key .v-good::before { background: color-mix(in srgb, var(--good) 34%, var(--card)); }
.cal-key .v-wait::before { background: color-mix(in srgb, var(--wait) 26%, var(--card)); }
.cal-key .v-unknown::before { background: var(--card); border-style: dashed; }
.cal-key .none::before {
  background-image: repeating-linear-gradient(135deg,
    color-mix(in srgb, var(--ink) 7%, transparent) 0 1px, transparent 1px 5px);
}

/* --- the shortcut: three lines, no card stack --------------------------- */
.cal-best { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 6px; max-width: 720px; }
.cal-best a {
  /* Wraps: a long date range must push the saving onto a second line rather
     than the whole page sideways on a phone. */
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px;
  min-height: var(--tap);
  padding: 8px 12px; border: 1px solid var(--line); border-left: 3px solid var(--good);
  border-radius: var(--r); background: var(--card); color: var(--ink); text-decoration: none;
}
.cal-best li.v-good a { border-left-color: color-mix(in srgb, var(--good) 45%, var(--card)); }
.cal-best b { font-size: var(--t-body); font-variant-numeric: tabular-nums; }
.cal-best .w { font-weight: 600; font-size: var(--t-meta); }
.cal-best .d { font-size: var(--t-meta); color: var(--ink-2); min-width: 0; }
.cal-best .s { margin-left: auto; font-size: var(--t-meta); color: var(--good);
               font-weight: 600; white-space: nowrap; }

.cal-note { font-size: var(--t-meta); color: var(--ink-2); margin: 10px 0 0; }

@media (min-width: 760px) {
  .cal-grid .corner, .cal-grid .r { width: 264px; min-width: 264px; max-width: 264px; }
  .r-code { display: none; }
  .r-full { display: block; font-size: var(--t-meta); font-weight: 600; white-space: nowrap;
            overflow: hidden; text-overflow: ellipsis; }
  .cal-grid td.c, .cal-grid .d-row .d { width: 62px; min-width: 62px; }
}
@media (prefers-reduced-motion: no-preference) {
  .cal-grid td.c a { transition: transform .08s ease; }
  .cal-grid td.c a:active { transform: scale(.9); }
}

/* --- how old the prices are, and the notice a stale static copy raises --- */
.cal-foot { margin: 16px 0 0; font-size: var(--t-meta); color: var(--ink-2); }

/* The static export inserts this notice and reveals it from the viewer's own
 * clock (see export.py): a file is served for days, so the page cannot know at
 * build time that it has gone stale. Same markup as the answer screen's. */
.notice {
  display: flex; gap: 12px; margin: 0 0 14px; padding: 14px 16px;
  border-radius: var(--r); background: var(--card);
  box-shadow: var(--shadow), 0 0 0 1px var(--line);
}
.notice-mark { flex: 0 0 auto; width: 5px; border-radius: 3px; background: var(--m-wait); }
.notice-body { min-width: 0; flex: 1; }
.notice h2 { margin: 0 0 4px; font-size: var(--t-body); font-weight: 650; line-height: 1.3; }
.notice p { margin: 0; font-size: var(--t-meta); color: var(--ink-2); }
