/* EVOLVING WALKERS page. The shared palette, buttons, panels and the how-it-works layout come from style.css and
   app.css; this file styles the arena, the charts, the lineage and hall of fame, and the creature lab. */

/* Buttons and panels set their own display, which would override the hidden attribute. */
[hidden] { display: none !important; }

/* ---------- arena: a neon frame with a faint scanline overlay, like the other labs */
.ew-stage { display: flex; flex-direction: column; gap: 0.8rem; width: 100%; }
.ew-frame {
  position: relative;
  padding: 8px;
  border: 1px solid var(--cyan);
  border-radius: 6px;
  background: #020610;
  box-shadow: 0 0 22px rgba(0, 245, 255, 0.3), 0 0 60px rgba(155, 0, 255, 0.18), inset 0 0 30px rgba(0, 245, 255, 0.06);
  overflow: hidden;
}
.ew-frame::after {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 4px;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.16) 0 1px, transparent 1px 3px);
}
#ew-arena {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 2.1 / 1;
  border-radius: 3px;
}
.ew-frame.ew-glitch { animation: ew-glitch 0.32s steps(2, end); }
@keyframes ew-glitch {
  0% { filter: none; }
  25% { filter: hue-rotate(90deg) saturate(2); transform: translate(3px, -1px); }
  50% { filter: hue-rotate(-60deg) brightness(1.3); transform: translate(-4px, 1px); }
  75% { filter: saturate(0.4); transform: translate(2px, 0); }
  100% { filter: none; transform: none; }
}

/* HUD: text over the arena, pinned to the corners. */
.ew-hud { position: absolute; inset: 8px; pointer-events: none; display: flex; flex-direction: column; justify-content: space-between; padding: 0.5rem 0.6rem; }
.ew-hud-top, .ew-hud-bottom { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.6rem; flex-wrap: wrap; }
.ew-tag {
  font-family: var(--orb);
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  color: #020610;
  background: var(--green);
  padding: 0.15rem 0.45rem;
  box-shadow: 0 0 10px var(--green);
}
.ew-label { font-family: var(--mono); font-size: 0.7rem; color: var(--text); text-shadow: 0 0 6px #000; }
.ew-dist { font-family: var(--orb); font-size: clamp(1rem, 2.4vw, 1.5rem); color: var(--yellow); text-shadow: 0 0 10px var(--yellow); }
.ew-clock { font-family: var(--mono); font-size: 0.7rem; color: var(--dim); text-shadow: 0 0 6px #000; }
.ew-back { pointer-events: auto; align-self: flex-end; }

.ew-transport { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.6rem; }
.ew-transport .cyber-btn { min-width: 8rem; }
.ew-slider { display: flex; flex-direction: column; min-width: 9rem; flex: 1 1 9rem; }
.ew-slider .field-lbl { display: flex; justify-content: space-between; }

/* ---------- charts and panels */
.ew-charts, .ew-lower { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1.2rem; }
.ew-panel {
  position: relative;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
  padding: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-width: 0;
}
.ew-panel::before, .ew-panel::after { content: ""; position: absolute; width: 14px; height: 14px; pointer-events: none; }
.ew-panel::before { top: -1px; left: -1px; border-top: 2px solid var(--cyan); border-left: 2px solid var(--cyan); }
.ew-panel::after { bottom: -1px; right: -1px; border-bottom: 2px solid var(--pink); border-right: 2px solid var(--pink); }
.ew-chart { width: 100%; height: 170px; display: block; }
.ew-panel .section-title { margin: 0; font-size: 0.7rem; }

.ew-log-wrap { margin-top: 1.2rem; }
.ew-log { max-height: 190px; border-color: rgba(0, 245, 255, 0.3); font-family: var(--mono); font-size: 0.7rem; line-height: 1.5; }
.ew-log > div { padding: 0.08rem 0; color: var(--text); }
.ew-log > .rec { color: var(--green); font-weight: 700; }
.ew-log > .spc { color: var(--pink); }
.ew-log > .warn { color: var(--yellow); }
.ew-log > .err { color: var(--red); }

/* ---------- lineage */
.lineage { display: flex; flex-direction: column; gap: 0.3rem; }
/* Each ancestor is one row, indented by depth: a tag column (what it is), then the score and the body plan. */
.lin-row {
  all: unset;
  box-sizing: border-box;
  cursor: pointer;
  display: grid;
  grid-template-columns: 6.2rem 1fr;
  gap: 0.1rem 0.6rem;
  padding: 0.35rem 0.5rem 0.35rem calc(0.5rem + var(--indent, 0px));
  border-left: 2px solid rgba(0, 245, 255, 0.35);
  background: rgba(0, 245, 255, 0.03);
  font-family: var(--mono);
  font-size: 0.7rem;
  text-align: left;
}
.lin-row:hover, .lin-row:focus-visible { background: rgba(0, 245, 255, 0.12); outline: 1px solid var(--cyan); }
.lin-tag { font-family: var(--orb); font-size: 0.52rem; letter-spacing: 0.1em; color: var(--pink); grid-row: span 2; align-self: center; }
.lin-main { color: var(--green); }
.lin-sub { color: var(--dim); grid-column: 2; }

/* ---------- hall of fame */
.hof-head { display: grid; grid-template-columns: auto 1fr auto; gap: 0.5rem; align-items: center; }
.hof-head .cyber-btn { min-width: 2.6rem; padding-left: 0.4rem; padding-right: 0.4rem; }
.hof-title { font-family: var(--orb); font-size: 0.78rem; color: var(--green); text-align: center; text-shadow: 0 0 8px var(--green); }

/* ---------- creature lab */
.ew-tools { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.ew-tools .cyber-btn { flex: 1 1 auto; min-width: 4.4rem; padding-left: 0.5rem; padding-right: 0.5rem; }
.ew-tools .cyber-btn.on { background: rgba(0, 245, 255, 0.15); box-shadow: 0 0 14px var(--cyan); }
.ew-tools .cyber-btn.pink.on { background: rgba(255, 0, 160, 0.16); box-shadow: 0 0 14px var(--pink); }
.ew-lab-frame { border: 1px solid var(--border); background: rgba(0, 0, 0, 0.35); }
#ed-canvas { display: block; width: 100%; height: 240px; touch-action: none; cursor: crosshair; }
.ew-code { width: 100%; font-family: var(--mono); font-size: 0.7rem; resize: vertical; }
.ew-challenger { font-family: var(--raj); font-size: 0.9rem; color: var(--dim); }
.chal-line { font-family: var(--orb); font-size: 0.8rem; letter-spacing: 0.08em; color: var(--pink); margin-bottom: 0.3rem; }
.chal-line.win { color: var(--yellow); text-shadow: 0 0 10px var(--yellow); }

/* ---------- small screens: the arena stays usable, the panels stack */
@media (max-width: 1100px) {
  .ew-charts, .ew-lower { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  #ew-arena { aspect-ratio: 16 / 11; }
  .ew-frame { padding: 5px; }
  .ew-frame::after { inset: 5px; }
  .ew-hud { inset: 5px; padding: 0.35rem; }
  .ew-transport .cyber-btn { min-width: 0; flex: 1 1 40%; }
  .ew-chart { height: 150px; }
  #ed-canvas { height: 200px; }
  .ew-panel { padding: 0.6rem; }
}

@media (prefers-reduced-motion: reduce) {
  .ew-frame.ew-glitch { animation: none; }
}
