/* Packet Lab — airmail minimal */
:root {
  --paper: #f3ead8;
  --paper-2: #ece1cb;
  --ink: #1d1b18;
  --ink-2: #5d564b;
  --ink-3: #9a917f;
  --rule: #cdbfa3;
  --red: #c32f27;
  --blue: #1f3f8a;
  --serif: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --gutter: 16px;
  --slow: 700ms;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.55;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }
::selection { background: var(--blue); color: var(--paper); }
:focus-visible { outline: 1.5px solid var(--blue); outline-offset: 3px; }

/* the airmail stripe */
.airmail {
  height: 7px;
  flex: none;
  background: repeating-linear-gradient(-45deg,
    var(--red) 0 11px, var(--paper) 11px 16px,
    var(--blue) 16px 27px, var(--paper) 27px 32px);
}

/* header */
.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 14px var(--gutter);
}
.mark {
  font-size: 19px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
}
.mark em { font-style: italic; font-weight: 300; }
.toggles { display: flex; gap: 14px; }
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 0;
  border: 0;
  background: none;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-2);
  cursor: pointer;
}
.toggle::before {
  content: "";
  width: 8px; height: 8px;
  border: 1px solid currentColor;
  border-radius: 50%;
}
.toggle[aria-pressed="true"] { color: var(--ink); }
.toggle[aria-pressed="true"]::before { background: var(--blue); border-color: var(--blue); }

main {
  flex: 1;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 20px var(--gutter) 56px;
}

/* type */
.kicker, .label, .meta, .fine, .foot, .count, .mono {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.kicker { margin: 0 0 18px; color: var(--ink-2); }
.kicker .hot { color: var(--red); }
h1 {
  margin: 0 0 14px;
  font-size: clamp(34px, 9vw, 54px);
  line-height: 1.04;
  font-weight: 340;
  letter-spacing: -0.02em;
  font-variation-settings: "opsz" 144;
}
h1 em, h2 em { font-weight: 300; }
h2.quiet {
  margin: 0 0 22px;
  font-size: 24px;
  font-weight: 340;
  line-height: 1.2;
  letter-spacing: -0.01em;
}
.lede { margin: 0 0 30px; max-width: 30em; color: var(--ink-2); }
.meta { margin: 0 0 28px; color: var(--ink-2); }

/* explain notes */
.note {
  display: none;
  margin: 18px 0 26px;
  padding: 2px 0 2px 14px;
  border-left: 1px solid var(--blue);
  font-size: 15px;
  line-height: 1.5;
  max-width: 34em;
  color: var(--ink);
}
.note b { font-weight: 500; color: var(--blue); }
.explain .note { display: block; }
.explain-only { display: none; }
.explain .explain-only { display: inline; }

/* form */
form { margin: 0; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.field { display: block; margin: 0 0 24px; }
.label { display: flex; justify-content: space-between; margin-bottom: 6px; color: var(--ink-2); }
.count { color: var(--ink-3); letter-spacing: .04em; }
.count.full { color: var(--red); }
input:not([type="checkbox"]), textarea {
  display: block;
  width: 100%;
  margin: 0;
  padding: 6px 0 7px;
  border: 0;
  border-bottom: 1px solid var(--ink);
  border-radius: 0;
  background: transparent;
  font-size: 19px;
  -webkit-appearance: none;
  appearance: none;
}
textarea {
  padding: 10px 12px;
  border: 1px solid var(--ink);
  min-height: 170px;
  resize: vertical;
  line-height: 1.5;
}
input::placeholder, textarea::placeholder { color: var(--ink-3); opacity: 1; }
input:focus, textarea:focus { outline: none; border-color: var(--blue); }
input:focus { box-shadow: 0 1px 0 var(--blue); }
textarea:focus { box-shadow: inset 0 0 0 1px var(--blue); }

.lock { margin: 0 0 6px; }
.check {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  font-size: 16px;
  cursor: pointer;
}
.check input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.check .box {
  width: 14px; height: 14px;
  border: 1px solid var(--ink);
  display: inline-block;
  position: relative;
}
.check input:checked + .box::after {
  content: "";
  position: absolute;
  inset: 2px;
  background: var(--red);
}
.check input:focus-visible + .box { outline: 1.5px solid var(--blue); outline-offset: 3px; }

.error { min-height: 1.4em; margin: 0 0 14px; color: var(--red); font-size: 15px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 20px;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: transparent;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .1em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink);
  cursor: pointer;
  transition: color var(--slow), background-color var(--slow), border-color var(--slow);
}
.btn:hover { border-color: var(--blue); color: var(--blue); }
.btn.primary { background: var(--ink); color: var(--paper); }
.btn.primary:hover { background: var(--blue); border-color: var(--blue); color: var(--paper); }
.btn.text { border: 0; padding: 0; min-height: 40px; color: var(--ink-2); }
.btn.text:hover { color: var(--blue); }
.btn:disabled { opacity: .45; cursor: default; }
form .btn.primary { width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0; }
.actions.end { margin-top: 26px; }
.actions .btn { flex: 1 1 auto; padding: 0 14px; white-space: nowrap; letter-spacing: .08em; }

/* packets being cut */
.packets {
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px 12px;
}
.pkt {
  position: relative;
  padding: 10px 10px 9px;
  border: 1px solid var(--ink);
  background: var(--paper);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 900ms ease, transform 900ms ease;
}
.pkt.in { opacity: 1; transform: none; }
.pkt.away { opacity: 0; transform: translateY(-14px); transition-duration: 1400ms; }
.pkt::before { /* envelope flap */
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 18px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 18' preserveAspectRatio='none'%3E%3Cpolyline points='0,0 50,17 100,0' fill='none' stroke='%23cdbfa3' stroke-width='1' vector-effect='non-scaling-stroke'/%3E%3C/svg%3E") no-repeat center / 100% 100%;
}
.pkt .seq { position: relative; font-family: var(--mono); font-size: 13px; font-weight: 500; }
.pkt .hdr { margin: 16px 0 6px; font-family: var(--mono); font-size: 10px; line-height: 1.55; letter-spacing: .03em; color: var(--ink-2); }
.pkt .hdr b { font-weight: 400; color: var(--ink); }
.pkt .bit { margin: 0; font-size: 14px; font-style: italic; line-height: 1.35; color: var(--ink); overflow-wrap: anywhere; }
.pkt .stamp { position: absolute; top: 7px; right: 8px; width: 14px; height: 17px; border: 1px solid var(--red); }
.pkt .stamp::after { content: ""; position: absolute; inset: 3px; border: 1px solid var(--blue); }

/* flight */
.flight { margin: 6px 0 30px; }
.flight-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--ink);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.map {
  display: block;
  width: 100%;
  height: auto;
  margin: 4px 0 6px;
  overflow: visible;
}
.map .link { stroke: var(--ink); stroke-width: .6; opacity: .3; }
.map .route-re { fill: none; stroke: var(--red); stroke-width: .8; stroke-dasharray: 2 3; opacity: 0; transition: opacity 1.2s; }
.map .route-re.on { opacity: .9; }
.map .po-ring { fill: var(--paper); stroke: var(--ink); stroke-width: .8; }
.map .po-dot { fill: var(--ink); }
.map .po-busy .po-ring { stroke: var(--blue); }
.map .end-box { fill: var(--ink); }
.map text { font-family: var(--mono); font-size: 6.6px; letter-spacing: .06em; fill: var(--ink-2); text-transform: uppercase; }
.map .name { font-family: var(--serif); font-size: 10.5px; letter-spacing: 0; text-transform: none; fill: var(--ink); font-style: italic; }
.map .ex { fill: var(--blue); font-size: 6.2px; }
.map .ex-line { stroke: var(--blue); stroke-width: .5; }
.map .exg { opacity: 0; transition: opacity var(--slow); pointer-events: none; }
.explain .map .exg { opacity: 1; }
.map .pg { transition: opacity 600ms; }
.map .pg-body { fill: var(--ink); }
.map .pg-env { fill: var(--paper); stroke: var(--ink); stroke-width: .7; }
.map .pg.re .pg-env { stroke: var(--red); }
.map .pg-num { font-size: 6px; fill: var(--ink); }
.map .pg.re .pg-num { fill: var(--red); }
.map .wing {
  fill: var(--ink);
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: flap 1.1s ease-in-out infinite alternate;
}
@keyframes flap { from { transform: scaleY(1); } to { transform: scaleY(-.35); } }
.map .lost line { stroke: var(--red); stroke-width: 1.3; }
.map .lost text { fill: var(--red); font-size: 6px; }
.map .resend { fill: var(--red); }

.slots {
  list-style: none;
  margin: 10px 0 0;
  padding: 12px 0 0;
  border-top: 1px solid var(--rule);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 12px 6px;
}
.slot { text-align: center; font-family: var(--mono); font-size: 10px; letter-spacing: .03em; color: var(--ink-3); }
.slot svg { display: block; width: 34px; height: 24px; margin: 0 auto 4px; overflow: visible; }
.slot .env { fill: none; stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 2 2; transition: stroke 600ms, fill 600ms; }
.slot .flap { fill: none; stroke: var(--ink-3); stroke-width: 1; opacity: 0; transition: opacity 600ms; }
.slot .tick { fill: none; stroke: var(--blue); stroke-width: 1.4; stroke-dasharray: 20; stroke-dashoffset: 20; transition: stroke-dashoffset 700ms ease; }
.slot .x { stroke: var(--red); stroke-width: 1.3; opacity: 0; }
.slot .sum { display: block; height: 1.3em; color: var(--ink-3); }
.slot.got { color: var(--ink); }
.slot.got .env { stroke: var(--ink); stroke-dasharray: none; fill: var(--paper); }
.slot.got .flap { opacity: 1; stroke: var(--ink); }
.slot.got .tick { stroke-dashoffset: 0; }
.slot.buf .env { stroke: var(--blue); }
.slot.buf .flap { stroke: var(--blue); }
.slot.buf { color: var(--blue); }
.slot.lost .x { opacity: 1; }
.slot.lost { color: var(--red); }
.slot.sealed.got .env { fill: var(--paper-2); }

.buffer {
  margin: 14px 0 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.buffer .wait { color: var(--blue); }
.buffer .miss { color: var(--red); }

/* link */
.linkbox { margin-top: 10px; padding-top: 22px; border-top: 1px solid var(--ink); }
.linkbox input { font-family: var(--mono); font-size: 13px; color: var(--ink-2); text-overflow: ellipsis; }
.fine { margin: 12px 0 8px; max-width: 46em; color: var(--ink-2); line-height: 1.7; letter-spacing: .04em; text-transform: none; font-size: 12px; }
.fine b { color: var(--red); font-weight: 500; }

/* letter */
.letter-frame {
  position: relative;
  padding: 6px;
  margin: 8px 0 0;
  background: repeating-linear-gradient(-45deg,
    var(--red) 0 9px, var(--paper) 9px 13px,
    var(--blue) 13px 22px, var(--paper) 22px 26px);
}
.letter {
  position: relative;
  min-height: 220px;
  padding: 26px 20px 64px;
  background: var(--paper);
}
.salute, .sign { margin: 0; font-style: italic; font-weight: 300; font-size: 19px; color: var(--ink-2); }
.sign { margin-top: 20px; text-align: right; }
.letter-body {
  margin: 16px 0 0;
  font-size: 21px;
  line-height: 1.55;
  font-weight: 340;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-variation-settings: "opsz" 24;
}
.letter-body .gap { color: transparent; border-bottom: 1px dotted var(--ink-3); }
.letter-body .chunk { animation: ink 1.6s ease both; }
@keyframes ink { from { opacity: 0; } to { opacity: 1; } }

.sealed-box { text-align: center; padding: 10px 0 0; white-space: normal; font-size: 17px; }
.sealed-box svg { width: 120px; height: 82px; display: block; margin: 0 auto 18px; }
.sealed-box p { margin: 0 0 16px; color: var(--ink-2); font-size: 16px; }
.sealed-box form { max-width: 300px; margin: 0 auto; text-align: left; }
.sealed-box .btn { width: 100%; margin-top: 4px; }
.sealed-box .error { text-align: center; margin: 12px 0 0; }

.postmark {
  position: absolute;
  left: 8px;
  bottom: -26px;
  width: 112px;
  height: 112px;
  pointer-events: none;
  transform: rotate(-14deg);
}
.postmark svg { width: 100%; height: 100%; overflow: visible; }
.postmark.stamp { animation: stamp 650ms cubic-bezier(.3,.7,.4,1) both; }
@keyframes stamp {
  from { opacity: 0; transform: rotate(-14deg) scale(1.35); }
  to { opacity: .9; transform: rotate(-14deg) scale(1); }
}
.postmark { opacity: .9; }
.postmark text { font-family: var(--mono); fill: var(--red); }
.postmark .pm-ring { fill: none; stroke: var(--red); }

.screen { animation: ink 900ms ease both; }

#broken .btn { margin-top: 8px; }

.foot {
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding: 18px var(--gutter) 22px;
  color: var(--ink-3);
  font-size: 10px;
}

@media (min-width: 620px) {
  :root { --gutter: 28px; }
  main { padding-top: 40px; }
  .packets { grid-template-columns: repeat(3, 1fr); }
  .letter { padding: 40px 44px 44px; }
  .letter-body { font-size: 23px; }
  .postmark { width: 128px; height: 128px; left: 30px; }
  .actions .btn { flex: 0 0 auto; }
  form .btn.primary { width: auto; min-width: 220px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
  .map .wing { animation: none; }
}
