:root {
  color-scheme: light dark;
  --border: #b9b9b9;
  --surface: light-dark(#fff, #1b1b1b);
  --raised: light-dark(#f4f4f4, #262626);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font: 16px/1.5 system-ui, sans-serif;
}

.masthead {
  position: sticky;
  top: 0;
  z-index: 1;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.masthead-inner,
main {
  max-width: 56rem;
  margin: 0 auto;
  padding: 0 1rem;
}

.masthead-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 1rem;
}

.masthead-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* --- GitHub status --- */

.status {
  position: relative;
}

.status-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: ButtonFace;
  color: ButtonText;
  cursor: pointer;
}

.status-dot {
  flex: none;
  width: 0.625rem;
  height: 0.625rem;
  border-radius: 50%;
  background: GrayText;
}

.status-dot[data-level="green"] { background: #2e7d32; }
.status-dot[data-level="yellow"] { background: #b8860b; }
.status-dot[data-level="red"] { background: #c0392b; }

.status-panel {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  z-index: 2;
  width: 20rem;
  max-width: calc(100vw - 2rem);
  gap: 0.75rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.2);
  font-size: 0.875rem;
}

.status-panel:not([hidden]) {
  display: grid;
}

.status-check {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 0.5rem;
}

.status-check-dot {
  grid-row: 1;
  margin-top: 0.3rem;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: GrayText;
}

.status-check-dot[data-level="green"] { background: #2e7d32; }
.status-check-dot[data-level="yellow"] { background: #b8860b; }
.status-check-dot[data-level="red"] { background: #c0392b; }

.status-check-name {
  font-weight: 600;
}

.status-check-detail {
  grid-column: 2;
  margin: 0;
  color: GrayText;
}

.status-panel a {
  color: inherit;
}

main {
  padding-bottom: 4rem;
}

h1 {
  font-size: 1.5rem;
  margin: 0;
}

h2 {
  font-size: 1.125rem;
}

.lede {
  color: GrayText;
  margin: 0;
}

.filters {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1rem;
  padding-block: 1.5rem;
}

.filter {
  font-size: 0.875rem;
}

label {
  display: grid;
  gap: 0.25rem;
  font-weight: 600;
}

input,
textarea,
select {
  font: inherit;
  font-weight: 400;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: Field;
  color: FieldText;
  width: 100%;
}

textarea {
  resize: vertical;
}

/* `:user-invalid` rather than `:invalid` so the empty required fields aren't
   already red the moment the modal opens. */
input:user-invalid {
  border-color: #c0392b;
}

.message {
  color: GrayText;
  padding: 2rem 0;
}

/* --- Location list --- */

.list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr));
  gap: 1rem;
  align-items: start;
}

.location {
  display: grid;
  gap: 0.5rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}

.location header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.location h2 {
  margin: 0;
  font-size: 1rem;
}

.badge {
  flex: none;
  font-size: 0.75rem;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  background: var(--raised);
  color: GrayText;
  white-space: nowrap;
}

.address {
  font-size: 0.875rem;
}

.description {
  margin: 0;
  font-size: 0.875rem;
  color: GrayText;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tags li {
  font-size: 0.75rem;
  padding: 0.125rem 0.375rem;
  border: 1px solid var(--border);
  border-radius: 3px;
}

.contact {
  display: flex;
  gap: 1rem;
  margin: 0;
  font-size: 0.875rem;
}

/* --- Add-a-location modal --- */

dialog {
  width: min(40rem, calc(100vw - 2rem));
  max-height: calc(100vh - 4rem);
  overflow-y: auto;
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: inherit;
}

dialog::backdrop {
  background: rgb(0 0 0 / 0.5);
}

.dialog-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
}

.dialog-head h2 {
  margin: 0;
}

form {
  display: grid;
  gap: 1rem;
  margin-top: 1.5rem;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

button {
  font: inherit;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: ButtonFace;
  color: ButtonText;
  cursor: pointer;
}

button.secondary {
  background: transparent;
}

button.icon {
  flex: none;
  padding: 0 0.5rem;
  font-size: 1.5rem;
  line-height: 1.5;
  border-color: transparent;
  background: transparent;
}

section#output {
  margin-top: 2rem;
  display: grid;
  gap: 0.75rem;
}

section#output h3 {
  margin: 0;
  font-size: 1rem;
}

#csv {
  font-family: ui-monospace, monospace;
  font-size: 0.875rem;
  white-space: pre;
}

#status {
  color: GrayText;
  font-size: 0.875rem;
}

@media (max-width: 34rem) {
  .masthead-inner {
    flex-direction: column;
    align-items: stretch;
  }

  .filters,
  .row {
    grid-template-columns: 1fr;
  }

  /* The status button sits at the left edge of its row here, so anchoring
     the panel from the right (correct when the row hugs the right side of a
     wide header) would push most of it off-screen. */
  .status-panel {
    left: 0;
    right: auto;
  }
}
