/* Flockdeck remote.
 *
 * It looks like the rest of Flockdeck because it is Flockdeck, seen from
 * somewhere else: the palette, the type and the glyphs are the flockdeck.ai
 * site's, which are in turn the application's (design/color.css in the
 * flockdeck repository). Like the site and the application it commits to the
 * dark ground agents are run on, so there is no light variant.
 *
 * Green, amber and red mean here exactly what they mean in a pane header --
 * working, waiting on you, gone -- and are spent on nothing else. Every status
 * is still glyph and word as well as colour: the colour is never the only
 * thing saying which is which.
 *
 * Mobile first: a phone held in one hand is the case this is for, and a
 * desktop browser gets the same layout with more room around it.
 */

/* The fonts are the site's, served from here rather than from a font service:
   the page's policy only admits this origin, and a phone opening a terminal
   should not have to ask anyone else for anything. Both are SIL OFL 1.1; the
   licences are beside the files. */
@font-face {
  font-family: "Archivo";
  src: url("/app/fonts/archivo.woff2") format("woff2");
  font-weight: 400 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/app/fonts/jetbrains-mono.woff2") format("woff2");
  font-weight: 400 500;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;

  --surface:   #0F1418;
  --raised:    #161C21;
  --sunken:    #0A0E11;

  --edge-soft: #1F272D;
  --edge:      #2C363D;
  --edge-hard: #5D6B72;

  --text:      #E6EDF1;
  --muted:     #93A1A9;

  --accent:        #4FD1DB;
  --accent-strong: #7BE0E8;
  --accent-subtle: #0E2B2E;
  --accent-edge:   #1F4E53;
  --on-accent:     #0F1418;

  --working:        #64C97F;
  --waiting:        #E2B341;
  --waiting-subtle: #2A2110;
  --waiting-edge:   #4E3D18;
  --exited:         #F0776A;
  --exited-subtle:  #2C1512;
  --exited-edge:    #58251F;
  --idle:           #738087;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 0 rgba(255,255,255,.03), 0 24px 60px -28px rgba(0,0,0,.9);

  --display: Archivo, "Segoe UI", -apple-system, BlinkMacSystemFont, Ubuntu, sans-serif;
  --body:    Archivo, "Segoe UI", -apple-system, BlinkMacSystemFont, Ubuntu, sans-serif;
  --mono:    "JetBrains Mono", ui-monospace, Consolas, "SF Mono", monospace;

  --tap: 44px;
  --gutter: max(16px, env(safe-area-inset-left));
  --gutter-r: max(16px, env(safe-area-inset-right));
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; background: var(--surface); }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  color: var(--text);
  font: 16px/1.6 var(--body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* The site's wash behind the fold: the accent, and a breath of the amber, so
   the ground is not flat without anything on it having to be loud. */
body::before {
  content: "";
  position: fixed;
  inset: -20% -10% auto -10%;
  height: 70vh;
  background:
    radial-gradient(60% 55% at 22% 0%, rgba(79,209,219,.12), transparent 70%),
    radial-gradient(45% 45% at 82% 8%, rgba(226,179,65,.07), transparent 70%);
  pointer-events: none;
  z-index: 0;
}
/* A terminal wants a quiet frame; the wash stays on the pages that have prose. */
body[data-view="pane"]::before { display: none; }

#app { position: relative; z-index: 1; flex: 1; display: flex; flex-direction: column; min-height: 0; }

::selection { background: var(--accent-edge); color: var(--text); }

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}
@media (forced-colors: active) {
  :focus-visible { outline: 2px solid Highlight !important; }
}

h1:focus { outline: none; }

a { color: var(--accent); text-decoration-color: var(--accent-edge); text-underline-offset: 3px; }
a:hover { color: var(--accent-strong); }

code, kbd, pre { font-family: var(--mono); }
code {
  font-size: .88em;
  background: var(--sunken);
  border: 1px solid var(--edge-soft);
  border-radius: 4px;
  padding: 1px 6px;
}
kbd {
  font-size: .84em;
  background: var(--raised);
  border: 1px solid var(--edge-hard);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 2px 7px;
  color: var(--text);
  white-space: nowrap;
}
pre {
  margin: 10px 0;
  padding: 14px 16px;
  overflow-x: auto;
  background: var(--sunken);
  border: 1px solid var(--edge-soft);
  border-radius: var(--radius);
}
pre code { font-size: 13px; background: none; border: 0; padding: 0; color: var(--text); }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

[hidden] { display: none !important; }

.loading { padding: 32px var(--gutter); color: var(--muted); font-family: var(--mono); font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.hint { color: var(--muted); font-size: .875rem; margin: 6px 0 12px; }
.error { color: var(--exited); }
.lede { font-size: clamp(1.02rem, 2.4vw, 1.15rem); color: var(--muted); max-width: 60ch; margin: 0 0 22px; }

/* The site's small type: a mono label over a section, and a pill. */
.eyebrow {
  font-family: var(--mono); font-size: 11.5px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--accent); margin: 0 0 10px;
}
.kicker {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 12px; letter-spacing: .06em;
  text-transform: uppercase; color: var(--accent);
  background: var(--accent-subtle); border: 1px solid var(--accent-edge);
  border-radius: 999px; padding: 5px 12px; margin: 4px 0 18px;
}

/* ------------------------------------------------------------------ chrome */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: env(safe-area-inset-top) var(--gutter-r) 0 var(--gutter);
  background: rgba(15,20,24,.84);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--edge-soft);
}

.brand, .back {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: var(--tap);
  text-decoration: none;
  color: var(--text);
}
.brand:hover { color: var(--text); }
.mark { display: block; width: 20px; height: 20px; flex: none; }
.wordmark {
  font-family: var(--display); font-weight: 700; font-size: 17px;
  letter-spacing: -.015em;
}
.brand-sub {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--accent);
  border: 1px solid var(--accent-edge); background: var(--accent-subtle);
  border-radius: 999px; padding: 1px 8px;
}
/* On a page with a way back, the mark alone is the way home. */
.brand-mark { min-width: var(--tap); justify-content: center; margin-left: -12px; }
.back {
  gap: 2px;
  font-family: var(--display); font-weight: 600; font-size: 15.5px;
  color: var(--text);
  max-width: 60vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.back:hover { color: var(--accent-strong); }
.back > span[aria-hidden] { color: var(--accent); font-size: 1.25em; line-height: 1; }

.topnav { margin-left: auto; display: flex; gap: 2px; }
.navlink {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 14.5px;
  text-decoration: none;
}
.navlink:hover { color: var(--text); }
.navlink[aria-current="page"] { color: var(--text); background: var(--raised); box-shadow: inset 0 0 0 1px var(--edge-soft); }

.topbar > .button { margin-left: auto; }

.view {
  flex: 1;
  width: 100%;
  max-width: 780px;
  margin: 0 auto;
  padding: 20px var(--gutter-r) calc(28px + env(safe-area-inset-bottom)) var(--gutter);
}

h1 {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(1.85rem, 6.2vw, 2.6rem);
  line-height: 1.06;
  letter-spacing: -.03em;
  margin: 10px 0 14px;
  text-wrap: balance;
}
/* The accent, never the amber: amber is what a pane goes when it is blocked on
   you, and spending it on a heading would make it mean nothing in particular. */
h1 em { font-style: normal; color: var(--accent); }
h2 {
  font-family: var(--display); font-weight: 700;
  font-size: 1.3rem; letter-spacing: -.02em;
  margin: 36px 0 8px;
}

.foot {
  position: relative; z-index: 1;
  display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center;
  width: 100%; max-width: 780px; margin: 0 auto;
  padding: 18px var(--gutter-r) calc(22px + env(safe-area-inset-bottom)) var(--gutter);
  border-top: 1px solid var(--edge-soft);
  font-family: var(--mono); font-size: 12px; color: var(--idle);
}
.foot a { color: var(--muted); text-decoration: none; margin-left: auto; }
.foot a:hover { color: var(--text); }

/* ----------------------------------------------------------------- controls */

/* The site's buttons: a filled accent for the one thing a page is for, and an
   outline for everything else. */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 18px;
  border-radius: 8px;
  border: 1px solid var(--edge-hard);
  background: transparent;
  color: var(--text);
  font-family: var(--display);
  font-weight: 600;
  font-size: 15px;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform .12s ease, background .12s ease, border-color .12s ease;
}
.button:hover { background: var(--raised); border-color: var(--accent); color: var(--text); }
.button:disabled { opacity: .55; cursor: default; transform: none; }
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.button.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--on-accent); transform: translateY(-1px); }
.button.danger { color: var(--exited); border-color: var(--exited-edge); }
.button.danger:hover { background: var(--exited-subtle); border-color: var(--exited); color: var(--exited); }
.button.small { min-height: 36px; padding: 0 12px; font-size: 13.5px; }

.card {
  background: var(--raised);
  border: 1px solid var(--edge-soft);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin: 14px 0;
}
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }

.form label { display: block; font-family: var(--display); font-weight: 600; margin-bottom: 8px; }
.form input, .compose input {
  width: 100%;
  min-height: var(--tap);
  padding: 8px 12px;
  border: 1px solid var(--edge-hard);
  border-radius: 8px;
  background: var(--sunken);
  color: var(--text);
  font-family: var(--body);
  font-size: 16px; /* anything smaller and iOS zooms the page on focus */
}
.form input:focus, .compose input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,209,219,.18); }
.form input::placeholder, .compose input::placeholder { color: var(--idle); }
.form .button { margin-top: 4px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 4px 0 14px; }
.notify { display: inline-flex; align-items: center; }

/* The pairing steps, as the site draws a row of cards: each with its mono
   label in the accent over a heading. */
/* minmax(0, 1fr) and min-width: 0 are what keep a long command inside its
   card: left to their automatic minimum, a grid item grows to fit its widest
   line, and on a phone that ran the whole card off the side of the screen. */
.steps { list-style: none; padding: 0; margin: 8px 0 20px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; counter-reset: step; }
.steps li {
  min-width: 0;
  counter-increment: step;
  background: var(--raised);
  border: 1px solid var(--edge-soft);
  border-radius: var(--radius);
  padding: 16px 18px;
  color: var(--muted);
}
.steps li::before {
  content: "0" counter(step);
  display: block;
  font-family: var(--mono); font-size: 12px; color: var(--accent);
  margin-bottom: 6px;
}
.steps li strong { color: var(--text); font-family: var(--display); font-weight: 650; }
.steps pre { margin: 10px 0 0; }

.tag {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--accent-subtle);
  border: 1px solid var(--accent-edge);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: .06em;
  text-transform: uppercase;
  vertical-align: 2px;
}

.toast {
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--raised);
  border: 1px solid var(--edge);
  font-size: 14.5px;
}
.toast-error { background: var(--exited-subtle); border-color: var(--exited-edge); color: var(--exited); }

.codeline { display: flex; gap: 8px; align-items: center; }
.codeline pre { flex: 1; min-width: 0; margin: 0; }

.notice-card .status { font-size: 13px; }

/* ------------------------------------------------------------------- status */

/* The glyphs are the ones a pane header draws: ● working, ▲ waiting on you,
   ● idle and ● exited in their own colours, and the word beside every one. */
.status {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--mono); font-size: 12px; font-weight: 500;
  white-space: nowrap;
}
.status .glyph { width: 1em; text-align: center; font-size: 10px; line-height: 1; }
.status-working { color: var(--working); }
.status-waiting { color: var(--waiting); }
.status-exited  { color: var(--exited); }
/* Connected is activity, not a verdict, so it is the accent. */
.status-online  { color: var(--accent); }
.status-idle, .status-starting, .status-offline, .status-unknown { color: var(--muted); }
.status-idle .glyph, .status-offline .glyph, .status-unknown .glyph { color: var(--idle); }

/* Working is the one state that moves, which is a channel colour cannot fake. */
.status-working .glyph { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* -------------------------------------------------------------------- lists */

.list { list-style: none; margin: 0; padding: 0; }
.list > li + li { margin-top: 10px; }
.empty {
  padding: 18px; color: var(--muted);
  border: 1px dashed var(--edge); border-radius: var(--radius);
  font-family: var(--mono); font-size: 13px;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 68px;
  padding: 14px 16px;
  background: var(--raised);
  border: 1px solid var(--edge-soft);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  transition: border-color .15s ease, transform .15s ease;
}
a.row:hover { border-color: var(--edge-hard); color: var(--text); transform: translateY(-1px); }
a.row:active { transform: none; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.row-head { display: flex; align-items: center; gap: 8px; }
.row-title {
  font-family: var(--display); font-weight: 650; font-size: 16.5px;
  letter-spacing: -.012em; overflow-wrap: anywhere;
}
.row-meta { color: var(--muted); font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; }
/* What the agent is doing right now -- the running tool -- in the accent, as
   the pane header has it. */
.row-detail {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-detail.error { color: var(--exited); }
.row-when { margin-left: auto; color: var(--idle); font-family: var(--mono); font-size: 11.5px; }
.chev { color: var(--idle); font-size: 1.5rem; line-height: 1; }
a.row:hover .chev { color: var(--accent); }

/* A pane waiting on you is found without reading every row, as it is on the
   site's deck: ringed and washed in the amber, and already at the top. */
.pane-row[data-status="waiting"] {
  background: linear-gradient(rgba(226,179,65,.07), rgba(226,179,65,.07)), var(--raised);
  border-color: var(--waiting);
  box-shadow: inset 0 0 0 1px var(--waiting-edge);
}
.pane-row[data-status="waiting"] .row-title { color: var(--waiting); }
.pane-row[data-status="waiting"]:hover { border-color: var(--waiting); }
.pane-row[data-status="exited"] { border-left: 3px solid var(--exited-edge); }

.projects { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 0 0 14px; }
.project {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  padding: 5px 12px;
  border: 1px solid var(--edge-soft);
  border-radius: 999px;
  background: var(--raised);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}
.project-name { color: var(--text); font-weight: 500; }

.conn { margin: 0 0 14px; min-height: 1.5em; }

/* ------------------------------------------------------------------- a pane */

/* The pane view fills the screen exactly: the terminal takes whatever the
 * heading, the keys and the message box leave, and the page itself does not
 * scroll -- two scrolling things stacked is one too many on a phone. */
body[data-view="pane"] { height: 100vh; height: 100dvh; overflow: hidden; }

.view-pane {
  max-width: none;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding-top: 10px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  gap: 8px;
}

/* The heading is a pane header, as the application and the site draw one. */
.pane-head {
  flex: none;
  padding: 8px 12px;
  background: var(--raised);
  border: 1px solid var(--edge-soft);
  border-radius: var(--radius);
}
.pane-heading { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.pane-title {
  margin: 0;
  font-family: var(--display); font-weight: 700;
  font-size: 1.1rem; letter-spacing: -.015em; line-height: 1.3;
}
.pane-meta { margin: 2px 0 0; color: var(--muted); font-family: var(--mono); font-size: 11.5px; overflow-wrap: anywhere; }
.pane-detail {
  margin: 2px 0 0;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pane-detail:empty, .pane-meta:empty { display: none; }

.term-bar { flex: none; display: flex; align-items: center; gap: 8px; }
.spacer { flex: 1; }
.term-phase { color: var(--muted); font-family: var(--mono); font-size: 12px; }
.fit-hint { flex: none; margin: 0; }
.term-note {
  flex: none;
  margin: 0;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--raised);
  border: 1px solid var(--edge-soft);
  font-size: .85rem;
  color: var(--muted);
}

.switch { display: inline-flex; align-items: center; gap: 8px; min-height: var(--tap); cursor: pointer; font-family: var(--display); font-weight: 600; font-size: 14.5px; }
.switch input { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; }

/* The terminal sits in the sunken surface, framed like a pane on the deck. */
.term {
  flex: 1;
  min-height: 120px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--sunken);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 4px 2px 2px 6px;
}
.term .xterm { width: max-content; }

/* The keys are drawn as keycaps, the way the site and the help draw a key. */
.softkeys {
  flex: none;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}
.softkeys::-webkit-scrollbar { display: none; }
.softkey {
  flex: none;
  min-width: var(--tap);
  min-height: var(--tap);
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--edge-hard);
  border-bottom-width: 2px;
  background: var(--raised);
  color: var(--text);
  font: 500 13px var(--mono);
  touch-action: manipulation;
  cursor: pointer;
}
.softkey:active { background: var(--accent-subtle); border-color: var(--accent); color: var(--accent-strong); }

.compose { flex: none; display: flex; gap: 8px; }
.compose input { flex: 1; min-width: 0; }

@media (min-width: 720px) {
  .view { padding-top: 32px; }
  .view-pane { padding-top: 14px; }
}

/* On a narrow screen a command is wrapped rather than scrolled, as the site
   does: what is copied is the text, not the lines it was drawn on, and a
   sideways scroll inside a card is easy to miss. Inline code may break too, so
   `flockdeck remote pair` cannot push a sentence off the edge. */
@media (max-width: 660px) {
  pre code { white-space: pre-wrap; overflow-wrap: anywhere; }
  p code, li code { overflow-wrap: anywhere; }
}

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