website: fix the dialog, align the rail, and add a first-visit intro

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 <dialog>,
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.
This commit is contained in:
Duarte Santos committed 2026-08-25 22:50:28 +02:00
1 parent 57ab683bf6
commit 1290db11b5
5 files changed
+93 -10

No files matched your search

+2 -2
View File
@@ -9,7 +9,7 @@
<link rel="icon" type="image/png" sizes="512x512" href="icon-512.png">
<link rel="icon" type="image/png" sizes="180x180" href="icon-180.png">
<link rel="apple-touch-icon" href="icon-180.png">
<link rel="stylesheet" href="styles.css?v=6">
<link rel="stylesheet" href="styles.css?v=8">
<script>document.documentElement.className += ' js'</script>
<!-- Umami web analytics for opengym.duarte-santos.ch (self-hosted, cookieless). -->
<script defer src="https://stats.duarte-santos.ch/script.js" data-website-id="db36019e-50f4-453c-9c56-d0588aefe233"></script>
@@ -130,6 +130,6 @@
</div>
</div></footer>
<script src="site.js?v=6" defer></script>
<script src="site.js?v=8" defer></script>
</body>
</html>
+2 -2
View File
@@ -9,7 +9,7 @@
<link rel="icon" type="image/png" sizes="512x512" href="icon-512.png">
<link rel="icon" type="image/png" sizes="180x180" href="icon-180.png">
<link rel="apple-touch-icon" href="icon-180.png">
<link rel="stylesheet" href="styles.css?v=6">
<link rel="stylesheet" href="styles.css?v=8">
<script>document.documentElement.className += ' js'</script>
<!-- Umami web analytics for opengym.duarte-santos.ch (self-hosted, cookieless). -->
<script defer src="https://stats.duarte-santos.ch/script.js" data-website-id="db36019e-50f4-453c-9c56-d0588aefe233"></script>
@@ -209,6 +209,6 @@ docker compose up -d</code></pre>
</div>
</div></footer>
<script src="site.js?v=6" defer></script>
<script src="site.js?v=8" defer></script>
</body>
</html>
+14 -3
View File
@@ -14,10 +14,21 @@
<link rel="icon" type="image/png" sizes="512x512" href="icon-512.png">
<link rel="icon" type="image/png" sizes="180x180" href="icon-180.png">
<link rel="apple-touch-icon" href="icon-180.png">
<link rel="stylesheet" href="styles.css?v=6">
<link rel="stylesheet" href="styles.css?v=8">
<!-- Marks that JS is alive before first paint, so the scroll-reveal styles never
hide content from a browser that will not run them. -->
<script>document.documentElement.className += ' js'</script>
<script>
/* Before first paint: .js arms the scroll reveals, .intro plays the hero entrance once per
tab. Deferred scripts run too late for this — the hero would paint, then vanish and
animate back in. site.js takes .intro off again when the animation ends. */
document.documentElement.className += ' js'
try {
if (!sessionStorage.getItem('og-intro')) {
sessionStorage.setItem('og-intro', '1')
document.documentElement.className += ' intro'
}
} catch (e) { document.documentElement.className += ' intro' }
</script>
<!-- Umami web analytics for opengym.duarte-santos.ch (self-hosted, cookieless). -->
<script defer src="https://stats.duarte-santos.ch/script.js" data-website-id="db36019e-50f4-453c-9c56-d0588aefe233"></script>
<script type="application/ld+json">
@@ -479,6 +490,6 @@
</div>
</div></footer>
<script src="site.js?v=6" defer></script>
<script src="site.js?v=8" defer></script>
</body>
</html>
+12
View File
@@ -234,3 +234,15 @@ const GL_PROJECT = 'https://gitlab.com/api/v4/projects/DuarteSantos8%2Fopengym'
sync()
}
})()
/* The hero intro is armed in the inline <head> 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
})()
+63 -3
View File
@@ -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; }
}