From 1290db11b5722e81a715967010720e88d897f0d4 Mon Sep 17 00:00:00 2001 From: Duarte Santos Date: Tue, 25 Aug 2026 22:50:28 +0200 Subject: [PATCH] website: fix the dialog, align the rail, and add a first-visit intro MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tested in a real browser this time, at 1440, 1024, 390 and 360, with touch emulation and with reduced motion — which is how the first three of these were found, and none of them were visible from reading the markup. **The dialog never opened where you could see it.** `* { margin: 0 }` at the top of this file removes the margin:auto a browser uses to centre a modal , and without a position of its own it resolved to `position: absolute`, so `inset: 0` centred it inside the document rather than the viewport — near the top of the page. Opening a card scrolled the whole page up to meet it, showed a clipped corner on desktop and nothing at all on a phone. It is pinned to the viewport now, centred on both axes, capped at the screen height and scrollable inside if the text is long. Measured: centred and fully in frame at all four sizes, with no scroll jump. **The rail sat 34px left of everything above it.** Its gutter was half the leftover width, which lands on the wrap's outer edge, not on the text inside it — the wrap's own padding was missing from the sum. Cards now line up exactly with the paragraph above them (measured: 0px). Using 100% instead of 100vw also keeps the scrollbar out of the arithmetic. The screenshot rail below inherits the same fix. **The intro.** The hero settles in on the first load of a visit: a short rise and fade, staggered eyebrow to headline to lead to buttons to phone. Deliberately the same movement as the scroll reveals further down, so it reads as one behaviour rather than an effect. Armed in the inline head script, because site.js is deferred and would have let the hero paint and then hide it again. Once per tab, so a reload is not a splash screen. Off entirely for prefers-reduced-motion, and the animation ends on opacity 1 regardless of whether the cleanup ever runs — the hero cannot get stuck invisible. No horizontal overflow at any of the four widths. Arrows confirmed present for a mouse and absent for touch. --- website/about.html | 4 +-- website/docs.html | 4 +-- website/index.html | 17 +++++++++--- website/site.js | 12 +++++++++ website/styles.css | 66 +++++++++++++++++++++++++++++++++++++++++++--- 5 files changed, 93 insertions(+), 10 deletions(-) diff --git a/website/about.html b/website/about.html index fcee66a..c662937 100644 --- a/website/about.html +++ b/website/about.html @@ -9,7 +9,7 @@ - + @@ -130,6 +130,6 @@ - + diff --git a/website/docs.html b/website/docs.html index 8526b25..9fc3ff8 100644 --- a/website/docs.html +++ b/website/docs.html @@ -9,7 +9,7 @@ - + @@ -209,6 +209,6 @@ docker compose up -d - + diff --git a/website/index.html b/website/index.html index 130affc..2e1ddc3 100644 --- a/website/index.html +++ b/website/index.html @@ -14,10 +14,21 @@ - + - + + diff --git a/website/site.js b/website/site.js index bae313e..1b6a8c0 100644 --- a/website/site.js +++ b/website/site.js @@ -234,3 +234,15 @@ const GL_PROJECT = 'https://gitlab.com/api/v4/projects/DuarteSantos8%2Fopengym' sync() } })() + +/* The hero intro is armed in the inline script, before the first paint — a deferred + script would arm it too late and the hero would flash. All this does is take the class off + once the last element has landed, so nothing stays mid-animation. */ +;(() => { + const root = document.documentElement + if (!root.classList.contains('intro')) return + const done = () => root.classList.remove('intro') + const last = document.querySelector('.hero-stage') || document.querySelector('.hero .actions') + if (last) last.addEventListener('animationend', done, { once: true }) + setTimeout(done, 2400) // if the animation never fires, do not leave the hero hidden +})() diff --git a/website/styles.css b/website/styles.css index 7402e81..5e4b918 100644 --- a/website/styles.css +++ b/website/styles.css @@ -398,7 +398,10 @@ section { padding: var(--sec) 0 0; } .rail { display: flex; gap: clamp(12px, 2.4vw, 22px); overflow-x: auto; scroll-snap-type: x mandatory; - padding: 4px max(var(--pad), calc((100vw - var(--max)) / 2)) 6px; + /* Line the first card up with the text above it: the gutter is half the leftover width + PLUS the wrap's own padding. Using 100% rather than 100vw keeps the scrollbar out of + the sum, which would otherwise push the rail a few pixels off. */ + padding: 4px max(var(--pad), calc((100% - var(--max)) / 2 + var(--pad))) 6px; scrollbar-width: none; overscroll-behavior-x: contain; } @@ -720,6 +723,7 @@ table.cfg td:first-child { white-space: nowrap; width: 1%; padding-right: 26px; .more-hint { color: var(--fg-2); font-size: 15px; margin-top: 12px; } .frail { align-items: stretch; padding-top: 10px; padding-bottom: 10px; } +.more + .bleed, .bleed:has(.frail) { margin-top: clamp(18px, 2.4vw, 26px); } .fcard { flex: 0 0 auto; width: clamp(232px, 74vw, 290px); scroll-snap-align: center; display: flex; flex-direction: column; text-align: left; @@ -768,9 +772,28 @@ table.cfg td:first-child { white-space: nowrap; width: 1%; padding-right: 26px; @media (hover: none) { .frail-nav { display: none; } } .fdlg { - width: min(460px, calc(100vw - 2 * var(--pad))); + /* margin:auto is what centres a modal dialog, and `* { margin: 0 }` at the top of this + file had taken it away — the dialog was rendering at its static position, which put it + off the top-left of the viewport on desktop and completely off-screen on a phone. */ + /* Pinned to the viewport, not the document. Left to the browser it resolved to + `position: absolute`, so `inset: 0; margin: auto` centred it inside the initial + containing block — near the top of the PAGE — and opening it scrolled the whole page + up to meet it. `fixed` also makes this the containing block for the close button. */ + position: fixed; inset: 0; margin: auto; + width: min(460px, calc(100% - 2 * var(--pad))); + height: fit-content; + max-height: calc(100dvh - 2 * var(--pad)); padding: 26px; border: 1px solid var(--hair); border-radius: var(--r-m); - background: var(--surface); color: var(--fg); position: relative; + background: var(--surface); color: var(--fg); + overflow: auto; overscroll-behavior: contain; +} +/* Fade in with the backdrop rather than snapping into place. */ +.fdlg[open] { animation: dlgIn .26s var(--ease); } +.fdlg[open]::backdrop { animation: dlgBackdrop .26s var(--ease); } +@keyframes dlgIn { from { opacity: 0; transform: translateY(8px) scale(.985); } } +@keyframes dlgBackdrop { from { opacity: 0; } } +@media (prefers-reduced-motion: reduce) { + .fdlg[open], .fdlg[open]::backdrop { animation: none; } } .fdlg::backdrop { background: rgba(0, 0, 0, .62); } .fdlg-ic { @@ -794,3 +817,40 @@ table.cfg td:first-child { white-space: nowrap; width: 1%; padding-right: 26px; } .fdlg-x:hover { color: var(--fg); background: var(--surface-2); } .fdlg-x svg { width: 17px; height: 17px; } + +/* ------------------------------------------------------------ first-visit intro + The hero settles in on the first load of a visit instead of appearing all at once. + Deliberately the same movement as the scroll reveals below the fold (a short rise + and a fade) so it reads as one behaviour rather than an effect. Runs once per tab: + site.js sets .intro, and clears it after the last child has finished. */ + +.js.intro .hero .eyebrow, +.js.intro .hero h1, +.js.intro .hero .lead, +.js.intro .hero .actions, +.js.intro .hero-stage { + opacity: 0; + animation: introUp .85s var(--ease) forwards; +} +.js.intro .hero .eyebrow { animation-delay: .04s; } +.js.intro .hero h1 { animation-delay: .12s; } +.js.intro .hero .lead { animation-delay: .24s; } +.js.intro .hero .actions { animation-delay: .34s; } +.js.intro .hero-stage { animation-delay: .42s; animation-duration: 1.05s; } +@keyframes introUp { + from { opacity: 0; transform: translateY(18px); } + to { opacity: 1; transform: none; } +} +/* The phone in the hero lifts a little further, so it arrives last and reads as depth. */ +.js.intro .hero-stage { animation-name: introRise; } +@keyframes introRise { + from { opacity: 0; transform: translateY(34px) scale(.985); } + to { opacity: 1; transform: none; } +} +@media (prefers-reduced-motion: reduce) { + .js.intro .hero .eyebrow, + .js.intro .hero h1, + .js.intro .hero .lead, + .js.intro .hero .actions, + .js.intro .hero-stage { opacity: 1; animation: none; } +}