/* Sluse base styles: the shared look of every surface. It needs tokens.css
   first. Nothing here uses a URL, and no page may put a style attribute on an
   element: the pages slused and the desktop app serve run under a CSP that
   allows neither. Use the utility classes at the end instead. */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 1.75rem;
  line-height: 1.2;
  font-weight: 750;
  letter-spacing: -0.015em;
}

h2 {
  font-size: 1.2rem;
  line-height: 1.3;
  font-weight: 700;
  letter-spacing: -0.01em;
}

h3 {
  font-size: 1rem;
  font-weight: 650;
}

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

code,
.mono {
  font-family: var(--mono);
  font-size: 0.88em;
}

code {
  background: var(--surface-2);
  border-radius: 4px;
  padding: 0.1em 0.35em;
}

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

::selection {
  background: var(--sky);
  color: var(--ink);
}

/* ---- Layout ------------------------------------------------------------ */

.page {
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 4rem;
}

.page-narrow {
  max-width: 560px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stack > * + * {
  margin-top: 1rem;
}

.stack-s > * + * {
  margin-top: 0.5rem;
}

.stack-l > * + * {
  margin-top: 1.75rem;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}

.spread {
  justify-content: space-between;
}

.grow {
  flex: 1 1 auto;
  min-width: 0;
}

.center {
  text-align: center;
}

.row.center {
  justify-content: center;
}

/* ---- Logo ---------------------------------------------------------------- */

/* The logo is inline SVG whose letters use currentColor, so it follows the
   theme. Its box includes the stream above and below the letters. */
.logo {
  display: block;
  height: 64px;
  width: auto;
  color: var(--text);
}

.logo-l {
  height: 132px;
}

.logo-s {
  height: 44px;
}

.mark {
  display: block;
  width: 48px;
  height: 48px;
  color: var(--text);
}

.mark-s {
  width: 28px;
  height: 28px;
}

/* ---- Card ---------------------------------------------------------------- */

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}

.card-l {
  padding: 2rem;
}

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

/* ---- Buttons ------------------------------------------------------------- */

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 2.6rem;
  padding: 0.5rem 1.1rem;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-s);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  overflow: hidden;
  transition: background-color 0.12s, border-color 0.12s, transform 0.06s;
}

.btn:hover {
  background: var(--surface-2);
  border-color: var(--text);
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

/* The main action: ink, with the stream showing along the bottom on hover. */
.btn-primary {
  background: var(--solid);
  border-color: var(--solid);
  color: var(--on-solid);
}

.btn-primary:hover {
  background: var(--solid-hover);
  border-color: var(--solid-hover);
}

.btn-primary::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  background: var(--stream);
  transform: translateY(4px);
  transition: transform 0.12s;
}

.btn-primary:hover::after,
.btn-primary:focus-visible::after {
  transform: none;
}

.btn-primary:disabled::after {
  display: none;
}

.btn-quiet {
  background: transparent;
  border-color: transparent;
}

.btn-quiet:hover {
  background: rgba(127, 140, 140, 0.18);
  border-color: transparent;
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--surface);
}

.btn-danger:hover {
  background: var(--danger);
  border-color: var(--text);
}

.btn-l {
  min-height: 3.25rem;
  padding: 0.7rem 1.6rem;
  font-size: 1.1rem;
}

.btn-s {
  min-height: 2.1rem;
  padding: 0.3rem 0.75rem;
  font-size: 0.92rem;
}

.btn-block {
  display: flex;
  width: 100%;
}

.btn-icon {
  min-width: 2.6rem;
  padding: 0.4rem;
}

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

.field {
  display: block;
}

.field > .label,
.label {
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.92rem;
  font-weight: 600;
}

.hint {
  display: block;
  margin-top: 0.3rem;
  color: var(--text-2);
  font-size: 0.88rem;
}

.input {
  display: block;
  width: 100%;
  min-height: 2.75rem;
  padding: 0.55rem 0.75rem;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-s);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.input::placeholder {
  color: var(--text-2);
  opacity: 0.8;
}

.input:focus {
  outline: 3px solid var(--sky);
  outline-offset: 0;
  border-color: var(--text);
}

.input[readonly] {
  background: var(--surface-2);
}

.input:disabled {
  opacity: 0.6;
}

/* An input with a button on its right. */
.input-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.input-row > .input {
  flex: 1 1 auto;
  min-width: 0;
}

/* ---- Notices ------------------------------------------------------------- */

.notice {
  border-left: 6px solid var(--sky);
  border-radius: var(--radius-s);
  background: var(--info-bg);
  padding: 0.75rem 1rem;
}

.notice-ok {
  border-left-color: var(--ok);
  background: var(--ok-bg);
}

.notice-warn {
  border-left-color: var(--yellow);
  background: var(--warn-bg);
}

.notice-error {
  border-left-color: var(--danger);
  background: var(--danger-bg);
  color: var(--danger);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ---- Chips --------------------------------------------------------------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.12rem 0.6rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 0.82rem;
  font-weight: 650;
  white-space: nowrap;
}

.chip::before {
  content: "";
  width: 8px;
  height: 8px;
  background: currentColor;
}

.chip-ok {
  background: var(--ok-bg);
  color: var(--ok);
}

.chip-busy {
  background: var(--info-bg);
  color: var(--accent);
}

.chip-warn {
  background: var(--warn-bg);
  color: var(--warn);
}

.chip-off {
  background: var(--danger-bg);
  color: var(--danger);
}

/* ---- Stream progress bar ------------------------------------------------- */

/* Markup: a .stream element holding one .stream-fill. Script sets the fill's
   width. The ::after layer cuts the bar into pixels. */
.stream {
  position: relative;
  height: 16px;
  border-radius: 3px;
  background: var(--surface-2);
  overflow: hidden;
}

.stream-fill {
  height: 100%;
  width: 0%;
  background: var(--stream-pixels);
  transition: width 0.2s linear;
}

/* While data is moving, a soft highlight travels along the filled part, so
   a slow transfer still reads as alive. Script adds and removes .is-flowing;
   a stalled transfer loses it. */
.stream.is-flowing .stream-fill {
  background-image: linear-gradient(
      100deg,
      transparent 0 38%,
      rgba(255, 255, 255, 0.6) 50%,
      transparent 62% 100%
    ),
    var(--stream-pixels);
  background-size: 192px 100%, auto;
  background-repeat: repeat-x, repeat;
  animation: sluse-flow 1.3s linear infinite;
}

@keyframes sluse-flow {
  from {
    background-position: -192px 0, 0 0;
  }
  to {
    background-position: 0 0, 0 0;
  }
}

.stream::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 14px, var(--surface) 14px 16px);
  pointer-events: none;
}

/* A row of six stream pixels, as a small accent under a title. */
.pixels {
  display: flex;
  gap: 4px;
}

.pixels > i {
  width: 10px;
  height: 10px;
  background: var(--yellow);
}

.pixels > i:nth-child(2) {
  background: var(--coral);
}

.pixels > i:nth-child(3) {
  background: var(--magenta);
}

.pixels > i:nth-child(4) {
  background: var(--purple);
}

.pixels > i:nth-child(5) {
  background: var(--sky);
}

.pixels > i:nth-child(6) {
  background: var(--blue);
}

.center > .pixels,
.pixels.center {
  justify-content: center;
}

/* While something is in flight, the pixels take turns dipping. */
.pixels-busy > i {
  animation: sluse-dip 1.2s ease-in-out infinite;
}

.pixels-busy > i:nth-child(2) {
  animation-delay: 0.1s;
}

.pixels-busy > i:nth-child(3) {
  animation-delay: 0.2s;
}

.pixels-busy > i:nth-child(4) {
  animation-delay: 0.3s;
}

.pixels-busy > i:nth-child(5) {
  animation-delay: 0.4s;
}

.pixels-busy > i:nth-child(6) {
  animation-delay: 0.5s;
}

@keyframes sluse-dip {
  0%,
  60%,
  100% {
    transform: none;
  }
  30% {
    transform: translateY(6px);
  }
}

/* ---- Disclosure: where the technical detail lives ------------------------- */

.more {
  border-top: 1px solid var(--line);
  padding-top: 0.75rem;
}

.more > summary {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--text-2);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  border-radius: 4px;
}

.more > summary::-webkit-details-marker {
  display: none;
}

.more > summary::before {
  content: "";
  width: 8px;
  height: 8px;
  background: currentColor;
  transition: transform 0.12s;
}

.more[open] > summary::before {
  transform: rotate(45deg);
}

.more > summary:hover {
  color: var(--text);
}

.more > summary + * {
  margin-top: 0.75rem;
}

.more-plain {
  border-top: 0;
  padding-top: 0;
}

/* Label and value pairs inside a disclosure. */
.facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.3rem 1rem;
  margin: 0;
  font-size: 0.9rem;
}

.facts dt {
  color: var(--text-2);
}

.facts dd {
  margin: 0;
  overflow-wrap: anywhere;
}

/* ---- Dropdown menu ------------------------------------------------------- */

/* Markup: a details.menu whose summary is the button (.btn .btn-quiet
   .btn-icon, with an aria-label), followed by a .menu-list of .menu-item
   buttons. */
.menu {
  position: relative;
  display: inline-block;
}

.menu > summary {
  list-style: none;
}

.menu > summary::-webkit-details-marker {
  display: none;
}

.menu-list {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  right: 0;
  min-width: 13rem;
  padding: 0.35rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 0;
  border-radius: var(--radius-s);
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.menu-item:hover,
.menu-item:focus-visible {
  background: var(--surface-2);
}

.menu-item-danger {
  color: var(--danger);
}

.menu-sep {
  height: 1px;
  margin: 0.3rem 0;
  background: var(--line);
}

/* Three stacked pixels: the "more" glyph. */
.dots {
  display: inline-grid;
  gap: 3px;
}

.dots > i {
  width: 4px;
  height: 4px;
  background: currentColor;
}

/* ---- Dialog -------------------------------------------------------------- */

.dialog {
  width: min(28rem, calc(100vw - 2rem));
  padding: 1.5rem;
  border: 0;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-pop);
}

.dialog::backdrop {
  background: var(--scrim);
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 1.5rem;
}

/* ---- Drop zone ----------------------------------------------------------- */

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 2.5rem 1.25rem;
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.12s, background-color 0.12s;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--text);
}

.dropzone.dragover {
  border-style: solid;
  background: var(--info-bg);
}

.dropzone-title {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* ---- Lists of things (sends, files) -------------------------------------- */

.list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.list > li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 0;
  border-top: 1px solid var(--line);
}

.list > li:first-child {
  border-top: 0;
}

.item-title {
  font-weight: 650;
  overflow-wrap: anywhere;
}

.item-sub {
  color: var(--text-2);
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

/* A bounded, scrollable region for long lists. */
.scroll {
  max-height: 20rem;
  overflow: auto;
}

/* ---- Tabs ---------------------------------------------------------------- */

.tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0.25rem;
  border-radius: var(--radius);
  background: rgba(127, 140, 140, 0.2);
}

.tab {
  flex: 1 1 0;
  min-height: 2.5rem;
  padding: 0.4rem 0.75rem;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

.tab:hover {
  color: var(--text);
}

.tab[aria-selected="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

/* ---- Utilities ----------------------------------------------------------- */

.hidden {
  display: none !important;
}

.muted {
  color: var(--text-2);
}

.small {
  font-size: 0.9rem;
}

.strong {
  font-weight: 650;
}

.nowrap {
  white-space: nowrap;
}

.break {
  overflow-wrap: anywhere;
}

.pre {
  white-space: pre-line;
}

.mt-0 {
  margin-top: 0 !important;
}

.mt-s {
  margin-top: 0.5rem !important;
}

.mt-m {
  margin-top: 1rem !important;
}

.mt-l {
  margin-top: 1.75rem !important;
}

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

@media (max-width: 520px) {
  .page {
    padding: 1rem 0.9rem 3rem;
  }

  .card,
  .card-l {
    padding: 1.15rem;
  }

  h1 {
    font-size: 1.45rem;
  }

  .logo-l {
    height: 104px;
  }
}

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