/* FTX pages: the live FT8 map and the log. On top of ../styles.css (the site's paper,
   ink, blue dimension lines and red markers); the map itself is a dark chart, the same
   in both themes, as the ic705suite map it copies. */

:root {
  --chart: #0f1a29;
  --chart-ink: #dbe4f0;
  --chart-rule: #2c405b;
  --cq: #1f8a50;
  --tx: var(--mark);
  --lamp-off: #9aa6b5;
}

@media (prefers-color-scheme: dark) {
  :root {
    --cq: #6cdc98;
    --lamp-off: #4b5d76;
  }
}

.wrap-wide {
  max-width: 84rem;
  margin: 0 auto;
  padding-left: 2rem;
  padding-right: 2rem;
}

.masthead-ftx {
  padding-bottom: 0;
}

.masthead-ftx .site-nav {
  margin-top: 2rem;
}

.lang-switch {
  float: right;
  font-size: 1rem;
}

/* ---------- The two pages of the section ---------- */

.ftx-live {
  padding: 2rem 0 4rem;
}

.ftx-tabs {
  display: flex;
  gap: 0.25rem;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 1.125rem;
}

.ftx-tabs a {
  padding: 0.35rem 0.9rem;
  border: 1.5px solid var(--rule);
  border-radius: 4px;
  color: var(--ink);
  text-decoration: none;
}

.ftx-tabs a:hover {
  border-color: var(--cota);
  color: var(--cota);
}

.ftx-tabs a[aria-current] {
  border-color: var(--cota);
  background: var(--cota);
  color: var(--sheet);
}

/* ---------- On the air? ---------- */

.on-air {
  display: flex;
  align-items: baseline;
  gap: 0.85rem;
  margin: 1.75rem 0 1.25rem;
}

.on-air-lamp {
  flex: none;
  width: 0.9rem;
  height: 0.9rem;
  margin: 0;
  border-radius: 50%;
  background: var(--lamp-off);
  transform: translateY(0.05rem);
}

.is-on-air .on-air-lamp {
  background: var(--tx);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--tx) 22%, transparent);
}

.is-unreachable .on-air-lamp {
  background: transparent;
  border: 2px solid var(--lamp-off);
}

.on-air-text {
  margin: 0;
  max-width: 52rem;
  font-family: var(--sans);
  font-weight: 500;
  font-size: clamp(1.35rem, 2.6vw, 1.85rem);
  line-height: 1.25;
}

.on-air-text #status {
  font-weight: 600;
}

#status-more {
  color: var(--muted);
}

/* ---------- The QSO under way, above the chart ---------- */

/* Five steps in a row, as the QSO goes: done in green, to come in yellow, the one awaited
   outlined. Without a QSO the row waits in grey. */
.qso-steps {
  --step-done: var(--cq);
  --step-pending: #f2b630;
  display: grid;
  grid-template-columns: minmax(9rem, auto) repeat(5, minmax(0, 1fr));
  align-items: stretch;
  gap: 3px;
  margin: 0 0 6px;
  font-family: var(--sans);
}

.qso-steps-title {
  display: flex;
  align-items: center;
  margin: 0;
  padding: 0 0.75rem 0 0;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.2;
}

.qso-steps.is-idle .qso-steps-title {
  color: var(--muted);
  font-weight: 500;
}

.qso-steps ol {
  display: contents;
  list-style: none;
}

.qso-steps li {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
  padding: 0.4rem 0.6rem;
  border-radius: 2px;
  background: color-mix(in srgb, var(--cota) 8%, var(--sheet));
}

.qso-steps li.is-next {
  box-shadow: inset 0 0 0 2px var(--step-pending);
}

.step-head {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 1rem;
  font-weight: 600;
}

.qso-steps .dot {
  flex: none;
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 50%;
  background: var(--rule);
}

.qso-steps .is-done .dot {
  background: var(--step-done);
}

.qso-steps .is-pending .dot {
  background: var(--step-pending);
}

.qso-steps .is-idle .step-name,
.qso-steps .is-pending .step-name {
  color: var(--muted);
}

.step-msg {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.step-msg:empty::before {
  content: "\00a0";
}

.qso-steps .is-done .step-msg {
  color: var(--ink);
}


/* ---------- The chart ---------- */

.chart {
  margin: 0;
}

.chart-frame {
  position: relative;
  background: var(--chart);
  border: 1px solid var(--ink);
}

.chart canvas {
  display: block;
  width: 100%;
  aspect-ratio: 2 / 1;
  max-height: 74vh;
  min-height: 18rem;
  touch-action: none;
  cursor: grab;
}

.chart canvas.is-dragging {
  cursor: grabbing;
}

.chart canvas:focus-visible {
  outline: 3px solid var(--cota);
  outline-offset: 2px;
}

.map-tools {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  display: flex;
  gap: 0.35rem;
}

.map-tools button {
  min-width: 2.25rem;
  height: 2.25rem;
  padding: 0 0.7rem;
  border: 1px solid var(--chart-rule);
  border-radius: 4px;
  background: rgb(15 26 41 / 0.85);
  color: var(--chart-ink);
  font-family: var(--sans);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
}

/* A switch: lit while on. */
.map-tools .map-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-right: 0.35rem;
}

.map-tools .map-switch::before {
  content: '';
  width: 1.6rem;
  height: 0.9rem;
  border-radius: 0.45rem;
  background: radial-gradient(circle at 0.45rem 50%, #9fb0c6 0.3rem, transparent 0.32rem) #2c405b;
}

.map-tools .map-switch[aria-pressed="true"]::before {
  background: radial-gradient(circle at 1.15rem 50%, var(--chart) 0.3rem, transparent 0.32rem) #dbe4f0;
}

.map-tools button:hover {
  border-color: var(--chart-ink);
}

.map-tools button:focus-visible {
  outline: 2px solid #9dbdff;
  outline-offset: 2px;
}

.map-readout {
  position: absolute;
  left: 0.75rem;
  bottom: 0.75rem;
  max-width: min(36rem, calc(100% - 1.5rem));
  margin: 0;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--chart-rule);
  border-radius: 4px;
  background: rgb(15 26 41 / 0.9);
  color: var(--chart-ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.35;
}

/* Not on FT8: a plain notice at the top of the chart, with the last time on the air. */
.chart-idle {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  margin: 0;
  padding: 0.35rem 0.8rem;
  border: 1.5px solid #9fb0c6;
  border-radius: 4px;
  background: rgb(15 26 41 / 0.9);
  color: var(--chart-ink);
  font-family: var(--sans);
  font-size: 1.15rem;
  font-weight: 600;
  pointer-events: none;
}

.chart-idle span {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: #9fb0c6;
}

.chart-idle span:empty {
  display: none;
}

/* The key, under the chart: the same marks the canvas draws. */
.key {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1.4rem;
  margin-top: 0.75rem;
  font-family: var(--sans);
  font-size: 1rem;
  color: var(--muted);
}

.key-item {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.mark {
  display: inline-block;
  flex: none;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 0 1px var(--chart);
}

.mark.is-cq { --c: #6cdc98; }
.mark.is-to-me { --c: #ff8f7f; }
.mark.is-other { --c: #dbe4f0; box-shadow: 0 0 0 1px var(--muted); }
.mark.is-fresh { --c: #ffd27a; }

.mark.is-new {
  background: transparent;
  box-shadow: inset 0 0 0 2px #c46be0;
  width: 0.95rem;
  height: 0.95rem;
}

.mark.is-approx {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--muted);
}

.mark.is-home {
  --c: #ffd27a;
  border-radius: 1px;
  box-shadow: 0 0 0 1.5px var(--chart);
}

.mark.is-worked,
.mark.is-confirmed {
  width: 1rem;
  border-radius: 1px;
  background: color-mix(in srgb, var(--c) 45%, transparent);
  box-shadow: inset 0 0 0 1px var(--c);
}

.mark.is-worked { --c: #f0a840; }
.mark.is-confirmed { --c: #47b878; }

.mark.is-wave {
  width: 0.95rem;
  height: 0.95rem;
  background: radial-gradient(circle, #ffd27a 0 20%, var(--chart) 21% 42%, #ffd27a 43% 58%, var(--chart) 59%);
  box-shadow: 0 0 0 1px var(--chart);
}

.mark.is-path.is-mine {
  background: #ffd27a;
}

.mark.is-path {
  width: 1.1rem;
  height: 0.6rem;
  border-radius: 0;
  background: #ff8f7f;
  clip-path: polygon(0 35%, 60% 35%, 60% 0, 100% 50%, 60% 100%, 60% 65%, 0 65%);
  box-shadow: none;
}

.mark.is-path.is-others {
  background: var(--muted);
  box-shadow: none;
  opacity: 0.8;
}

/* ---------- Under the chart ---------- */

.ftx-columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 2.5rem;
  margin-top: 2.5rem;
}

.ftx-panel h2 {
  margin: 0 0 0.35rem;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 1.6rem;
  line-height: 1.15;
}

.ftx-side .ftx-panel + .ftx-panel {
  margin-top: 2rem;
}

.panel-note {
  margin: 0 0 0.9rem;
  font-size: 1rem;
  color: var(--muted);
}

.ftx-side > .panel-note {
  margin-top: 2rem;
}

.table-scroll {
  overflow-x: auto;
  border-top: 1.5px solid var(--ink);
}

/* What I hear: ten rows, then it scrolls under a header that stays put (a
   pager would jump back to page one on every cycle). */
.table-scroll.is-fixed {
  max-height: calc(11 * 2.25rem);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.table-scroll.is-fixed:focus-visible {
  outline: 2px solid var(--cota);
  outline-offset: 3px;
}

.table-scroll.is-fixed thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--paper);
  box-shadow: inset 0 -1px 0 var(--ink);   /* the rule, which collapsed borders lose when stuck */
}

.decodes,
.log {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--sans);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}

.decodes th,
.log thead th {
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--ink);
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}

.decodes td,
.log td,
.log tbody th {
  padding: 0.3rem 0.6rem;
  border-bottom: 1px solid var(--rule);
  white-space: nowrap;
}

.log tbody th {
  font-weight: 600;
  text-align: left;
}

.decodes .num,
.log .num {
  text-align: right;
}

.decodes thead th:nth-child(-n+3),
.decodes thead th:last-child,
.log thead th:nth-child(5),
.log thead th:nth-child(6),
.log thead th:nth-child(9) {
  text-align: right;
}

.decodes .msg,
.lines .msg {
  font-family: var(--mono);
  font-size: 0.875rem;
}

.decodes tr.is-cq .msg {
  color: var(--cq);
}

.decodes tr.is-to-me td {
  background: color-mix(in srgb, var(--tx) 14%, transparent);
}

.decodes tr.is-to-me .msg {
  color: var(--tx);
  font-weight: 700;
}

.decodes tbody tr,
.log tbody tr {
  cursor: pointer;
}

.decodes tbody tr:hover td,
.log tbody tr:hover td,
.log tbody tr:hover th {
  background: color-mix(in srgb, var(--cota) 7%, transparent);
}

tr.is-selected td,
tr.is-selected th {
  box-shadow: inset 0 1px 0 var(--cota), inset 0 -1px 0 var(--cota);
}

/* Today's QSOs: a short log, not a list to choose from. */
.log.today thead th:nth-child(1),
.log.today thead th:nth-child(4),
.log.today thead th:nth-child(5),
.log.today thead th:nth-child(8) {
  text-align: right;
}

.log.today thead th:nth-child(6),
.log.today thead th:nth-child(9) {
  text-align: left;
}

.log.today tbody tr {
  cursor: auto;
}

.log td.empty {
  color: var(--muted);
}

.log .confirmed {
  color: var(--cq);
  font-weight: 600;
}

/* Our messages and today's QSOs: one line each. */
.lines {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1.5px solid var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}

.lines li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.2rem 0.85rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--rule);
}

.lines .num {
  color: var(--muted);
}

.lines .watts {
  margin-left: auto;
}

.lines .empty {
  color: var(--muted);
}

/* ---------- The log: a drawing's title block ---------- */

.title-block {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin: 1.75rem 0 2rem;
  border: 1.5px solid var(--ink);
  background: var(--ink);
}

/* The rules between the fields are the 1px gaps over the ink. */
.tb-cell {
  padding: 0.6rem 0.85rem 0.7rem;
  background: var(--sheet);
}

.tb-wide,
.tb-half {
  grid-column: span 2;
}

.title-block dt {
  font-family: var(--sans);
  font-weight: 500;
  font-size: 0.9375rem;
  color: var(--muted);
}

.title-block dd {
  margin: 0.1rem 0 0;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 1.35rem;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.title-block .tb-main dd {
  font-size: 2.6rem;
  line-height: 1;
  color: var(--cota);
}

.log-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  margin-top: 2.5rem;
}

.band-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.band-filter[hidden] {
  display: none;
}

.band-filter button {
  padding: 0.25rem 0.75rem;
  border: 1.5px solid var(--rule);
  border-radius: 4px;
  background: transparent;
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
}

.band-filter button:hover {
  border-color: var(--cota);
}

.band-filter button[aria-pressed="true"] {
  border-color: var(--cota);
  background: var(--cota);
  color: var(--sheet);
}

/* ---------- Small screens ---------- */

@media (max-width: 56rem) {
  .ftx-columns {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 48rem) {
  .wrap-wide {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .chart canvas {
    aspect-ratio: 4 / 3;
  }

  .qso-steps {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .qso-steps-title {
    grid-column: 1 / -1;
    padding: 0 0 0.2rem;
  }

  .qso-steps li {
    padding: 0.35rem 0.4rem;
  }

  .step-head {
    font-size: 0.9rem;
  }

  .qso-steps .step-msg {
    display: none;
  }

  .title-block {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tb-half {
    grid-column: auto;
  }

  .lang-switch {
    float: none;
    display: block;
    margin-top: 0.25rem;
  }
}
