diff --git a/README.md b/README.md index 5b46190..69f5d02 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,14 @@ -# `hyperstitionstudio-core` (`hyperstitionstud_io.*` — `v2.0.0`) +# `hyperstitionstudio-core` (`hyperstitionstud_io.*` — `v2.7.0`) -Shared Python common library (`hyperstitionstud_io.*`), offline `URN:` JSON Schema registry (`urn:io:hyperstitionstud:schema:v1:*`), and offline browser/ESM modules (`@hyperstitionstud.io/*` / `window.HyperstitionStudio.*`) across all workspace projects. + +> **Gitea Commit & Release Telemetry (`v2.7.0` • Namespace `urn:io:hyperstitionstud`)** +> - **Repository Role & Public Route:** Shared PEP 420 Python core library (`hyperstitionstud_io.*`), MCP/REST server, `/quant/`, `/learn/`, `/engineering/`, `/math/`, & `/donate/` webroots → [`https://hyperstitionstud.io/`](https://hyperstitionstud.io/) +> - **Latest Commit Scope (`hyperstitionstudio-core`):** Synchronized v2.7.0 release state across 48 tracked module/artifact surface(s) +> - **Touched Files / Surfaces:** `deploy/run-vps-data-production.sh`, `deploy/sync-vps-repos.sh`, `deploy/test-first-deployment.sh`, `package.json`, `packages-js/ciphers-aq/package.json`, `pyproject.toml`, `scripts/build_gallery_manifest.py`, `site/assets/closeups/quadrant-1-cybermemetics-calc-graph.png` (+40 more) +> - **Live Verified Ecosystem Metrics (`v2.7.0`):** `6` Repositories • `17` CLI Entrypoints • `20` MCP/REST Tools • `14` URN Resources • `63` Verified Web Routes • `388` KG Nodes / `1,282` Edges • `282` Glossary Entries • `4,943` Offline CMUdict Phonetics • `0` Synthetic Data + + +Shared Python common library (`hyperstitionstud_io.*`), stateless read-only Model Context Protocol (`/mcp`) & OpenAPI 3.1 REST (`/api/v1/*`) server, SQLite FTS5 metadata catalog (`hs-db-build`), offline `URN:` JSON Schema registry (`urn:io:hyperstitionstud:schema:v1:*`), and Group 3 Stealth Basalt web workbenches (`/`, `/learn/`, `/quant/`, `/engineering/`, `/math/`, `/donate/`) with the 4-Ring Hardened Polyglot REPL (`Guile Scheme`, `TypeScript`, `Rust`) and Subtle Cybernetic Code Rain (`hs-matrix-coderain.js`). --- @@ -10,7 +18,7 @@ Shared Python common library (`hyperstitionstud_io.*`), offline `URN:` JSON Sche # 1. Create a parent workspace folder anywhere on your machine mkdir -p ~/hyperstition-workspace && cd ~/hyperstition-workspace -# 2. Clone the peer repositories over public HTTPS (no SSH key required) +# 2. Clone the 6 peer repositories over public HTTPS (no SSH key required) git clone https://git.libre.audio/seasharp/hyperstitionstudio-core.git git clone https://git.libre.audio/seasharp/ingglish-hyperdope-gematria.git git clone https://git.libre.audio/seasharp/technocapital-singularity-zoology.git @@ -33,25 +41,22 @@ pip install --no-deps -e ./hyperstitionstudio-core cp hyperstitionstudio-core/workspace.example.toml ./workspace.toml hs-doctor -# 5. Run the 6-suite verification test runner (stdlib-compatible, zero pytest dependency required) +# 5. Run the 7-suite verification test runner (including ProtectSystem=strict EROFS introspection) python3 hyperstitionstudio-core/tests/test_core_suite.py -# 6. Test the complete per-repository web deployment locally across all 22 HTTP routes +# 6. Test the complete per-repository web deployment locally across all 63 HTTP routes + MCP/REST + P1-P6 smoke gates ./hyperstitionstudio-core/deploy/test-first-deployment.sh ``` --- -## Key Features (`v1.2.0`) +## Key Architecture & Capabilities (`v2.7.0`) -1. **100% Offline & Location-Independent Architecture (Zero `https://` Network Calls, Zero `/workspace` Lock-In):** - - Python package root: `hyperstitionstud_io.{config,ciphers,phonetics,publishing,glossary,graph,ci,audio}` - - Dynamic `__file__`-anchored `WORKSPACE_ROOT` discovery so sibling repositories work in any parent directory (`~/...`, `/tmp/...`, `/workspace/`). - - Cross-OS TrueType font resolver (`hyperstitionstud_io.publishing.fonts`) supporting Debian/Ubuntu, Fedora/RHEL, Arch, Alpine, and macOS with built-in Pillow/ReportLab fallbacks. - - Offline JSON Schema `$id` URNs: `urn:io:hyperstitionstud:schema:v1:*` (`schemas/v1/*.schema.json`). - - GraphML / GEXF XML namespace: `xmlns:hs="urn:io:hyperstitionstud:ns:kg:1.0"`. -2. **Local-Configuration Citation URL Resolution (`[citations.path_mounts]` in `workspace.toml`):** - - Resolves local dossier paths into remote citation URLs **only** when explicitly configured in local `workspace.toml`, falling back deterministically to the verified local filesystem path. - - Transparently rebases `/workspace/...` paths in existing `v1` citation ledgers onto the active `WORKSPACE_ROOT` when running outside `/workspace`. -3. **4,897-Entry Offline `CMUdict` Phonetics Lookup (`cmudict_fallback.json`):** - - Translates `Gen 0` English tokens to `Gen 1` Ingglish 100% offline without requiring Node.js or `--workdir`. +1. **17 CLI Entrypoints (`pyproject.toml [project.scripts]`):** + - `hs-doctor`, `hs-citations`, `hs-pdf-build`, `hs-kg-build`, `hs-quant-harvest`, `hs-macro-harvest`, `hs-daily-brief`, `hs-ticker-card`, `hs-mcp`, `hs-db-build`, `hs-sync-version`, `hs-readme-sync`, `hs-archive-rotate`, `hs-public-smoke`, `hs-eng-docs`, `hs-math-docs`, and `hs-highlights`. +2. **20 Stateless Read-Only MCP & OpenAPI 3.1 REST Tools + HTTP `ETag` (`304 Not Modified`) Caching:** + - Exposes all cipher, phonetics, knowledge-graph, `ETI`, financial/macro time-series, Bayesian daily-brief, polyglot AST sandbox, SQLite FTS5 catalog, and IPLD `dag-json` `CIDv1` tools over `/mcp` and `/api/v1/*`. +3. **Interactive Web Workbenches (`https://hyperstitionstud.io/`):** + - `/` (Portal Home), `/learn/` (6-Module Interactive Track), `/quant/` (3-Pane Closing-Bell & FRED Macro Time-Series + 25-Scene Guided Tour), `/engineering/` (`E0-E5` Software Engineering Hub), `/math/` (`M0-M5` Applied Mathematics Hub), and `/donate/` (Signal Patronage). +4. **4,943-Entry Offline `CMUdict` Phonetics Lookup (`cmudict_fallback.json`):** + - Translates `Gen 0` English tokens to `Gen 1` Ingglish 100% offline with zero network calls. diff --git a/deploy/run-vps-data-production.sh b/deploy/run-vps-data-production.sh index d5710fb..3945d9a 100755 --- a/deploy/run-vps-data-production.sh +++ b/deploy/run-vps-data-production.sh @@ -115,6 +115,7 @@ fi if [[ "${DO_PUSH}" -eq 1 ]] && [[ -f "/etc/hyperstitionstud.io/id_ed25519_git_libre_audio" ]]; then echo "[4/5] Committing and pushing automated VPS telemetry updates to git.libre.audio..." + run_checked "hs-readme-sync --all" python3 -m hyperstitionstud_io.publishing.readme_sync --all export GIT_SSH_COMMAND="ssh -i /etc/hyperstitionstud.io/id_ed25519_git_libre_audio -o StrictHostKeyChecking=accept-new" STAMP_UTC="$(date -u +%Y-%m-%dT%H:%M:%SZ)" for r in hyperstitionstudio-core ingglish-hyperdope-gematria encyclopedia-knowledge-graph; do diff --git a/deploy/sync-vps-repos.sh b/deploy/sync-vps-repos.sh index 35ef078..c9681ba 100755 --- a/deploy/sync-vps-repos.sh +++ b/deploy/sync-vps-repos.sh @@ -133,6 +133,7 @@ if [[ -f "${REPOS_ROOT}/workspace.toml" ]] && [[ -f "${REPOS_ROOT}/hyperstitions # Sync schema_version in untracked parent workspace.toml with hyperstitionstud_io.__version__ run_checked "version_sync (sync untracked workspace.toml)" "${PYTHON_BIN}" -m hyperstitionstud_io.version_sync fi +run_checked "hs-readme-sync --install-hooks" "${PYTHON_BIN}" -m hyperstitionstud_io.publishing.readme_sync --install-hooks run_checked "version_sync --check" "${PYTHON_BIN}" -m hyperstitionstud_io.version_sync --check run_checked "hs-db-build (--build)" "${PYTHON_BIN}" -m hyperstitionstud_io.db.sqlite_meta --build run_checked "hs-doctor" "${PYTHON_BIN}" -m hyperstitionstud_io.ci.doctor diff --git a/deploy/test-first-deployment.sh b/deploy/test-first-deployment.sh index a81ff96..57b1af1 100755 --- a/deploy/test-first-deployment.sh +++ b/deploy/test-first-deployment.sh @@ -54,6 +54,12 @@ ROUTES=( "/" "/assets/hs-group3-basalt-chamfer.css" "/assets/hs-guile-scheme-repl.js" + "/assets/hs-matrix-coderain.js" + "/assets/matrix-font.woff2" + "/assets/closeups/quadrant-1-cybermemetics-calc-graph.png" + "/assets/closeups/quadrant-2-esoteric-finance-quant.png" + "/assets/closeups/quadrant-3-info-science-novice-learn-polyglot.png" + "/assets/closeups/quadrant-4-operators-deployment-vps.png" "/donate/index.html" "/learn/index.html" "/learn/learn-app.js" diff --git a/package.json b/package.json index 4944d64..92aa48d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hyperstitionstud.io/workspace-core", - "version": "2.4.0", + "version": "2.7.0", "private": true, "description": "Offline-first ESM & browser global (@hyperstitionstud.io/* / window.HyperstitionStudio.*) packages for Base-36 AQ ciphers and interactive knowledge graph workbenches.", "license": "MIT", diff --git a/packages-js/ciphers-aq/package.json b/packages-js/ciphers-aq/package.json index 28956a6..e2b6805 100644 --- a/packages-js/ciphers-aq/package.json +++ b/packages-js/ciphers-aq/package.json @@ -1,6 +1,6 @@ { "name": "@hyperstitionstud.io/ciphers-aq", - "version": "2.4.0", + "version": "2.7.0", "type": "module", "main": "index.js", "license": "MIT" diff --git a/pyproject.toml b/pyproject.toml index 858fb2f..6c3f447 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "hyperstitionstudio-core" -version = "2.4.0" +version = "2.7.0" description = "Shared PEP 420 common library (hyperstitionstud_io.*) for Base-36 AQ ciphers, offline CMUdict Ingglish phonetics, ReportLab/Pillow publishing, SHA-256 glossary isolation guards, local-config citation verification, and multi-format knowledge graphs." readme = "README.md" requires-python = ">=3.10" @@ -39,6 +39,7 @@ hs-public-smoke = "hyperstitionstud_io.ci.public_regression:main" hs-eng-docs = "hyperstitionstud_io.publishing.engineering_docs:main" hs-math-docs = "hyperstitionstud_io.publishing.math_docs:main" hs-highlights = "hyperstitionstud_io.publishing.highlights:main" +hs-readme-sync = "hyperstitionstud_io.publishing.readme_sync:main" [tool.setuptools.packages.find] where = ["src"] diff --git a/scripts/build_gallery_manifest.py b/scripts/build_gallery_manifest.py index 19d3677..1c4431d 100755 --- a/scripts/build_gallery_manifest.py +++ b/scripts/build_gallery_manifest.py @@ -144,8 +144,8 @@ def main() -> int: }) manifest = { - "version": "2.4.0", - "namespace_urn": "urn:io:hyperstitionstud:gallery:2.4.0", + "version": "2.7.0", + "namespace_urn": "urn:io:hyperstitionstud:gallery:2.7.0", "total_items": len(items), "items": items, } diff --git a/site/assets/closeups/quadrant-1-cybermemetics-calc-graph.png b/site/assets/closeups/quadrant-1-cybermemetics-calc-graph.png new file mode 100644 index 0000000..fe4ff87 Binary files /dev/null and b/site/assets/closeups/quadrant-1-cybermemetics-calc-graph.png differ diff --git a/site/assets/closeups/quadrant-2-esoteric-finance-quant.png b/site/assets/closeups/quadrant-2-esoteric-finance-quant.png new file mode 100644 index 0000000..66b947f Binary files /dev/null and b/site/assets/closeups/quadrant-2-esoteric-finance-quant.png differ diff --git a/site/assets/closeups/quadrant-3-info-science-novice-learn-polyglot.png b/site/assets/closeups/quadrant-3-info-science-novice-learn-polyglot.png new file mode 100644 index 0000000..f55dd73 Binary files /dev/null and b/site/assets/closeups/quadrant-3-info-science-novice-learn-polyglot.png differ diff --git a/site/assets/closeups/quadrant-4-operators-deployment-vps.png b/site/assets/closeups/quadrant-4-operators-deployment-vps.png new file mode 100644 index 0000000..6122734 Binary files /dev/null and b/site/assets/closeups/quadrant-4-operators-deployment-vps.png differ diff --git a/site/assets/hs-group3-basalt-chamfer.css b/site/assets/hs-group3-basalt-chamfer.css index a49d0c7..fcc76e1 100644 --- a/site/assets/hs-group3-basalt-chamfer.css +++ b/site/assets/hs-group3-basalt-chamfer.css @@ -180,12 +180,12 @@ button.btn:not(.tactile-donate-btn):hover, color: #f8fafc; } -/* RETAINED DONATION BUTTON STYLE (Deliberate border-radius: 999px Stadium-Pill Contrast) */ +/* RETAINED DONATION BUTTON STYLE (Deliberate border-radius: 999px Stadium-Pill Contrast — v2.4.0 Canonical Single Source of Truth) */ .nav-donate-sep { width: 1px; height: 20px; background: var(--border); - margin: 0 0.4rem; + margin: 0 0.2rem; display: inline-block; flex-shrink: 0; align-self: center; @@ -196,7 +196,7 @@ button.btn:not(.tactile-donate-btn):hover, box-sizing: border-box !important; border-radius: 999px !important; clip-path: none !important; - padding: 0 0.9rem 0 0.38rem !important; + padding: 0.28rem 0.9rem 0.28rem 0.35rem !important; background: linear-gradient(180deg, #ffd86b 0%, #f59e0b 52%, #d97706 100%) !important; color: #020617 !important; border: 1px solid #f5c630 !important; @@ -211,6 +211,14 @@ button.btn:not(.tactile-donate-btn):hover, line-height: 1 !important; text-decoration: none !important; flex-shrink: 0 !important; + transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease !important; +} + +.btn-donate-pill:hover { + filter: brightness(1.06) !important; + transform: translateY(-1px) !important; + box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.65), 0 4px 12px rgba(245, 158, 11, 0.32) !important; + color: #020617 !important; } .donate-pill-emblem { @@ -383,3 +391,122 @@ html[data-guile-scheme-mode="on"] #hsGuileReplDrawer { #hsGuileReplDrawer.hs-repl-minimized .hs-repl-body { display: none; } + +/* ========================================================================== + Subtle Basalt-Phosphor Matrix Code Rain & Cybernetic/Occult Micro-Sigils + ========================================================================== */ +@font-face { + font-family: "matrix-font"; + src: url("matrix-font.woff2") format("woff2"); + font-display: swap; +} + +#hsMatrixCodeRainCanvas { + position: fixed; + inset: 0; + width: 100vw; + height: 100vh; + z-index: 0; + pointer-events: none; + opacity: 0.45; + transition: opacity 0.25s ease; +} + +body > .container, +body > header, +body > main, +body > section, +body > footer, +#hsGuileReplDrawer { + position: relative; + z-index: 1; +} + +.hs-sigil { + display: inline-block; + font-family: 'DejaVu Sans Mono', monospace; + opacity: 0.78; + margin-right: 0.28rem; + font-weight: 400; +} + +.hs-sigil-seal { + display: inline-block; + font-family: 'DejaVu Sans Mono', monospace; + font-size: 0.7rem; + color: var(--gold); + opacity: 0.72; + letter-spacing: 0.08em; + margin-left: 0.35rem; +} + +.hs-sigil-colophon { + display: inline-block; + font-family: 'DejaVu Sans Mono', monospace; + color: var(--cyan); + opacity: 0.68; + letter-spacing: 0.08em; +} + +.hs-plate-g3.plate-lock-gold::after, +.card.plate-lock-gold::after, +.panel.plate-lock-gold::after { + content: "\260D \00B7 37\00D73k"; + position: absolute; + top: 6px; + right: 12px; + font-family: 'DejaVu Sans Mono', monospace; + font-size: 0.64rem; + color: var(--gold); + opacity: 0.32; + pointer-events: none; + letter-spacing: 0.04em; +} + +.hs-plate-g3.plate-lock-emerald::after, +.card.plate-lock-emerald::after, +.panel.plate-lock-emerald::after { + content: "\263F \00B7 \0394=0"; + position: absolute; + top: 6px; + right: 12px; + font-family: 'DejaVu Sans Mono', monospace; + font-size: 0.64rem; + color: var(--emerald); + opacity: 0.32; + pointer-events: none; + letter-spacing: 0.04em; +} + +.hs-plate-g3.plate-lock-rose::after, +.card.plate-lock-rose::after, +.panel.plate-lock-rose::after { + content: "\2297 \00B7 S\00D7S6"; + position: absolute; + top: 6px; + right: 12px; + font-family: 'DejaVu Sans Mono', monospace; + font-size: 0.64rem; + color: var(--rose); + opacity: 0.32; + pointer-events: none; + letter-spacing: 0.04em; +} + +html[data-sigil-accents="off"] .hs-sigil, +html[data-sigil-accents="off"] .hs-sigil-seal, +html[data-sigil-accents="off"] .hs-sigil-colophon, +html[data-sigil-accents="off"] .hs-plate-g3::after, +html[data-sigil-accents="off"] .card::after, +html[data-sigil-accents="off"] .panel::after { + display: none !important; +} + +.hs-rain-toggle-btn { + padding: 0.18rem 0.52rem !important; + font-size: 0.67rem !important; + border-color: rgba(56, 189, 248, 0.45) !important; + color: var(--cyan) !important; + background: var(--bg-void) !important; + cursor: pointer; +} diff --git a/site/assets/hs-matrix-coderain.js b/site/assets/hs-matrix-coderain.js new file mode 100644 index 0000000..a53927f --- /dev/null +++ b/site/assets/hs-matrix-coderain.js @@ -0,0 +1,340 @@ +/* ========================================================================== + Hyperstition Studio — Subtle Basalt-Phosphor Cybernetic Code Rain + Adapted from haiperdohp-jemaytreeah/calc/coderain.js (matrix-font.woff2) + - Three modes: "subtle" (default), "classic" (hyperdope-gematria), "off" + - Peripheral vignette attenuation (-60% behind central .container reading column) + - ~4% leading-droplet cybernetic & Hermetic/occult micro-sigil glints + - Page Visibility API & prefers-reduced-motion guards (Alt+M shortcut) + ========================================================================== */ +(function (root) { + "use strict"; + + var STORAGE_KEY = "hs:matrix-coderain:v1"; + + // Exact 66-code glyph repertoire from haiperdohp-jemaytreeah/calc/coderain.js + var MATRIX_CHARS = [ + 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, + 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, + 54, 55, 56, 57, 36, 43, 45, 42, 47, 61, 37, 34, 39, 35, 38, 95, 40, 41, 44, + 46, 59, 58, 63, 33, 92, 124, 123, 125, 60, 62, 91, 93, 94, 126 + ]; + + // Canonical 8-sigil + mathematical glint vocabulary (verified in DejaVuSansMono.ttf) + var SIGIL_GLINTS = [ + "\u263F", // ☿ Mercury (Ciphers / Ingglish) + "\u260D", // ☍ Opposition / Syzygy (333/666/777 Locks) + "\u2609", // ☉ Solar Monad (Knowledge Graph Apex Hubs) + "\u2644", // ♄ Saturn (Chronos / Time-Series & Cold Archive) + "\u269A", // ⚚ Staff of Hermes (MCP / REST Conduit) + "\u269B", // ⚛ Cybernetic Kernel (Wiener Feedback / EROFS) + "\u25C8", // ◈ Isometric Lattice Node (G4 Fixed Point) + "\u2206", // ∆ Alchemical / Variance-Collapse Delta + "\u2297", // ⊗ Double Articulation (S x S6) + "\u03BB", // λ Church / Z-Combinator Lambda + "\u03A6", // Φ Phonemic Projection + "\u03A9", // Ω Terminal Attractor + "\u221E" // ∞ Recursive Horizon + ]; + + var PROFILES = { + subtle: { + mode: "subtle", + label: "SUBTLE", + hue: 152, + sat: 34, + lit: 24, + fontSizePx: 12.5, + colPitchPx: 24, + stepPx: 13, + frameIntervalMs: 80, + canvasOpacity: 0.45, + fadeFill: "rgba(2, 6, 23, 0.095)", + trailAlphaOuter: 0.24, + trailAlphaCenter: 0.085, + tipAlphaOuter: 0.34, + tipAlphaCenter: 0.14, + resetHorizonPx: 18000, + sigilGlintProb: 0.045 + }, + classic: { + mode: "classic", + label: "CLASSIC", + hue: 148, + sat: 20, + lit: 19, + fontSizePx: 17, + colPitchPx: 15, + stepPx: 20, + frameIntervalMs: 50, + canvasOpacity: 0.72, + fadeFill: "rgba(2, 6, 23, 0.07)", + trailAlphaOuter: 0.52, + trailAlphaCenter: 0.28, + tipAlphaOuter: 0.68, + tipAlphaCenter: 0.40, + resetHorizonPx: 10000, + sigilGlintProb: 0.06 + }, + off: { + mode: "off", + label: "OFF", + canvasOpacity: 0 + } + }; + + function computeColumnAlpha(xPx, widthPx, profile, isTip) { + if (!widthPx || widthPx <= 0) return isTip ? profile.tipAlphaOuter : profile.trailAlphaOuter; + var normX = xPx / widthPx; + // Outer 14% margins on left and right get outer alpha; central 72% reading well is attenuated + var distFromCenter = Math.abs(normX - 0.5) * 2.0; // 0 at center, 1 at edges + var t = Math.max(0, Math.min(1, (distFromCenter - 0.55) / 0.45)); + var centerA = isTip ? profile.tipAlphaCenter : profile.trailAlphaCenter; + var outerA = isTip ? profile.tipAlphaOuter : profile.trailAlphaOuter; + return Number((centerA + (outerA - centerA) * t).toFixed(4)); + } + + function pickRandomGlyph(sigilProb) { + if (sigilProb > 0 && Math.random() < sigilProb) { + return { + ch: SIGIL_GLINTS[Math.floor(Math.random() * SIGIL_GLINTS.length)], + isSigil: true + }; + } + var code = MATRIX_CHARS[Math.floor(Math.random() * MATRIX_CHARS.length)]; + return { + ch: String.fromCharCode(code), + isSigil: false + }; + } + + function initBrowserCodeRain() { + if (typeof document === "undefined" || !document.body) return null; + + var canvas = document.getElementById("hsMatrixCodeRainCanvas"); + if (!canvas) { + canvas = document.createElement("canvas"); + canvas.id = "hsMatrixCodeRainCanvas"; + canvas.setAttribute("aria-hidden", "true"); + document.body.insertBefore(canvas, document.body.firstChild); + } + var ctx = canvas.getContext && canvas.getContext("2d"); + if (!ctx) return null; + + var currentMode = "subtle"; + try { + var saved = window.localStorage.getItem(STORAGE_KEY); + if (saved && PROFILES[saved]) currentMode = saved; + } catch (_e) {} + + var reducedMotion = false; + try { + reducedMotion = !!(window.matchMedia && window.matchMedia("(prefers-reduced-motion: reduce)").matches); + } catch (_e) {} + + var width = 0; + var height = 0; + var cols = 0; + var ypos = []; + var colSpeeds = []; + var rafId = null; + var lastTickTime = 0; + + function setupColumns() { + var prof = PROFILES[currentMode] || PROFILES.subtle; + width = canvas.width = Math.max(320, window.innerWidth || document.documentElement.clientWidth || 1280); + height = canvas.height = Math.max(240, window.innerHeight || document.documentElement.clientHeight || 800); + ctx.fillStyle = "#020617"; + ctx.fillRect(0, 0, width, height); + + if (prof.mode === "off") { + cols = 0; + ypos = []; + colSpeeds = []; + return; + } + cols = Math.floor(width / prof.colPitchPx) + 1; + ypos = new Array(cols); + colSpeeds = new Array(cols); + for (var i = 0; i < cols; i++) { + // Stagger initial positions so only ~35% of streams are initially in-viewport + ypos[i] = Math.random() < 0.35 + ? Math.floor(Math.random() * height) + : -Math.floor(Math.random() * height * 1.6); + colSpeeds[i] = 0.85 + Math.random() * 0.30; + } + } + + function stepFrame() { + var prof = PROFILES[currentMode]; + if (!prof || prof.mode === "off") return; + + ctx.shadowBlur = 0; + ctx.fillStyle = prof.fadeFill; + ctx.fillRect(0, 0, width, height); + + var baseFont = prof.fontSizePx + "px 'matrix-font', 'DejaVu Sans Mono', monospace"; + var sigilFont = (prof.fontSizePx + 0.5) + "px 'DejaVu Sans Mono', monospace"; + + for (var ind = 0; ind < cols; ind++) { + var y = ypos[ind]; + var x = ind * prof.colPitchPx; + if (y >= 0 && y <= height + 30) { + var glyph = pickRandomGlyph(prof.sigilGlintProb); + if (glyph.isSigil) { + var tipA = computeColumnAlpha(x, width, prof, true); + ctx.font = sigilFont; + ctx.fillStyle = "hsla(168, 55%, 48%, " + tipA + ")"; + ctx.fillText(glyph.ch, x, y); + } else { + var trA = computeColumnAlpha(x, width, prof, false); + ctx.font = baseFont; + ctx.fillStyle = "hsla(" + prof.hue + ", " + prof.sat + "%, " + prof.lit + "%, " + trA + ")"; + ctx.fillText(glyph.ch, x, y); + } + } + if (y > 120 + Math.random() * prof.resetHorizonPx) { + ypos[ind] = -Math.floor(Math.random() * 360); + } else { + ypos[ind] = y + prof.stepPx * colSpeeds[ind]; + } + } + } + + function loop(now) { + var prof = PROFILES[currentMode]; + if (!prof || prof.mode === "off" || document.hidden) { + rafId = null; + return; + } + if (!lastTickTime || now - lastTickTime >= prof.frameIntervalMs) { + lastTickTime = now; + stepFrame(); + } + if (!reducedMotion) { + rafId = window.requestAnimationFrame(loop); + } + } + + function updateToggleButtons() { + var prof = PROFILES[currentMode] || PROFILES.subtle; + document.querySelectorAll(".hs-rain-toggle-btn").forEach(function (btn) { + btn.textContent = "\u263F RAIN: " + prof.label; + btn.setAttribute("data-rain-mode", prof.mode); + }); + } + + function applyMode(mode) { + if (!PROFILES[mode]) mode = "subtle"; + currentMode = mode; + var prof = PROFILES[currentMode]; + document.documentElement.setAttribute("data-matrix-coderain", mode); + try { + window.localStorage.setItem(STORAGE_KEY, mode); + } catch (_e) {} + + if (rafId) { + window.cancelAnimationFrame(rafId); + rafId = null; + } + if (mode === "off") { + canvas.style.opacity = "0"; + canvas.style.display = "none"; + } else { + canvas.style.display = "block"; + canvas.style.opacity = String(prof.canvasOpacity); + setupColumns(); + // Pre-warm 8 steps so the initial frame has subtle phosphor trails + for (var wStep = 0; wStep < 8; wStep++) stepFrame(); + if (!reducedMotion && !document.hidden) { + rafId = window.requestAnimationFrame(loop); + } + } + updateToggleButtons(); + } + + function cycleMode() { + var order = ["subtle", "classic", "off"]; + var nextIdx = (order.indexOf(currentMode) + 1) % order.length; + applyMode(order[nextIdx]); + } + + // Inject a compact toggle pill into