/* The universe page (/universe): the whole viewport is the sky. client/universe.ts draws the
   universe on the canvas with the landing's engine; everything else is HUD over it: the title
   and the search at the top left, the legend at the bottom left, the view's tools at the
   bottom right, and one panel (the list of taus, a tau's card, or how to add yours) at the
   right on wide screens and rising from the bottom on narrow ones.

   On top of theme.css and site.css. Black, grey lines, and fire only on what is alive or
   what you act on. */

/* The page is the viewport: neither the document nor the body scrolls. */
.page-universe,
html:has(.page-universe),
html:has(.page-universe) body {
  overflow: hidden;
}

.page-universe .site-header {
  position: absolute;
  inset: 0 0 auto;
  z-index: 4;
  border-bottom-color: transparent;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.78), rgba(0, 0, 0, 0));
}

.universe {
  position: relative;
  height: 100vh;
  height: 100svh;
}

.u-sky {
  position: relative;
  isolation: isolate;
  height: 100%;
  overflow: hidden;
  background: #000;
}

.u-canvas {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
  outline: none;
}

.u-canvas:focus-visible {
  box-shadow: inset 0 0 0 1px var(--accent-line);
}

.u-canvas.is-pointing {
  cursor: pointer;
}

.u-canvas.is-dragging {
  cursor: grabbing;
}

/* Dark under the header and behind the bottom HUD, a vignette around the rest. */
.u-shade {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.55) 0, transparent 11rem),
    linear-gradient(0deg, rgba(0, 0, 0, 0.6) 0, transparent 8rem),
    radial-gradient(ellipse 90% 85% at 50% 50%, transparent 60%, rgba(0, 0, 0, 0.6) 100%);
}

.u-hud {
  position: absolute;
  z-index: 2;
}

/* ---- the title, the count and the search ------------------------------------------ */

/* `--top` is the header's height (client/universe.ts). */
.u-head {
  top: calc(var(--top, 4rem) + 1.2rem);
  left: var(--gutter);
  display: grid;
  gap: 0.55rem;
  width: min(24rem, calc(100% - 2 * var(--gutter)));
  pointer-events: none;
}

.u-head > * {
  pointer-events: auto;
}

.u-head .kicker {
  color: var(--muted);
}

.u-head h1 {
  font-size: clamp(1.7rem, 1.1rem + 1.6vw, 2.5rem);
  line-height: 1.02;
  letter-spacing: -0.01em;
}

.u-count {
  color: var(--muted);
}

.u-search {
  margin-top: 0.5rem;
}

.u-search input {
  width: 100%;
  min-height: 2.6rem;
  padding: 0.5rem 0.9rem 0.5rem 2.4rem;
  border: 1px solid var(--line-2);
  border-radius: 0;
  background-color: var(--glass);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M8.5 3l5 8.7H3.5z' fill='none' stroke='%238c8c92' stroke-width='1.4'/%3E%3Cpath d='M12.5 13.5l4 4' stroke='%238c8c92' stroke-width='1.4'/%3E%3C/svg%3E");
  background-position: 0.8rem 50%;
  background-repeat: no-repeat;
  background-size: 1rem;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  -webkit-appearance: none;
  appearance: none;
}

.u-search input::placeholder {
  color: var(--faint);
}

.u-search input:hover:not(:disabled) {
  border-color: var(--faint);
}

.u-search input:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.u-search input:disabled {
  opacity: 0.5;
}

.u-note {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

/* ---- the states: loading, failed, empty ------------------------------------------- */

.u-message {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 2;
  display: grid;
  justify-items: center;
  gap: 0.75rem;
  width: min(28rem, calc(100% - 2 * var(--gutter)));
  color: var(--muted);
  text-align: center;
  transform: translate(-50%, -50%);
}

/* The empty universe: "your tau" waits in the middle, the words go under it. */
.u-message:has(.u-command) {
  top: 68%;
}

.u-message > p:first-child {
  color: var(--text);
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
}

.u-command code {
  white-space: nowrap;
}

/* ---- the legend and the hint ------------------------------------------------------ */

.u-foot {
  bottom: 1.25rem;
  left: var(--gutter);
  display: grid;
  gap: 0.5rem;
  max-width: calc(100% - 2 * var(--gutter) - 30rem);
  pointer-events: none;
}

.u-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.2rem;
  color: var(--muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.u-legend .pip {
  animation: none;
}

.legend-link {
  width: 1.5rem;
  height: 1px;
  background: linear-gradient(90deg, var(--signal), var(--ember) 50%, var(--signal));
  box-shadow: 0 0 6px rgba(255, 122, 61, 0.5);
}

.legend-moon {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--flare);
  box-shadow: 0 0 6px var(--ember);
}

.u-hint {
  color: var(--faint);
}

.u-readout {
  position: absolute;
  top: calc(var(--top, 4rem) + 1.6rem);
  right: var(--gutter);
  z-index: 2;
  margin: 0;
  pointer-events: none;
}

body.is-panel-open .u-readout,
body.is-panel-open .u-hint {
  display: none;
}

/* With the panel open the tools move left of it; the legend wraps before them. */
body.is-panel-open .u-foot {
  max-width: calc(100% - 2 * var(--gutter) - var(--panel-w) - 24rem);
}

/* ---- the tools -------------------------------------------------------------------- */

.u-tools {
  right: var(--gutter);
  bottom: 1.1rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 0.4rem;
}

.u-tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-width: 2.5rem;
  min-height: 2.5rem;
  padding: 0.35rem 0.85rem;
  border: 1px solid var(--line-2);
  border-radius: 0;
  background-color: var(--glass);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
}

.u-tool:hover {
  border-color: var(--faint);
  color: var(--text);
}

.u-tool[aria-expanded="true"] {
  border-color: var(--accent-line);
  color: var(--text);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.u-tool-count {
  color: var(--text);
}

.u-tool-count:empty {
  display: none;
}

.u-icon {
  padding: 0;
}

.u-icon svg {
  width: 1rem;
  height: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: square;
}

/* ---- the panel -------------------------------------------------------------------- */

.page-universe {
  --panel-w: min(26rem, 40vw);
}

.u-panel {
  --cut: 14px;
  position: absolute;
  top: calc(var(--top, 4rem) + 0.6rem);
  right: var(--gutter);
  bottom: 1.1rem;
  z-index: 3;
  display: flex;
  flex-direction: column;
  width: var(--panel-w);
  background-color: var(--glass-2);
}

body.is-panel-open .u-tools {
  right: calc(var(--gutter) + var(--panel-w) + 0.75rem);
}

.u-panel-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 3rem;
  padding: 0.55rem 0.6rem 0 1.2rem;
}

.u-back {
  padding: 0.5rem 0;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
}

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

.u-close {
  width: 2.3rem;
  min-height: 2.3rem;
  margin-left: auto;
  border: 1px solid var(--line-2);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.u-close:hover {
  border-color: var(--faint);
  color: var(--text);
}

.u-panel-body {
  flex: 1;
  min-height: 0;
  padding: 0.3rem 1.2rem 1.4rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: var(--line-2) transparent;
  scrollbar-width: thin;
}

.u-panel h2 {
  font-size: 1.35rem;
}

.u-panel h2:focus {
  outline: none;
}

/* The list of taus: the keyboard path into the universe. */
.u-roster-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.9rem;
  margin-bottom: 1rem;
}

.u-roster-count {
  color: var(--muted);
}

.u-roster-empty {
  color: var(--muted);
}

.u-list {
  display: grid;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.u-row {
  --cut: 10px;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  align-items: center;
  gap: 0.35rem 0.85rem;
  padding: 0.7rem 0.85rem 0.75rem;
}

.u-row > svg {
  grid-row: 1;
}

.u-row-titles {
  display: grid;
  gap: 0.1rem;
  min-width: 0;
}

.u-row-name {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.u-row .pip-live {
  animation: none;
}

.u-row.is-offline .u-row-name {
  color: var(--muted);
}

.u-row .tau-card-address {
  font-size: 0.72rem;
}

.u-row-subs,
.u-row-meta {
  grid-column: 2;
}

.u-row-subs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.u-row-subs .sub-chip {
  font-size: 0.7rem;
}

.u-row-meta {
  color: var(--faint);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.03em;
}

.u-row[aria-current="true"] {
  --edge: var(--accent);
}

/* A tau's card, and one of its sub-taus'. */
.detail-head {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.detail-head svg {
  flex: none;
}

.detail-titles {
  display: grid;
  gap: 0.35rem;
  min-width: 0;
}

.detail-status {
  gap: 0.5rem;
  color: var(--faint);
  font-size: 0.64rem;
}

.detail-status.is-online {
  color: var(--accent-hot);
}

.detail-name {
  font-size: 1.55rem;
  overflow-wrap: anywhere;
}

.detail-parent {
  margin-top: 0.9rem;
  color: var(--muted);
}

.detail-address {
  margin-top: 0.6rem;
}

.detail-address code {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 0.78rem;
  white-space: normal;
  overflow-wrap: anywhere;
}

.detail-handle {
  display: inline-block;
  margin-top: 0.3rem;
  font-family: var(--font-mono);
  font-size: 0.84rem;
}

.detail-tag {
  display: inline-block;
  margin-top: 0.8rem;
  padding: 0 0.45rem;
  border: 1px solid var(--accent-line);
  color: var(--accent-hot);
  font-family: var(--font-mono);
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  line-height: 1.7;
  text-transform: uppercase;
}

.detail-about {
  margin-top: 0.9rem;
  color: var(--text);
}

.detail-facts {
  display: grid;
  gap: 0.4rem;
  margin: 1.1rem 0 0;
  padding-top: 0.9rem;
  border-top: 1px solid var(--line);
}

.detail-facts div {
  display: grid;
  grid-template-columns: minmax(5rem, 7.5rem) minmax(0, 1fr);
  gap: 0.75rem;
}

.detail-facts dt {
  color: var(--faint);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  line-height: 2.1;
  text-transform: uppercase;
}

.detail-facts dd {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  overflow-wrap: anywhere;
}

.detail-heading {
  margin: 1.5rem 0 0.6rem;
  color: var(--faint);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.detail-subs,
.detail-links {
  margin: 0;
  padding: 0;
  list-style: none;
}

.detail-subs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.detail-links li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--line);
}

.detail-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
  color: var(--text);
  text-decoration: none;
  overflow-wrap: anywhere;
}

.detail-links a:hover {
  color: var(--accent-hot);
}

.detail-links .pip-live {
  animation: none;
}

.detail-count {
  flex: none;
  color: var(--faint);
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

.detail-none {
  margin-top: 1.3rem;
  color: var(--muted);
}

.detail-page {
  margin-top: 1.5rem;
}

/* How to add your tau. */
.u-join {
  display: grid;
  gap: 1rem;
  color: var(--muted);
}

.u-join h2 {
  color: var(--text);
}

/* ---- narrow screens --------------------------------------------------------------- */

@media (max-width: 64rem) {
  .u-foot {
    max-width: calc(100% - 2 * var(--gutter) - 24rem);
  }

  .u-hint {
    display: none;
  }
}

/* The panel rises from the bottom; the tools make way for it. */
@media (max-width: 48rem) {
  .page-universe {
    --panel-w: auto;
  }

  .u-head {
    top: calc(var(--top, 4rem) + 0.5rem);
    gap: 0.4rem;
  }

  /* Phones pinch to zoom; the buttons would only crowd the row. */
  #zoom-in,
  #zoom-out {
    display: none;
  }

  .u-head .kicker {
    display: none;
  }

  .u-search {
    margin-top: 0.25rem;
  }

  .u-foot,
  .u-readout {
    display: none;
  }

  .u-tools {
    left: var(--gutter);
    justify-content: flex-end;
  }

  .u-panel {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: auto;
    max-height: 64svh;
  }

  body.is-panel-open .u-tools,
  body.is-panel-open .u-head {
    display: none;
  }
}
