/* peer.io */

:root {
  --paper: #eef2f4;
  --surface: #ffffff;
  --ink: #17232b;
  --ink-soft: #52616b;
  --line: #c9d3d9;
  --accent: #0d6b5c;
  --accent-ink: #ffffff;
  --accent-wash: #dcefe9;
  --warn: #a8461f;
  --warn-wash: #f6e4da;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --sans: "Avenir Next", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  --display: ui-rounded, "SF Pro Rounded", "Nunito", "Avenir Next Rounded", "Avenir Next", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

/* Dark: follows the device unless the switch has chosen light; or forced by the switch. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #11181d;
    --surface: #182228;
    --ink: #e4ebef;
    --ink-soft: #95a4ad;
    --line: #2d3b44;
    --accent: #3fc4a6;
    --accent-ink: #062520;
    --accent-wash: #15342e;
    --warn: #f0926a;
    --warn-wash: #3a2219;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --paper: #11181d;
  --surface: #182228;
  --ink: #e4ebef;
  --ink-soft: #95a4ad;
  --line: #2d3b44;
  --accent: #3fc4a6;
  --accent-ink: #062520;
  --accent-wash: #15342e;
  --warn: #f0926a;
  --warn-wash: #3a2219;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font: 17px/1.55 var(--sans);
}

main, .top, .foot {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: 0 20px;
}

main { flex: 1; padding-bottom: 48px; }

[hidden] { display: none !important; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

a { color: var(--accent); }

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

/* Header ------------------------------------------------------------------ */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 16px;
  padding-bottom: 0;
}

.theme-toggle {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  color: var(--ink-soft);
  background: transparent;
  border: 1.5px solid transparent;
  border-radius: 50%;
}
.theme-toggle:hover:not(:disabled) { color: var(--ink); border-color: var(--line); }
.theme-toggle svg { width: 20px; height: 20px; }
.theme-toggle .sun, .theme-toggle[data-mode="dark"] .moon { display: none; }
.theme-toggle[data-mode="dark"] .sun { display: block; }

.mark {
  font: 700 19px/1 var(--display);
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.mark .io { color: var(--accent); transition: color .3s; }
/* peer.io reads as I/O: "o" for output when sending, "i" for input when receiving. */
body[data-direction="outbound"] .mark .i,
body[data-direction="inbound"] .mark .o { color: var(--ink); }

/* Home -------------------------------------------------------------------- */

h1 {
  font: 700 clamp(30px, 6.4vw, 42px)/1.12 var(--display);
  letter-spacing: -0.02em;
  margin: 48px 0 14px;
  max-width: 23ch;
  text-wrap: balance;
}

.lede {
  color: var(--ink-soft);
  margin: 0 0 32px;
  max-width: 44ch;
}

.drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 200px;
  padding: 24px;
  border: 2px dashed var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  cursor: pointer;
  text-align: center;
  transition: border-color .15s, background-color .15s;
}
.drop:hover, .drop.over { border-color: var(--accent); }
.drop.over { background: var(--accent-wash); }
.drop:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }
.drop-title { font: 700 22px/1.2 var(--display); }
.drop-sub { color: var(--ink-soft); }

.totals { margin: 12px 0 0; font-size: 14px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.code-form { margin-top: 36px; }
.code-form label { display: block; font-weight: 600; margin-bottom: 8px; }
.code-row, .share-row, .chat-form { display: flex; gap: 8px; }

input {
  flex: 1;
  min-width: 0;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
input:focus-visible { outline-offset: 0; border-color: var(--accent); }
input:disabled { opacity: .6; }
#code-input { font-family: var(--display); font-weight: 600; }

button {
  font: 600 16px/1 var(--sans);
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  cursor: pointer;
  white-space: nowrap;
}
button:hover:not(:disabled) { border-color: var(--ink-soft); }
button:disabled { opacity: .5; cursor: default; }
button.primary, .code-row button {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
button.primary:hover:not(:disabled), .code-row button:hover { filter: brightness(1.08); border-color: var(--accent); }
button.quiet { background: transparent; }

.hint { color: var(--ink-soft); font-size: 14px; margin: 8px 0 0; }

/* Transfer ---------------------------------------------------------------- */

#transfer { padding-top: 4px; }

/* "Outbound transfer" / "Inbound transfer": names the view without competing with the code. */
.view-title {
  font-size: clamp(24px, 5vw, 30px);
  margin: 36px 0 18px;
}

.file { display: flex; align-items: center; gap: 14px; }
.file-glyph { width: 26px; flex: none; color: var(--ink-soft); }
.file-name { font-weight: 600; overflow-wrap: anywhere; line-height: 1.3; }
.file-size { color: var(--ink-soft); font-size: 15px; }

.share { margin-top: 28px; }
.share-intro { margin: 0; color: var(--ink-soft); }

/* The code is the thing people read aloud, so it is the largest thing on the page. */
.big-code {
  /* Sized so the longest codes (about 21 characters) stay on one line at full width. */
  font: 800 clamp(28px, 7.4vw, 44px)/1.1 var(--display);
  letter-spacing: -0.02em;
  margin: 6px 0 18px;
  user-select: all;
}

#share-link { font-size: 15px; color: var(--ink-soft); }

.share-row { flex-wrap: wrap; }
#share-link { flex: 1 1 240px; }
.share-actions { display: flex; gap: 8px; }
.share-wrap { position: relative; display: flex; }

/* Shown only where the device has no share menu of its own. */
.share-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  min-width: 170px;
  padding: 4px;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: 0 6px 20px rgb(0 0 0 / .12);
}
.share-menu a {
  padding: 10px 12px;
  border-radius: 4px;
  color: var(--ink);
  font-weight: 600;
  font-size: 15px;
  text-decoration: none;
}
.share-menu a:hover, .share-menu a:focus-visible { background: var(--accent-wash); outline: none; }

.offer {
  margin-top: 24px;
  padding: 20px;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-lg);
}
.offer p:first-child { margin: 0 0 14px; font-weight: 600; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }

.status {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 26px 0 0;
  min-height: 1.55em;
}
.status:has(#status-text:empty) { visibility: hidden; }
.dot {
  width: 9px; height: 9px;
  flex: none;
  border-radius: 50%;
  background: var(--ink-soft);
  transform: translateY(-1px);
}
.status[data-tone="live"] .dot { background: var(--accent); }
.status[data-tone="done"] .dot { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-wash); }
.status[data-tone="bad"] .dot { background: var(--warn); }
.status[data-tone="wait"] .dot { animation: breathe 1.6s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: .25; } }

.progress { margin-top: 14px; }
.track {
  height: 10px;
  border-radius: 5px;
  background: var(--line);
  overflow: hidden;
}
.fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 5px;
  transition: width .25s linear;
}
.stats {
  display: flex;
  gap: 16px;
  margin-top: 8px;
  font-size: 14px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.stats span:first-child { margin-right: auto; color: var(--ink); }

/* Receipt: a torn-off ticket stub ---------------------------------------- */

.receipt {
  --notch: 9px;
  position: relative;
  margin-top: 28px;
  padding: 26px 22px 22px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  /* Punched edge along the top, as if torn from a roll. */
  -webkit-mask: radial-gradient(circle var(--notch) at 50% 0, transparent 98%, #000) 0 0 / calc(var(--notch) * 2.6) 100% repeat-x;
          mask: radial-gradient(circle var(--notch) at 50% 0, transparent 98%, #000) 0 0 / calc(var(--notch) * 2.6) 100% repeat-x;
  animation: print .5s cubic-bezier(.2, .8, .2, 1) both;
}
@keyframes print {
  from { clip-path: inset(0 0 100% 0); }
  to { clip-path: inset(0 0 0 0); }
}
.receipt h2 {
  font: 700 22px/1.2 var(--display);
  margin: 0 0 6px;
}
.verdict {
  margin: 0 0 18px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--accent-wash);
  font-weight: 600;
}
.receipt[data-match="false"] .verdict { background: var(--warn-wash); color: var(--warn); }

.receipt dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 10px 18px;
  margin: 0 0 20px;
  padding-top: 16px;
  border-top: 1.5px dashed var(--line);
}
.receipt dt { color: var(--ink-soft); font-size: 15px; }
.receipt dd { margin: 0; overflow-wrap: anywhere; }
.receipt dd .hint { display: block; margin-top: 2px; }
.hash { font: 14px/1.5 var(--mono); }
.phrase { font: 700 18px/1.3 var(--display); }

/* Chat -------------------------------------------------------------------- */

.chat {
  margin-top: 32px;
  border-top: 1.5px solid var(--line);
  padding-top: 14px;
}
.messages {
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.messages:not(:empty) { margin-bottom: 12px; }
.msg {
  max-width: 85%;
  padding: 7px 11px;
  border-radius: 12px;
  font-size: 15px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.msg time { margin-left: 8px; font-size: 12px; opacity: .65; }
.msg.me { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 4px; }
.msg.them { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.note { align-self: center; color: var(--ink-soft); font-size: 13px; padding: 2px; }
.chat-form input { font-size: 15px; }
.chat-form button { padding: 10px 14px; font-size: 15px; }

/* Error + footer ---------------------------------------------------------- */

.error h1 { margin-top: 56px; }
.error p { color: var(--ink-soft); }

.foot {
  padding-top: 20px;
  padding-bottom: 28px;
  font-size: 13px;
  color: var(--ink-soft);
}
.foot p { margin: 0; max-width: 52ch; }
.foot .tip { margin-top: 8px; }
.foot .tip a { font-weight: 600; }
.foot-nav { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 14px; font-size: 14px; }
.foot-nav a { color: var(--ink-soft); }
.foot-nav a[aria-current] { color: var(--ink); font-weight: 600; text-decoration: none; }

/* FAQ, terms and privacy ---------------------------------------------------- */

.doc h1 { font-size: clamp(30px, 6vw, 38px); max-width: none; margin: 40px 0 6px; }
.doc .updated { color: var(--ink-soft); font-size: 14px; margin: 0 0 24px; }
.doc h2 { font: 700 21px/1.25 var(--display); margin: 36px 0 8px; }
.doc h3 { font: 700 17px/1.35 var(--sans); margin: 24px 0 4px; }
.doc h2 + h3 { margin-top: 12px; }
.doc p, .doc li { max-width: 66ch; }
.doc p { margin: 0 0 12px; }
.doc ul { padding-left: 1.2em; margin: 0 0 12px; }
.doc li + li { margin-top: 6px; }
.doc .summary {
  margin: 0 0 8px;
  padding: 14px 16px;
  background: var(--surface);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.doc code {
  font: .9em var(--mono);
  padding: 1px 5px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
}
/* Placeholders still to be filled in before launch. */
.todo { background: #fde68a; color: #3b2f00; border-radius: 3px; padding: 0 3px; }

@media (max-width: 420px) {
  body { font-size: 16px; }
  .share-actions { width: 100%; }
  .share-actions > button, .share-wrap, .share-wrap > button { flex: 1; }
  .receipt dl { grid-template-columns: 1fr; gap: 2px; }
  .receipt dd { margin-bottom: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Admin stats page -------------------------------------------------------- */

body.admin main, body.admin .top { max-width: 960px; }
.admin-head { margin: 32px 0 8px; }
.admin-head h1 { margin: 0 0 4px; font-size: clamp(30px, 5vw, 38px); }
.admin section { margin-top: 28px; }
.admin h2 { font: 700 18px/1.3 var(--display); margin: 0 0 10px; }
.admin h2 .soft { font: 400 14px var(--sans); color: var(--ink-soft); margin-left: 6px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.tiles.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-lg);
}
.tile-label { font-size: 14px; color: var(--ink-soft); }
.tile-value { font: 700 28px/1.15 var(--display); font-variant-numeric: tabular-nums; }
.tile-note { font-size: 14px; color: var(--ink-soft); }
.tile.relay { gap: 10px; }
.tile.relay .tile-value { font-size: 22px; }
.tile[data-warn] { border-color: var(--warn); }
.tile[data-warn] .fill { background: var(--warn); }
.admin-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
.admin-error { margin: 16px 0 0; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--warn-wash); color: var(--warn); font-weight: 600; }
.months { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; }
.months th, .months td { text-align: left; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.months th { font-size: 14px; font-weight: 600; color: var(--ink-soft); }
.months th:not(:first-child), .months td:not(:first-child) { text-align: right; white-space: nowrap; }
.months tbody tr:last-child td { border-bottom: 0; }
.server-note { margin-top: 28px; }
@media (max-width: 720px) {
  .admin-pair { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tile { padding: 14px; }
  .tile-value { font-size: 24px; }
  .months th, .months td { padding: 10px 12px; }
}

/* Desktop layout ---------------------------------------------------------- */
/* Phones and narrow windows keep the single column above. From 960px the home
   page and transfer pages use two columns; FAQ, terms and privacy stay narrow
   because long lines are harder to read. */

.chat-title { display: none; }

@media (min-width: 960px) {
  body.app main, body.app .top, body.app .foot { max-width: 1120px; padding-left: 40px; padding-right: 40px; }
  body.app .top { padding-top: 22px; }

  /* Home: words and the code box on the left, a large drop zone on the right. */
  #home {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
    grid-template-areas: "intro drop" "code drop";
    grid-template-rows: auto 1fr;
    column-gap: 64px;
    align-items: start;
    padding-top: 40px;
  }
  .home-intro { grid-area: intro; }
  .home-drop { grid-area: drop; align-self: stretch; display: flex; flex-direction: column; }
  #home .code-form { grid-area: code; margin-top: 8px; max-width: 420px; }
  #home h1 { font-size: clamp(42px, 4.2vw, 54px); margin-top: 24px; max-width: 14ch; }
  #home .lede { font-size: 19px; max-width: 34ch; margin-bottom: 32px; }
  #home .drop { flex: 1; min-height: 380px; }
  #home .drop-title { font-size: 26px; }

  /* Transfer: everything about the file on the left, messages as a column on the right. */
  #transfer:not([hidden]) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    column-gap: 56px;
    align-items: start;
    padding-top: 12px;
  }
  .transfer-main { min-width: 0; }
  .chat {
    position: sticky;
    top: 24px;
    margin-top: 36px;
    padding: 16px;
    border: 1.5px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    display: flex;
    flex-direction: column;
    height: min(560px, calc(100vh - 140px));
  }
  .chat-title { display: block; font: 700 17px/1.3 var(--display); margin: 0 0 12px; }
  .messages { flex: 1; max-height: none; margin-bottom: 12px; }
  .messages:empty::before {
    content: "Send a quick note while the file transfers. Messages go straight between the two of you.";
    color: var(--ink-soft);
    font-size: 14px;
  }
  .msg.them { background: var(--paper); }
  .big-code { font-size: 48px; }
}

/* 404 ---------------------------------------------------------------------- */

/* Neither "i" nor "o" is lit: nothing in, nothing out. */
body[data-direction="none"] .mark .io { color: var(--ink-soft); }
.not-found { padding-top: 24px; }
.nf-code {
  font: 800 clamp(72px, 16vw, 128px)/1 var(--display);
  letter-spacing: -0.04em;
  color: var(--line);
  margin: 40px 0 0;
}
.not-found h1 { margin-top: 12px; }
.not-found .lede { max-width: 46ch; }
a.button {
  display: inline-flex;
  align-items: center;
  font: 600 16px/1 var(--sans);
  color: var(--ink);
  text-decoration: none;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
}
a.button:hover { border-color: var(--ink-soft); }
a.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
a.button.primary:hover { filter: brightness(1.08); }

.debug-log {
  margin: 28px 0 0;
  padding: 12px 14px;
  max-height: 320px;
  overflow: auto;
  font: 12px/1.5 var(--mono);
  white-space: pre-wrap;
  background: var(--surface);
  border: 1.5px dashed var(--line);
  border-radius: var(--radius-sm);
}
@media (min-width: 960px) { #transfer:not([hidden]) ~ .debug-log { max-width: calc(100% - 396px); } }

/* Check a receipt ----------------------------------------------------------- */

.verify-drops { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.drop.small { min-height: 130px; }
.drop.small .drop-title { font-size: 19px; }
.drop.small .drop-sub { overflow-wrap: anywhere; }
.drop.chosen { border-style: solid; border-color: var(--accent); }
.verify-error { margin: 18px 0 0; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--warn-wash); color: var(--warn); font-weight: 600; }
.verify .receipt { margin-bottom: 8px; }
.receipt[data-ok="false"] .verdict { background: var(--warn-wash); color: var(--warn); }
.receipt[data-ok="partial"] .verdict { background: transparent; border: 1.5px solid var(--line); }
.checks { list-style: none; padding: 0; margin: 0 0 18px; display: grid; gap: 12px; }
.checks li { display: grid; grid-template-columns: 24px 1fr; gap: 0 10px; max-width: none; }
.checks li + li { margin-top: 0; }
.checks .mark-icon { grid-row: span 2; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font: 700 13px/1 var(--sans); }
.checks [data-state="ok"] .mark-icon { background: var(--accent); color: var(--accent-ink); }
.checks [data-state="bad"] .mark-icon { background: var(--warn); color: var(--accent-ink); }
.checks [data-state="skip"] .mark-icon, .checks [data-state="busy"] .mark-icon { border: 2px solid var(--line); color: var(--ink-soft); }
.checks strong { font-weight: 600; }
.checks span.why { color: var(--ink-soft); font-size: 15px; }
@media (max-width: 520px) {
  .verify-drops { grid-template-columns: 1fr; }
}

/* Check a receipt, on wide screens: the checking on the left, what it means on the right,
   in the same frame as the home and transfer pages. */
@media (min-width: 960px) {
  .verify {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    column-gap: 56px;
    align-items: start;
  }
  .verify-main { min-width: 0; }
  .verify .lede { font-size: 19px; max-width: 46ch; }
  .verify .drop.small { min-height: 170px; }
  .verify-about {
    position: sticky;
    top: 24px;
    margin-top: 48px;
    padding: 4px 20px 8px;
    border: 1.5px solid var(--line);
    border-radius: var(--radius-lg);
    font-size: 15px;
  }
  .verify-about h2 { font-size: 19px; margin-top: 18px; }
  .verify-about p, .verify-about li { max-width: none; }
}

/* FAQ, terms and privacy on wide screens: the same frame as the other pages, the text
   kept to a comfortable line length, and a list of sections beside it. */
.toc { display: none; }
.doc h2 { scroll-margin-top: 20px; }
@media (min-width: 960px) {
  main.doc:has(> .toc) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 260px;
    column-gap: 56px;
    align-items: start;
  }
  .doc-body { min-width: 0; }
  .toc {
    display: block;
    position: sticky;
    top: 24px;
    margin-top: 48px;
    padding: 16px 20px;
    border: 1.5px solid var(--line);
    border-radius: var(--radius-lg);
    font-size: 15px;
  }
  .toc-title { margin: 0 0 8px; font-weight: 600; color: var(--ink-soft); font-size: 13px; text-transform: uppercase; letter-spacing: .06em; }
  .toc ol { list-style: none; margin: 0; padding: 0; }
  .toc li { margin: 0; max-width: none; }
  .toc li + li { margin-top: 2px; }
  .toc a { display: block; padding: 4px 0; color: var(--ink); text-decoration: none; }
  .toc a:hover { color: var(--accent); text-decoration: underline; }
}
