/* ==========================================================================
   xCloud Web — visual identity
   Grounded in the Xbox dashboard's own language: signature green used as a
   single saturated accent (not a wash), a blocky geometric display face,
   and a recurring angular "power glyph" motif that stands in for the
   product's actual job — turning something on and connecting to it.
   ========================================================================== */

:root {
  --bg: #0a0e0c;
  --bg-raised: #121712;
  --panel: #151b16;
  --border: #232b24;
  --border-hover: #2f3d30;
  --text: #f2f4f2;
  --muted: #7c877d;
  --muted-dim: #565f57;
  --accent: #107c10;
  --accent-bright: #4cc74c;
  --signal: #ffb020;
  --error: #e5484d;

  --font-display: "Segoe UI", "Archivo", "Arial Narrow", sans-serif;
  --font-body: -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
  --font-mono: "SF Mono", "Cascadia Code", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
}

body {
  background-image:
    radial-gradient(circle at 15% 20%, rgba(16, 124, 16, 0.07), transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(16, 124, 16, 0.05), transparent 40%);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

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

.screen { height: 100%; }

/* --------------------------------------------------------------------
   Signature element: the power glyph. A ring broken by a vertical
   stroke — the universal "power" symbol, redrawn angular/geometric to
   match the rest of the identity. Idle: static outline. Working:
   segments pulse in sequence, like a console boot animation.
   -------------------------------------------------------------------- */

.power-glyph {
  width: 84px;
  height: 84px;
  display: block;
}

.power-glyph .ring {
  fill: none;
  stroke: var(--accent);
  stroke-width: 6;
  stroke-linecap: square;
}

.power-glyph .stem {
  stroke: var(--accent);
  stroke-width: 6;
  stroke-linecap: square;
}

.power-glyph.active .ring {
  stroke: var(--accent-bright);
  animation: glyph-pulse 1.6s ease-in-out infinite;
}
.power-glyph.active .stem {
  stroke: var(--accent-bright);
  animation: glyph-pulse 1.6s ease-in-out infinite 0.15s;
}

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

/* --------------------------------------------------------------------
   Sign-in / status — asymmetric split, console-tile texture on the
   idle side rather than a centered generic card.
   -------------------------------------------------------------------- */

#screen-signin, #screen-status {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  min-height: 100%;
}

@media (max-width: 760px) {
  #screen-signin, #screen-status {
    grid-template-columns: 1fr;
  }
  .brand-pane { display: none; }
}

.brand-pane {
  background: var(--bg-raised);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  padding: 0 10%;
  position: relative;
  overflow: hidden;
}

.brand-pane::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    115deg,
    transparent 0 68px,
    rgba(16, 124, 16, 0.05) 68px 69px
  );
  pointer-events: none;
}

.brand-pane .power-glyph { margin-bottom: 28px; }

.brand-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-bright);
  margin: 0 0 10px;
}

.brand-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-stretch: condensed;
  font-size: 2.6rem;
  letter-spacing: -0.01em;
  line-height: 1.02;
  margin: 0;
  z-index: 1;
}

.brand-sub {
  color: var(--muted);
  font-size: 0.95rem;
  max-width: 34ch;
  margin: 14px 0 0;
  z-index: 1;
}

.action-pane {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.card {
  width: 100%;
  max-width: 380px;
  text-align: left;
}

.card h1 { display: none; } /* title now lives in .brand-pane */

.card-kicker {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted-dim);
  margin: 0 0 6px;
}

.card-heading {
  font-size: 1.3rem;
  font-weight: 700;
  margin: 0 0 20px;
}

.btn-primary {
  width: 100%;
  padding: 13px 18px;
  border: none;
  border-radius: 4px;
  background: var(--accent);
  color: #eafff0;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}
.btn-primary:hover { background: var(--accent-bright); color: #06130a; }
.btn-primary:active { transform: scale(0.98); }

.btn-link {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0;
}
.btn-link:hover { color: var(--text); }

.error {
  color: var(--error);
  margin-top: 16px;
  font-size: 0.9rem;
  padding-left: 10px;
  border-left: 2px solid var(--error);
}

#device-code-box {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.link-big {
  display: inline-block;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent-bright);
  text-decoration: none;
  margin: 4px 0;
  font-family: var(--font-mono);
}
.link-big:hover { text-decoration: underline; }

.code {
  font-family: var(--font-mono);
  font-size: 2rem;
  letter-spacing: 0.35rem;
  font-weight: 700;
  margin: 12px 0;
  color: var(--text);
  background: #00000059;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  padding: 12px 0 12px 0.35rem;
}

#screen-status .action-pane { flex-direction: column; }
#screen-status .power-glyph { margin: 0 auto 24px; }
#screen-status .card { text-align: center; }
#screen-status .code { display: none; }

/* --------------------------------------------------------------------
   Library — the dashboard proper.
   -------------------------------------------------------------------- */

#screen-library { display: flex; flex-direction: column; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-raised);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-family: var(--font-display);
  font-stretch: condensed;
  letter-spacing: -0.01em;
}

.topbar-brand .power-glyph { width: 26px; height: 26px; }

.library-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--border);
  overflow-y: auto;
}

.panel {
  background: var(--bg);
  padding: 28px;
}

.panel-consoles { flex: 0 0 auto; }
.panel-catalog { flex: 1; }

.panel h2 {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted-dim);
  margin: 0 0 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.panel-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
  margin-bottom: 16px;
}
.panel-heading-row h2 { border-bottom: none; padding-bottom: 0; margin: 0; }

.catalog-search input {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 7px 12px;
  color: var(--text);
  font-size: 0.85rem;
  width: 200px;
  max-width: 100%;
  font-family: var(--font-body);
}
.catalog-search input:focus {
  outline: none;
  border-color: var(--accent);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
}

.grid-consoles {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.grid-catalog {
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 20px 16px;
  margin-bottom: 20px;
}

.console-tile {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 18px;
  cursor: pointer;
  text-align: left;
  position: relative;
  transition: border-color 0.15s ease, transform 0.1s ease;
}
.console-tile:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}
.console-tile:hover::after { opacity: 1; }
.console-tile::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 6px;
  box-shadow: 0 0 0 1px var(--accent) inset, 0 8px 24px -12px rgba(16, 124, 16, 0.5);
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}
.console-tile h3 {
  margin: 0 0 6px;
  font-size: 0.95rem;
  font-weight: 700;
}
.console-tile .status-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.console-tile .status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted-dim);
  flex-shrink: 0;
}
.console-tile:not(.offline) .status-dot {
  background: var(--accent-bright);
  box-shadow: 0 0 6px var(--accent-bright);
}
.console-tile.offline {
  opacity: 0.55;
  cursor: not-allowed;
}
.console-tile.offline:hover {
  transform: none;
  border-color: var(--border);
}
.console-tile.offline:hover::after { opacity: 0; }

/* Game Pass catalog cards — box art is the whole point, so the card is
   mostly image with a thin caption, not a text-forward tile like the
   console cards. */
.game-card {
  cursor: pointer;
  border-radius: 6px;
  outline-offset: 3px;
}

.game-art {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: 6px;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--border);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.game-card:hover .game-art,
.game-card:focus-visible .game-art {
  border-color: var(--accent);
  transform: translateY(-3px);
}

.game-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.game-art-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
}
.game-art-fallback::before {
  content: "";
  width: 32px;
  height: 32px;
  border: 4px solid var(--muted-dim);
  border-radius: 50%;
  border-top-color: transparent;
  transform: rotate(45deg);
}
.game-art-fallback img { display: none; }

.game-play-badge {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: #fff;
  background: rgba(6, 10, 7, 0.45);
  opacity: 0;
  transition: opacity 0.15s ease;
}
.game-card:hover .game-play-badge,
.game-card:focus-visible .game-play-badge {
  opacity: 1;
}

.game-title {
  margin: 8px 2px 0;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.manual-launch {
  margin-top: 8px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}
.manual-launch summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.85rem;
  user-select: none;
}
.manual-launch summary:hover { color: var(--text); }
.manual-launch .cloud-launch { margin-top: 12px; }

.cloud-launch { display: flex; gap: 8px; }
.cloud-launch input {
  flex: 1;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 11px 12px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.9rem;
}
.cloud-launch input:focus {
  outline: none;
  border-color: var(--accent);
}
.cloud-launch .btn-primary { width: auto; padding: 11px 20px; }

/* --------------------------------------------------------------------
   Stream screen
   -------------------------------------------------------------------- */

#screen-stream { position: relative; background: #000; }

#streamHolder, #streamHolder video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.75), transparent);
}

.hud .btn-link { font-weight: 600; }

#connection-status {
  font-family: var(--font-mono);
}

#input-indicator {
  font-family: var(--font-mono);
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 3px;
}
