/* Hark's trip components: the airline in a flight table's first column, the flight table's day marker, a day of plans in the library's timeline, and the white cards a trip page sets its tables, days and to-book list on. They use hark.css's tokens, so link this after hark.css. style-gates: data */

/* @component carrier */
/* The airline's logo, or its two-letter code on a tile when there is no logo, beside the flight's
   name and the airline under it. */
.carrier {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.carrier__logo {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  object-fit: contain;
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--stroke-secondary);
}
.carrier__code {
  flex: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--fill-tertiary);
  font: var(--type-tag);
  color: var(--text-secondary);
}
.carrier small {
  font-weight: var(--weight-regular);
}
/* A highlighted row is the tile's own grey, so its tile takes the page's ground instead. */
tr.is-highlight .carrier__code {
  background: var(--fill-primary-on);
}

/* @component flights */
/* The day marker after a landing time, such as +1. */
.flights sup {
  font: var(--type-caption);
  color: var(--text-secondary);
  vertical-align: 4px;
  margin-left: 2px;
}

/* @component day */
/* A day in the library's timeline: its theme and an optional photo under the date, and its plans
   in the content column, each a time, what it is, a note, and an optional pill. */
.day__when {
  display: grid;
  align-content: start;
  gap: 4px;
  min-width: 0;
}
.day__theme {
  padding-left: 20px;
  font: var(--type-small);
  color: var(--text-secondary);
}
.day__photo {
  width: 100%;
  aspect-ratio: 4 / 3;
  margin-top: 8px;
  border-radius: var(--r-s);
  object-fit: cover;
  background: var(--fill-tertiary);
}
.plans {
  display: grid;
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.timeline__what .plans > li {
  margin-bottom: 0;
}
/* A day's note, before or after its plans, lines up with the plans' names and keeps a gap from them. */
.timeline__what > :not(.plans, .day__toggle) {
  margin-left: calc(76px + 16px);
}
.timeline__what > .plans + *,
.timeline__what > * + .plans {
  margin-top: 12px;
}
.plan {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) auto;
  gap: 4px 16px;
  align-items: start;
}
.plan__time {
  font: var(--type-small);
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  padding-top: 1px;
}
.plan__what {
  font: var(--type-body-strong);
}
.plan__note {
  display: block;
  margin-top: 2px;
  font: var(--type-small);
  color: var(--text-secondary);
}
/* A plan's price and length as small grey chips beside its name. */
.plan__fact {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: var(--r-pill);
  background: var(--fill-tertiary);
  font: var(--type-caption);
  color: var(--text-secondary);
  white-space: nowrap;
  vertical-align: 2px;
}
/* What to do before going sits at the plan's right as an outlined tag; a booked plan's is solid. */
.plan > :is(.pill, .chip) {
  justify-self: end;
  white-space: nowrap;
}
.plan > .pill {
  background: none;
  box-shadow: inset 0 0 0 1px var(--stroke-primary);
}
@media (max-width: 899px) {
  .day__photo {
    width: calc(100% - 20px);
    margin-left: 20px;
    aspect-ratio: 16 / 9;
  }
}
/* hark.js adds a day's toggle and opens the first day. The toggle shows only on a phone, where a
   closed day lists each plan's time and title and keeps its notes and pills for when it opens. */
.day__toggle {
  display: none;
}
@media (max-width: 599px) {
  .timeline__what > :not(.plans, .day__toggle) {
    margin-left: 0;
  }
  .plan {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }
  .plan__time {
    font: var(--type-caption);
    white-space: normal;
  }
  .plan > :is(.pill, .chip) {
    justify-self: start;
    margin-top: 4px;
  }
  .js .timeline > li:not(.is-open) .plans {
    gap: 8px;
  }
  .js .timeline > li:not(.is-open) .plan {
    grid-template-columns: 72px minmax(0, 1fr);
    column-gap: 12px;
  }
  .js .timeline > li:not(.is-open) .plan__time {
    font: var(--type-small);
    padding-top: 2px;
  }
  .js .timeline > li:not(.is-open) .plan__what {
    font: var(--type-body);
  }
  .js
    .timeline
    > li:not(.is-open)
    :is(.plan__note, .plan > .pill, .plan > .chip, .timeline__what > :not(.plans, .day__toggle)) {
    display: none;
  }
  .day__toggle {
    display: block;
    margin-top: 10px;
    padding: 0;
    border: 0;
    background: none;
    font: var(--type-small);
    font-weight: var(--weight-medium);
    color: var(--text-primary);
    text-decoration: underline;
    text-decoration-color: var(--stroke-primary);
    text-underline-offset: 3px;
    cursor: pointer;
  }
}

/* @component flight ticket */
/* On a phone each flight row becomes a ticket: the carrier across the top, one line per leg with
   its date, and a foot with the price beside the button. Order keeps that foot last whatever
   columns the page adds. A row's plain "Not booked" chip drops out; a booked chip stays. */
@media (max-width: 599px) {
  .table-wrap .flights tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 12px;
    padding: 16px 0;
  }
  .table-wrap .flights tbody tr.is-highlight {
    padding-inline: 12px;
  }
  .table-wrap .flights tbody tr > * {
    grid-column: 1 / -1;
  }
  .table-wrap .flights tbody td:not(.num, :has(.btn))[data-label]::before {
    display: inline;
    content: attr(data-label) ' \00b7  ';
    font-size: var(--size-small);
  }
  .table-wrap .flights tbody td > span {
    font-weight: var(--weight-bold);
  }
  .table-wrap .flights tbody td.num {
    order: 10;
    grid-column: 1;
    align-self: center;
    margin-top: 4px;
    font-size: 18px;
  }
  .table-wrap .flights tbody td.num small {
    font-size: var(--size-caption);
    font-weight: var(--weight-regular);
  }
  .table-wrap .flights tbody td:is(:has(> .btn), :has(> .link:only-child)) {
    order: 11;
    grid-column: 2;
    align-self: center;
    margin-top: 4px;
  }
  .table-wrap .flights tbody td:is(.num, :has(> .btn), :has(> .link:only-child))::before {
    display: none;
  }
  /* The link under the button keeps its full tap height, so it needs no gap of its own. */
  .table-wrap .flights tbody td:has(> .btn) > .link {
    display: flex;
    justify-content: center;
    width: auto;
    margin: 0;
  }
  .table-wrap .flights tbody td:has(> .btn) .btn {
    min-height: 40px;
    padding-inline: 16px;
    font-size: var(--size-small);
  }
  .table-wrap .flights .carrier small {
    display: inline;
    margin: 0;
  }
  .table-wrap .flights .carrier small::before {
    content: '  \00b7  ';
  }
  .table-wrap .flights .carrier .chip {
    margin-left: 6px;
    vertical-align: 1px;
  }
  .table-wrap tbody td:has(> .chip:only-child:not(.chip--solid)),
  .table-wrap .flights tbody td .chip:not(.chip--solid),
  .photo-card__meta .chip:not(.chip--solid) {
    display: none;
  }
}

/* @component trip cards */
/* A trip page sets its tables, its days and its to-book list on raised white cards. A tag in a
   table reads as words under the name, and a row's Hark button sits at its right. */
:root {
  --trip-card: light-dark(#ffffff, #262628);
  --trip-card-edge:
    0 1px 3px light-dark(#1d1d1f0a, #00000033), inset 0 0 0 1px var(--stroke-secondary);
}
.table-wrap,
.timeline,
.checklist {
  border-radius: var(--r-l);
  background: var(--trip-card);
  box-shadow: var(--trip-card-edge);
}
.table-wrap {
  margin-inline: 0;
  padding: 8px 12px;
}
.timeline,
.checklist {
  padding: 8px 24px;
}
.table-wrap table {
  border-collapse: separate;
  border-spacing: 0;
}
.table-wrap :is(th, td),
.table-wrap :is(th, td):is(:first-child, :last-child) {
  padding: 14px 12px;
}
.table-wrap thead :is(th, td) {
  padding-top: 16px;
  padding-bottom: 12px;
  font: var(--type-small);
  color: var(--text-secondary);
  border-bottom-color: var(--stroke-secondary);
}
.table-wrap caption {
  padding: 14px 12px 0;
}
.table-wrap tr.is-highlight > :is(*, :first-child, :last-child) {
  box-shadow: none;
  border-bottom-color: transparent;
}
.table-wrap tr.is-highlight > :first-child {
  border-radius: 12px 0 0 12px;
}
.table-wrap tr.is-highlight > :last-child {
  border-radius: 0 12px 12px 0;
}
.table-wrap tbody tr:has(+ tr.is-highlight) > * {
  border-bottom-color: transparent;
}
.table-wrap .flights td.num {
  color: var(--fill-system-green);
  font: var(--type-body-strong);
}
.table-wrap .flights td.num small {
  color: var(--text-secondary);
}
.table-wrap .chip:not(.chip--solid) {
  display: block;
  width: fit-content;
  margin-top: 2px;
  padding: 0;
  background: none;
  font: var(--type-caption);
  color: var(--text-secondary);
}
.table-wrap .chip:not(.chip--solid)::before {
  display: none;
}
.table-wrap .chip--solid {
  display: flex;
  width: fit-content;
  margin-top: 4px;
  padding: 0;
  background: none;
  font: var(--type-tag);
  color: var(--text-primary);
}
.table-wrap .btn[data-hark-action] {
  min-height: 36px;
  padding: 0 16px;
  font: var(--type-label);
}
/* A row's link cell is a column as narrow as its widest part: the Hark button, then the site's link
   centred under it, as on a shop card. A flight with only the link centres it in the same column. */
.table-wrap td:has(> .btn),
.table-wrap .flights td:has(> .link:only-child) {
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
}
.table-wrap td:has(> .btn) > .link {
  display: block;
  width: fit-content;
  margin: 6px auto 0;
}
@media (min-width: 600px) {
  .table-wrap td:has(> .btn),
  .table-wrap .flights td:has(> .link:only-child) {
    width: 1%;
  }
}
.timeline > li {
  padding-top: 24px;
  padding-bottom: 24px;
}
.timeline > li:first-child {
  padding-top: 20px;
}
.timeline > li:last-child {
  padding-bottom: 20px;
}
.checklist > li {
  padding-top: 16px;
  padding-bottom: 16px;
}
/* Between a phone and a desktop, less padding lets a five-column flight table fit its card. */
@media (min-width: 600px) and (max-width: 899px) {
  .table-wrap {
    padding-inline: 6px;
  }
  .table-wrap :is(th, td),
  .table-wrap :is(th, td):is(:first-child, :last-child) {
    padding-inline: 8px;
  }
  /* The card's radius less its 6px padding, so a highlighted row's corners run parallel to the card's. */
  .table-wrap tr.is-highlight > :first-child {
    border-radius: calc(var(--r-l) - 6px) 0 0 calc(var(--r-l) - 6px);
  }
  .table-wrap tr.is-highlight > :last-child {
    border-radius: 0 calc(var(--r-l) - 6px) calc(var(--r-l) - 6px) 0;
  }
}
@media (max-width: 599px) {
  .table-wrap,
  .timeline,
  .checklist {
    padding: 4px 16px;
  }
  .table-wrap tbody tr:last-child {
    border-bottom: 0;
  }
  /* The card's radius less the 4px between the row and the card's edge, so the corners run parallel. */
  .table-wrap tbody tr.is-highlight {
    border-radius: calc(var(--r-l) - 4px);
  }
  .table-wrap tbody tr > :is(*, :first-child, :last-child) {
    padding: 0;
  }
  .table-wrap tbody tr:has(+ tr.is-highlight) {
    border-bottom-color: transparent;
  }
}
