/* Colour tokens: the app's dark theme (web/src/index.css .dark), named as
   the app names them. Every colour on these pages is one of them;
   internal/connector/authorize.go mirrors them. The type sizes, spacing and
   layout widths are not the app's: they come from the website's design rule
   (docs/design-cloudfield.md on feat/cloudfield-site, f2a108dda). */
:root {
  --canvas: #181825;
  --chrome: #11111b;
  --hover: #252536;
  --raised: #222233;
  --hover-chrome: #2a2b3c;
  --seam: rgb(205 214 244 / 0.1);
  --control-border: #8c91a8;
  --text: #cdd6f4;
  --text-muted: #a6adc8;
  --icon-faint: #7f849c;
  --accent-fill: #fab387;
  --accent-fill-hover: #dc9e77;
  --on-accent: #11111b;
  --accent-text: #89dceb;
  --focus-ring: #89dceb;
  --state-done: #a6e3a1;
  --state-paused: #9399b2;
  --state-failed: #f38ba8;
  --state-failed-hover: #dd809b;
  --on-failed: #11111b;
  --state-needs-you: #fab387;

  --button-shadow: 0 2px 3.5px -1px rgb(0 0 0 / 0.67);
  --button-hover-shadow: 0 2px 4px -1px rgb(0 0 0 / 0.75);
  --card-shadow: 0 1px 2px rgb(0 0 0 / 0.4);

  --radius-chip: 5px;
  --radius-control: 8px;
  --radius-panel: 12px;

  --duration-hover: 150ms;
  --ease-hover: cubic-bezier(0.25, 0.1, 0.25, 1);
  --duration-press: 150ms;
  --duration-release: 130ms;
  --ease-press: cubic-bezier(0.16, 1, 0.3, 1);
  --scale-press: 0.97;

  --font-sans: 'DM Sans Variable', 'DM Sans Fallback', system-ui, sans-serif;
  --font-title: 'Open Sans Variable', 'DM Sans Variable', 'DM Sans Fallback', system-ui, sans-serif;
  --font-code: ui-monospace, 'SF Mono', Menlo, 'Cascadia Mono', Consolas, 'Liberation Mono', 'DejaVu Sans Mono', monospace;

  --size-small: 13px;
  --size-ui: 15px;
  --size-body: 16px;
  --size-h3: 16px;
  --size-h2: 20px;
  --size-h1: 28px;
  --size-device-code: 24px;
  --size-confirm-code: 34px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;

  --gutter: 24px;
  --column: 880px;
  --measure: 68ch;
  --panel-wide: 680px;
  --panel: 440px;
  --control-height: 40px;
  --input-height: 44px;
  --touch-target: 44px;
  --logo-height: 32px;

  color-scheme: dark;
}

@font-face {
  font-family: 'DM Sans Variable';
  font-style: normal;
  font-weight: 100 1000;
  font-display: swap;
  src: url('/fonts/dm-sans-latin-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Arial (or its metric twin Liberation Sans) scaled to DM Sans's metrics,
   as the dashboard does. */
@font-face {
  font-family: 'DM Sans Fallback';
  src: local('Arial'), local('Liberation Sans');
  size-adjust: 104.53%;
  ascent-override: 94.90%;
  descent-override: 29.66%;
  line-gap-override: 0%;
}

@font-face {
  font-family: 'Open Sans Variable';
  font-style: normal;
  font-weight: 300 800;
  font-display: swap;
  src: url('/fonts/open-sans-latin-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

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

html {
  background: var(--canvas);
  color: var(--text);
  font: 400 var(--size-body)/1.55 var(--font-sans);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0 auto;
  max-width: calc(var(--column) + 2 * var(--gutter));
  padding: 0 var(--gutter) var(--space-12);
  overflow-wrap: break-word;
}

p, ul, dl, table, form { margin: 0 0 var(--space-4); }
main > p:not(.error, .warning, .empty), .note, .danger-zone p { max-width: var(--measure); }

/* A page with one task (sign in, a code, a result, an error) is one narrow
   column, centred when signed out; lists and the account page keep the full
   width. */
main:not(:has(.list, .choices, .danger-zone, .empty, .panel.full)), .top:not(:has(nav)) { max-width: var(--panel); }
main:has(.usercode) { max-width: var(--panel-wide); }
.top:not(:has(nav)), .top:not(:has(nav)) + main { margin-inline: auto; }
main > .panel:only-of-type { max-width: none; }

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

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

strong { font-weight: 600; }

code {
  font-family: var(--font-code);
  font-size: 0.875em;
  overflow-wrap: anywhere;
  background: var(--chrome);
  border: 1px solid var(--seam);
  border-radius: var(--radius-chip);
  padding: 0 var(--space-1);
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

h1, h2 { font-family: var(--font-title); font-weight: 600; line-height: 1.2; letter-spacing: 0; overflow-wrap: anywhere; }
h1 { font-size: var(--size-h1); margin: var(--space-8) 0 var(--space-5); }
h2 { font-size: var(--size-h2); margin: 0 0 var(--space-3); }
h3 { font-size: var(--size-h3); font-weight: 600; line-height: 1.3; margin: var(--space-6) 0 var(--space-3); }

/* The shell */

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-4);
  padding-top: var(--space-4);
  border-bottom: 1px solid var(--seam);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: 0;
  min-height: 48px;
  padding-bottom: var(--space-4);
  line-height: 1;
  color: var(--text-muted);
  font-size: var(--size-ui);
  font-weight: 500;
}
.brand img { display: block; height: var(--logo-height); width: auto; }
/* Sets Edge on the wordmark's baseline, 29.4 of the logo's 32px down. */
.brand span { align-self: flex-start; padding-top: 26px; }
.top:has(nav) .brand { padding-bottom: 0; }

.who {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  margin: 0;
  color: var(--text-muted);
  font-size: var(--size-small);
  overflow-wrap: anywhere;
}
.who form { margin: 0; }

.top nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--space-5);
  flex-basis: 100%;
}
.top nav a {
  display: inline-flex;
  align-items: center;
  min-height: var(--touch-target);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  color: var(--text-muted);
  font-size: var(--size-ui);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--duration-hover) var(--ease-hover);
}
.top nav a:hover { color: var(--text); }
.top nav a[aria-current='page'] { color: var(--text); border-bottom-color: var(--accent-text); }
.top nav a:focus-visible { outline-offset: -2px; border-radius: var(--radius-chip); }

/* Controls */

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--control-height);
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--seam);
  border-radius: var(--radius-control);
  background: var(--raised);
  box-shadow: var(--button-shadow);
  color: var(--text);
  font: 500 var(--size-ui)/1.3 var(--font-sans);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  vertical-align: middle;
  transition:
    color var(--duration-hover) var(--ease-hover),
    background-color var(--duration-hover) var(--ease-hover),
    border-color var(--duration-hover) var(--ease-hover),
    box-shadow var(--duration-hover) var(--ease-hover),
    scale var(--duration-release) var(--ease-press);
}
button:hover, .button:hover { background: var(--hover-chrome); box-shadow: var(--button-hover-shadow); }

.primary, .primary:hover { border-color: transparent; box-shadow: none; color: var(--on-accent); }
.primary { background: var(--accent-fill); }
.primary:hover { background: var(--accent-fill-hover); }

.danger, .danger:hover { border-color: transparent; box-shadow: none; color: var(--on-failed); }
.danger { background: var(--state-failed); }
.danger:hover { background: var(--state-failed-hover); }

.small { min-height: 32px; padding: var(--space-1) var(--space-3); font-size: var(--size-small); }

.wide { display: flex; width: 100%; white-space: normal; }

@media (pointer: fine) {
  button:active, .button:active {
    scale: var(--scale-press);
    transition-duration: var(--duration-hover), var(--duration-hover), var(--duration-hover), var(--duration-hover), var(--duration-press);
  }
}


label { display: block; margin-bottom: var(--space-4); color: var(--text-muted); font-size: var(--size-ui); font-weight: 500; }
label strong { color: var(--text); }

input {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: var(--input-height);
  margin-top: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--control-border);
  border-radius: var(--radius-control);
  background: var(--chrome);
  color: var(--text);
  font: 400 var(--size-body)/1.4 var(--font-sans);
}
input:focus-visible { outline: 1px solid var(--focus-ring); outline-offset: -1px; border-color: var(--focus-ring); }

input[name='user_code'] {
  width: 12ch;
  box-sizing: content-box;
  font-family: var(--font-code);
  font-size: var(--size-device-code);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* Surfaces */

.panel {
  max-width: var(--panel);
  margin-bottom: var(--space-6);
  padding: var(--space-6);
  border: 1px solid var(--seam);
  border-radius: var(--radius-panel);
  background: var(--raised);
  box-shadow: var(--card-shadow);
}
.panel > :last-child { margin-bottom: 0; }
.panel.full { max-width: none; }

.error, .warning {
  padding: var(--space-3) var(--space-4);
  border-radius: 0 var(--radius-control) var(--radius-control) 0;
  color: var(--text);
}
.error { background: var(--chrome); border-left: 2px solid var(--state-failed); }
.warning {
  margin-bottom: var(--space-5);
  border: 1px solid var(--seam);
  border-left: 2px solid var(--state-needs-you);
  background: var(--raised);
}
.done { border-left: 2px solid var(--state-done); }

.note { color: var(--text-muted); font-size: var(--size-ui); }

.empty {
  padding: var(--space-5) var(--space-6);
  border: 1px solid var(--seam);
  border-radius: var(--radius-panel);
  background: var(--chrome);
  color: var(--text-muted);
}
.empty code { white-space: nowrap; }

.actions { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.actions button { min-width: 8rem; }

/* Device confirmation */

.details { display: grid; gap: var(--space-3); }
.details > div { display: grid; grid-template-columns: 9rem minmax(0, 1fr); gap: var(--space-1) var(--space-4); }
.details dt { color: var(--text-muted); font-size: var(--size-ui); }
.details dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.details code { font-size: var(--size-small); }

.details > .usercode {
  display: block;
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--seam);
  border-radius: var(--radius-panel);
  background: var(--chrome);
}
.usercode dt { font-size: var(--size-small); margin-bottom: var(--space-1); }
.usercode dd {
  font-family: var(--font-code);
  font-size: var(--size-confirm-code);
  font-weight: 600;
  letter-spacing: 0.14em;
  line-height: 1.2;
  white-space: nowrap;
  overflow-wrap: normal;
}

/* Lists: a table at 900px and up, a card per row below. */

.list { width: 100%; border-collapse: separate; border-spacing: 0; border: 1px solid var(--seam); border-radius: var(--radius-panel); overflow: hidden; }
.list th, .list td { padding: var(--space-3); font-size: var(--size-ui); text-align: left; vertical-align: top; border-bottom: 1px solid var(--seam); }
.list tbody tr:last-child td { border-bottom: 0; }
.list th { background: var(--chrome); color: var(--text-muted); font-size: var(--size-small); font-weight: 500; }
.list th:first-child, .list td:first-child { padding-left: var(--space-4); }
.list tbody tr { transition: background-color var(--duration-hover) var(--ease-hover); }
.list tbody tr:hover { background: var(--hover); }
.list td form { margin: 0; }
.list td:first-child { min-width: 13.5rem; }
.list code.sub { white-space: nowrap; }
.list td[data-label='Status'] { white-space: nowrap; }
.list .action { padding-block: 6px; text-align: right; width: 1%; white-space: nowrap; }
.list .action button { min-height: 32px; padding: var(--space-1) var(--space-3); background: none; box-shadow: none; color: var(--text-muted); font-size: var(--size-small); }
.list .action button:hover { background: var(--hover-chrome); color: var(--text); }
.list .name { display: block; font-weight: 600; overflow-wrap: anywhere; }
.list .sub { display: block; }
.list td .sub { margin-top: var(--space-1); padding: 0; border: 0; background: none; color: var(--text-muted); font-size: var(--size-small); }
.list .date { white-space: nowrap; }

.status::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: var(--space-2);
  border-radius: 50%;
  background: var(--state-paused);
  vertical-align: 1px;
}
.status.online::before { background: var(--state-done); }

@media (max-width: 899.98px) {
  .list, .list tbody, .list tr, .list td { display: block; }
  .list { border: 0; border-radius: 0; overflow: visible; }
  .list thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .list tbody tr {
    margin-bottom: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--seam);
    border-radius: var(--radius-panel);
    background: var(--raised);
  }
  .list tbody tr:hover { background: var(--raised); }
  .list td, .list td:first-child, .list tbody tr:last-child td { padding: var(--space-1) 0; border: 0; }
  .list td[data-label]::before, .list .sub[data-label]::before {
    content: attr(data-label);
    display: block;
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: var(--size-small);
    font-weight: 500;
  }
  .list td .sub { margin-top: var(--space-2); }
  .list th:first-child, .list td:first-child { width: auto; }
  .list .action { width: auto; margin-top: var(--space-2); padding-top: var(--space-3); border-top: 1px solid var(--seam); text-align: left; }
  .list .action:empty { display: none; }
  .list .action button { width: 100%; min-height: var(--touch-target); }
  .list code.sub { white-space: normal; overflow-wrap: anywhere; }
  .list .date { white-space: normal; }
}

/* Choosing a server */

.choices { display: grid; gap: var(--space-3); padding: 0; list-style: none; }
.choices > li {
  padding: var(--space-5);
  border: 1px solid var(--seam);
  border-radius: var(--radius-panel);
  background: var(--raised);
  box-shadow: var(--card-shadow);
}
.choices form { margin: 0; }
.choices p { margin-bottom: var(--space-4); color: var(--text-muted); }
.choices p strong { display: block; margin-bottom: var(--space-1); color: var(--text); font-size: 18px; overflow-wrap: anywhere; }
.choices > li:not(:only-child) .primary { border-color: var(--seam); background: var(--raised); box-shadow: var(--button-shadow); color: var(--text); }
.choices > li:not(:only-child) .primary:hover { background: var(--hover-chrome); box-shadow: var(--button-hover-shadow); }
@media (min-width: 640px) { .choices .wide { display: inline-flex; width: auto; } }
.choices.unavailable > li { background: none; box-shadow: none; color: var(--text-muted); }

/* Account */

.danger-zone {
  margin-top: var(--space-8);
  padding: var(--space-6);
  border: 1px solid var(--seam);
  border-radius: var(--radius-panel);
  box-shadow: inset 2px 0 0 var(--state-failed);
}
.danger-zone p > .button { min-height: 32px; padding: 2px var(--space-3); font-size: var(--size-small); vertical-align: baseline; }
.danger-zone .error { margin-top: var(--space-6); }
.danger-zone > :last-child { margin-bottom: 0; }
.danger-zone h3:first-of-type { margin-top: var(--space-6); }
.danger-zone form { margin-top: var(--space-6); }
.danger-zone label { max-width: 360px; }

/* Joining */

.copy { display: flex; gap: var(--space-2); align-items: stretch; margin-top: var(--space-2); }
.copy input { flex: 1; margin: 0; font-family: var(--font-code); font-size: var(--size-small); }
.copy button { min-height: var(--input-height); }

@media (max-width: 480px) {
  .details > div { grid-template-columns: minmax(0, 1fr); gap: 0; }
}

@media (max-width: 400px) {
  :root { --gutter: 16px; --size-h1: 24px; --size-confirm-code: 32px; }
  .top nav { gap: 0 var(--space-3); }
  .panel, .danger-zone { padding: var(--space-5) var(--space-4); }
  .actions { flex-direction: column; }
  .actions button { width: 100%; }
  .usercode dd { letter-spacing: 0.1em; }
}

@media (pointer: coarse) {
  button, .button, .small, .list .action button, .danger-zone p > .button { min-height: var(--touch-target); }
}

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