/* =============================================================================
   Wormhole — drop text or a small file in, get one short code out.

   Deep space rather than Classified's dossier: a slow-turning portal, a
   starfield, and two panels for the two ends of the tunnel (violet sends,
   cyan receives). The page runs under a route-specific CSP (style-src 'self',
   img-src 'self' blob:), so everything here is pure CSS — no data: URIs, no
   inline styles. Persian text is never letter-spaced or upper-cased, and
   every looping animation stops under reduced motion.
   ========================================================================== */

.wormhole-page {
  --wh-space: #04050c;
  --wh-panel: #0a0c18;
  --wh-panel-2: #0e1122;
  --wh-well: #05060d;
  --wh-line: rgb(190 200 255 / 10%);
  --wh-line-strong: rgb(190 200 255 / 18%);
  --wh-send: var(--violet-400);
  --wh-send-deep: var(--violet-500);
  --wh-receive: var(--accent-400);
  --wh-ok: var(--ok-400);
  --wh-bad: var(--danger-400);
  --wh-dim: var(--text-dim);

  position: relative;
  isolation: isolate;
  overflow: clip;
  /* The header is fixed; base.css supplies the trailing space before the footer. */
  padding-block-start: var(--header-h);
  background:
    radial-gradient(ellipse 70rem 34rem at 50% -8rem, rgb(139 92 246 / 14%), transparent 70%),
    radial-gradient(ellipse 40rem 26rem at 85% 38rem, rgb(34 211 238 / 6%), transparent 70%),
    linear-gradient(180deg, var(--bg), var(--wh-space) 25%, var(--wh-space) 85%, var(--bg));
}

/* Anything with a display of its own still honours [hidden]. */
.wormhole-page [hidden] { display: none !important; }

/* A starfield from a handful of tiled gradients: cheap, and no image request. */
.wormhole-stars {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.7;
  background:
    radial-gradient(1px 1px at 12% 18%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 68% 9%, rgb(255 255 255 / 80%) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 33% 62%, rgb(196 181 253 / 90%) 50%, transparent 51%),
    radial-gradient(1px 1px at 82% 44%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 51% 83%, rgb(165 243 252 / 80%) 50%, transparent 51%),
    radial-gradient(1px 1px at 7% 71%, rgb(255 255 255 / 70%) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 91% 77%, #fff 50%, transparent 51%);
  background-size: 23rem 19rem;
  animation: wormhole-drift 120s linear infinite;
}
@keyframes wormhole-drift { to { background-position: 23rem 38rem; } }

/* --- Hero ------------------------------------------------------------------- */
.wormhole-hero {
  max-width: 72rem;
  padding-block: clamp(1.75rem, 4vw, 3.5rem) var(--space-10);
}
.wormhole-back {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-block-end: var(--space-8);
  color: var(--text-muted);
  font-size: var(--text-sm);
  text-decoration: none;
  transition: color var(--dur-fast);
}
.wormhole-back:hover { color: var(--wh-send); }
.wormhole-hero__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(14rem, 0.7fr);
  gap: clamp(1.5rem, 4vw, 3.5rem);
  align-items: center;
}
.wormhole-kicker,
.wormhole-label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  unicode-bidi: isolate;
}
:lang(fa) :is(.wormhole-kicker, .wormhole-label, .wormhole-field > span:first-child, .wormhole-lifetimes legend) {
  font-family: var(--font-sans);
  letter-spacing: 0;
  text-transform: none;
}
.wormhole-kicker {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-block: 0 var(--space-4);
  color: var(--wh-send);
  font-weight: 700;
}
.wormhole-pulse {
  flex: none;
  inline-size: 0.5rem;
  block-size: 0.5rem;
  border-radius: 50%;
  background: var(--wh-receive);
  box-shadow: 0 0 0 3px rgb(34 211 238 / 15%), 0 0 12px rgb(34 211 238 / 70%);
  animation: wormhole-pulse 2.4s ease-in-out infinite;
}
@keyframes wormhole-pulse { 50% { opacity: 0.45; box-shadow: 0 0 0 6px rgb(34 211 238 / 0%), 0 0 4px rgb(34 211 238 / 30%); } }
.wormhole-title {
  margin-block: 0 var(--space-5);
  font-size: var(--text-5xl);
  font-weight: 900;
  line-height: 1.1;
  background: linear-gradient(100deg, #f5f3ff 10%, var(--wh-send) 45%, var(--wh-receive) 90%);
  background-clip: text;
  color: transparent;
}
.wormhole-hero .lede { max-width: 44rem; margin: 0; color: var(--text-soft); }
.wormhole-facts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: var(--space-6) 0 0;
  padding: 0;
  list-style: none;
}
.wormhole-facts li {
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--wh-line-strong);
  border-radius: var(--r-full);
  background: rgb(255 255 255 / 3%);
  color: var(--text-soft);
  font-size: var(--text-sm);
}

/* The portal: four rings turning at different speeds around a glowing core. */
.wormhole-portal {
  position: relative;
  justify-self: center;
  inline-size: min(100%, 17rem);
  aspect-ratio: 1;
}
.wormhole-portal__ring,
.wormhole-portal__core {
  position: absolute;
  border-radius: 50%;
}
.wormhole-portal__ring {
  inset: 0;
  border: 2px solid transparent;
  background:
    conic-gradient(from 0deg, transparent 0 20%, var(--wh-send) 35%, transparent 55%, var(--wh-receive) 80%, transparent 95%) border-box;
  mask: linear-gradient(#000 0 0) padding-box exclude, linear-gradient(#000 0 0) border-box;
  animation: wormhole-spin 14s linear infinite;
}
.wormhole-portal__ring:nth-child(2) { inset: 12%; animation-duration: 10s; animation-direction: reverse; opacity: 0.85; }
.wormhole-portal__ring:nth-child(3) { inset: 24%; animation-duration: 7s; opacity: 0.75; }
.wormhole-portal__ring:nth-child(4) { inset: 35%; animation-duration: 4.5s; animation-direction: reverse; opacity: 0.65; }
.wormhole-portal__core {
  inset: 42%;
  background: radial-gradient(circle, #fff 0 15%, rgb(196 181 253 / 90%) 35%, rgb(139 92 246 / 0%) 72%);
  box-shadow: 0 0 40px 12px rgb(139 92 246 / 45%), 0 0 90px 30px rgb(34 211 238 / 18%);
  animation: wormhole-breathe 3.2s ease-in-out infinite;
}
@keyframes wormhole-spin { to { transform: rotate(1turn); } }
@keyframes wormhole-breathe { 50% { transform: scale(1.18); } }
/* Faster while something is going through. */
.wormhole-page.is-sending .wormhole-portal__ring,
.wormhole-page.is-receiving-now .wormhole-portal__ring { animation-duration: 1.4s; }

/* --- Panels ------------------------------------------------------------------- */
.wormhole-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: start;
  gap: var(--space-6);
  max-width: 72rem;
}
/* Arriving by link: the receiving end comes first. */
.wormhole-page.is-receiving .wormhole-panel--receive { order: -1; }

.wormhole-panel {
  --wh-accent: var(--wh-send);
  position: relative;
  min-inline-size: 0;
  padding: clamp(1.125rem, 3vw, 2rem);
  border: 1px solid var(--wh-line-strong);
  border-radius: var(--r-xl);
  background: linear-gradient(180deg, var(--wh-panel-2), var(--wh-panel));
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgb(255 255 255 / 5%);
}
.wormhole-panel::before {
  content: '';
  position: absolute;
  inset-block-start: -1px;
  inset-inline: 12%;
  block-size: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--wh-accent), transparent);
  pointer-events: none;
}
.wormhole-panel--receive { --wh-accent: var(--wh-receive); }
.wormhole-panel__head {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding-block-end: var(--space-4);
  margin-block-end: var(--space-5);
  border-block-end: 1px solid var(--wh-line);
}
.wormhole-step {
  display: grid;
  place-items: center;
  flex: none;
  inline-size: 2.5rem;
  block-size: 2.5rem;
  border: 1px solid color-mix(in srgb, var(--wh-accent) 50%, transparent);
  border-radius: 50%;
  background: color-mix(in srgb, var(--wh-accent) 10%, transparent);
  color: var(--wh-accent);
  font-size: var(--text-lg);
  font-weight: 800;
}
.wormhole-label {
  margin: 0 0 var(--space-1);
  color: var(--wh-accent, var(--wh-send));
  font-weight: 700;
}
.wormhole-panel h2,
.wormhole-notes h2 {
  margin: 0;
  color: var(--text);
  font-size: var(--text-xl);
  line-height: var(--leading-tight);
}
.wormhole-form { display: grid; gap: var(--space-5); }

/* --- Fields ----------------------------------------------------------------- */
.wormhole-field { display: grid; gap: var(--space-2); margin: 0; }
.wormhole-field > span:first-child {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
}
.wormhole-field textarea,
.wormhole-field input {
  inline-size: 100%;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--wh-line-strong);
  border-radius: var(--r-md);
  background: var(--wh-well);
  color: var(--text);
  font: inherit;
  line-height: var(--leading-snug);
  box-shadow: inset 0 2px 10px rgb(0 0 0 / 50%);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.wormhole-field textarea { min-block-size: 7.5rem; resize: vertical; }
.wormhole-field :is(textarea, input)::placeholder { color: var(--wh-dim); }
.wormhole-field :is(textarea, input):hover { border-color: rgb(190 200 255 / 30%); }
.wormhole-field :is(textarea, input):focus {
  border-color: var(--wh-accent);
  box-shadow: inset 0 2px 10px rgb(0 0 0 / 50%), 0 0 0 3px color-mix(in srgb, var(--wh-accent) 22%, transparent);
  outline: none;
}
.wormhole-code-input {
  font-family: var(--font-mono) !important;
  font-size: var(--text-2xl) !important;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-align: center;
  text-transform: uppercase;
}
.wormhole-code-input::placeholder { letter-spacing: 0.18em; }

.wormhole-help { margin: 0; color: var(--wh-dim); font-size: var(--text-xs); line-height: var(--leading-snug); }

/* File drop zone. The real input is visually hidden but stays focusable. */
.wormhole-dropzone {
  position: relative;
  display: grid;
  gap: var(--space-3);
  padding: var(--space-5);
  border: 1.5px dashed var(--wh-line-strong);
  border-radius: var(--r-lg);
  background: rgb(139 92 246 / 4%);
  transition: border-color var(--dur-fast), background var(--dur-fast);
}
.wormhole-dropzone:hover,
.wormhole-dropzone.is-dragging { border-color: var(--wh-send); background: rgb(139 92 246 / 10%); }
.wormhole-dropzone:focus-within { border-color: var(--wh-send); box-shadow: 0 0 0 3px rgb(167 139 250 / 25%); }
.wormhole-dropzone.has-file { border-style: solid; border-color: rgb(167 139 250 / 55%); }
.wormhole-file-input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.wormhole-dropzone__label {
  display: grid;
  justify-items: center;
  gap: var(--space-2);
  color: var(--text-soft);
  font-size: var(--text-sm);
  text-align: center;
  cursor: pointer;
}
.wormhole-dropzone__icon { color: var(--wh-send); font-size: var(--text-3xl); line-height: 1; }
.wormhole-dropzone__text strong { color: var(--text); }
.wormhole-chips {
  display: grid;
  gap: var(--space-2);
  max-block-size: 15rem;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}
.wormhole-total {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.wormhole-total[data-state='over'] { color: var(--wh-bad); font-weight: 700; }
.wormhole-chip {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: 0;
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-4);
  border: 1px solid rgb(167 139 250 / 35%);
  border-radius: var(--r-full);
  background: rgb(139 92 246 / 12%);
  font-size: var(--text-sm);
}
:dir(rtl) .wormhole-chip { padding: var(--space-2) var(--space-4) var(--space-2) var(--space-2); }
.wormhole-chip__name {
  flex: 1;
  min-inline-size: 0;
  overflow: hidden;
  color: var(--text);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wormhole-chip__size { flex: none; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.wormhole-chip__clear {
  display: grid;
  place-items: center;
  flex: none;
  inline-size: 2rem;
  block-size: 2rem;
  border: 0;
  border-radius: 50%;
  background: rgb(255 255 255 / 8%);
  color: var(--text);
  font-size: var(--text-lg);
  line-height: 1;
  cursor: pointer;
}
.wormhole-chip__clear:hover { background: rgb(248 113 113 / 20%); color: var(--wh-bad); }
.wormhole-chip__clear:focus-visible { outline: 2px solid var(--wh-send); outline-offset: 2px; }

/* Lifetime pills. */
.wormhole-lifetimes {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  border: 0;
}
.wormhole-lifetimes legend {
  float: inline-start;
  margin-inline-end: var(--space-3);
  padding: 0;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
}
.wormhole-pill { position: relative; cursor: pointer; }
.wormhole-pill input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.wormhole-pill span {
  display: block;
  padding: 0.4rem 0.95rem;
  border: 1px solid var(--wh-line-strong);
  border-radius: var(--r-full);
  color: var(--text-soft);
  font-size: var(--text-sm);
  font-weight: 600;
  transition: border-color var(--dur-fast), background var(--dur-fast), color var(--dur-fast);
}
.wormhole-pill:hover span { border-color: rgb(167 139 250 / 50%); }
.wormhole-pill input:checked + span { border-color: var(--wh-send); background: rgb(139 92 246 / 22%); color: #fff; }
.wormhole-pill input:focus-visible + span { box-shadow: 0 0 0 3px rgb(167 139 250 / 35%); }

/* One-time switch. */
.wormhole-toggle {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  cursor: pointer;
}
.wormhole-toggle input {
  flex: none;
  inline-size: 1.15rem;
  block-size: 1.15rem;
  margin: 0.2rem 0 0;
  accent-color: var(--wh-send);
}
.wormhole-toggle input:focus-visible { outline: 2px solid var(--wh-send); outline-offset: 2px; }
.wormhole-toggle strong { display: block; color: var(--text); font-size: var(--text-sm); }
.wormhole-toggle small { display: block; color: var(--wh-dim); font-size: var(--text-xs); }

.wormhole-submit { justify-self: start; }
.wormhole-panel--send .wormhole-submit { background: linear-gradient(100deg, var(--wh-send-deep), var(--wh-send)); border-color: transparent; }
.wormhole-panel--receive .wormhole-submit { background: linear-gradient(100deg, var(--accent-600), var(--wh-receive)); border-color: transparent; color: #021014; }

/* Progress bar. */
.wormhole-progress {
  inline-size: 100%;
  block-size: 6px;
  border: 0;
  border-radius: var(--r-full);
  background: rgb(255 255 255 / 8%);
  overflow: hidden;
  appearance: none;
}
.wormhole-progress::-webkit-progress-bar { background: rgb(255 255 255 / 8%); border-radius: var(--r-full); }
.wormhole-progress::-webkit-progress-value { background: linear-gradient(90deg, var(--wh-send), var(--wh-receive)); border-radius: var(--r-full); }
.wormhole-progress::-moz-progress-bar { background: linear-gradient(90deg, var(--wh-send), var(--wh-receive)); border-radius: var(--r-full); }

/* Status lines. */
.wormhole-status {
  min-block-size: 1.5em;
  margin: 0;
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
}
.wormhole-status[data-state='pending'] { color: var(--text-soft); }
.wormhole-status[data-state='pending']::after {
  content: '';
  display: inline-block;
  inline-size: 0.5em;
  block-size: 0.5em;
  margin-inline-start: 0.5em;
  border-radius: 50%;
  background: var(--wh-receive);
  animation: wormhole-pulse 1s ease-in-out infinite;
}
.wormhole-status[data-state='success'] { color: var(--wh-ok); }
.wormhole-status[data-state='error'] { color: var(--wh-bad); }

/* --- Share: the code ---------------------------------------------------------- */
.wormhole-share,
.wormhole-result { display: grid; gap: var(--space-4); }
.wormhole-share > h2,
.wormhole-result > h2 { margin-block-end: var(--space-1); }
.wormhole-code {
  margin: 0;
  padding: var(--space-5) var(--space-4);
  border: 1px solid rgb(167 139 250 / 40%);
  border-radius: var(--r-lg);
  background:
    radial-gradient(ellipse at 50% 120%, rgb(139 92 246 / 25%), transparent 70%),
    var(--wh-well);
  color: #fff;
  font-family: var(--font-mono);
  font-size: clamp(1.75rem, 1.2rem + 3vw, 2.75rem);
  font-weight: 800;
  letter-spacing: 0.14em;
  text-align: center;
  text-shadow: 0 0 24px rgb(167 139 250 / 55%);
  user-select: all;
  overflow-wrap: anywhere;
}
.wormhole-code:focus { outline: none; }
.wormhole-code:focus-visible { box-shadow: 0 0 0 3px rgb(167 139 250 / 35%); }
.wormhole-link {
  margin: 0;
  color: var(--wh-receive);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  text-align: center;
  overflow-wrap: anywhere;
  user-select: all;
}
.wormhole-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); justify-content: center; }
.wormhole-qr {
  justify-self: center;
  inline-size: min(100%, 15rem);
  padding: var(--space-2);
  border-radius: var(--r-md);
  background: #fff;
}
.wormhole-qr svg { display: block; inline-size: 100%; block-size: auto; }
.wormhole-countdown {
  margin: 0;
  color: var(--text-soft);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
  text-align: center;
}
:lang(fa) .wormhole-countdown { font-family: var(--font-sans); }
.wormhole-countdown:empty { display: none; }
.wormhole-countdown[data-state='urgent'] { color: var(--warn-400); }
.wormhole-countdown[data-state='expired'] { color: var(--wh-bad); }
.wormhole-share .wormhole-help { text-align: center; }
.wormhole-again { justify-self: center; }

/* A package arriving: it unfolds out of the portal. */
.wormhole-share.is-arriving,
.wormhole-result.is-arriving { animation: wormhole-arrive 0.6s var(--ease-out) both; }
@keyframes wormhole-arrive {
  from { opacity: 0; transform: scale(0.92); filter: blur(6px); }
}

/* --- Received ------------------------------------------------------------------ */
.wormhole-result__text,
.wormhole-result__file { display: grid; gap: var(--space-3); }
.wormhole-plaintext {
  max-block-size: 24rem;
  margin: 0;
  padding: var(--space-4);
  overflow: auto;
  border: 1px solid rgb(34 211 238 / 30%);
  border-radius: var(--r-md);
  background: var(--wh-well);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.wormhole-files {
  display: grid;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}
.wormhole-filecard {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid rgb(34 211 238 / 30%);
  border-radius: var(--r-md);
  background: rgb(34 211 238 / 6%);
}
.wormhole-preview {
  display: block;
  grid-column: 1 / -1;
  justify-self: center;
  max-inline-size: 100%;
  max-block-size: 16rem;
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-md);
}
.wormhole-filecard__icon { color: var(--wh-receive); font-size: var(--text-2xl); line-height: 1; }
.wormhole-filecard__meta { display: grid; min-inline-size: 0; }
.wormhole-filecard__meta strong { overflow: hidden; color: var(--text); text-overflow: ellipsis; white-space: nowrap; }
.wormhole-filecard__meta small { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.wormhole-result .btn { justify-self: start; }

/* --- Notes -------------------------------------------------------------------- */
.wormhole-notes { max-width: 72rem; margin-block-start: var(--space-16); }
.wormhole-notes h2 { margin-block-end: var(--space-6); font-size: var(--text-2xl); }
.wormhole-notes__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
}
.wormhole-notes__grid article {
  padding: var(--space-5);
  border: 1px solid var(--wh-line);
  border-radius: var(--r-lg);
  background: rgb(255 255 255 / 2%);
}
.wormhole-notes__grid article.is-wide { grid-column: 1 / -1; border-color: rgb(167 139 250 / 25%); }
.wormhole-notes h3 { margin: 0 0 var(--space-2); color: var(--text); font-size: var(--text-lg); }
.wormhole-notes p { margin: 0; color: var(--text-soft); font-size: var(--text-sm); line-height: var(--leading-normal); }
.wormhole-notes a { color: var(--wh-send); }

/* --- Narrow screens ------------------------------------------------------------- */
@media (max-width: 56rem) {
  .wormhole-layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 44rem) {
  .wormhole-hero__grid { grid-template-columns: minmax(0, 1fr); }
  .wormhole-portal { order: -1; inline-size: 9rem; }
  .wormhole-notes__grid { grid-template-columns: minmax(0, 1fr); }
  .wormhole-submit { justify-self: stretch; }
  .wormhole-actions .btn { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
  .wormhole-stars,
  .wormhole-pulse,
  .wormhole-portal__ring,
  .wormhole-portal__core,
  .wormhole-status[data-state='pending']::after { animation: none; }
  .wormhole-share.is-arriving,
  .wormhole-result.is-arriving { animation: none; }
}
