/* ---------------------------------------------------------------------------
   The opening page, and the trip finder.

   Separate from app.css because these are the only two pages with no form on
   them. The shell's styles are shared by everything; the panels and the list are
   shared by two.
   --------------------------------------------------------------------------- */

.home main { max-width: 62rem; }

/* Two panels, side by side where there is room and stacked where there is not.

   The grid is `auto-fit` rather than two fixed halves so the Reports panel does
   not get half the width of a wide screen while holding nothing. */
.panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
  gap: 1.25rem;
  align-items: start;
}

.panel {
  padding: 1.1rem 1.25rem 1.25rem;
  border: 1px solid var(--accent-line);
  border-radius: 8px;
  /* A wash rather than a border colour, matching the Trip form's groups. */
  background: color-mix(in srgb, var(--accent-soft) 45%, transparent);
}

.panel h2 {
  margin: 0 0 0.3rem;
  font-size: 1.05rem;
  color: var(--accent);
}

.panel .note { margin: 0 0 1rem; }

/* A box inside a panel, holding one kind of thing.

   The Reports panel has two: text reports and graphical reports. They are boxes
   rather than a flat list because one of them is empty, and a flat list cannot
   say "there are none of these" without the whole panel reading as unfinished. */
.group + .group {
  margin-top: 1.1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--accent-line);
}

.group-title {
  margin: 0 0 0.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--fg);
  font-family: inherit;
}

.group-note {
  margin: 0 0 0.6rem;
  font-size: 0.82rem;
  color: var(--muted);
}

/* Eighteen buttons is a long column, and they are all view names, so they are
   set in a monospaced face at a smaller size: this is a list of identifiers to
   be recognised, not a menu of destinations to be read. */
.entries.compact .entry { padding: 0.45rem 0.6rem; }

.entries.compact .entry-label {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  font-weight: 500;
}

/* The entries are links rather than buttons because they navigate. A button that
   goes somewhere is a link that has been told to lie about what it is. */
.entries {
  display: grid;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.entry {
  display: grid;
  gap: 0.15rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--bg);
  color: inherit;
  text-decoration: none;
}

.entry:hover {
  background: var(--panel);
  border-color: var(--accent-line);
}

.entry:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.entry-label {
  font-size: 1rem;
  font-weight: 600;
}

.entry-detail {
  font-size: 0.82rem;
  color: var(--muted);
}

/* A panel with nothing in it yet says so, rather than showing an empty box that
   reads as something failed to load. */
.panel-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-style: italic;
}

.crumbs {
  margin: 0.2rem 0 0;
  font-size: 0.85rem;
}

.crumbs a { color: inherit; opacity: 0.7; }
.crumbs a:hover { opacity: 1; }

.colophon-links {
  margin: 0.4rem 0 0;
  font-size: 0.82rem;
}

.colophon-links a { color: inherit; opacity: 0.7; }
.colophon-links a:hover { opacity: 1; }

/* The finder ---------------------------------------------------------------- */

/* Wider than reading width. Five columns of trip data do not fit in 46rem
   without wrapping every route onto three lines, and a list whose identifying
   detail is broken across lines is a list nobody reads. On a window narrower
   than the fixed columns, `.form-page main` scrolls sideways - deliberate, and
   the same bargain the Trip form makes. */
.finder { max-width: 56rem; }

.finder h2 { margin-bottom: 0.75rem; }

.finder-label {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.finder input[type="text"] {
  width: 100%;
  /* The box stays at reading width even though the list below it is wider. A
     900px search field is a worse search field. */
  max-width: 46rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-size: 0.95rem;
}

.finder input[type="text"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* The query and modifier boxes each carry a Clear button at their right
   edge - a long rule should not have to be selected and deleted by hand.
   The input keeps its reading-width cap; the button sits just past it. */
.finder-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.finder-field input[type="text"] {
  flex: 0 1 auto;
  min-width: 0;
}

.finder-field .btn { flex: none; }

/* Touch lane (the fluid design): a coarse pointer never gets a sub-16px
   search field - the browser zooms the page on focus, which moves the caret and
   reads as a lost character. Same floor the trip form's fields carry. */
@media (pointer: coarse) {
  .finder input[type="text"] { font-size: 16px; }
}

.finder-count {
  margin: 0.6rem 0 0.8rem;
  color: var(--muted);
  font-size: 0.82rem;
}

/* The prefix glossary sits between the box and the count: reference material,
   quieter than the count it precedes, and allowed to wrap rather than pushing
   the results down a second line of its own. */
.finder-glossary {
  margin: 0.3rem 0 0.5rem;
  color: var(--muted);
  font-size: 0.78rem;
}

/* Custom Report stacks its elements the way the other multi-element report
   pages do: the query box, the checklist and the report sections are ordinary
   flow `main` scrolls between. `report.css` gives `body.report-page main` a
   flex column under `overflow: hidden` - right for report.html's one table,
   wrong here, where a flex child would be shrink-clipped the way the heatmap
   page's drill-down tables once were. `display: block` is load-bearing for
   the same reason it is there. */
body.report-page.custom-report-page main {
  display: block;
  overflow: auto;
  overscroll-behavior: contain;
}

/* And the box sits where the trip-details picker sits: `.finder`'s
   max-width alone leaves it hugging the left edge of a wide window, so it
   centres at reading width the same way `.trip-details-page .finder` does. */
.custom-report-page .finder {
  margin-inline: auto;
}

/* A message carried in from a page that has just been left - currently only
   cancelling the trip form, which arrives here as a query parameter.

   Styled to read as an aside rather than as a heading: it is something that
   happened, not something to act on. It sits above the panels and is the first
   thing on the page when it is there, because it is the answer to what the user
   just asked. */
.notice {
  margin: 0 0 1.25rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  background: var(--bg);
  color: var(--muted);
  font-size: 0.9rem;
}

.notice[hidden] {
  display: none;
}

.finder-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--rule);
  border-radius: 6px;
  overflow: hidden;
}

.finder-list:empty { border: 0; }

/* Five columns, all the same width, and the same width on every row.

   A grid track is already identical on every row, so the raggedness was never the
   tracks - it was the cells inside them. `text-align: right` put "Bus" and "Rental
   With Driver" at different x positions in the same 8rem, which reads as a table
   whose columns do not line up. So: every cell left-aligned at the left edge of
   its track, and text that does not fit wrapping inside the track rather than
   being ellipsised away. Nothing is hidden.

   The tracks were then sized from the data - 5rem for a five-digit trip number,
   6.5rem for a date, 9rem for the longest mode, 17rem for the longest vehicle
   label - which made every column a different width. Asked for as they are now:
   one size for all five, so `repeat(5, minmax(0, 1fr))`. The cost is that the
   trip number and the date sit in tracks wider than they need, which is the
   cheaper of the two ways to be wrong: a ragged row is harder to read down than
   a roomy one is to read across. */
.finder-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.75rem;
  align-items: baseline;
  padding: 0.45rem 0.7rem;
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
}

.finder-list li:last-child .finder-row { border-bottom: 0; }

.finder-row:hover { background: var(--panel); }

.finder-row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* The Trip Number is the one thing a finder row is for - it is the link target -
   so it is the one thing in bold. */
.finder-id {
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}

.finder-when {
  font-variant-numeric: tabular-nums;
  font-size: 0.88rem;
}

.finder-where,
.finder-how,
.finder-vehicle { overflow-wrap: anywhere; }

/* The mode is a quiet tail. The vehicle is not greyed: on a day with three
   flights it is the column that tells them apart, and greying out the thing
   that decides the row is the wrong way round. */
.finder-how {
  color: var(--muted);
  font-size: 0.82rem;
}

.finder-vehicle { font-size: 0.85rem; }

@media (max-width: 768px) {
  /* Below this the five columns are unreadable, and the route is the part that
     identifies a trip. The date drops under the number and the mode goes
     beside it; the vehicle runs the full width underneath rather than being
     hidden, because dropping the column that says which car it was would lose
     the reason the column was added.

     `.finder-where` is placed explicitly. It was auto-placed before, and with
     every other cell given a row the route landed in row 2 with an empty cell
     above it. */
  .finder-row {
    grid-template-columns: 4.5rem minmax(0, 1fr);
    row-gap: 0.1rem;
  }
  .finder-where { grid-column: 2; grid-row: 1; }
  .finder-when { grid-column: 1; grid-row: 2; }
  .finder-how { grid-column: 2; grid-row: 2; }
  .finder-vehicle { grid-column: 1 / -1; grid-row: 3; }
}

/* The Custom Report checklist ------------------------------------------------
   One row per matching trip: the tick, then the trip read the way the finder
   reads it - number and start, the route, and a quiet mode/vehicle tail. The
   list scrolls inside the page rather than growing it without bound, because
   a query can legitimately match every trip in the database. */

.query-actions { margin: 0.6rem 0 0.4rem; }

.cr-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}

.trip-checklist {
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--rule);
  border-radius: 6px;
  overflow: auto;
  max-height: 26rem;
}

.trip-checklist:empty { border: 0; }

.trip-check {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.4rem 0.7rem;
  border-bottom: 1px solid var(--rule);
  cursor: pointer;
}

.trip-checklist li:last-child .trip-check { border-bottom: 0; }

.trip-check:hover { background: var(--panel); }

.trip-check input[type="checkbox"] {
  flex: none;
  align-self: center;
}

.trip-check-text {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  flex-wrap: wrap;
  min-width: 0;
}

.trip-check-head {
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  white-space: nowrap;
}

.trip-check-route { overflow-wrap: anywhere; }

.trip-check .muted { font-size: 0.82rem; }

/* The Custom Report field glossary: a dialog rather than a line under the
   box, because the prefix list outgrew one. Same dialog language as the
   record modals - bordered panel on a dimmed backdrop - but sized for a
   reference list, not a form. */
.glossary-dialog {
  width: min(46rem, calc(100vw - 4rem));
  max-height: calc(100dvh - 4rem);
  margin: auto;
  padding: 1rem 1.2rem 1.2rem;
  border: 1px solid var(--accent-line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--fg);
  box-shadow: 0 18px 50px rgb(0 0 0 / 0.28);
}

.glossary-dialog::backdrop { background: rgb(0 0 0 / 0.45); }

.glossary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.6rem;
}

.glossary-head h2 { margin: 0; font-size: 1.05rem; }

.glossary-body {
  overflow-y: auto;
  max-height: 60dvh;
  display: grid;
  gap: 0.35rem;
}

.glossary-section {
  margin: 0.7rem 0 0.1rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.glossary-section:first-child { margin-top: 0; }

/* Each entry is a button: the whole row is the target, the prefix reads as
   code so it cannot be mistaken for the description beside it. */
.glossary-term {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  width: 100%;
  padding: 0.28rem 0.45rem;
  border: 0;
  border-radius: 5px;
  background: none;
  color: var(--fg);
  font: inherit;
  font-size: 0.85rem;
  text-align: left;
  cursor: pointer;
}

.glossary-term:hover { background: var(--accent-soft); }

.glossary-term code {
  flex: none;
  min-width: 6.5rem;
  font-weight: 700;
  color: var(--accent);
}

/* Google Drive connection status on the home page --------------------------- */

.auth-line {
  margin: 0 0 1.25rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  background: var(--bg);
  color: var(--muted);
  font-size: 0.9rem;
}

.auth-line[hidden] {
  display: none;
}

.auth-status {
  margin: 0;
}

.auth-status a {
  color: var(--accent);
  text-decoration: underline;
}

.auth-status a:hover {
  filter: brightness(1.15);
}

.auth-signout {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: inherit;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
}

.auth-signout:hover {
  color: var(--fg);
}

.auth-download {
  margin: 0.5rem 0 0;
  padding: 0;
}

.auth-download-button {
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--accent-line);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  margin-left: 0.5rem;
}

.auth-download-button:hover:not(:disabled) {
  filter: brightness(1.1);
}

.auth-download-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Wipe the Database - styled as the form's secondary/Cancel button, since it
   is the destructive counterpart to the accent-filled actions: panel fill on
   a rule border, rule fill on hover, accent focus ring, muted when disabled. */
.auth-wipe {
  margin: 0.5rem 0 0;
  padding: 0;
}

.auth-wipe-button {
  padding: 0.5rem 1.1rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--panel);
  color: var(--fg);
  font: inherit;
  font-size: 0.92rem;
  line-height: 1.2;
  cursor: pointer;
  margin-left: 0.5rem;
}

.auth-wipe-button:hover:not(:disabled) {
  background: var(--rule);
}

.auth-wipe-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.auth-wipe-button:disabled {
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.55;
}

/* Connect page ------------------------------------------------------------- */

.connect-panel {
  max-width: 36rem;
  margin: 0 auto;
  padding: 1.5rem;
  border: 1px solid var(--accent-line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent-soft) 45%, transparent);
}

.connect-panel p {
  margin: 0 0 1rem;
  line-height: 1.5;
}

.connect-note {
  font-size: 0.88rem;
  color: var(--muted);
}

.connect-status {
  margin: 1rem 0;
  padding: 0.6rem 0.85rem;
  border-radius: 6px;
  font-size: 0.9rem;
}

.connect-status[data-kind="error"] {
  background: color-mix(in srgb, var(--fail) 15%, transparent);
  border: 1px solid var(--fail);
  color: var(--fg);
}

.connect-status[data-kind="ok"] {
  background: color-mix(in srgb, var(--pass) 15%, transparent);
  border: 1px solid var(--pass);
  color: var(--fg);
}

.connect-status[data-kind="info"] {
  background: var(--panel);
  border: 1px solid var(--rule);
  color: var(--muted);
}

.connect-actions {
  margin: 1.5rem 0 0;
}

.connect-button {
  padding: 0.65rem 1.25rem;
  border: 1px solid var(--accent-line);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.connect-button:hover:not(:disabled) {
  filter: brightness(1.1);
}

.connect-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* The Drive-file pick over a stored copy (`applyChosenFile` in js/home.js).
   The landing page loads only app.css and home.css, so the trip form's
   `.record-modal` rules are not here; this dialog gets its own compact block
   rather than pulling the whole form stylesheet onto the opening page. */
.import-choice-dialog {
  width: min(36rem, calc(100vw - 3rem));
  max-height: calc(100dvh - 3rem);
  overflow-y: auto;
  padding: 1.25rem 1.35rem 1.1rem;
  border: 1px solid var(--accent-line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--fg);
  box-shadow: 0 18px 50px rgb(0 0 0 / 0.28);
}

.import-choice-dialog::backdrop {
  background: rgb(0 0 0 / 0.45);
}

.import-choice-dialog h2 {
  margin: 0 0 0.6rem;
  font-size: 1.15rem;
}

.import-choice-dialog p {
  margin: 0 0 0.6rem;
}

.import-choice-dialog ul {
  margin: 0 0 1rem;
  padding-left: 1.25rem;
}

.import-choice-dialog li {
  margin-bottom: 0.45rem;
}

.import-choice-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: flex-end;
}

.import-choice-actions button {
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  cursor: pointer;
}

.import-choice-actions button:hover:not(:disabled) {
  background: var(--rule);
}

.import-choice-actions button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.import-choice-actions button.primary:hover:not(:disabled) {
  filter: brightness(1.08);
}

/* The shared notice/confirm dialogs (`js/forms/message-dialog.js`) carry
   `.record-modal`, whose rules live in form.css - not loaded on this page.
   They get the same chrome as the choice dialog above at the same compact
   size: a two-button question does not need the trip form's 63rem. */
.record-modal.message-modal {
  width: min(36rem, calc(100vw - 3rem));
  max-height: calc(100dvh - 3rem);
  overflow-y: auto;
  padding: 1.25rem 1.35rem 1.1rem;
  border: 1px solid var(--accent-line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--fg);
  box-shadow: 0 18px 50px rgb(0 0 0 / 0.28);
}

.record-modal.message-modal::backdrop {
  background: rgb(0 0 0 / 0.45);
}

.record-modal.message-modal h2 {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
  color: var(--accent);
}

.record-modal.message-modal .record-body {
  display: grid;
  gap: 0.6rem;
  margin: 0 0 1rem;
}

.record-modal.message-modal .record-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
}

.record-modal.message-modal .record-buttons button {
  padding: 0.5rem 1.1rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--panel);
  color: var(--fg);
  font: inherit;
  font-size: 0.92rem;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
}

.record-modal.message-modal .record-buttons button:hover:not(:disabled) {
  background: var(--rule);
}

.record-modal.message-modal .record-buttons button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.record-modal.message-modal .record-buttons .primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.record-modal.message-modal .record-buttons .primary:hover:not(:disabled) {
  filter: brightness(1.08);
}
