/* The Panorama's own layout. Colours, type, shape and motion come from theme.css. */

/* Crowd colours, each dark enough to show as a dot on white. */
:root {
  --c-search: var(--blue);
  --c-ai-crawl: #5b8ff0;
  --c-ai-agent: #e8437f;
  --c-seo: #e0600f;
  --c-social: #2f8a22;
  --c-tool: #b8841f;
  --c-scanner: var(--red);
  --c-headless: var(--green);
  --c-human: #a67c5e;
  --c-unknown: #8a8a8a;
  --c-guestbook: #c9567a;
}

body { min-width: 320px; }

/* The header bar: wordmark and tag on the left, the connection on the right. */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-base) var(--space-xl);
  padding: var(--space-base) var(--space-xxl);
  border-bottom: var(--border-thin) solid var(--border);
}
.brand { display: flex; align-items: center; gap: var(--space-md); flex: none; }

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-family: var(--font-label);
  font-size: var(--size-small);
  color: var(--text-dim);
  text-align: right;
}
.status::before {
  content: '';
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-tertiary);
}
.status.live { color: var(--success); }
.status.live::before { background: var(--success); }
.status.down::before { background: var(--danger); }

/* The content column. */
.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-xl) var(--space-xxl) var(--space-huge);
}
.page > section { margin: 0 0 var(--space-xl); }

/* ----- The television ------------------------------------------------------ */
/* A card is the bezel, the screen sits in it, a panel of knobs to the right. */

.tv-set {
  display: grid;
  /* The screen grows to its cap; the panel takes what is left. */
  grid-template-columns: minmax(0, calc(54vh * 4 / 3)) minmax(176px, 1fr);
  gap: var(--space-xl);
  padding: var(--space-xl);
}
.tv-screen {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: var(--radius-sm);
  border: var(--border-thin) solid var(--ink);
  background: #101010;
}
.tv-screen video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
/* The glass: a dark inner edge drawn over the picture. */
.tv-screen::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.55), inset 0 0 28px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

/* The floor, drawn over the picture: arriving guests as dots on clear glass. */
.tv-floor {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  background: transparent;
  pointer-events: none;
}

/* The panel is the action panel: what is on, what it is, then the sound. */
.tv-panel {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-md);
  min-width: 0;
  padding-left: var(--space-xl);
  border-left: var(--border-thin) solid var(--border-light);
}
.tv-air {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-label);
  font-size: var(--size-label);
  color: var(--text-dim);
}
.tv-dot {
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--danger);
}
.tv.on-air .tv-air { color: var(--success); }
.tv.on-air .tv-dot { background: var(--success); }
/* An arrival on the floor: the dot goes out for an instant. */
.tv .tv-dot.blink { background: var(--text-tertiary); }
.tv-channel { margin-top: calc(-1 * var(--space-xs)); font-size: var(--size-body); color: var(--text); }

/* Start sound: the one prominent pill, the width of the panel. */
.tv-start {
  align-self: stretch;
  margin: var(--space-xs) 0;
  padding: var(--space-md) var(--space-xl);
  font-size: var(--size-medium);
}
/* Sound on: the pill turns Tirith green. */
button.on, button.on:hover { background: var(--green-fill); border-color: var(--green); color: var(--green); }

/* The quieter pills keep their text in line with the labels above. */
.tv-panel .pill { display: inline-flex; align-items: center; gap: var(--space-sm); }
.tv-panel .volume, .tv-toggles, .tv-play { margin-left: calc(-1 * var(--space-base)); }
.volume { align-self: stretch; }
.volume input { flex: 1; min-width: 0; max-width: 220px; margin: 0; }
.tv-toggles { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-xs); }
/* A ticked box or chosen radio makes its pill the chosen one. */
.pill:has(input:checked) { border-color: var(--border-active); background: var(--surface); color: var(--text); }
.pill input[type='checkbox'], .pill input[type='radio'] { margin: 0; }
.soundset { display: inline-flex; align-items: center; gap: var(--space-xs); }
.soundset.hidden { display: none; }
.note { color: var(--text-tertiary); }

/* The speaker grille takes whatever height is left, and none if none is. */
.tv-grille {
  flex: 1 1 0;
  align-self: stretch;
  min-height: 0;
  max-height: 160px;
  border-radius: var(--radius-sm);
  background: repeating-linear-gradient(to bottom, var(--border) 0 1px, transparent 1px 8px);
}

/* Pause picture: the second control, smaller, at the foot of the panel. */
.tv-play { margin-top: auto; padding: var(--space-xs) var(--space-base); font-size: var(--size-small); }
.tv-play.stopped { border-color: var(--border-active); color: var(--text); }

/* ----- Banners -------------------------------------------------------------------- */

.replay-banner, .drop-banner {
  margin: 0 0 var(--space-xl);
  padding: var(--space-md) var(--space-xl);
  border-radius: var(--radius-md);
  font-size: var(--size-body);
  font-variant-numeric: tabular-nums;
}
.replay-banner {
  border: var(--border-thin) solid var(--danger);
  background: #fff5f5;
  color: var(--danger);
}
.drop-banner {
  border: var(--border-thin) solid var(--border-light);
  color: var(--text-dim);
}
.drop-banner.on {
  background: var(--green-fill);
  border-color: var(--green-fill);
  color: var(--green);
  font-weight: var(--weight-header);
}

/* ----- Crowds: a ruled grid inside the card ------------------------------------ */

.crowd-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  /* Hide the outer rules so only the lines between cells show. */
  margin-bottom: -1px;
  overflow: hidden;
}
.crowd-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-xl);
  border-bottom: var(--border-thin) solid var(--border-light);
  box-shadow: 1px 0 0 var(--border-light);
  font-size: var(--size-label);
  transition: background-color var(--dur-base) var(--ease);
}
.crowd-item:hover { background: var(--surface-alt); }
.crowd-item label { display: flex; align-items: center; gap: var(--space-sm); flex: 1; min-width: 0; cursor: pointer; }
.crowd-item input { margin: 0; }
.crowd-item .count { font-variant-numeric: tabular-nums; font-weight: var(--weight-header); }
.crowd-item.muted .name, .crowd-item.muted .count { color: var(--text-tertiary); }
.crowd-item.muted .name { text-decoration: line-through; }
.crowd-item.muted .swatch { opacity: 0.3; }
.more { padding: var(--space-md) var(--space-xl); font-size: var(--size-small); color: var(--text-tertiary); }
.more:empty { display: none; }
.crowds { overflow: hidden; }

.swatch {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}

/* ----- Arrivals: a Tirith table --------------------------------------------------- */

.arrivals { overflow: hidden; }
.arrival-head, .arrival {
  display: grid;
  /* In px, not em: the header row's type is smaller than the rows'. */
  grid-template-columns: 72px 170px 130px 56px minmax(0, 1fr) 72px;
  gap: var(--space-base);
  padding: 14px var(--space-xl);
  align-items: baseline;
}
.arrival-head {
  padding-top: var(--space-md);
  padding-bottom: var(--space-md);
  border-bottom: var(--border-thin) solid var(--border);
  font-family: var(--font-label);
  font-size: var(--size-tiny);
  letter-spacing: var(--track-wide);
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.arrival-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: var(--size-label);
  font-variant-numeric: tabular-nums;
}
.arrival-list:empty::after {
  content: 'Nobody yet. Arrivals appear here as they walk in.';
  display: block;
  padding: var(--space-huge) var(--space-xl);
  text-align: center;
  color: var(--text-tertiary);
}
.arrival {
  border-bottom: var(--border-thin) solid var(--border-light);
  transition: background-color var(--dur-base) var(--ease);
  animation: enter 600ms var(--ease);
}
.arrival:last-child { border-bottom: 0; }
.arrival:hover { background: var(--surface-alt); }
.arrival > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.arrival .time, .arrival .guest, .arrival .method, .arrival .family { color: var(--text-dim); }
.arrival .crowd::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 7px;
  vertical-align: 1px;
  background: var(--crowd, var(--c-unknown));
}
.arrival.replayed { color: var(--text-dim); font-style: italic; }
.arrival.silent { opacity: 0.45; }
.arrival.in-drop { box-shadow: inset 3px 0 0 var(--green); background: #f3faf4; }
.arrival.summary { grid-template-columns: 72px 1fr; color: var(--text-tertiary); }

.foot {
  margin-top: var(--space-huge);
  padding-top: var(--space-base);
  border-top: var(--border-thin) solid var(--border);
  font-size: var(--size-small);
  color: var(--text-tertiary);
}

@media (max-width: 640px) {
  .top { flex-wrap: wrap; padding: var(--space-md) var(--space-base); }
  .top h1 { font-size: 28px; }
  .status { flex-basis: 100%; text-align: left; }
  .page { padding: var(--space-base) var(--space-base) var(--space-xxl); }
  .page > section { margin-bottom: var(--space-base); }

  .tv-set { grid-template-columns: 1fr; gap: var(--space-base); padding: var(--space-md); }
  /* Under the screen: on air with Pause picture beside it, then Start, the
     caption, the volume and the toggles. */
  .tv-panel {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }
  /* The card's padding is narrower here, so the pills sit flush instead of
     hanging past its edge. */
  .tv-panel .volume, .tv-toggles, .tv-play { margin-left: 0; }
  .tv-panel {
    gap: var(--space-sm) var(--space-base);
    padding-left: 0;
    border-left: 0;
  }
  .tv-air { order: 1; }
  .tv-play { order: 2; margin: 0 calc(-1 * var(--space-sm)) 0 auto; }
  .tv-start { order: 3; flex-basis: 100%; margin: var(--space-xs) 0; }
  .tv-channel { order: 4; flex-basis: 100%; margin: 0; }
  .volume { order: 5; flex-basis: 100%; }
  .volume input { max-width: none; }
  .tv-toggles { order: 6; flex-basis: 100%; }
  .note { order: 7; flex-basis: 100%; }
  .tv-grille { display: none; }

  .section-head { padding: var(--space-md) var(--space-base); }
  .crowd-item { padding: var(--space-md) var(--space-base); }

  .arrival-head { display: none; }
  .arrival {
    grid-template-columns: 72px 1fr 72px;
    gap: 2px var(--space-sm);
    padding: var(--space-md) var(--space-base);
  }
  .arrival .family, .arrival .method { display: none; }
  .arrival .guest { grid-column: 3; grid-row: 1; text-align: right; }
  .arrival .path { grid-column: 1 / -1; grid-row: 2; }
}

/* Crowd colours, applied through classes only. */
.crowd-search { --crowd: var(--c-search); }
.crowd-ai-crawl { --crowd: var(--c-ai-crawl); }
.crowd-ai-agent { --crowd: var(--c-ai-agent); }
.crowd-seo { --crowd: var(--c-seo); }
.crowd-social { --crowd: var(--c-social); }
.crowd-tool { --crowd: var(--c-tool); }
.crowd-scanner { --crowd: var(--c-scanner); }
.crowd-headless { --crowd: var(--c-headless); }
.crowd-human { --crowd: var(--c-human); }
.crowd-unknown { --crowd: var(--c-unknown); }
.crowd-guestbook { --crowd: var(--c-guestbook); }
.swatch { background: var(--crowd, var(--c-unknown)); }
