/* ============================================================
   Distributed Donut — "Render Console"
   A dark technical viewport with an amber-phosphor live feed.
   ============================================================ */

:root {
  color-scheme: dark;

  --bg: #0a0b0d;
  --bg-panel: #111317;
  --bg-cell: #0e1013;

  --ink: #ECE7DA;
  --ink-dim: #8C887C;
  --ink-faint: #57544c;

  --line: rgba(236, 231, 218, 0.10);
  --line-soft: rgba(236, 231, 218, 0.06);

  --accent: #FFB454;
  --accent-2: #6FE0A6;
  --accent-glow: rgba(255, 180, 84, 0.45);
  --warn: #f59e3c;

  /* page-level atmosphere glows */
  --glow-1: rgba(255, 180, 84, 0.10);
  --glow-2: rgba(111, 224, 166, 0.05);

  /* the render viewport is always a dark screen, in any theme */
  --phosphor: #FFB454;

  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;

  --maxw: 940px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-mono);
  color: var(--ink);
  background-color: var(--bg);
  /* layered atmosphere: a warm glow up top, a faint grid, base color */
  background-image:
    radial-gradient(120% 80% at 50% -10%, var(--glow-1), transparent 55%),
    radial-gradient(100% 60% at 50% 120%, var(--glow-2), transparent 60%),
    linear-gradient(var(--line-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-soft) 1px, transparent 1px);
  background-size: auto, auto, 46px 46px, 46px 46px;
  background-attachment: fixed;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(1.25rem, 3vw, 2.25rem);
  line-height: 1.5;
}

/* film grain overlay for texture */
.grain {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.5;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.45'/%3E%3C/svg%3E");
}

a {
  color: inherit;
  text-decoration: none;
}

/* ---------------------------------------------------------- top bar */
.topbar {
  width: 100%;
  max-width: var(--maxw);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: clamp(2.5rem, 7vw, 4.5rem);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 500;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
}

.brand-glyph {
  color: var(--accent);
  font-size: 1.15rem;
  text-shadow: 0 0 10px var(--accent-glow);
  animation: spin 9s linear infinite;
}

.brand-name {
  color: var(--ink);
}

.topnav {
  display: flex;
  align-items: center;
  gap: clamp(0.9rem, 3vw, 1.6rem);
  font-size: 0.8rem;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--ink-dim);
  letter-spacing: 0.04em;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-faint);
  box-shadow: 0 0 0 0 transparent;
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

.status.online .dot {
  background: var(--accent-2);
  box-shadow: 0 0 8px color-mix(in srgb, var(--accent-2) 75%, transparent);
  animation: pulse 2.4s ease-in-out infinite;
}

.status.offline .dot {
  background: var(--warn);
  box-shadow: 0 0 8px color-mix(in srgb, var(--warn) 70%, transparent);
}

.ghlink {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--ink-dim);
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg-panel) 55%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.ghlink:hover {
  color: var(--ink);
  border-color: color-mix(in srgb, var(--accent) 50%, transparent);
  background: color-mix(in srgb, var(--accent) 12%, var(--bg-panel));
}

/* ---------------------------------------------------------- main */
main {
  width: 100%;
  max-width: var(--maxw);
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ---------------------------------------------------------- hero */
.hero {
  text-align: center;
  margin-bottom: clamp(2rem, 5vw, 3rem);
}

.wordmark {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.6rem, 9vw, 5.2rem);
  line-height: 0.95;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.wordmark .key {
  color: var(--accent);
  text-shadow: 0 0 28px var(--accent-glow);
}

.tagline {
  max-width: 46ch;
  margin: 1.2rem auto 0;
  font-size: clamp(0.85rem, 1.6vw, 0.98rem);
  line-height: 1.65;
  color: var(--ink-dim);
}

/* ---------------------------------------------------------- console */
.console {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-panel);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.03) inset,
    0 40px 80px -40px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}

.console-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
}

.console-title {
  color: var(--ink-dim);
}

.console-feed {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--accent);
  text-transform: uppercase;
}

.dot-live {
  background: var(--accent);
  box-shadow: 0 0 8px color-mix(in srgb, var(--accent) 85%, transparent);
  animation: pulse 1.8s ease-in-out infinite;
}

.viewport {
  position: relative;
  min-height: clamp(300px, 44vw, 420px);
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(80% 80% at 50% 50%, #0b0d10, #07080a);
  overflow: hidden;
}

.bloom {
  position: absolute;
  width: 60%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 180, 84, 0.16), transparent 65%);
  filter: blur(20px);
  pointer-events: none;
}

#donut {
  position: relative;
  z-index: 2;
  margin: 0;
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: clamp(6px, 1.9vw, 15px);
  line-height: 1.15;
  white-space: pre;
  color: var(--phosphor);
  text-shadow:
    0 0 7px rgba(255, 180, 84, 0.55),
    0 0 16px rgba(255, 150, 40, 0.28);
  animation: flicker 5.5s infinite steps(60);
}

.scanlines {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.22) 3px
  );
  background-size: 100% 3px;
  animation: drift 8s linear infinite;
}

.vignette {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  box-shadow: inset 0 0 120px 20px rgba(0, 0, 0, 0.75);
}

/* ---------------------------------------------------------- telemetry */
.telemetry {
  width: 100%;
  margin-top: 1rem;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-cell);
}

.cell {
  position: relative;
  padding: 1.05rem 1.2rem;
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* 3-column borders: first cell of each row has no left border, rows after the
   first get a top one. Scoped to desktop so these don't out-specify the 2-column
   rules below (media queries don't add specificity). */
@media (min-width: 721px) {
  .cell:nth-child(3n + 1) {
    border-left: none;
  }

  .cell:nth-child(n + 4) {
    border-top: 1px solid var(--line);
  }
}

.cell-label {
  display: flex;
  align-items: center;
  gap: 0.45em;
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* the "?" affordance next to each metric, plus its hover/tap tooltip */
.info {
  flex: none;
  width: 14px;
  height: 14px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--ink-faint);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: help;
  transition: color 0.15s, border-color 0.15s;
}

.info-icon {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.info:hover,
.info:focus-visible {
  color: var(--ink);
  border-color: var(--ink-dim);
  outline: none;
}

.tip {
  position: absolute;
  left: 1.2rem;
  right: 1.2rem;
  top: 2.6rem;
  z-index: 20;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-panel);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  color: var(--ink-dim);
  font-size: 0.72rem;
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: 0;
  text-transform: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
  pointer-events: none;
}

.cell:has(.info:hover) .tip,
.cell:focus-within .tip {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.cell-value {
  font-size: clamp(1.3rem, 3.4vw, 1.7rem);
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: baseline;
  gap: 0.18em;
}

.cell-value .unit,
.cell-value .hash {
  font-size: 0.62em;
  font-weight: 500;
  color: var(--ink-faint);
}

#t-buffer,
#t-fps {
  color: var(--accent);
}

#t-task,
#t-clients {
  color: var(--accent-2);
}

/* server-buffer gauge: a thin fill bar pinned to the base of its cell */
.gauge {
  margin-top: auto;
  height: 4px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}

.gauge-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--accent-2);
  box-shadow: 0 0 6px var(--accent-glow);
  transition: width 0.4s ease;
}

/* buffer cell carries a live sparkline anchored to its base */
.cell-buffer {
  position: relative;
}

.cell-buffer > .cell-label,
.cell-buffer > .cell-value {
  position: relative;
  z-index: 1;
}

.spark {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 38px;
  pointer-events: none;
  filter: drop-shadow(0 0 3px var(--accent-glow));
}

.spark-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.spark-area {
  fill: var(--accent);
  opacity: 0.12;
  stroke: none;
}

/* ---------------------------------------------------------- flow */
.flow {
  width: 100%;
  margin-top: clamp(2.5rem, 6vw, 4rem);
  display: flex;
  align-items: stretch;
  gap: 1rem;
}

.step {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.step-n {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--accent);
}

.step p {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--ink-dim);
}

.step b {
  color: var(--ink);
  font-weight: 700;
}

.step-arrow {
  align-self: center;
  color: var(--ink-faint);
  font-size: 1.1rem;
}

/* ---------------------------------------------------------- footer */
footer {
  width: 100%;
  max-width: var(--maxw);
  margin-top: clamp(3rem, 8vw, 5rem);
  padding-top: 1.2rem;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  font-size: 0.76rem;
  color: var(--ink-faint);
}

footer a {
  color: var(--ink-dim);
  border-bottom: 1px solid transparent;
  transition: color 0.2s ease, border-color 0.2s ease;
}

footer a:hover {
  color: var(--accent);
  border-bottom-color: color-mix(in srgb, var(--accent) 50%, transparent);
}

footer .sep {
  color: var(--line);
}

/* ---------------------------------------------------------- entrance */
.hero,
.console,
.telemetry,
.flow {
  animation: rise 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.hero {
  animation-delay: 0.05s;
}

.console {
  animation-delay: 0.18s;
}

.telemetry {
  animation-delay: 0.3s;
}

.flow {
  animation-delay: 0.42s;
}

/* ---------------------------------------------------------- keyframes */
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(18px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

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

  50% {
    opacity: 0.35;
  }
}

@keyframes drift {
  to {
    background-position: 0 -120px;
  }
}

@keyframes flicker {
  0%, 100% { opacity: 1; }
  2% { opacity: 0.86; }
  4% { opacity: 1; }
  38% { opacity: 1; }
  40% { opacity: 0.92; }
  42% { opacity: 1; }
}

/* ---------------------------------------------------------- responsive */
@media (max-width: 720px) {
  .telemetry {
    grid-template-columns: repeat(2, 1fr);
  }

  /* reset the desktop 3-col border rules, then re-derive for 2 columns */
  .cell {
    border-left: 1px solid var(--line);
    border-top: none;
  }

  .cell:nth-child(n + 3) {
    border-top: 1px solid var(--line);
  }

  .cell:nth-child(odd) {
    border-left: none;
  }

  .flow {
    flex-direction: column;
    gap: 1.4rem;
  }

  .step-arrow {
    transform: rotate(90deg);
  }
}

@media (max-width: 420px) {
  .brand-name {
    display: none;
  }
}

/* ---------------------------------------------------------- reduced motion */
@media (prefers-reduced-motion: reduce) {

  .hero,
  .console,
  .telemetry,
  .flow,
  #donut,
  .scanlines,
  .brand-glyph,
  .dot,
  .dot-live {
    animation: none !important;
  }
}
