/* hub.css — one view, no scroll.
 *
 * The page was four stacked narrative sections. This is a console: a fixed
 * frame, everything present at once, tabs where content is deeper than the
 * frame. The whole file is built on one constraint — the body never scrolls —
 * so every measurement below is either a fraction of the viewport or a value
 * that survives being squeezed by one.
 *
 * Ground is near-black with a violet cast, one accent. Not cream, not a
 * neutral: the palette was decided before the layout.
 */

:root {
  --bg: #08060f;
  --panel: #0e0b18;
  --panel-2: #141020;
  --line: rgba(157, 78, 221, 0.18);
  --line-soft: rgba(255, 255, 255, 0.07);
  --violet: #9d4edd;
  --violet-bright: #c084fc;
  --cyan: #22d3ee;
  --green: #6ee7a8;
  --fg: #efeaf8;
  --muted: #9d97ad;
  --dim: #6b6580;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --pad: clamp(12px, 1.6vw, 22px);
  --radius: 14px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  /* The load-bearing line. Everything else adapts to it. */
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Ambient wash. Two fixed radial glows rather than an animated gradient —
   a full-viewport animated mesh is the single most overexposed effect on the
   web right now, and this page does not need to look like every AI startup. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(70% 55% at 12% 8%, rgba(157, 78, 221, 0.16), transparent 62%),
    radial-gradient(55% 50% at 92% 96%, rgba(34, 211, 238, 0.09), transparent 65%);
  pointer-events: none;
  z-index: 0;
}

.hub {
  position: relative;
  z-index: 1;
  height: 100dvh;             /* dvh, not vh — vh is wrong on mobile Safari with the URL bar */
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: var(--pad);
  padding: var(--pad);
}

/* ── Title bar ─────────────────────────────────────────────────────── */
.hub-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.hub-id { display: flex; align-items: baseline; gap: 10px; min-width: 0; }

.hub-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--violet);
  box-shadow: 0 0 12px var(--violet);
  align-self: center;
  animation: pulse 2.6s ease-in-out infinite;
}

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.hub-name {
  font-size: clamp(19px, 2.1vw, 27px);
  font-weight: 900;
  letter-spacing: -0.02em;
}

.hub-sub {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--dim);
  white-space: nowrap;
}

.hub-state {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 15px;
  background: rgba(157, 78, 221, 0.07);
  white-space: nowrap;
}

.hub-state.is-awake { color: var(--green); border-color: rgba(110, 231, 168, 0.32); }

/* ── Body: stage + panel ───────────────────────────────────────────── */
.hub-body {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: var(--pad);
  min-height: 0;              /* lets the grid children actually shrink */
}

.hub-stage,
.hub-panel {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* ── Stage: video + face ───────────────────────────────────────────── */
.stage-video {
  position: relative;
  flex: 1;
  min-height: 0;
  /* MUST clip. The iframe is absolutely positioned and scaled 1.35 to push the
     YouTube chrome out of frame; without overflow:hidden HERE it paints over
     the face row below it, because .hub-stage clipping the outer box does not
     stop a child overflowing into a sibling. */
  overflow: hidden;
}

.stage-video iframe {
  position: absolute;
  /* Overscaled and centred so the YouTube chrome — the title bar and channel
     name it paints in the top-left — sits outside the visible frame. Cropping
     is the only way to hide it; the embed has no parameter that removes it. */
  top: 50%; left: 50%;
  width: 178vh; height: 100%;
  min-width: 100%;
  transform: translate(-50%, -50%) scale(1.35);
  border: 0;
  pointer-events: none;
}

.stage-veil {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to top, var(--panel) 2%, rgba(14, 11, 24, 0.55) 38%, rgba(14, 11, 24, 0.2) 100%),
    radial-gradient(circle at 50% 50%, rgba(14, 11, 24, 0.45) 0%, transparent 46%);
}

.stage-face {
  position: relative;
  z-index: 2;                 /* above the video, belt and braces with the clip */
  display: flex;
  align-items: center;
  gap: 14px;
  padding: var(--pad);
  border-top: 1px solid var(--line-soft);
  background: var(--panel);
}

.stage-face img {
  width: clamp(52px, 5.4vw, 74px);
  height: clamp(52px, 5.4vw, 74px);
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--violet);
  box-shadow: 0 0 22px rgba(157, 78, 221, 0.4);
  flex-shrink: 0;
}

.stage-meta { min-width: 0; }

.stage-mood {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--violet-bright);
}

.stage-line {
  margin-top: 5px;
  font-size: clamp(12px, 1.05vw, 14px);
  line-height: 1.45;
  color: var(--muted);
}

/* ── Panel: tabs ───────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 2px;
  padding: 6px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--panel-2);
  flex-shrink: 0;
}

.tab {
  flex: 1;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dim);
  background: none;
  border: 0;
  border-radius: 8px;
  padding: 10px 8px;
  cursor: pointer;
  transition: color 0.18s ease, background 0.18s ease;
}

.tab:hover { color: var(--fg); }
.tab.is-on { color: var(--fg); background: rgba(157, 78, 221, 0.16); }
.tab:focus-visible { outline: 2px solid var(--violet); outline-offset: -2px; }

.pane {
  display: none;
  padding: var(--pad);
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 12px;
}

.pane.is-on { display: flex; }

.pane-note {
  font-size: clamp(11.5px, 1vw, 13px);
  line-height: 1.5;
  color: var(--muted);
  flex-shrink: 0;
}

/* ── Systems ───────────────────────────────────────────────────────── */
.figs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  flex-shrink: 0;
}

.figs div {
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 10px 8px;
  text-align: center;
}

.figs b {
  display: block;
  font-family: var(--mono);
  font-size: clamp(15px, 1.7vw, 21px);
  color: var(--violet-bright);
}

.figs span {
  display: block;
  margin-top: 3px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--dim);
}

/* The one place a scrollbar is allowed, and only inside the card list — the
   PAGE never scrolls. Six cards fit most viewports; a short laptop gets a
   contained scroll rather than a cropped grid. */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  /* Rows share the height instead of hugging their content — six cards left a
     dead half-pane below them on a tall viewport, which reads as unfinished
     rather than airy. */
  grid-auto-rows: minmax(min-content, 1fr);
  gap: 8px;
  overflow-y: auto;
  min-height: 0;
  flex: 1;
  padding-right: 4px;
  align-content: stretch;
}

.flex-card {
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 11px 12px;
}

.flex-card h3 {
  font-size: 12.5px;
  font-weight: 700;
  margin-bottom: 3px;
}

.flex-card p {
  font-size: 11.5px;
  line-height: 1.42;
  color: var(--muted);
}

.flex-card-stat {
  float: right;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  color: var(--violet);
}

.flex-card-meta {
  margin-top: 7px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--dim);
}

.flex-card.is-live { border-color: rgba(110, 231, 168, 0.32); }
.flex-card.is-live .flex-card-meta,
.flex-card.is-recent .flex-card-meta { color: var(--green); }
.flex-card.is-dormant, .flex-card.is-unknown { opacity: 0.66; }

/* ── Games ─────────────────────────────────────────────────────────── */
.games {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
  grid-auto-rows: minmax(min-content, 1fr);
  gap: 8px;
  overflow-y: auto;
  min-height: 0;
  flex: 1;
  padding-right: 4px;
  align-content: stretch;
}

.game {
  display: block;
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 11px 12px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.18s ease, transform 0.18s ease;
}

.game:hover { border-color: var(--violet); transform: translateY(-2px); }
.game:focus-visible { outline: 2px solid var(--violet); outline-offset: 2px; }
.game b { display: block; font-size: 12.5px; }
.game span { display: block; margin-top: 3px; font-size: 11px; color: var(--muted); }

/* ── Talk ──────────────────────────────────────────────────────────── */
.pane-talk { padding: 0; }
.chat { display: flex; flex-direction: column; height: 100%; min-height: 0; }

.chat-log {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding: var(--pad);
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.chat-msg {
  max-width: 88%;
  padding: 9px 13px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.chat-msg-passion {
  align-self: flex-start;
  background: rgba(157, 78, 221, 0.14);
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}

.chat-msg-user {
  align-self: flex-end;
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  border-bottom-right-radius: 4px;
  color: var(--muted);
}

/* The model round-trip is ~1s. Silence in a chat box reads as broken. */
.chat-msg-passion.is-thinking {
  opacity: 0.55;
  letter-spacing: 0.3em;
  animation: thinking 1.1s ease-in-out infinite;
}

@keyframes thinking { 0%, 100% { opacity: 0.35; } 50% { opacity: 0.75; } }

.chat-form {
  display: flex;
  gap: 8px;
  padding: 12px var(--pad) var(--pad);
  border-top: 1px solid var(--line-soft);
  flex-shrink: 0;
}

.chat-form input {
  flex: 1;
  min-width: 0;
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  padding: 11px 14px;
  color: var(--fg);
  font-family: var(--sans);
  font-size: 13px;
}

.chat-form input::placeholder { color: var(--dim); }
.chat-form input:focus { outline: none; border-color: var(--violet); }

.chat-form button {
  background: var(--violet);
  border: 0;
  border-radius: 9px;
  width: 44px;
  color: #fff;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.18s ease;
}

.chat-form button:hover { background: var(--violet-bright); }
.chat-form button:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

/* ── Footer doors ──────────────────────────────────────────────────── */
.hub-links {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  flex-shrink: 0;
}

.door {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 13px 10px;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 11px;
  text-decoration: none;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  transition: color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.door:hover { color: var(--fg); border-color: var(--violet); transform: translateY(-2px); }
.door:focus-visible { outline: 2px solid var(--violet); outline-offset: 2px; }

.door svg { width: 17px; height: 17px; flex-shrink: 0; }
/* Line icons stroke; brand marks fill. Mixing the two is what makes an icon
   row look assembled from three different sets. */
.door svg:not(.brand) { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.door svg.brand { fill: currentColor; }

.door-primary {
  color: var(--fg);
  border-color: var(--violet);
  background: linear-gradient(135deg, rgba(157, 78, 221, 0.24), rgba(157, 78, 221, 0.08));
}

.door-primary:hover { background: linear-gradient(135deg, rgba(157, 78, 221, 0.36), rgba(157, 78, 221, 0.14)); }

/* ── Narrow ────────────────────────────────────────────────────────── */
@media (max-width: 880px) {
  .hub-body { grid-template-columns: 1fr; grid-template-rows: minmax(140px, 0.7fr) minmax(0, 1.3fr); }
  .hub-links { grid-template-columns: repeat(2, 1fr); }
  .door span { font-size: 10px; }
  .hub-sub { display: none; }
  .figs { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 560px) {
  /* Under ~560px a fixed frame stops being honest: the video, six cards, four
     doors and a chat cannot all be legible at once. The page is allowed to
     scroll here rather than shrink type below readable. A no-scroll rule that
     costs legibility is a worse rule than scrolling. */
  html, body { overflow: auto; }
  .hub { height: auto; min-height: 100dvh; }
  .hub-body { grid-template-rows: 200px auto; }
  .cards, .games { max-height: none; overflow: visible; }
  .pane-talk .chat-log { max-height: 46vh; }
}

@media (prefers-reduced-motion: reduce) {
  .hub-dot, .chat-msg-passion.is-thinking { animation: none; }
  .door:hover, .game:hover { transform: none; }
}

/* ── Stage controls ──────────────────────────────────────────────────
 * Sits over the video, above the veil. The iframe keeps pointer-events:none
 * so YouTube's own chrome never appears on hover; these are the only controls,
 * and they talk to the player over postMessage. */
.stage-controls {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 3;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.stage-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  /* Backdrop blur over a translucent fill so the label stays legible whatever
     frame the video is on — a flat tint fails on a bright cut. */
  background: rgba(8, 6, 15, 0.62);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.18s ease, border-color 0.18s ease;
}

.stage-btn:hover { color: var(--fg); border-color: var(--violet); }
.stage-btn:focus-visible { outline: 2px solid var(--violet); outline-offset: 2px; }

.stage-btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.stage-btn svg:not(.brand) { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.stage-btn svg.brand { fill: currentColor; }

/* One icon at a time, driven by aria-pressed — the button's own state, so the
   visual and the accessible state cannot disagree. */
#soundBtn .ic-loud { display: none; }
#soundBtn[aria-pressed="true"] { color: var(--violet-bright); border-color: var(--violet); }
#soundBtn[aria-pressed="true"] .ic-loud { display: block; }
#soundBtn[aria-pressed="true"] .ic-muted { display: none; }

.stage-yt:hover { color: #ff4444; border-color: rgba(255, 68, 68, 0.5); }

@media (max-width: 880px) {
  .stage-btn span { display: none; }   /* icons only when the stage is short */
  .stage-btn { padding: 8px; }
}
