/* Home screen, layout B, look "Sonnensturm": the sun in the middle, fields as small windows around it. */

.home { flex: 1; width: 100%; max-width: 1440px; margin: 0 auto; padding: 0 16px; }
.stage { position: relative; }

/* ---------- Sun (reactor.js): canvas sphere + sparks, golden ring, side lines, greeting below ---------- */
.reactor { position: relative; z-index: 0; }
.stage.ring .reactor { position: absolute; left: var(--cx); top: var(--cy); width: 0; height: 0; } /* = disc centre */
.sun {
  position: absolute; width: var(--s, 440px); height: var(--s, 440px);
  left: calc(var(--s, 440px) / -2); top: calc(var(--s, 440px) / -2 + var(--dy, 0px));
}
.sun-canvas {
  position: absolute; left: 50%; top: 50%; width: calc(var(--s, 440px) * 1.6); height: calc(var(--s, 440px) * 1.6);
  transform: translate(-50%, -50%); pointer-events: none;
}
.sun-ring { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.sun-ring circle { stroke: var(--ring); }
.sun-ring .faint { stroke-opacity: .2; }
.sun-ring .dash { stroke-opacity: .72; }
.sun-ring .dots { stroke-opacity: .42; }
.sun-ring .r1, .sun-ring .r2 { transform-box: view-box; transform-origin: 220px 220px; }
.sun-ring .r1 { animation: sun-spin 130s linear infinite; }
.sun-ring .r2 { animation: sun-spin 90s linear infinite reverse; }
@keyframes sun-spin { to { transform: rotate(360deg); } }
.sun .wordmark-title { /* letters ~80 % of the sphere diameter (0.71 × box; the svg is 582/542 wider than the letters) */
  position: absolute; left: 50%; top: 50%; width: calc(var(--s, 440px) * .61); margin: 0; font: inherit;
  transform: translate(-50%, -50%); pointer-events: none;
}
.wordmark { display: block; width: 100%; height: auto; overflow: visible; animation: wordmark-flicker 6s infinite; }
.wordmark g { stroke: var(--wm-ink, #fff3c9); }
@keyframes wordmark-flicker {
  0%, 54%, 56%, 84%, 86%, 100% { opacity: 1; }
  55%, 85% { opacity: .55; }
}
/* On white: light wire on the saturated sphere, dark soft glow (drop-shadow instead of the bloom filter) */
html[data-backdrop='weiss'] .wordmark g { filter: none; }
html[data-backdrop='weiss'] .wordmark {
  filter: drop-shadow(0 0 2px var(--wm-glow, #3a1a00)) drop-shadow(0 0 7px var(--wm-glow, #3a1a00));
}
.sun-line { position: absolute; top: 50%; height: 1px; width: var(--line, 0px); opacity: .32; pointer-events: none; }
.sun-line.l { right: calc(50% + var(--s, 440px) * .56); background: linear-gradient(90deg, transparent, var(--ring) 30%); }
.sun-line.r { left: calc(50% + var(--s, 440px) * .56); background: linear-gradient(270deg, transparent, var(--ring) 30%); }

.reactor-text { position: relative; z-index: 2; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; }
.stage.ring .reactor-text { position: absolute; left: 0; top: var(--ty, 222px); width: max-content; transform: translateX(-50%); }
/* Never cut: one line at its natural width, shrunk by fitLines to the room between the fields. */
.reactor-greet, .reactor-status { width: max-content; max-width: none; white-space: nowrap; }
.reactor-greet {
  font: 200 var(--fs, 22px)/1.25 "Helvetica Neue", Helvetica, Arial, sans-serif;
  letter-spacing: .18em; padding-left: .18em; /* balances the spacing after the last letter */
  color: var(--soft); text-shadow: 0 1px 12px var(--shade);
}
.reactor-status {
  font: 600 var(--fs, 10px)/1.3 Rajdhani, sans-serif; letter-spacing: .45em; padding-left: .45em; text-transform: uppercase;
  color: var(--state); text-shadow: 0 1px 10px var(--shade);
}
.reactor-status[data-tone='warn'] { color: var(--warn); }
.reactor-status[data-tone='dim'] { color: var(--detail); }
html[data-backdrop='weiss'] .reactor-greet { font-weight: 300; }

/* ---------- Fields: plain windows, header line (title, dot), value large in gold, detail (module · detail) ---------- */
.field-btn {
  position: relative; z-index: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden;
  font: inherit; color: var(--fg); text-align: left; cursor: pointer; padding: 0;
  border: 1px solid var(--win-line); border-radius: 0; background: var(--win-bg-field);
  /* no backdrop-filter: blurring over the animated canvas every frame is too costly on iPad */
  transition: border-color .2s, box-shadow .2s;
}
.f-head {
  flex: none; display: flex; align-items: center; gap: 10px; height: 22px; padding: 0 10px;
  border-bottom: 1px solid var(--win-line-hd);
}
.f-title { /* never cut: the header's free width is its budget, fitLines shrinks the text into it */
  flex: 1 1 auto; min-width: 0; white-space: nowrap;
  font: 600 var(--fs, 10px)/1 Rajdhani, sans-serif; letter-spacing: .3em; color: var(--head);
}
.f-body { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 2px; padding: 6px 12px 9px; }
.f-value {
  display: block; white-space: nowrap; /* not clipped here: the glow would get a hard edge; fitLines shrinks it */
  font: 600 var(--fs, 26px)/1.1 Rajdhani, sans-serif; letter-spacing: .01em; color: var(--value);
  text-shadow: 0 0 20px var(--value-glow);
}
.f-detail {
  display: block; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font: 500 12px/1.25 Rajdhani, sans-serif; color: var(--detail);
}
.f-detail[hidden] { display: none; }

.field-btn:hover { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.field-btn.selected { border-color: var(--accent); box-shadow: 0 0 22px var(--value-glow), inset 0 0 0 1px color-mix(in srgb, var(--accent) 40%, transparent); }
.field-btn.hl .f-value { color: var(--value-on); }
.field-btn.hl .f-dot { background: var(--value-on); box-shadow: 0 0 8px var(--value-on); }
.field-btn.down { opacity: .82; }
.field-btn.down .f-value, .field-btn.starting .f-value { color: var(--detail); text-shadow: none; }
.field-btn.down .f-dot { background: var(--warn); }
.field-btn.starting .f-dot { background: var(--detail); }

/* Fields on the right mirror the header (dot outside, title next to the sun) and align right. */
.field-btn[data-side='right'] { text-align: right; }
.field-btn[data-side='right'] .f-head { flex-direction: row-reverse; }
.field-btn[data-side='right'] .f-body { align-items: flex-end; }
.field-btn[data-side='centre'] { text-align: center; }
.field-btn[data-side='centre'] .f-body { align-items: center; }

/* Ring: absolute positions from layout.js */
.stage.ring { height: var(--h, 600px); }
.stage.ring .field-btn {
  position: absolute; left: var(--x); top: var(--y); width: var(--fw); height: var(--fh);
  transform: translate(-50%, -50%);
}

/* Stacked: sun on top, fields as a grid below */
.stage.stacked { display: flex; flex-direction: column; align-items: center; gap: 28px; padding: 36px 0 8px; }
.stage.stacked .reactor { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.stage.stacked .sun { position: relative; left: auto; top: auto; }
.stage.stacked .fields {
  position: relative; z-index: 1; width: 100%; display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr));
}
.stage.stacked .field-btn { min-height: 92px; }

@media (prefers-reduced-motion: reduce) {
  .sun-ring .r1, .sun-ring .r2, .wordmark { animation: none; }
}
