Manual
Almnck.
Price: 50ⓐ

Mobile Margins Design

Date: 2026-01-24 Status: Ready for implementation

Overview

Transform the mobile reading experience from inline footnotes to a swipeable three-column layout that preserves the desktop’s spatial relationship between text and marginalia.

The Spatial Model

On touch devices (pointer: coarse), the article becomes a horizontally-scrollable viewport containing three full-height columns: left margin, main content, right margin. Each column is 100vw wide, but scroll-padding-inline: 5vw on the container creates visible peek gutters at rest—revealing ~5vw of each adjacent column.

┌─────────────────────────────────────┐
│ ☞│        Main Content         │☜ │
│   │                             │   │
│ 5%│           90%               │5% │
└─────────────────────────────────────┘
     gutter      center          gutter

The manicules (☞/☜) in the gutters point inward, hinting at swipeable margin content.

Synchronized Scrolling

All three columns share one vertical scroll position. When you scroll in any column, all columns scroll together. It’s one tall page with three parallel strips; you’re always at the same vertical position across all three.

When you swipe horizontally to a margin, you’re already at the right vertical position to see sidenotes relevant to where you were reading.

┌──────────┬──────────┬──────────┐
│  Left    │   Main   │  Right   │  ← all at same
│  Margin  │  Content │  Margin  │    scroll position
│          │          │          │
│    ☞     │   ¶ ¶ ¶  │    ☜     │
│          │          │          │
└──────────┴──────────┴──────────┘
              ↕ scroll synced

Footnote Tap

Tapping a footnote superscript: 1. Determines which margin column contains the sidenote (left or right, alternating) 2. Smoothly snaps horizontally to that column 3. Smoothly scrolls vertically to center the sidenote 4. Briefly highlights the sidenote

For offset sidenotes (pushed down due to collision avoidance), the animated vertical scroll makes the distance legible—showing the spatial relationship between anchor and note.

Backref Tap

Tapping “§ back §” in a sidenote: 1. Snaps horizontally back to main column 2. Scrolls vertically to the footnote anchor 3. Briefly highlights the anchor

Manual Swipe

Swiping left/right navigates between columns at the current scroll position. No automatic vertical adjustment—user explores freely.

Margin Boxes

Margin boxes (quotes, poems, ads) receive the same treatment as sidenotes—they live in the margins at their positioned locations. Users discover them by scrolling the margin column or swiping to explore.

CSS Implementation

The layout stays as CSS Grid, changing only the column sizing:

@media (pointer: coarse) {
  .margins-layout {
    /* Keep grid, change columns to full viewport width */
    grid-template-columns: 100vw 100vw 100vw;

    /* Horizontal scroll-snap */
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    scroll-padding-inline: 5vw;

    /* Hide scrollbar */
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .margins-layout::-webkit-scrollbar {
    display: none;
  }

  /* Column snap targets */
  .margin-left,
  .body-text,
  .margin-right {
    scroll-snap-align: start;
    scroll-snap-stop: always;
  }
}

Desktop vs Mobile Comparison

Property Desktop Mobile (touch)
grid-template-columns minmax(12rem, 0.33fr) minmax(22rem, 1fr) minmax(12rem, 0.33fr) 100vw 100vw 100vw
overflow-x visible auto + scroll-snap
Column visibility all visible one visible + peek gutters

Progressive Enhancement

Without JavaScript, sidenotes aren’t created and margins would be empty. The swipe layout only activates when JS succeeds:

/* Default: single column, footnotes inline */
@media (pointer: coarse) {
  .margins-layout {
    display: block;
  }

  .margin-left,
  .margin-right {
    display: none;
  }

  .footnotes {
    display: block;
  }
}

/* JS-enabled: swipe layout */
@media (pointer: coarse) {
  .swipe-margins-enabled .margins-layout {
    display: grid;
    grid-template-columns: 100vw 100vw 100vw;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: 5vw;
    scroll-behavior: smooth;
    scrollbar-width: none;
  }

  .swipe-margins-enabled .margin-left,
  .swipe-margins-enabled .margin-right {
    display: block;
  }

  .swipe-margins-enabled .footnotes {
    display: none;
  }
}

Load Sequence

  1. Page loads with single-column layout (no-JS default)
  2. JS runs, creates sidenotes, adds .swipe-margins-enabled to body
  3. CSS transitions to swipe layout
  4. JS scrolls to main column (instant, before user sees anything)

JavaScript Enhancements

Initialization

if (window.matchMedia('(pointer: coarse)').matches) {
  document.body.classList.add('swipe-margins-enabled');
  initMobileNavigation();
}

Footnote Tap Handler

footnoteRef.addEventListener('click', (e) => {
  if (!isTouchDevice()) return;

  e.preventDefault();
  const sidenote = document.getElementById(`sn:${index}`);
  const column = sidenote.closest('.margin-left, .margin-right');

  // Horizontal snap
  column.scrollIntoView({ behavior: 'smooth', inline: 'start' });

  // Vertical scroll to sidenote
  sidenote.scrollIntoView({ behavior: 'smooth', block: 'center' });

  // Highlight
  sidenote.classList.add('highlighted');
  setTimeout(() => sidenote.classList.remove('highlighted'), 2000);
});

Load Behavior

On page load, scroll the container to the main column (scroll position 100vw). No animation—instant positioning before first paint.

Automated Testing with Playwright

Tests use Playwright with iPhone device emulation to verify touch interactions:

Test Cases

  1. starts centered on main column - Verify initial scroll position
  2. peek gutters show manicules - Manicules visible in 5vw gutters
  3. footnote tap navigates to sidenote - Tap footnote, verify horizontal scroll and highlight
  4. backref returns to main column - Tap backref, verify return navigation
  5. swipe navigates between columns - Simulate swipe gesture, verify snap
  6. no-JS fallback shows inline footnotes - Disable JS, verify fallback layout

Makefile Integration

test-mobile:
    npx playwright test tests/mobile-margins.spec.js

test-mobile-headed:
    npx playwright test tests/mobile-margins.spec.js --headed

Files to Modify

File Changes
assets/css/almanack.css Add @media (pointer: coarse) rules for swipe layout
assets/js/sidenotes.js Add touch detection and navigation handlers
tests/mobile-margins.spec.js Playwright test suite (new)
playwright.config.js Playwright configuration (new)
Makefile Add test-mobile target
package.json Add Playwright dependency (new)

Testing Checklist

  • [ ] Swipe navigation between columns
  • [ ] Peek gutters show manicules
  • [ ] Footnote tap jumps to correct sidenote
  • [ ] Backref tap returns to anchor
  • [ ] Offset sidenotes animate scroll visibly
  • [ ] No-JS fallback shows inline footnotes
  • [ ] Desktop unchanged (pointer: fine)
  • [ ] Playwright tests pass