feat: redesign UI with themes, animations, procedural ASCII engine
- Split app.py into routes + ascii_engine.py (stdlib-only procedural generation: figlet banners, creatures, patterns, scenes, classics) - API: /api/random?category=..., /api/categories, richer JSON payload - New frontend: templates/index.html + static/ (vanilla JS/CSS) - 4 themes (graphite/paper/phosphor/amber), localStorage persist, no-flash boot, prefers-color-scheme default - Scramble-resolve art transition, reduced-motion support - Responsive: rail collapses to chips <760px, art auto-fits width - Fix grid blowout on mobile (min-width: 0 on stage children) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,556 @@
|
||||
/* ==========================================================================
|
||||
asciigen — terminal instrument UI
|
||||
Themes are token sets on <html data-theme="...">.
|
||||
========================================================================== */
|
||||
|
||||
:root {
|
||||
--font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas,
|
||||
"DejaVu Sans Mono", monospace;
|
||||
--ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
|
||||
--art-base: 15px;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
Theme tokens
|
||||
-------------------------------------------------------------------------- */
|
||||
|
||||
/* graphite — modern dark: warm near-black, bone ink, ember accent */
|
||||
:root,
|
||||
[data-theme="graphite"] {
|
||||
--bg: #101211;
|
||||
--panel: #0a0c0b;
|
||||
--ink: #e9e4d6;
|
||||
--dim: #98937f;
|
||||
--accent: #ff6b35;
|
||||
--accent-ink: #14100c;
|
||||
--line: #2b2f2c;
|
||||
--dot: rgba(233, 228, 214, 0.05);
|
||||
--glow: none;
|
||||
--scan: 0;
|
||||
--sel: rgba(255, 107, 53, 0.28);
|
||||
}
|
||||
|
||||
/* paper — modern light: warm paper, near-black ink, persimmon accent */
|
||||
[data-theme="paper"] {
|
||||
--bg: #f2eee3;
|
||||
--panel: #faf7ee;
|
||||
--ink: #211f18;
|
||||
--dim: #6e6a5c;
|
||||
--accent: #b93a20;
|
||||
--accent-ink: #faf7ee;
|
||||
--line: #d5cfba;
|
||||
--dot: rgba(33, 31, 24, 0.07);
|
||||
--glow: none;
|
||||
--scan: 0;
|
||||
--sel: rgba(185, 58, 32, 0.2);
|
||||
}
|
||||
|
||||
/* phosphor — P1 green terminal */
|
||||
[data-theme="phosphor"] {
|
||||
--bg: #041007;
|
||||
--panel: #020a04;
|
||||
--ink: #46e883;
|
||||
--dim: #2f9e5c;
|
||||
--accent: #46e883;
|
||||
--accent-ink: #041007;
|
||||
--line: #10381e;
|
||||
--dot: rgba(70, 232, 131, 0.05);
|
||||
--glow: 0 0 6px rgba(70, 232, 131, 0.55);
|
||||
--scan: 0.14;
|
||||
--sel: rgba(70, 232, 131, 0.25);
|
||||
}
|
||||
|
||||
/* amber — P3 amber CRT */
|
||||
[data-theme="amber"] {
|
||||
--bg: #150d02;
|
||||
--panel: #0e0801;
|
||||
--ink: #ffb300;
|
||||
--dim: #b57f14;
|
||||
--accent: #ffb300;
|
||||
--accent-ink: #150d02;
|
||||
--line: #453006;
|
||||
--dot: rgba(255, 179, 0, 0.05);
|
||||
--glow: 0 0 6px rgba(255, 179, 0, 0.5);
|
||||
--scan: 0.14;
|
||||
--sel: rgba(255, 179, 0, 0.25);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
Base
|
||||
-------------------------------------------------------------------------- */
|
||||
|
||||
*,
|
||||
*::before,
|
||||
*::after {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
html {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
min-height: 100dvh;
|
||||
font-family: var(--font-mono);
|
||||
font-size: 14px;
|
||||
line-height: 1.5;
|
||||
background-color: var(--bg);
|
||||
/* subtle dot-grid texture */
|
||||
background-image: radial-gradient(var(--dot) 1px, transparent 1px);
|
||||
background-size: 22px 22px;
|
||||
color: var(--ink);
|
||||
transition: background-color 0.25s ease, color 0.25s ease;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
::selection {
|
||||
background: var(--sel);
|
||||
}
|
||||
|
||||
button {
|
||||
font-family: inherit;
|
||||
}
|
||||
|
||||
:focus-visible {
|
||||
outline: 2px dashed var(--accent);
|
||||
outline-offset: 3px;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
Ambient layers: scanlines (CRT themes) + drifting glyphs
|
||||
-------------------------------------------------------------------------- */
|
||||
|
||||
.scan {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 50;
|
||||
pointer-events: none;
|
||||
opacity: var(--scan);
|
||||
background:
|
||||
repeating-linear-gradient(
|
||||
0deg,
|
||||
rgba(0, 0, 0, 0.55) 0 1px,
|
||||
transparent 1px 3px
|
||||
),
|
||||
radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.35) 100%);
|
||||
transition: opacity 0.25s ease;
|
||||
}
|
||||
|
||||
.drift {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 0;
|
||||
pointer-events: none;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.drift span {
|
||||
position: absolute;
|
||||
top: 105%;
|
||||
left: var(--x);
|
||||
font-size: calc(14px * var(--s));
|
||||
color: var(--ink);
|
||||
opacity: 0.07;
|
||||
animation: rise var(--d) linear var(--dl) infinite;
|
||||
text-shadow: var(--glow);
|
||||
}
|
||||
|
||||
@keyframes rise {
|
||||
to {
|
||||
transform: translateY(-130vh) rotate(8deg);
|
||||
}
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
Shell
|
||||
-------------------------------------------------------------------------- */
|
||||
|
||||
.app {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
max-width: 1060px;
|
||||
margin: 0 auto;
|
||||
padding: 0 clamp(16px, 4vw, 40px);
|
||||
min-height: 100dvh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
/* topbar ------------------------------------------------------------------ */
|
||||
|
||||
.topbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
flex-wrap: wrap;
|
||||
padding: 18px 0 14px;
|
||||
border-bottom: 1px solid var(--line);
|
||||
}
|
||||
|
||||
.brand {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.brand-mark {
|
||||
color: var(--accent);
|
||||
font-size: 18px;
|
||||
text-shadow: var(--glow);
|
||||
}
|
||||
|
||||
.brand-name {
|
||||
font-size: 17px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.22em;
|
||||
text-transform: uppercase;
|
||||
text-shadow: var(--glow);
|
||||
}
|
||||
|
||||
.brand-tag {
|
||||
font-size: 11px;
|
||||
color: var(--dim);
|
||||
letter-spacing: 0.08em;
|
||||
}
|
||||
|
||||
.themes {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.theme-btn {
|
||||
width: 26px;
|
||||
height: 26px;
|
||||
padding: 4px;
|
||||
background: transparent;
|
||||
border: 1px solid var(--line);
|
||||
cursor: pointer;
|
||||
transition: border-color 0.15s ease, transform 0.15s var(--ease-out-expo);
|
||||
}
|
||||
|
||||
.theme-btn:hover {
|
||||
transform: translateY(-2px);
|
||||
border-color: var(--dim);
|
||||
}
|
||||
|
||||
.theme-btn.is-active {
|
||||
border-color: var(--accent);
|
||||
}
|
||||
|
||||
.theme-btn .sw {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.theme-btn[data-set-theme="graphite"] .sw { background: linear-gradient(135deg, #101211 55%, #ff6b35 55%); }
|
||||
.theme-btn[data-set-theme="paper"] .sw { background: linear-gradient(135deg, #f2eee3 55%, #b93a20 55%); }
|
||||
.theme-btn[data-set-theme="phosphor"] .sw { background: linear-gradient(135deg, #041007 55%, #46e883 55%); }
|
||||
.theme-btn[data-set-theme="amber"] .sw { background: linear-gradient(135deg, #150d02 55%, #ffb300 55%); }
|
||||
|
||||
/* stage: asymmetric rail + canvas ----------------------------------------- */
|
||||
|
||||
.stage {
|
||||
flex: 1;
|
||||
display: grid;
|
||||
grid-template-columns: 190px minmax(0, 1fr);
|
||||
gap: clamp(24px, 5vw, 56px);
|
||||
align-items: start;
|
||||
padding: clamp(24px, 5vh, 48px) 0;
|
||||
}
|
||||
|
||||
.stage > * {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.rail-label {
|
||||
font-size: 10px;
|
||||
letter-spacing: 0.35em;
|
||||
text-transform: uppercase;
|
||||
color: var(--dim);
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.cats {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
border-left: 1px solid var(--line);
|
||||
}
|
||||
|
||||
.cat {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 9px 12px;
|
||||
background: transparent;
|
||||
border: none;
|
||||
border-left: 2px solid transparent;
|
||||
margin-left: -1px;
|
||||
color: var(--dim);
|
||||
font-size: 13px;
|
||||
letter-spacing: 0.12em;
|
||||
text-transform: uppercase;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
transition: color 0.15s ease, transform 0.2s var(--ease-out-expo),
|
||||
border-color 0.15s ease;
|
||||
}
|
||||
|
||||
.cat:hover {
|
||||
color: var(--ink);
|
||||
transform: translateX(3px);
|
||||
}
|
||||
|
||||
.cat-cursor {
|
||||
opacity: 0;
|
||||
transform: translateX(-4px);
|
||||
transition: opacity 0.15s ease, transform 0.2s var(--ease-out-expo);
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
.cat.is-active {
|
||||
color: var(--ink);
|
||||
border-left-color: var(--accent);
|
||||
}
|
||||
|
||||
.cat.is-active .cat-cursor,
|
||||
.cat:hover .cat-cursor {
|
||||
opacity: 1;
|
||||
transform: translateX(0);
|
||||
}
|
||||
|
||||
.hints {
|
||||
margin-top: 36px;
|
||||
font-size: 11px;
|
||||
color: var(--dim);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
kbd {
|
||||
font-family: inherit;
|
||||
border: 1px solid var(--line);
|
||||
padding: 1px 5px;
|
||||
font-size: 10px;
|
||||
color: var(--ink);
|
||||
}
|
||||
|
||||
/* canvas ------------------------------------------------------------------ */
|
||||
|
||||
.canvas {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.frame {
|
||||
position: relative;
|
||||
background: var(--panel);
|
||||
border: 1px solid var(--line);
|
||||
padding: clamp(18px, 3.5vw, 40px);
|
||||
transition: background-color 0.25s ease, border-color 0.25s ease;
|
||||
}
|
||||
|
||||
.corner {
|
||||
position: absolute;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
border-color: var(--accent);
|
||||
border-style: solid;
|
||||
border-width: 0;
|
||||
}
|
||||
|
||||
.c-tl { top: -1px; left: -1px; border-top-width: 2px; border-left-width: 2px; }
|
||||
.c-tr { top: -1px; right: -1px; border-top-width: 2px; border-right-width: 2px; }
|
||||
.c-bl { bottom: -1px; left: -1px; border-bottom-width: 2px; border-left-width: 2px; }
|
||||
.c-br { bottom: -1px; right: -1px; border-bottom-width: 2px; border-right-width: 2px; }
|
||||
|
||||
.art-scroll {
|
||||
overflow-x: auto;
|
||||
display: grid;
|
||||
justify-items: center;
|
||||
min-height: 240px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
#art {
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--art-base);
|
||||
line-height: 1.25;
|
||||
white-space: pre;
|
||||
text-shadow: var(--glow);
|
||||
}
|
||||
|
||||
/* status readout ----------------------------------------------------------- */
|
||||
|
||||
.status {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 10px;
|
||||
padding: 10px 2px;
|
||||
font-size: 11px;
|
||||
letter-spacing: 0.1em;
|
||||
text-transform: uppercase;
|
||||
color: var(--dim);
|
||||
}
|
||||
|
||||
.st-title {
|
||||
color: var(--ink);
|
||||
}
|
||||
|
||||
.st-msg {
|
||||
margin-left: auto;
|
||||
transition: color 0.2s ease;
|
||||
}
|
||||
|
||||
.st-msg.is-hot {
|
||||
color: var(--accent);
|
||||
text-shadow: var(--glow);
|
||||
}
|
||||
|
||||
/* actions ------------------------------------------------------------------ */
|
||||
|
||||
.actions {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 13px 26px;
|
||||
font-size: 13px;
|
||||
letter-spacing: 0.18em;
|
||||
text-transform: uppercase;
|
||||
background: transparent;
|
||||
color: var(--accent);
|
||||
border: 1px solid var(--accent);
|
||||
border-radius: 0;
|
||||
cursor: pointer;
|
||||
transition: transform 0.18s var(--ease-out-expo), background-color 0.15s ease,
|
||||
color 0.15s ease, box-shadow 0.18s ease;
|
||||
}
|
||||
|
||||
.btn:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 0 -1px var(--accent);
|
||||
}
|
||||
|
||||
.btn:active {
|
||||
transform: translateY(1px) scale(0.98);
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.btn-glyph {
|
||||
transition: transform 0.2s var(--ease-out-expo);
|
||||
}
|
||||
|
||||
.btn:hover .btn-glyph {
|
||||
transform: translateX(3px);
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background: var(--accent);
|
||||
color: var(--accent-ink);
|
||||
}
|
||||
|
||||
.btn[disabled] {
|
||||
opacity: 0.55;
|
||||
cursor: wait;
|
||||
transform: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
/* footer ------------------------------------------------------------------- */
|
||||
|
||||
.foot {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
flex-wrap: wrap;
|
||||
padding: 14px 0 18px;
|
||||
border-top: 1px solid var(--line);
|
||||
font-size: 11px;
|
||||
letter-spacing: 0.08em;
|
||||
color: var(--dim);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
Responsive
|
||||
-------------------------------------------------------------------------- */
|
||||
|
||||
@media (max-width: 760px) {
|
||||
.stage {
|
||||
grid-template-columns: 1fr;
|
||||
gap: 20px;
|
||||
padding-top: 20px;
|
||||
}
|
||||
|
||||
.rail-label {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.cats {
|
||||
flex-direction: row;
|
||||
overflow-x: auto;
|
||||
border-left: none;
|
||||
border-bottom: 1px solid var(--line);
|
||||
padding-bottom: 8px;
|
||||
gap: 4px;
|
||||
scrollbar-width: thin;
|
||||
}
|
||||
|
||||
.cat {
|
||||
border-left: none;
|
||||
border-bottom: 2px solid transparent;
|
||||
margin-left: 0;
|
||||
white-space: nowrap;
|
||||
padding: 7px 10px;
|
||||
}
|
||||
|
||||
.cat.is-active {
|
||||
border-bottom-color: var(--accent);
|
||||
}
|
||||
|
||||
.cat:hover {
|
||||
transform: none;
|
||||
}
|
||||
|
||||
.hints {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.actions {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.btn {
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.art-scroll {
|
||||
min-height: 180px;
|
||||
}
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
Reduced motion
|
||||
-------------------------------------------------------------------------- */
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
*,
|
||||
*::before,
|
||||
*::after {
|
||||
animation-duration: 0.01ms !important;
|
||||
animation-iteration-count: 1 !important;
|
||||
transition-duration: 0.01ms !important;
|
||||
}
|
||||
|
||||
.drift {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user