:root {
  color-scheme: light dark;
  --color-text: light-dark(black, white);
  --color-background: light-dark(white, #0c1019);
  --color-highlight: light-dark(#1f6ed6, #3681e4);
  --color-highlight-contra: #ffffff;
  --color-note: light-dark(#666666, #999999);
  --color-darken-less: light-dark(rgba(0, 0, 0, 0.01), rgba(0, 0, 0, 0.5));
  --color-darken: light-dark(rgba(0, 0, 0, 0.1), rgba(255, 255, 255, 0.2));
  --color-darken-more: light-dark(rgba(0, 0, 0, 0.2), rgba(255, 255, 255, 0.3));
  --color--warning: #e6007a;
  --fontweight-bold: 600;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji",
    "Segoe UI Emoji", "Segoe UI Symbol";
  line-height: 1.5;
  color: var(--color-text);
  background-color: var(--color-background);
}

* + :is(label, .label, form, p, h1, h2, h3, h4, details, pre, ul, .component, #map) {
  margin-top: 1em;
}

* + :is(section) {
  margin-top: 2em;
}

a {
  color: var(--color-highlight);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1,
h2,
h3,
summary {
  font-weight: var(--fontweight-bold);
}

h2 {
  border-top: 1px solid var(--color-darken-more);
  padding-top: 0.2em;
}

h3 {
  font-size: 1em;
}

ul {
  margin-left: 1em;
}

section,
details {
  position: relative;
}

summary {
  cursor: pointer;
}

svg {
  vertical-align: -0.15em;
  height: 1em;
  width: auto;
}

code,
kbd {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
  background-color: var(--color-darken);
  display: inline-block;
  padding: 0 0.2em;
  border-radius: 0.2em;
  font-size: 0.9em;
}

abbr {
  text-decoration: none;
  border-bottom: 1px dotted;
}

small {
  font-size: 0.5em;
}

#map {
  aspect-ratio: 16/9;
}

missionsgeraet-simbrief {
  display: block;
}

/* Form */

button,
input,
select,
textarea,
output {
  padding: 0.25em;
  border-radius: 0.25em;
  border: 1px solid var(--color-darken-more);
  color: inherit;
  font: inherit;
  display: inline-block;
  width: 100%;
  accent-color: var(--color-highlight);
}

input[type="range"] {
  vertical-align: middle;
}

input[type="number"],
output.number,
input.has-output {
  width: calc(100% - 2.5em);
}

input[type="checkbox"] {
  width: auto;
}

input.has-output + output {
  width: 2em;
  border: none;
  padding: none;
}

:invalid {
  border-color: var(--color--warning);
}

textarea {
  height: 5em;
}

output {
  background-color: transparent;
  border-color: var(--color-darken);
}

input,
textarea,
select {
  background: var(--color-darken-less);
}

label,
.label {
  padding: 0.25em 0 0;
  display: block;
  font-size: 0.6875em;
}

button {
  background-color: var(--color-darken-more);
  color: var(--color-text);
  margin-top: 0.5em;
  cursor: pointer;

  &.primary {
    background-color: var(--color-highlight);
    color: var(--color-highlight-contra);
    padding-top: 1em;
    padding-bottom: 1em;
  }

  &.secondary {
    background-color: var(--color-highlight);
    color: var(--color-highlight-contra);
    margin: 0;
  }
}

::file-selector-button {
  font: inherit;
  background-color: var(--color-highlight);
  color: var(--color-highlight-contra);
  cursor: pointer;
  padding: 0.1em 0.25em;
  border-radius: 0.25em;
  border: 1px solid var(--color-darken-more);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button:is(:hover, :focus):not(:disabled),
::file-selector-button:is(:hover, :focus) {
  box-shadow: var(--color-darken-more) 0px 0.5em 0.5em;
}

button {
  &.icon {
    width: auto;
    font-size: 0.8rem;
    border-radius: 1em;
    padding: 0.35em 0.5em 0.55em;
    min-width: 2em;
    height: 2em;
    position: absolute;
    text-align: center;
    top: 1em;
    right: 1em;
    line-height: 1;
    text-align: center;
  }

  &.icon span {
    display: none;
  }

  &.icon:hover span {
    display: inline-block;
  }

  &.help,
  &.reset {
    top: 0;
    right: 0;
  }

  &.second {
    right: 2.5em;
  }

  &.reset,
  &.is-loading {
    background-color: var(--color--warning);
    color: var(--color-highlight-contra);
  }
}

/* Dialog */

dialog {
  color: var(--color-text);
  background-color: var(--color-background);
  border: 1px solid var(--color-darken);
  padding: 1em;
  margin: auto !important;
  box-shadow: var(--color-darken-more) 0.5em 0.5em 0.5em;
  border-radius: 0.25em;
  max-width: 40em;
}

dialog::backdrop {
  background-color: rgba(0, 0, 0, 0.7);
}

/* Table */

.component {
  max-width: 100%;
  overflow: auto;
  display: block;
}

caption {
  font-weight: var(--fontweight-bold);
  text-align: left;
  font-size: 1.2em;
  padding-bottom: 0.5em;
}

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

  &.empty {
    display: none;
  }

  input {
    max-width: 6.5em;
  }

  input[type="number"] {
    width: 5.5em;
  }

  input[data-cp-prop="speed"] {
    width: 4.5em;
  }
}

thead,
tfoot {
  font-weight: var(--fontweight-bold);
}

td,
th {
  padding: 0.05em 0.25em;
  text-align: left;
  white-space: nowrap;
}

:is(tbody, tfoot) :is(td, th) {
  border-top: 1px solid var(--color-darken);
}

.table-checkpoints :is(td, th):nth-child(n + 6) {
  text-align: right;
}

.is-simple-mode {
  .expert-mode,
  .table-checkpoints :is(td, th):nth-child(3),
  .table-checkpoints :is(td, th):nth-child(5) {
    display: none;
  }

  button#expert-mode {
    background-color: var(--color--warning);
    color: var(--color-highlight-contra);
  }
}

/* Page */

.container {
  margin: auto;
  max-width: 50em;
  position: relative;

  > * {
    padding: 1em;
  }
}

header {
  color: var(--color-highlight);

  img {
    vertical-align: -0.5em;
  }
}

footer {
  color: var(--color-note);
  border-top: 1px solid var(--color-darken-more);
  text-align: center;
  font-size: 0.8em;
  margin-top: 2em;
}

@media screen and (max-width: 24em) {
  body {
    font-size: 0.9em;
  }
}

@media screen and (min-width: 24em) {
  .col-4,
  .col-3,
  .col-2 {
    display: flex;
    flex-flow: row wrap;
    column-gap: 2%;
  }

  :is(.col-4, .col-3, .col-2) > * {
    margin-top: 0.5em;
  }

  .col-4 > *,
  .col-2 > * {
    width: 49%;
  }

  .col-3 > * {
    width: 32%;
  }
}

@media screen and (min-width: 42em) and (max-width: 80em) {
  .col-4 > * {
    width: 23.5%;
  }
}

@media screen and (min-width: 80em) {
  .container {
    max-width: 100em;
  }

  main {
    display: grid;
    grid-template-columns: 30em 1fr;
    grid-template-areas:
      "p p"
      "upload map"
      "settings map"
      "buttons map";
    column-gap: 3em;

    > p {
      grid-area: p;
    }

    > section:nth-child(2) {
      grid-area: upload;
    }

    > section:nth-child(3) {
      grid-area: settings;
    }

    > section:nth-child(4) {
      padding-left: 3em;
      border-left: 1px solid var(--color-darken-more);
      grid-area: map;
    }

    > section:nth-child(5) {
      grid-area: buttons;
    }

    > section:nth-child(even) h2 {
      border-top: none;
    }
  }
}

@media print {
  body {
    font-size: 10pt;
  }

  .no-print {
    display: none;
  }

  input,
  select,
  textarea,
  output {
    border: none;
    padding: 0;
    margin: 0;
  }

  input[type="number"] {
    text-align: right;
  }

  pre,
  div.pre,
  pre span {
    color: black !important;
    background-color: white;
  }
}

#matomo-opt-out label {
  display: inline-block;
  margin-inline-start: 1em;
  font-size: 1em;
}
