/* The FluxGlow board. Every size is a multiple of --orb (the orb diameter), which board.js sets
   so the whole board fits its container. Used by the viewer, the editor and the landing page. */

@property --fg-c { syntax: "<color>"; inherits: true; initial-value: #2a2d32; }
@property --fg-hi { syntax: "<color>"; inherits: true; initial-value: #474b52; }
@property --fg-lo { syntax: "<color>"; inherits: true; initial-value: #17191c; }
@property --fg-glow { syntax: "<color>"; inherits: true; initial-value: transparent; }

.fg {
  --orb: 100px;
  --hf: 16px;
  --nh: 3;
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  color: #fff;
  font-family: "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.fg [hidden] { display: none !important; }

.fg-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- title bar ---------- */

.fg-head {
  flex: none;
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 1.1em;
  margin: 0 calc(var(--hf) * 0.9);
  padding: calc(var(--hf) * 1.7) calc(var(--hf) * 0.9) calc(var(--hf) * 1.5);
  border-bottom: 1px solid #343434;
  font-size: var(--hf);
  line-height: 1.2;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
}

.fg-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #8c8c8c;
}

.fg-tag { flex: none; color: #f4f4f4; }
.fg-tag::before { content: "[ "; color: #5c5c5c; }
.fg-tag::after { content: " ]"; color: #5c5c5c; }

/* ---------- stage and layouts ---------- */

.fg-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  transition: filter 0.6s ease;
}

.fg-flow {
  position: relative;
  z-index: 1;
  display: flex;
  width: max-content;
}

.fg-flow[data-mode="h"] { flex-direction: row; align-items: center; gap: calc(var(--orb) * 0.6); }
.fg-flow[data-mode="h"] .fg-col { display: flex; flex-direction: column; justify-content: center; gap: calc(var(--orb) * 0.3); }

.fg-flow[data-mode="v"] { flex-direction: column; align-items: center; gap: calc(var(--orb) * 0.6); }
.fg-flow[data-mode="v"] .fg-col { display: flex; flex-direction: row; justify-content: center; gap: calc(var(--orb) * 0.4); }

.fg-flow[data-mode="t"] { flex-direction: column; align-items: center; gap: calc(var(--orb) * 0.62); }
.fg-flow[data-mode="t"] .fg-col { display: flex; flex-direction: row; justify-content: center; gap: calc(var(--orb) * 0.3); }

.fg-flow[data-mode="grid"] {
  display: grid;
  justify-content: center;
  gap: calc(var(--orb) * 0.38) calc(var(--orb) * 0.5);
}

.fg-edges {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.fg-edge { fill: none; stroke: #2b2b2b; stroke-width: var(--edge, 1px); stroke-linecap: round; }
.fg-arrow { fill: #5e5e5e; }
.fg-edge.is-live { stroke: #2f7fc9; animation: fg-run 0.9s linear infinite; }
.fg-arrow.is-live { fill: #59b0ff; }

/* ---------- a node ---------- */

.fg-node {
  --fg-c: #2a2d32;
  --fg-hi: #474b52;
  --fg-lo: #17191c;
  --fg-glow: transparent;
  --ink: #fff;
  position: relative;
  display: grid;
  grid-template-areas: "label" "orb" "meta" "badge";
  justify-items: center;
  align-content: start;
  width: calc(var(--orb) * 1.7);
  transition: --fg-c 0.7s ease, --fg-hi 0.7s ease, --fg-lo 0.7s ease, --fg-glow 0.7s ease;
}

.fg-sized .fg-node { height: calc(var(--orb) * var(--nh)); }

.fg-node[data-state="ok"] { --fg-c: #84b324; --fg-hi: #c4e665; --fg-lo: #50780b; --fg-glow: #9bd82b; }
.fg-node[data-state="warn"] { --fg-c: #e39a12; --fg-hi: #ffd670; --fg-lo: #8f5a04; --fg-glow: #ffae1f; --ink: #1d1300; }
.fg-node[data-state="bad"] { --fg-c: #d43a20; --fg-hi: #ff8c69; --fg-lo: #86170a; --fg-glow: #ff4a26; }
.fg-node[data-state="run"] { --fg-c: #2687df; --fg-hi: #88cdff; --fg-lo: #0b4687; --fg-glow: #3aa0ff; }
.fg-node[data-state="idle"] { --ink: #979da5; }

.fg-label {
  grid-area: label;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: 100%;
  height: calc(var(--orb) * 0.3);
  margin-bottom: calc(var(--orb) * 0.2);
}

.fg-label-text {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: calc(var(--orb) * 0.19);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: 0.13em;
  text-indent: 0.13em;
  text-transform: uppercase;
}

.fg-label-text[data-fit="1"] { font-size: calc(var(--orb) * 0.15); }
.fg-label-text[data-fit="2"] { font-size: calc(var(--orb) * 0.118); }
.fg-label-text[data-fit="3"] { font-size: calc(var(--orb) * 0.09); }

.fg-orb {
  grid-area: orb;
  position: relative;
  display: grid;
  place-content: center;
  justify-items: center;
  width: var(--orb);
  height: var(--orb);
  border-radius: 50%;
  color: var(--ink);
  text-align: center;
  background: radial-gradient(circle at 50% 34%, var(--fg-hi) 0%, var(--fg-c) 50%, var(--fg-lo) 100%);
  box-shadow:
    inset 0 0 0 calc(var(--orb) * 0.024) color-mix(in srgb, var(--fg-lo) 62%, #000),
    inset 0 calc(var(--orb) * -0.05) calc(var(--orb) * 0.14) rgb(0 0 0 / 0.26),
    0 0 0 calc(var(--orb) * 0.018) color-mix(in srgb, var(--fg-glow) 72%, transparent),
    0 0 calc(var(--orb) * 0.14) color-mix(in srgb, var(--fg-glow) 60%, transparent);
}

/* The breathing halo. Its own layer, so only opacity animates. */
.fg-orb::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: 0 0 calc(var(--orb) * 0.46) calc(var(--orb) * 0.05) color-mix(in srgb, var(--fg-glow) 55%, transparent);
  opacity: 0.6;
  pointer-events: none;
  animation: fg-breathe 5.5s ease-in-out infinite;
}

.fg-node[data-state="bad"] .fg-orb::after { animation-duration: 1.6s; }
.fg-node[data-state="warn"] .fg-orb::after { animation-duration: 3.2s; }
.fg-node[data-state="idle"] .fg-orb::after { animation: none; opacity: 0; }

/* The ring that turns while a node is running. */
.fg-spin {
  position: absolute;
  inset: calc(var(--orb) * -0.105);
  border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0 55%, var(--fg-hi) 100%);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - var(--orb) * 0.042), #000 calc(100% - var(--orb) * 0.042 + 0.6px));
  mask: radial-gradient(farthest-side, transparent calc(100% - var(--orb) * 0.042), #000 calc(100% - var(--orb) * 0.042 + 0.6px));
  opacity: 0;
  transition: opacity 0.4s ease;
  animation: fg-turn 1.25s linear infinite paused;
}

.fg-node[data-state="run"] .fg-spin { opacity: 1; animation-play-state: running; }

.fg-val {
  position: relative;
  font-size: calc(var(--orb) * 0.4);
  font-weight: 700;
  line-height: 0.95;
  letter-spacing: -0.02em;
  text-shadow: 0 calc(var(--orb) * 0.012) calc(var(--orb) * 0.03) rgb(0 0 0 / 0.4);
}

.fg-val[data-fit="1"] { font-size: calc(var(--orb) * 0.34); }
.fg-val[data-fit="2"] { font-size: calc(var(--orb) * 0.275); }
.fg-val[data-fit="3"] { font-size: calc(var(--orb) * 0.228); }
.fg-val[data-fit="4"] { font-size: calc(var(--orb) * 0.192); }
.fg-val[data-fit="5"] { font-size: calc(var(--orb) * 0.166); }
.fg-val[data-fit="6"] { font-size: calc(var(--orb) * 0.146); }

.fg-unit {
  position: relative;
  max-width: calc(var(--orb) * 0.82);
  margin-top: calc(var(--orb) * 0.025);
  overflow: hidden;
  font-size: calc(var(--orb) * 0.14);
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  text-shadow: 0 calc(var(--orb) * 0.01) calc(var(--orb) * 0.02) rgb(0 0 0 / 0.35);
}

.fg-unit[data-fit="1"] { font-size: calc(var(--orb) * 0.122); }
.fg-unit[data-fit="2"] { font-size: calc(var(--orb) * 0.102); }

.fg-node[data-state="warn"] .fg-val,
.fg-node[data-state="warn"] .fg-unit { text-shadow: 0 1px 0 rgb(255 255 255 / 0.18); }

.fg-meta {
  grid-area: meta;
  margin-top: calc(var(--orb) * 0.25);
  color: #707070;
  font-size: calc(var(--orb) * 0.125);
  line-height: 1.8;
  letter-spacing: 0.09em;
  text-align: center;
  text-transform: uppercase;
}

.fg-cap,
.fg-since b,
.fg-since i { display: block; font-style: normal; }
.fg-since b { color: #fff; font-weight: 700; }

.fg-badge {
  grid-area: badge;
  width: calc(var(--orb) * 1.48);
  margin-top: calc(var(--orb) * 0.16);
  padding: calc(var(--orb) * 0.012) calc(var(--orb) * 0.1);
  border-radius: calc(var(--orb) * 0.022);
  background: var(--fg-c);
  box-shadow: 0 0 calc(var(--orb) * 0.14) color-mix(in srgb, var(--fg-glow) 78%, transparent);
  color: var(--ink);
  font-size: calc(var(--orb) * 0.13);
  font-weight: 700;
  line-height: 1.8;
  letter-spacing: 0.06em;
  text-align: center;
  text-transform: uppercase;
  text-wrap: balance;
  overflow-wrap: anywhere;
}

.fg-node[data-state="idle"] .fg-badge { background: #1f2226; }

/* ---------- top-to-bottom layout: orb on the left, words on the right ---------- */

/* The empty first and last rows share the spare height, which centres the words on the orb
   however many of them a node has. */
.fg-flow[data-mode="v"] .fg-node {
  grid-template-columns: var(--orb) 1fr;
  grid-template-rows: 1fr auto auto auto 1fr;
  grid-template-areas: "orb ." "orb label" "orb meta" "orb badge" "orb .";
  column-gap: calc(var(--orb) * 0.34);
  justify-items: start;
  width: calc(var(--orb) * 3.8);
}

.fg-flow[data-mode="v"] .fg-orb { align-self: center; }
.fg-flow[data-mode="v"] .fg-label { justify-content: flex-start; height: auto; margin: 0; }
.fg-flow[data-mode="v"] .fg-label-text { text-indent: 0; font-size: calc(var(--orb) * 0.2); }
.fg-flow[data-mode="v"] .fg-label-text[data-fit="2"] { font-size: calc(var(--orb) * 0.17); }
.fg-flow[data-mode="v"] .fg-label-text[data-fit="3"] { font-size: calc(var(--orb) * 0.13); }
.fg-flow[data-mode="v"] .fg-meta { margin-top: calc(var(--orb) * 0.05); line-height: 1.5; text-align: left; }
.fg-flow[data-mode="v"] .fg-cap,
.fg-flow[data-mode="v"] .fg-since b,
.fg-flow[data-mode="v"] .fg-since i { display: inline; }
.fg-flow[data-mode="v"] .fg-badge { width: auto; max-width: 100%; margin-top: calc(var(--orb) * 0.09); padding-inline: calc(var(--orb) * 0.13); text-align: left; }

/* ---------- when the board cannot be trusted ---------- */

.fg.is-stale .fg-stage { filter: grayscale(0.92) brightness(0.5); }
.fg.is-stale .fg-orb::after,
.fg.is-stale .fg-spin,
.fg.is-stale .fg-edge { animation-play-state: paused; }

.fg-note {
  flex: none;
  align-self: center;
  max-width: 92%;
  margin-bottom: calc(var(--hf) * 1.3);
  padding: 0.55em 1.1em;
  overflow: hidden;
  border: 1px solid #7a5406;
  border-radius: 4px;
  background: rgb(22 15 0 / 0.92);
  color: #ffb92e;
  font-size: calc(var(--hf) * 0.82);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

@keyframes fg-breathe {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

@keyframes fg-turn { to { transform: rotate(1turn); } }
@keyframes fg-run { to { stroke-dashoffset: var(--edge-loop, -7px); } }

@media (prefers-reduced-motion: reduce) {
  .fg-node { transition: none; }
  .fg-orb::after { animation: none; opacity: 0.8; }
  .fg-spin { animation: none; background: var(--fg-hi); }
  .fg-edge.is-live { animation: none; }
}
