/* Colours from a VFR sectional chart: lowland tint for paper, magenta for your course and what's yours,
   towered-airport blue for what you can press, terrain ochre for the world event. */
:root {
  --paper: #eef3ea;
  --card: #f8faf5;
  --ink: #17242e;
  --muted: #56656e;
  --rule: #c7d2c4;
  --control: #7d8c86;
  --blue: #2557a7;
  --magenta: #a3246f;
  --ochre: #7f5b0c;
  --ochre-fill: #c99a35;
  --round: ui-rounded, "SF Pro Rounded", "Varela Round", "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  --text: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0e1820;
    --card: #15222c;
    --ink: #e2eaee;
    --muted: #97a7b1;
    --rule: #2b3b47;
    --control: #6b7f8c;
    --blue: #8db2f2;
    --magenta: #e87fc0;
    --ochre: #dcb65e;
    --ochre-fill: #b88d2e;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1rem/1.5 var(--text);
  -webkit-text-size-adjust: 100%;
}

.top, main, .foot {
  max-width: 60rem;
  margin: 0 auto;
  padding: 0 1rem;
}

h1, h2, h3, .cs, button, .code, .tag {
  font-family: var(--round);
}

h2 {
  font-size: 1.5rem;
  line-height: 1.2;
  margin: 0 0 0.5rem;
}

h3 {
  font-size: 1rem;
  margin: 0 0 0.25rem;
}

p { margin: 0.5rem 0; max-width: 72ch; }

a, .link { color: var(--blue); }

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

/* ---- Callsign and settings ---- */

.top {
  display: grid;
  gap: 0.5rem 2rem;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  padding-top: 1.25rem;
  padding-bottom: 1rem;
}

.who label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.who-row {
  display: flex;
  gap: 0.5rem;
  max-width: 26rem;
}

input, select {
  font: inherit;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--control);
  border-radius: 0.5rem;
  padding: 0.45rem 0.6rem;
}

select {
  max-width: 100%;
  min-width: 0;
}

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

#callsign, #airport {
  flex: 1;
  min-width: 0;
  font-family: var(--round);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

#callsign::placeholder, #airport::placeholder {
  text-transform: none;
  letter-spacing: normal;
  font-weight: 400;
}

button {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  background: var(--blue);
  border: 0;
  border-radius: 0.5rem;
  padding: 0.5rem 1rem;
  cursor: pointer;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) button:not(.link) { color: #0e1820; }
}

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

.never {
  font-size: 0.875rem;
  color: var(--muted);
  max-width: 34rem;
}

.settings {
  min-width: 14rem;
  max-width: 30rem;
}

.settings summary {
  cursor: pointer;
  color: var(--blue);
  font-weight: 600;
  padding: 0.25rem 0;
}

.settings[open] {
  grid-column: 1 / -1;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 0.75rem;
  padding: 0.5rem 1rem 1rem;
  max-width: none;
}

fieldset {
  border: 0;
  margin: 0.75rem 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
}

legend {
  font-weight: 600;
  padding: 0;
  margin-bottom: 0.25rem;
  width: 100%;
}

label.check {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
}

/* ---- Where you are: the one loud thing on the page ---- */

.where {
  padding: 1.5rem 0 2rem;
}

.where h1:not(.cs) {
  font-size: 2.25rem;
  line-height: 1.1;
  margin: 0;
}

.lede {
  font-size: 1.125rem;
  color: var(--muted);
}

.cs {
  font-size: clamp(2.5rem, 9vw, 4.5rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.04em;
  margin: 0 0 1rem;
  color: var(--magenta);
}

.strip {
  --done: 0;
  display: grid;
  grid-template-columns: minmax(0, 11rem) minmax(4rem, 1fr) minmax(0, 11rem);
  align-items: center;
  gap: 1rem;
}

.strip .end { display: grid; }
.strip .end.to { text-align: right; }

.strip .code {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.1;
}

.strip .name {
  font-size: 0.875rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

/* The course line: dashed ahead, solid where you've flown */
.track {
  position: relative;
  height: 2rem;
  background: linear-gradient(90deg, var(--magenta) 50%, transparent 0) 0 50% / 0.75rem 2px repeat-x;
}

.track .flown {
  position: absolute;
  left: 0;
  top: calc(50% - 1.5px);
  height: 3px;
  width: calc(var(--done) * 100%);
  background: var(--magenta);
  border-radius: 2px;
}

.track .plane {
  position: absolute;
  top: 0;
  left: calc(var(--done) * (100% - 2rem));
  width: 2rem;
  height: 2rem;
  fill: var(--magenta);
  transform: rotate(90deg);
}

@media (prefers-reduced-motion: no-preference) {
  .track .plane { transition: left 0.8s ease-out; }
  .track .flown { transition: width 0.8s ease-out; }
}

.facts {
  font-size: 1.125rem;
  margin-top: 1rem;
}

.facts.parked .code {
  font-size: 1.5rem;
}

.choices {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 0.5rem;
  max-width: 34rem;
}

.choices button {
  width: 100%;
  text-align: left;
  font-weight: 600;
}

.airport {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  max-width: 30rem;
}

.airport label { width: 100%; font-weight: 600; }

.form-error {
  width: 100%;
  margin: 0;
  color: var(--magenta);
  font-weight: 600;
}

.form-error:empty { display: none; }

/* ---- Panels ---- */

.panel {
  border-top: 2px solid var(--ink);
  padding: 1.25rem 0 2rem;
}

.panel[aria-busy="true"] { opacity: 0.6; }

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

.code {
  font-weight: 700;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  align-items: center;
  margin: 0.75rem 0;
}

.controls label:not(.check) {
  display: inline-flex;
  gap: 0.4rem;
  align-items: center;
  max-width: 100%;
}

.take {
  font-size: 1.125rem;
  border-left: 4px solid var(--magenta);
  padding: 0.25rem 0 0.25rem 0.75rem;
  margin: 1rem 0;
}

.take strong:first-of-type { color: var(--magenta); }

.wait {
  border-left: 4px solid var(--blue);
  padding: 0.25rem 0 0.25rem 0.75rem;
}

.error {
  border-left: 4px solid var(--magenta);
  padding: 0.25rem 0 0.25rem 0.75rem;
  font-weight: 600;
}

.note {
  font-size: 0.875rem;
  color: var(--muted);
}

/* ---- Tables ---- */

.scroll {
  overflow-x: auto;
  margin: 0.5rem 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

th {
  text-align: left;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--muted);
  padding: 0.25rem 0.5rem;
  border-bottom: 1px solid var(--ink);
  white-space: nowrap;
}

td {
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}

th:first-child, td:first-child { padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }

.num { text-align: right; white-space: nowrap; }

.jobs .what {
  display: block;
  font-weight: 600;
}

.jobs .detail {
  display: block;
  font-size: 0.8125rem;
  color: var(--muted);
}

.jobs tbody tr:first-child:not(.cant) .what,
.jobs .gain {
  color: var(--magenta);
  font-weight: 700;
}

.jobs .star { color: var(--ochre); }

/* A job for this week's event, in the event's ochre: its mark, and what the job to take adds to the goal */
.event {
  color: var(--ochre);
  font-weight: 600;
}

.jobs .cant td { color: var(--muted); }
.jobs .cant .what { font-weight: 400; }
.jobs .why { font-style: italic; }

tr.me td { background: color-mix(in srgb, var(--magenta) 10%, transparent); }

.hit {
  color: var(--magenta);
  font-weight: 700;
}

.tag {
  font-weight: 800;
  letter-spacing: 0.04em;
}

/* ---- Shop picker ---- */

.chips {
  gap: 0.5rem;
}

.chip {
  position: relative;
  display: inline-flex;
}

.chip input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
}

.chip span {
  border: 1px solid var(--control);
  border-radius: 999px;
  padding: 0.2rem 0.75rem;
  background: var(--card);
  font-weight: 600;
}

.chip small {
  font-weight: 400;
  color: var(--muted);
}

.chip input:checked + span {
  border-color: var(--blue);
  box-shadow: inset 0 0 0 1px var(--blue);
  color: var(--blue);
}

.chip input:focus-visible + span {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}

/* ---- Event ---- */

.progress {
  position: relative;
  height: 0.75rem;
  margin: 1rem 0 0.5rem;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 999px;
}

.progress .fill {
  --p: 0;
  position: absolute;
  inset: 0 auto 0 0;
  width: calc(var(--p) * 100%);
  background: var(--ochre-fill);
  border-radius: 999px;
}

.progress .tick {
  --at: 0;
  position: absolute;
  top: -0.3rem;
  bottom: -0.3rem;
  left: calc(var(--at) * 100% - 1px);
  width: 2px;
  background: var(--ink);
}

.progress .tick.reached { background: var(--ochre); }

.tiers { max-width: 36rem; }
.tiers .reached td { color: var(--muted); }
.tiers .reached td:last-child { color: var(--ochre); font-weight: 700; }

.you { font-size: 1.125rem; }

.leaders {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 1rem 2rem;
  margin-top: 1rem;
}

.leaders ol {
  margin: 0;
  padding-left: 1.5rem;
}

.leaders li .num { float: right; color: var(--muted); }
.leaders li.me { color: var(--magenta); font-weight: 700; }

/* Next week's event, once the game names it */
.next {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
}

/* ---- Footer ---- */

.foot {
  border-top: 1px solid var(--rule);
  padding-top: 1rem;
  padding-bottom: 3rem;
  font-size: 0.875rem;
  color: var(--muted);
}

/* ---- Phones ---- */

@media (max-width: 40rem) {
  .top { grid-template-columns: minmax(0, 1fr); }
  .wide { display: none; }
  th, td { padding-left: 0.25rem; padding-right: 0.25rem; }
  .strip { grid-template-columns: minmax(0, 1fr) minmax(3rem, 1.2fr) minmax(0, 1fr); gap: 0.5rem; }
  .strip .code { font-size: 1.5rem; }
  .strip .name { font-size: 0.75rem; }
}
