@font-face {
  font-family: "Figtree";
  src: url("assets/fonts/Figtree-VariableFont_wght.ttf") format("truetype");
  font-weight: 300 900;
  font-style: normal;
  font-display: block;
}

@font-face {
  font-family: "Barlow Condensed";
  src: url("assets/fonts/BarlowCondensed-Black.ttf") format("truetype");
  font-weight: 900;
  font-style: normal;
  font-display: block;
}

:root {
  --bg: #101216;
  --surface: #181c23;
  --surface-2: #222733;
  --text: #ececec;
  --muted: #9aa0aa;
  --line: #2c323c;
  --accent: #8eb4d4;
  --ink: #101216;
  --focus: #8eb4d4;
  --shadow: 0 18px 50px rgba(0, 0, 0, .45);
  --sans: "Figtree", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
}

.app {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 64px;
}

.top { margin-bottom: 28px; max-width: 40rem; }
.eyebrow {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--accent);
}
.top h1 {
  margin: 0 0 8px;
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  font-weight: 700;
  letter-spacing: -.03em;
  line-height: 1.1;
}
.lead { margin: 0; color: var(--muted); }

.layout {
  display: grid;
  gap: 28px;
}
.preview-col { order: -1; }

@media (min-width: 900px) {
  .layout {
    grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
    align-items: start;
  }
  .preview-col { order: 0; position: sticky; top: 20px; }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 18px 20px;
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 0.95rem;
  font-weight: 650;
  letter-spacing: .02em;
}

.fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 12px;
}

.field { display: flex; flex-direction: column; gap: 5px; }
.field-wide { grid-column: 1 / -1; }

.field label {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

.field input,
.field select {
  width: 100%;
  appearance: none;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  font-size: 15px;
}

.field input:focus,
.field select:focus,
.btn:focus-visible,
.file-btn:focus-visible,
.qso-row:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.btn,
.file-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  padding: 8px 14px;
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  color: inherit;
}

.btn:disabled,
.file-btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary { background: var(--text); color: var(--ink); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.06); }

.btn-secondary,
.file-btn {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--line);
}
.btn-secondary:hover:not(:disabled),
.file-btn:hover:not(:disabled) { background: #2a303c; }

.file-btn input { display: none; }

.divider {
  height: 1px;
  background: var(--line);
  margin: 22px 0 16px;
  border: 0;
}

.status {
  min-height: 1.3em;
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--muted);
}
.status[data-kind="error"] { color: var(--accent); }
.status[data-kind="ok"] { color: var(--text); }

.qso-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  max-height: 240px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.qso-row {
  display: grid;
  grid-template-columns: 7.5rem 1fr auto;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  color: inherit;
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.qso-row:last-child { border-bottom: 0; }
.qso-row[aria-current="true"] { background: var(--surface-2); }
.qso-row .call { font-weight: 700; letter-spacing: .02em; }
.qso-row .meta { color: var(--muted); }
.qso-row .when { color: var(--muted); font-variant-numeric: tabular-nums; }

.preview-col .hint {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.stage {
  width: 100%;
  aspect-ratio: 11 / 7;
  background: #0a0c10;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.stage-inner {
  width: 5.5in;
  height: 3.5in;
  transform-origin: top left;
}

/* ---- The card: --u is 1% of card width, so type and layout do not compound ---- */
.card {
  --u: calc(5.5in / 100);
  width: 5.5in;
  height: 3.5in;
  aspect-ratio: 11 / 7;
  position: relative;
  overflow: hidden;
  background: #1b2a3d url("assets/bg.jpg") center / cover;
  color: #fff;
  font-family: "Figtree", "Helvetica Neue", Arial, sans-serif;
  font-size: calc(1.5 * var(--u));
  text-shadow: 0 calc(0.1 * var(--u)) calc(0.5 * var(--u)) rgba(8, 14, 24, .8);
}
.card > * { position: absolute; }

.head { left: calc(4.4 * var(--u)); top: calc(2.6 * var(--u)); }
.country { font-size: calc(1.5 * var(--u)); font-weight: 600; letter-spacing: .12em; }
.card .call-sign {
  font-family: "Barlow Condensed", "Arial Narrow", Impact, sans-serif;
  font-weight: 900;
  font-size: calc(17.4 * var(--u));
  line-height: .86;
  margin: calc(0.5 * var(--u)) 0 0 calc(-0.6 * var(--u));
  text-shadow: calc(0.28 * var(--u)) calc(0.28 * var(--u)) 0 #14253b;
}
.zero { position: relative; display: inline-block; }
.zero::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: .05em;
  height: .56em;
  background: currentColor;
  transform: translate(-50%, -52%) rotate(16deg);
}
.name { font-size: calc(3 * var(--u)); font-weight: 700; margin: 0; }
.where { font-size: calc(1.55 * var(--u)); font-weight: 500; line-height: 1.4; margin-top: calc(0.3 * var(--u)); }

.me {
  right: calc(4.4 * var(--u));
  top: calc(3.6 * var(--u));
  width: calc(19 * var(--u));
  height: auto;
  aspect-ratio: 4 / 4.7;
  object-fit: cover;
  border: calc(0.45 * var(--u)) solid #fff;
}

.qso { left: calc(4.4 * var(--u)); right: calc(4.4 * var(--u)); bottom: calc(3 * var(--u)); }
.to {
  font-size: calc(1.7 * var(--u));
  font-weight: 600;
  display: flex;
  align-items: baseline;
  gap: calc(1 * var(--u));
}
.to p { flex: 0 0 calc(22 * var(--u)); border-bottom: calc(0.14 * var(--u)) solid #fff; margin: 0; }
.fill {
  height: calc(3.2 * var(--u));
  line-height: calc(3.2 * var(--u));
  font-size: calc(2 * var(--u));
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  outline: 0;
  padding: 0 calc(0.6 * var(--u));
  margin: 0;
}
.card table {
  width: 100%;
  margin-top: calc(1.1 * var(--u));
  border-collapse: collapse;
  table-layout: fixed;
  background: rgba(10, 18, 30, .5);
  text-shadow: none;
}
.card th, .card td { border: calc(0.14 * var(--u)) solid #fff; text-align: center; padding: 0; }
.card th { font-size: calc(1.25 * var(--u)); font-weight: 600; letter-spacing: .08em; padding: calc(0.4 * var(--u)) 0; }
.foot {
  margin-top: calc(1.1 * var(--u));
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: calc(1.5 * var(--u));
  font-weight: 500;
}
.foot i {
  display: inline-block;
  width: calc(1.3 * var(--u));
  height: calc(1.3 * var(--u));
  border: calc(0.14 * var(--u)) solid #fff;
  margin: 0 calc(1.6 * var(--u)) 0 calc(0.5 * var(--u));
  vertical-align: calc(-0.15 * var(--u));
}
.foot b { font-size: calc(1.9 * var(--u)); }

/* Off-screen 300 dpi card used for PNG export */
.export-rack {
  position: fixed;
  left: -20000px;
  top: 0;
  width: 1650px;
  height: 1050px;
  pointer-events: none;
}
.export-rack .card {
  --u: 16.5px;
  width: 1650px;
  height: 1050px;
  aspect-ratio: auto;
  font-size: 16.5px;
}

.print-rack { display: none; }

@page { size: 5.5in 3.5in; margin: 0; }

@media print {
  html, body {
    background: none !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 5.5in;
    height: auto;
  }
  .app, .export-rack { display: none !important; }
  .print-rack { display: block; }
  .print-rack .card {
    --u: calc(5.5in / 100);
    width: 5.5in;
    height: 3.5in;
    font-size: calc(1.5 * var(--u));
    break-after: page;
    page-break-after: always;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
  .print-rack .card:last-child {
    break-after: auto;
    page-break-after: auto;
  }
}
