/* The cat (js/cat/). Everything here is prefixed so nothing of the app is touched. */

/* A popover layer sits in the top layer, above everything including modal dialogs. The browser's own
   popover styles (centered, boxed, scrolling) are all undone: it is a transparent full-window layer
   that lets every click through except on the cat and its bubble. */
#cat-layer {
  position: fixed;
  inset: 0;
  width: auto;
  height: auto;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  overflow: visible;
  pointer-events: none;
}

#cat-layer.cat-fixed {
  z-index: 2147483647;
}

.cat-box {
  position: absolute;
  left: 0;
  top: 0;
  width: 112px;
  height: 112px;
  pointer-events: none;
  will-change: transform;
}

.cat-sprite {
  display: block;
  width: 112px;
  height: 112px;
  pointer-events: none;
}

/* The part of the cat that takes clicks and drags: an ellipse around the body (the feet are at 56, 86). */
.cat-hit {
  position: absolute;
  left: 24px;
  top: 38px;
  width: 64px;
  height: 52px;
  border-radius: 50%;
  pointer-events: auto;
  touch-action: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.cat-hit.dragging {
  cursor: grabbing;
}

.cat-bubble {
  position: absolute;
  left: 0;
  top: 0;
  max-width: min(240px, calc(100vw - 16px));
  margin: 0;
  padding: 9px 13px;
  border: 1.5px solid #3ee8ff;
  border-radius: 14px;
  background: #10142b;
  color: #e8fbff;
  font: 600 13px/1.35 var(--font, system-ui, sans-serif);
  text-align: left;
  cursor: pointer;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity .2s, visibility .2s;
  box-shadow: 0 0 14px rgba(62, 232, 255, .35), 0 6px 18px rgba(0, 0, 0, .35);
}

.cat-bubble.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.cat-bubble:hover,
.cat-bubble:focus-visible {
  box-shadow: 0 0 20px rgba(62, 232, 255, .6), 0 6px 18px rgba(0, 0, 0, .35);
  outline: 2px solid #c07bff;
  outline-offset: 2px;
}

.cat-bubble::after {
  content: "";
  position: absolute;
  left: var(--tail, 50%);
  bottom: -7px;
  width: 11px;
  height: 11px;
  border: 1.5px solid #3ee8ff;
  border-top: 0;
  border-left: 0;
  background: #10142b;
  transform: translateX(-50%) rotate(45deg);
}

.cat-bubble.below::after {
  top: -7px;
  bottom: auto;
  border: 1.5px solid #3ee8ff;
  border-right: 0;
  border-bottom: 0;
}

/* The security readme. */
#cat-readme {
  width: min(560px, calc(100vw - 24px));
  max-height: min(82dvh, 680px);
  margin: auto;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--shadow);
  overflow: hidden;
  font: 15px/1.55 var(--font);
}

#cat-readme[open] {
  display: flex;
  flex-direction: column;
}

#cat-readme::backdrop {
  background: rgba(5, 6, 10, .6);
  backdrop-filter: blur(4px);
}

.cat-readme-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 8px 22px;
}

#cat-readme h2 {
  margin: 0;
  font-size: 19px;
}

.cat-readme-x {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}

.cat-readme-x:hover {
  color: var(--text);
  background: var(--surface-strong);
}

.cat-readme-body {
  overflow: auto;
  padding: 4px 22px 6px;
}

.cat-readme-body p {
  margin: 0 0 13px;
}

.cat-readme-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 22px 18px;
}

.cat-readme-secret {
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  letter-spacing: .12em;
  cursor: pointer;
}

.cat-readme-secret:hover {
  color: var(--text);
  background: var(--surface-strong);
}

.cat-readme-secret:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.cat-readme-ok {
  margin-left: auto;
  padding: 10px 24px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.cat-readme-ok:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.cat-readme-ok:focus-visible,
.cat-readme-x:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* The channel card, laid out like the password dialog: a title, a muted explanation, fields, buttons. */
#cat-channel {
  width: min(420px, calc(100vw - 32px));
  max-height: 92dvh;
  margin: auto;
  padding: 22px 24px 20px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--shadow);
  overflow: auto;
  font: 15px/1.5 var(--font);
}

#cat-channel::backdrop {
  background: rgba(5, 6, 10, .6);
  backdrop-filter: blur(4px);
}

.cat-channel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: 0 -8px 8px 0;
}

#cat-channel h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: .14em;
}

.cat-channel-name {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.cat-channel-text {
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--muted);
}

.cat-channel-switch {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0 14px;
  cursor: pointer;
  user-select: none;
}

.cat-channel-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.cat-channel-track {
  position: relative;
  flex: none;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  transition: background .2s;
}

.cat-channel-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform .2s, background .2s;
}

.cat-channel-switch input:checked + .cat-channel-track {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.cat-channel-switch input:checked + .cat-channel-track::after {
  transform: translateX(18px);
  background: #fff;
}

.cat-channel-switch input:focus-visible + .cat-channel-track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.cat-channel-label {
  display: block;
  margin: 0 0 3px;
  font-size: 13px;
  color: var(--text);
}

/* The characters used of a dispatch, at the right end of its label. */
.cat-channel-count {
  float: right;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* What a field is for, between its label and the field. */
.cat-channel-hint {
  margin: 0 0 7px;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--muted);
}

.cat-channel-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.cat-channel-input {
  flex: 1;
  min-width: 0;
  box-sizing: border-box;
  padding: 10px 14px;
  font: inherit;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.cat-channel-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.cat-channel-btn {
  flex: none;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-strong);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.cat-channel-go {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  border: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-weight: 600;
}

/* While a broadcast waits for its request the button is a progress bar: a dark layer over the
   gradient that clears from left to right (the script runs its width). */
.cat-channel-bar {
  position: absolute;
  inset: 0;
  z-index: -1;
  background: rgba(0, 0, 0, 0.5);
  transform: scaleX(0);
  transform-origin: right;
  pointer-events: none;
}

.cat-channel-go.sending:disabled {
  opacity: 1;
  cursor: progress;
}

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

.cat-channel-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.cat-channel-note {
  min-height: 1.3em;
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

/* The energy orb thrown at the top hat button (the script moves it; the first one is the orb, the
   others its tail). Its centre is the point it is moved to. */
.cat-orb {
  position: absolute;
  left: 0;
  top: 0;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0 28%, #3ee8ff 55%, rgba(62, 232, 255, 0) 72%);
  box-shadow: 0 0 10px 3px rgba(62, 232, 255, 0.7), 0 0 20px 7px rgba(192, 123, 255, 0.4);
  pointer-events: none;
}

.cat-orb[data-tail] {
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  box-shadow: 0 0 8px 2px rgba(62, 232, 255, 0.45);
}

.cat-orb[data-tail='2'] {
  width: 7px;
  height: 7px;
  margin: -3.5px 0 0 -3.5px;
  box-shadow: 0 0 6px 1px rgba(192, 123, 255, 0.4);
}
