/* Wait Times Page Specific Styles */
.wait-times-intro {
  color: var(--secondary-color);
  font-size: 17px;
  line-height: 1.5;
  margin-bottom: var(--spacing-unit);
  max-width: 800px;
}

.wait-times-meta p {
  color: var(--secondary-color);
  font-size: 15px;
  line-height: 1.5;
  margin: calc(var(--spacing-unit) * 1.5) 0 var(--spacing-unit);
  max-width: 800px;
}

.wait-times-unavailable {
  color: var(--secondary-color);
  font-size: 17px;
  line-height: 1.5;
  margin: calc(var(--spacing-unit) * 2) 0;
  max-width: 800px;
}

/* Scroll container for mid-width screens. Phones get the stacked-card layout
   further down instead, so they never scroll sideways at all. */
.wait-times-table-wrapper {
  overflow-x: auto;
  margin-bottom: calc(var(--spacing-unit) * 3);
  -webkit-overflow-scrolling: touch;
}

/* NOTE: no `overflow: hidden` here. It was clipping the right-hand column
   instead of letting the wrapper scroll it. The rounded corners are applied to
   the corner cells below rather than by clipping the table. */
.wait-times-table {
  border-collapse: collapse;
  width: 100%;
  min-width: 620px;
  font-size: 16px;
  background-color: rgba(255, 255, 255, 0.6);
  border-radius: 8px;
}

.wait-times-table th,
.wait-times-table td {
  padding: 12px 16px;
  vertical-align: middle;
  border-bottom: 1px solid rgba(93, 93, 95, 0.15);
}

/* Data columns are centred; the centre name stays left aligned because it acts
   as the row's label rather than a value. */
.wait-times-table th,
.wait-times-table td {
  text-align: center;
}

.wait-times-table th:first-child,
.wait-times-table td:first-child {
  text-align: left;
}

.wait-times-table th {
  background-color: var(--primary-color);
  color: white;
  font-weight: 600;
  font-size: 15px;
  line-height: 1.3;
  white-space: nowrap;
}

.wait-times-table thead th:first-child {
  border-top-left-radius: 8px;
}

.wait-times-table thead th:last-child {
  border-top-right-radius: 8px;
}

.wait-times-table td {
  color: var(--secondary-color);
}

/* Every value column is short enough to sit on one line. Wrapping them is what
   made rows three lines tall. */
.wait-times-table td:not(:first-child) {
  white-space: nowrap;
}

/* The centre name is the only long value, so it is capped and allowed to wrap
   rather than stretching the column to fit "Townsville Garbutt CSC". */
.wait-times-table th:first-child,
.wait-times-table td:first-child {
  max-width: 120px;
  white-space: normal;
}

.wait-times-table td:first-child {
  color: var(--accent-color);
  font-weight: 600;
}

.wait-times-table tbody tr:last-child td {
  border-bottom: none;
}

/* Filtering hides rows with the `hidden` attribute, which normally relies on the
   user-agent's `[hidden] { display: none }`. The stacked-card layout below sets
   `display: block` on `tr`, and ANY author declaration beats a user-agent one
   regardless of specificity — so without this rule the filter silently did
   nothing on mobile (every card stayed visible). Stated here, outside the media
   query, so it holds in both layouts; the extra attribute selector outweighs the
   `display: block` rules so source order does not matter. */
.wait-times-table tr[hidden] {
  display: none;
}

.wait-times-section {
  margin-bottom: calc(var(--spacing-unit) * 3);
}

.wait-times-section h2 {
  color: var(--primary-color);
  font-size: 28px;
  font-weight: 600;
  margin: calc(var(--spacing-unit) * 3) 0 var(--spacing-unit);
}

.wait-times-section p,
.wait-times-section li {
  color: var(--secondary-color);
  font-size: 17px;
  line-height: 1.5;
  max-width: 800px;
}

.wait-times-section ul {
  padding-left: calc(var(--spacing-unit) * 1.25);
}

.wait-times-section li {
  margin-bottom: calc(var(--spacing-unit) * 0.75);
}

.wait-times-definitions dt {
  color: var(--accent-color);
  font-size: 18px;
  font-weight: 600;
  margin-top: var(--spacing-unit);
}

.wait-times-definitions dd {
  color: var(--secondary-color);
  font-size: 17px;
  line-height: 1.5;
  margin: 4px 0 0;
  max-width: 800px;
}

.wait-times-links a {
  color: var(--accent-color);
  text-decoration: underline;
}

.wait-times-links a:hover {
  opacity: 0.7;
}

/* Visually hidden but still read by screen readers. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 768px) {
  .wait-times-section h2 {
    font-size: 24px;
  }

  .wait-times-intro,
  .wait-times-section p,
  .wait-times-section li,
  .wait-times-definitions dd {
    font-size: 16px;
  }

  /* Stacked-card layout.
     Six columns cannot fit a phone, and sideways scrolling hides the columns
     that matter. Each row becomes a self-contained card instead, with the
     column name shown against each value via the data-label attribute the
     server already renders. No horizontal scrolling at all. */
  .wait-times-table-wrapper {
    overflow-x: visible;
  }

  .wait-times-table {
    min-width: 0;
    background: none;
    border-radius: 0;
    font-size: 16px;
  }

  /* The header row is replaced by the per-cell labels, so it is removed from
     view. Sorting stays available through the select in the controls above. */
  .wait-times-table thead {
    display: none;
  }

  .wait-times-table tbody,
  .wait-times-table tr,
  .wait-times-table td {
    display: block;
    width: auto;
  }

  .wait-times-table tr {
    margin-bottom: var(--spacing-unit);
    padding: 4px 0;
    background-color: rgba(255, 255, 255, 0.75);
    border: 1px solid rgba(93, 93, 95, 0.15);
    border-radius: 12px;
  }

  /* Cards are narrow, so values wrap again and the desktop width cap on the
     centre name would squash the card heading. */
  .wait-times-table td,
  .wait-times-table td:not(:first-child) {
    white-space: normal;
  }

  .wait-times-table td:first-child {
    max-width: none;
  }

  .wait-times-table td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--spacing-unit);
    padding: 8px 14px;
    border-bottom: 1px solid rgba(93, 93, 95, 0.1);
    text-align: right;
  }

  .wait-times-table td::before {
    content: attr(data-label);
    flex-shrink: 0;
    color: var(--secondary-color);
    font-size: 14px;
    font-weight: 600;
    text-align: left;
  }

  .wait-times-table tr td:last-child {
    border-bottom: none;
  }

  /* The centre name heads the card rather than sitting in a label/value pair. */
  .wait-times-table td:first-child {
    display: block;
    padding: 12px 14px 10px;
    font-size: 18px;
    text-align: left;
    background-color: rgba(0, 184, 147, 0.09);
    border-radius: 11px 11px 0 0;
  }

  .wait-times-table td:first-child::before {
    display: none;
  }

  /* The column tint is meaningless once each row is its own card. */
  .wait-times-table td.is-sorted-column {
    background-color: transparent;
    color: var(--secondary-color);
  }

  .wait-times-table td:first-child.is-sorted-column {
    background-color: rgba(0, 184, 147, 0.09);
    color: var(--accent-color);
  }
}

/* Trend column. Colour is a secondary cue only — the cell always states the
   direction in words, so meaning never depends on colour alone. */
.wait-trend-rising {
  color: #b4341f;
  font-weight: 600;
}

.wait-trend-falling {
  color: #0f7a53;
  font-weight: 600;
}

.wait-trend-steady,
.wait-trend-unknown {
  color: var(--secondary-color);
}

/* --- Filter control (revealed by wait-times.js; hidden without JS) --- */
.wait-times-controls {
  margin: calc(var(--spacing-unit) * 1.5) 0 var(--spacing-unit);
  max-width: 520px;
}

.wait-times-filter-label {
  display: block;
  color: var(--accent-color);
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
}

.wait-times-filter {
  width: 100%;
  padding: 10px 14px;
  font-size: 16px; /* >=16px stops iOS Safari zooming the page on focus */
  font-family: inherit;
  color: var(--accent-color);
  background-color: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(93, 93, 95, 0.3);
  border-radius: 8px;
}

.wait-times-filter:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 1px;
  border-color: var(--primary-color);
}

.wait-times-filter-status {
  color: var(--secondary-color);
  font-size: 15px;
  margin: 6px 0 0;
  min-height: 1.4em; /* reserve space so results don't shift the table */
}

/* --- Sortable headings --- */
/* display:flex, not inline-flex. As an inline-level box with width:100% inside
   a table cell (which sizes to its content) the width resolves ambiguously, so
   justify-content centred against the wrong box and the labels sat off-centre.
   A block-level flex container fills the cell and centres reliably. */
.wait-times-sort-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 0;
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  /* Toggling sort direction means clicking the same heading twice, which the
     browser treats as a double-click and selects the label text. That renders
     as a blue highlight over the heading. */
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.wait-times-table th:first-child .wait-times-sort-button {
  justify-content: flex-start;
}

/* Keep the keyboard focus ring, but as a thin underline rather than a heavy
   ring that reads as a selected/hover state. */
.wait-times-sort-button:focus {
  outline: none;
}

.wait-times-sort-button:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.9);
  outline-offset: 3px;
  border-radius: 3px;
}

.wait-times-sort-button:hover .wait-times-sort-icon {
  opacity: 1;
}

/* Neutral state shows a faint double arrow so the column reads as sortable
   before it is used. Kept low-contrast so six of them don't shout. */
.wait-times-sort-icon {
  font-size: 11px;
  line-height: 1;
  opacity: 0.55;
}

.wait-times-sort-icon::after {
  content: '↑↓';
  letter-spacing: -2px;
}

/* Active state: the arrow goes solid and a white underline marks the column.
   Deliberately NOT a different background colour — a dark block against the
   teal header row reads as a rendering fault rather than a selection. */
.wait-times-table th.is-sorted {
  box-shadow: inset 0 -3px 0 rgba(255, 255, 255, 0.9);
}

.wait-times-table th.is-sorted .wait-times-sort-icon {
  opacity: 1;
}

.wait-times-table th.is-sorted .wait-times-sort-icon::after {
  content: '↑';
  letter-spacing: normal;
}

.wait-times-table th.is-sorted-desc .wait-times-sort-icon::after {
  content: '↓';
}

/* Subtle tint on the sorted column's cells so the eye can follow it down the
   table without the header itself changing colour. */
.wait-times-table td.is-sorted-column {
  background-color: rgba(0, 184, 147, 0.07);
  color: var(--accent-color);
}

/* Mobile sort control. Hidden on desktop, where the column headings already
   provide sorting; shown on small screens where the headings are not visible. */
.wait-times-sort-select-wrap {
  display: none;
  margin-top: var(--spacing-unit);
}

.wait-times-sort-select {
  width: 100%;
  padding: 10px 14px;
  font-size: 16px;
  font-family: inherit;
  color: var(--accent-color);
  background-color: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(93, 93, 95, 0.3);
  border-radius: 8px;
}

.wait-times-sort-select:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 1px;
}

@media (max-width: 768px) {
  .wait-times-sort-select-wrap {
    display: block;
  }
}
