/* Rusty Mumble Bot web UI.
   Flat and quiet: panels are separated by rules, not cards. One serif for
   headings and track names, the system sans for everything else. The signal
   colour (--live) marks only live state: what is playing, locked mode. */

:root {
  color-scheme: light dark;
  --bg: #eef1f3;
  --surface: #ffffff;
  --ink: #13202b;
  --muted: #4f5e6b;
  --rule: #c8d1d9;
  --rule-strong: #71808d;
  --primary: #1d4e63;
  --on-primary: #ffffff;
  --live: #b23d0b;
  --danger: #a1281b;
  --warn: #7a4a00;
  --focus: #0b57d0;

  --serif: Georgia, "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --step-1: 0.875rem;
  --step-2: 1rem;
  --step-3: 1.25rem;
  --step-4: 1.563rem;
  --step-5: 1.953rem;

  --r-sm: 6px;
  --r: 8px;
  --gutter: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e161d;
    --surface: #15202a;
    --ink: #e6edf3;
    --muted: #a6b4c0;
    --rule: #2d3d4a;
    --rule-strong: #66798a;
    --primary: #8fc9de;
    --on-primary: #0b1820;
    --live: #ff9d6b;
    --danger: #ff8a80;
    --warn: #ffd27a;
    --focus: #7fb6ff;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 var(--step-2) / 1.5 var(--sans);
  overflow-x: hidden;
}

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 var(--gutter); }

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

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--surface);
  color: var(--ink);
  padding: 0.5rem 1rem;
  z-index: 20;
}
.skip:focus { left: var(--gutter); }

a { color: var(--primary); }

/* header ------------------------------------------------------------------ */

.top { border-bottom: 1px solid var(--rule); }
.top-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding-top: 0.75rem;
  padding-bottom: 0.5rem;
}
.brand-row { display: flex; align-items: center; gap: 0.75rem; }
.brand {
  font-family: var(--serif);
  font-size: var(--step-3);
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
}
.session { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.who { color: var(--muted); font-size: var(--step-1); }
.conn { color: var(--muted); font-size: var(--step-1); }

.mode-badge {
  font-size: var(--step-1);
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-sm);
}
.mode-badge[data-mode="locked"] {
  border-color: var(--live);
  color: var(--live);
  font-weight: 600;
}

.nav {
  display: flex;
  gap: 0.25rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
  scrollbar-width: thin;
}
.nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.25rem 0.75rem;
  white-space: nowrap;
  color: var(--ink);
  text-decoration: none;
  border-radius: var(--r-sm);
}
.nav a:hover { background: var(--rule); }
.nav a[aria-current="page"] {
  box-shadow: inset 0 -3px 0 var(--primary);
  font-weight: 600;
}

main { padding: 1.5rem 0 5rem; outline: none; }

/* type -------------------------------------------------------------------- */

h1 {
  font-family: var(--serif);
  font-size: var(--step-5);
  line-height: 1.15;
  font-weight: 700;
  margin: 0 0 0.5rem;
  overflow-wrap: anywhere;
}
h2 {
  font-family: var(--serif);
  font-size: var(--step-3);
  font-weight: 700;
  margin: 0 0 0.75rem;
}
p { margin: 0 0 0.75rem; max-width: 66ch; }
.lede { color: var(--muted); }
.muted { color: var(--muted); }
.warn { color: var(--warn); font-weight: 600; }
.form-msg { color: var(--danger); font-weight: 600; margin: 0.5rem 0; }

/* sections ---------------------------------------------------------------- */

.panel {
  border-top: 1px solid var(--rule);
  padding: 1.25rem 0;
}
.notice {
  border-left: 3px solid var(--live);
  padding: 0.25rem 0 0.25rem 1rem;
  margin: 1rem 0;
}
.stack > * + * { margin-top: 0.75rem; }
.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}
.grow { flex: 1 1 14rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1rem 0; }

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

.btn {
  font: inherit;
  min-height: 44px;
  padding: 0.5rem 1rem;
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.btn:hover { border-color: var(--ink); }
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
  font-weight: 600;
}
.btn-danger { color: var(--danger); }
.btn-quiet { background: transparent; border-color: transparent; }
.btn-small { min-height: 36px; padding: 0.25rem 0.6rem; font-size: var(--step-1); }
.btn:disabled,
.btn:disabled:hover {
  color: var(--muted);
  border-color: var(--rule);
  background: transparent;
  cursor: not-allowed;
}

input, select {
  font: inherit;
  min-height: 44px;
  max-width: 100%;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
}
input:disabled, select:disabled { color: var(--muted); border-color: var(--rule); }
input[type="range"] {
  width: 100%;
  padding: 0;
  accent-color: var(--primary);
}
input[type="checkbox"] { width: 1.25rem; height: 1.25rem; min-height: 0; accent-color: var(--primary); }

.field { display: grid; gap: 0.25rem; margin: 0.5rem 0; }
.field > label { font-weight: 600; }
.check { display: flex; align-items: center; gap: 0.5rem; min-height: 44px; }

.range-row { display: flex; align-items: center; gap: 1rem; }
.range-row output {
  min-width: 3ch;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

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

.dash { display: grid; gap: 0; }
.hero { padding: 0.5rem 0 1.25rem; }
.title {
  font-family: var(--serif);
  font-size: clamp(2rem, 7.5vw, 3.4rem);
  line-height: 1.08;
  font-weight: 700;
  margin: 0.25rem 0 0.5rem;
  overflow-wrap: anywhere;
}
.artist {
  font-family: var(--serif);
  font-size: var(--step-3);
  color: var(--muted);
  margin: 0;
}
.state {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  color: var(--muted);
  font-size: var(--step-1);
  text-transform: none;
}
.state.playing { color: var(--live); font-weight: 600; }

.eq { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; width: 16px; }
.eq i {
  display: block;
  width: 3px;
  height: 100%;
  background: currentColor;
  transform-origin: bottom;
  animation: eq 1.1s ease-in-out infinite;
}
.eq i:nth-child(2) { animation-delay: -0.4s; }
.eq i:nth-child(3) { animation-delay: -0.8s; }
@keyframes eq {
  0%, 100% { transform: scaleY(0.3); }
  50% { transform: scaleY(1); }
}

.facts {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 0.3rem 1.25rem;
  margin: 1rem 0 0;
  max-width: 40rem;
}
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }

.transport {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1.5rem;
}
.hint { color: var(--muted); margin-top: 0.75rem; }

/* queue ------------------------------------------------------------------- */

.queue {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--rule);
}
.qrow {
  display: grid;
  grid-template-columns: 2.25rem minmax(0, 1fr);
  gap: 0.5rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--rule);
}
.qrow.is-current {
  box-shadow: inset 3px 0 0 var(--live);
  padding-left: 0.75rem;
}
.pos { font-variant-numeric: tabular-nums; color: var(--muted); }
.qtitle { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.qmeta { margin: 0; color: var(--muted); font-size: var(--step-1); overflow-wrap: anywhere; }
.tag { color: var(--live); font-size: var(--step-1); font-weight: 600; margin-left: 0.4rem; }
.row-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem; }
.empty { color: var(--muted); padding: 0.75rem 0; }

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

.list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  justify-content: space-between;
  align-items: flex-start;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--rule);
}
.row > div { min-width: 0; flex: 1 1 14rem; }
.rtitle { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.rmeta { margin: 0.15rem 0 0; color: var(--muted); font-size: var(--step-1); overflow-wrap: anywhere; }
.hash { word-break: break-all; }

.status {
  align-self: center;
  font-size: var(--step-1);
  font-weight: 600;
  white-space: nowrap;
}
.status[data-s="ok"] { color: var(--primary); }
.status[data-s="degraded"] { color: var(--warn); }
.status[data-s="down"] { color: var(--danger); }
.status[data-s="starting"] { color: var(--muted); }

details.pl { border-bottom: 1px solid var(--rule); }
details.pl > summary {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  min-height: 44px;
  align-items: center;
  padding: 0.6rem 0;
  cursor: pointer;
  font-weight: 600;
}
details.pl > .pl-body { padding: 0 0 1rem; }
.pl-tracks { margin: 0.5rem 0 1rem; padding-left: 1.25rem; }
.pl-tracks li { margin-bottom: 0.2rem; }

/* management, account ------------------------------------------------------ */

.card { border-top: 1px solid var(--rule); padding: 1rem 0 0.5rem; }
#main { padding-top: 1rem; padding-bottom: 3rem; }
.inline > input { flex: 1 1 16rem; min-width: 0; }
.card > h2:first-child { margin-top: 0; }
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 0 2rem; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); }
.inline { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: flex-start; }
.inline > .field { flex: 1 1 12rem; min-width: 0; }
.inline.spread { justify-content: space-between; align-items: center; }
.table { width: 100%; border-collapse: collapse; margin: 0.5rem 0; }
.table th, .table td { text-align: left; padding: 0.5rem 0.5rem 0.5rem 0; border-bottom: 1px solid var(--rule); vertical-align: middle; overflow-wrap: anywhere; }
.table th { font-size: var(--step-1); color: var(--muted); font-weight: 600; }
.table td.actions { white-space: nowrap; text-align: right; }
.table td.actions .btn { margin-left: 0.25rem; }
.table input, .table select { min-height: 36px; }
.badge { display: inline-block; font-size: var(--step-1); font-weight: 600; margin: 0; }
.state-running { color: var(--primary); }
.state-stopped { color: var(--muted); }
.state-failed { color: var(--danger); }
.codes {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-sm);
  padding: 0.75rem;
  overflow-x: auto;
  user-select: all;
}
.qr { background: #ffffff; padding: 0.5rem; border-radius: var(--r-sm); width: 200px; height: 200px; }
.or { text-align: center; color: var(--muted); margin: 0; }
.subnav { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 1rem; padding-top: 0.75rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--rule); }
.subnav a { padding: 0.35rem 0; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; }
.subnav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--primary); font-weight: 600; }
.subnav-title { font-family: var(--serif); font-weight: 700; font-size: var(--step-3); margin-right: 0.75rem; }
@media (max-width: 640px) { .subnav { flex-wrap: nowrap; overflow-x: auto; } .subnav-title { flex: 0 0 auto; } .subnav a { flex: 0 0 auto; } }
.picker { min-height: 36px; font-size: var(--step-1); }
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
h3 { font-family: var(--serif); font-size: var(--step-3); font-weight: 700; margin: 1.5rem 0 0.25rem; }
@media (max-width: 640px) {
  .table thead { display: none; }
  .table tr { display: block; border-bottom: 1px solid var(--rule); padding: 0.5rem 0; }
  .table td { display: block; border: 0; padding: 0.15rem 0; }
  .table td.actions { text-align: left; }
  .table td.actions .btn { margin: 0.25rem 0.25rem 0 0; }
}

/* login ------------------------------------------------------------------- */

.login { max-width: 26rem; }

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

.toasts {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 1rem;
  width: min(92vw, 28rem);
  display: grid;
  gap: 0.5rem;
  z-index: 10;
}
.toast {
  background: var(--ink);
  color: var(--bg);
  padding: 0.75rem 1rem;
  border-radius: var(--r);
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.25);
  overflow-wrap: anywhere;
}
.toast.error { background: #7a1a12; color: #ffffff; }

/* desktop --------------------------------------------------------------- */

@media (min-width: 760px) {
  .nav { flex-wrap: wrap; overflow: visible; }
  .dash {
    grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
    column-gap: 3rem;
    align-items: start;
  }
  .side { border-left: 1px solid var(--rule); padding-left: 2rem; }
  .side > .panel:first-child { border-top: 0; padding-top: 0.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  .eq i { animation: none; transform: scaleY(0.7); }
  * { transition: none !important; }
}

/* Soundboard: a grid with the number of columns the admin set. */
.soundgrid {
  display: grid;
  grid-template-columns: repeat(var(--columns, 4), minmax(0, 1fr));
  gap: 0.5rem;
}
.soundbtn {
  --sound: var(--primary);
  min-height: 4.5rem;
  border-color: var(--sound);
  border-left-width: 0.5rem;
  background: color-mix(in srgb, var(--sound) 14%, var(--surface));
  white-space: normal;
  overflow-wrap: anywhere;
  font-weight: 600;
}
.soundbtn:hover { border-color: var(--sound); background: color-mix(in srgb, var(--sound) 26%, var(--surface)); }
@media (max-width: 30rem) {
  .soundgrid { grid-template-columns: repeat(min(var(--columns, 4), 2), minmax(0, 1fr)); }
}
