/* Geist, latin and latin-ext only (variable weights), served by the app itself. */
@font-face {
  font-family: 'Geist Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(fonts/geist-latin-ext-wght-normal.woff2) format('woff2-variations');
  unicode-range:
    U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F,
    U+A720-A7FF;
}

@font-face {
  font-family: 'Geist Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(fonts/geist-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;
}

@font-face {
  font-family: 'Geist Mono Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(fonts/geist-mono-latin-ext-wght-normal.woff2) format('woff2-variations');
  unicode-range:
    U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F,
    U+A720-A7FF;
}

@font-face {
  font-family: 'Geist Mono Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(fonts/geist-mono-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;
}

:root {
  color-scheme: light dark;
  --paper: #f7f6f2;
  --surface: #ffffff;
  --ink: #0e0e0c;
  --muted: #6b6a64;
  /* Borders of cards, buttons and fields: the ink at 20%, on both themes. */
  --line: rgb(14 14 12 / 20%);
  --sans: 'Geist Variable', ui-sans-serif, system-ui, sans-serif;
  --mono: 'Geist Mono Variable', ui-monospace, 'SFMono-Regular', Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0e0e0c;
    --surface: #171715;
    --ink: #f7f6f2;
    --muted: #9a998f;
    --line: rgb(247 246 242 / 20%);
  }
}

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

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* `minmax(0, 1fr)`: a grid column would otherwise grow with its widest button and overflow. */
.screen {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  max-width: 520px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}

.screen.narrow {
  min-height: 100dvh;
  align-content: center;
}

h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.topbar {
  padding-top: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.topbar h1 {
  font-size: 1.125rem;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.devices {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

.card,
.login {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.card-mac {
  margin: 4px 0 0;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--muted);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.marker {
  width: 10px;
  height: 10px;
  border: 2px solid var(--ink);
}

.status.online .marker {
  background: var(--ink);
}

.status.starting .marker {
  background: var(--ink);
  animation: blink 1s steps(2, start) infinite;
}

.status.unknown .marker {
  background: repeating-linear-gradient(45deg, var(--ink) 0 2px, transparent 2px 4px);
}

/* The state is being confirmed by the hub: the loader takes the place of the marker. */
.status.checking {
  color: var(--muted);
}

.status.checking .icon {
  width: 14px;
  height: 14px;
}

@keyframes blink {
  to {
    visibility: hidden;
  }
}

/* The home is out of reach: the cards below are its last known state. */
.notice {
  margin: 0;
  padding: 12px 16px;
  font-family: var(--mono);
  font-size: 0.8rem;
  border: 1px dashed var(--line);
  color: var(--muted);
}

.button,
.field {
  min-height: 48px;
  font: inherit;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  -webkit-appearance: none;
  appearance: none;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 22px;
  font-weight: 500;
  cursor: pointer;
}

.icon {
  flex: none;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: square;
  stroke-linejoin: miter;
}

.button.compact .icon {
  width: 16px;
  height: 16px;
}

/* The loading icon is a standard "loader circle" that turns. */
.icon-loading {
  animation: spin 0.9s linear infinite;
}

/* A button that sends a request swaps its own icon for the loading one (htmx adds the class). */
.button .icon-busy {
  display: none;
}

.button.htmx-request .icon-busy {
  display: block;
}

.button.htmx-request .icon-idle {
  display: none;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.card-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}

.button.compact {
  gap: 8px;
  min-height: 40px;
  padding: 0 10px;
  font-size: 0.875rem;
}

.button:hover:not(:disabled) {
  color: var(--paper);
  background: var(--ink);
}

.button.primary {
  color: var(--paper);
  background: var(--ink);
}

.button.primary:hover:not(:disabled) {
  background: var(--muted);
  border-color: var(--muted);
}

.button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.button:focus-visible,
.field:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

.field {
  width: 100%;
  padding: 0 16px;
  background: var(--paper);
}

.field::placeholder {
  color: var(--muted);
}

.toasts {
  position: fixed;
  inset: auto 0 max(16px, env(safe-area-inset-bottom));
  display: grid;
  gap: 8px;
  justify-items: center;
  padding: 0 16px;
  pointer-events: none;
}

/* A toast appears, stays 4 seconds, then fades out by itself: no script needed. */
.toast {
  max-width: 520px;
  margin: 0;
  padding: 12px 16px;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--paper);
  background: var(--ink);
  border: 1px solid var(--ink);
  animation:
    toast-in 0.2s ease-out,
    toast-out 0.2s ease-in 3.8s forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(8px);
    visibility: hidden;
  }
}

.empty {
  margin: 0;
  padding: 24px 0;
  color: var(--muted);
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  .toast {
    animation: toast-out 0.01s linear 4s forwards;
  }

  .icon-loading,
  .status.starting .marker {
    animation: none;
  }
}
