/* w4deq.tech: the cloud photo fixed behind everything; a QSL card floats in the sky, with a
   note card under it. "Send a message" flips the QSL card to its back, which holds the form.
   A deliberately single (light) look: the daytime sky sets it. */
:root {
  --sky: #2f5f9e;          /* deep sky at the top of the photo */
  --paper: #fdfdfb;        /* card stock */
  --ink: #1a2130;
  --muted: #5b6474;
  --line: #d8dce3;
  --signal: #cf3326;       /* signal red */
  --signal-hi: #e0412f;
  --amber: #f5a00f;
  --ok: #2f9e5b;
  --bad: #b3261e;
  --call: "Bungee", Impact, sans-serif;
  --body: "Work Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --hand: "Caveat", "Segoe Script", cursive;
  color-scheme: light;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--sky); color: var(--ink); font-family: var(--body); font-size: 16px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
.sky { position: fixed; inset: 0; z-index: 0; }
.sky img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 40%; }
.sky::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to bottom, rgba(20,45,85,.25), rgba(20,45,85,0) 35%); }

.page {
  position: relative; z-index: 1; min-height: 100vh;
  display: grid; justify-items: center; align-content: start; gap: 22px;
  padding-block: max(16vh, 90px) 64px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* QSL card: postcard proportions on wide screens, content height on phones. */
.card-wrap { width: min(760px, 100%); perspective: 1600px; }
.qsl {
  background: var(--paper); border-radius: 6px; color: var(--ink);
  box-shadow: 0 1px 0 rgba(255,255,255,.6) inset, 0 18px 50px -12px rgba(10,30,60,.45), 0 4px 14px rgba(10,30,60,.18);
  transform-origin: 50% 50%; transition: transform .22s ease-in;
  position: relative; overflow: hidden;
}
.qsl.turning { transform: rotateY(90deg); }
.face { padding: clamp(20px, 4vw, 36px); display: grid; gap: 18px; }
.front { aspect-ratio: 14 / 9; align-content: space-between; }
@media (max-width: 640px) { .front { aspect-ratio: auto; } }

.toprow { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.stamp { font: 600 .72rem var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--signal); border: 1.5px solid var(--signal); border-radius: 3px; padding: 4px 8px; transform: rotate(-3deg); }
.country { font: 500 .78rem var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); text-align: right; }

.call { margin: 0; font-family: var(--call); font-weight: 400; font-size: clamp(3.4rem, 12.6vw, 7.4rem); line-height: .9; color: var(--ink); }
.call .four { color: var(--signal); }
.op { margin: 4px 0 0; font-size: 1.05rem; color: var(--muted); }
.op strong { color: var(--ink); font-weight: 600; }

.fields { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 4px; margin: 0; }
.fields div { padding: 8px 12px; border-left: 1px solid var(--line); min-width: 0; }
.fields div:first-child { border-left: 0; }
.fields dt { font: 600 .66rem var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.fields dd { margin: 2px 0 0; font: 600 1rem var(--mono); color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 640px) {
  .fields { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .fields div:nth-child(4) { border-left: 0; }
  .fields div:nth-child(n+4) { border-top: 1px solid var(--line); }
}

.bottomrow { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; }
.status { display: inline-flex; align-items: center; gap: 12px; font: 500 .9rem var(--mono); color: var(--ink); margin: 0; }
.status i { position: relative; width: 13px; height: 13px; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 35% 35%, #ffe08a, var(--amber) 60%);
  box-shadow: 0 0 6px 1px rgba(245,160,15,.75), 0 0 16px 3px rgba(245,160,15,.35); }
/* Two rings radiating out of the dot, like a signal. */
.status i::before, .status i::after { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--amber); animation: radiate 2.4s ease-out infinite; }
.status i::after { animation-delay: 1.2s; }
@keyframes radiate { 0% { transform: scale(1); opacity: .9; } 100% { transform: scale(3.4); opacity: 0; } }
.status.ok i { background: radial-gradient(circle at 35% 35%, #b6f5cf, var(--ok) 60%); box-shadow: 0 0 6px 1px rgba(47,158,91,.7), 0 0 16px 3px rgba(47,158,91,.3); }
.status.ok i::before, .status.ok i::after { border-color: var(--ok); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn { display: inline-block; font: 600 .92rem var(--body); text-decoration: none; border-radius: 4px; padding: 10px 16px; cursor: pointer; border: 1.5px solid var(--ink); color: var(--ink); background: transparent; transition: background .15s, color .15s, border-color .15s; }
.btn:hover { background: var(--ink); color: var(--paper); }
.btn.solid { background: var(--signal); border-color: var(--signal); color: #fff; }
.btn.solid:hover { background: var(--signal-hi); border-color: var(--signal-hi); }
.btn:disabled { opacity: .6; cursor: progress; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }

/* Back of the card: the form */
.back header { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.back h2 { margin: 0; font: 600 1.25rem var(--body); }
.back .to { font: 500 .78rem var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
form { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.field { display: grid; gap: 5px; min-width: 0; align-content: start; }
.field.wide { grid-column: 1 / -1; }
label { font: 600 .68rem var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
label small { font: inherit; text-transform: none; letter-spacing: 0; opacity: .8; }
input, textarea { font: 400 1rem var(--body); color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 4px; padding: 9px 11px; width: 100%; }
input.callsign { font-family: var(--mono); text-transform: uppercase; }
textarea { min-height: 130px; resize: vertical; line-height: 1.45; }
.field[data-invalid] input, .field[data-invalid] textarea { border-color: var(--bad); }
.err { color: var(--bad); font-size: .85rem; }
.counter { justify-self: end; font: .75rem var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.cf-turnstile { grid-column: 1 / -1; min-height: 65px; }
.sendrow { grid-column: 1 / -1; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.sendrow small { color: var(--muted); font-size: .82rem; }
.form-error { grid-column: 1 / -1; margin: 0; color: var(--bad); font-size: .9rem; }
@media (max-width: 640px) { form { grid-template-columns: 1fr; } }
.sent { display: grid; gap: 12px; justify-items: start; }
.sent .big { margin: 0; font-family: var(--call); font-size: clamp(2.6rem, 8vw, 4rem); line-height: 1; }
.sent p { margin: 0; color: var(--muted); max-width: 46ch; }

/* The note */
.note {
  width: min(620px, 100%); background: var(--paper); border-radius: 4px; padding: clamp(20px, 4vw, 32px);
  box-shadow: 0 14px 40px -14px rgba(10,30,60,.4); transform: rotate(-.6deg);
}
.note p { margin: 0 0 14px; max-width: 62ch; }
.note .sig { font-family: var(--hand); font-size: 1.7rem; line-height: 1.1; color: var(--sky); margin: 6px 0 0; }

/* 404 */
.lost .front { aspect-ratio: auto; gap: 22px; }

@media (prefers-reduced-motion: reduce) { .qsl { transition: none; } .status i::before, .status i::after { animation: none; opacity: 0; } }
