:root {
  color-scheme: light dark;
  --bg: #fafaf9;
  --fg: #1c1917;
  --muted: #57534e;
  --accent: #c2410c;
  --border: #e7e5e4;
  --field: #ffffff;
  --error: #b91c1c;
  --ok: #15803d;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1917;
    --fg: #f5f5f4;
    --muted: #a8a29e;
    --accent: #fb923c;
    --border: #44403c;
    --field: #292524;
    --error: #f87171;
    --ok: #4ade80;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
}

header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 600;
  color: inherit;
  text-decoration: none;
}

header nav,
.account {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 1rem;
}

header nav a[aria-current="page"] {
  font-weight: 600;
  text-decoration: none;
}

.account form {
  display: inline;
}

a {
  color: var(--accent);
}

main {
  max-width: 60rem;
  margin: 0 auto;
  padding: 1rem;
}

h1 {
  margin: 0.5rem 0;
}

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

#map {
  height: min(70vh, 40rem);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  overflow: hidden;
}

/* The map popups keep MapLibre's light look in dark mode, so their text must stay dark. */
.maplibregl-popup-content {
  color: #1c1917;
}

/* /map: only the map, filling the iframe. */
body.embed,
body.embed #map {
  height: 100vh;
  border: 0;
  border-radius: 0;
}

h2 {
  margin: 2rem 0 0.5rem;
}

footer {
  max-width: 60rem;
  margin: 2rem auto 0;
  padding: 1rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.875rem;
}

.hint,
small {
  color: var(--muted);
}

.hint {
  margin: 0.25rem 0 0;
  font-size: 0.875rem;
}

.error {
  color: var(--error);
  font-weight: 600;
}

.done {
  color: var(--ok);
  font-weight: 600;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Buttons, and links that look like them */
button,
.button {
  display: inline-block;
  padding: 0.5rem 1rem;
  border: 0;
  border-radius: 0.375rem;
  background: var(--accent);
  color: #ffffff;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

@media (prefers-color-scheme: dark) {
  button,
  .button {
    color: #1c1917;
  }
}

button.link {
  padding: 0;
  background: none;
  color: var(--accent);
  font-weight: normal;
  text-decoration: underline;
}

button.danger {
  background: var(--error);
}

.buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
}

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

/* Ride list */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 0.5rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

tr.full td {
  color: var(--muted);
}

td.note {
  max-width: 20rem;
  overflow-wrap: anywhere;
}

td.actions a {
  margin-right: 0.75rem;
  white-space: nowrap;
}

/* Ride form */
.ride-form {
  max-width: 32rem;
}

.field {
  position: relative;
  margin-bottom: 1.25rem;
}

label {
  display: block;
  font-weight: 600;
}

input:not([type="radio"]),
select,
textarea {
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.5rem;
  border: 1px solid var(--muted);
  border-radius: 0.375rem;
  background: var(--field);
  color: inherit;
  font: inherit;
}

.invalid input,
.invalid select,
.invalid textarea {
  border: 2px solid var(--error);
}

fieldset {
  margin: 0 0 1.25rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
}

legend {
  font-weight: 600;
}

fieldset label {
  font-weight: normal;
  padding: 0.25rem 0;
}

.choices {
  margin-top: -0.5rem;
}

/* Suggestions under the place field (src/client/places.ts) */
.place-options {
  position: absolute;
  z-index: 10;
  left: 0;
  right: 0;
  max-height: 18rem;
  margin: 0.25rem 0 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
  border: 1px solid var(--muted);
  border-radius: 0.375rem;
  background: var(--field);
  box-shadow: 0 4px 12px rgb(0 0 0 / 0.15);
}

.place-options li {
  padding: 0.5rem;
  cursor: pointer;
}

.place-options li[aria-selected="true"],
.place-options li:hover {
  background: var(--accent);
  color: #ffffff;
}

.place-options li[aria-selected="true"] small,
.place-options li:hover small {
  color: inherit;
}

/* Rides near you */
.near-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.near-input {
  position: relative;
  flex: 1 1 14rem;
}

.near-input input {
  width: 100%;
}

/* Map popups */
.ride-popup .ride,
.ride-popup section + section {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid #e7e5e4;
}

.ride-popup section + section {
  border-top-width: 2px;
}

.ride-popup .route {
  color: #57534e;
  font-size: 0.875em;
}

.ride-popup {
  max-height: 20rem;
  overflow-y: auto;
}

.ride-popup .open {
  color: #15803d;
}

.ride-popup .full {
  color: #78716c;
}

.ride-popup .note {
  font-style: italic;
  overflow-wrap: anywhere;
}

/* Room for the popup's close button */
.ride-popup {
  padding-right: 0.75rem;
}

@media (prefers-color-scheme: dark) {
  .place-options li[aria-selected="true"],
  .place-options li:hover {
    color: #1c1917;
  }
}
