feat: implement GuideController for evolution guide panel

- Added GuideController to manage the evolution guide panel, including event listeners for opening/closing the panel and spawning entities.
- Introduced a new guide.js file with the GuideController implementation.
- Created guide.css for styling the guide panel and its elements.
- Updated main.js to initialize the GuideController and link it with the EvolutionController.
- Enhanced settings.js to include functionality for resetting settings to defaults and saving state to localStorage.
- Modified modal.css to improve the layout and styling of the modal footer and reset button.
- Adjusted main.css to unify button styles for settings and guide buttons.
- Updated icons.css to add animations for entity interactions.
- Refactored gradient.js to utilize constants for default values.
This commit is contained in:
sha
2026-02-21 16:27:34 +02:00
parent 899d9d7c13
commit e3ec163ad7
19 changed files with 1428 additions and 112 deletions
+237
View File
@@ -0,0 +1,237 @@
/* ════════════════════════════════════════════════════════════
guide.css — evolution guide button and panel
════════════════════════════════════════════════════════════ */
/* ── Guide trigger button (position only — appearance from .icon-btn) ── */
.guide-btn {
position: fixed;
bottom: 1.5rem;
right: 1.5rem;
z-index: 100;
}
/* ── Guide panel ─────────────────────────────────────────── */
.guide-panel {
position: fixed;
bottom: 4.2rem;
right: 1.5rem;
z-index: 200;
width: 272px;
padding: 1.1rem 1.2rem 1.2rem;
background: var(--modal-surface);
border: 1px solid var(--modal-border);
border-radius: 14px;
box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
opacity: 0;
transform: translateY(6px) scale(0.98);
pointer-events: none;
transition: opacity 0.18s ease, transform 0.18s ease;
}
.guide-panel--visible {
opacity: 1;
transform: translateY(0) scale(1);
pointer-events: auto;
}
/* ── Panel header (title + uptime) ───────────────────────── */
.guide-panel__header {
display: flex;
align-items: baseline;
justify-content: space-between;
margin: 0 0 1rem;
}
.guide-panel__title {
font-family: var(--font-mono);
font-size: 0.68rem;
font-weight: 400;
color: var(--text-lo);
text-transform: lowercase;
letter-spacing: 0.1em;
margin: 0;
}
.guide-panel__uptime {
font-family: var(--font-mono);
font-size: 0.58rem;
color: rgba(255, 255, 255, 0.2);
letter-spacing: 0.05em;
font-variant-numeric: tabular-nums;
}
/* ── Section ─────────────────────────────────────────────── */
.guide-section + .guide-section {
margin-top: 0.9rem;
padding-top: 0.9rem;
border-top: 1px solid var(--modal-divider);
}
.guide-section__label {
font-family: var(--font-mono);
font-size: 0.58rem;
color: rgba(255, 255, 255, 0.28);
text-transform: uppercase;
letter-spacing: 0.14em;
margin: 0 0 0.55rem;
}
/* ── Entities list ───────────────────────────────────────── */
.guide-entities {
list-style: none;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
gap: 0.48rem;
}
.guide-entity {
display: flex;
align-items: center;
gap: 0.55rem;
cursor: pointer;
border-radius: 6px;
padding: 0.2rem 0.35rem;
margin: 0 -0.35rem;
transition: background 0.15s ease;
}
.guide-entity:hover {
background: var(--surface-tint);
}
/* Icon container — SVG injected here by guide.js */
.guide-entity__icon {
width: 16px;
height: 16px;
flex-shrink: 0;
color: var(--c, rgba(255, 255, 255, 0.6));
display: flex;
align-items: center;
justify-content: center;
filter: drop-shadow(0 0 4px color-mix(in srgb, var(--c, white) 60%, transparent));
}
.guide-entity__icon svg { width: 100%; height: 100%; display: block; }
.guide-entity__name {
font-family: var(--font-mono);
font-size: 0.7rem;
font-weight: 500;
color: var(--c, rgba(255, 255, 255, 0.8));
width: 54px;
flex-shrink: 0;
}
.guide-entity__role {
font-family: var(--font-mono);
font-size: 0.6rem;
color: rgba(255, 255, 255, 0.28);
flex: 1;
}
.guide-entity__count {
font-family: var(--font-mono);
font-size: 0.62rem;
color: rgba(255, 255, 255, 0.22);
min-width: 20px;
text-align: right;
flex-shrink: 0;
font-variant-numeric: tabular-nums;
}
/* ── Interactions list ───────────────────────────────────── */
.guide-rules {
list-style: none;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
gap: 0.42rem;
}
.guide-rule {
display: grid;
grid-template-columns: 9px 9px 9px 1fr;
align-items: center;
gap: 0.28rem;
}
/* Coloured circle representing an entity type */
.guide-rule__dot {
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--c, rgba(255, 255, 255, 0.25));
flex-shrink: 0;
box-shadow: 0 0 5px color-mix(in srgb, var(--c, white) 55%, transparent);
}
.guide-rule__op {
font-family: var(--font-mono);
font-size: 0.55rem;
color: rgba(255, 255, 255, 0.22);
text-align: center;
}
.guide-rule__desc {
font-family: var(--font-mono);
font-size: 0.62rem;
color: rgba(255, 255, 255, 0.45);
line-height: 1.3;
}
.guide-rule__pct {
color: rgba(255, 255, 255, 0.22);
font-size: 0.58rem;
}
/* ── Guide footer + restart button ───────────────────────── */
.guide-footer {
margin-top: 0.9rem;
padding-top: 0.9rem;
border-top: 1px solid var(--modal-divider);
}
.guide-reset-btn {
appearance: none;
width: 100%;
padding: 5px 0;
background: transparent;
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 6px;
cursor: pointer;
outline: none;
-webkit-tap-highlight-color: transparent;
font-family: var(--font-mono);
font-size: 0.58rem;
font-weight: 400;
letter-spacing: 0.12em;
text-transform: lowercase;
color: rgba(255, 255, 255, 0.28);
transition:
color 0.18s ease,
background 0.18s ease,
border-color 0.18s ease;
}
.guide-reset-btn:hover {
color: rgba(255, 255, 255, 0.65);
background: rgba(255, 255, 255, 0.06);
border-color: rgba(255, 255, 255, 0.2);
}
.guide-reset-btn:active {
color: var(--text-hi);
background: rgba(255, 255, 255, 0.1);
}
.guide-reset-btn:focus-visible {
outline: 2px solid rgba(255, 255, 255, 0.35);
outline-offset: 2px;
}
+35
View File
@@ -70,3 +70,38 @@
display: block;
/* SVGs use currentColor — colour is inherited from .icon-entity */
}
/* ── Collision hit flash ─────────────────────────────────── */
/*
* Brief scale-punch animation applied by Entity.onHit().
* Runs independently of the scale transition on .icon-entity__body —
* CSS animations take priority over transitions, and both settle on scale:1.
*
* The class is added and removed by JS; the `both` fill-mode holds the
* final scale:1 state until the class is removed, avoiding any jump.
*/
@keyframes entity-hit {
0% { scale: 1; }
35% { scale: 1.5; }
100% { scale: 1; }
}
.icon-entity__body--hit {
animation: entity-hit 0.35s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}
/* ── Entity slow-death state ─────────────────────────────── */
/*
* Added by Entity.die() after KILL_FADE_MS delay.
* The entity is already light-red (set via inline color) when this kicks in.
* Transitions to dark + grayscale over ~2.6s before JS destroys the DOM node.
* scale:1 prevents the spawning transition from interfering.
*/
.icon-entity__body--dying {
scale: 1 !important;
opacity: 0.12;
filter: brightness(0.2) grayscale(1) drop-shadow(0 0 0 transparent) !important;
transition:
opacity 2.6s ease-in,
filter 2.6s ease-in !important;
}
+22 -17
View File
@@ -20,7 +20,7 @@
--rotation-duration: 22s;
/* Modal surface */
--modal-surface: rgba(10, 10, 14, 0.82);
--modal-surface: rgba(10, 10, 14, 0.6);
--modal-border: rgba(255, 255, 255, 0.08);
--modal-divider: rgba(255, 255, 255, 0.06);
@@ -52,14 +52,9 @@ body {
justify-content: center;
}
/* ── Settings Button ─────────────────────────────────────── */
.settings-btn {
position: fixed;
top: 22px;
right: 26px;
z-index: 100;
/* Strip all button decoration */
/* ── Icon Button (shared base — settings + guide) ────────── */
.icon-btn {
/* Strip browser defaults */
appearance: none;
background: transparent;
border: none;
@@ -67,21 +62,22 @@ body {
padding: 0;
cursor: pointer;
-webkit-tap-highlight-color: transparent;
user-select: none;
/* Shape & layout */
/* Shape */
width: 38px;
height: 38px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
/* Typography */
font-family: var(--font-mono);
font-size: 1.05rem;
font-weight: 500;
line-height: 1;
letter-spacing: -0.02em;
color: rgba(255, 255, 255, 0.65);
transition:
@@ -89,18 +85,27 @@ body {
background 0.18s ease;
}
.settings-btn:hover {
color: rgba(255, 255, 255, 0.95);
background: rgba(255, 255, 255, 0.14);
.icon-btn:hover,
.icon-btn[aria-expanded="true"] {
color: var(--text-hi);
background: var(--surface-tint);
}
.settings-btn:active {
.icon-btn:active {
color: #fff;
background: rgba(255, 255, 255, 0.22);
}
/* Focus-visible ring for keyboard nav */
.settings-btn:focus-visible {
.icon-btn:focus-visible {
outline: 2px solid rgba(255, 255, 255, 0.5);
outline-offset: 2px;
}
/* ── Settings Button (position only) ────────────────────── */
.settings-btn {
position: fixed;
top: 22px;
right: 26px;
z-index: 100;
letter-spacing: -0.02em;
}
+75 -1
View File
@@ -112,7 +112,35 @@
padding: 20px;
display: flex;
flex-direction: column;
gap: 22px;
gap: 0;
max-height: calc(90vh - 60px);
overflow-y: auto;
scrollbar-width: none;
}
.modal-body::-webkit-scrollbar { display: none; }
/* ── Settings section (visual group) ─────────────────────── */
.settings-section {
padding: 16px 0;
display: flex;
flex-direction: column;
gap: 14px;
}
.settings-section + .settings-section {
border-top: 1px solid var(--modal-divider);
}
.settings-section__label {
font-family: var(--font-mono);
font-size: 0.56rem;
font-weight: 400;
letter-spacing: 0.18em;
text-transform: uppercase;
color: var(--text-lo);
opacity: 0.5;
user-select: none;
margin: 0;
}
/* ── Setting group (label + control) ─────────────────────── */
@@ -333,3 +361,49 @@
outline: 2px solid rgba(255, 255, 255, 0.45);
outline-offset: 2px;
}
/* ── Modal footer + reset button ─────────────────────────── */
.modal-footer {
padding: 14px 20px 18px;
border-top: 1px solid var(--modal-divider);
}
.reset-btn {
appearance: none;
width: 100%;
padding: 7px 0;
background: transparent;
border: 1px solid rgba(255, 80, 80, 0.22);
border-radius: 8px;
cursor: pointer;
outline: none;
-webkit-tap-highlight-color: transparent;
font-family: var(--font-mono);
font-size: 0.60rem;
font-weight: 400;
letter-spacing: 0.14em;
text-transform: lowercase;
color: rgba(255, 120, 100, 0.55);
transition:
color 0.18s ease,
background 0.18s ease,
border-color 0.18s ease;
}
.reset-btn:hover {
color: rgba(255, 140, 110, 0.85);
background: rgba(255, 80, 60, 0.09);
border-color: rgba(255, 80, 80, 0.40);
}
.reset-btn:active {
color: rgba(255, 160, 130, 1);
background: rgba(255, 80, 60, 0.16);
}
.reset-btn:focus-visible {
outline: 2px solid rgba(255, 100, 80, 0.45);
outline-offset: 2px;
}