/* Filedrop — airmail counter aesthetic.
   One memorable thing: par-avion stripes + perforated claim ticket.
   Everything else is quiet paper and ink.
   Fonts are self-hosted (vendor/fonts, latin subset) — no Google Fonts
   requests, so claim codes and IPs are never sent to a font CDN. */

@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("vendor/fonts/grotesk-latin.woff2") format("woff2");
}
@font-face {
  font-family: "Space Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("vendor/fonts/mono-400-latin.woff2") format("woff2");
}
@font-face {
  font-family: "Space Mono";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("vendor/fonts/mono-700-latin.woff2") format("woff2");
}

:root {
  color-scheme: light;
  --paper: #ffffff;
  --ink: #1a2b4a;
  --ink-soft: #4a5a78;
  --red: #d43d2a;
  --blue: #2456c8;
  --counter: #f2f0ea;
  --line: #d9d4c7;
  --grotesk: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Space Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--grotesk);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Full-bleed par-avion bar: the single graphic motif. */
.stripe {
  height: 14px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='14' viewBox='0 0 56 14'%3E%3Crect width='56' height='14' fill='%23ffffff'/%3E%3Cpolygon points='0,14 14,0 28,0 14,14' fill='%23d43d2a'/%3E%3Cpolygon points='28,14 42,0 56,0 42,14' fill='%232456c8'/%3E%3C/svg%3E") repeat-x left top;
  background-size: 56px 14px;
}

.page { max-width: 640px; margin: 0 auto; padding: 2.5rem 1.25rem 3rem; }

/* ---------- masthead ---------- */
.masthead { margin-bottom: 2rem; }

.brand { display: flex; align-items: center; gap: 0.7rem; }

.brandmark { width: 44px; height: 44px; border-radius: 10px; display: block; }

.wordmark { font-size: 1.9rem; font-weight: 700; letter-spacing: -0.02em; }

.lede { max-width: 46ch; color: var(--ink-soft); margin: 0.9rem 0 1.6rem; }

/* Segmented Send / Receive control */
.switch {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  border: 2px solid var(--ink);
  border-radius: 12px;
  overflow: hidden;
  min-width: min(100%, 340px);
  background: var(--ink);
}

.switch button {
  appearance: none;
  border: 0;
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  font: 500 1rem var(--grotesk);
  padding: 0.65rem 1rem;
  cursor: pointer;
  min-width: 0;
  touch-action: manipulation;
}

.switch button + button { border-left: 2px solid var(--ink); }
.switch button.active { background: var(--ink); color: var(--paper); }

/* ---------- send counter ---------- */
.counter {
  background: var(--counter);
  border: 2px dashed var(--ink-soft);
  border-radius: 16px;
  padding: 3rem 1.5rem;
  text-align: center;
}

.counter:not([hidden]) { animation: rise 0.5s ease both; }

.counter.over { border-color: var(--blue); border-style: solid; background: #e9eefb; }
.counter-icon { color: var(--blue); }
.counter-title { font-size: 1.35rem; font-weight: 700; margin: 0.8rem 0 0.2rem; }
.counter-sub { margin: 0; }
.counter-note { color: var(--ink-soft); font-size: 0.9rem; margin: 0.9rem 0 0; }

.filelink { color: var(--blue); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.filelink:focus-within { outline: 3px solid var(--blue); outline-offset: 2px; border-radius: 4px; }

/* Visually hidden but keyboard-focusable and tap-friendly (unlike `hidden`).
   iOS Safari ignores clicks on inputs hidden via clip/position:absolute, so we
   use opacity:0 + size:1px instead — still invisible but tappable. */
.vh-input { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; opacity: 0; pointer-events: none; border: 0; }

/* Inline batch-rejection state: red-tinted, impossible to miss, dropzone stays. */
.send-error {
  border: 2px solid var(--red);
  background: #fdecea;
  color: var(--ink);
  border-radius: 12px;
  padding: 0.8rem 1rem;
  margin: 1rem 0 0;
  font-weight: 500;
}

/* ---------- claim ticket ---------- */
#send-panel:not([hidden]) .ticket { animation: rise 0.45s ease both; }

.ticket {
  display: grid;
  grid-template-columns: minmax(0, auto) 2px minmax(0, 1fr);
  border: 2px solid var(--ink);
  border-radius: 14px;
  overflow: hidden;
  background: var(--paper);
  box-shadow: 6px 6px 0 var(--ink);
}

.stub {
  grid-column: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1.5rem 1.25rem;
  background: var(--ink);
  color: var(--paper);
}

.stub-label { font-size: 0.8rem; color: #b9c3da; }

/* 12-char codes must fit: fluid size, wraps mid-code on narrow tickets. */
#share-code {
  font-family: var(--mono);
  font-weight: 700;
  font-size: clamp(1.05rem, 1rem + 2.2vw, 1.5rem);
  letter-spacing: 0.08em;
  text-align: center;
  line-height: 1.25;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.tear {
  grid-column: 2;
  border-left: 2px dashed var(--line);
  min-height: 100%;
}

.ticket .body { grid-column: 3; padding: 1.25rem 1.25rem 1.1rem; min-width: 0; }

.fileline { margin: 0 0 0.2rem; overflow-wrap: anywhere; }
.bytes { font-family: var(--mono); font-size: 0.85em; color: var(--ink-soft); }
.hint { color: var(--ink-soft); font-size: 0.92rem; margin: 0 0 0.9rem; }

.linkrow { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.linkrow input {
  flex: 1 1 200px;
  min-width: 0;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
  background: var(--paper);
}

.progressline { display: flex; align-items: center; gap: 0.7rem; margin-top: 1rem; }

progress {
  flex: 1;
  height: 12px;
  appearance: none;
  border: 1px solid var(--ink);
  border-radius: 99px;
  background: var(--paper);
  overflow: hidden;
}
progress::-webkit-progress-bar { background: var(--paper); }
progress::-webkit-progress-value {
  background: repeating-linear-gradient(-45deg, var(--blue) 0 8px, var(--red) 8px 16px);
}
progress::-moz-progress-bar {
  background: repeating-linear-gradient(-45deg, var(--blue) 0 8px, var(--red) 8px 16px);
}

/* Indeterminate "something is happening" shimmer while connecting. */
progress.busy::-webkit-progress-value {
  background: repeating-linear-gradient(-45deg, var(--line) 0 10px, #fff 10px 20px);
  animation: slide 0.8s linear infinite;
}
progress.busy::-moz-progress-bar {
  background: repeating-linear-gradient(-45deg, var(--line) 0 10px, #fff 10px 20px);
  animation: slide 0.8s linear infinite;
}

/* Big readout + liveness dot: progress you can see across the room. */
#send-pct, #receive-pct { font-size: 1.5rem; font-weight: 700; color: var(--ink); }
.live {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: auto;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  white-space: nowrap;
}
.livedot { width: 0.6rem; height: 0.6rem; border-radius: 50%; background: var(--line); }
.live[data-live="on"] { color: var(--ink); }
.live[data-live="on"] .livedot { background: var(--red); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }
@keyframes slide { to { background-position: 28px 0; } }

#vault h2 { font-size: 1.05rem; margin: 1.8rem 0 0.2rem; }

.status { font-weight: 500; margin: 0.7rem 0 0; }

.actionrow { display: flex; gap: 0.6rem; margin-top: 0.9rem; flex-wrap: wrap; }

/* ---------- buttons ---------- */
button {
  font-family: var(--grotesk);
  font-size: 1rem;
  font-weight: 500;
  border-radius: 10px;
  padding: 0.6rem 1.1rem;
  cursor: pointer;
}

button.primary {
  background: var(--ink);
  border: 2px solid var(--ink);
  color: #fff;
}
button.primary:hover { background: #2c3f66; border-color: #2c3f66; }
button.primary:active, button.ghost:active { filter: brightness(0.9); }
button.quiet:active { transform: translateY(1px); }

button.ghost {
  background: transparent;
  border: 1.5px solid #b9c3da;
  color: var(--paper);
  font-size: 0.85rem;
  padding: 0.3rem 0.8rem;
}
button.ghost:hover { border-color: #fff; }

button.quiet {
  background: transparent;
  border: 2px solid var(--ink-soft);
  border-radius: 10px;
  color: var(--ink);
  text-decoration: none;
  padding: 0.5rem 1rem;
}
button.quiet:hover { border-color: var(--red); color: var(--red); }

/* ---------- receive form ---------- */
.claim { display: grid; gap: 0.9rem; }

.field { display: grid; gap: 0.35rem; font-weight: 500; }

#receive-code {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 1.6rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border: 2px solid var(--ink);
  border-radius: 10px;
  padding: 0.7rem 0.9rem;
  width: 100%;
  color: var(--ink);
  background: var(--paper);
}

.primary { justify-self: start; }

.filelist {
  list-style: none;
  margin: 0 0 0.9rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.filelist:empty { display: none; }
.filelist li {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.45rem 0.7rem;
  font-size: 0.92rem;
}
.filelist li + li { border-top: 1px dashed var(--line); }
.filelist .fname { font-weight: 500; overflow-wrap: anywhere; min-width: 0; }
.filelist .bytes { margin-left: auto; white-space: nowrap; }
.filelist .fstate { white-space: nowrap; color: var(--ink-soft); font-size: 0.85rem; }
.filelist li[data-state="sending"] .fstate,
.filelist li[data-state="receiving"] .fstate { color: var(--blue); }
.filelist li[data-state="sent"] .fstate,
.filelist li[data-state="done"] .fstate { color: #1e7d32; }

.minilink { color: var(--red); font-weight: 700; }
.minilink:hover { color: #b23222; }

/* Security warning for risky file types (executables, scripts, HTML/SVG). */
.filewarn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: 0.5rem;
  padding: 0.1rem 0.45rem;
  border: 1.5px solid var(--red);
  border-radius: 99px;
  color: var(--red);
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}
.filelist li[data-state="error"] .fstate { color: var(--red); font-weight: 700; }

/* Short-authentication-string (MITM check) + ephemeral vault opt-out. */
.sas {
  margin: 0.6rem 0 0;
  padding: 0.5rem 0.7rem;
  border: 1.5px dashed var(--blue);
  border-radius: 10px;
  font-size: 0.92rem;
}
.sas-code { font-family: var(--mono); letter-spacing: 0.1em; }
.ephem { display: flex; align-items: center; gap: 0.45rem; margin: 0 0 0.8rem; font-size: 0.92rem; }

/* ---------- qr ---------- */
.qrwrap { display: flex; align-items: center; gap: 1rem; margin: 1.2rem 0 0; }
.qrwrap img { border: 2px solid var(--ink); border-radius: 10px; display: block; flex: none; }
.qrwrap img[hidden] { display: none; }
.qrwrap img[hidden] + figcaption { display: none; }
.qrwrap figcaption { color: var(--ink-soft); font-size: 0.85rem; margin: 0; max-width: 26ch; }

/* ---------- footer ---------- */
footer { margin-top: 3rem; border-top: 1px solid var(--line); padding-top: 1rem; }
footer p { color: var(--ink-soft); font-size: 0.85rem; margin: 0; max-width: 60ch; }

/* ---------- motion, focus, small screens ---------- */
@keyframes rise {
  from { transform: translateY(12px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

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

@media (max-width: 520px) {
  .ticket { grid-template-columns: 1fr; }
  .tear { grid-column: 1; border-left: 0; border-top: 2px dashed var(--line); min-height: 0; }
  .stub { grid-column: 1; padding: 1.1rem; }
  .ticket .body { grid-column: 1; }
  .linkrow { flex-direction: column; }
  .linkrow .primary { width: 100%; }
  .primary { justify-self: stretch; }
  .qrwrap { flex-wrap: wrap; }
}

/* ---------- fx: GSAP + anime.js animation flood (additive, no layout changes) ---------- */
.fx-ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.page { position: relative; z-index: 1; }
.stripe { position: relative; z-index: 1; animation: stripe-slide 18s linear infinite; }
@keyframes stripe-slide { to { background-position-x: 56px; } }

.orb { position: absolute; border-radius: 50%; filter: blur(46px); opacity: 0.5; will-change: transform; }
.orb-a { width: 340px; height: 340px; left: -110px; top: 8vh; background: radial-gradient(circle at 35% 35%, #ffd9d2, #d43d2a55 60%, transparent 70%); animation: orb-drift-a 16s ease-in-out infinite alternate; }
.orb-b { width: 300px; height: 300px; right: -100px; top: 32vh; background: radial-gradient(circle at 60% 40%, #d4e2ff, #2456c855 60%, transparent 70%); animation: orb-drift-b 20s ease-in-out infinite alternate; }
.orb-c { width: 220px; height: 220px; left: 30vw; bottom: -90px; background: radial-gradient(circle at 50% 50%, #fff3c4, #d9d4c755 65%, transparent 72%); animation: orb-drift-a 24s ease-in-out infinite alternate-reverse; }
@keyframes orb-drift-a { from { transform: translate3d(0, 0, 0) scale(1); } to { transform: translate3d(46px, 34px, 0) scale(1.12); } }
@keyframes orb-drift-b { from { transform: translate3d(0, 0, 0) scale(1.05); } to { transform: translate3d(-52px, -30px, 0) scale(0.94); } }

.fx-plane { position: absolute; color: var(--ink-soft); opacity: 0.35; will-change: transform; }
.fx-plane.p1 { left: 6vw; top: 22vh; }
.fx-plane.p2 { right: 10vw; top: 14vh; opacity: 0.28; }
.fx-plane.p3 { left: 16vw; bottom: 12vh; opacity: 0.22; }

#fx-confetti { position: fixed; inset: 0; z-index: 60; pointer-events: none; overflow: hidden; }
#fx-confetti .cfetti { position: absolute; left: 0; top: 0; width: 9px; height: 13px; border-radius: 2px; will-change: transform, opacity; }

/* Brand + wordmark */
.brandmark { will-change: transform; }
.wordmark .wm-char { display: inline-block; will-change: transform; }
.brand:hover .brandmark { animation: brand-wiggle 0.6s ease; }
@keyframes brand-wiggle { 25% { transform: rotate(-10deg) scale(1.06); } 55% { transform: rotate(8deg) scale(1.03); } 100% { transform: none; } }

/* Counter tilt + glow */
.counter { transform-style: preserve-3d; will-change: transform; transition: box-shadow 0.25s ease, border-color 0.25s ease, background 0.25s ease; }
.counter.over { box-shadow: 0 14px 44px #2456c833, 0 0 0 4px #2456c822; }
.counter.over .counter-icon { animation: icon-bounce 0.55s ease; color: var(--red); }
.counter-icon { will-change: transform; }
@keyframes icon-bounce { 30% { transform: translateY(-9px) scale(1.12); } 60% { transform: translateY(2px) scale(0.97); } 100% { transform: none; } }
.counter-title { will-change: transform; }

/* Ticket entrance + success */
.ticket { transform-style: preserve-3d; will-change: transform; }
.ticket.sent-glow { box-shadow: 6px 6px 0 var(--ink), 0 0 0 5px #1e7d3244, 0 18px 60px #1e7d3233; }
.fx-stamp {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  position: absolute; right: 14px; top: 12px;
  font-family: var(--mono); font-weight: 700; font-size: 0.8rem; letter-spacing: 0.14em;
  color: #1e7d32; border: 2px solid #1e7d32; border-radius: 8px;
  padding: 0.15rem 0.55rem; transform: rotate(9deg);
  background: #ffffffdd; pointer-events: none;
}
.ticket { position: relative; }
#share-code .code-char { display: inline-block; will-change: transform, opacity; }

/* File rows */
.filelist li { will-change: transform, opacity; }
.filelist li.fx-enter { animation: row-in 0.45s cubic-bezier(0.2, 0.9, 0.25, 1.2) both; }
@keyframes row-in { from { transform: translateX(-16px); opacity: 0; } to { transform: none; opacity: 1; } }
.filelist li[data-state="sent"] .fstate, .filelist li[data-state="done"] .fstate { animation: state-pop 0.4s ease; display: inline-block; }
@keyframes state-pop { 0% { transform: scale(0.6); } 60% { transform: scale(1.18); } 100% { transform: scale(1); } }

/* Buttons: magnetic + ripple */
button { position: relative; overflow: hidden; will-change: transform; touch-action: manipulation; }
button.fx-press { animation: btn-press 0.18s ease; }
@keyframes btn-press { 50% { transform: scale(0.96); } }
.fx-ripple { position: absolute; border-radius: 50%; background: currentColor; opacity: 0.25; transform: scale(0); pointer-events: none; }
.switch button { overflow: hidden; }

/* Progress glow while live */
.progressline.live-flow progress { box-shadow: 0 0 0 3px #2456c822, 0 6px 22px #2456c833; }
#send-pct, #receive-pct { display: inline-block; will-change: transform; }

/* Status swap */
.status { will-change: transform, opacity; }

/* Receive input */
#receive-code { transition: box-shadow 0.25s ease, border-color 0.25s ease, transform 0.25s ease; }
#receive-code:focus { box-shadow: 0 0 0 4px #2456c833, 0 10px 30px #2456c822; border-color: var(--blue); }
.fx-shake { animation: fx-shake 0.45s ease !important; border-color: var(--red) !important; }
@keyframes fx-shake { 20% { transform: translateX(-8px); } 40% { transform: translateX(7px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(4px); } }
#receive-reconnect.fx-attn { animation: attn-pulse 1.4s ease-in-out infinite; }
@keyframes attn-pulse { 50% { transform: scale(1.05); box-shadow: 0 8px 28px #2456c855; } }

/* QR pop */
.qrwrap img { will-change: transform; }
.qrwrap img.fx-pop { animation: qr-pop 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.4) both; }
@keyframes qr-pop { from { transform: scale(0.6) rotate(-4deg); opacity: 0; } to { transform: none; opacity: 1; } }

/* Copy success */
button.fx-copied { border-color: #1e7d32 !important; color: #1e7d32 !important; }

/* Vault */
#vault-list li.fx-enter { animation: row-in 0.4s ease both; }

/* Footer */
footer { will-change: transform, opacity; }

@media (max-width: 520px) {
  .orb-a { width: 220px; height: 220px; }
  .orb-b { width: 190px; height: 190px; }
  .fx-plane.p2, .fx-plane.p3 { display: none; }
}

/* ---------- custom svg icons (no emoji anywhere in the UI) ---------- */
.fd-icon { width: 1em; height: 1em; flex: none; }
.filewarn .fd-icon { width: 0.95em; height: 0.95em; }
.fx-stamp .fd-icon { width: 0.95em; height: 0.95em; }
#sound-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  padding: 0.4rem 0.8rem;
  margin-top: 0.7rem;
}
#sound-toggle .snd-icon { width: 16px; height: 16px; flex: none; }

/* ---------- toast notifications ---------- */
.toasts {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 1rem;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: min(92vw, 420px);
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 12px;
  padding: 0.65rem 0.8rem;
  box-shadow: 4px 4px 0 var(--ink);
  font-weight: 500;
  animation: toast-in 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}
.toast.warn { border-color: var(--red); box-shadow: 4px 4px 0 var(--red); }
.toast .fd-icon { width: 18px; height: 18px; }
.toast.warn .fd-icon { color: var(--red); }
.toast.info .fd-icon { color: var(--blue); }
.toast span { overflow-wrap: anywhere; }
.toast-x {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font-size: 1.1rem;
  line-height: 1;
  padding: 0.2rem 0.4rem;
  flex: none;
}
.toast-x:hover { color: var(--ink); }
.toast.leaving { animation: toast-out 0.25s ease both; }
@keyframes toast-in { from { transform: translateY(14px); opacity: 0; } }
@keyframes toast-out { to { transform: translateY(8px); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .counter:not([hidden]), #send-panel:not([hidden]) .ticket { animation: none; }
  .live[data-live="on"] .livedot, progress.busy::-webkit-progress-value,
  progress.busy::-moz-progress-bar { animation: none; }
  button.quiet:active { transform: none; }
  .toast, .toast.leaving { animation: none; }
  .stripe, .orb-a, .orb-b, .orb-c,
  .filelist li.fx-enter, #vault-list li.fx-enter,
  .counter.over .counter-icon, #receive-reconnect.fx-attn,
  .qrwrap img.fx-pop, button.fx-press, .fx-shake { animation: none !important; }
   .fx-ambient, #fx-confetti { display: none !important; }
}
