:root {
  --paper: #e4e9e4;
  --sheet: #f4f7f4;
  --ink: #1d2a26;
  --muted: #53625c;
  --rule: #b3bdb6;
  --marigold: #e8a33d;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: "Avenir Next", "Gill Sans", "Trebuchet MS", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

/* Layout */

.app {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 72px;
  max-width: 1160px;
  margin: 0 auto;
  padding: 56px 48px 96px;
}

.masthead {
  position: sticky;
  top: 48px;
  align-self: start;
}

.name {
  margin: 0 0 20px;
  font: 400 clamp(2.75rem, 4.6vw, 4rem)/0.95 var(--serif);
  letter-spacing: -0.02em;
}

.lede {
  margin: 0 0 40px;
  max-width: 30ch;
  color: var(--muted);
  font-size: 1.0625rem;
}

.controls {
  display: grid;
  gap: 20px;
}

.field {
  display: grid;
  gap: 8px;
}

.field label {
  font-size: 0.9375rem;
  font-weight: 600;
}

.field input,
.field select {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: var(--sheet);
}

/* Controls */

.toggle,
.button {
  height: 48px;
  padding: 0 18px;
  border: 1px solid var(--ink);
  border-radius: 0;
  cursor: pointer;
  font-weight: 600;
}

.toggle {
  background: transparent;
  text-align: left;
}

.toggle[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
}

.button {
  background: var(--ink);
  color: var(--paper);
}

.button.ghost {
  background: transparent;
  color: var(--ink);
}

.button.save[aria-pressed="true"] {
  background: var(--marigold);
  color: var(--ink);
}

/* Timetable list */

.result-count {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.9375rem;
}

.day + .day {
  margin-top: 56px;
}

.day-title {
  margin: 0;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--ink);
  font: 400 1.625rem/1.2 var(--serif);
}

.list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.row {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) 140px;
  gap: 28px;
  padding: 24px 0;
  border-bottom: 1px solid var(--rule);
}

.start {
  margin: 0;
  font: 400 1.75rem/1 var(--serif);
  font-variant-numeric: lining-nums tabular-nums;
}

.until {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font: 400 0.875rem/1.4 var(--sans);
}

.title {
  margin: 0;
  font: 400 1.4375rem/1.2 var(--serif);
}

.title button {
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

.title button:hover {
  text-decoration-thickness: 2px;
}

.place {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.9375rem;
}

.summary {
  margin: 8px 0 0;
  max-width: 60ch;
}

.side {
  display: grid;
  justify-items: end;
  align-content: start;
  gap: 6px;
  font-size: 0.9375rem;
  text-align: right;
}

.category {
  font-weight: 600;
}

.price {
  color: var(--muted);
}

.saved-mark {
  margin-top: 6px;
  padding: 3px 8px;
  background: var(--marigold);
  color: var(--ink);
  font-size: 0.8125rem;
  font-weight: 600;
}

/* Empty state */

.empty {
  padding: 48px 0;
  border-top: 2px solid var(--ink);
}

.empty p {
  max-width: 28ch;
  margin: 0 0 20px;
  font: 400 1.375rem/1.35 var(--serif);
}

/* Detail dialog */

dialog {
  width: min(660px, calc(100vw - 48px));
  max-height: calc(100vh - 64px);
  margin: auto;
  padding: 0;
  border: 0;
  background: var(--sheet);
  color: var(--ink);
  overflow: auto;
  box-shadow: 0 30px 80px -30px rgba(29, 42, 38, 0.5);
}

dialog::backdrop {
  background: rgba(29, 42, 38, 0.45);
}

dialog[open] {
  animation: lift 0.24s cubic-bezier(0.2, 0.7, 0.2, 1);
}

@keyframes lift {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

.detail-inner {
  padding: 32px 36px 40px;
}

.detail-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.detail-title {
  margin: 20px 0 0;
  font: 400 2rem/1.15 var(--serif);
  letter-spacing: -0.01em;
}

.detail-title:focus {
  outline: none;
}

.facts {
  margin: 24px 0;
  border-top: 2px solid var(--ink);
}

.facts div {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--rule);
}

.facts dt {
  color: var(--muted);
}

.facts dd {
  margin: 0;
}

.detail-inner .save {
  margin-bottom: 32px;
}

.detail-body {
  max-width: 60ch;
  white-space: pre-line;
  font-size: 1.0625rem;
  line-height: 1.65;
}

/* Small screens */

@media (max-width: 800px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
    gap: 40px;
    padding: 32px 20px 72px;
  }

  .masthead {
    position: static;
  }

  .name {
    font-size: 2.75rem;
  }

  .lede {
    margin-bottom: 28px;
  }

  .row {
    grid-template-columns: 64px minmax(0, 1fr);
    gap: 16px;
  }

  .start {
    font-size: 1.4rem;
  }

  .side {
    grid-column: 2;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-items: start;
    gap: 4px 12px;
    text-align: left;
  }

  .saved-mark {
    margin-top: 0;
  }

  dialog {
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
  }

  .detail-inner {
    padding: 24px 20px 40px;
  }

  .facts div {
    grid-template-columns: 80px minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  dialog[open] {
    animation: none;
  }
}
