/* plopsDesk web — glass over brutalism.
 *
 * The two idioms pull in opposite directions, which is the point. Glass gives
 * depth and softness: translucent panels, a real backdrop blur, light borders.
 * Brutalism gives the structure something to sit on: hard offset shadows with no
 * blur, unapologetic borders, chunky type, and buttons that physically move when
 * pressed. Used together the glass stops the brutalism being harsh and the
 * brutalism stops the glass being mush.
 *
 * The rule that keeps it honest: every translucent surface that text sits on
 * MUST carry a backdrop-filter. Translucency without blur is how you get a
 * heading rendered over a paragraph — see `.topbar`, which is the one that would
 * bite hardest because it is sticky and always over something.
 */

:root {
  --bg: #0a0c12;
  --bg-2: #10131c;
  --ink: #f2f5fa;
  --ink-dim: #a3adc2;
  --ink-faint: #6b7488;

  --accent: #22d3a8;
  --accent-ink: #04120d;
  --violet: #8b7cf6;
  --amber: #f0b429;
  --rose: #fb7185;

  /* Glass */
  --glass: rgb(255 255 255 / 5%);
  --glass-strong: rgb(255 255 255 / 8%);
  --glass-line: rgb(255 255 255 / 12%);
  --blur: blur(20px) saturate(140%);

  /* Brutalist shadow: no blur, hard offset. The whole trick. */
  --hard: 5px 5px 0 rgb(0 0 0 / 55%);
  --hard-sm: 3px 3px 0 rgb(0 0 0 / 55%);
  --hard-accent: 5px 5px 0 var(--accent-ink);

  --radius: 14px;
  --radius-sm: 9px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

/* The UA stylesheet gives [hidden] `display: none`, but any rule that sets a
 * display wins on specificity — so `.field { display: flex }` silently defeats
 * `hidden = true`. That is what left the invite field on screen for a server
 * that does not want one. */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
  /* The page must never scroll sideways; wide things get their own scroller. */
  overflow-x: hidden;
}

/* Ambient colour behind the glass. Fixed rather than scrolling, so the blur has
 * something that actually changes as content passes over it — glass over a flat
 * colour is indistinguishable from a slightly lighter flat colour. */
body::before {
  content: "";
  position: fixed;
  inset: -20vmax;
  z-index: -1;
  background:
    radial-gradient(38vmax 38vmax at 12% 8%, rgb(34 211 168 / 18%), transparent 60%),
    radial-gradient(34vmax 34vmax at 88% 14%, rgb(139 124 246 / 16%), transparent 60%),
    radial-gradient(40vmax 40vmax at 60% 92%, rgb(240 180 41 / 10%), transparent 62%),
    var(--bg);
  /* Decorative only; it must never intercept a click. */
  pointer-events: none;
}

/* ------------------------------------------------------------------ topbar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;

  /* The load-bearing lines. A sticky bar sits over body text as you scroll; at
   * 72% alpha without a blur, that text reads straight through the bar and the
   * nav becomes unreadable. The blur is what separates the layers. */
  background: rgb(10 12 18 / 72%);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--glass-line);
}

/* Safari before 18 and Firefox before 103 have no backdrop-filter. Falling back
 * to a translucent bar there would be exactly the failure the blur prevents, so
 * the fallback is opaque instead: less pretty, still readable. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .topbar {
    background: rgb(10 12 18 / 98%);
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-decoration: none;
}

.brand svg {
  width: 22px;
  height: 22px;
  color: var(--accent);
}

.brand__tag {
  padding: 2px 8px;
  border: 1.5px solid var(--glass-line);
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.nav a {
  color: var(--ink-dim);
  text-decoration: none;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
}

.nav a:hover {
  color: var(--ink);
  background: var(--glass);
}

/* A button that happens to be a link inside the nav must keep the button's
 * colours. `.nav a` is specificity (0,1,1) and `.btn--primary` is (0,1,0), so
 * without this the primary button renders its own accent text on its own accent
 * background — invisible, and only obvious once you look at it. */
.nav a.btn {
  padding: 9px 16px;
}

.nav a.btn--primary,
.nav a.btn--primary:hover {
  color: var(--accent-ink);
  background: var(--accent);
}

.nav a.btn:not(.btn--primary):hover {
  background: rgb(255 255 255 / 12%);
}

/* ------------------------------------------------------------------ layout */

.wrap {
  width: 100%;
  max-width: 1060px;
  margin: 0 auto;
  padding: 32px 20px 72px;
}

.wrap--narrow {
  max-width: 460px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ------------------------------------------------------------------- glass */

.panel {
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1.5px solid var(--glass-line);
  border-radius: var(--radius);
  box-shadow: var(--hard);
  padding: 22px;
}

.panel--flush {
  padding: 0;
  overflow: hidden;
}

.panel h2 {
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.panel__hint {
  margin: 0;
  color: var(--ink-dim);
  font-size: 14px;
  max-width: 64ch;
}

/* --------------------------------------------------------------------- hero */

.hero {
  padding: 56px 0 36px;
  text-align: center;
}

.hero h1 {
  margin: 0 0 14px;
  font-size: clamp(34px, 7vw, 60px);
  line-height: 1.02;
  font-weight: 900;
  letter-spacing: -0.045em;
}

.hero h1 em {
  font-style: normal;
  color: var(--accent);
  /* Brutalist accent: a hard shadow on the word itself. */
  text-shadow: 3px 3px 0 rgb(0 0 0 / 45%);
}

.hero p {
  margin: 0 auto 26px;
  max-width: 60ch;
  color: var(--ink-dim);
  font-size: 17px;
}

.hero__cta {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ----------------------------------------------------------------- buttons */

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--glass-line);
  background: var(--glass-strong);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  color: var(--ink);
  font: 600 15px/1 var(--font);
  cursor: pointer;
  text-decoration: none;
  box-shadow: var(--hard-sm);
  /* Only transform and box-shadow animate, so the press is cheap to composite. */
  transition:
    transform 90ms ease,
    box-shadow 90ms ease,
    background 140ms ease;
}

.btn:hover:not(:disabled) {
  background: rgb(255 255 255 / 12%);
}

/* The brutalist press: the element moves onto its own shadow. */
.btn:active:not(:disabled) {
  transform: translate(3px, 3px);
  box-shadow: 0 0 0 rgb(0 0 0 / 0%);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
  box-shadow: var(--hard-sm);
}

.btn--primary:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 88%, white);
}

.btn--lg {
  padding: 14px 26px;
  font-size: 16px;
  box-shadow: var(--hard);
}

.btn--lg:active:not(:disabled) {
  transform: translate(5px, 5px);
}

.btn--danger {
  color: var(--rose);
  border-color: color-mix(in srgb, var(--rose) 40%, transparent);
}

.btn--ghost {
  box-shadow: none;
  border-color: transparent;
  background: transparent;
}

.btn--ghost:hover:not(:disabled) {
  background: var(--glass);
}

.btn--ghost:active:not(:disabled) {
  transform: none;
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

/* ------------------------------------------------------------------ fields */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.field label {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.input {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--glass-line);
  background: rgb(0 0 0 / 28%);
  color: var(--ink);
  font: 15px/1.4 var(--font);
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

.input--code {
  font-family: var(--mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.field__error {
  font-size: 13px;
  color: var(--rose);
  min-height: 1.2em;
}

.field__hint {
  font-size: 13px;
  color: var(--ink-faint);
}

/* ------------------------------------------------------------------- notes */

.note {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  padding: 13px 15px;
  border-radius: var(--radius-sm);
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1.5px solid var(--glass-line);
  border-left-width: 4px;
  font-size: 14px;
  color: var(--ink-dim);
}

.note strong {
  color: var(--ink);
}

/* Without an explicit size an inline SVG takes its viewBox as intrinsic
 * dimensions and renders enormous next to the text it annotates. */
.note svg,
.note__icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  margin-top: 2px;
}

.note--ok svg {
  color: var(--accent);
}
.note--warn svg {
  color: var(--amber);
}
.note--bad svg {
  color: var(--rose);
}

.note--ok {
  border-left-color: var(--accent);
}
.note--warn {
  border-left-color: var(--amber);
}
.note--bad {
  border-left-color: var(--rose);
}

/* ------------------------------------------------------------------- cards */

.grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.card {
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1.5px solid var(--glass-line);
  border-radius: var(--radius);
  box-shadow: var(--hard-sm);
  padding: 20px;
}

.card h3 {
  margin: 12px 0 6px;
  font-size: 16px;
  font-weight: 800;
}

.card p {
  margin: 0;
  color: var(--ink-dim);
  font-size: 14px;
}

.card__icon {
  width: 26px;
  height: 26px;
  color: var(--accent);
}

/* ---------------------------------------------------------------- machines */

.machines {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.machine {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1.5px solid var(--glass-line);
  border-radius: var(--radius);
  box-shadow: var(--hard-sm);
}

.machine--off {
  opacity: 0.6;
}

.machine__icon {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: rgb(0 0 0 / 30%);
  border: 1.5px solid var(--glass-line);
  color: var(--ink-dim);
}

.machine__icon svg {
  width: 20px;
  height: 20px;
}

.machine__body {
  flex: 1;
  min-width: 0;
}

.machine__name {
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.machine__meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 5px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1.5px solid var(--glass-line);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--ink-faint);
}

.tag--on {
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  color: var(--accent);
}

.tag--warn {
  border-color: color-mix(in srgb, var(--amber) 45%, transparent);
  color: var(--amber);
}

/* --------------------------------------------------------------- invites */

.invite {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 15px;
  border: 1.5px solid var(--glass-line);
  border-radius: var(--radius-sm);
  background: rgb(0 0 0 / 22%);
  flex-wrap: wrap;
}

.invite--dead {
  opacity: 0.5;
}

.invite__code {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.08em;
  /* A code exists to be selected and copied. */
  user-select: all;
}

.invite__meta {
  font-size: 12px;
  color: var(--ink-faint);
  flex: 1;
  min-width: 140px;
}

/* --------------------------------------------------------------- utilities */

.empty {
  padding: 34px 22px;
  text-align: center;
  color: var(--ink-dim);
  border: 2px dashed var(--glass-line);
  border-radius: var(--radius);
}

.muted {
  color: var(--ink-faint);
  font-size: 13px;
}

.mono {
  font-family: var(--mono);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.center {
  text-align: center;
}

.spread {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

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

/* Wide content gets its own scroller so the page body never does. */
.scroll-x {
  overflow-x: auto;
  max-width: 100%;
}

/* ------------------------------------------------------------------ toasts */

#toasts {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 9px;
  width: min(520px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--glass-line);
  background: rgb(16 19 28 / 88%);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: var(--hard-sm);
  font-size: 14px;
  font-weight: 600;
  animation: rise 160ms ease;
}

.toast--bad {
  border-color: color-mix(in srgb, var(--rose) 50%, transparent);
  color: var(--rose);
}

.toast--ok {
  border-color: color-mix(in srgb, var(--accent) 50%, transparent);
  color: var(--accent);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* Motion is decoration here; the settings that ask for less should get less. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ------------------------------------------------------------- responsive */

@media (max-width: 620px) {
  .topbar {
    padding: 10px 14px;
  }

  .brand__tag {
    display: none;
  }

  .machine {
    flex-wrap: wrap;
  }

  .machine__body {
    flex-basis: 100%;
    order: 2;
  }

  .hero {
    padding: 34px 0 26px;
  }
}
