diff --git a/README.md b/README.md index b62f95b..01cf212 100644 --- a/README.md +++ b/README.md @@ -357,7 +357,7 @@ It plays itself, so all of this is optional. | scroll wheel | zoom | | `Tab` | take the controls / give them back | | `Esc` | give them back | -| `P` | photo mode — freezes the world, you can still look and move | +| `P` or `Space` | photo mode — freezes the world, you can still look and move (also the Pause button in the top bar) | | `1` `2` `3` `4` | world: CyberCity, Frontier, Moonwalk, Edo (gamepad: `Y` / triangle cycles) | | `T` | step the time of day (`Shift`+`T` steps back) | | `Y` | stop / restart the automatic day cycle | @@ -365,7 +365,7 @@ It plays itself, so all of this is optional. | `[` `]` | cycle weather | | `N` | new seed | | `F` | fullscreen | -| `H` | show the controls | +| `?` or `H` | the help screen: every key, the touch gestures, and it pauses the city while open (also Help in the top bar) | The weather presets are `clear, drizzle, rain, downpour, mist, storm` in the city, `blazing, breeze, dust, squall, overcast, thunder` on the frontier, `clear, haze, tsuyu, shower, diff --git a/build.js b/build.js index 93cc2a8..ea7b9e1 100644 --- a/build.js +++ b/build.js @@ -319,11 +319,15 @@ for (const need of ['var CC', 'CC.City', 'CC.Surf', 'CC.Cast', 'CC.Canvas', 'CC. /* The page is black before a single pixel of city is drawn — html, body and canvas all — so that * entering fullscreen never flashes white and never shows a seam at an edge the canvas overhangs. * The hint is CSS-only on purpose: it fades itself out and no JavaScript ever has to know it - * existed, which keeps main.js free of anything resembling UI. */ -/* The baseline head block (description, canonical, Open Graph, JSON-LD) is written into - * index.html by Carino-Systems/baseline/apply.py, between two marker comments. This build - * regenerates index.html from scratch, so it carries that block over from the previous - * output instead of dropping it. */ + * existed, which keeps main.js free of anything resembling UI. Its wording is picked by + * (pointer: coarse) in CSS, so a phone reads "tap" from the first frame. + * + * The fleet chrome sits around the city, never in it: carino-ui.css (tokens and components, + * linked before the page's own style), carino-navbar.js with data-immersive (it slides away in + * fullscreen or after 3 s idle), carino-lang.js + i18n.js, and ui.js, which owns the help + * overlay and the pause button and talks to main.js only through window events. The body is + * Branding's play column: the navbar on top, .play-stage taking every remaining pixel, the + * canvas inside it. None of those files is part of the bundle. */ const PREV = fs.existsSync(OUT) ? fs.readFileSync(OUT, 'utf8') : ''; const BASELINE = (PREV.match(/\n/) || [''])[0]; @@ -336,41 +340,94 @@ const HTML = ` CyberCity -${BASELINE} - + +
+ + +
+
-
click for fullscreen
-Legal +
click for fullscreentap for fullscreen
+
+ ${chunks.map(c => '\n').join('')} + + + + `; diff --git a/carino-clock.js b/carino-clock.js new file mode 100644 index 0000000..1aa9529 --- /dev/null +++ b/carino-clock.js @@ -0,0 +1,115 @@ +/* ============================================================ + carino-clock.js — single source of truth for the Carino navbar clock. + ------------------------------------------------------------ + Hosted at https://carino.systems/carino-clock.js and loaded by every + Carino navbar (the shared carino-navbar.js injects it automatically; + bespoke navbars include it with a + + It injects a compact language button (a language glyph + AUTO, + or the picked code: EN / ES / PT / 日本語 / RU) into the header's + right cluster, left of the Sys. Status control. Clicking it opens + a dropdown: Auto (follow the browser) plus the five languages. + + AUTOMATIC: the language resolves without any user action — + ?lang= in the URL > fleet-wide choice > browser language + > English. + The fleet-wide choice is a cookie on .carino.systems, so one + pick on any subdomain applies to every site in the fleet + (subdomains do NOT share localStorage — the cookie is the only + thing that makes the preference travel). The same choice is + mirrored into per-site localStorage, which is what off-domain + copies (local dev, forks) read, and what keeps the pick alive + on Safari — ITP caps a JS-set cookie at seven days. + + The file owns only the preference. Each app owns its own + dictionary and reacts via: + window.CarinoLang.current // 'en' | 'es' | 'pt-BR' | 'ja' | 'ru' + window.CarinoLang.set(code) // programmatic switch + window.addEventListener('carino:langchange', (e) => e.detail.lang) + An app with no dictionary simply stays English — the choice + still persists for the sites that do translate. + + Self-contained: styles are inlined and scoped under #cnLangBtn / + #cnLangBox with hard-coded colours, so it is safe on light-themed + or Tailwind pages and needs no CDN. + ============================================================ */ +(function () { + 'use strict'; + + var A = '#eab308', BG = '#0f0f0f', BORDER = '#262626', MUTED = '#8a8a8a', TEXT = '#fff'; + var MONO = '"IBM Plex Mono",ui-monospace,SFMono-Regular,Menlo,monospace'; + + // [code, button label, native name] + var LANGS = [ + ['en', 'EN', 'English'], + ['es', 'ES', 'Español'], + ['pt-BR', 'PT', 'Português'], + ['ja', '日本語', '日本語'], + ['ru', 'RU', 'Русский'], + ]; + + var CSS = '' + + '#cnLangBtn{display:flex;align-items:center;gap:6px;background:transparent;border:1px solid ' + BORDER + ';' + + 'color:' + MUTED + ';font-family:' + MONO + ';font-size:.8rem;text-transform:uppercase;letter-spacing:.1em;' + + 'padding:0 10px;height:32px;border-radius:4px;cursor:pointer;transition:.2s;white-space:nowrap;}' + + '#cnLangBtn:hover{border-color:' + A + ';color:' + A + ';background:rgba(234,179,8,.08);}' + + '#cnLangBox{position:fixed;top:56px;right:12px;width:180px;background:' + BG + ';' + + 'border:1px solid ' + BORDER + ';border-radius:8px;padding:6px;box-shadow:0 18px 40px rgba(0,0,0,.6);' + + 'opacity:0;visibility:hidden;transform:translateY(-8px);transition:.18s;z-index:400;}' + + '#cnLangBox.open{opacity:1;visibility:visible;transform:translateY(0);}' + + '#cnLangBox button{display:flex;justify-content:space-between;align-items:center;width:100%;' + + 'background:transparent;border:0;border-radius:5px;padding:7px 10px;cursor:pointer;text-align:left;' + + 'color:' + TEXT + ';font-size:.8rem;}' + + '#cnLangBox button:hover{background:rgba(234,179,8,.08);color:' + A + ';}' + + '#cnLangBox button .code{font-family:' + MONO + ';font-size:.65rem;letter-spacing:.1em;color:' + MUTED + ';}' + // "Русский" is the only Cyrillic on an English page, and it is inside a + // menu nobody has opened yet — enough to pull a whole Cyrillic webfont + // subset down on every first visit in every language. A system face for + // that one label costs nothing and every other row keeps the site's font. + + '#cnLangBox button .nat[lang="ru"]{font-family:system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;}' + + '#cnLangBox button.active{color:' + A + ';}' + + '#cnLangBox button.active .code{color:' + A + ';}'; + + /* ---- resolution ---- */ + + function resolve(tag) { + if (!tag) return null; + var l = String(tag).toLowerCase(); + if (l.indexOf('es') === 0) return 'es'; + if (l.indexOf('pt') === 0) return 'pt-BR'; + if (l.indexOf('ja') === 0) return 'ja'; + if (l.indexOf('ru') === 0) return 'ru'; + if (l.indexOf('en') === 0) return 'en'; + return null; + } + + var onFleet = /(^|\.)carino\.systems$/.test(location.hostname); + + /* Storage is a MIRROR, not an either/or. The parent-domain cookie is the + only thing that carries the choice across subdomains, but Safari's ITP + caps the lifetime of any cookie written from JS at seven days — so on + Safari the fleet-wide pick silently reverted to Auto about once a week, + while Gecko and Chromium honoured the full Max-Age=31536000. localStorage + is not capped that way, so we write both: the cookie for travel, the + localStorage copy as a same-origin backstop. Reads prefer the cookie (it + is the one another subdomain can have just updated) and fall through to + the mirror when it is gone. */ + + function readCookie() { + try { + var m = document.cookie.match(/(?:^|;\s*)carino_lang=([^;]+)/); + return m ? resolve(decodeURIComponent(m[1])) : null; + } catch (e) { return null; } + } + + function readStored() { + var c = onFleet ? readCookie() : null; + if (c) return c; + try { return resolve(localStorage.getItem('carino_lang')); } catch (e) { return null; } + } + + // Secure is added only where it means something: a browser rejects a Secure + // cookie outright from a plain-http origin, so setting it unconditionally + // would throw the preference away on any fleet site still served over http. + var COOKIE = '; Domain=.carino.systems; Path=/; SameSite=Lax' + + (location.protocol === 'https:' ? '; Secure' : ''); + + function store(code) { + if (onFleet) { + try { + document.cookie = 'carino_lang=' + encodeURIComponent(code) + '; Max-Age=31536000' + COOKIE; + } catch (e) { /* cookies blocked */ } + } + try { localStorage.setItem('carino_lang', code); } catch (e) { /* private mode */ } + } + + function clearStore() { + if (onFleet) { + try { + document.cookie = 'carino_lang=; Max-Age=0' + COOKIE; + } catch (e) { /* cookies blocked */ } + } + try { localStorage.removeItem('carino_lang'); } catch (e) { /* private mode */ } + } + + // AUTO is the default: no stored choice means "follow the browser". A + // manual pick stores it fleet-wide; picking Auto again clears it. + var urlLang = resolve(new URLSearchParams(location.search).get('lang')); + if (urlLang) store(urlLang); + var stored = urlLang || readStored(); + var manual = !!stored; + var current = stored || resolve(navigator.language) || 'en'; + document.documentElement.lang = current; + + // Translated and description, written into the page by the fleet + // baseline as <script type="application/json" id="carino-head-i18n">. When + // the URL names the language (?lang=es), the canonical points at that URL + // too, so search engines index each language version as its own page. + var headI18n = null, headOrig = null; + try { + var hi = document.getElementById('carino-head-i18n'); + if (hi) headI18n = JSON.parse(hi.textContent); + } catch (e) { headI18n = null; } + + function headEl(sel) { return document.head && document.head.querySelector(sel); } + + function applyHead() { + if (!headI18n) return; + var desc = headEl('meta[name="description"]'), canon = headEl('link[rel="canonical"]'); + var ogt = headEl('meta[property="og:title"]'), ogd = headEl('meta[property="og:description"]'); + if (!headOrig) { + headOrig = { title: document.title, desc: desc && desc.content, canon: canon && canon.href, + ogt: ogt && ogt.content, ogd: ogd && ogd.content }; + } + var t = headI18n[current]; + document.title = t ? t.title : headOrig.title; + if (desc) desc.content = t ? t.desc : headOrig.desc; + if (ogt) ogt.content = t ? t.title : headOrig.ogt; + if (ogd) ogd.content = t ? t.desc : headOrig.ogd; + if (canon && headOrig.canon) { + var inUrl = resolve(new URLSearchParams(location.search).get('lang')) === current; + canon.href = (t && inUrl) ? headOrig.canon.split('?')[0] + '?lang=' + encodeURIComponent(current) + : headOrig.canon; + } + } + applyHead(); + + // The "language" glyph (A + 文) shown on the button in every state. + var ICON = '<svg viewBox="0 0 24 24" width="13" height="13" fill="currentColor" aria-hidden="true">' + + '<path d="M12.87 15.07l-2.54-2.51.03-.03A17.52 17.52 0 0 0 14.07 6H17V4h-7V2H8v2H1v2h11.17' + + 'C11.5 7.92 10.44 9.75 9 11.35 8.07 10.32 7.3 9.19 6.69 8h-2c.73 1.63 1.73 3.17 2.98 4.56' + + 'l-5.09 5.02L4 19l5-5 3.11 3.11.76-2.04zM18.5 10h-2L12 22h2l1.12-3h4.75L21 22h2l-4.5-12z' + + 'm-2.62 7l1.62-4.33L19.12 17h-3.24z"/></svg>'; + + function set(code) { + if (code === 'auto') { + manual = false; + clearStore(); + current = resolve(navigator.language) || 'en'; + } else { + code = resolve(code) || 'en'; + manual = true; + store(code); + current = code; + } + document.documentElement.lang = current; + applyHead(); + updateBtn(); + renderRows(); + window.dispatchEvent(new CustomEvent('carino:langchange', { detail: { lang: current } })); + } + + function label(code) { + for (var i = 0; i < LANGS.length; i++) if (LANGS[i][0] === code) return LANGS[i][1]; + return 'EN'; + } + + window.CarinoLang = { + get current() { return current; }, + get mode() { return manual ? 'manual' : 'auto'; }, + set: set, + resolve: resolve, + }; + + /* ---- UI ---- */ + + // The shield link to carino.systems/legal.html (#cnLegal) sits in every + // header, shared or bespoke. Its tooltip is translated here, the one script + // all of those headers load, rather than in each site's own dictionary. + var LEGAL = { en: 'Legal notice & privacy', es: 'Aviso legal y privacidad', 'pt-BR': 'Aviso legal e privacidade', + ja: '法的通知とプライバシー', ru: 'Правовая информация и конфиденциальность' }; + + function updateBtn() { + var btn = document.getElementById('cnLangBtn'); + if (btn) btn.innerHTML = ICON + '<span class="lbl">' + (manual ? label(current) : 'AUTO') + '</span>'; + var legal = document.getElementById('cnLegal'); + if (legal) { legal.title = LEGAL[current] || LEGAL.en; legal.setAttribute('aria-label', legal.title); } + } + + function renderRows() { + var box = document.getElementById('cnLangBox'); + if (!box) return; + box.innerHTML = ''; + var auto = document.createElement('button'); + auto.type = 'button'; + auto.className = manual ? '' : 'active'; + auto.innerHTML = '<span>Auto</span><span class="code">' + label(resolve(navigator.language) || 'en') + '</span>'; + auto.addEventListener('click', function (e) { + e.stopPropagation(); + set('auto'); + box.classList.remove('open'); + }); + box.appendChild(auto); + LANGS.forEach(function (l) { + var b = document.createElement('button'); + b.type = 'button'; + b.className = (manual && l[0] === current) ? 'active' : ''; + b.innerHTML = '<span class="nat" lang="' + l[0] + '">' + l[2] + '</span><span class="code">' + l[1] + '</span>'; + b.addEventListener('click', function (e) { + e.stopPropagation(); + set(l[0]); + box.classList.remove('open'); + }); + box.appendChild(b); + }); + } + + function build(right, beforeEl) { + if (document.getElementById('cnLangBtn')) return; + + var style = document.createElement('style'); + style.id = 'carino-lang-style'; + style.textContent = CSS; + document.head.appendChild(style); + + var btn = document.createElement('button'); + btn.id = 'cnLangBtn'; + btn.type = 'button'; + btn.title = 'Language — Auto follows your browser'; + btn.setAttribute('aria-haspopup', 'true'); + + if (beforeEl) right.insertBefore(btn, beforeEl); else right.appendChild(btn); + updateBtn(); + + var box = document.createElement('div'); + box.id = 'cnLangBox'; + document.body.appendChild(box); + renderRows(); + + btn.addEventListener('click', function (e) { + e.stopPropagation(); + box.classList.toggle('open'); + }); + box.addEventListener('click', function (e) { e.stopPropagation(); }); + + // Tap-outside-to-dismiss: WebKit does not bubble a click to document from + // a non-interactive element, so on iOS the document 'click' below never + // fires and the menu stays stuck open. touchend always bubbles, so it is + // the iOS path. Both handlers only ever REMOVE the class, so a desktop + // browser that emits touchend and then click cannot double-fire into a + // reopen. The button and the box stop touchend too, so a tap inside is + // handled by the click handlers rather than closing the menu first. + function dismiss() { box.classList.remove('open'); } + btn.addEventListener('touchend', function (e) { e.stopPropagation(); }); + box.addEventListener('touchend', function (e) { e.stopPropagation(); }); + document.addEventListener('touchend', dismiss); + document.addEventListener('click', dismiss); + document.addEventListener('keydown', function (e) { + if (e.key === 'Escape') box.classList.remove('open'); + }); + } + + // Attach to whichever header exists: TV's native .header-right, or the + // injected navbar's .cn-right (carino-navbar.js). Sit LEFT of Sys. Status. + function tryAttach() { + var nav = document.getElementById('carinoNav'); + if (nav) { + var right = nav.querySelector('.cn-right'); + if (right) { build(right, document.getElementById('cnDiagBtn') || right.querySelector('.social-row')); return true; } + } + var hr = document.querySelector('.header-right'); + if (hr) { build(hr, document.getElementById('diagToggle') || hr.querySelector('.social-row')); return true; } + return false; + } + + function start() { + if (tryAttach()) return; + // The navbar self-injects on DOMContentLoaded; both scripts are deferred + // so order is not guaranteed — watch for it instead of assuming. + var obs = new MutationObserver(function () { + if (tryAttach()) obs.disconnect(); + }); + obs.observe(document.body, { childList: true, subtree: true }); + setTimeout(function () { obs.disconnect(); }, 10000); + } + + if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', start); + else start(); +})(); diff --git a/carino-navbar.js b/carino-navbar.js new file mode 100644 index 0000000..f438fdd --- /dev/null +++ b/carino-navbar.js @@ -0,0 +1,475 @@ +/* ============================================================ + carino-navbar.js — the shared Carino navbar, self-injecting. + ------------------------------------------------------------ + Drop this file into any Carino Systems project and include it: + + <script src="carino-navbar.js" data-app="AppName" data-repo="RepoName" defer></script> + + data-app is the little tag next to the brand; data-repo is the + GitHub repository the header's GitHub button points at. They + differ on the few sites whose repo name is longer than the tag + (Netplan/NetplanConfig, Setup/SimpleSetup, Software/ + SoftwareCatalog, SyncSubs/SyncSubsStudio), so data-repo falls + back to data-app and, failing that, to the profile page. + + It injects its own (scoped) styles + the canonical top-header + markup and runs the greeting. The live CLOCK (Local/UTC/Epoch/ + TAI/.beats + click-to-cycle) lives in the companion file + carino-clock.js, which this script loads from the SAME site — both + files ship together in every project, so there is no external/CDN + dependency and each site works standalone/offline. To change the + clock, edit carino-clock.js and re-copy it to each site (see + propagate.sh). All styles are scoped under #carinoNav so nothing + leaks into (or clashes with) the app. + + The Status diagnostics dropdown lives only on carino.systems + itself — every sub-project's navbar omits it. + + Brand links: "Carino" goes to the hub (carino.systems); the + app-tag next to it links to the app's own root — clicking it + acts as a fresh reload of the current site. + + Right-cluster order is fixed by CSS `order`, not by DOM + position, because four different scripts insert into it and + none of them can rely on the others having run yet. Read it + from the right edge inwards — the socials anchor the row and + language sits immediately beside them: + 1 the app's own controls (.cn-actions) + 2 status (carino-diag.js, or an app's own toggle) + 3 language (carino-lang.js) + 4 legal + GitHub + LinkedIn — always last + + The shield in that last group opens carino.systems/legal.html, the one + legal notice, privacy and cookie page for every site. carino-lang.js + translates its tooltip (it finds the link by its id, #cnLegal). + The legal page itself leaves the shield out. + + Fitting. The brand must never be squeezed out and the clock must stay + readable, at any width. When the right cluster would do either, items + fold into a generated "⋯" menu, in this order: first the legal/GitHub/ + LinkedIn row; then the clock steps aside (as it already does below + 900px), because an app's controls matter more than the time; last, the + app's own controls. Controls marked + data-priority="1" stay in the bar (an app's one main action), and + data-priority="2" ones too while there is room (a Live page's source + badge); without any mark, the first .btn-primary / .primary control + stays. If even those squeeze the brand, priority 2 folds, then 1. The real + nodes move (never clones) and return when there is room again, and the + menu sits inside #carinoNav, so `#carinoNav .cn-actions …` rules still + apply. If an app has moved .cn-actions somewhere else itself (Topo's + drawer), it is left alone. + + Immersive mode (Games and ambient pages). Opt in on the script tag: + <script src="carino-navbar.js" data-app="…" data-immersive defer> + (data-immersive="5000" sets the idle delay in ms; 3000 by default). In + fullscreen, or after that long without the pointer near the top, the bar + slides away; moving the pointer to the top edge, focusing into it or + pressing Esc brings it back. On touch screens it only hides in + fullscreen. Under reduced motion it hides and shows without sliding. + Each change fires `carino:navbar` with detail {hidden}. A page that + needs it only some of the time (Asobi: while a game is open, not on + its scrolling chooser) switches it at run time instead: + window.CarinoNav.immersive(true | false). + ============================================================ */ +(function () { + 'use strict'; + + var SCRIPT = document.currentScript; + var TAG = (SCRIPT && SCRIPT.getAttribute('data-app')) || ''; + // The GitHub button points at THIS project's repository, not the profile. + var REPO = (SCRIPT && SCRIPT.getAttribute('data-repo')) || TAG; + var GH_URL = 'https://github.com/MiguelCarino' + (REPO ? '/' + REPO : ''); + var CLOCK_SRC = 'carino-clock.js'; // local copy shipped in each site (no CDN) + + var CSS = '' + + '#carinoNav{--cn-accent:#eab308;--cn-bg:#050505;--cn-border:#262626;--cn-text:#fff;--cn-muted:#8a8a8a;' + + '--cn-mono:"IBM Plex Mono",ui-monospace,SFMono-Regular,Menlo,monospace;' + + '--cn-sans:"IBM Plex Sans",system-ui,-apple-system,sans-serif;' + + 'height:60px;flex-shrink:0;box-sizing:border-box;background:linear-gradient(180deg,#0f0f0f 0%,#050505 100%);' + + 'border-bottom:1px solid var(--cn-border);display:flex;align-items:center;justify-content:space-between;' + + 'gap:16px;padding:0 20px;position:relative;z-index:2147483000;font-family:var(--cn-sans);}' + + '#carinoNav *,#carinoNav *::before,#carinoNav *::after{box-sizing:border-box;}' + + '#carinoNav .cn-left{display:flex;align-items:center;gap:18px;min-width:0;flex:1 1 auto;overflow:hidden;}' + + '#carinoNav .cn-right{display:flex;align-items:center;gap:10px;flex-shrink:0;}' + + '#carinoNav .brand-name{font-family:"Red Hat Display",var(--cn-sans);font-weight:900;font-size:1.5rem;line-height:1;' + + 'background:linear-gradient(130deg,#fef08a 0%,#eab308 50%,#b45309 100%);-webkit-background-clip:text;background-clip:text;' + + '-webkit-text-fill-color:transparent;text-decoration:none;white-space:nowrap;cursor:pointer;}' + + '#carinoNav .cn-brand{display:flex;align-items:center;flex-shrink:0;}' + + '#carinoNav .app-tag{-webkit-text-fill-color:var(--cn-accent);color:var(--cn-accent);font-family:var(--cn-mono);' + + 'font-size:.6rem;font-weight:700;letter-spacing:.14em;text-transform:uppercase;border:1px solid var(--cn-border);' + + 'border-radius:4px;padding:3px 6px;margin-left:10px;text-decoration:none;transition:.2s;}' + + '#carinoNav .app-tag:hover{border-color:var(--cn-accent);background:rgba(234,179,8,.12);}' + + '#carinoNav .app-tag:empty{display:none;}' + + '#carinoNav .header-clock{display:flex;align-items:baseline;gap:8px;border-left:1px solid var(--cn-border);padding-left:18px;min-width:0;overflow:hidden;cursor:pointer;user-select:none;}' + + '#carinoNav .header-clock:hover .clock-tz{filter:brightness(1.12);}' + + '#carinoNav .clock-time{font-family:var(--cn-mono);font-size:1.05rem;font-weight:700;color:var(--cn-text);flex-shrink:0;}' + + '#carinoNav .clock-tz{font-family:var(--cn-mono);font-size:.58rem;font-weight:700;color:#050505;background:var(--cn-accent);padding:2px 5px;border-radius:3px;flex-shrink:0;}' + + '#carinoNav .brand-greeting{font-family:var(--cn-mono);font-size:.68rem;color:var(--cn-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0;}' + + '#carinoNav .social-row{display:flex;gap:8px;}' + + '#carinoNav .icon-btn{width:32px;height:32px;border:1px solid var(--cn-border);border-radius:4px;display:flex;' + + 'align-items:center;justify-content:center;color:var(--cn-muted);transition:.2s;text-decoration:none;background:transparent;cursor:pointer;}' + + '#carinoNav .icon-btn:hover{border-color:var(--cn-accent);color:#050505;background:var(--cn-accent);transform:translateY(-2px);box-shadow:0 4px 12px rgba(234,179,8,.18);}' + + '#carinoNav .icon-btn svg{width:15px;height:15px;}' + + '#carinoNav .cn-right{gap:12px;min-width:0;}' + + '#carinoNav .cn-actions{display:flex;align-items:center;gap:8px;flex-wrap:nowrap;min-width:0;}' + // Slot order, independent of which script inserted what first. + + '#carinoNav .cn-right > *{order:1;}' + + '#carinoNav .cn-right > #cnDiagBtn,#carinoNav .cn-right > .status-toggle{order:2;}' + + '#carinoNav .cn-right > #cnLangBtn{order:3;}' + + '#carinoNav .cn-right > .social-row{order:4;}' + // The divider only makes sense when something sits to the left of it; + // :only-child covers the sites that ship neither language nor actions. + + '#carinoNav .cn-right > .social-row:not(:only-child){border-left:1px solid var(--cn-border);padding-left:12px;}' + + '@media(max-width:900px){#carinoNav .header-clock{display:none;}}' + + '@media(max-width:640px){#carinoNav .app-tag{display:none;}}' + // Fitting: the "⋯" button and the menu the folded items move into. + + '#carinoNav .cn-right > .cn-keep{order:1;display:flex;align-items:center;gap:8px;}' + + '#carinoNav .cn-right > .cn-more{order:5;}' + + '#carinoNav .cn-more[hidden],#carinoNav .cn-keep:empty{display:none;}' + + '#carinoNav.cn-noclock .header-clock{display:none;}' + + '#carinoNav .cn-more[aria-expanded="true"]:not(:hover){border-color:var(--cn-accent);color:var(--cn-accent);}' + + '#carinoNav .cn-more-menu{position:absolute;top:calc(100% + 6px);right:12px;z-index:3;display:flex;flex-direction:column;' + + 'align-items:stretch;gap:12px;min-width:220px;max-width:min(360px,calc(100vw - 24px));max-height:calc(100dvh - 80px);overflow:auto;' + + 'padding:12px;background:#0b0b0b;border:1px solid rgba(234,179,8,.3);border-radius:8px;box-shadow:0 18px 40px rgba(0,0,0,.7);}' + + '#carinoNav .cn-more-menu[hidden]{display:none;}' + + '#carinoNav .cn-more-menu .cn-actions{flex-wrap:wrap;overflow:visible;gap:8px;}' + + '#carinoNav .cn-more-menu .social-row{border:0;padding:0;margin:0;justify-content:flex-start;}' + + '#carinoNav .cn-more-menu .social-row:not(:first-child){border-top:1px solid var(--cn-border);padding-top:12px;}' + // Immersive: collapse the bar's own height so the stage below takes it. + + '#carinoNav{transition:margin-top .25s ease,opacity .25s ease;}' + + '#carinoNav.cn-immersed{margin-top:-60px;opacity:0;pointer-events:none;}' + + '@media(prefers-reduced-motion:reduce){#carinoNav{transition:none;}}'; + + var GH = 'M9 19c-5 1.5-5-2.5-7-3m14 6v-3.87a3.37 3.37 0 0 0-.94-2.61c3.14-.35 6.44-1.54 6.44-7A5.44 5.44 0 0 0 20 4.77 5.07 5.07 0 0 0 19.91 1S18.73.65 16 2.48a13.38 13.38 0 0 0-7 0C6.27.65 5.09 1 5.09 1A5.07 5.07 0 0 0 5 4.77a5.44 5.44 0 0 0-1.5 3.78c0 5.42 3.3 6.61 6.44 7A3.37 3.37 0 0 0 9 18.13V22'; + var LI = 'M16 8a6 6 0 0 1 6 6v7h-4v-7a2 2 0 0 0-2-2 2 2 0 0 0-2 2v7h-4v-7a6 6 0 0 1 6-6z'; + var SHIELD = 'M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z'; + var LEGAL_URL = 'https://carino.systems/legal.html'; + var LEGAL = 'Legal notice & privacy'; + + var MARKUP = '' + + '<header class="top-header" id="carinoNav">' + + '<div class="cn-left">' + + '<span class="cn-brand">' + + '<a class="brand-name" href="https://carino.systems/" title="Carino Systems — back to hub">Carino</a>' + + '<a class="app-tag" href="./"></a>' + + '</span>' + + '<div class="header-clock">' + + '<span class="clock-time">00:00:00</span>' + + '<span class="clock-tz">LOCAL</span>' + + '<span class="brand-greeting" id="cnGreeting">Ready.</span>' + + '</div></div>' + + '<div class="cn-right">' + + '<div class="social-row">' + + '<a href="' + LEGAL_URL + '" class="icon-btn" id="cnLegal" title="' + LEGAL + '" aria-label="' + LEGAL + '"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="' + SHIELD + '"></path></svg></a>' + + '<a href="' + GH_URL + '" target="_blank" rel="noopener" class="icon-btn" title="' + (REPO ? REPO + ' on GitHub' : 'GitHub') + '" aria-label="GitHub"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="' + GH + '"></path></svg></a>' + + '<a href="https://www.linkedin.com/in/miguelcarino94/" target="_blank" rel="noopener" class="icon-btn" title="LinkedIn" aria-label="LinkedIn"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="' + LI + '"></path><rect x="2" y="9" width="4" height="12"></rect><circle cx="4" cy="4" r="2"></circle></svg></a>' + + '</div>' + + '</div>' + + '</header>'; + + function set(id, v) { var el = document.getElementById(id); if (el) el.textContent = v; } + + // Greeting stays local to the navbar; the clock is owned by carino-clock.js. + // Routed through window.t so the greeting follows the fleet language. + // i18n.js is deferred and may not have run yet, hence the guard; the + // langchange listener re-renders it when the visitor switches language. + function greet() { + var h = new Date().getHours(); + var s = h < 5 ? 'Late shift.' : h < 12 ? 'Good morning.' : h < 18 ? 'Good afternoon.' : 'Good evening.'; + set('cnGreeting', (typeof window.t === 'function') ? window.t(s) : s); + } + window.addEventListener('carino:langchange', greet); + // carino-navbar.js is deferred and executes BEFORE i18n.js, so window.t does + // not exist yet when inject() first calls greet(). Each site's i18n.js adopts + // the fleet locale in its own DOMContentLoaded handler, registered after this + // one — so re-render on a timeout, once every handler has finished. + document.addEventListener('DOMContentLoaded', function () { setTimeout(greet, 0); }); + + function loadClockModule() { + if (document.querySelector('script[data-carino-clock]')) return; + var s = document.createElement('script'); + s.src = CLOCK_SRC; + s.async = true; + s.setAttribute('data-carino-clock', ''); + document.head.appendChild(s); + } + + // Move an app's own header controls INTO the navbar's right cluster so there + // is a single top bar. The real DOM nodes are moved (not cloned), so their + // event handlers and ids are preserved. An app can opt in explicitly with + // [data-carino-actions] (the controls) + [data-carino-strip] (the now-empty + // wrapper to delete); otherwise we auto-detect the leftover `header.cs-header` + // bar that this migration leaves as a direct child of <body>. + function relocateActions(nav) { + var actions = document.querySelector('[data-carino-actions]'); + var strip = document.querySelector('[data-carino-strip]'); + if (!actions) { + var old = document.querySelector('body > header.cs-header'); + if (old) { actions = old.querySelector('.cs-right') || old; strip = old; } + } + if (actions) { + actions.classList.add('cn-actions'); + var right = nav.querySelector('.cn-right'); + right.insertBefore(actions, right.querySelector('.social-row')); + } + if (strip && strip !== actions && strip.parentNode) strip.remove(); + } + + // ---- fitting ---------------------------------------------------------- + // Stage 0: everything in the bar. Stage 1: the socials row folds into the + // menu. Stage 2: the clock steps aside. Stage 3: the app's controls fold + // too, except the kept ones. Stage 4: the kept ones fold as well, since + // the brand comes first. Each stage is tried from 0 upward and the first + // that fits wins. + var fitting = false, fitQueued = false, fitPending = false, fitObserver = null; + + function moreLabel() { return (typeof window.t === 'function') ? window.t('More') : 'More'; } + + function ensureMore(nav) { + var btn = nav.querySelector('.cn-more'); + if (btn) return btn; + btn = document.createElement('button'); + btn.type = 'button'; + btn.className = 'icon-btn cn-more'; + // An SVG like its neighbours, not a text glyph a site's font may lack. + btn.innerHTML = '<svg viewBox="0 0 24 24" fill="currentColor" stroke="none" aria-hidden="true"><circle cx="5" cy="12" r="1.9"></circle><circle cx="12" cy="12" r="1.9"></circle><circle cx="19" cy="12" r="1.9"></circle></svg>'; + btn.hidden = true; + btn.setAttribute('aria-haspopup', 'true'); + btn.setAttribute('aria-expanded', 'false'); + btn.setAttribute('aria-controls', 'cnMoreMenu'); + var menu = document.createElement('div'); + menu.className = 'cn-more-menu'; + menu.id = 'cnMoreMenu'; + menu.hidden = true; + var keep = document.createElement('div'); + // .cn-actions too, so an app's `#carinoNav .cn-actions …` rules still reach a kept control + keep.className = 'cn-keep cn-actions'; + var right = nav.querySelector('.cn-right'); + right.appendChild(keep); + right.appendChild(btn); + nav.appendChild(menu); + function label() { var l = moreLabel(); btn.title = l; btn.setAttribute('aria-label', l); } + label(); + window.addEventListener('carino:langchange', label); + document.addEventListener('DOMContentLoaded', function () { setTimeout(label, 0); }); + function open(on) { + menu.hidden = !on; + btn.setAttribute('aria-expanded', on ? 'true' : 'false'); + } + btn.addEventListener('click', function (e) { e.stopPropagation(); open(menu.hidden); }); + document.addEventListener('click', function (e) { + if (menu.hidden || menu.contains(e.target)) return; + open(false); + }); + // A button or link inside the menu does its job and closes it; form + // fields (selects, inputs) keep it open while they are in use. + menu.addEventListener('click', function (e) { + var hit = e.target.closest && e.target.closest('button,a'); + // a toggle for something nested (a dropdown, a disclosure) keeps it open + if (hit && !hit.closest('select,label') && !hit.hasAttribute('aria-haspopup') && !hit.hasAttribute('aria-expanded')) { + setTimeout(function () { open(false); }, 0); + } + }); + document.addEventListener('keydown', function (e) { + if (e.key === 'Escape' && !menu.hidden) { open(false); btn.focus(); } + }); + return btn; + } + + // Each moved node leaves a comment behind, so it returns to its exact spot. + function park(node, dest) { + if (!node || node.__cnHome) return; + var mark = document.createComment('cn-home'); + node.parentNode.insertBefore(mark, node); + node.__cnHome = mark; + dest.appendChild(node); + } + function unpark(node) { + var mark = node && node.__cnHome; + if (!mark) return; + if (mark.parentNode) mark.parentNode.insertBefore(node, mark), mark.remove(); + node.__cnHome = null; + } + + function keptControls(actions) { + var marked = actions.querySelectorAll('[data-priority="1"],[data-priority="2"]'); + if (marked.length) return Array.prototype.slice.call(marked); + var first = actions.querySelector('.btn-primary,.primary,.cs-btn.primary'); + return first ? [first] : []; + } + + function cramped(nav) { + // Positions, not widths: an app may put its own button before the brand. + var left = nav.querySelector('.cn-left').getBoundingClientRect(); + var brand = nav.querySelector('.cn-brand').getBoundingClientRect(); + if (brand.right > left.right + 1 || brand.right > window.innerWidth) return true; + if (nav.scrollWidth > nav.clientWidth + 1) return true; + var clock = nav.querySelector('.header-clock'); + if (clock && clock.offsetParent !== null && clock.clientWidth + 1 < clock.scrollWidth) { + // the clock may give up its greeting, but never the time itself + var time = clock.querySelector('.clock-time'), tz = clock.querySelector('.clock-tz'); + var need = (time ? time.offsetWidth : 0) + (tz ? tz.offsetWidth : 0) + 26; + if (clock.clientWidth < need) return true; + } + return false; + } + + // Moving a field someone is typing in would drop the caret (and a phone's + // keyboard resizes the window), so wait until focus leaves it. + function typingInNav(nav) { + var a = document.activeElement; + return !!(a && nav.contains(a) && a.matches('input,select,textarea,[contenteditable="true"]')); + } + + function fit() { + var nav = document.getElementById('carinoNav'); + if (!nav || fitting) return; + if (typingInNav(nav)) { fitPending = true; return; } + fitting = true; + try { + var right = nav.querySelector('.cn-right'); + var more = ensureMore(nav); + var menu = nav.querySelector('.cn-more-menu'); + var keep = right.querySelector('.cn-keep'); + var socials = nav.querySelector('.social-row'); + var actions = nav.querySelector('.cn-actions:not(.cn-keep)'); + // An app that moved its controls out of the bar owns them now. + var ownActions = actions && (actions.parentNode === right || actions.parentNode === menu); + // Back to stage 0. + Array.prototype.slice.call(keep.children).forEach(unpark); + if (ownActions) unpark(actions); + unpark(socials); + nav.classList.remove('cn-noclock'); + more.hidden = true; + if (!cramped(nav)) { menu.hidden = true; more.setAttribute('aria-expanded', 'false'); return; } + // Stage 1. + more.hidden = false; + park(socials, menu); + if (!cramped(nav)) return; + // Stage 2. + nav.classList.add('cn-noclock'); + if (!cramped(nav) || !ownActions) return; + // Stage 3: the whole controls block folds, the kept controls stay out. + keptControls(actions).forEach(function (el) { park(el, keep); }); + menu.insertBefore(actions, menu.firstChild); + var mark = document.createComment('cn-home'); + right.insertBefore(mark, keep); + actions.__cnHome = mark; + // Stage 4: the brand comes before even the kept controls: priority 2 + // folds first, then priority 1. + ['2', '1'].forEach(function (rank) { + if (!cramped(nav)) return; + Array.prototype.slice.call(keep.children).forEach(function (el) { + if (el.getAttribute('data-priority') === rank || rank === '1') unpark(el); + }); + }); + } finally { + // The moves above are this function's own; don't let them refit again. + if (fitObserver) fitObserver.takeRecords(); + fitting = false; + } + } + + function queueFit() { + if (fitQueued) return; + fitQueued = true; + requestAnimationFrame(function () { fitQueued = false; fit(); }); + } + + function watchFit(nav) { + window.addEventListener('resize', queueFit); + window.addEventListener('carino:langchange', queueFit); + // carino-lang.js, carino-diag.js and the app add to the bar after this + // runs, and apps show or hide their own controls; refit on any of it. + // Only the right cluster and the menu are watched (the clock ticks every + // second on the left), and text changes are ignored: a live readout in + // an app's controls would otherwise refit on every update. + if (window.MutationObserver) { + ensureMore(nav); + var menuEl = nav.querySelector('.cn-more-menu'), moreEl = nav.querySelector('.cn-more'); + fitObserver = new MutationObserver(function (records) { + if (fitting) return; + // opening and closing the menu is not a change in what has to fit + for (var i = 0; i < records.length; i++) { + if (records[i].target !== menuEl && records[i].target !== moreEl) { queueFit(); return; } + } + }); + var opts = { childList: true, subtree: true, attributes: true, attributeFilter: ['class', 'hidden', 'style'] }; + fitObserver.observe(nav.querySelector('.cn-right'), opts); + fitObserver.observe(nav.querySelector('.cn-more-menu'), opts); + } + if (document.fonts && document.fonts.ready) document.fonts.ready.then(queueFit); + window.addEventListener('load', queueFit); + nav.addEventListener('focusout', function () { + if (fitPending) { fitPending = false; setTimeout(queueFit, 0); } + }); + queueFit(); + } + + // ---- immersive ------------------------------------------------------- + function immersive(nav) { + var enabled = !!(SCRIPT && SCRIPT.hasAttribute('data-immersive')); + var delay = (SCRIPT && parseInt(SCRIPT.getAttribute('data-immersive'), 10)) || 3000; + var coarse = window.matchMedia && window.matchMedia('(pointer: coarse)').matches; + var timer = null, hidden = false; + function set(h) { + if (h === hidden) return; + hidden = h; + nav.classList.toggle('cn-immersed', h); + try { window.dispatchEvent(new CustomEvent('carino:navbar', { detail: { hidden: h } })); } catch (e) {} + } + function busy() { + var menu = nav.querySelector('.cn-more-menu'); + return nav.contains(document.activeElement) || (menu && !menu.hidden) || nav.matches(':hover'); + } + function arm() { + clearTimeout(timer); + if (!enabled || (coarse && !document.fullscreenElement)) return; + timer = setTimeout(function () { if (!busy()) set(true); else arm(); }, document.fullscreenElement ? 1200 : delay); + } + function show() { set(false); arm(); } + window.CarinoNav = window.CarinoNav || {}; + window.CarinoNav.immersive = function (on) { + enabled = !!on; + if (enabled) arm(); else { clearTimeout(timer); set(false); } + }; + document.addEventListener('mousemove', function (e) { + if (!enabled) return; + if (e.clientY < 70) show(); else if (!hidden) arm(); + }, { passive: true }); + nav.addEventListener('focusin', function () { if (enabled) show(); }); + document.addEventListener('keydown', function (e) { if (enabled && e.key === 'Escape') show(); }); + document.addEventListener('fullscreenchange', function () { + if (!enabled) return; + if (document.fullscreenElement) arm(); else show(); + }); + arm(); + } + + function inject() { + if (document.getElementById('carinoNav')) return; + var style = document.createElement('style'); + style.id = 'carino-nav-style'; + style.textContent = CSS; + document.head.appendChild(style); + var wrap = document.createElement('div'); + wrap.innerHTML = MARKUP; + var nav = wrap.firstElementChild; + document.body.insertBefore(nav, document.body.firstChild); + if (TAG) { var t = nav.querySelector('.app-tag'); if (t) { t.textContent = TAG; t.title = TAG + ' — reload'; } } + // On the legal page itself the shield would only link back to this page. + if (/\/legal(\.html)?$/.test(location.pathname)) { + var legal = nav.querySelector('#cnLegal'); + if (legal) legal.remove(); + } + relocateActions(nav); + watchFit(nav); + immersive(nav); + greet(); + setInterval(greet, 60000); + loadClockModule(); + } + + if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', inject); + else inject(); +})(); diff --git a/carino-ui.css b/carino-ui.css new file mode 100644 index 0000000..820f4f0 --- /dev/null +++ b/carino-ui.css @@ -0,0 +1,763 @@ +/* ============================================================ + carino-ui.css — the shared Carino UI: design tokens, base and every + production component. Canonical copy: Branding/carino-ui.css. + Carino-Systems/propagate.sh copies it byte-for-byte into each site, the + same way it copies carino-navbar.js; a site opts in by linking it BEFORE + its own stylesheet. Sites may add new tokens (--kind-*, --cat-*) but never + redefine one declared here. Documented at https://branding.carino.systems/ + ============================================================ */ + /* ============================================================ + Carino Branding — the canonical design tokens & components. + This file IS the reference: view-source, or use the per-section + Copy buttons to lift a snippet into another project. + Hosted at branding.carino.systems. Tokens mirror + Carino-Systems/index.html :root. + ============================================================ */ + :root { + --bg: #050505; /* near-black page background */ + --bg-elev: #0d0d0d; /* elevated surface (inputs, code) */ + --bg-card: #0b0b0b; /* card / panel background */ + --accent: #eab308; /* Sharp Gold — the one accent */ + --accent-faint: rgba(234,179,8,0.05); + --accent-glow: rgba(234,179,8,0.15); + --accent-dim: rgba(234,179,8,0.30); + --border: #262626; /* hairline borders */ + --border-hv: #eab308; /* border on hover/focus */ + --text: #ffffff; /* primary text */ + --text-sec: #a3a3a3; /* secondary text */ + --text-muted: #8a8a8a; /* muted / labels */ + --ok: #22c55e; + --warn: #eab308; + --err: #ef4444; + --info: #38bdf8; /* informational; the fourth toast state, previously a magic number */ + --stage-grad: radial-gradient(1200px 520px at 50% -12%, rgba(234,179,8,0.08) 0%, transparent 60%), linear-gradient(180deg,#0b0b0b 0%,#050505 100%); + --gold-text: linear-gradient(130deg,#fef08a 0%,#eab308 50%,#b45309 100%); + --sans: 'IBM Plex Sans', system-ui, -apple-system, sans-serif; + --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace; + --display: 'Red Hat Display', var(--sans); + --radius: 10px; + --nav-h: 60px; /* carino-navbar.js height; it scrolls with the page */ + /* Breakpoints (media queries cannot read a token, so these are the rule): + 900px and below, a workspace settings rail becomes a drawer; + 640px and below, the phone layout. Nothing else. */ + + /* ---- type scale ---------------------------------------------- + Thirteen named steps and nothing in between: size text with a + token, never a raw value. --fs-micro is the legibility floor — + no UI text below it, ever. Display sizes are fluid (clamp), so + heroes never overflow a laptop. Body base stays 15–16px. + (Decorative glyphs — watermark numerals, emoji, SVG-canvas + labels — may size freely; the scale governs readable text.) + px equivalents assume the 16px root. */ + --fs-micro: 0.6rem; /* 9.6px tiny tags, fine print, table meta */ + --fs-label: 0.65rem; /* 10.4px mono uppercase labels, chips */ + --fs-btn: 0.7rem; /* 11.2px buttons, tabs, kickers, nav */ + --fs-sm: 0.8rem; /* 12.8px dense UI text, tables, alerts, code */ + --fs-mono: 0.85rem; /* 13.6px mono data, ledes in mono */ + --fs-sec: 0.9rem; /* 14.4px secondary prose */ + --fs-body: 1rem; /* 16px primary reading text */ + --fs-lg: 1.05rem; /* 16.8px emphasised body, card titles */ + --fs-h3: 1.2rem; /* 19.2px card / panel headings */ + --fs-h2: 1.5rem; /* 24px section headings */ + --fs-h1: 1.9rem; /* 30.4px page headings */ + --fs-display: 2.4rem; /* 38.4px display text, the wordmark */ + --fs-hero: clamp(2.6rem, 7vw, 4.6rem); /* landing hero — always fluid */ + } + + * { box-sizing: border-box; } + + /* Slim scrollbars in every engine — the cross-browser recipe projects copy. + ::-webkit-scrollbar covers Chromium + WebKit; Firefox has no pseudo-element, + only these two inherited properties, so setting them on :root cascades to + every scroll container. Keep both — neither engine reads the other's. */ + :root { scrollbar-width: thin; scrollbar-color: #3a3a3a transparent; } + ::-webkit-scrollbar { width: 8px; height: 8px; } + ::-webkit-scrollbar-track { background: transparent; } + ::-webkit-scrollbar-thumb { background: #3a3a3a; border-radius: 6px; } + ::-webkit-scrollbar-thumb:hover { background: var(--accent-dim); } + body { + margin: 0; background: var(--bg); color: var(--text); + font-family: var(--sans); font-size: 15px; line-height: 1.6; + -webkit-font-smoothing: antialiased; + } + a { color: var(--accent); } + /* Components below set display:flex/grid; the hidden attribute still wins. */ + [hidden] { display: none !important; } + code, .mono { font-family: var(--mono); } + /* ============ 3. typography ============ */ + .t-hero { font-family: var(--display); font-weight: 900; font-size: var(--fs-hero); text-transform: uppercase; line-height: 0.95; } + .t-display { font-family: var(--display); font-weight: 900; font-size: var(--fs-display); text-transform: uppercase; line-height: 1; } + .t-h1 { font-family: var(--display); font-weight: 900; font-size: var(--fs-h1); text-transform: uppercase; } + .t-h2 { font-family: var(--display); font-weight: 900; font-size: var(--fs-h2); text-transform: uppercase; } + .t-h3 { font-family: var(--display); font-weight: 900; font-size: var(--fs-h3); text-transform: uppercase; } + .t-lg { font-family: var(--sans); font-size: var(--fs-lg); font-weight: 700; color: var(--text); } + .t-body { font-family: var(--sans); font-size: var(--fs-body); color: var(--text); } + .t-sec { font-family: var(--sans); font-size: var(--fs-sec); color: var(--text-sec); } + .t-mono { font-family: var(--mono); font-size: var(--fs-mono); color: var(--text); } + .t-sm { font-family: var(--sans); font-size: var(--fs-sm); color: var(--text-sec); } + .t-btn-sample { font-family: var(--mono); font-size: var(--fs-btn); font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-sec); } + .t-label { font-family: var(--mono); font-size: var(--fs-label); text-transform: uppercase; letter-spacing: 0.14em; color: var(--text-muted); } + .t-micro { font-family: var(--mono); font-size: var(--fs-micro); text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); } + .wordmark { font-family: var(--display); font-weight: 900; font-size: var(--fs-display); background: var(--gold-text); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; } + + /* ============ 4. buttons ============ */ + .btn { + display: inline-flex; align-items: center; gap: 8px; + font-family: var(--mono); font-size: var(--fs-btn); font-weight: 700; + text-transform: uppercase; letter-spacing: 0.06em; + padding: 0 16px; height: 38px; border-radius: 6px; cursor: pointer; + border: 1px solid var(--border); background: transparent; color: var(--text-sec); + transition: 0.18s; text-decoration: none; + } + .btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-faint); } + .btn-primary { background: var(--accent); border-color: var(--accent); color: #050505; } + .btn-primary:hover { background: #fbbf24; color: #050505; box-shadow: 0 4px 16px var(--accent-glow); } + .btn-ghost { border-color: transparent; } + .btn-ghost:hover { border-color: var(--border); background: transparent; color: var(--text); } + .btn:disabled, .btn.disabled { opacity: 0.35; pointer-events: none; } + + /* toggle / segmented buttons (module & template style) */ + .toggle-btn { + font-family: var(--mono); font-size: var(--fs-btn); text-transform: uppercase; letter-spacing: 0.05em; + padding: 8px 14px; border-radius: 4px; cursor: pointer; transition: 0.18s; + border: 1px solid var(--border); background: transparent; color: var(--text-sec); + } + .toggle-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-faint); } + .toggle-btn.active { background: var(--accent); border-color: var(--accent); color: #050505; font-weight: 700; } + + /* ============ 5. tabs ============ */ + .tabbar { display: flex; gap: 4px; border-bottom: 1px solid var(--border); } + .tabbtn { + font-family: var(--mono); font-size: var(--fs-btn); text-transform: uppercase; letter-spacing: 0.06em; + padding: 10px 16px; cursor: pointer; color: var(--text-sec); background: transparent; + border: none; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: 0.15s; + } + .tabbtn:hover { color: var(--text); } + .tabbtn.active { color: var(--accent); border-bottom-color: var(--accent); } + .tabpane { padding: 18px 2px 2px; color: var(--text-sec); font-size: var(--fs-sec); } + + /* ============ 6. forms ============ */ + .field { display: flex; flex-direction: column; gap: 6px; min-width: 220px; } + .field label { font-family: var(--mono); font-size: var(--fs-micro); text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); } + .input, .select, .textarea { + background: var(--bg-elev); border: 1px solid var(--border); border-radius: 6px; + color: var(--text); font-family: var(--mono); font-size: var(--fs-sm); + padding: 9px 11px; width: 100%; transition: 0.15s; + } + .input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-faint); } + .textarea { resize: vertical; min-height: 84px; line-height: 1.5; } + .select option { background: #111; } + .check { display: inline-flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: var(--fs-btn); text-transform: uppercase; color: var(--text-sec); cursor: pointer; } + .check input { accent-color: var(--accent); width: 15px; height: 15px; } + /* switch */ + .switch { position: relative; width: 42px; height: 22px; flex-shrink: 0; } + .switch input { opacity: 0; width: 0; height: 0; } + .switch .track { position: absolute; inset: 0; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 999px; transition: 0.2s; } + .switch .track::before { content: ""; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px; background: var(--text-muted); border-radius: 50%; transition: 0.2s; } + .switch input:checked + .track { background: var(--accent-faint); border-color: var(--accent); } + .switch input:checked + .track::before { transform: translateX(20px); background: var(--accent); } + + /* ============ 7. alerts ============ */ + .alert { border: 1px solid; border-radius: 8px; padding: 12px 14px; font-family: var(--mono); font-size: var(--fs-sm); line-height: 1.5; margin-bottom: 10px; } + .alert:last-child { margin-bottom: 0; } + .alert.ok { color: #86efac; background: rgba(34,197,94,0.08); border-color: rgba(34,197,94,0.5); } + .alert.warn { color: #fcd34d; background: rgba(234,179,8,0.08); border-color: rgba(234,179,8,0.45); } + .alert.err { color: #fca5a5; background: rgba(239,68,68,0.08); border-color: rgba(239,68,68,0.5); } + .alert.info { color: #bae6fd; background: color-mix(in srgb, var(--info) 8%, transparent); border-color: color-mix(in srgb, var(--info) 50%, transparent); } + .alert code { background: #1a1a1a; padding: 1px 5px; border-radius: 3px; color: #fde68a; } + .alert b { color: #fde68a; } + + /* ============ 8. badges & chips ============ */ + .chip-tag { font-family: var(--mono); font-size: var(--fs-micro); font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); border: 1px solid var(--border); border-radius: 4px; padding: 3px 6px; text-decoration: none; } + /* split-brand: in the navbar the chip is an <a href="./"> (app reload) next + to the wordmark's <a href="https://carino.systems/"> (hub) */ + a.chip-tag { transition: 0.2s; } + a.chip-tag:hover { border-color: var(--accent); background: var(--accent-glow); } + .chip-tz { font-family: var(--mono); font-size: var(--fs-micro); font-weight: 700; color: #050505; background: var(--accent); padding: 2px 5px; border-radius: 3px; } + .pill { font-family: var(--mono); font-size: var(--fs-micro); text-transform: uppercase; letter-spacing: 0.05em; border-radius: 999px; padding: 3px 10px; border: 1px solid; } + .pill.ok { color: var(--ok); border-color: rgba(34,197,94,0.4); background: rgba(34,197,94,0.08); } + .pill.warn{ color: var(--warn);border-color: rgba(234,179,8,0.4); background: rgba(234,179,8,0.08); } + .pill.err { color: var(--err); border-color: rgba(239,68,68,0.4); background: rgba(239,68,68,0.08); } + .dot { display: inline-flex; align-items: center; gap: 7px; font-family: var(--mono); font-size: var(--fs-btn); color: var(--text-sec); } + .dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); } + .dot.live::before { animation: pulse 1.6s infinite; } + @keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } } + /* AI Bloat Certified: a two-part seal for the top of a project page. Gold half with the + rosette, dark half with the verdict; one gold hairline around both. */ + .cert-badge { display: inline-flex; align-items: stretch; vertical-align: middle; font-family: var(--mono); font-size: var(--fs-label); font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; line-height: 1; border: 1px solid var(--accent); border-radius: 5px; overflow: hidden; white-space: nowrap; box-shadow: 0 0 14px var(--accent-glow); } + .cert-badge .cert-l { display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px 5px 5px; background: var(--accent); color: #050505; } + .cert-badge .cert-r { display: inline-flex; align-items: center; padding: 5px 9px; background: var(--bg-card); color: var(--accent); } + .cert-badge .cert-seal { width: 15px; height: 15px; flex: none; } + .cert-badge .cert-rosette { fill: #050505; } + .cert-badge .cert-check { fill: none; stroke: var(--accent); stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; } + + /* ============ 9. cards ============ */ + .card { + display: flex; flex-direction: column; background: var(--bg-card); + border: 1px solid var(--border); padding: 22px; border-radius: 12px; transition: 0.22s; + } + .card:hover { border-color: var(--accent); background: linear-gradient(145deg,#17120a 0%,#0b0b0b 100%); transform: translateY(-4px); box-shadow: 0 14px 28px rgba(0,0,0,0.6), 0 0 22px var(--accent-glow); } + .c-title { font-size: var(--fs-lg); font-weight: 700; margin-bottom: 6px; } + .c-desc { font-size: var(--fs-mono); color: var(--text-sec); line-height: 1.6; flex: 1; } + .c-link { margin-top: 16px; font-family: var(--mono); font-size: var(--fs-btn); text-transform: uppercase; letter-spacing: 0.1em; font-weight: 700; color: var(--accent); } + .card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); gap: 14px; } + .panel-header { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 1px solid var(--border); padding-bottom: 14px; } + .panel-title { font-family: var(--display); font-weight: 900; font-size: var(--fs-h1); text-transform: uppercase; letter-spacing: 1px; } + .panel-desc { font-family: var(--mono); font-size: var(--fs-sm); color: var(--text-sec); margin-top: 6px; } + .panel-num { font-family: var(--display); font-weight: 900; font-size: 3.2rem; line-height: 0.8; color: rgba(234,179,8,0.12); user-select: none; } + + /* ============ 10. dropdown / diagnostics ============ */ + .diag-wrap { position: relative; display: inline-block; } + .diag-toggle { + display: inline-flex; align-items: center; gap: 8px; cursor: pointer; + background: transparent; border: 1px solid var(--border); color: var(--text-sec); + font-family: var(--mono); font-size: var(--fs-btn); text-transform: uppercase; letter-spacing: 0.05em; + padding: 8px 12px; border-radius: 6px; transition: 0.18s; + } + .diag-toggle:hover, .diag-toggle.open { border-color: var(--accent); color: var(--accent); background: var(--accent-faint); } + .diag-dropdown { + position: absolute; top: calc(100% + 8px); right: 0; width: 260px; + background: var(--bg-card); border: 1px solid var(--accent-dim); border-radius: 8px; + padding: 14px; box-shadow: 0 18px 40px rgba(0,0,0,0.7); display: none; z-index: 20; + } + .diag-dropdown.open { display: block; } + .diag-section { font-family: var(--mono); font-size: var(--fs-micro); text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); opacity: 0.6; border-bottom: 1px solid var(--border); padding-bottom: 3px; margin: 4px 0 8px; } + .diag-row { display: flex; justify-content: space-between; font-family: var(--mono); font-size: var(--fs-btn); margin-bottom: 6px; } + .diag-lbl { color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; } + .diag-val { color: var(--text); } + /* Wrap two short readings in .diag-pair to put them on one line. Each half + keeps its natural width, so a long value or translation wraps the pair + back into full-width rows instead of truncating. */ + .diag-pair { display: flex; flex-wrap: wrap; justify-content: space-between; column-gap: 20px; } + .diag-pair > .diag-row { flex: 0 1 auto; min-width: max-content; gap: 8px; } + + /* ============ 11. table ============ */ + table.data { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: var(--fs-sm); } + table.data th { text-align: left; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; font-size: var(--fs-micro); font-weight: 700; padding: 8px 12px; border-bottom: 1px solid var(--border); } + table.data td { padding: 9px 12px; border-bottom: 1px solid var(--border); color: var(--text-sec); } + table.data tr:hover td { background: var(--accent-faint); color: var(--text); } + + /* ============ 12. code ============ */ + pre.code { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 8px; padding: 16px; overflow-x: auto; font-family: var(--mono); font-size: var(--fs-sm); line-height: 1.6; color: #e0e0e0; margin: 0; } + pre.code .k { color: var(--accent); } + pre.code .c { color: var(--text-muted); } + + /* ============ 13. loading ============ */ + .spinner { width: 26px; height: 26px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; } + @keyframes spin { to { transform: rotate(360deg); } } + .progress { width: 260px; height: 6px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; } + .progress > span { display: block; height: 100%; width: 62%; background: var(--accent); border-radius: 999px; box-shadow: 0 0 10px var(--accent-glow); } + .ekg { width: 180px; height: 44px; } + .ekg .trace { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 0 4px var(--accent-glow)); stroke-dasharray: 320; stroke-dashoffset: 320; animation: ekg 1.8s linear infinite; } + @keyframes ekg { to { stroke-dashoffset: -320; } } + + + /* ============ 15. toast ============ */ + .toast { + position: fixed; top: 76px; right: 20px; z-index: 9999; + display: inline-flex; align-items: center; gap: 10px; + font-family: var(--mono); font-size: var(--fs-sm); font-weight: 700; + padding: 11px 16px; border-radius: 8px; border: 1px solid; + box-shadow: 0 10px 30px rgba(0,0,0,0.55); + opacity: 0; transform: translateY(-10px); pointer-events: none; transition: 0.2s ease; + } + .toast.show { opacity: 1; transform: translateY(0); pointer-events: auto; } + .toast.ok { color: #86efac; background: rgba(34,197,94,0.10); border-color: rgba(34,197,94,0.5); } + .toast.info { color: #bae6fd; background: color-mix(in srgb, var(--info) 10%, transparent); border-color: color-mix(in srgb, var(--info) 50%, transparent); } + .toast.warn { color: #fde68a; background: rgba(234,179,8,0.10); border-color: rgba(234,179,8,0.45); } + .toast.err { color: #fca5a5; background: rgba(239,68,68,0.10); border-color: rgba(239,68,68,0.5); } + + /* ============ 16. navbar action portal ============ */ + /* carino-navbar.js relocates the real DOM node marked [data-carino-actions] + into the navbar's .cn-right (handlers and ids survive) and removes the + [data-carino-strip] wrapper. Controls riding in the bar follow this 32px + recipe — the compact sibling of .btn. */ + .cs-btn { + display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; + font-family: var(--mono); font-size: var(--fs-label); font-weight: 700; + text-transform: uppercase; letter-spacing: 0.06em; white-space: nowrap; + border: 1px solid var(--border); border-radius: 6px; background: transparent; + color: var(--text-sec); cursor: pointer; transition: 0.18s; text-decoration: none; + } + .cs-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-faint); } + .cs-btn:disabled, .cs-btn.disabled { opacity: 0.35; pointer-events: none; } + /* a toggle that is on (pause, a chosen view, sound) */ + .cs-btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-faint); } + /* the one filled control in the bar: a page's main action */ + .cs-btn.primary { background: var(--accent); border-color: var(--accent); color: #050505; } + .cs-btn.primary:hover { background: #fbbf24; color: #050505; box-shadow: 0 4px 16px var(--accent-glow); } + + /* ---- Export menu: every output of a tool behind one navbar button ---- + <div class="cs-menu"> + <button class="cs-btn" aria-haspopup="true" aria-expanded="false">Export ▾</button> + <div class="cs-menu-panel" role="menu" hidden> + <button class="cs-menu-item" role="menuitem">PDF <span class="cs-menu-note">printable</span></button> + <div class="cs-menu-div"></div> … + </div> + </div> + carino-ui.js opens and closes it. When the navbar folds the controls + into its ⋯ menu, the items show there directly. Reference: Topo. */ + .cs-menu { position: relative; display: flex; } + .cs-caret { font-size: 0.6rem; opacity: 0.7; margin-left: 1px; } + .cs-menu-panel { + position: absolute; top: calc(100% + 6px); right: 0; z-index: 60; min-width: 210px; padding: 6px; + display: flex; flex-direction: column; gap: 1px; + background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 12px 32px rgba(0,0,0,0.55); + } + .cs-menu-item { + display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 10px; border: none; border-radius: 5px; + background: transparent; color: var(--text-sec); font-family: var(--sans); font-size: var(--fs-sm); + text-align: left; white-space: nowrap; cursor: pointer; transition: 0.15s; text-decoration: none; + } + .cs-menu-item:hover, .cs-menu-item:focus-visible { background: var(--accent-faint); color: var(--accent); outline: none; } + .cs-menu-item.danger { color: #fca5a5; } + .cs-menu-item.danger:hover { background: rgba(239,68,68,0.08); color: var(--err); } + .cs-menu-item:disabled { opacity: 0.35; pointer-events: none; } + .cs-menu-note { margin-left: auto; padding-left: 14px; font-family: var(--mono); font-size: var(--fs-micro); color: var(--text-muted); } + .cs-menu-div { height: 1px; background: var(--border); margin: 4px; } + /* On a phone the panel hangs from the screen's right edge, not the + button's, so it never runs off the left side. */ + @media (max-width: 640px) { .cs-menu-panel { position: fixed; top: calc(var(--nav-h) + 6px); right: 12px; } } + #carinoNav .cn-more-menu .cs-menu { flex-basis: 100%; } + #carinoNav .cn-more-menu .cs-menu > [aria-haspopup] { display: none; } + #carinoNav .cn-more-menu .cs-menu-panel, #carinoNav .cn-more-menu .cs-menu-panel[hidden] { + display: flex !important; position: static; min-width: 0; padding: 0; border: 0; box-shadow: none; background: transparent; + } + + /* ============ 17. dropzone ============ */ + .dropzone { + border: 2px dashed var(--border); border-radius: 10px; padding: 30px 18px; + text-align: center; cursor: pointer; background: var(--bg-elev); + color: var(--text-sec); font-size: var(--fs-sec); transition: 0.18s; + } + .dropzone strong { font-family: var(--mono); color: var(--accent); font-weight: 700; } + .dropzone:hover, .dropzone.dragover { border-color: var(--accent); background: var(--accent-faint); box-shadow: 0 0 24px var(--accent-glow); } + .dropzone.success { border-color: var(--ok); border-style: solid; } + .dz-icon { font-size: 1.6rem; margin-bottom: 8px; opacity: 0.8; } + .dz-hint { font-family: var(--mono); font-size: var(--fs-label); color: var(--text-muted); margin-top: 6px; text-transform: uppercase; letter-spacing: 0.08em; } + + /* ============ 18. modal & scrim ============ */ + /* Above the navbar (which sits at 2147483000 to stay over app content), + so a tall dialog's head is never hidden under it. */ + .modal-scrim { + position: fixed; inset: 0; z-index: 2147483600; padding: 24px; + display: flex; align-items: center; justify-content: center; + background: rgba(0,0,0,0.65); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); + } + .modal-scrim[hidden] { display: none; } + /* .modal on a native <dialog>: closed, it stays closed (.modal sets display). */ + dialog.modal:not([open]) { display: none; } + dialog.modal { padding: 0; color: inherit; } + dialog.modal::backdrop { background: rgba(0,0,0,0.65); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); } + .modal { + display: flex; flex-direction: column; width: 100%; max-width: 520px; + max-height: min(90vh, 640px); overflow: hidden; + background: var(--bg-card); border: 1px solid var(--border); border-radius: 14px; + box-shadow: 0 30px 80px rgba(0,0,0,0.75); + } + .modal-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--border); } + /* the title (or the block wrapping title + subtitle) takes the row, so ✕ sits at the end */ + .modal-head > :first-child { flex: 1; min-width: 0; } + .modal-title { font-family: var(--display); font-weight: 900; font-size: var(--fs-lg); text-transform: uppercase; letter-spacing: 0.5px; flex: 1; } + .modal-sub { font-family: var(--mono); font-size: var(--fs-label); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; } + .modal-x { border: none; background: transparent; color: var(--text-muted); font-size: var(--fs-lg); line-height: 1; cursor: pointer; padding: 4px 8px; border-radius: 6px; transition: 0.15s; } + .modal-x:hover { color: var(--accent); background: var(--accent-faint); } + .modal-body { padding: 18px; color: var(--text-sec); font-size: var(--fs-sec); overflow-y: auto; } + .modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--border); } + + /* copy button: the per-section Copy on the reference page and the + floating copy on a command block (.copy-btn.term-copy) */ + .copy-btn { + flex-shrink: 0; display: inline-flex; align-items: center; gap: 6px; + font-family: var(--mono); font-size: var(--fs-micro); font-weight: 700; + text-transform: uppercase; letter-spacing: 0.08em; + padding: 7px 11px; border-radius: 6px; cursor: pointer; white-space: nowrap; + border: 1px solid var(--border); background: transparent; color: var(--text-sec); transition: 0.18s; + } + .copy-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-faint); } + .copy-btn.done { border-color: var(--ok); color: var(--ok); background: rgba(34,197,94,0.08); } + .copy-btn svg { width: 13px; height: 13px; } + + /* ============ 19. command block ============ */ + .terminal-wrapper { position: relative; } + .terminal { background: #000; border: 1px solid var(--border); border-radius: 12px; padding: 1.4rem 1.6rem; overflow-x: auto; } + .terminal code { display: block; font-family: var(--mono); font-size: var(--fs-sm); line-height: 1.7; color: var(--ok); white-space: pre; } + .terminal .prompt { color: var(--accent); user-select: none; } + .term-copy { position: absolute; top: 10px; right: 10px; background: rgba(5,5,5,0.85); } + + /* ============ 21. key caps ============ */ + .kbd { + display: inline-block; font-family: var(--mono); font-size: var(--fs-label); font-weight: 700; + color: var(--text-sec); background: var(--bg-elev); + border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; padding: 2px 7px; + } + .kbd.accent { color: var(--accent); border-color: var(--accent-dim); } + .kbd-legend { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; font-family: var(--mono); font-size: var(--fs-btn); color: var(--text-muted); } + .kbd-legend .lbl { text-transform: uppercase; letter-spacing: 0.06em; } + + + /* ── Data Viz ────────────────────────────────────────────────────────── + Dashboard/monitoring primitives. Gains --ok, losses --err, gold stays the + brand/interactive accent. All figures use tabular-nums via .num. + Reference: Stocks (stocks.carino.systems). */ + .num, .amount { font-variant-numeric: tabular-nums; } + + .stat-tile { border: 1px solid var(--border); border-radius: 6px; background: var(--bg-card); padding: 8px 12px; min-width: 132px; } + .stat-tile .st-label { font-family: var(--mono); font-size: var(--fs-micro); letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); } + .stat-tile .st-value { font-family: var(--mono); font-size: var(--fs-lg); font-weight: 700; margin: 2px 0; } + + /* signed change chip */ + .delta { display: inline-flex; align-items: center; gap: 3px; font-family: var(--mono); font-size: var(--fs-btn); font-weight: 600; padding: 2px 6px; border-radius: 4px; white-space: nowrap; font-variant-numeric: tabular-nums; } + .delta.up { color: var(--ok); background: rgba(34,197,94,0.1); } + .delta.down { color: var(--err); background: rgba(239,68,68,0.1); } + .delta.flat { color: var(--text-muted); background: var(--border); } + + /* dependency-free SVG sparkline; direction class tints line/area/dot */ + .spark { width: 100%; height: 40px; display: block; } + .spark-line { stroke-width: 1.5; vector-effect: non-scaling-stroke; } + .spark-area { fill: currentColor; opacity: 0.08; } + .spark.up .spark-line, .spark.up .spark-dot { stroke: var(--ok); fill: var(--ok); } + .spark.down .spark-line, .spark.down .spark-dot { stroke: var(--err); fill: var(--err); } + .spark.flat .spark-line, .spark.flat .spark-dot { stroke: var(--accent); fill: var(--accent); } + .spark.up .spark-area { color: var(--ok); } .spark.down .spark-area { color: var(--err); } .spark.flat .spark-area { color: var(--accent); } + .spark-dot { stroke: none; } + + /* low→high range bar with a current-value marker */ + .rangebar { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: var(--fs-micro); color: var(--text-muted); font-variant-numeric: tabular-nums; } + .rangebar .rb-track { flex: 1; position: relative; height: 4px; background: var(--border); border-radius: 2px; } + .rangebar .rb-mark { position: absolute; top: -2px; width: 2px; height: 8px; background: var(--accent); border-radius: 1px; box-shadow: 0 0 6px var(--accent-glow); } + + /* threshold rule row: switch + condition + remove */ + .rule-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 5px; } + .rule-row .rule-cond { font-family: var(--mono); font-size: var(--fs-btn); color: var(--text-sec); flex: 1; } + /* scoped to .rule-row so it doesn't collide with the Forms toggle (§05 .switch/.track) */ + .rule-row .switch { width: 34px; height: 18px; border-radius: 9px; background: var(--border); border: none; position: relative; cursor: pointer; flex-shrink: 0; transition: 0.15s; } + .rule-row .switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--text-muted); transition: 0.15s; } + .rule-row .switch.on { background: var(--accent); } .rule-row .switch.on::after { left: 18px; background: #050505; } + .icon-mini { width: 24px; height: 24px; border: 1px solid var(--border); border-radius: 5px; background: transparent; color: var(--text-muted); cursor: pointer; font-size: var(--fs-btn); display: inline-flex; align-items: center; justify-content: center; transition: 0.15s; } + .icon-mini:hover { border-color: var(--accent); color: var(--accent); } + + /* data-freshness chip (extends .dot.live semantics into a labelled pill) */ + .live-chip { font-family: var(--mono); font-size: var(--fs-micro); font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); border: 1px solid var(--border); border-radius: 4px; padding: 3px 6px; white-space: nowrap; } + .live-chip.live { color: var(--ok); border-color: rgba(34,197,94,0.4); } + + /* screenshot-safe privacy blur: toggle body.privacy-on to hide sensitive figures */ + body.privacy-on .amount { filter: blur(6px); } + body.privacy-on .amount:hover { filter: none; } + + + /* ============ 24. finance / currency ============ */ + /* Composite cards from Currency (currency.carino.systems); they reuse the + Data-Viz .spark micro-chart and .delta chip. Gold/green = the target + currency strengthening vs base, red = weakening. */ + .fx-card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 7px; padding: 11px 12px; min-width: 200px; } + .fx-card .fx-top { display: flex; align-items: center; gap: 7px; } + .fx-card .fx-flag { font-size: var(--fs-lg); } + .fx-card .fx-pair { font-family: var(--mono); font-size: var(--fs-btn); color: var(--text); font-weight: 600; } + .fx-card .fx-name { font-family: var(--mono); font-size: var(--fs-micro); color: var(--text-muted); margin-left: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } + .fx-card .fx-rate { font-family: var(--display); font-weight: 700; font-size: var(--fs-h3); margin: 6px 0 2px; } + .fx-card .fx-spark { height: 40px; margin: 4px 0 2px; } + .fx-card .fx-foot { display: flex; align-items: center; justify-content: space-between; } + + .movers { display: flex; flex-wrap: wrap; gap: 8px; } + .mover { flex: 1 1 auto; min-width: 130px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 6px; padding: 8px 11px; } + .mover .mv-l { font-family: var(--mono); font-size: var(--fs-micro); text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); } + .mover .mv-v { font-family: var(--display); font-weight: 700; font-size: var(--fs-sec); margin-top: 2px; display: flex; align-items: baseline; gap: 6px; } + .mover .mv-code { color: var(--text); } + .mover .mv-pct { font-family: var(--mono); font-size: var(--fs-sm); } + .mv-pct.up { color: var(--ok); } .mv-pct.down { color: var(--err); } .mv-pct.flat { color: var(--text-muted); } + + .news-feed { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; } + .news-item { display: block; background: var(--bg-elev); border: 1px solid var(--border); border-left: 2px solid var(--border); border-radius: 6px; padding: 10px 12px; text-decoration: none; color: var(--text); transition: 0.15s; } + .news-item:hover { border-color: var(--accent-dim); border-left-color: var(--accent); } + .news-item.pos { border-left-color: var(--ok); } .news-item.neg { border-left-color: var(--err); } + .news-item .news-title { font-size: var(--fs-sm); line-height: 1.35; margin: 0 0 6px; } + .news-item .news-src { font-family: var(--mono); font-size: var(--fs-micro); color: var(--text-muted); display: flex; gap: 8px; justify-content: space-between; } + .news-item .news-tone { font-weight: 600; } + + /* ============ utilities ============ */ + .gold { color: var(--accent); } + /* shown only where the pointer is a finger (help's touch section) */ + @media (pointer: fine) { .touch-only { display: none !important; } } + .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; } + button.chip-tag { background: transparent; cursor: pointer; transition: 0.2s; } + button.chip-tag:hover, button.chip-tag:focus-visible { border-color: var(--accent); background: var(--accent-glow); outline: none; } + .progress.fluid { width: 100%; } + + /* ============ command block: room for the copy button ============ + The floating Copy sat on top of the command on phones. Desktop + reserves the right edge; a phone gives the button its own band. */ + .terminal-wrapper:has(.term-copy) .terminal { padding-right: 6.5rem; } + /* .band: commands long enough to scroll get the button's own band at + every width, so the text never slides under it. */ + .terminal-wrapper.band:has(.term-copy) .terminal { padding: 3.1rem 1.1rem 1.1rem; } + @media (max-width: 640px) { + .terminal-wrapper:has(.term-copy) .terminal { padding: 3.1rem 1.1rem 1.1rem; } + } + + /* ============ landing hero ============ + The gold-C hero of every landing page (hub, Product, Reference, + Learning overview, a Suite's overview). Reference: dicom.carino.systems. + Top-anchored, and every size is `base + --tall × rate`: --tall is the + height a screen has beyond 900px, so a short screen keeps exactly the + base sizes and a tall one grows continuously, with no breakpoint jump. */ + .landing-hero { + --tall: max(0px, 100vh - 900px); + padding: min(72px, calc(clamp(12px, 2.4vh, 46px) + var(--tall) * .07)) 0 clamp(10px, 2vh, 34px); + text-align: center; + background: radial-gradient(1100px 360px at 50% -12%, rgba(234,179,8,.10), transparent 70%); + } + .lh-wrap { width: min(1040px, 90%); margin: 0 auto; } + .lh-mark { + display: flex; flex-direction: column; align-items: center; justify-content: center; + gap: min(34px, calc(9px + var(--tall) * .05)); + margin: 0 auto min(56px, calc(clamp(3px, .7vh, 12px) + var(--tall) * .11)); + } + .lh-mark .mark { display: block; width: auto; height: min(136px, calc(clamp(19px, 3.5vh, 44px) + var(--tall) * .21)); } + /* optional decorative motif under the mark (dicom's EKG): aria-hidden, + 5:1, gone on phones, still under reduced motion */ + .lh-motif { display: block; width: auto; aspect-ratio: 5 / 1; overflow: visible; height: min(72px, calc(clamp(16px, 3vh, 38px) + var(--tall) * .10)); } + .landing-hero h1 { + font-family: var(--sans); font-weight: 800; line-height: 1.1; letter-spacing: -.01em; margin: 0 0 min(64px, calc(clamp(8px, 1.5vh, 16px) + var(--tall) * .11)); + font-size: min(3.6rem, calc(clamp(1.6rem, 3.6vw + .4vh, 2.7rem) + var(--tall) * .035)); + } + .lh-lede { + color: #d4d4d4; margin: 0 auto 10px; + max-width: min(820px, calc(660px + var(--tall) * .35)); + font-size: min(1.32rem, calc(clamp(.92rem, .55rem + .5vh, 1.05rem) + var(--tall) * .012)); + } + .lh-lede strong { color: var(--text); } + .lh-situations { + list-style: none; padding: 0; text-align: left; color: #cfcfcf; + max-width: min(720px, calc(600px + var(--tall) * .3)); + font-size: min(1.08rem, calc(clamp(.86rem, .5rem + .45vh, .98rem) + var(--tall) * .008)); + margin: 0 auto min(52px, calc(clamp(12px, 2.4vh, 26px) + var(--tall) * .07)); + } + .lh-situations li { padding-left: 1.1em; position: relative; margin: .25em 0; } + .lh-situations li::before { content: "›"; color: var(--accent); position: absolute; left: 0; } + .lh-stats, .sys-line { + font-family: var(--mono); color: var(--text-muted); margin: 0 0 min(28px, calc(clamp(7px, 1.2vh, 14px) + var(--tall) * .035)); + font-size: min(1rem, calc(.78rem + var(--tall) * .008)); + } + .lh-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; } + @media (max-width: 640px) { + .lh-motif { display: none; } + .lh-mark .mark { height: clamp(46px, 13vw, 78px); } + } + + /* ============ short hero ============ + A tool's empty state: it sits IN the work pane (never as a band above + it) and leaves as soon as there is work. Mark, a two-line claim with + the second line gold, a lede of two lines at most, one input target, + example chips, then the privacy line. .rail-head is the compact form + for tools that always open with content (Desk, Password, Aldis). */ + .short-hero { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 14px; max-width: 640px; margin: 0 auto; padding: 40px 16px; } + .short-hero .mark { width: 48px; height: 48px; display: block; } + .short-hero h1 { font-family: var(--sans); font-weight: 800; font-size: var(--fs-h1); line-height: 1.15; letter-spacing: -.01em; margin: 0; } + .sh-lede { color: var(--text-sec); font-size: var(--fs-sec); line-height: 1.55; max-width: 52ch; margin: 0; } + .sh-input { width: 100%; } + .short-hero.rail-head { flex-direction: row; align-items: center; text-align: left; gap: 12px; max-width: none; margin: 0; padding: 0 0 14px; border-bottom: 1px solid var(--border); } + .short-hero.rail-head .mark { width: 32px; height: 32px; flex: none; } + .short-hero.rail-head h1 { font-size: var(--fs-h3); } + .short-hero.rail-head .sh-lede { font-size: var(--fs-sm); } + + /* example chips: the empty state's second door — "Try: …" */ + .examples { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; } + .examples .ex-label { font-family: var(--mono); font-size: var(--fs-label); text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); margin-right: 2px; } + + /* ============ privacy line ============ + Required on Tool, Suite, Learning and Product pages. Canonical wording + (an i18n key, shared fleet-wide): "Runs in your browser. Nothing you add + here is uploaded." Any outside request is named in the same line as a + .pl-also clause — the line must be literally true. */ + /* Block, not flex: a sentence and its .pl-also clause flow as one paragraph. */ + .privacy-line { display: block; margin: 0; padding-left: 20px; text-indent: -20px; font-family: var(--mono); font-size: var(--fs-label); line-height: 1.55; color: var(--text-muted); text-align: left; } + /* Inline with a hanging indent, so the lock stays on the first line + whatever padding a page gives the line. */ + .privacy-line::before { + content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 8px; vertical-align: -1px; background: var(--ok); + -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4' y='11' width='16' height='10' rx='2'/%3E%3Cpath d='M8 11V7a4 4 0 0 1 8 0v4'/%3E%3C/svg%3E") center / contain no-repeat; + mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4' y='11' width='16' height='10' rx='2'/%3E%3Cpath d='M8 11V7a4 4 0 0 1 8 0v4'/%3E%3C/svg%3E") center / contain no-repeat; + } + .privacy-line .pl-also { color: var(--text-sec); } + .short-hero .privacy-line { display: inline-block; text-align: left; } + + /* ============ workspace shell ============ + Tool chrome: a 340px settings rail on the LEFT, scrolling on its own, + beside a fluid pane. At 900px and below the rail becomes a drawer + opened by a [data-ws-toggle] button (carino-ui.js wires it). Use .col + for tools with three settings or fewer: one centred 900px column. */ + .ws { display: flex; min-height: calc(100dvh - var(--nav-h)); background: var(--bg); } + .ws-rail { + width: 340px; flex: none; display: flex; flex-direction: column; gap: 14px; padding: 16px; + background: var(--bg-card); border-right: 1px solid var(--border); overflow-y: auto; + } + .ws-rail-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); } + .ws-rail .field { min-width: 0; } + .ws-pane { flex: 1; min-width: 0; overflow: auto; padding: 20px; } + .ws-toggle { display: none; } + .ws-scrim { display: none; } + .col { width: min(900px, 100%); margin: 0 auto; padding: 24px 16px 48px; display: flex; flex-direction: column; gap: 16px; } + @media (max-width: 900px) { + .ws-toggle { display: inline-flex; } + .ws-rail { + position: fixed; top: var(--nav-h); bottom: 0; left: 0; z-index: 1001; width: min(340px, 86vw); + transform: translateX(-100%); transition: transform 0.22s ease; + } + /* the shadow only while open: closed, it would bleed onto the page edge */ + .ws.drawer-open .ws-rail { transform: none; box-shadow: 0 0 40px rgba(0,0,0,0.6); } + .ws.drawer-open .ws-scrim { display: block; position: fixed; inset: var(--nav-h) 0 0 0; z-index: 1000; background: rgba(0,0,0,0.55); } + .ws-pane { padding: 16px; } + /* .ws-stack: the rail stacks above the pane instead of becoming a + drawer — for suites whose files-in sits in the rail (dcm, Media). */ + .ws.ws-stack { flex-direction: column; min-height: 0; } + .ws.ws-stack .ws-rail { position: static; transform: none; width: auto; box-shadow: none; border-right: 0; border-bottom: 1px solid var(--border); overflow: visible; } + .ws.ws-stack .ws-pane { overflow: visible; } + .ws.ws-stack .ws-toggle { display: none; } + } + @media (max-width: 900px) and (prefers-reduced-motion: reduce) { .ws-rail { transition: none; } } + + /* ============ slice menu ============ + A Suite's (and Learning's) module chooser. Overview: full slices that + widen on hover. .collapsed (or body.state-module): a 44px bar sticky at + the top of the page while a module is open. Phones stack the overview + and show the bar as labels only, equal width, scrolling sideways when + there are more than four. carino-ui.js has the #module router. */ + .slice-menu { display: flex; min-height: 200px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: #060606; } + .slice-menu .slice { + flex: 1; min-width: 0; position: relative; display: flex; flex-direction: column; justify-content: flex-end; gap: 4px; + padding: 16px; border: 0; border-right: 1px solid var(--border); background: #060606; color: var(--text); + font: inherit; text-align: left; text-decoration: none; cursor: pointer; transition: 0.25s; + } + .slice-menu .slice:last-child { border-right: none; } + .slice-menu .slice::before { content: ""; position: absolute; inset: 0; background: radial-gradient(400px 180px at 50% 120%, var(--accent-glow) 0%, transparent 70%); opacity: 0; transition: 0.25s; pointer-events: none; } + .slice-menu .slice:hover, .slice-menu .slice:focus-visible { flex: 1.6; background: #0a0a0a; outline: none; } + .slice-menu .slice:hover::before, .slice-menu .slice:focus-visible::before { opacity: 1; } + .slice .s-num { font-family: var(--display); font-weight: 900; font-size: 1.8rem; line-height: 1; color: rgba(234,179,8,0.2); } + .slice .s-text { font-family: var(--display); font-weight: 900; text-transform: uppercase; font-size: var(--fs-sec); letter-spacing: 0.5px; } + .slice .s-blurb { font-size: var(--fs-sm); color: var(--text-sec); line-height: 1.45; } + .slice-menu.collapsed, body.state-module .slice-menu { + position: sticky; top: 0; z-index: 40; min-height: 0; height: 44px; border-radius: 0; border-width: 0 0 1px; + } + .slice-menu.collapsed .slice, body.state-module .slice-menu .slice { flex-direction: row; align-items: center; justify-content: center; gap: 10px; padding: 0 12px; } + .slice-menu.collapsed .slice:hover, body.state-module .slice-menu .slice:hover { flex: 1; } + .slice-menu.collapsed .s-num, body.state-module .slice-menu .s-num { font-size: var(--fs-body); color: rgba(234,179,8,0.35); } + .slice-menu.collapsed .s-text, body.state-module .slice-menu .s-text { font-size: var(--fs-btn); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } + .slice-menu.collapsed .s-blurb, body.state-module .slice-menu .s-blurb { display: none; } + .slice-menu .slice.active { background: #0a0a0a; box-shadow: inset 0 2px 0 var(--accent); } + .slice-menu .slice.active .s-text { color: var(--accent); } + @media (max-width: 640px) { + .slice-menu:not(.collapsed) { flex-direction: column; } + body.state-module .slice-menu { flex-direction: row; } + .slice-menu:not(.collapsed) .slice { flex: none; min-height: auto; border-right: none; border-bottom: 1px solid var(--border); } + body.state-module .slice-menu .slice { flex: 1 0 auto; min-height: 0; border-bottom: none; border-right: 1px solid var(--border); } + .slice-menu.collapsed, body.state-module .slice-menu { overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; } + .slice-menu.collapsed .slice, body.state-module .slice-menu .slice, + .slice-menu.collapsed .slice:hover, body.state-module .slice-menu .slice:hover { flex: 1 0 25%; scroll-snap-align: start; padding: 0 8px; } + .slice-menu.collapsed .s-num, body.state-module .slice-menu .s-num { display: none; } + } + @media (prefers-reduced-motion: reduce) { .slice-menu .slice, .slice-menu .slice::before { transition: none; } .slice-menu .slice:hover { flex: 1; } } + + /* ============ filter chips ============ + A Reference page's first control: a sticky bar of facet chips, one + radio group per facet (click again to clear), a Clear chip once any is + on and the "N shown" count. One line that scrolls sideways on phones. + A search box never comes first; past ~300 entries a Find may follow + the chips. Reference: Law. */ + .fchips { + position: sticky; top: 0; z-index: 50; display: flex; flex-wrap: wrap; align-items: center; gap: 7px; + padding: 10px 0; background: rgba(5,5,5,0.88); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); + border-bottom: 1px solid var(--border); font-family: var(--mono); font-size: var(--fs-label); + } + .fchip-lbl { color: var(--text-muted); letter-spacing: 0.08em; text-transform: uppercase; font-size: var(--fs-micro); } + .fchip { + border: 1px solid var(--border); border-radius: 20px; padding: 4px 10px; background: transparent; color: var(--text-sec); + font-family: var(--mono); font-size: var(--fs-label); white-space: nowrap; cursor: pointer; transition: 0.15s; + } + .fchip:hover, .fchip:focus-visible { border-color: var(--accent); color: var(--accent); outline: none; } + .fchip.active, .fchip[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-faint); } + .fchip.clear { border-style: dashed; } + /* a rule, not a "·": on a wrapping bar a glyph ends up orphaned at a line end */ + .fchip-sep { width: 1px; height: 15px; background: var(--border); margin: 0 2px; flex: none; } + .fchips-count { margin-left: auto; color: var(--text-muted); white-space: nowrap; } + @media (max-width: 640px) { + .fchips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; } + .fchips::-webkit-scrollbar { display: none; } + } + + /* ============ entry card + source line ============ + The dense card of a Reference page: left-aligned, no lift on hover, + a two-line description, badges, and a source line at its foot. */ + .card.entry { padding: 14px 16px; gap: 6px; border-radius: 10px; } + .card.entry:hover { transform: none; box-shadow: none; background: var(--bg-card); } + .e-title { font-weight: 700; font-size: var(--fs-lg); line-height: 1.3; } + .e-sub { font-family: var(--mono); font-size: var(--fs-label); color: var(--text-muted); } + .e-desc { font-size: var(--fs-sm); color: var(--text-sec); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; } + .e-badges { display: flex; flex-wrap: wrap; gap: 5px; } + .card.entry .src-line { margin-top: auto; padding-top: 8px; border-top: 1px solid var(--border); } + /* "Source: domain ↗ · checked YYYY-MM" — every entry carries one */ + .src-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-family: var(--mono); font-size: var(--fs-label); color: var(--text-muted); } + .src-line a { color: var(--text-sec); text-decoration: none; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; } + .src-line a:hover { color: var(--accent); border-color: var(--accent); } + .src-line .src-date { white-space: nowrap; } + .pill.muted { color: var(--text-muted); border-color: var(--border); background: transparent; } + + /* ============ live data: freshness ============ + .live-chip is the source badge; each state looks different, and none + is silent. .fresh is the "Updated 15:49:13" stamp beside it, .is-stale + dims a panel still showing its last good copy. */ + .live-chip.delayed, .live-chip.stale { color: var(--warn); border-color: rgba(234,179,8,0.45); } + .live-chip.err { color: var(--err); border-color: rgba(239,68,68,0.5); } + .live-chip.paused { color: var(--text-muted); border-style: dashed; } + .live-chip.sample { color: var(--info); border-color: color-mix(in srgb, var(--info) 50%, transparent); } + .fresh { display: inline-flex; align-items: center; gap: 7px; font-family: var(--mono); font-size: var(--fs-label); color: var(--text-sec); white-space: nowrap; font-variant-numeric: tabular-nums; } + .fresh::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); } + .fresh.stale::before { background: var(--warn); } + .fresh.err::before { background: var(--err); } + .fresh.paused::before { background: var(--text-muted); } + .is-stale .num, .is-stale .st-value, .is-stale .spark { opacity: 0.5; } + .stale-note { font-family: var(--mono); font-size: var(--fs-label); color: var(--warn); } + /* the one-line source footer of a Live page */ + .data-foot { font-family: var(--mono); font-size: var(--fs-label); color: var(--text-muted); line-height: 1.6; padding: 10px 0; border-top: 1px solid var(--border); } + + /* ============ lab ============ + Learning's "something you try". Inline form sits in the page at the + stage it teaches; the step player walks an algorithm one step at a + time (Play · Step · Back · Reset · speed), keyboard Space and ←/→. */ + .lab { border: 1px solid var(--accent-dim); border-radius: var(--radius); background: var(--bg-card); padding: 18px; display: flex; flex-direction: column; gap: 12px; } + .lab-kicker { font-family: var(--mono); font-size: var(--fs-label); text-transform: uppercase; letter-spacing: 0.14em; color: var(--accent); } + .lab h3 { font-family: var(--display); font-weight: 900; font-size: var(--fs-h3); text-transform: uppercase; margin: 0; } + .lab-blurb { color: var(--text-sec); font-size: var(--fs-sec); margin: 0; } + .lab-mount { min-height: 120px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-elev); padding: 14px; min-width: 0; overflow-x: auto; } + .step-player { display: flex; flex-direction: column; gap: 10px; } + .sp-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; } + .sp-count { margin-left: auto; font-family: var(--mono); font-size: var(--fs-sm); color: var(--text-sec); font-variant-numeric: tabular-nums; } + .sp-stage { border: 1px solid var(--border); border-radius: 8px; background: #000; padding: 14px; font-family: var(--mono); font-size: var(--fs-sm); color: var(--text); overflow-x: auto; } + .sp-stage .hot { color: var(--accent); } + /* overall progress for a course: "12 / 40 steps · 30%" */ + .progress-pill { display: inline-flex; align-items: center; gap: 10px; font-family: var(--mono); font-size: var(--fs-label); color: var(--text-sec); border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px; font-variant-numeric: tabular-nums; } + .progress-pill .progress { width: 90px; height: 5px; } + + /* ============ footer ============ + Hub, Reference, Learning and Product pages end in one. Links are + short and mono; the line below names licence and source honestly. */ + .site-foot { border-top: 1px solid var(--border); padding: 18px 0 28px; display: flex; flex-direction: column; gap: 8px; font-family: var(--mono); font-size: var(--fs-label); color: var(--text-muted); } + .sf-links { display: flex; flex-wrap: wrap; gap: 6px 16px; } + .sf-links a { color: var(--text-sec); text-decoration: none; } + .sf-links a:hover { color: var(--accent); } + .sf-line { line-height: 1.6; } + + /* ============ play stage ============ + Games and ambient pieces: the body is a column, the navbar on top and + the stage taking every remaining pixel (never top:60px offsets). The + dock is the optional floating control bar. Help and pause use .modal. */ + body.play-body { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; } + .play-stage { flex: 1; min-height: 0; position: relative; overflow: hidden; background: var(--bg); } + .play-stage > canvas { display: block; width: 100%; height: 100%; } + .play-dock { + position: absolute; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 20; + display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; padding: 6px; + background: rgba(5,5,5,0.82); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); + border: 1px solid var(--border); border-radius: 10px; max-width: calc(100% - 16px); + } + @media (max-width: 640px) { .play-dock { left: 8px; right: 8px; transform: none; } } diff --git a/carino-ui.js b/carino-ui.js new file mode 100644 index 0000000..77c4010 --- /dev/null +++ b/carino-ui.js @@ -0,0 +1,133 @@ +/* ============================================================ + carino-ui.js — the behaviour half of carino-ui.css. + Canonical copy: Branding/carino-ui.js; Carino-Systems/propagate.sh + copies it into each site. Load it deferred, after carino-navbar.js: + <script src="carino-ui.js" defer></script> + + Three pieces, all opt-in by markup, so loading the file on a page that + uses none of them does nothing: + + 1. Workspace drawer. Below 900px .ws-rail is an off-canvas drawer. + Any [data-ws-toggle] button opens and closes it; the scrim, Esc and + growing past 900px close it. The scrim is created here. + + 2. Slice router. A Suite's (or Learning's) modules are addressable as + #<module>, with extra parameters after "&": #edit&sample=ct, and a + place inside a module after "/": #sha2/stage-3 (as params.path). + CarinoUI.slices({ + menu: document.querySelector('.slice-menu'), // .slice[data-id] inside + onRoute(id, params) { … }, // id null = overview + collapsed: true, // optional: start collapsed (modules share one input) + }); + Clicking a slice only sets location.hash; hashchange drives + everything, so Back, bookmarks and shared links all land right. + It keeps body.state-overview / body.state-module and .active in step. + + 3. Export menu. Every .cs-menu: its [aria-haspopup] button opens the + .cs-menu-panel; choosing an item, clicking away or Esc closes it. + Items keep their own handlers; the menu only governs visibility. + ============================================================ */ +(function () { + 'use strict'; + var WS_MQ = window.matchMedia('(max-width: 900px)'); + + function initDrawer(ws) { + if (ws.dataset.wsReady) return; + ws.dataset.wsReady = '1'; + var scrim = ws.querySelector('.ws-scrim'); + if (!scrim) { + scrim = document.createElement('div'); + scrim.className = 'ws-scrim'; + ws.appendChild(scrim); + } + var toggles = function () { + return document.querySelectorAll('[data-ws-toggle]'); + }; + function set(open) { + ws.classList.toggle('drawer-open', open); + toggles().forEach(function (b) { b.setAttribute('aria-expanded', open ? 'true' : 'false'); }); + } + // Delegated, so a toggle the navbar relocates (data-carino-actions) keeps working. + document.addEventListener('click', function (e) { + var t = e.target.closest && e.target.closest('[data-ws-toggle]'); + if (t) { e.preventDefault(); set(!ws.classList.contains('drawer-open')); } + }); + scrim.addEventListener('click', function () { set(false); }); + window.addEventListener('keydown', function (e) { if (e.key === 'Escape') set(false); }); + var onMq = function () { if (!WS_MQ.matches) set(false); }; + if (WS_MQ.addEventListener) WS_MQ.addEventListener('change', onMq); + else if (WS_MQ.addListener) WS_MQ.addListener(onMq); // older Safari + set(false); + } + + function parseHash() { + var raw = decodeURIComponent(location.hash.replace(/^#/, '')); + var parts = raw.split('&'); + var params = {}; + // A path inside a module (#hash-family/stage-3, #module/lab) travels as + // params.path; the module id is what comes before the first "/". + var slash = parts[0].indexOf('/'); + if (slash >= 0) { params.path = parts[0].slice(slash + 1); parts[0] = parts[0].slice(0, slash); } + parts.slice(1).forEach(function (p) { + if (!p) return; + var i = p.indexOf('='); + if (i < 0) params[p] = true; + else params[p.slice(0, i)] = p.slice(i + 1); + }); + return { id: parts[0] || null, params: params }; + } + + function slices(opts) { + var menu = opts && opts.menu; + if (!menu) return null; + var ids = function () { + return Array.prototype.map.call(menu.querySelectorAll('.slice[data-id]'), function (s) { return s.dataset.id; }); + }; + menu.addEventListener('click', function (e) { + var s = e.target.closest && e.target.closest('.slice[data-id]'); + if (!s) return; + e.preventDefault(); + if (parseHash().id !== s.dataset.id) location.hash = '#' + s.dataset.id; + }); + function route() { + var h = parseHash(); + var id = ids().indexOf(h.id) >= 0 ? h.id : null; + document.body.classList.toggle('state-module', !!id); + document.body.classList.toggle('state-overview', !id); + menu.classList.toggle('collapsed', !!id || !!opts.collapsed); + Array.prototype.forEach.call(menu.querySelectorAll('.slice[data-id]'), function (s) { + var on = s.dataset.id === id; + s.classList.toggle('active', on); + if (on) s.setAttribute('aria-current', 'page'); else s.removeAttribute('aria-current'); + if (on && s.scrollIntoView && menu.scrollWidth > menu.clientWidth) s.scrollIntoView({ block: 'nearest', inline: 'center' }); + }); + if (typeof opts.onRoute === 'function') opts.onRoute(id, h.params); + } + window.addEventListener('hashchange', route); + route(); + return { route: route, go: function (id) { location.hash = id ? '#' + id : '#'; } }; + } + + function initMenu(m) { + if (m.dataset.menuReady) return; + m.dataset.menuReady = '1'; + var btn = m.querySelector('[aria-haspopup]'), panel = m.querySelector('.cs-menu-panel'); + if (!btn || !panel) return; + var isOpen = function () { return !panel.hidden; }; + function set(open) { panel.hidden = !open; btn.setAttribute('aria-expanded', open ? 'true' : 'false'); } + btn.addEventListener('click', function (e) { e.stopPropagation(); set(!isOpen()); }); + panel.addEventListener('click', function (e) { if (e.target.closest('.cs-menu-item')) set(false); }); + document.addEventListener('click', function (e) { if (isOpen() && !m.contains(e.target)) set(false); }); + window.addEventListener('keydown', function (e) { if (e.key === 'Escape' && isOpen()) { set(false); btn.focus(); } }); + set(false); + } + + function boot() { + Array.prototype.forEach.call(document.querySelectorAll('.ws'), initDrawer); + Array.prototype.forEach.call(document.querySelectorAll('.cs-menu'), initMenu); + } + if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', boot); + else boot(); + + window.CarinoUI = { slices: slices, drawer: initDrawer, menu: initMenu, parseHash: parseHash }; +})(); diff --git a/fonts/IBMPlexMono-400-cyrillic.woff2 b/fonts/IBMPlexMono-400-cyrillic.woff2 new file mode 100644 index 0000000..20e72b0 Binary files /dev/null and b/fonts/IBMPlexMono-400-cyrillic.woff2 differ diff --git a/fonts/IBMPlexMono-400-latin-ext.woff2 b/fonts/IBMPlexMono-400-latin-ext.woff2 new file mode 100644 index 0000000..732c64d Binary files /dev/null and b/fonts/IBMPlexMono-400-latin-ext.woff2 differ diff --git a/fonts/IBMPlexMono-400-latin.woff2 b/fonts/IBMPlexMono-400-latin.woff2 new file mode 100644 index 0000000..0804aaf Binary files /dev/null and b/fonts/IBMPlexMono-400-latin.woff2 differ diff --git a/fonts/IBMPlexMono-500-cyrillic.woff2 b/fonts/IBMPlexMono-500-cyrillic.woff2 new file mode 100644 index 0000000..328efe3 Binary files /dev/null and b/fonts/IBMPlexMono-500-cyrillic.woff2 differ diff --git a/fonts/IBMPlexMono-500-latin-ext.woff2 b/fonts/IBMPlexMono-500-latin-ext.woff2 new file mode 100644 index 0000000..6f33f8c Binary files /dev/null and b/fonts/IBMPlexMono-500-latin-ext.woff2 differ diff --git a/fonts/IBMPlexMono-500-latin.woff2 b/fonts/IBMPlexMono-500-latin.woff2 new file mode 100644 index 0000000..090f82f Binary files /dev/null and b/fonts/IBMPlexMono-500-latin.woff2 differ diff --git a/fonts/IBMPlexMono-600-cyrillic.woff2 b/fonts/IBMPlexMono-600-cyrillic.woff2 new file mode 100644 index 0000000..56fa97f Binary files /dev/null and b/fonts/IBMPlexMono-600-cyrillic.woff2 differ diff --git a/fonts/IBMPlexMono-600-latin-ext.woff2 b/fonts/IBMPlexMono-600-latin-ext.woff2 new file mode 100644 index 0000000..c0b57de Binary files /dev/null and b/fonts/IBMPlexMono-600-latin-ext.woff2 differ diff --git a/fonts/IBMPlexMono-600-latin.woff2 b/fonts/IBMPlexMono-600-latin.woff2 new file mode 100644 index 0000000..67aeeb0 Binary files /dev/null and b/fonts/IBMPlexMono-600-latin.woff2 differ diff --git a/fonts/IBMPlexMono-700-cyrillic.woff2 b/fonts/IBMPlexMono-700-cyrillic.woff2 new file mode 100644 index 0000000..4c11137 Binary files /dev/null and b/fonts/IBMPlexMono-700-cyrillic.woff2 differ diff --git a/fonts/IBMPlexMono-700-latin-ext.woff2 b/fonts/IBMPlexMono-700-latin-ext.woff2 new file mode 100644 index 0000000..140a3ba Binary files /dev/null and b/fonts/IBMPlexMono-700-latin-ext.woff2 differ diff --git a/fonts/IBMPlexMono-700-latin.woff2 b/fonts/IBMPlexMono-700-latin.woff2 new file mode 100644 index 0000000..5d7ff0c Binary files /dev/null and b/fonts/IBMPlexMono-700-latin.woff2 differ diff --git a/fonts/IBMPlexSans-300-latin-ext.woff2 b/fonts/IBMPlexSans-300-latin-ext.woff2 new file mode 100644 index 0000000..394ebbb Binary files /dev/null and b/fonts/IBMPlexSans-300-latin-ext.woff2 differ diff --git a/fonts/IBMPlexSans-300-latin.woff2 b/fonts/IBMPlexSans-300-latin.woff2 new file mode 100644 index 0000000..b757bc5 Binary files /dev/null and b/fonts/IBMPlexSans-300-latin.woff2 differ diff --git a/fonts/IBMPlexSans-400-latin-ext.woff2 b/fonts/IBMPlexSans-400-latin-ext.woff2 new file mode 100644 index 0000000..394ebbb Binary files /dev/null and b/fonts/IBMPlexSans-400-latin-ext.woff2 differ diff --git a/fonts/IBMPlexSans-400-latin.woff2 b/fonts/IBMPlexSans-400-latin.woff2 new file mode 100644 index 0000000..b757bc5 Binary files /dev/null and b/fonts/IBMPlexSans-400-latin.woff2 differ diff --git a/fonts/IBMPlexSans-500-latin-ext.woff2 b/fonts/IBMPlexSans-500-latin-ext.woff2 new file mode 100644 index 0000000..394ebbb Binary files /dev/null and b/fonts/IBMPlexSans-500-latin-ext.woff2 differ diff --git a/fonts/IBMPlexSans-500-latin.woff2 b/fonts/IBMPlexSans-500-latin.woff2 new file mode 100644 index 0000000..b757bc5 Binary files /dev/null and b/fonts/IBMPlexSans-500-latin.woff2 differ diff --git a/fonts/IBMPlexSans-600-latin-ext.woff2 b/fonts/IBMPlexSans-600-latin-ext.woff2 new file mode 100644 index 0000000..394ebbb Binary files /dev/null and b/fonts/IBMPlexSans-600-latin-ext.woff2 differ diff --git a/fonts/IBMPlexSans-600-latin.woff2 b/fonts/IBMPlexSans-600-latin.woff2 new file mode 100644 index 0000000..b757bc5 Binary files /dev/null and b/fonts/IBMPlexSans-600-latin.woff2 differ diff --git a/fonts/IBMPlexSans-700-latin-ext.woff2 b/fonts/IBMPlexSans-700-latin-ext.woff2 new file mode 100644 index 0000000..394ebbb Binary files /dev/null and b/fonts/IBMPlexSans-700-latin-ext.woff2 differ diff --git a/fonts/IBMPlexSans-700-latin.woff2 b/fonts/IBMPlexSans-700-latin.woff2 new file mode 100644 index 0000000..b757bc5 Binary files /dev/null and b/fonts/IBMPlexSans-700-latin.woff2 differ diff --git a/fonts/IBMPlexSans-cyrillic.woff2 b/fonts/IBMPlexSans-cyrillic.woff2 new file mode 100644 index 0000000..92a5629 Binary files /dev/null and b/fonts/IBMPlexSans-cyrillic.woff2 differ diff --git a/fonts/OFL.txt b/fonts/OFL.txt new file mode 100644 index 0000000..ebcadf3 --- /dev/null +++ b/fonts/OFL.txt @@ -0,0 +1,108 @@ +Fonts redistributed in this directory, and the licences they carry. + +These font files are NOT covered by this project's own licence. They are +third-party works, subsetted (a permitted modification) and self-hosted so the +site makes no request to a font CDN. SIL OFL 1.1 requires that this notice and +the licence text below travel with the files -- that is what this file is for. + +=========================================================== +COPYRIGHT NOTICES +=========================================================== + +IBM Plex Mono -- SIL OFL 1.1 + Copyright © 2017 IBM Corp. with Reserved Font Name "Plex". + +IBM Plex Sans -- SIL OFL 1.1 + Copyright © 2017 IBM Corp. with Reserved Font Name "Plex". + +Red Hat Display -- SIL OFL 1.1 + Copyright 2021 Red Hat, Inc., with Reserved Font Name Red Hat. + +=========================================================== + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/fonts/RedHatDisplay-400-latin-ext.woff2 b/fonts/RedHatDisplay-400-latin-ext.woff2 new file mode 100644 index 0000000..a3f0a5b Binary files /dev/null and b/fonts/RedHatDisplay-400-latin-ext.woff2 differ diff --git a/fonts/RedHatDisplay-400-latin.woff2 b/fonts/RedHatDisplay-400-latin.woff2 new file mode 100644 index 0000000..81b9dce Binary files /dev/null and b/fonts/RedHatDisplay-400-latin.woff2 differ diff --git a/fonts/RedHatDisplay-500-latin-ext.woff2 b/fonts/RedHatDisplay-500-latin-ext.woff2 new file mode 100644 index 0000000..a3f0a5b Binary files /dev/null and b/fonts/RedHatDisplay-500-latin-ext.woff2 differ diff --git a/fonts/RedHatDisplay-500-latin.woff2 b/fonts/RedHatDisplay-500-latin.woff2 new file mode 100644 index 0000000..81b9dce Binary files /dev/null and b/fonts/RedHatDisplay-500-latin.woff2 differ diff --git a/fonts/RedHatDisplay-700-latin-ext.woff2 b/fonts/RedHatDisplay-700-latin-ext.woff2 new file mode 100644 index 0000000..a3f0a5b Binary files /dev/null and b/fonts/RedHatDisplay-700-latin-ext.woff2 differ diff --git a/fonts/RedHatDisplay-700-latin.woff2 b/fonts/RedHatDisplay-700-latin.woff2 new file mode 100644 index 0000000..81b9dce Binary files /dev/null and b/fonts/RedHatDisplay-700-latin.woff2 differ diff --git a/fonts/RedHatDisplay-800-latin-ext.woff2 b/fonts/RedHatDisplay-800-latin-ext.woff2 new file mode 100644 index 0000000..a3f0a5b Binary files /dev/null and b/fonts/RedHatDisplay-800-latin-ext.woff2 differ diff --git a/fonts/RedHatDisplay-800-latin.woff2 b/fonts/RedHatDisplay-800-latin.woff2 new file mode 100644 index 0000000..81b9dce Binary files /dev/null and b/fonts/RedHatDisplay-800-latin.woff2 differ diff --git a/fonts/RedHatDisplay-900-latin-ext.woff2 b/fonts/RedHatDisplay-900-latin-ext.woff2 new file mode 100644 index 0000000..a3f0a5b Binary files /dev/null and b/fonts/RedHatDisplay-900-latin-ext.woff2 differ diff --git a/fonts/RedHatDisplay-900-latin.woff2 b/fonts/RedHatDisplay-900-latin.woff2 new file mode 100644 index 0000000..81b9dce Binary files /dev/null and b/fonts/RedHatDisplay-900-latin.woff2 differ diff --git a/fonts/carino-fonts.css b/fonts/carino-fonts.css new file mode 100644 index 0000000..8c45a66 --- /dev/null +++ b/fonts/carino-fonts.css @@ -0,0 +1,369 @@ +/* Carino brand fonts — self-hosted (IBM Plex Mono/Sans + Red Hat Display), latin + latin-ext + cyrillic. + Generated from upstream OFL sources; replaces the Google Fonts <link>. + Licences and required copyright notices: ./OFL.txt (SIL OFL 1.1). */ +/* latin-ext */ +@font-face { + font-family: 'IBM Plex Mono'; + font-style: normal; + font-weight: 400; + font-display: swap; + src: url(./IBMPlexMono-400-latin-ext.woff2) format('woff2'); + unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; +} +/* latin */ +@font-face { + font-family: 'IBM Plex Mono'; + font-style: normal; + font-weight: 400; + font-display: swap; + src: url(./IBMPlexMono-400-latin.woff2) format('woff2'); + unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; +} +/* latin-ext */ +@font-face { + font-family: 'IBM Plex Mono'; + font-style: normal; + font-weight: 500; + font-display: swap; + src: url(./IBMPlexMono-500-latin-ext.woff2) format('woff2'); + unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; +} +/* latin */ +@font-face { + font-family: 'IBM Plex Mono'; + font-style: normal; + font-weight: 500; + font-display: swap; + src: url(./IBMPlexMono-500-latin.woff2) format('woff2'); + unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; +} +/* latin-ext */ +@font-face { + font-family: 'IBM Plex Mono'; + font-style: normal; + font-weight: 600; + font-display: swap; + src: url(./IBMPlexMono-600-latin-ext.woff2) format('woff2'); + unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; +} +/* latin */ +@font-face { + font-family: 'IBM Plex Mono'; + font-style: normal; + font-weight: 600; + font-display: swap; + src: url(./IBMPlexMono-600-latin.woff2) format('woff2'); + unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; +} +/* latin-ext */ +@font-face { + font-family: 'IBM Plex Mono'; + font-style: normal; + font-weight: 700; + font-display: swap; + src: url(./IBMPlexMono-700-latin-ext.woff2) format('woff2'); + unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; +} +/* latin */ +@font-face { + font-family: 'IBM Plex Mono'; + font-style: normal; + font-weight: 700; + font-display: swap; + src: url(./IBMPlexMono-700-latin.woff2) format('woff2'); + unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; +} +/* latin-ext */ +@font-face { + font-family: 'IBM Plex Sans'; + font-style: normal; + font-weight: 300; + font-stretch: 100%; + font-display: swap; + src: url(./IBMPlexSans-300-latin-ext.woff2) format('woff2'); + unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; +} +/* latin */ +@font-face { + font-family: 'IBM Plex Sans'; + font-style: normal; + font-weight: 300; + font-stretch: 100%; + font-display: swap; + src: url(./IBMPlexSans-300-latin.woff2) format('woff2'); + unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; +} +/* latin-ext */ +@font-face { + font-family: 'IBM Plex Sans'; + font-style: normal; + font-weight: 400; + font-stretch: 100%; + font-display: swap; + src: url(./IBMPlexSans-400-latin-ext.woff2) format('woff2'); + unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; +} +/* latin */ +@font-face { + font-family: 'IBM Plex Sans'; + font-style: normal; + font-weight: 400; + font-stretch: 100%; + font-display: swap; + src: url(./IBMPlexSans-400-latin.woff2) format('woff2'); + unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; +} +/* latin-ext */ +@font-face { + font-family: 'IBM Plex Sans'; + font-style: normal; + font-weight: 500; + font-stretch: 100%; + font-display: swap; + src: url(./IBMPlexSans-500-latin-ext.woff2) format('woff2'); + unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; +} +/* latin */ +@font-face { + font-family: 'IBM Plex Sans'; + font-style: normal; + font-weight: 500; + font-stretch: 100%; + font-display: swap; + src: url(./IBMPlexSans-500-latin.woff2) format('woff2'); + unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; +} +/* latin-ext */ +@font-face { + font-family: 'IBM Plex Sans'; + font-style: normal; + font-weight: 600; + font-stretch: 100%; + font-display: swap; + src: url(./IBMPlexSans-600-latin-ext.woff2) format('woff2'); + unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; +} +/* latin */ +@font-face { + font-family: 'IBM Plex Sans'; + font-style: normal; + font-weight: 600; + font-stretch: 100%; + font-display: swap; + src: url(./IBMPlexSans-600-latin.woff2) format('woff2'); + unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; +} +/* latin-ext */ +@font-face { + font-family: 'IBM Plex Sans'; + font-style: normal; + font-weight: 700; + font-stretch: 100%; + font-display: swap; + src: url(./IBMPlexSans-700-latin-ext.woff2) format('woff2'); + unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; +} +/* latin */ +@font-face { + font-family: 'IBM Plex Sans'; + font-style: normal; + font-weight: 700; + font-stretch: 100%; + font-display: swap; + src: url(./IBMPlexSans-700-latin.woff2) format('woff2'); + unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; +} +/* latin-ext */ +@font-face { + font-family: 'Red Hat Display'; + font-style: normal; + font-weight: 400; + font-display: swap; + src: url(./RedHatDisplay-400-latin-ext.woff2) format('woff2'); + unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; +} +/* latin */ +@font-face { + font-family: 'Red Hat Display'; + font-style: normal; + font-weight: 400; + font-display: swap; + src: url(./RedHatDisplay-400-latin.woff2) format('woff2'); + unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; +} +/* latin-ext */ +@font-face { + font-family: 'Red Hat Display'; + font-style: normal; + font-weight: 500; + font-display: swap; + src: url(./RedHatDisplay-500-latin-ext.woff2) format('woff2'); + unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; +} +/* latin */ +@font-face { + font-family: 'Red Hat Display'; + font-style: normal; + font-weight: 500; + font-display: swap; + src: url(./RedHatDisplay-500-latin.woff2) format('woff2'); + unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; +} +/* latin-ext */ +@font-face { + font-family: 'Red Hat Display'; + font-style: normal; + font-weight: 700; + font-display: swap; + src: url(./RedHatDisplay-700-latin-ext.woff2) format('woff2'); + unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; +} +/* latin */ +@font-face { + font-family: 'Red Hat Display'; + font-style: normal; + font-weight: 700; + font-display: swap; + src: url(./RedHatDisplay-700-latin.woff2) format('woff2'); + unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; +} +/* latin-ext */ +@font-face { + font-family: 'Red Hat Display'; + font-style: normal; + font-weight: 800; + font-display: swap; + src: url(./RedHatDisplay-800-latin-ext.woff2) format('woff2'); + unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; +} +/* latin */ +@font-face { + font-family: 'Red Hat Display'; + font-style: normal; + font-weight: 800; + font-display: swap; + src: url(./RedHatDisplay-800-latin.woff2) format('woff2'); + unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; +} +/* latin-ext */ +@font-face { + font-family: 'Red Hat Display'; + font-style: normal; + font-weight: 900; + font-display: swap; + src: url(./RedHatDisplay-900-latin-ext.woff2) format('woff2'); + unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; +} +/* latin */ +@font-face { + font-family: 'Red Hat Display'; + font-style: normal; + font-weight: 900; + font-display: swap; + src: url(./RedHatDisplay-900-latin.woff2) format('woff2'); + unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; +} + +/* --------------------------------------------------------------- + Cyrillic (Russian). Gated by unicode-range, so visitors reading + any other language never download these files. + Declared per weight rather than as one variable-weight range: + when a family also has discrete-weight latin faces, browsers + match a discrete face first and skip a range face entirely. + Red Hat Display/Text have no Cyrillic glyphs upstream, so Russian + headings fall through the existing stack to IBM Plex Sans. + --------------------------------------------------------------- */ +/* cyrillic */ +@font-face { + font-family: 'IBM Plex Mono'; + font-style: normal; + font-weight: 400; + font-display: swap; + src: url(./IBMPlexMono-400-cyrillic.woff2) format('woff2'); + unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; +} + +/* cyrillic */ +@font-face { + font-family: 'IBM Plex Mono'; + font-style: normal; + font-weight: 500; + font-display: swap; + src: url(./IBMPlexMono-500-cyrillic.woff2) format('woff2'); + unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; +} + +/* cyrillic */ +@font-face { + font-family: 'IBM Plex Mono'; + font-style: normal; + font-weight: 600; + font-display: swap; + src: url(./IBMPlexMono-600-cyrillic.woff2) format('woff2'); + unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; +} + +/* cyrillic */ +@font-face { + font-family: 'IBM Plex Mono'; + font-style: normal; + font-weight: 700; + font-display: swap; + src: url(./IBMPlexMono-700-cyrillic.woff2) format('woff2'); + unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; +} + +/* cyrillic */ +@font-face { + font-family: 'IBM Plex Sans'; + font-style: normal; + font-weight: 300; + font-stretch: 100%; + font-display: swap; + src: url(./IBMPlexSans-cyrillic.woff2) format('woff2'); + unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; +} + +/* cyrillic */ +@font-face { + font-family: 'IBM Plex Sans'; + font-style: normal; + font-weight: 400; + font-stretch: 100%; + font-display: swap; + src: url(./IBMPlexSans-cyrillic.woff2) format('woff2'); + unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; +} + +/* cyrillic */ +@font-face { + font-family: 'IBM Plex Sans'; + font-style: normal; + font-weight: 500; + font-stretch: 100%; + font-display: swap; + src: url(./IBMPlexSans-cyrillic.woff2) format('woff2'); + unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; +} + +/* cyrillic */ +@font-face { + font-family: 'IBM Plex Sans'; + font-style: normal; + font-weight: 600; + font-stretch: 100%; + font-display: swap; + src: url(./IBMPlexSans-cyrillic.woff2) format('woff2'); + unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; +} + +/* cyrillic */ +@font-face { + font-family: 'IBM Plex Sans'; + font-style: normal; + font-weight: 700; + font-stretch: 100%; + font-display: swap; + src: url(./IBMPlexSans-cyrillic.woff2) format('woff2'); + unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; +} diff --git a/i18n.js b/i18n.js new file mode 100644 index 0000000..9b4274b --- /dev/null +++ b/i18n.js @@ -0,0 +1,138 @@ +// i18n — CyberCity dictionaries (fleet convention, see Password/i18n.js). +// English source strings ARE the keys, so a missing entry falls back to +// English. Locale comes from carino-lang.js (window.CarinoLang.current); +// this script is deferred and loaded after it, and re-applies on the fleet +// 'carino:langchange' event. Only the DOM chrome is translated: the stencil +// hint drawn into the city (src/elements/hud.js) stays English, because its +// glyph set has no other script; the help overlay is its translated twin. + +const I18N = { + es: { + 'Late shift.': 'Turno nocturno.', + 'Good morning.': 'Buenos días.', + 'Good afternoon.': 'Buenas tardes.', + 'Good evening.': 'Buenas noches.', + 'More': 'Más', + 'click for fullscreen': 'clic para pantalla completa', + 'tap for fullscreen': 'toca para pantalla completa', + 'Help': 'Ayuda', + 'Pause': 'Pausa', + 'Resume': 'Reanudar', + 'Close': 'Cerrar', + 'Fullscreen': 'Pantalla completa', + 'How to play': 'Cómo se juega', + 'Four worlds drawn in text characters. Leave it alone and it walks itself; take the camera whenever you like. Opening this pauses the city.': 'Cuatro mundos dibujados con caracteres de texto. Si lo dejas, camina solo; toma la cámara cuando quieras. Abrir esta ayuda pausa la ciudad.', + 'Walk': 'Caminar', + 'Look (or drag)': 'Mirar (o arrastrar)', + 'Run, crouch': 'Correr, agacharse', + 'Change world': 'Cambiar de mundo', + 'Change the weather': 'Cambiar el clima', + 'Time of day, stop the clock': 'Hora del día, detener el reloj', + 'New city': 'Ciudad nueva', + 'Take or give back the camera': 'Tomar o devolver la cámara', + 'Touch': 'Táctil', + 'Left half of the screen walks, right half looks. Tap the city for fullscreen.': 'La mitad izquierda de la pantalla camina y la derecha mira. Toca la ciudad para pantalla completa.', + 'No sound. Nothing is sent anywhere.': 'Sin sonido. No se envía nada a ningún sitio.', + }, + 'pt-BR': { + 'Late shift.': 'Turno da noite.', + 'Good morning.': 'Bom dia.', + 'Good afternoon.': 'Boa tarde.', + 'Good evening.': 'Boa noite.', + 'More': 'Mais', + 'click for fullscreen': 'clique para tela cheia', + 'tap for fullscreen': 'toque para tela cheia', + 'Help': 'Ajuda', + 'Pause': 'Pausar', + 'Resume': 'Retomar', + 'Close': 'Fechar', + 'Fullscreen': 'Tela cheia', + 'How to play': 'Como jogar', + 'Four worlds drawn in text characters. Leave it alone and it walks itself; take the camera whenever you like. Opening this pauses the city.': 'Quatro mundos desenhados com caracteres de texto. Deixe quieto e ele anda sozinho; assuma a câmera quando quiser. Abrir esta ajuda pausa a cidade.', + 'Walk': 'Andar', + 'Look (or drag)': 'Olhar (ou arrastar)', + 'Run, crouch': 'Correr, agachar', + 'Change world': 'Trocar de mundo', + 'Change the weather': 'Mudar o tempo', + 'Time of day, stop the clock': 'Hora do dia, parar o relógio', + 'New city': 'Nova cidade', + 'Take or give back the camera': 'Assumir ou devolver a câmera', + 'Touch': 'Toque', + 'Left half of the screen walks, right half looks. Tap the city for fullscreen.': 'A metade esquerda da tela anda e a direita olha. Toque na cidade para tela cheia.', + 'No sound. Nothing is sent anywhere.': 'Sem som. Nada é enviado a lugar nenhum.', + }, + ja: { + 'Late shift.': '夜勤お疲れさま。', + 'Good morning.': 'おはようございます。', + 'Good afternoon.': 'こんにちは。', + 'Good evening.': 'こんばんは。', + 'More': 'その他', + 'click for fullscreen': 'クリックで全画面', + 'tap for fullscreen': 'タップで全画面', + 'Help': 'ヘルプ', + 'Pause': '一時停止', + 'Resume': '再開', + 'Close': '閉じる', + 'Fullscreen': '全画面', + 'How to play': '遊び方', + 'Four worlds drawn in text characters. Leave it alone and it walks itself; take the camera whenever you like. Opening this pauses the city.': '文字で描かれた四つの世界。放っておけば自動で歩きます。いつでもカメラを操作できます。このヘルプを開くと街は一時停止します。', + 'Walk': '歩く', + 'Look (or drag)': '見回す(ドラッグでも可)', + 'Run, crouch': '走る、しゃがむ', + 'Change world': '世界を切り替え', + 'Change the weather': '天気を変える', + 'Time of day, stop the clock': '時間帯、時計を止める', + 'New city': '新しい街', + 'Take or give back the camera': 'カメラを操作/自動に戻す', + 'Touch': 'タッチ', + 'Left half of the screen walks, right half looks. Tap the city for fullscreen.': '画面の左半分で歩き、右半分で見回します。街をタップすると全画面になります。', + 'No sound. Nothing is sent anywhere.': '音はありません。どこにも何も送信しません。', + }, + ru: { + 'Late shift.': 'Ночная смена.', + 'Good morning.': 'Доброе утро.', + 'Good afternoon.': 'Добрый день.', + 'Good evening.': 'Добрый вечер.', + 'More': 'Ещё', + 'click for fullscreen': 'щёлкните для полного экрана', + 'tap for fullscreen': 'коснитесь для полного экрана', + 'Help': 'Справка', + 'Pause': 'Пауза', + 'Resume': 'Продолжить', + 'Close': 'Закрыть', + 'Fullscreen': 'Полный экран', + 'How to play': 'Как играть', + 'Four worlds drawn in text characters. Leave it alone and it walks itself; take the camera whenever you like. Opening this pauses the city.': 'Четыре мира, нарисованных текстовыми символами. Если ничего не трогать, камера гуляет сама; управление можно взять в любой момент. Открытая справка ставит город на паузу.', + 'Walk': 'Идти', + 'Look (or drag)': 'Смотреть (или перетаскивать)', + 'Run, crouch': 'Бежать, присесть', + 'Change world': 'Сменить мир', + 'Change the weather': 'Сменить погоду', + 'Time of day, stop the clock': 'Время суток, остановить часы', + 'New city': 'Новый город', + 'Take or give back the camera': 'Взять или вернуть камеру', + 'Touch': 'Касание', + 'Left half of the screen walks, right half looks. Tap the city for fullscreen.': 'Левая половина экрана — ходьба, правая — обзор. Коснитесь города для полного экрана.', + 'No sound. Nothing is sent anywhere.': 'Без звука. Ничего никуда не отправляется.', + }, +}; + +function currentFleetLang() { return (window.CarinoLang && window.CarinoLang.current) || 'en'; } + +function t(key) { + const dict = I18N[currentFleetLang()]; + return (dict && dict[key]) || key; +} + +// Static markup: elements carrying data-i18n use their original English text +// as the key (captured on first pass, so locale switches stay reversible). +function applyI18n() { + document.documentElement.lang = currentFleetLang(); + document.querySelectorAll('[data-i18n]').forEach((el) => { + if (!el.dataset.i18nKey) el.dataset.i18nKey = el.textContent.trim().replace(/\s+/g, ' '); + el.textContent = t(el.dataset.i18nKey); + }); +} + +document.addEventListener('DOMContentLoaded', applyI18n); +window.addEventListener('carino:langchange', applyI18n); diff --git a/index.html b/index.html index 27798bb..a0c5127 100644 --- a/index.html +++ b/index.html @@ -22,39 +22,88 @@ <meta name="twitter:card" content="summary_large_image"> <script type="application/ld+json">{"@context": "https://schema.org", "@type": "WebApplication", "name": "CyberCity", "url": "https://cybercity.carino.systems/", "description": "Four walkable worlds drawn entirely in text characters — a rain-lit city, an 1880s frontier town, the Moon and a castle town at dusk — with the sun going round.", "operatingSystem": "Any (runs in a web browser)", "isAccessibleForFree": true, "author": {"@type": "Person", "name": "Miguel Cariño", "url": "https://carino.systems/"}}</script> <!-- /carino:head --> +<link rel="stylesheet" href="fonts/carino-fonts.css"> +<link rel="stylesheet" href="carino-ui.css"> <style> html, body { margin: 0; padding: 0; background: #000; height: 100%; overflow: hidden; } - /* The canvas is allowed to overhang the viewport by a fraction of a cell (see main.js layout), - so it is pinned to the origin and the overflow above hides the remainder. */ - #cc { position: fixed; inset: 0; display: block; background: #000; + body { overscroll-behavior: none; } + .play-stage { background: #000; } + /* The canvas is allowed to overhang the stage by a fraction of a cell (see main.js layout), so + it is pinned to the stage's corner and the stage's overflow hides the remainder. main.js + sizes it from the stage, not the window, so the navbar never covers a row of city. */ + #cc { position: absolute; left: 0; top: 0; display: block; background: #000; image-rendering: auto; } - /* Nothing here is selectable, draggable or scrollable: every gesture is a fullscreen request. */ - body { -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; - touch-action: none; overscroll-behavior: none; } + /* Nothing on the stage is selectable, draggable or scrollable: every gesture is a fullscreen + request. Kept off the body so the help overlay can still scroll on a phone. */ + .play-stage { -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; + touch-action: none; } #hint { - position: fixed; left: 50%; bottom: 6vh; transform: translateX(-50%); - font: 500 12px/1 ui-monospace, "Liberation Mono", "DejaVu Sans Mono", monospace; - letter-spacing: .28em; text-transform: uppercase; color: #d8e84a; + position: absolute; left: 50%; bottom: 6vh; transform: translateX(-50%); + font: 500 var(--fs-sm)/1 var(--mono); + letter-spacing: .28em; text-transform: uppercase; color: var(--text-sec); white-space: nowrap; pointer-events: none; opacity: 0; animation: hint 9s ease-in-out .8s 1 forwards; } + #hint .h-coarse { display: none; } + @media (pointer: coarse) { #hint .h-fine { display: none; } #hint .h-coarse { display: inline; } } /* Ends at opacity 0 and stays there — 'forwards' holds the last keyframe, so the hint is gone for good after one play and never reappears on resize or fullscreen change. */ - @keyframes hint { 0% { opacity: 0 } 12% { opacity: .34 } 70% { opacity: .34 } 100% { opacity: 0 } } + @keyframes hint { 0% { opacity: 0 } 12% { opacity: .6 } 70% { opacity: .6 } 100% { opacity: 0 } } @media (prefers-reduced-motion: reduce) { #hint { animation-duration: 14s } } - /* The one link on the page: the fleet's legal notice. Dim and small, in the corner the - city's skyline never needs; it brightens only under the pointer. */ - #legal { position: fixed; right: 10px; bottom: 8px; z-index: 1; - font: 500 10px/1 ui-monospace, "Liberation Mono", "DejaVu Sans Mono", monospace; - letter-spacing: .12em; text-transform: uppercase; color: #d8e84a; opacity: .28; - text-decoration: none; } - #legal:hover, #legal:focus-visible { opacity: .8; } + /* The help overlay: Branding's modal; the touch section shows on coarse pointers only. */ + .cc-keys { display: grid; grid-template-columns: max-content 1fr; gap: 8px 14px; align-items: center; + margin: 12px 0 0; font-family: var(--mono); font-size: var(--fs-btn); color: var(--text-muted); } + .cc-keys dt { white-space: nowrap; } + .cc-keys dd { margin: 0; text-transform: uppercase; letter-spacing: .06em; } + .cc-touch { display: none; margin: 14px 0 0; } + .modal-head > div:first-child { flex: 1; } + @media (pointer: coarse) { .cc-touch { display: block; } } + #ccPause[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); background: var(--accent-faint); } </style> </head> -<body> +<body class="play-body"> +<div data-carino-actions> + <button type="button" class="cs-btn" id="ccPause" aria-pressed="false">Pause</button> + <button type="button" class="cs-btn" id="ccHelpBtn" data-priority="1" aria-haspopup="dialog" aria-controls="ccHelp">? <span data-i18n>Help</span></button> +</div> +<main class="play-stage" id="stage"> <canvas id="cc"></canvas> -<div id="hint">click for fullscreen</div> -<a id="legal" href="https://carino.systems/legal.html">Legal</a> +<div id="hint"><span class="h-fine" data-i18n>click for fullscreen</span><span class="h-coarse" data-i18n>tap for fullscreen</span></div> +</main> +<div class="modal-scrim" id="ccHelp" hidden> + <div class="modal" role="dialog" aria-modal="true" aria-labelledby="ccHelpTitle"> + <div class="modal-head"> + <div><div class="modal-title" id="ccHelpTitle" data-i18n>How to play</div><div class="modal-sub">CyberCity</div></div> + <button type="button" class="modal-x" id="ccHelpX" aria-label="Close">✕</button> + </div> + <div class="modal-body"> + <p style="margin:0" data-i18n>Four worlds drawn in text characters. Leave it alone and it walks itself; take the camera whenever you like. Opening this pauses the city.</p> + <div class="cc-touch"> + <div class="modal-sub" data-i18n>Touch</div> + <p style="margin:6px 0 0" data-i18n>Left half of the screen walks, right half looks. Tap the city for fullscreen.</p> + </div> + <dl class="cc-keys"> + <dt><span class="kbd">W</span> <span class="kbd">A</span> <span class="kbd">S</span> <span class="kbd">D</span></dt><dd data-i18n>Walk</dd> + <dt><span class="kbd">←</span> <span class="kbd">→</span> <span class="kbd">↑</span> <span class="kbd">↓</span></dt><dd data-i18n>Look (or drag)</dd> + <dt><span class="kbd">Shift</span> <span class="kbd">C</span></dt><dd data-i18n>Run, crouch</dd> + <dt><span class="kbd">1</span>–<span class="kbd">4</span></dt><dd data-i18n>Change world</dd> + <dt><span class="kbd">[</span> <span class="kbd">]</span></dt><dd data-i18n>Change the weather</dd> + <dt><span class="kbd">T</span> <span class="kbd">Y</span></dt><dd data-i18n>Time of day, stop the clock</dd> + <dt><span class="kbd">N</span></dt><dd data-i18n>New city</dd> + <dt><span class="kbd">Tab</span></dt><dd data-i18n>Take or give back the camera</dd> + <dt><span class="kbd accent">P</span> <span class="kbd accent">Space</span></dt><dd data-i18n>Pause</dd> + <dt><span class="kbd">F</span></dt><dd data-i18n>Fullscreen</dd> + <dt><span class="kbd">?</span> <span class="kbd">H</span></dt><dd data-i18n>Help</dd> + <dt><span class="kbd">Esc</span></dt><dd data-i18n>Close</dd> + </dl> + <p style="margin:14px 0 0;font-size:var(--fs-sm);color:var(--text-muted)" data-i18n>No sound. Nothing is sent anywhere.</p> + </div> + <div class="modal-foot"> + <button type="button" class="btn" id="ccFull" data-i18n>Fullscreen</button> + <button type="button" class="btn btn-primary" id="ccResume" data-i18n>Resume</button> + </div> + </div> +</div> <script src="w/west.js?v=baf528f930"></script> <script src="w/jp.js?v=fa656c3016"></script> <script src="w/moon.js?v=b38866aba9"></script> @@ -3577,6 +3626,11 @@ W("surf_west.js"); hintClose = t + HINT_IN + HINT_HOLD; } + function setPaused(v) { + paused = v ? 1 : 0; Control.paused = paused; + if (hooksRef && hooksRef.paused) hooksRef.paused(paused); + } + var el = null; var hooksRef = null; @@ -3615,9 +3669,13 @@ W("surf_west.js"); hooks && hooks.now ? hooks.now() : 0); idle = 0; if (doc.exitPointerLock) doc.exitPointerLock(); break; - case 'KeyH': hintToggle(hooks && hooks.now ? hooks.now() : 0); break; - case 'KeyP': paused = paused ? 0 : 1; Control.paused = paused; break; + case 'KeyH': + hintToggle(hooks && hooks.now ? hooks.now() : 0); + if (hooks && hooks.help) hooks.help(); + break; + + case 'KeyP': case 'Space': setPaused(!paused); e.preventDefault(); break; case 'KeyF': if (hooks && hooks.fullscreen) hooks.fullscreen(); break; case 'KeyN': if (hooks && hooks.reseed) hooks.reseed(); break; @@ -3633,6 +3691,10 @@ W("surf_west.js"); default: hit = 0; } + if (!hit && h === '?') { + if (hooks && hooks.help) hooks.help(); else hintToggle(hooks && hooks.now ? hooks.now() : 0); + hit = 2; + } var dg = /^Digit[1-9]$/.test(c) ? parseInt(c.slice(5), 10) : (h && h.length === 1 && h >= '1' && h <= '9' ? h.charCodeAt(0) - 48 : 0); if (!hit && dg) { @@ -3657,6 +3719,11 @@ W("surf_west.js"); win.addEventListener('keydown', function (e) { if (e.metaKey || e.ctrlKey && e.code !== 'ControlLeft' || e.altKey) return; + + if (hooks && hooks.blocked && hooks.blocked()) return; + var tg = e.target; + if (tg && (tg.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(tg.tagName || ''))) return; + if (e.code === 'Space' && tg && /^(BUTTON|A)$/.test(tg.tagName || '')) return; if (e.repeat) { K.any = 1; return; } if (set(e, 1) && e.code !== 'Tab') { } }); @@ -3682,7 +3749,7 @@ W("surf_west.js"); if (!isTouch(e)) { mouseDrag = 1; mlx = e.clientX; mly = e.clientY; return; } Control.touch = 1; - var w = win.innerWidth || el.clientWidth || 800; + var w = el.clientWidth || win.innerWidth || 800; if (e.clientX < w * 0.5) { if (stickId < 0) { stickId = e.pointerId; stickX0 = e.clientX; stickY0 = e.clientY; } } else if (lookId < 0) { lookId = e.pointerId; llx = e.clientX; lly = e.clientY; } @@ -3755,6 +3822,7 @@ W("surf_west.js"); touch: 0, paused: 0, + setPaused: function (v) { setPaused(v); }, hintAlpha: hintAlpha, @@ -3770,6 +3838,7 @@ W("surf_west.js"); seedWanted = 0; padWorld = 0; paused = 0; Control.paused = 0; + if (hooksRef && hooksRef.paused) hooksRef.paused(0); hintOpen = 0; hintClose = HINT_IN + HINT_HOLD; } }; @@ -11969,9 +12038,16 @@ W("elements/west_town.js"); return w * zoom; } + function stageSize() { + var p = canvas && canvas.parentNode; + var w = p && p.clientWidth, h = p && p.clientHeight; + return (w > 0 && h > 0) ? [w, h] : [window.innerWidth, window.innerHeight]; + } + function layout() { - var vw = Math.max(window.innerWidth || 320, 200); - var vh = Math.max(window.innerHeight || 240, 160); + var sz = stageSize(); + var vw = Math.max(sz[0] || 320, 200); + var vh = Math.max(sz[1] || 240, 160); var dpr = Math.min(window.devicePixelRatio || 1, 2); @@ -12104,6 +12180,15 @@ W("elements/west_town.js"); adapt(nowMs() - t0, now); } + var modalOpen = false; + function emit(name, detail) { + try { window.dispatchEvent(new CustomEvent(name, { detail: detail })); } catch (err) { } + } + + function onStage(e) { + var t = e && e.target; + return !modalOpen && !!e && !(t && t.closest && t.closest('#carinoNav, .modal-scrim, [data-carino-actions]')); + } var rzT = 0; function onResize() { window.clearTimeout(rzT); @@ -12131,6 +12216,9 @@ W("elements/west_town.js"); document.body.appendChild(canvas); } + try { + if (CC.Control && window.matchMedia && window.matchMedia('(pointer: coarse)').matches) CC.Control.touch = 1; + } catch (err) { } var mq = window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)'); CC.reducedMotion = !!(mq && mq.matches); if (mq && mq.addEventListener) @@ -12155,6 +12243,14 @@ W("elements/west_town.js"); window.addEventListener('resize', onResize, { passive: true }); window.addEventListener('orientationchange', onResize, { passive: true }); + + if (typeof ResizeObserver === 'function' && canvas.parentNode && canvas.parentNode.nodeType === 1) + new ResizeObserver(onResize).observe(canvas.parentNode); + window.addEventListener('carino:navbar', onResize); + window.addEventListener('cybercity:modal', function (e) { modalOpen = !!(e && e.detail && e.detail.open); }); + window.addEventListener('cybercity:pause', function (e) { + if (CC.Control && CC.Control.setPaused) CC.Control.setPaused(!!(e && e.detail && e.detail.paused)); + }); document.addEventListener('fullscreenchange', onResize); document.addEventListener('webkitfullscreenchange', onResize); @@ -12166,9 +12262,9 @@ W("elements/west_town.js"); if (ns !== null && ns !== seed) moved = 1; if (moved) build(ns === null ? seed : ns); }); - window.addEventListener('pointerdown', goFullscreen, { passive: true }); + window.addEventListener('pointerdown', function (e) { if (onStage(e)) goFullscreen(); }, { passive: true }); window.addEventListener('keydown', function (e) { - if (!e.metaKey && !e.ctrlKey && !e.altKey) goFullscreen(); + if (!e.metaKey && !e.ctrlKey && !e.altKey && onStage(e) && e.key !== 'Escape') goFullscreen(); }); if (CC.Control && CC.Control.attach) { @@ -12176,6 +12272,9 @@ W("elements/west_town.js"); city: function () { return city; }, now: function () { return simT; }, fullscreen: goFullscreen, + help: function () { emit('cybercity:help', {}); }, + blocked: function () { return modalOpen; }, + paused: function (p) { emit('cybercity:paused', { paused: !!p }); }, reseed: function () { var ns = (Math.random() * 4294967296) >>> 0; seed = ns; @@ -12192,8 +12291,8 @@ W("elements/west_town.js"); worldName: function () { return CC.World ? CC.World.name : ''; } }); - window.addEventListener('pointerdown', function () { - if (CC.Control.requestLook) CC.Control.requestLook(); + window.addEventListener('pointerdown', function (e) { + if (onStage(e) && CC.Control.requestLook) CC.Control.requestLook(); }, { passive: true }); } @@ -12217,5 +12316,9 @@ W("elements/west_town.js"); })(); </script> +<script src="carino-navbar.js" data-app="CyberCity" data-repo="CyberCity" data-immersive defer></script> +<script src="carino-lang.js" defer></script> +<script src="i18n.js" defer></script> +<script src="ui.js" defer></script> </body> </html> diff --git a/src/control.js b/src/control.js index 56d9704..fc7a5a6 100644 --- a/src/control.js +++ b/src/control.js @@ -476,6 +476,13 @@ hintClose = t + HINT_IN + HINT_HOLD; } + /* Photo mode on and off, from P, Space or the page's pause button. hooksRef.paused hears every + * change so the page's own button and overlay can follow it. */ + function setPaused(v) { + paused = v ? 1 : 0; Control.paused = paused; + if (hooksRef && hooksRef.paused) hooksRef.paused(paused); + } + /* ---- DOM ------------------------------------------------------------------------------------ * Everything below this line is skipped entirely when there is no window, which is what keeps * the offline reference frame honest. */ @@ -519,13 +526,18 @@ hooks && hooks.now ? hooks.now() : 0); idle = 0; if (doc.exitPointerLock) doc.exitPointerLock(); break; - case 'KeyH': hintToggle(hooks && hooks.now ? hooks.now() : 0); break; + /* H (and ?) toggle the stencil hint as they always did, and also open the page's DOM + * help overlay when main.js wires one: the translated, readable twin of the stencil. */ + case 'KeyH': + hintToggle(hooks && hooks.now ? hooks.now() : 0); + if (hooks && hooks.help) hooks.help(); + break; /* Photo mode. The flag is all this file owns — main.js reads Control.paused and stops * stepping the world; what happens HERE is that the autopilot's clock is frozen with it * (see update), so the pose under a paused city holds still whether or not a viewer is * driving. Look and walk both keep working, which is the point: a still is something * you compose, not something you take by accident. */ - case 'KeyP': paused = paused ? 0 : 1; Control.paused = paused; break; + case 'KeyP': case 'Space': setPaused(!paused); e.preventDefault(); break; case 'KeyF': if (hooks && hooks.fullscreen) hooks.fullscreen(); break; case 'KeyN': if (hooks && hooks.reseed) hooks.reseed(); break; /* ---- the clock ------------------------------------------------------------------------ @@ -563,6 +575,11 @@ * for Digit1 on a US layout, '"' on a UK one, and so on), so the key path cannot read the * digit and only the code path handles the weather — which is why the shifted branch is * code-only and the unshifted one keeps both. */ + // ? by the character it types, whatever key makes it on this layout. + if (!hit && h === '?') { + if (hooks && hooks.help) hooks.help(); else hintToggle(hooks && hooks.now ? hooks.now() : 0); + hit = 2; + } var dg = /^Digit[1-9]$/.test(c) ? parseInt(c.slice(5), 10) : (h && h.length === 1 && h >= '1' && h <= '9' ? h.charCodeAt(0) - 48 : 0); if (!hit && dg) { @@ -608,6 +625,12 @@ win.addEventListener('keydown', function (e) { if (e.metaKey || e.ctrlKey && e.code !== 'ControlLeft' || e.altKey) return; + /* A dialog over the stage (the help overlay) owns the keyboard until it closes, a text field + * keeps its keys, and Space on a focused button presses the button, not photo mode. */ + if (hooks && hooks.blocked && hooks.blocked()) return; + var tg = e.target; + if (tg && (tg.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(tg.tagName || ''))) return; + if (e.code === 'Space' && tg && /^(BUTTON|A)$/.test(tg.tagName || '')) return; if (e.repeat) { K.any = 1; return; } if (set(e, 1) && e.code !== 'Tab') { /* handled */ } }); @@ -646,12 +669,12 @@ if (el.setPointerCapture) { try { el.setPointerCapture(e.pointerId); } catch (err) {} } if (!isTouch(e)) { mouseDrag = 1; mlx = e.clientX; mly = e.clientY; return; } /* The one bit elements/hud.js needs to know: this viewer has a thumb, not a keyboard, so the - * hint must talk about halves of the screen rather than about WASD. It is latched on the - * FIRST touch and never cleared — a device does not stop having a touchscreen, and clearing + * hint must talk about halves of the screen rather than about WASD. It is set at boot (main.js) + * on a coarse pointer, else latched on the FIRST touch, and never cleared — a device does not stop having a touchscreen, and clearing * it in reset() would make N (which a touch viewer cannot press anyway) rewrite the hint. * Never set without a DOM, so the offline reference frame keeps the keyboard wording. */ Control.touch = 1; - var w = win.innerWidth || el.clientWidth || 800; + var w = el.clientWidth || win.innerWidth || 800; if (e.clientX < w * 0.5) { if (stickId < 0) { stickId = e.pointerId; stickX0 = e.clientX; stickY0 = e.clientY; } } else if (lookId < 0) { lookId = e.pointerId; llx = e.clientX; lly = e.clientY; } @@ -738,6 +761,7 @@ /* Photo mode, published for main.js to read. This file only owns the flag — see the KeyP * case for what still has to happen at the other end. */ paused: 0, + setPaused: function (v) { setPaused(v); }, /* The hint overlay's envelope, as a pure function of the simulation clock. elements/hud.js is * the only caller; it gets t handed to its draw() and asks here rather than keeping a clock of * its own, so that H and the eight-second timer have exactly one implementation. */ @@ -758,6 +782,7 @@ /* N rebuilds the city and calls through here, and a new city that arrives paused is a viewer * staring at a still they did not ask for. */ paused = 0; Control.paused = 0; + if (hooksRef && hooksRef.paused) hooksRef.paused(0); hintOpen = 0; hintClose = HINT_IN + HINT_HOLD; } }; diff --git a/src/elements/ads.js b/src/elements/ads.js index 8e80dfe..cc3f926 100644 --- a/src/elements/ads.js +++ b/src/elements/ads.js @@ -1,4 +1,5 @@ /* CyberCity ads — storey-scale lit media bolted to the building faces. Layer 34. + * Diegetic signage drawn into the city, not advertising: no third-party content, no network. * * WHAT THIS IS AND WHAT IT IS NOT. elements/signage.js owns everything at SHOPFRONT scale: the * tubes over a door (neon, 30), the junction heads (31), the translucent panels (holo, 33) and the diff --git a/src/main.js b/src/main.js index 0b31580..b8f09fa 100644 --- a/src/main.js +++ b/src/main.js @@ -98,9 +98,19 @@ return w * zoom; } + /* The stage the canvas sits in: everything under the fleet navbar, or the whole screen once the + * navbar has slid away (fullscreen, or idle). Without a laid-out parent (the DOM shim) it is + * the window, as it always was. */ + function stageSize() { + var p = canvas && canvas.parentNode; + var w = p && p.clientWidth, h = p && p.clientHeight; + return (w > 0 && h > 0) ? [w, h] : [window.innerWidth, window.innerHeight]; + } + function layout() { - var vw = Math.max(window.innerWidth || 320, 200); - var vh = Math.max(window.innerHeight || 240, 160); + var sz = stageSize(); + var vw = Math.max(sz[0] || 320, 200); + var vh = Math.max(sz[1] || 240, 160); /* Capped at 2. A phone at dpr 3 would triple the fill rate of the bloom taps to sharpen glyphs * that are already sub-pixel-crisp at 2, and the bloom is where the frame budget goes. */ var dpr = Math.min(window.devicePixelRatio || 1, 2); @@ -331,7 +341,24 @@ /* ---- DOM plumbing -------------------------------------------------------------------------- * Kept to the minimum the contract allows main to own: one canvas, one resize, one fullscreen * gesture. The fade-out hint is pure CSS in index.html precisely so no code here has to know - * about it or ever remove it. */ + * about it or ever remove it. The fleet chrome (navbar, help overlay, pause button) lives in + * ui.js and talks to this file only through four window events, so the bundle still leaks + * nothing to window: + * cybercity:help main -> ui H or ? was pressed; open the help overlay + * cybercity:paused main -> ui photo mode changed, detail {paused} + * cybercity:pause ui -> main set photo mode, detail {paused} + * cybercity:modal ui -> main a dialog opened or closed, detail {open}; while open the + * keys belong to the dialog and nothing goes fullscreen */ + var modalOpen = false; + function emit(name, detail) { + try { window.dispatchEvent(new CustomEvent(name, { detail: detail })); } catch (err) { } + } + /* A gesture on the city (the canvas) asks for fullscreen and the mouse-look; one on the navbar, + * a dialog or a button is about that control and asks for neither. */ + function onStage(e) { + var t = e && e.target; + return !modalOpen && !!e && !(t && t.closest && t.closest('#carinoNav, .modal-scrim, [data-carino-actions]')); + } var rzT = 0; function onResize() { window.clearTimeout(rzT); @@ -368,6 +395,11 @@ } /* Before ANY module initialises: elements read CC.reducedMotion at init time as well as in * update, so setting it after boot would leave half the city un-damped. */ + /* A coarse pointer means a thumb, so the stencil hint speaks touch from its first frame rather + * than after the first tap. Asked before the motion query, which is the one kept live. */ + try { + if (CC.Control && window.matchMedia && window.matchMedia('(pointer: coarse)').matches) CC.Control.touch = 1; + } catch (err) { } var mq = window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)'); CC.reducedMotion = !!(mq && mq.matches); if (mq && mq.addEventListener) @@ -399,6 +431,15 @@ window.addEventListener('resize', onResize, { passive: true }); window.addEventListener('orientationchange', onResize, { passive: true }); + /* The stage also changes size with no window event: the navbar sliding away or back + * (carino:navbar), or arriving at all after boot. */ + if (typeof ResizeObserver === 'function' && canvas.parentNode && canvas.parentNode.nodeType === 1) + new ResizeObserver(onResize).observe(canvas.parentNode); + window.addEventListener('carino:navbar', onResize); + window.addEventListener('cybercity:modal', function (e) { modalOpen = !!(e && e.detail && e.detail.open); }); + window.addEventListener('cybercity:pause', function (e) { + if (CC.Control && CC.Control.setPaused) CC.Control.setPaused(!!(e && e.detail && e.detail.paused)); + }); document.addEventListener('fullscreenchange', onResize); // goFullscreen already reaches for the webkit entry point; without its event too, a Safari // that DID go fullscreen would keep drawing at the old grid until something else resized it. @@ -414,9 +455,9 @@ if (ns !== null && ns !== seed) moved = 1; // same reason: navigating to #0 is a real move if (moved) build(ns === null ? seed : ns); }); - window.addEventListener('pointerdown', goFullscreen, { passive: true }); + window.addEventListener('pointerdown', function (e) { if (onStage(e)) goFullscreen(); }, { passive: true }); window.addEventListener('keydown', function (e) { - if (!e.metaKey && !e.ctrlKey && !e.altKey) goFullscreen(); + if (!e.metaKey && !e.ctrlKey && !e.altKey && onStage(e) && e.key !== 'Escape') goFullscreen(); }); /* The keys. `hooks` is how control.js reaches back into main without importing it — it owns @@ -426,6 +467,9 @@ city: function () { return city; }, now: function () { return simT; }, fullscreen: goFullscreen, + help: function () { emit('cybercity:help', {}); }, + blocked: function () { return modalOpen; }, + paused: function (p) { emit('cybercity:paused', { paused: !!p }); }, reseed: function () { var ns = (Math.random() * 4294967296) >>> 0; seed = ns; @@ -447,8 +491,8 @@ }); /* Pointer lock is a mouse-look, and a mouse-look nobody asked for is a trap: it is only * requested on a real click, which is also the gesture that goes fullscreen. */ - window.addEventListener('pointerdown', function () { - if (CC.Control.requestLook) CC.Control.requestLook(); + window.addEventListener('pointerdown', function (e) { + if (onStage(e) && CC.Control.requestLook) CC.Control.requestLook(); }, { passive: true }); } diff --git a/tools/domshim.cjs b/tools/domshim.cjs index ad30619..799095f 100644 --- a/tools/domshim.cjs +++ b/tools/domshim.cjs @@ -63,6 +63,13 @@ while ((t = TAG.exec(html))) { if (/\btype\s*=\s*["']?application\/ld\+json/i.test(attrs)) { JSON.parse(t[2]); continue; } if (/\btype\s*=/i.test(attrs)) throw new Error('domshim: unexpected <script' + attrs + '> in index.html'); const src = /\bsrc\s*=\s*["']([^"']+)["']/i.exec(attrs); + /* The fleet chrome (navbar, language, i18n, the help overlay's ui.js) is not the city: build.js + * writes those tags after the bundle, deferred, and they need a real browser. They are named + * here one by one, so a stray script anywhere else still fails below, and each must exist. */ + if (src && /^(carino-navbar|carino-lang|i18n|ui)\.js$/.test(src[1]) && /\bdefer\b/i.test(attrs)) { + if (!fs.existsSync(path.join(ROOT, src[1]))) throw new Error('domshim: index.html loads ' + src[1] + ', which does not exist'); + continue; + } if (src) { /* The ?v= is build.js's cache-buster, the chunk's own content hash — and it is CHECKED, not * just stripped: a tag whose hash disagrees with the file beside it is exactly the stale pair diff --git a/ui.js b/ui.js new file mode 100644 index 0000000..35c721c --- /dev/null +++ b/ui.js @@ -0,0 +1,87 @@ +/* CyberCity — the fleet chrome around the city: the help overlay and the pause button. + * + * Not part of the bundle (build.js never sees it) and it never touches CC: it talks to main.js + * through window events, so the city stays a closed IIFE that leaks nothing. + * cybercity:help in H or ? was pressed on the stage; toggle the overlay + * cybercity:paused in photo mode changed, detail {paused} + * cybercity:pause out set photo mode, detail {paused} + * cybercity:modal out the overlay opened or closed, detail {open} + * Opening help pauses the city, and closing it resumes only a pause help itself made. */ +(function () { + 'use strict'; + var scrim = document.getElementById('ccHelp'); + var helpBtn = document.getElementById('ccHelpBtn'); + var pauseBtn = document.getElementById('ccPause'); + var resumeBtn = document.getElementById('ccResume'); + var fullBtn = document.getElementById('ccFull'); + var closeX = document.getElementById('ccHelpX'); + if (!scrim) return; + var paused = false, pausedByHelp = false, lastFocus = null; + + function tr(s) { return typeof window.t === 'function' ? window.t(s) : s; } + function emit(name, detail) { window.dispatchEvent(new CustomEvent(name, { detail: detail })); } + + function paint() { + if (pauseBtn) { + pauseBtn.textContent = paused ? tr('Resume') : tr('Pause'); + pauseBtn.setAttribute('aria-pressed', String(paused)); + } + if (closeX) closeX.setAttribute('aria-label', tr('Close')); + } + + function open() { + if (!scrim.hidden) return; + lastFocus = document.activeElement; + scrim.hidden = false; + emit('cybercity:modal', { open: true }); + if (!paused) { pausedByHelp = true; emit('cybercity:pause', { paused: true }); } + if (resumeBtn) resumeBtn.focus(); + } + + function close(resume) { + if (scrim.hidden) return; + scrim.hidden = true; + emit('cybercity:modal', { open: false }); + if (pausedByHelp || resume) emit('cybercity:pause', { paused: false }); + pausedByHelp = false; + if (lastFocus && lastFocus.focus && lastFocus !== document.body) lastFocus.focus(); + } + + function toggleFullscreen() { + var d = document, e = d.documentElement; + if (d.fullscreenElement || d.webkitFullscreenElement) { + (d.exitFullscreen || d.webkitExitFullscreen || function () {}).call(d); + return; + } + var fn = e.requestFullscreen || e.webkitRequestFullscreen; + if (!fn) return; + try { var p = fn.call(e); if (p && p.catch) p.catch(function () {}); } catch (err) {} + } + + window.addEventListener('cybercity:help', function () { if (scrim.hidden) open(); else close(); }); + window.addEventListener('cybercity:paused', function (e) { paused = !!(e.detail && e.detail.paused); paint(); }); + + if (helpBtn) helpBtn.addEventListener('click', open); + if (pauseBtn) pauseBtn.addEventListener('click', function () { + emit('cybercity:pause', { paused: !paused }); + }); + if (resumeBtn) resumeBtn.addEventListener('click', function () { close(true); }); + if (closeX) closeX.addEventListener('click', function () { close(); }); + if (fullBtn) fullBtn.addEventListener('click', function () { close(true); toggleFullscreen(); }); + scrim.addEventListener('click', function (e) { if (e.target === scrim) close(); }); + + /* While the overlay is open main.js ignores the keyboard, so its keys are handled here, and + stopped: the window listener would otherwise see H again once the overlay has closed. */ + document.addEventListener('keydown', function (e) { + if (scrim.hidden || e.metaKey || e.ctrlKey || e.altKey) return; + e.stopPropagation(); + var k = e.key; + if (k === 'Escape' || k === '?' || k === 'h' || k === 'H') { e.preventDefault(); close(); } + else if (k === 'p' || k === 'P') { e.preventDefault(); close(true); } + else if (k === 'f' || k === 'F') { e.preventDefault(); close(true); toggleFullscreen(); } + }); + + window.addEventListener('carino:langchange', paint); + document.addEventListener('DOMContentLoaded', paint); + paint(); +})();