/* Clipboard Relay — the "Industry" design system, as this app uses it.
 *
 * Tokens and component classes are lifted from the design's own styles.css so
 * the values stay the ones the design was drawn against. Two deliberate
 * departures, both from the handover:
 *   - no "+" corner registration marks anywhere (the user asked for plain
 *     hairline edges), so there is no .corner rule and nothing emits one
 *   - only the classes this app actually uses, rather than the whole system
 */

@font-face {
  font-family: 'Barlow';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(./fonts/barlow-latin-400-normal.b0a8ad37.woff2) format('woff2');
}
@font-face {
  font-family: 'Barlow';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(./fonts/barlow-latin-500-normal.cd759df8.woff2) format('woff2');
}
@font-face {
  font-family: 'Barlow Condensed';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(./fonts/barlow-condensed-latin-600-normal.215a93c6.woff2) format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(./fonts/ibm-plex-mono-latin-400-normal.08949f72.woff2) format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(./fonts/ibm-plex-mono-latin-500-normal.01d28544.woff2) format('woff2');
}

:root {
  --color-bg: #f2f2f3;
  --color-surface: #e9e9ea;
  --color-text: #1d1f20;
  --color-accent: #5980a6;
  --color-divider: color-mix(in srgb, #1d1f20 16%, transparent);
  /* Warnings only (the feedback paste check). The design has no warning
     colour; the accent is too calm for "you just pasted a password". */
  --color-warning: #b45309;

  --color-neutral-300: #d4d4d7;
  --color-neutral-400: #b7b7ba;

  --color-accent-100: #eef6ff;
  --color-accent-600: #597ea3;
  --color-accent-700: #416180;
  --color-accent-800: #2c455d;

  --font-heading: 'Barlow Condensed', system-ui, sans-serif;
  --font-body: 'Barlow', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;

  --space-1: 3.4px;
  --space-2: 6.8px;
  --space-3: 10.2px;
  --space-4: 13.6px;

  --radius-md: 4px;

  color-scheme: light;
}

/* The design's dark palette, defined in Relay.dc.html rather than in the
 * system's own stylesheet (Industry ships no dark theme). */
:root[data-theme='dark'] {
  --color-bg: #141617;
  --color-surface: #1c1f21;
  --color-text: #e2e4e7;
  --color-accent: #7ea5cb;
  --color-divider: color-mix(in srgb, #e2e4e7 16%, transparent);
  --color-warning: #f59e0b;

  --color-accent-100: #1d2d3d;
  --color-accent-600: #94bce3;
  --color-accent-700: #b5d9fd;
  --color-accent-800: #d6ebff;
  --color-neutral-100: #2b2b2d;

  color-scheme: dark;
}

/* Follow the system until the header toggle says otherwise. The toggle writes
 * data-theme, and the selectors above/below are specific enough to win. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --color-bg: #141617;
    --color-surface: #1c1f21;
    --color-text: #e2e4e7;
    --color-accent: #7ea5cb;
    --color-divider: color-mix(in srgb, #e2e4e7 16%, transparent);
    --color-warning: #f59e0b;
    --color-accent-100: #1d2d3d;
    --color-accent-600: #94bce3;
    --color-accent-700: #b5d9fd;
    --color-accent-800: #d6ebff;
    --color-neutral-100: #2b2b2d;
    color-scheme: dark;
  }
}

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

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  font-weight: 400;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.015em;
  margin: 0 0 var(--space-2);
}
h3 { font-size: 24px; }
h4 { font-size: 19px; }
h5 { font-size: 17px; }

p { margin: 0 0 var(--space-3); }

.text-muted { color: color-mix(in srgb, var(--color-text) 55%, transparent); }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--color-accent) 30%, transparent); }

/* — the wireframe frame: square, transparent, hairline. No corner marks. — */
.blueprint {
  position: relative;
  border: 1px solid var(--color-divider);
  border-radius: 0;
}

/* — buttons — */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  text-decoration: none;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 14px;
  line-height: 1.2;
  color: var(--color-text);
  background: transparent;
  border: 1px solid var(--color-divider);
  padding: var(--space-2) calc(var(--space-3) * 1.2);
  border-radius: 0;
}
.btn svg { display: block; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary {
  background: var(--color-accent);
  color: var(--color-bg);
  border-color: var(--color-accent);
}
.btn-primary:hover:not(:disabled) { background: var(--color-accent-600); }
.btn-primary:active:not(:disabled) { background: var(--color-accent-700); }
.btn-secondary { border-color: var(--color-divider); }
.btn-secondary:hover:not(:disabled) { background: color-mix(in srgb, var(--color-text) 7%, transparent); }
.btn-secondary:active:not(:disabled) { background: color-mix(in srgb, var(--color-text) 14%, transparent); }
.btn-ghost {
  color: var(--color-accent);
  border-color: transparent;
  padding-inline: var(--space-1);
}
.btn-ghost:hover:not(:disabled) { background: color-mix(in srgb, var(--color-accent) 10%, transparent); }
.btn-ghost:active:not(:disabled) { background: color-mix(in srgb, var(--color-accent) 18%, transparent); }
.btn-icon { width: 36px; height: 36px; padding: 0; }

/* — fields — */
.field > label {
  display: block;
  font-size: 12px;
  margin-bottom: 5px;
  color: color-mix(in srgb, var(--color-text) 70%, transparent);
}
.input {
  width: 100%;
  min-height: 36px;
  padding: 6px 10px;
  font: inherit;
  font-size: 14px;
  color: var(--color-text);
  caret-color: var(--color-accent);
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: 0;
}
.input:hover { border-color: color-mix(in srgb, var(--color-text) 45%, transparent); }
.input:focus-visible { border-color: var(--color-accent); outline-offset: 0; }
textarea.input { resize: vertical; }

/* — tags — */
.tag {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 0;
}
.tag-accent { background: var(--color-accent-100); color: var(--color-accent-800); }

/* — header — */
.nav {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: 9px 20px;
  border-bottom: 1px solid var(--color-divider);
  flex-wrap: wrap;
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 19px;
  margin-right: auto;
}

/* ── app layout ─────────────────────────────────────────────────── */

main {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 16px;
}

.machine-btn {
  border: 0;
  padding: 2px 6px;
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 13px;
  color: var(--color-text);
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.machine-btn:hover { background: color-mix(in srgb, var(--color-accent) 10%, transparent); }
.machine-name { font-weight: 500; }

/* Errors get their own place. They used to be written into the connect
 * panel's helper text, so a failed sync or a clipboard refusal would silently
 * replace "This page will switch to that relay." with something unrelated. */
.error-banner {
  margin-top: 12px;
  padding: 8px 6px 8px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  border-color: var(--color-accent);
  background: color-mix(in srgb, var(--color-accent) 9%, transparent);
}
.error-banner span { flex: 1; text-wrap: pretty; }

/* Fixed rather than in the flow, so it shows wherever the deleted block was
   scrolled to, and nothing on the page jumps when it comes and goes. */
.undo-toast {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 20;
  max-width: calc(100% - 32px);
  padding: 6px 6px 6px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  background: var(--color-surface);
  box-shadow: 0 4px 16px color-mix(in srgb, #000 18%, transparent);
}
.undo-toast .btn { min-height: 36px; padding-inline: 12px; font-weight: 600; }

.encryption-line {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding-top: 10px;
  font-size: 12.5px;
  line-height: 1.45;
  color: color-mix(in srgb, var(--color-text) 66%, transparent);
}
.encryption-line svg { flex: none; margin-top: 2px; }
.encryption-line span { text-wrap: pretty; }

/* Links in the small print take the accent, like the footer's Feedback
   button, not the browser's default blue. */
.encryption-line a, footer a { color: var(--color-accent); }

.kbd {
  font-family: var(--font-mono);
  font-size: 11.5px;
  padding: 0 6px;
  border: 1px solid var(--color-divider);
  border-bottom-width: 2px;
  white-space: nowrap;
}

/* the paste invitation */
.paste-strip {
  border-style: dashed;
  margin-top: 16px;
  padding: 9px 10px 9px 14px;
  display: flex;
  align-items: center;
  gap: 10px 14px;
  flex-wrap: wrap;
}
.paste-strip svg { flex: none; }
.paste-strip .hint {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}
.paste-strip .spacer { margin-left: auto; }

.phone-strip { display: none; gap: 8px; margin-top: 14px; }
.phone-strip .btn { min-height: 44px; font-size: 15px; }

.composer { margin-top: 16px; padding: 10px; }
.composer textarea {
  font-family: var(--font-mono);
  font-size: 12.5px;
  white-space: pre;
  background: transparent;
  min-height: 96px;
}
.composer .row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}
.composer .row .spacer { margin-left: auto; }

/* connect panel */
.connect { margin-top: 16px; padding: 14px 16px 16px; }
.connect-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.connect-head .close { margin-left: auto; width: 30px; height: 30px; color: var(--color-text); }
.connect-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 18px 32px;
}
/* Under the join code. Its height must not depend on the countdown: nothing
   follows the timer on its line, and its digits are fixed-width so the line
   does not shift each second either. */
.code-note {
  font-size: 12px;
  margin-top: 4px;
  min-height: 1lh;
  text-wrap: pretty;
}
.code-note .countdown { font-variant-numeric: tabular-nums; }

.join-code {
  font-family: var(--font-mono);
  font-size: 30px;
  font-weight: 500;
  letter-spacing: 0.16em;
}
.code-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.code-input {
  max-width: 170px;
  font-family: var(--font-mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

/* search */
.search-row {
  display: flex;
  align-items: center;
  gap: 6px 14px;
  flex-wrap: wrap;
  margin-top: 14px;
}
.search-wrap { position: relative; flex: 1 1 260px; max-width: 420px; }
.search-wrap .icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: color-mix(in srgb, var(--color-text) 55%, transparent);
}
.search-wrap input {
  padding-left: 32px;
  padding-right: 34px;
  min-height: 36px;
  font-size: 13.5px;
}
.search-wrap .slash {
  position: absolute;
  right: 9px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: color-mix(in srgb, var(--color-text) 60%, transparent);
}
.danger-ghost {
  margin-left: auto;
  font-size: 13px;
  color: color-mix(in srgb, var(--color-text) 62%, transparent);
}
.inline-confirm {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 13px;
}
.inline-confirm .btn { padding: 3px 10px; font-size: 13px; }

/* first load: a clipboard whose lines get selected one by one. Drawn in the
 * theme's tokens, so it follows dark mode like everything else. */
.loading {
  margin-top: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  color: color-mix(in srgb, var(--color-text) 70%, transparent);
  animation: loading-in 0.3s ease-out 0.25s backwards;
}
.loading-board {
  position: relative;
  width: 64px;
  height: 80px;
  border: 5px solid var(--color-accent-800);
  border-radius: 9px;
  background: var(--color-surface);
  animation: loading-bob 2s ease-in-out infinite;
}
.loading-clip {
  position: absolute;
  top: -10px;
  left: 50%;
  width: 26px;
  height: 13px;
  margin-left: -13px;
  border-radius: 4px 4px 2px 2px;
  background: var(--color-accent-800);
}
.loading-clip::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 50%;
  width: 5px;
  height: 5px;
  margin-left: -2.5px;
  border-radius: 50%;
  background: var(--color-surface);
}
.loading-paper {
  position: absolute;
  inset: 12px 8px;
  overflow: hidden;
}
.loading-paper span {
  display: block;
  height: 4px;
  margin-bottom: 8px;
  border-radius: 2px;
  background: color-mix(in srgb, var(--color-text) 20%, transparent);
}
.loading-paper span:nth-child(2) { width: 75%; }
.loading-paper span:nth-child(3) { width: 90%; }
.loading-paper span:nth-child(4) { width: 60%; }
.loading-selection {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--color-accent);
  animation: loading-select 2s ease-in-out infinite;
}
.loading-text {
  font-family: var(--font-heading);
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
/* Reserves the width of "..." so the label does not shift as the dots grow. */
.loading-dots {
  display: inline-block;
  width: 1.2em;
  text-align: left;
}
.loading-dots::after {
  content: '';
  animation: loading-dots 1.5s steps(1, end) infinite;
}

@keyframes loading-in {
  from { opacity: 0; }
}
@keyframes loading-bob {
  50% { transform: translateY(-4px); }
}
/* One line per step: 12px is a line plus its margin. */
@keyframes loading-select {
  0%, 10% { top: 0; left: -100%; }
  25%, 30% { top: 0; left: 0; }
  45%, 50% { top: 12px; left: 0; }
  65%, 70% { top: 24px; left: 0; }
  80% { top: 36px; left: 0; }
  95%, 100% { top: 36px; left: 100%; }
}
@keyframes loading-dots {
  0% { content: ''; }
  25% { content: '.'; }
  50% { content: '..'; }
  75% { content: '...'; }
}

@media (prefers-reduced-motion: reduce) {
  .loading-board, .loading-selection, .loading-dots::after { animation: none; }
  .loading-dots::after { content: '...'; }
}

/* empty state */
.empty {
  margin-top: 20px;
  padding: 48px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  border-style: dashed;
}
.empty p {
  margin: 0;
  max-width: 430px;
  text-wrap: pretty;
  color: color-mix(in srgb, var(--color-text) 75%, transparent);
}

.no-results {
  margin-top: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
}

/* day groups */
.day { margin-top: 18px; }
.day-head {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--color-bg);
  display: flex;
  align-items: center;
  gap: 4px 10px;
  flex-wrap: wrap;
  padding: 6px 0;
  border-bottom: 1px solid var(--color-divider);
  margin-bottom: 14px;
}
.day-head h5 { margin: 0; }
.day-blocks { display: flex; flex-direction: column; gap: 16px; }

/* a block */
.block { background: transparent; }
.block.is-new {
  background: color-mix(in srgb, var(--color-accent) 9%, transparent);
  border-color: var(--color-accent);
}
.block-head {
  position: relative;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px 12px;
  padding: 4px 5px 4px 12px;
  border-bottom: 1px solid var(--color-divider);
  font-size: 12.5px;
}
.block-from {
  display: flex;
  align-items: center;
  gap: 6px;
}
.block-from .name { font-weight: 500; }
.block-sending { color: var(--color-accent-700); }
.block-failed { color: var(--color-accent-700); }
.block-left {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: color-mix(in srgb, var(--color-text) 50%, transparent);
}
.block-left.soon { color: var(--color-accent-700); }
.block-actions { display: flex; gap: 2px; align-items: center; }
.block-actions .btn { padding: 3px 10px; font-size: 13px; }
.block-actions .copy { min-width: 78px; }
.block-actions .btn-icon { width: 30px; height: 30px; padding: 0; min-width: 0; }
.icon-dim { color: color-mix(in srgb, var(--color-text) 60%, transparent); }
.progress {
  position: absolute;
  left: 0;
  bottom: -1px;
  height: 2px;
  background: var(--color-accent);
  transition: width 120ms linear;
}
.block-body {
  margin: 0;
  padding: 8px 12px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.5;
  /* Never wrap: terminal output's alignment is information, so it scrolls on
   * both axes instead. max-height is about seven lines. */
  white-space: pre;
  overflow: auto;
  max-height: 148px;
  tab-size: 4;
  scrollbar-width: thin;
}
.block.sending .block-body { opacity: 0.55; }
.block-body mark {
  background: color-mix(in srgb, var(--color-accent) 32%, transparent);
  color: var(--color-text);
}

/* A secret block's body is replaced by dots, not merely visually covered:
 * the characters must not be in the DOM to be selected, inspected or read by
 * a screen reader while hidden. */
/* An image block's body: shrunk to fit the list, full size in a new tab. */
.block-image {
  display: block;
  padding: 8px 12px;
}
.block-image img {
  display: block;
  max-width: 100%;
  max-height: 360px;
  width: auto;
  height: auto;
  border: 1px solid var(--color-divider);
}
.block.sending .block-image { opacity: 0.55; }
.block-image.masked {
  font-size: 12.5px;
  color: color-mix(in srgb, var(--color-text) 70%, transparent);
  user-select: none;
}

/* The Images filter: a toggle, so its pressed state has to be visible. */
.chip[aria-pressed='true'] {
  background: var(--color-accent-100);
  color: var(--color-accent-800);
  border-color: var(--color-accent);
}

.block-body.masked {
  color: color-mix(in srgb, var(--color-text) 70%, transparent);
  letter-spacing: 0.08em;
  user-select: none;
}
.secret-note {
  color: color-mix(in srgb, var(--color-text) 55%, transparent);
  font-size: 12px;
}

/* A button that reads as one of the footer's links. */
.link-btn {
  font: inherit;
  color: var(--color-accent);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
}

/* — feedback dialog — */
.feedback {
  width: min(480px, calc(100vw - 32px));
  padding: 20px;
  background: var(--color-surface);
  color: var(--color-text);
}
.feedback::backdrop { background: color-mix(in srgb, black 45%, transparent); }
.feedback h2 { font-size: 16px; margin: 0 0 12px; }
.feedback textarea { width: 100%; box-sizing: border-box; }
.feedback p { font-size: 12.5px; margin: 8px 0 14px; }

/* Shown on a paste, between the text and the buttons, so it is in the way of
   Send. Two strengths: a plain paste, and text that came from the relay. */
.feedback-warning {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-top: 10px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.4;
  border: 1px solid var(--color-warning);
  border-left-width: 4px;
  background: color-mix(in srgb, var(--color-warning) 8%, transparent);
}
.feedback-warning svg { flex: none; margin-top: 1px; color: var(--color-warning); }
.feedback-warning strong { display: block; font-weight: 600; }
.feedback-warning.strong { background: color-mix(in srgb, var(--color-warning) 18%, transparent); }

footer {
  margin-top: 32px;
  padding: 12px 0 28px;
  border-top: 1px solid var(--color-divider);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 24px;
  font-size: 12px;
  color: color-mix(in srgb, var(--color-text) 60%, transparent);
}

.hidden { display: none !important; }

/* ── phone ──────────────────────────────────────────────────────── */

@media (max-width: 600px) {
  .nav { padding: 8px 8px 8px 14px; gap: 4px; }
  .nav-brand { font-size: 18px; gap: 7px; }
  /* 44px touch targets, per the handover. */
  .nav .btn-icon { width: 44px; height: 44px; }
  .nav .desktop-only { display: none; }

  .machine-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 7px 16px;
    font-size: 12.5px;
    border-bottom: 1px solid var(--color-divider);
  }

  .paste-strip { display: none; }
  .phone-strip { display: flex; }
  .search-wrap .slash { display: none; }
  .block-actions .btn { min-height: 32px; }
}

@media (min-width: 601px) {
  .machine-row { display: none; }
}
