# Recreate this site as a single HTML file: Field Notes — a newsletter landing page around a live 3D globe of past issues

## What it is
A landing page for **Field Notes**, a fictional free nature and science newsletter that comes out every other Thursday. Four correspondents write from places where the planet keeps its records: a peat bog, a coral reef, a glacier and others.

- **The page:** a night-blue hero with a subscribe form; an atlas list; then a warm paper-and-ink body with proof, "what you get", a 12-issue archive with an in-page reader view, the correspondents, an FAQ; and a night-blue footer sign-up with a live countdown to the next issue.
- **Signature:** a live three.js Earth.
  - It is built from NASA Blue Marble and Black Marble imagery, with a bump-mapped day side, ocean glint, a twilight band, city lights on the night side, procedural drifting clouds that cast soft shadows, and an atmosphere rim.
  - The terminator is placed from the **real sun position at page load**, and the HUD shows the subsolar point.
  - Each past issue is a glowing field-report pin at its real coordinates, and comet-like particle streams run along great circles between the issues in date order.
  - Hover a pin to see the issue title and place. Click it and the camera flies there while the sunlight swings round to morning, then the issue opens in a reader view.
  - The globe idles, follows the cursor with spring tilt, and can be dragged.
- **The form really works.** One `CONFIG.provider` switch connects it to Ghost, any provider's own embed code (beehiiv, Substack, Kit and others), a custom endpoint, or demo mode.

## Page shell & libraries
- One `index.html` with inline CSS and JS, and images in `assets/`.
- three.js **0.170.0** comes from jsDelivr through an import map:
  - `"three": "https://cdn.jsdelivr.net/npm/three@0.170.0/build/three.module.js"`
  - `"three/addons/": "https://cdn.jsdelivr.net/npm/three@0.170.0/examples/jsm/"`
- Dynamically import `three`, `EffectComposer`, `RenderPass`, `UnrealBloomPass` and `ShaderPass`, so the fallback path never downloads three.js.
- Google Fonts: **Fraunces** (variable: opsz 9–144, wght 300–700, SOFT 0–100, plus italic), **Newsreader** (opsz 6–72, 400–600, plus italic), **IBM Plex Mono** (400, 500) and **Caveat** (500–600, used only for hand-written margin notes).
- A tiny inline `<head>` script sets classes before first paint:
  - `gl loading` when WebGL2 exists, otherwise `nogl`; `?static` forces `nogl`;
  - `rm` when `prefers-reduced-motion: reduce`.
- No other libraries.

## Tokens
- **Paper body:** paper `#f2ebdd`, paper-2 `#e9dfcc` (archive band), paper-3 `#dccfb5`; ink `#1d1812`, ink-2 `#4d4236`, ink-3 `#655849` (≥ 5.2:1 on both papers). Rules are `rgba(29,24,18,.18)` and, for strong rules, `.34`. Rust accent `#a3401e`.
- **Paper texture:** an inline SVG `feTurbulence` noise at 7% alpha, tinted brown.
- **Night zone:** night `#070c18`, night-2 `#0e1628`; text `#ece5d6`; muted text `#a7b1c3`; hairline `rgba(236,229,214,.16)`; glow `#ffb35c` and `#ffd59a` (pins, button, accents).
- **Topic colours:** wetlands `#6b4423`, oceans `#1d4c66`, ice `#3b5d73`, forests `#3d5636`, drylands `#93461a`.
- **Type:**
  - h1 is Fraunces 300, `clamp(42px,5.3vw,84px)`, line-height .98, tracking −.025em, `"SOFT" 50, "opsz" 144`; the italic accent word is in glow-2.
  - h2 is Fraunces 300, `clamp(34px,3.6vw,56px)`, with an italic second phrase.
  - Body is Newsreader 18px/1.55 (17px on phones).
  - Labels, meta, HUD and buttons are Plex Mono, 11–13px, uppercase, tracking .06–.08em.
- **Shape:** radius 3px. Pills only on chips and the nav subscribe button. No glassmorphism, except a 4px blur on the mobile atlas panel.
- **Spacing:** gutter `clamp(16px,5.5vw,88px)`, section padding `clamp(72px,10vw,140px)`, hit targets ≥ 40px (48px for the main buttons).

## Layout & structure
1. **Preloader** (full screen, night, only when `.gl`):
   - the "Field *Notes*" wordmark;
   - a mono readiness log whose lines are real steps: Modules (three r170 · 4 passes), Earth plates 0/2 → 2/2, Stars (count), Field pins (13 plotted), Shaders (`renderer.info.programs.length` after `compileAsync`), Warm frames 3/3 · bloom + grade;
   - a 2px gradient progress bar;
   - it fades out over .9s. A 9s failsafe always hides it.
2. **Fixed canvas** behind the night zone, full viewport. `#night` and its sections are `pointer-events:none` and only real controls (`.live`) take pointer events, so the globe stays draggable around the text.
3. **Masthead:** a compass logo (an SVG ring with a glow-coloured needle) + "Field Notes". Nav: Archive / What you get / FAQ / a **Subscribe** pill. Below 760px only the pill shows.
4. **Hero** (min-height 100svh), with the copy at left, max-width `min(560px,46vw)`:
   - kicker "● No. 112 out now · every other Thursday";
   - h1 "Dispatches from the places the planet keeps its *records.*";
   - a deck paragraph;
   - the sign-up form;
   - a proof line: **41,860** readers · **96** countries · **61%** open every issue.
   - **HUD bar** at the bottom: "Sun overhead now 21.0°S 44.3°E · 08:48 UTC" | "Cursor 58.40°N 3.80°W" (live, from a ray–sphere hit) | "Drag to turn · click a pin to read".
5. **Atlas** (min-height 115svh):
   - eyebrow "The atlas", h2 "Twelve dispatches, pinned *where they were written.*";
   - a list of 13 buttons: No., place, coordinates. The last one is "No. 113 · *Sealed until it lands*".
   - Hovering or focusing a row highlights its pin; clicking flies there and opens the issue.
6. **Paper body**, which starts with an irregular torn-paper SVG edge, 24px high.
   - **Proof:**
     - a huge count-up "41,860" (Fraunces 300, up to 176px);
     - a caption, then a 3-cell ledger: Open rate 61% · Issues sent 112 · Since 2022;
     - three reader quotes as pinned specimen labels: off-white cards with a strip of tape, rotated −.8°, .9° and −.3° on an offset 6-column grid, and a Caveat note "specimens of reader mail ↓";
     - the line "Field Notes is a fictional publication…".
   - **What you get**, in two columns:
     - Left: "Every other Thursday, 07:00" with a 4-week calendar (today outlined in rust; issue days in solid ink with a glow dot), "Next: No. 113 on 3 Dec 2026, then No. 114 on 17 Dec 2026", then "Five beats" as topic tags with live issue counts.
     - Right: "Anatomy of an issue". A mini issue sheet (masthead, title, opening lines, photo plate, Specimen and Reading boxes) carries rust numbered markers 1–4, with matching Caveat notes in a side column (The dispatch / The plate / The specimen / The reading).
   - **Archive** (paper-2 band):
     - a toolbar under a 2px ink rule: topic chips (All 12 · Wetlands 3 · Oceans 2 · Ice 3 · Forests 2 · Drylands 2), a search field and a sort select (Newest / Oldest / Shortest read);
     - a live count "Showing 3 of 12 issues · Ice";
     - a 3/2/1-column card grid. Each card has a 3:2 photo with a "No. 110" tag, meta (topic in its colour · date · minutes), a Fraunces title, a dek, and a footer with the place plus a **Locate** button;
     - an empty state with **Clear filters**.
   - **Correspondents:** 4 columns, each with a double-ring initials stamp in the writer's topic colour, a name, beat · base, and one line.
   - **FAQ:** `<details>` accordions with a +/− circle. The privacy answer has `id="faq-privacy"`, which the consent links point to.
7. **Footer sign-up** (night-2, with a warm radial glow at the right):
   - "Next dispatch · No. 113 lands *Thursday 3 December.*";
   - a days/hours/minutes countdown computed from a fortnightly anchor (19 Nov 2026 07:00 UTC);
   - the second form, with an optional first name;
   - then the colophon with the image credits.
8. **Reader** (`<dialog>`, 1180×860 max, full screen on phones):
   - left: the photo with a Caveat place name and coordinates;
   - right: a bar ("Field Notes · No. 110 · 22 Oct 2026", ← Prev / Next → / Close ✕), kicker (topic · minutes · by writer), title, italic dek, two paragraphs with a rust drop cap, Specimen and Reading boxes, and an end block with **Get the next one** (scrolls to the footer form and focuses the email field) and **Show on the globe**.

## The globe (three.js)
- **Renderer:** WebGL2, `antialias:false`, pixel ratio ≤ 1.75 (≤ 1.5 in the low tier), `NoToneMapping`. Tone mapping happens in the grade pass.
- **Background:** linear (0.0016, 0.0032, 0.0085).
- **Camera:** PerspectiveCamera with fov 32.
- **Hierarchy:** scene → tiltGroup (`rotation.x`) → spinGroup (`rotation.y`). The globe, clouds, pins and routes sit inside spinGroup; the atmosphere and stars sit in the scene.
- **Lat/lon → vector**, matching SphereGeometry UVs: `ph=(lon+180)°`, `x=-cos(ph)cos(lat)`, `y=sin(lat)`, `z=sin(ph)cos(lat)`.
- **Textures:**
  - `earth-day.webp` (2048×1024, sRGB);
  - `earth-pack.webp` (linear), packed as R = water mask, G = topography, B = city lights (red minus 0.7 × blue from the night image, levelled).
- **Globe shader** (SphereGeometry(1,192,128), or 112×72 in the low tier). The fragment shader does, in order:
  - bump normal from topography differences one texel east and north, along east/north tangents, strength 2.2;
  - `dayAmt = smoothstep(-.10,.20,N·L)`;
  - diffuse `day*(.025+diff*1.35)`;
  - water tinted `(.86,.93,1.05)`;
  - ocean glint `pow(N·H,90)*1.7 + pow(N·H,14)*.07`, times the water mask;
  - twilight band `exp(-(ndl/.14)²)` tinting `(1.5,.82,.52)`;
  - cloud shadow (×(1−.35·cloud));
  - night lights `(1,.62,.30)*pow(lights,1.7)*3.0`;
  - fresnel rim `pow(1−N·V,3.2)`, coloured orange→blue across the terminator.
- **Clouds:** a sphere at r=1.009 with a 3D simplex fBm (5 octaves, 4 in the low tier).
  - Domain-warped by 0.22, scaled ×3.1, drifting `(t·.006, 0, t·.003)`.
  - Latitude bias: fewer in the subtropics, more at high latitudes; coverage `smoothstep(.10−bias, .50−bias, n)`.
  - Sun-lit with a twilight tint, alpha × .85, fading at the limb.
  - The same `cloudAt()` function drives the ground shadows.
- **Atmosphere:** a BackSide sphere at r=1.16, additive.
  - Intensity `pow(clamp(−n_view·z/0.5,0,1),2.6)`, so it is bright at the globe edge and fades outward.
  - Colour mixes orange (1,.45,.18) → blue (.32,.6,1) with sun-facing; ×2.2.
- **Sun:**
  - Hero direction `(-0.74,0.30,0.16)`; focus direction `(-0.50,0.32,0.80)`.
  - The initial spin is set so the real subsolar point (low-precision solar ephemeris: mean longitude, anomaly, obliquity, GMST) faces the hero sun.
  - The grade pass adds an off-frame warm sun leak at uv (−0.12, 0.95).
- **Stars:** 260k points (80k in the low tier) on a shell at r 60–150, 45% pulled toward a galactic band.
  - Size `0.55+m·2.6` with `m=rand^9`; colour mostly cool white with some warm; brightness `.10+m·2.6`, so the brightest bloom.
  - Twinkle `.72+.28·sin(t·(.6+seed·2.2)+seed·60)`; additive.
- **Routes:** 40k points (9k in the low tier) across the 12 legs (issues in date order, then a pale-blue leg to the sealed No. 113).
  - Each point slerps along its great circle with `t=fract(aT+time·(.018+.02/(angle+.4)))`, lifted by `1.006+(.012+.07·angle/π)·sin(πt)`.
  - Brightness is `sin(πt)·aT^2.2`, so each leg reads as a comet with a tail. Additive.
- **Pins:** one Points draw of 13 pins at r=1.05, plus additive stem lines from the surface.
  - The point shader has a white-hot core, a glow halo, and an expanding pulse ring (period 2.2s).
  - The latest issue is 54px (others 40px); a hovered pin is ×1.6.
  - The sealed next-issue pin is pale blue, with a dashed rotating ring and no core.
- **Post:** RenderPass → UnrealBloomPass(strength .5, radius .55, threshold .93) → grade ShaderPass:
  - chromatic aberration .0016 along the radius;
  - sun leak `exp(-3.6·dist)`;
  - ACES fitted curve at exposure 1.18, then gamma 2.2;
  - split tone (cool shadows `(.92,.98,1.08)`, warm highlights `(1.04,1,.94)`);
  - vignette to .62;
  - animated hash grain ±.045.

## Behaviour & interaction
- **Shots** (computed from the viewport, then applied with `camera.setViewOffset` so the camera always looks at the globe centre).
  - Desktop:
    - A (hero): radius `min(.36H,.24W)`, centre `(max(.70W, W−r−.08W), .52H)`;
    - B (atlas): radius `min(.46H,.28W)` at `(.69W,.5H)`;
    - F (open): radius `min(.85H,.7W)`, centred;
    - L (locate): A × 1.3.
  - Stacked (width < 900 or aspect < 1.1): A at the top centre, radius `min(.40W,.22H)`, and JS sets `--gb`, the hero's top padding, to just below the globe.
  - Camera distance for a target radius: `d = sqrt(1+((H/2)/(r·tan(fov/2)))²)`.
- **Scroll:** `p = scrollY/atlas.offsetTop`, eased with smoothstep, blends shot A → B.
- **Intro:** over 2.6s, ease-out-cubic: distance ×1.9 → 1, spin −1.1 rad → 0, tilt +.25 → 0.
- **Idle:** spin 0.045 rad/s (×0.15 while a pin is hovered); base tilt .38 rad (north toward the viewer).
- **Cursor springs:** yaw ±.25 and pitch ±.12, damped with `1−exp(−dt·3.5)`.
- **Drag:** turn with `dx·.0055` and tilt with `dy·.004`, clamped −1.1…1.2; on release, inertia decays with `exp(−dt·2.2)`. The canvas has `touch-action: pan-y`.
- **Hover:** project each pin to the screen, take the nearest within 26px whose normal faces the camera (>.12), and position a fixed tooltip above it: "No. 111 · Raja Ampat, Indonesia", the title in Fraunces, then coordinates · minutes. A "Latest · No. 112" tag tracks the newest pin when nothing is hovered.
- **Fly-to:**
  - spin target `−atan2(x,z)` of the pin (wrapped to the shortest way), tilt target = latitude (clamped ±1.2);
  - tween 1.7s ease-in-out-cubic, blending the camera into shot F and the sun from hero to focus direction;
  - then `showModal()` the reader.
  - Closing the reader releases over 1.3s back to the scroll shot.
  - "Locate" (from a card or the reader) scrolls to the top, flies to shot L without opening, shows the tooltip, and releases after 6.5s or on the next drag.
- **Archive:** chips toggle `aria-pressed`. Search matches every word against title, place, dek, topic, writer and body. The sort reorders DOM nodes. The live count and empty state update together.
- **Reader:** Prev/Next (and ←/→), Esc, a backdrop click and Close all work. The URL hash `#issue-N` deep-links and is cleared on close. Focus returns to the opener.
- **Count-up:** 41,860 over 1.6s, ease-out-quart, when 40% in view.
- **Countdown:** updates every 30s. The calendar, next issue numbers and dates all derive from the anchor.

## Sign-up form (both instances)
Fields:
- email (`type=email`, `autocomplete=email`) and an optional first name in the footer;
- **consent checkbox** (required) linking to `#faq-privacy`;
- **honeypot** `website` input, off-screen, `tabindex=-1`;
- `aria-live` error paragraph, and a double opt-in note: "We email you once to confirm (double opt-in). No click, no newsletter."

Validation, in order, with the field focused and `aria-invalid` set:
1. empty → "Add your email address…";
2. bad format → "That address looks incomplete. Check the part after the @." (or "it needs an @");
3. consent unticked → "Tick the box to confirm…".

If the honeypot is filled, pretend success and send nothing. Success replaces the form with a focused `role=status` box: "Nearly there. Check your inbox." It names the address, the next issue and its date, and has a "Use a different address" reset. Demo mode shows a dashed "Demo mode · nothing is sent" badge.

## Connect your newsletter
Set `CONFIG.provider` at the top of the main script to `"demo"`, `"ghost"`, `"embed"` or `"custom"`. `"beehiiv"`, `"substack"` and `"kit"` are accepted as aliases of `"embed"`, so the setting stays readable; they only change the provider name in the consent text. Never put API keys in the page: none of these modes needs one. Research was done on **2026-11-26**, and how far each one could be verified is stated below.

- **`"demo"`** (default): validates, waits 700ms, shows success, sends nothing.
- **`"ghost"`, verified on 2026-11-26 from https://ghost.org/help/embeddable-signup-forms/**, and from the embed generator in Ghost's own code (npm `ghost@6.79.0`).
  - In Ghost Admin, go to **Settings → Growth → Signup forms** and click **Embed** next to "Embeddable signup form". In Ghost's words: "you can copy the embed code for use anywhere on the web."
  - Set `CONFIG.ghost.site` to `"https://your-site.com"`. Optional: `labels` (Ghost's "Labels at signup"), `locale`, `buttonColor`, and `title`/`description`/`icon`/`backgroundColor`.
  - After consent, the page injects the same code Ghost Admin generates: a wrapper `div` with the script `https://cdn.jsdelivr.net/ghost/signup-form@~0.4/umd/signup-form.min.js` (Ghost's own version line; patch releases arrive automatically) carrying `data-button-color`, `data-button-text-color`, `data-site`, `data-locale` and `data-label-1…n`.
  - With `title` and `description` empty, this is Ghost's **minimal** layout, in a wrapper styled `min-height: 58px;max-width: 440px;margin: 0 auto;width: 100%`.
  - If `title` or `description` is set, it switches to Ghost's **all-in-one** layout: it adds `data-background-color`, `data-text-color` (black or white, whichever reads on the background), `data-title`, `data-description` and `data-icon`, in a wrapper styled `height: 40vmin;min-height: 360px`.
  - The script injects Ghost's own iframe form, sized to that wrapper. Ghost then emails a magic link to confirm (double opt-in by design).
- **`"embed"` (beehiiv, Substack, Kit and others): paste your provider's embed code.** In your provider's dashboard, open its embed or subscribe-form option and copy the embed code. Paste it into `CONFIG.embedHtml` between backticks, exactly as given (an iframe or a script).
  - Inside the page's script, write each closing script tag of the snippet as `<\/script>`, or the page's own script ends early.
  - After consent, the page puts the snippet into the form slot and re-creates any `<script>` in it so that it runs, keeping each script's attributes (and order, unless the snippet marks it `async`).
  - We could not confirm beehiiv's, Substack's or Kit's current menu paths on 2026-11-26, because their help centres blocked our automated access. Follow the provider's own help for where the embed code lives, and preview the form before launch.
- **API keys stay on a server.** beehiiv's API takes a Bearer API key that "should be kept secret at all times" and only "exposed on the server side" (https://developers.beehiiv.com/welcome/create-an-api-key). Kit's V4 API uses OAuth or an `X-Kit-Api-Key` header (https://developers.kit.com/api-reference/authentication), and its V3 API is deprecated. Neither belongs in this page. If you want your own form to add subscribers through those APIs, use `"custom"` with your own endpoint, and keep the key there.
- **`"custom"`:** POSTs `{email, first_name, consent:true, source}` as JSON (or form-encoded with `format:"form"`) to `CONFIG.custom.url`. A non-2xx answer shows an error; 409 → "already subscribed". Use it with your own serverless function that holds any secret API key server-side.
- **Consent gating for `"ghost"` and `"embed"`:** the email field is hidden and the consent text becomes "…and load the sign-up form from {Provider} (it connects to their servers and may set cookies)". The provider's form loads **only after** the box is ticked. Validation, confirmation and spam protection then happen inside the provider's form; the note under it says so (and, for Ghost, that it emails a link to confirm).

## Responsive
- **1440:** the hero copy sits left and the globe right (no overlap with the copy column); the atlas list is 440px wide at left; the card grid has 3 columns; proof, get and FAQ use 2-column grids.
- **768 / portrait** (width < 900 or aspect < 1.1): the globe is centred at the top and the hero copy flows below it (`padding-top: var(--gb)`). The atlas panel becomes a translucent night card over the globe. All 2-column grids stack; the card grid has 2 columns.
- **390:**
  - mast shows the pill only; the form button goes full width under the input; HUD is one column (sun + cursor);
  - atlas rows drop the coordinates; the card grid and correspondents are 1 column; quotes stack without rotation offsets;
  - the reader goes full screen with the photo at 30svh on top.
- No horizontal scroll at 390, 768 or 1440. `body{overflow-x:hidden}` is a guard, not a crutch: every grid uses `minmax(0,1fr)`.

## Accessibility & reduced motion
- Skip link; landmark sections with `aria-labelledby`.
- The canvas is `aria-hidden`; the atlas list is the keyboard route to every pin, and focusing a row highlights its pin.
- Visible 2px focus rings: glow on night, rust on paper. Card titles are real buttons, with a stretched hit area and a focus ring on the whole card.
- The reader is a native modal dialog.
- Form errors are announced; `aria-invalid` toggles.
- All text ≥ 4.5:1 (muted paper text 5.2–5.8:1; muted night text 8–9:1).
- Every photo has descriptive alt text.
- **Reduced motion:** no preloader delay, no intro, no idle spin, no cursor tilt and no twinkle or route flow (time frozen). Flights become instant cuts. The scene renders on demand only. The count-up shows its final value and CSS transitions are off.

## Fallbacks
- No WebGL2, or `?static`: show `assets/globe-poster.webp` (a render of the same globe, with a radial mask) at the globe's position, hide the canvas, "Locate" and "Show on the globe", and send atlas buttons straight to the reader.
- Any boot error falls back the same way.
- Rendering pauses when `#night` is off-screen (IntersectionObserver) and on `visibilitychange`; the tooltip hides when it pauses.
- Low tier (≤ 760px wide or ≤ 4 cores): 80k stars, 9k route points, lower sphere segments, no cloud shadows.

## Assets
- `assets/earth-day.webp`: NASA Blue Marble (with bathymetry), equirectangular 2048×1024. Public domain.
- `assets/earth-pack.webp`: R water mask, G topography, B city lights (from NASA Black Marble). Public domain.
- `assets/globe-poster.webp`: 900×900 render of the live globe, for the no-WebGL fallback.
- `assets/issue-*.webp`: 12 original 1000px documentary plates in one 35mm-film grade, muted colour, fine grain, no people, no text:
  - `bog`: Flow Country peat pools with cotton grass;
  - `reef`: Raja Ampat corals and blue fish;
  - `glacier`: ash-striped ice front over a lagoon;
  - `kelp`: kelp forest with a garibaldi;
  - `mangrove`: Sundarbans breathing roots at low tide;
  - `cloudforest`: mossy trunks in mist;
  - `saltflat`: Uyuni hexagon crust at dusk;
  - `tundra`: Svalbard polygon ground;
  - `delta`: Okavango channels;
  - `oldgrowth`: fallen mossy oak, Białowieża;
  - `bloom`: Atacama desert flowers;
  - `baikal`: clear cracked lake ice.

## Make it yours
This prompt rebuilds one exact design. If everyone ships it unchanged, the sites will look alike. Before you paste it, change these lines so the result is yours. Each change is one edit to the prompt; the structure and the interactions stay intact.

1. **Brand and beat.** Swap Field Notes, its four correspondents and the nature/science beat for your own newsletter. Keep 12 archive issues and 3–6 topics, so the chips, the grid and the atlas list stay balanced. Every issue still needs a real place with coordinates.
2. **Re-theme the globe.** Keep the pins, fly-to and reader, but change what the sphere is:
   - **the Moon** (LRO colour map, no clouds or lights; pins are landing sites) for a space letter;
   - **Mars** (MOLA shaded relief, dust-orange atmosphere) for a geology letter;
   - **a night-only Earth** (Black Marble only, gold city lights, no day side) for a cities or travel letter;
   - **an ocean-only globe** (bathymetry ramp, land in flat ink) for a marine letter.
3. **Palette.** Replace paper `#f2ebdd`, ink `#1d1812`, rust `#a3401e`, night `#070c18` and glow `#ffb35c` with your own. Keep muted text ≥ 4.5:1 on its background. The glow colour drives the pins, the button and the route comets, so change them together.
4. **Type pairing.** Swap Fraunces + Newsreader for another display serif and reading face (e.g. Instrument Serif + Literata, or Playfair + Source Serif 4). Keep a mono for the HUD and labels, and keep or drop the hand-written annotation face.
5. **Images.** Replace the 12 `issue-*.webp` plates with photos from your own issues, or regenerate them with one shared recipe: "documentary 35mm film photograph of {place}, overcast soft light, muted colour, fine grain, no people, no text". Keep them at 3:2, about 1000px and under 200 KB each.
6. **Signature details.** Change the sealed next-issue pin to your own teaser, the HUD readouts (e.g. local time at the latest pin instead of the subsolar point), and the route order (by topic instead of by date).
7. **Copy voice.** Rewrite the headline, deck, FAQ and reader excerpts in your own voice, with a concrete number in every issue. Avoid "unlock", "journey" and "dive into".
8. **Provider.** Set `CONFIG.provider`, then fill `CONFIG.ghost`, `CONFIG.embedHtml` or `CONFIG.custom`, following "Connect your newsletter" above.

Tell your AI: *"Build exactly as specified, but with these changes: …"*, then list your edits.

---

## Reference implementation (use verbatim)

The complete working `index.html`. Every number in the spec above is in this file; if the two ever seem to differ, the code wins. Images and models referenced as `assets/...` can be downloaded from https://copytheprompt.design/demos/science-newsletter-landing-globe/assets/ or replaced with your own (see Make it yours).

````html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Field Notes — a fortnightly letter from the field</title>
<meta name="description" content="Field Notes is a free fortnightly nature and science newsletter. Four correspondents write from the places the planet keeps its records: peat bogs, reefs, glaciers, deserts.">
<meta name="theme-color" content="#070c18">
<script>
/* Pick the render path before first paint. */
(function(){
  var h=document.documentElement, ok=false;
  try{ var c=document.createElement('canvas'); ok=!!(window.WebGL2RenderingContext && c.getContext('webgl2')); }catch(e){}
  if(/[?&]static\b/.test(location.search)) ok=false;
  h.classList.add(ok?'gl':'nogl');
  if(ok) h.classList.add('loading');
  if(window.matchMedia && matchMedia('(prefers-reduced-motion: reduce)').matches) h.classList.add('rm');
})();
</script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght,SOFT@0,9..144,300..700,0..100;1,9..144,300..700,0..100&family=Newsreader:ital,opsz,wght@0,6..72,400..600;1,6..72,400..500&family=IBM+Plex+Mono:wght@400;500&family=Caveat:wght@500..600&display=swap" rel="stylesheet">
<link rel="preload" as="image" href="assets/earth-day.webp" type="image/webp" crossorigin="anonymous">
<style>
:root{
  --paper:#f2ebdd; --paper-2:#e9dfcc; --paper-3:#dccfb5;
  --ink:#1d1812; --ink-2:#4d4236; --ink-3:#655849;
  --rule:rgba(29,24,18,.18); --rule-2:rgba(29,24,18,.34);
  --rust:#a3401e; --rust-2:#c2582f; --moss:#3d5636;
  --night:#070c18; --night-2:#0e1628; --night-3:#16213a;
  --n-ink:#ece5d6; --n-mute:#a7b1c3; --n-rule:rgba(236,229,214,.16);
  --glow:#ffb35c; --glow-2:#ffd59a;
  --t-wetlands:#6b4423; --t-oceans:#1d4c66; --t-ice:#3b5d73; --t-forests:#3d5636; --t-drylands:#93461a;
  --f-display:"Fraunces", "Iowan Old Style", Georgia, serif;
  --f-body:"Newsreader", "Iowan Old Style", Georgia, serif;
  --f-mono:"IBM Plex Mono", ui-monospace, Menlo, monospace;
  --f-hand:"Caveat", "Segoe Print", cursive;
  --gut:clamp(16px, 5.5vw, 88px);
  --gb:54svh;
  --r:3px;
}
*,*::before,*::after{box-sizing:border-box}
html{-webkit-text-size-adjust:100%;scroll-behavior:smooth}
html.rm{scroll-behavior:auto}
body{margin:0;background:var(--night);color:var(--n-ink);font-family:var(--f-body);font-size:18px;line-height:1.55;overflow-x:hidden}
img{max-width:100%;display:block}
button,input,select{font:inherit;color:inherit}
a{color:inherit}
:focus-visible{outline:2px solid var(--glow);outline-offset:3px;border-radius:2px}
.paper :focus-visible{outline-color:var(--rust)}
.sr-only{position:absolute!important;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}
.skip{position:absolute;left:12px;top:-60px;z-index:100;background:var(--glow);color:var(--ink);padding:10px 14px;font-family:var(--f-mono);font-size:13px;text-decoration:none}
.skip:focus{top:12px}
.mono{font-family:var(--f-mono);font-size:12px;letter-spacing:.08em;text-transform:uppercase}

/* ---------- Preloader ---------- */
#pre{position:fixed;inset:0;z-index:60;background:var(--night);display:none;place-items:center;transition:opacity .9s ease, visibility 0s linear .9s}
html.gl.loading #pre{display:grid}
#pre.done{opacity:0;visibility:hidden}
.pre-in{width:min(420px,84vw)}
.pre-mark{font-family:var(--f-display);font-weight:300;font-size:clamp(40px,9vw,64px);line-height:1;letter-spacing:-.02em;font-variation-settings:"SOFT" 60,"opsz" 144}
.pre-mark em{font-style:italic;color:var(--glow)}
.pre-log{list-style:none;margin:22px 0 14px;padding:0;font-family:var(--f-mono);font-size:12px;color:var(--n-mute);min-height:7.5em}
.pre-log li{display:flex;justify-content:space-between;gap:12px;padding:3px 0;border-bottom:1px dashed var(--n-rule)}
.pre-log li b{font-weight:500;color:var(--n-ink)}
.pre-bar{height:2px;background:var(--n-rule);position:relative;overflow:hidden}
.pre-bar i{position:absolute;inset:0;transform-origin:left;transform:scaleX(0);background:linear-gradient(90deg,var(--glow),var(--glow-2));transition:transform .3s ease}

/* ---------- Night zone (globe) ---------- */
#gl{position:fixed;inset:0;width:100%;height:100%;display:block;z-index:0;touch-action:pan-y;cursor:grab}
#gl.drag{cursor:grabbing}
#gl.over-pin{cursor:pointer}
html.nogl #gl{display:none}
#night{position:relative;z-index:1;pointer-events:none}
.mast{pointer-events:auto}
#night section{pointer-events:none}
#night section .live{pointer-events:auto}

.mast{position:absolute;top:0;left:0;right:0;z-index:5;display:flex;align-items:center;justify-content:space-between;gap:16px;padding:20px var(--gut)}
.logo{display:flex;align-items:center;gap:10px;text-decoration:none;font-family:var(--f-display);font-size:22px;font-weight:500;letter-spacing:-.01em;font-variation-settings:"SOFT" 80,"opsz" 40}
.logo svg{width:26px;height:26px}
.mast nav{display:flex;gap:4px;align-items:center}
.mast nav a{font-family:var(--f-mono);font-size:12px;letter-spacing:.08em;text-transform:uppercase;text-decoration:none;padding:10px 12px;color:var(--n-mute)}
.mast nav a:hover{color:var(--n-ink)}
.mast .pill{border:1px solid var(--n-rule);color:var(--n-ink);border-radius:99px;padding:9px 16px}
.mast .pill:hover{border-color:var(--glow);color:var(--glow)}

#hero{min-height:100svh;display:flex;align-items:center;padding:110px var(--gut) 120px;position:relative}
.hero-copy{max-width:min(560px,46vw)}
.kicker{display:flex;flex-wrap:wrap;gap:8px 14px;align-items:center;color:var(--n-mute);margin:0 0 22px}
.kicker .dot{width:7px;height:7px;border-radius:50%;background:var(--glow);box-shadow:0 0 12px var(--glow)}
h1{font-family:var(--f-display);font-weight:300;font-size:clamp(42px,5.3vw,84px);line-height:.98;letter-spacing:-.025em;margin:0 0 24px;font-variation-settings:"SOFT" 50,"opsz" 144;text-wrap:balance}
h1 em{font-style:italic;font-weight:300;color:var(--glow-2)}
.deck{font-size:clamp(17px,1.35vw,20px);color:#d3cdc0;margin:0 0 28px;max-width:34em;text-wrap:pretty}
.proof-line{display:flex;flex-wrap:wrap;gap:6px 18px;margin:22px 0 0;padding:0;list-style:none;color:var(--n-mute)}
.proof-line b{color:var(--n-ink);font-weight:500}

/* HUD */
.hud{position:absolute;left:0;right:0;bottom:0;display:grid;grid-template-columns:1fr auto 1fr;gap:16px;padding:16px var(--gut) 22px;color:var(--n-mute);font-family:var(--f-mono);font-size:11px;letter-spacing:.08em;text-transform:uppercase;border-top:1px solid var(--n-rule);background:linear-gradient(to top,rgba(7,12,24,.75),rgba(7,12,24,0))}
.hud span:nth-child(2){text-align:center}
.hud span:nth-child(3){text-align:right}
.hud b{color:var(--n-ink);font-weight:500}
html.nogl .hud .gl-only{visibility:hidden}

#tip,#tag-latest{position:fixed;z-index:4;left:0;top:0;pointer-events:none;transform:translate(-50%,calc(-100% - 16px));font-family:var(--f-mono);font-size:11px;letter-spacing:.06em;color:var(--n-ink);background:rgba(7,12,24,.88);border:1px solid rgba(255,179,92,.45);padding:8px 11px;border-radius:var(--r);max-width:260px;opacity:0;transition:opacity .2s}
#tip.on,#tag-latest.on{opacity:1}
#tip strong{display:block;font-family:var(--f-display);font-size:17px;font-weight:400;letter-spacing:-.005em;line-height:1.15;margin:3px 0 4px;text-transform:none;color:#fff}
#tip small{display:block;color:var(--glow-2);text-transform:uppercase}
#tag-latest{border-color:var(--n-rule);color:var(--glow-2);text-transform:uppercase;font-size:10px;padding:5px 8px}

/* Atlas */
#atlas{min-height:115svh;padding:16svh var(--gut) 14svh;position:relative}
.atlas-panel{max-width:440px}
.eyebrow{color:var(--glow-2);margin:0 0 14px}
h2{font-family:var(--f-display);font-weight:300;font-size:clamp(34px,3.6vw,56px);line-height:1.02;letter-spacing:-.02em;margin:0 0 16px;font-variation-settings:"SOFT" 40,"opsz" 120;text-wrap:balance}
h2 em{font-style:italic}
.atlas-sub{color:#cfc8ba;margin:0 0 22px;font-size:17px}
.places{list-style:none;margin:0;padding:0;border-top:1px solid var(--n-rule)}
.places button{all:unset;box-sizing:border-box;display:grid;grid-template-columns:52px 1fr auto;gap:10px;align-items:baseline;width:100%;padding:9px 6px;border-bottom:1px solid var(--n-rule);cursor:pointer;transition:background .2s}
.places button:hover,.places button.hot{background:rgba(255,179,92,.08)}
.places button:focus-visible{outline:2px solid var(--glow);outline-offset:-2px}
.places .n{font-family:var(--f-mono);font-size:11px;color:var(--glow)}
.places .t{font-family:var(--f-display);font-size:17px;line-height:1.2}
.places .c{font-family:var(--f-mono);font-size:10.5px;color:var(--n-mute);white-space:nowrap}
.places .next .t{font-style:italic;color:var(--n-mute)}
.atlas-hint{margin:16px 0 0;color:var(--n-mute)}

/* ---------- Forms ---------- */
.signup{max-width:520px}
.field-row{display:flex;gap:0;border:1px solid rgba(236,229,214,.36);border-radius:var(--r);background:rgba(7,12,24,.55);transition:border-color .2s}
.field-row:focus-within{border-color:var(--glow)}
.field-row input{flex:1;min-width:0;border:0;background:transparent;padding:15px 16px;font-size:17px;color:var(--n-ink);outline:none}
.field-row input::placeholder{color:#8f99ab}
.field-row input[aria-invalid="true"]{background:rgba(214,90,60,.12)}
.btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;border:0;border-radius:var(--r);background:var(--glow);color:#1b130a;font-family:var(--f-mono);font-size:13px;font-weight:500;letter-spacing:.06em;text-transform:uppercase;padding:0 20px;min-height:48px;cursor:pointer;white-space:nowrap;transition:background .2s, transform .2s}
.btn:hover{background:var(--glow-2)}
.btn:active{transform:translateY(1px)}
.btn[disabled]{opacity:.6;cursor:progress}
.field-row .btn{border-radius:0 2px 2px 0;margin:-1px -1px -1px 0}
.name-row{margin:0 0 10px}
.name-row input{width:100%;border:1px solid rgba(236,229,214,.36);border-radius:var(--r);background:rgba(7,12,24,.55);padding:13px 16px;font-size:16px}
.name-row input:focus{outline:none;border-color:var(--glow)}
.consent{display:flex;gap:10px;align-items:flex-start;margin:14px 0 0;font-size:14.5px;line-height:1.45;color:#cbc4b6;cursor:pointer}
.consent input{appearance:none;flex:none;width:20px;height:20px;margin:1px 0 0;border:1.5px solid rgba(236,229,214,.55);border-radius:2px;display:grid;place-items:center;cursor:pointer;background:transparent}
.consent input:checked{background:var(--glow);border-color:var(--glow)}
.consent input:checked::after{content:"";width:10px;height:5px;border:2px solid #1b130a;border-top:0;border-right:0;transform:translateY(-1px) rotate(-45deg)}
.consent input[aria-invalid="true"]{border-color:#ff8a6a}
.consent a{color:var(--glow-2)}
.hp{position:absolute!important;left:-10000px;width:1px;height:1px;overflow:hidden}
.err{margin:10px 0 0;min-height:0;color:#ffab8f;font-size:14.5px;font-weight:500}
.err:empty{display:none}
.note{margin:10px 0 0;font-size:13.5px;color:var(--n-mute);line-height:1.45}
.demo-badge{display:inline-block;margin-left:6px;font-family:var(--f-mono);font-size:10px;letter-spacing:.08em;text-transform:uppercase;border:1px dashed currentColor;padding:1px 6px;border-radius:2px;color:var(--glow-2)}
.success{border:1px solid rgba(255,179,92,.5);background:rgba(255,179,92,.08);border-radius:var(--r);padding:18px 18px 16px;outline:none}
.success h3{font-family:var(--f-display);font-weight:400;font-size:24px;margin:0 0 6px;letter-spacing:-.01em}
.success p{margin:0;font-size:16px;color:#d6cfc1}
.success .again{margin-top:12px;background:none;border:0;padding:0;color:var(--glow-2);text-decoration:underline;cursor:pointer;font-size:14px}
.embed-slot{margin-top:14px;border-radius:var(--r);overflow:hidden;background:#fff}
.embed-slot:empty{display:none}
.embed-slot iframe{display:block;width:100%;border:0;min-height:150px;background:#fff}
.embed-gate{font-size:13.5px;color:var(--n-mute);margin:10px 0 0}
.signup.is-embed .field-row,.signup.is-embed .name-row{display:none}

/* ---------- Paper body ---------- */
.paper{position:relative;z-index:2;background:var(--paper);color:var(--ink);
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .27 0 0 0 0 .18 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");}
.tear{position:absolute;left:0;right:0;top:-23px;height:24px;display:block;width:100%;color:var(--paper)}
.wrap{max-width:1280px;margin:0 auto;padding:0 var(--gut)}
.paper section{padding:clamp(72px,10vw,140px) 0}
.paper h2{color:var(--ink)}
.paper .eyebrow{color:var(--rust)}
.sec-head{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:24px 64px;align-items:end;margin-bottom:clamp(36px,5vw,64px)}
.sec-head p{margin:0;color:var(--ink-2);max-width:34em}
.hand{font-family:var(--f-hand);font-weight:500;color:var(--rust);font-size:22px;line-height:1.1}

/* Proof */
#proof{border-bottom:1px solid var(--rule)}
.proof-grid{display:grid;grid-template-columns:minmax(0,5fr) minmax(0,7fr);gap:clamp(32px,6vw,96px);align-items:start}
.bignum{font-family:var(--f-display);font-weight:300;font-size:clamp(76px,11vw,176px);line-height:.85;letter-spacing:-.045em;margin:0;font-variation-settings:"SOFT" 30,"opsz" 144;font-variant-numeric:lining-nums tabular-nums}
.bignum-cap{margin:14px 0 26px;font-size:20px;color:var(--ink-2)}
.ledger{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));border-top:1px solid var(--rule-2);margin:0}
.ledger div{padding:14px 12px 0 0}
.ledger dt{font-family:var(--f-mono);font-size:11px;letter-spacing:.08em;text-transform:uppercase;color:var(--ink-3)}
.ledger dd{margin:4px 0 0;font-family:var(--f-display);font-size:30px;letter-spacing:-.01em}
.quotes{position:relative;display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:22px}
.label{position:relative;background:#fbf7ee;border:1px solid var(--rule);padding:26px 24px 20px;box-shadow:0 1px 0 rgba(29,24,18,.06),0 14px 30px -18px rgba(29,24,18,.35);margin:0}
.label::before{content:"";position:absolute;top:-11px;left:50%;width:84px;height:22px;transform:translateX(-50%) rotate(-2deg);background:rgba(214,196,150,.62);border-left:1px dashed rgba(29,24,18,.15);border-right:1px dashed rgba(29,24,18,.15)}
.label blockquote{margin:0;font-family:var(--f-display);font-size:clamp(20px,1.7vw,25px);line-height:1.25;letter-spacing:-.01em;font-variation-settings:"SOFT" 70}
.label figcaption{margin-top:14px;font-family:var(--f-mono);font-size:11px;letter-spacing:.06em;text-transform:uppercase;color:var(--ink-3)}
.label figcaption b{color:var(--ink);font-weight:500}
.q1{grid-column:1 / span 4;transform:rotate(-.8deg)}
.q2{grid-column:3 / span 4;transform:rotate(.9deg);margin-top:-4px}
.q3{grid-column:1 / span 5;transform:rotate(-.3deg)}
.q-note{position:absolute;right:0;top:12px;width:120px;transform:rotate(6deg);text-align:center}
.fict{margin:26px 0 0;font-size:13px;color:var(--ink-3);font-family:var(--f-mono);letter-spacing:.04em}

/* What you get */
.get-grid{display:grid;grid-template-columns:minmax(0,5fr) minmax(0,7fr);gap:clamp(28px,5vw,80px)}
.get-col h3,.anatomy-head h3{font-family:var(--f-display);font-weight:400;font-size:26px;letter-spacing:-.01em;margin:0 0 8px}
.get-col p{margin:0 0 18px;color:var(--ink-2);font-size:17px}
.cal{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));gap:4px;margin:6px 0 10px;max-width:420px}
.cal span{aspect-ratio:1;border:1px solid var(--rule);display:grid;place-items:center;font-family:var(--f-mono);font-size:11px;color:var(--ink-3);position:relative;background:rgba(255,255,255,.25)}
.cal span.wk{border-style:dashed}
.cal span.issue{background:var(--ink);color:var(--paper);border-color:var(--ink)}
.cal span.issue::after{content:"";position:absolute;top:4px;right:4px;width:6px;height:6px;border-radius:50%;background:var(--glow)}
.cal span.today{outline:2px solid var(--rust);outline-offset:-3px}
.cal-dow{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));gap:4px;max-width:420px;font-family:var(--f-mono);font-size:10px;color:var(--ink-3);text-align:center;letter-spacing:.08em}
.cal-cap{font-family:var(--f-mono);font-size:12px;color:var(--ink-2);margin:0 0 34px}
.tags{display:flex;flex-wrap:wrap;gap:10px;margin:0;padding:0;list-style:none}
.tags li{display:flex;align-items:center;gap:8px;padding:7px 12px 7px 9px;border:1px solid currentColor;border-radius:2px;font-family:var(--f-mono);font-size:12px;letter-spacing:.06em;text-transform:uppercase;background:rgba(255,255,255,.3)}
.tags li::before{content:"";width:9px;height:9px;border-radius:50%;background:currentColor}
.tags li span{color:var(--ink-3)}
.c-wetlands{color:var(--t-wetlands)}.c-oceans{color:var(--t-oceans)}.c-ice{color:var(--t-ice)}.c-forests{color:var(--t-forests)}.c-drylands{color:var(--t-drylands)}

.anatomy{position:relative;display:grid;grid-template-columns:minmax(0,1fr) 170px;gap:18px}
.sheet{background:#fbf7ee;border:1px solid var(--rule);box-shadow:0 22px 40px -26px rgba(29,24,18,.5);padding:26px 26px 22px;position:relative}
.sheet-top{display:flex;justify-content:space-between;border-bottom:2px solid var(--ink);padding-bottom:8px;font-family:var(--f-mono);font-size:10.5px;letter-spacing:.08em;text-transform:uppercase}
.sheet-top b{font-family:var(--f-display);font-size:20px;letter-spacing:-.01em;text-transform:none;font-weight:500}
.sheet h4{font-family:var(--f-display);font-weight:400;font-size:28px;line-height:1.05;margin:14px 0 8px;letter-spacing:-.015em}
.sheet .plate{aspect-ratio:16/7;background:#cdbf9f center/cover no-repeat;margin:12px 0;filter:saturate(.85)}
.sheet p{font-size:14.5px;line-height:1.5;margin:0 0 10px;color:var(--ink-2)}
.sheet .row{display:grid;grid-template-columns:1fr 1fr;gap:12px;margin-top:12px}
.sheet .box{border:1px solid var(--rule-2);padding:10px 12px;font-size:13px;line-height:1.4}
.sheet .box b{display:block;font-family:var(--f-mono);font-size:10px;letter-spacing:.08em;text-transform:uppercase;color:var(--rust);margin-bottom:3px;font-weight:500}
.mark{position:absolute;width:24px;height:24px;border-radius:50%;background:var(--rust);color:#fff;font-family:var(--f-mono);font-size:12px;display:grid;place-items:center;box-shadow:0 0 0 3px #fbf7ee}
.notes-col{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;justify-content:space-around}
.notes-col li{font-family:var(--f-hand);font-size:21px;line-height:1.05;color:var(--ink-2)}
.notes-col li b{font-family:var(--f-mono);font-size:11px;color:#fff;background:var(--rust);border-radius:50%;width:20px;height:20px;display:inline-grid;place-items:center;margin-right:6px;vertical-align:2px;font-weight:500}

/* Archive */
#archive{background:var(--paper-2);border-top:1px solid var(--rule);border-bottom:1px solid var(--rule)}
.tools{display:flex;flex-wrap:wrap;gap:12px 20px;align-items:center;justify-content:space-between;padding:14px 0;border-top:2px solid var(--ink);border-bottom:1px solid var(--rule-2);margin-bottom:28px}
.chips{display:flex;flex-wrap:wrap;gap:6px}
.chip{border:1px solid var(--rule-2);background:transparent;border-radius:99px;padding:8px 14px;font-family:var(--f-mono);font-size:12px;letter-spacing:.06em;text-transform:uppercase;cursor:pointer;min-height:38px;color:var(--ink-2)}
.chip:hover{border-color:var(--ink)}
.chip[aria-pressed="true"]{background:var(--ink);color:var(--paper);border-color:var(--ink)}
.chip .k{opacity:.65;margin-left:4px}
.tools-r{display:flex;gap:10px;align-items:center;flex-wrap:wrap}
.search{position:relative}
.search input,.sort select{border:1px solid var(--rule-2);background:rgba(255,255,255,.45);border-radius:var(--r);padding:9px 12px;font-size:15px;min-height:40px;color:var(--ink)}
.search input{width:200px;padding-left:34px}
.search svg{position:absolute;left:11px;top:50%;transform:translateY(-50%);width:15px;height:15px;color:var(--ink-3)}
.sort select{font-family:var(--f-mono);font-size:12px;text-transform:uppercase;letter-spacing:.05em}
.count{font-family:var(--f-mono);font-size:12px;color:var(--ink-3);margin:0 0 18px}
.grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:32px 28px}
.card{position:relative;display:flex;flex-direction:column}
.card[hidden]{display:none}
.card figure{margin:0 0 14px;aspect-ratio:3/2;overflow:hidden;background:var(--paper-3);position:relative}
.card img{width:100%;height:100%;object-fit:cover;transition:transform .8s cubic-bezier(.2,.7,.2,1), filter .6s;filter:saturate(.9) contrast(1.02)}
.card:hover img{transform:scale(1.035);filter:saturate(1) contrast(1.04)}
.card .no-tag{position:absolute;left:10px;top:10px;background:var(--paper);color:var(--ink);font-family:var(--f-mono);font-size:11px;padding:3px 7px;letter-spacing:.06em}
.meta{display:flex;flex-wrap:wrap;gap:6px 12px;align-items:center;font-family:var(--f-mono);font-size:11px;letter-spacing:.06em;text-transform:uppercase;color:var(--ink-3);margin-bottom:8px}
.topic{font-weight:500}
.card h3{font-family:var(--f-display);font-weight:400;font-size:25px;line-height:1.1;letter-spacing:-.012em;margin:0 0 8px;font-variation-settings:"SOFT" 50}
.card h3 button{all:unset;cursor:pointer;background-image:linear-gradient(currentColor,currentColor);background-size:0 1px;background-repeat:no-repeat;background-position:0 100%;transition:background-size .35s}
.card h3 button::after{content:"";position:absolute;inset:0;z-index:1}
.card:hover h3 button,.card h3 button:focus-visible{background-size:100% 1px}
.card h3 button:focus-visible{outline:none}
.card:has(h3 button:focus-visible){outline:2px solid var(--rust);outline-offset:6px}
.card .dek{margin:0 0 12px;color:var(--ink-2);font-size:16px;line-height:1.45}
.card .foot{margin-top:auto;display:flex;justify-content:space-between;gap:10px;align-items:center;border-top:1px solid var(--rule);padding-top:10px;font-family:var(--f-mono);font-size:11px;color:var(--ink-3);letter-spacing:.04em}
.locate{position:relative;z-index:2;background:none;border:0;padding:8px 0 8px 8px;min-height:36px;font-family:var(--f-mono);font-size:11px;letter-spacing:.06em;text-transform:uppercase;color:var(--rust);cursor:pointer;display:inline-flex;align-items:center;gap:6px}
.locate:hover{text-decoration:underline}
html.nogl .locate{display:none}
.empty{display:none;padding:40px 0;text-align:center;color:var(--ink-2)}
.empty.show{display:block}
.empty button{margin-top:10px;background:var(--ink);color:var(--paper);border:0;padding:10px 16px;font-family:var(--f-mono);font-size:12px;text-transform:uppercase;letter-spacing:.06em;cursor:pointer;border-radius:var(--r)}

/* Correspondents */
.writers{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:28px;margin:0;padding:0;list-style:none}
.writers li{border-top:1px solid var(--rule-2);padding-top:16px}
.stamp{width:62px;height:62px;border-radius:50%;border:1.5px solid currentColor;display:grid;place-items:center;font-family:var(--f-display);font-size:22px;font-style:italic;margin-bottom:12px;position:relative}
.stamp::after{content:"";position:absolute;inset:4px;border-radius:50%;border:1px dashed currentColor;opacity:.6}
.writers h3{font-family:var(--f-display);font-weight:400;font-size:22px;margin:0 0 2px;letter-spacing:-.01em}
.writers p{margin:0;color:var(--ink-2);font-size:15.5px;line-height:1.45}
.writers .w-meta{font-family:var(--f-mono);font-size:11px;letter-spacing:.06em;text-transform:uppercase;color:var(--ink-3);margin:2px 0 8px}

/* FAQ */
.faq-grid{display:grid;grid-template-columns:minmax(0,4fr) minmax(0,8fr);gap:clamp(28px,5vw,80px)}
.faq details{border-top:1px solid var(--rule-2)}
.faq details:last-child{border-bottom:1px solid var(--rule-2)}
.faq summary{list-style:none;cursor:pointer;display:flex;justify-content:space-between;align-items:center;gap:20px;padding:20px 0;font-family:var(--f-display);font-size:clamp(20px,1.8vw,24px);letter-spacing:-.01em}
.faq summary::-webkit-details-marker{display:none}
.faq summary .pm{flex:none;width:28px;height:28px;border:1px solid var(--rule-2);border-radius:50%;position:relative}
.faq summary .pm::before,.faq summary .pm::after{content:"";position:absolute;left:50%;top:50%;width:11px;height:1.5px;background:var(--ink);transform:translate(-50%,-50%);transition:transform .25s}
.faq summary .pm::after{transform:translate(-50%,-50%) rotate(90deg)}
.faq details[open] summary .pm::after{transform:translate(-50%,-50%) rotate(0deg)}
.faq details p{margin:0 0 22px;color:var(--ink-2);max-width:40em}

/* Footer sign-up (night again) */
#join{background:var(--night-2);color:var(--n-ink);position:relative;z-index:2;overflow:hidden;padding:clamp(72px,9vw,130px) 0}
#join::before{content:"";position:absolute;right:-18vw;top:-30%;width:70vw;height:160%;background:radial-gradient(closest-side,rgba(255,179,92,.16),rgba(255,179,92,0));pointer-events:none}
.join-grid{display:grid;grid-template-columns:minmax(0,6fr) minmax(0,5fr);gap:clamp(32px,6vw,96px);align-items:end;position:relative}
#join h2{color:var(--n-ink)}
#join .eyebrow{color:var(--glow-2)}
.countdown{display:flex;gap:18px;margin:22px 0 0;font-family:var(--f-mono)}
.countdown div{border-top:1px solid var(--n-rule);padding-top:8px;min-width:70px}
.countdown b{display:block;font-family:var(--f-display);font-weight:300;font-size:44px;line-height:1;font-variant-numeric:tabular-nums}
.countdown span{font-size:11px;letter-spacing:.08em;text-transform:uppercase;color:var(--n-mute)}
.colophon{position:relative;z-index:2;background:var(--night);color:var(--n-mute);font-size:13px;padding:28px 0 36px;border-top:1px solid var(--n-rule)}
.colophon .wrap{display:flex;flex-wrap:wrap;justify-content:space-between;gap:12px 32px}
.colophon p{margin:0;max-width:62em}
.colophon a{color:var(--n-ink)}

/* Reader */
dialog#reader{padding:0;border:0;width:min(1180px,calc(100vw - 32px));max-width:none;height:min(860px,calc(100svh - 32px));max-height:none;background:var(--paper);color:var(--ink);border-radius:4px;box-shadow:0 40px 120px -20px rgba(0,0,0,.7);overflow:hidden}
dialog#reader::backdrop{background:rgba(5,8,16,.72);backdrop-filter:blur(3px)}
dialog#reader[open]{animation:rin .55s cubic-bezier(.2,.8,.2,1)}
@keyframes rin{from{opacity:0;transform:translateY(24px) scale(.985)}to{opacity:1;transform:none}}
.r-wrap{display:grid;grid-template-columns:minmax(0,5fr) minmax(0,7fr);height:100%}
.r-photo{margin:0;position:relative;background:#1a1712;overflow:hidden}
.r-photo img{width:100%;height:100%;object-fit:cover;filter:saturate(.92)}
.r-photo figcaption{position:absolute;left:0;right:0;bottom:0;padding:40px 20px 16px;background:linear-gradient(to top,rgba(10,8,6,.85),rgba(10,8,6,0));color:#efe8da;font-family:var(--f-mono);font-size:11px;letter-spacing:.06em;text-transform:uppercase}
.r-photo figcaption b{display:block;font-family:var(--f-hand);font-size:24px;text-transform:none;letter-spacing:0;font-weight:500;color:var(--glow-2)}
.r-main{display:flex;flex-direction:column;min-height:0}
.r-bar{display:flex;justify-content:space-between;align-items:center;gap:10px;padding:12px 18px 12px 28px;border-bottom:1px solid var(--rule-2);font-family:var(--f-mono);font-size:11px;letter-spacing:.08em;text-transform:uppercase;color:var(--ink-3)}
.r-btns{display:flex;gap:4px}
.r-btns button{background:none;border:1px solid var(--rule-2);border-radius:var(--r);min-width:40px;height:40px;padding:0 12px;cursor:pointer;font-family:var(--f-mono);font-size:11px;letter-spacing:.06em;text-transform:uppercase;color:var(--ink)}
.r-btns button:hover{border-color:var(--ink)}
.r-scroll{overflow:auto;padding:30px clamp(22px,4vw,56px) 40px;overscroll-behavior:contain}
.r-kicker{font-family:var(--f-mono);font-size:11px;letter-spacing:.08em;text-transform:uppercase;color:var(--ink-3);margin:0 0 12px}
.r-kicker .topic{margin-right:6px}
#r-title{font-family:var(--f-display);font-weight:300;font-size:clamp(34px,3.6vw,54px);line-height:1;letter-spacing:-.025em;margin:0 0 12px;font-variation-settings:"SOFT" 40,"opsz" 144}
.r-dek{font-size:20px;line-height:1.4;color:var(--ink-2);margin:0 0 22px;font-style:italic}
.r-body p{margin:0 0 16px;font-size:18px;line-height:1.62;max-width:36em}
.r-body p:first-child::first-letter{font-family:var(--f-display);float:left;font-size:64px;line-height:.82;padding:6px 8px 0 0;color:var(--rust);font-weight:400}
.r-extra{display:grid;grid-template-columns:1fr 1fr;gap:14px;margin:24px 0;max-width:40em}
.r-extra div{border:1px solid var(--rule-2);padding:14px 16px;background:#fbf7ee}
.r-extra b{display:block;font-family:var(--f-mono);font-size:10.5px;letter-spacing:.08em;text-transform:uppercase;color:var(--rust);font-weight:500;margin-bottom:4px}
.r-extra span{font-size:15.5px;line-height:1.45}
.r-end{border-top:2px solid var(--ink);padding-top:16px;margin-top:10px;max-width:40em}
.r-end p{margin:0 0 14px;color:var(--ink-2);font-size:16px}
.r-actions{display:flex;flex-wrap:wrap;gap:10px}
.btn-ink{background:var(--ink);color:var(--paper)}
.btn-ink:hover{background:#3a3026}
.btn-line{background:transparent;color:var(--ink);border:1px solid var(--ink)}
.btn-line:hover{background:rgba(29,24,18,.06)}
html.nogl .btn-line.globe-only{display:none}

/* Fallback poster (no WebGL) */
.poster{display:none}
html.nogl .poster{display:block;position:absolute;right:calc(var(--gut) - 4vw);top:50%;transform:translateY(-50%);width:min(52vw,86svh);aspect-ratio:1;z-index:0;pointer-events:none}
html.nogl .poster img{width:100%;height:100%;object-fit:contain;-webkit-mask-image:radial-gradient(closest-side,#000 82%,transparent 100%);mask-image:radial-gradient(closest-side,#000 82%,transparent 100%)}
html.nogl #night{background:radial-gradient(60% 60% at 70% 50%,#0f1a33 0%,var(--night) 70%)}

/* ---------- Responsive ---------- */
@media (max-width: 1100px){
  .grid{grid-template-columns:repeat(2,minmax(0,1fr))}
  .writers{grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media (max-width: 899px), (max-aspect-ratio: 11/10){
  #hero{align-items:flex-end;padding-top:var(--gb);padding-bottom:110px}
  .hero-copy{max-width:640px}
  #atlas{padding-top:calc(var(--gb) - 4svh)}
  .atlas-panel{max-width:640px;background:rgba(7,12,24,.8);padding:22px 18px;border:1px solid var(--n-rule);border-radius:4px;backdrop-filter:blur(4px)}
  html.nogl .poster{left:50%;right:auto;top:calc(var(--gb) * .48);transform:translate(-50%,-50%);width:min(88vw,46svh)}
  .sec-head,.proof-grid,.get-grid,.faq-grid,.join-grid{grid-template-columns:minmax(0,1fr)}
}
@media (max-width: 760px){
  body{font-size:17px}
  .mast{padding:14px 16px}
  .mast nav a:not(.pill){display:none}
  .hud{grid-template-columns:1fr;gap:4px;padding:12px 16px 14px;font-size:10px}
  .hud span:nth-child(2),.hud span:nth-child(3){text-align:left}
  .hud span:nth-child(3){display:none}
  .field-row{flex-direction:column;background:transparent;border:0;gap:10px}
  .field-row input{border:1px solid rgba(236,229,214,.36);border-radius:var(--r);background:rgba(7,12,24,.6)}
  .field-row input:focus{border-color:var(--glow)}
  .field-row .btn{border-radius:var(--r);margin:0;width:100%}
  .grid{grid-template-columns:minmax(0,1fr)}
  .writers{grid-template-columns:minmax(0,1fr)}
  .quotes{grid-template-columns:minmax(0,1fr)}
  .q1,.q2,.q3{grid-column:1/-1}
  .q-note{display:none}
  .ledger dd{font-size:24px}
  .anatomy{grid-template-columns:minmax(0,1fr)}
  .notes-col{flex-direction:row;flex-wrap:wrap;gap:8px 18px}
  .tools{flex-direction:column;align-items:stretch}
  .tools-r{justify-content:space-between}
  .search{flex:1}.search input{width:100%}
  .places .c{display:none}
  .places button{grid-template-columns:64px 1fr}
  dialog#reader{width:100vw;height:100svh;border-radius:0}
  .r-wrap{grid-template-columns:minmax(0,1fr);grid-template-rows:30svh minmax(0,1fr)}
  .r-bar{padding:10px 12px 10px 16px}
  .r-bar .r-where{display:none}
  .r-extra{grid-template-columns:minmax(0,1fr)}
  .countdown b{font-size:36px}
}
html.rm *,html.rm *::before,html.rm *::after{animation-duration:.001ms!important;transition-duration:.001ms!important}
</style>
</head>
<body>
<a class="skip" href="#main">Skip to content</a>

<div id="pre" role="status" aria-live="polite">
  <div class="pre-in">
    <div class="pre-mark">Field <em>Notes</em></div>
    <ul class="pre-log" id="pre-log"></ul>
    <div class="pre-bar"><i id="pre-bar"></i></div>
  </div>
</div>

<canvas id="gl" aria-hidden="true"></canvas>
<div id="tip" aria-hidden="true"></div>
<div id="tag-latest" aria-hidden="true"></div>

<div id="night">
  <header class="mast">
    <a class="logo" href="#top" aria-label="Field Notes, home">
      <svg viewBox="0 0 32 32" fill="none" stroke="currentColor" stroke-width="1.4" aria-hidden="true"><circle cx="16" cy="16" r="13"/><path d="M16 5v4M16 23v4M5 16h4M23 16h4"/><path d="M16 9l3.2 7L16 23l-3.2-7z" fill="#ffb35c" stroke="none"/></svg>
      Field Notes
    </a>
    <nav aria-label="Primary">
      <a href="#archive">Archive</a>
      <a href="#get">What you get</a>
      <a href="#faq">FAQ</a>
      <a class="pill" href="#join">Subscribe</a>
    </nav>
  </header>

  <main id="main">
  <section id="hero" aria-labelledby="hero-title">
    <div class="poster"><img src="assets/globe-poster.webp" alt="The Earth at dusk seen from space, with glowing pins marking the places past issues were written." width="900" height="900"></div>
    <div class="hero-copy live" id="top">
      <p class="kicker mono"><span class="dot" aria-hidden="true"></span> No. 112 out now <span aria-hidden="true">·</span> every other Thursday</p>
      <h1 id="hero-title">Dispatches from the places the planet keeps its <em>records.</em></h1>
      <p class="deck">A peat bog that has been filing away carbon for four thousand years. A glacier striped with the ash of old eruptions. Every other Thursday, one of four correspondents writes from somewhere the evidence is still lying on the ground. Ten minutes. Free.</p>
      <form class="signup" data-signup="hero" novalidate>
        <div class="field-row">
          <label class="sr-only" for="hero-email">Email address</label>
          <input id="hero-email" name="email" type="email" inputmode="email" autocomplete="email" placeholder="you@fieldstation.org" aria-describedby="hero-err hero-note" required>
          <button class="btn" type="submit">Subscribe</button>
        </div>
        <div class="hp" aria-hidden="true"><label>Leave this empty<input type="text" name="website" tabindex="-1" autocomplete="off"></label></div>
        <label class="consent"><input type="checkbox" name="consent" required aria-describedby="hero-err"> <span class="consent-text">Send me Field Notes by email. I can unsubscribe in one click. <a href="#faq-privacy">How we use your address</a></span></label>
        <p class="err" id="hero-err" aria-live="assertive"></p>
        <p class="note" id="hero-note">We email you once to confirm (double opt-in). No click, no newsletter.</p>
        <div class="embed-slot"></div>
      </form>
      <ul class="proof-line mono">
        <li><b>41,860</b> readers</li><li><b>96</b> countries</li><li><b>61%</b> open every issue</li>
      </ul>
    </div>
    <div class="hud" aria-hidden="true">
      <span>Sun overhead now <b id="hud-sun">—</b></span>
      <span class="gl-only">Cursor <b id="hud-cur">—</b></span>
      <span class="gl-only">Drag to turn · click a pin to read</span>
    </div>
  </section>

  <section id="atlas" aria-labelledby="atlas-title">
    <div class="atlas-panel live">
      <p class="eyebrow mono">The atlas</p>
      <h2 id="atlas-title">Twelve dispatches, pinned <em>where they were written.</em></h2>
      <p class="atlas-sub">Every pin is a field report. Pick one and we fly you there, then open the issue.</p>
      <ul class="places" id="places"></ul>
      <p class="atlas-hint mono" style="font-size:11px">The dashed pin is the next issue. Its location stays sealed until it lands.</p>
    </div>
  </section>
  </main>
</div>

<div class="paper">
  <svg class="tear" viewBox="0 0 1440 24" preserveAspectRatio="none" aria-hidden="true"><path fill="currentColor" d="M0 24V14l18-3 22 5 26-6 30 4 21-7 34 6 28-2 19 5 33-8 26 4 24-3 31 6 22-5 29 2 18-6 36 7 25-3 30 4 22-6 27 3 33-4 19 6 28-5 31 3 24-7 22 5 36-2 20 4 29-6 26 3 31-2 18 6 34-7 23 4 30-3 25 5 21-6 33 3 27 2 22-5 35 6 20-4 31 2 24-5 29 6 26-3 22 4 33-6 19 3 30 2 25-5 28 4 32-3 21 6 26-5 30 3 23-2 34 5 18-6 29 4 25-1 28 3V24z"/></svg>

  <section id="proof" aria-labelledby="proof-title">
    <div class="wrap proof-grid">
      <div>
        <p class="eyebrow mono">Who reads it</p>
        <p class="bignum" id="bignum" aria-hidden="true">41,860</p>
        <h2 id="proof-title" class="bignum-cap" style="font-family:var(--f-body);font-size:20px;font-weight:400;letter-spacing:0;line-height:1.4"><span class="sr-only">41,860 readers: </span>teachers, rangers, hydrologists and the plainly curious, in 96 countries.</h2>
        <dl class="ledger">
          <div><dt>Open rate</dt><dd>61%</dd></div>
          <div><dt>Issues sent</dt><dd>112</dd></div>
          <div><dt>Since</dt><dd>2022</dd></div>
        </dl>
      </div>
      <div class="quotes">
        <figure class="label q1"><blockquote>“The only email I print. The bog issue is pinned above my desk, next to the tide tables.”</blockquote><figcaption><b>Maren H.</b> · school teacher, Bergen</figcaption></figure>
        <p class="q-note hand" aria-hidden="true">specimens of reader mail ↓</p>
        <figure class="label q2"><blockquote>“Short enough for the bus, specific enough that I learn one real number every time.”</blockquote><figcaption><b>Dev P.</b> · hydrologist, Pune</figcaption></figure>
        <figure class="label q3"><blockquote>“It reads like somebody actually went there. Because somebody did.”</blockquote><figcaption><b>Clare O.</b> · retired ranger, Hobart</figcaption></figure>
      </div>
    </div>
    <div class="wrap"><p class="fict">Field Notes is a fictional publication. Readers, writers and numbers on this page are illustrative.</p></div>
  </section>

  <section id="get" aria-labelledby="get-title">
    <div class="wrap">
      <div class="sec-head">
        <div><p class="eyebrow mono">What you get</p><h2 id="get-title">One place, one fortnight, <em>one real number.</em></h2></div>
        <p>Each issue is a single dispatch, about ten minutes long, written by someone who stood there. We end with a measurement from the trip, so you always leave with something you could check.</p>
      </div>
      <div class="get-grid">
        <div class="get-col">
          <h3>Every other Thursday, 07:00</h3>
          <p>In your time zone. Never more, and if a trip runs late, we tell you rather than send filler.</p>
          <div class="cal-dow" aria-hidden="true"><span>M</span><span>T</span><span>W</span><span>T</span><span>F</span><span>S</span><span>S</span></div>
          <div class="cal" id="cal" role="img" aria-label="Four-week calendar with the next two issue days marked"></div>
          <p class="cal-cap" id="cal-cap"></p>
          <h3>Five beats</h3>
          <p>Our correspondents rotate through five kinds of place.</p>
          <ul class="tags" id="tags"></ul>
        </div>
        <div>
          <div class="anatomy-head"><h3>Anatomy of an issue</h3></div>
          <div class="anatomy">
            <div class="sheet" aria-label="Sample page from issue 112">
              <div class="sheet-top"><b>Field Notes</b><span>No. 112 · 19 Nov 2026</span></div>
              <span class="mark" style="left:-12px;top:62px" aria-hidden="true">1</span>
              <h4>The bog that breathes back</h4>
              <p>We arrived at the Flow Country in the second week of November expecting frost and found the bog steaming…</p>
              <span class="mark" style="right:-12px;top:150px" aria-hidden="true">2</span>
              <div class="plate" style="background-image:url(assets/issue-bog.webp)" role="img" aria-label="Plate: peat pools and cotton grass in the Flow Country"></div>
              <div class="row">
                <div class="box" style="position:relative"><span class="mark" style="left:-12px;top:-12px" aria-hidden="true">3</span><b>The specimen</b>Sphagnum papillosum, the ochre bog-moss that holds many times its weight in water.</div>
                <div class="box" style="position:relative"><span class="mark" style="right:-12px;top:-12px" aria-hidden="true">4</span><b>The reading</b>Peat depth at transect 4: 3.6 m.</div>
              </div>
            </div>
            <ol class="notes-col">
              <li><b>1</b>The dispatch. About 1,200 words from the field.</li>
              <li><b>2</b>The plate. One photograph, captioned with coordinates.</li>
              <li><b>3</b>The specimen. One living thing, up close.</li>
              <li><b>4</b>The reading. A number we measured, and how.</li>
            </ol>
          </div>
        </div>
      </div>
    </div>
  </section>

  <section id="archive" aria-labelledby="archive-title">
    <div class="wrap">
      <div class="sec-head">
        <div><p class="eyebrow mono">The archive</p><h2 id="archive-title">The last twelve <em>dispatches.</em></h2></div>
        <p>Open any issue to read an excerpt here on the page, or find it on the globe. Subscribers get the full back catalogue.</p>
      </div>
      <div class="tools" role="group" aria-label="Filter the archive">
        <div class="chips" id="chips"></div>
        <div class="tools-r">
          <div class="search">
            <svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" aria-hidden="true"><circle cx="7" cy="7" r="5"/><path d="M11 11l4 4"/></svg>
            <label class="sr-only" for="q">Search issues</label>
            <input id="q" type="search" placeholder="Search: ice, moss, Iceland…" autocomplete="off">
          </div>
          <div class="sort"><label class="sr-only" for="sort">Sort issues</label>
            <select id="sort"><option value="new">Newest first</option><option value="old">Oldest first</option><option value="short">Shortest read</option></select>
          </div>
        </div>
      </div>
      <p class="count" id="count" aria-live="polite"></p>
      <div class="grid" id="grid"></div>
      <div class="empty" id="empty"><p>No dispatches match that. Try another beat or word.</p><button type="button" id="clear">Clear filters</button></div>
    </div>
  </section>

  <section id="writers" aria-labelledby="writers-title">
    <div class="wrap">
      <div class="sec-head">
        <div><p class="eyebrow mono">Correspondents</p><h2 id="writers-title">Four people with <em>wet boots.</em></h2></div>
        <p>Nobody here writes from a desk about a place they have not been. When a number appears, the person who wrote it down is named.</p>
      </div>
      <ul class="writers">
        <li><div class="stamp c-wetlands" aria-hidden="true">IA</div><h3>Ines Arkwright</h3><p class="w-meta">Wetlands · Thurso</p><p>Peatland ecologist. Has spent more nights in a bog than she will admit to.</p></li>
        <li><div class="stamp c-forests" aria-hidden="true">AO</div><h3>Dr Amaka Ollen</h3><p class="w-meta">Reefs &amp; forests · Kampala</p><p>Field biologist. Counts things for a living: coral colonies, epiphytes, fungi on one log.</p></li>
        <li><div class="stamp c-drylands" aria-hidden="true">RC</div><h3>Ruairi Coyle</h3><p class="w-meta">Rock, salt &amp; ash · Galway</p><p>Geologist who reads landscapes the way other people read the paper.</p></li>
        <li><div class="stamp c-ice" aria-hidden="true">TW</div><h3>Tomasz Wren</h3><p class="w-meta">Ice &amp; oceans · Tromsø</p><p>Former deckhand turned science writer. Carries a thermometer everywhere.</p></li>
      </ul>
    </div>
  </section>

  <section id="faq" aria-labelledby="faq-title" style="border-top:1px solid var(--rule)">
    <div class="wrap faq-grid">
      <div><p class="eyebrow mono">Questions</p><h2 id="faq-title">Before you <em>sign up.</em></h2><p class="hand" style="margin-top:18px">short answers, honest ones</p></div>
      <div class="faq">
        <details><summary>How often will it arrive?<span class="pm" aria-hidden="true"></span></summary><p>Every other Thursday at 07:00 in your time zone: one dispatch, about a ten-minute read. If a trip runs late we send a one-line note instead of filler.</p></details>
        <details><summary>Is it really free?<span class="pm" aria-hidden="true"></span></summary><p>Yes. Every issue is free to read. Readers who want to fund the fieldwork can chip in, but nothing is paywalled.</p></details>
        <details><summary>Why do I have to confirm my email?<span class="pm" aria-hidden="true"></span></summary><p>It is called double opt-in. It means nobody can sign you up but you, and it keeps Field Notes out of spam folders. If the confirmation email does not arrive within ten minutes, check your promotions or spam folder.</p></details>
        <details id="faq-privacy"><summary>What do you do with my address?<span class="pm" aria-hidden="true"></span></summary><p>We use it only to send Field Notes. We never sell or share it, and every issue has a one-click unsubscribe link that removes you at once. Your address is stored by our email provider, under their privacy policy.</p></details>
        <details><summary>Where do the numbers come from?<span class="pm" aria-hidden="true"></span></summary><p>From our own instruments on the trip, or from the station or team we joined, named in the issue. If we are quoting someone else's figure, we say so.</p></details>
        <details><summary>Can I read the back issues?<span class="pm" aria-hidden="true"></span></summary><p>The archive on this page has excerpts from the last twelve. Subscribers get a link to the full back catalogue in their welcome email.</p></details>
      </div>
    </div>
  </section>
</div>

<section id="join" aria-labelledby="join-title">
  <div class="wrap join-grid">
    <div>
      <p class="eyebrow mono">Next dispatch</p>
      <h2 id="join-title"><span id="next-no">No. 113</span> lands <em id="next-date">Thursday 3 December.</em></h2>
      <p style="color:#cfc8ba;max-width:30em;margin:0">The location is sealed until it arrives. We will tell you this much: bring a jumper.</p>
      <div class="countdown" id="countdown" aria-hidden="true">
        <div><b data-u="d">00</b><span>days</span></div><div><b data-u="h">00</b><span>hours</span></div><div><b data-u="m">00</b><span>minutes</span></div>
      </div>
    </div>
    <form class="signup" data-signup="footer" novalidate>
      <div class="name-row"><label class="sr-only" for="foot-name">First name (optional)</label><input id="foot-name" name="first_name" type="text" autocomplete="given-name" placeholder="First name (optional)"></div>
      <div class="field-row">
        <label class="sr-only" for="foot-email">Email address</label>
        <input id="foot-email" name="email" type="email" inputmode="email" autocomplete="email" placeholder="you@fieldstation.org" aria-describedby="foot-err foot-note" required>
        <button class="btn" type="submit">Get No. 113</button>
      </div>
      <div class="hp" aria-hidden="true"><label>Leave this empty<input type="text" name="website" tabindex="-1" autocomplete="off"></label></div>
      <label class="consent"><input type="checkbox" name="consent" required aria-describedby="foot-err"> <span class="consent-text">Send me Field Notes by email. I can unsubscribe in one click. <a href="#faq-privacy">How we use your address</a></span></label>
      <p class="err" id="foot-err" aria-live="assertive"></p>
      <p class="note" id="foot-note">We email you once to confirm (double opt-in). No click, no newsletter.</p>
      <div class="embed-slot"></div>
    </form>
  </div>
</section>
<footer class="colophon">
  <div class="wrap">
    <p>© 2026 Field Notes, a fictional publication. Plates are original images made for this page. Earth imagery: NASA Blue Marble and Black Marble (public domain). Clouds are generated live.</p>
    <p><a href="#top">Back to the globe ↑</a></p>
  </div>
</footer>

<dialog id="reader" aria-labelledby="r-title">
  <div class="r-wrap">
    <figure class="r-photo"><img id="r-img" src="" alt=""><figcaption><b id="r-place"></b><span id="r-coords"></span></figcaption></figure>
    <div class="r-main">
      <div class="r-bar">
        <span class="r-where" id="r-where"></span>
        <div class="r-btns">
          <button type="button" id="r-prev" aria-label="Previous issue">← Prev</button>
          <button type="button" id="r-next" aria-label="Next issue">Next →</button>
          <button type="button" id="r-close" aria-label="Close the issue">Close ✕</button>
        </div>
      </div>
      <div class="r-scroll" id="r-scroll">
        <p class="r-kicker" id="r-kicker"></p>
        <h2 id="r-title"></h2>
        <p class="r-dek" id="r-dek"></p>
        <div class="r-body" id="r-body"></div>
        <div class="r-extra"><div><b>The specimen</b><span id="r-spec"></span></div><div><b>The reading</b><span id="r-read"></span></div></div>
        <div class="r-end">
          <p>This is an excerpt. The full dispatch, with field sketches and the method behind the reading, went to 41,860 inboxes.</p>
          <div class="r-actions">
            <button type="button" class="btn btn-ink" id="r-sub">Get the next one</button>
            <button type="button" class="btn btn-line globe-only" id="r-globe">Show on the globe</button>
          </div>
        </div>
      </div>
    </div>
  </div>
</dialog>

<script>
/* =====================================================================
   CONFIG — connect your newsletter here.
   provider: "demo" (default: validates, shows success, sends nothing)
             "ghost" | "embed" | "custom"
             ("beehiiv", "substack" and "kit" are aliases of "embed")
   See prompt.md → "Connect your newsletter" for where each value comes from.
   Never put API keys here: everything below is public.
   ===================================================================== */
const CONFIG = {
  provider: "demo",
  // "embed": paste the embed code exactly as your provider's dashboard gives it (iframe or script), inside backticks.
  // Write each closing script tag in the snippet as <\/script> (with the backslash), or this page's own script ends early.
  embedHtml: ``,
  // Ghost, verified 26 Nov 2026 from https://ghost.org/help/embeddable-signup-forms/ (Settings → Growth → Signup forms → Embed).
  // site = "https://your-ghost-site.com". Set title or description for Ghost's "all-in-one" layout; leave both empty for the minimal one.
  ghost:    { site: "", title: "", description: "", icon: "", labels: [], buttonColor: "#a3401e", backgroundColor: "#f2ebdd", locale: "en" },
  custom:   { url: "", format: "json" } // your own endpoint; "json" or "form"
};
const PROVIDER_ALIAS = { beehiiv: "embed", substack: "embed", kit: "embed" };

/* ---------------- Data ---------------- */
const TOPICS = { wetlands:"Wetlands", oceans:"Oceans", ice:"Ice", forests:"Forests", drylands:"Drylands" };
const ISSUES = [
 {no:112,date:"2026-11-19",title:"The bog that breathes back",place:"Flow Country, Scotland",lat:58.40,lon:-3.80,topic:"wetlands",mins:9,img:"bog",by:"Ines Arkwright",
  dek:"A metre of peat takes a thousand years to build. We spent a warm November week measuring what it breathes out.",
  body:["We arrived at the Flow Country in the second week of November expecting frost and found the bog steaming. Blanket bog covers roughly four thousand square kilometres of Caithness and Sutherland, and almost all of it is water held in place by moss. Sphagnum does not rot easily: it acidifies its surroundings and starves decay of oxygen, so the dead layers stack up, a millimetre or so a year.",
        "Our job was simpler than it sounds. Put a clear chamber over a patch of moss for two minutes and watch the carbon dioxide inside rise or fall. On cold mornings the bog drew carbon in. By the afternoon of an unseasonably warm day, several chambers were breathing out. One week proves nothing. A long run of weeks is what the station keeps, and that record is the one worth reading."],
  spec:"Sphagnum papillosum, the fat ochre bog-moss that holds many times its own dry weight in water.",read:"Peat depth at transect 4: 3.6 m, several thousand years of moss."},
 {no:111,date:"2026-11-05",title:"Night shift on the reef",place:"Raja Ampat, Indonesia",lat:-0.50,lon:130.50,topic:"oceans",mins:8,img:"reef",by:"Dr Amaka Ollen",
  dek:"Corals spawn by the moon. A survey team waits up with red torches and a stopwatch.",
  body:["Coral spawning is one of the few events on a reef you can put in a diary. A few nights after a full moon, when the water is warm enough, many colonies release bundles of eggs and sperm within the same hour, and the sea fills with what looks like slow pink snow. Predicting the night is half the science. The other half is staying awake for it.",
        "We dived with red torches, because white light can disturb the spawning, and a slate for timing. The plate corals went first and the branching ones about forty minutes later. We counted the colonies that spawned and the ones that did not, because the gap between those two numbers is one of the ways a reef tells you it is under stress."],
  spec:"Acropora, a branching coral. One colony is many thousands of genetically identical polyps.",read:"Water at 6 m, 22:10 local: 29.4 °C."},
 {no:110,date:"2026-10-22",title:"Ash in the ice",place:"Breiðamerkurjökull, Iceland",lat:64.10,lon:-16.30,topic:"ice",mins:11,img:"glacier",by:"Ruairi Coyle",
  dek:"Black stripes in a glacier front are diaries of old eruptions. We read them before they melt into the lagoon.",
  body:["The front of this glacier is striped like a cut cake. The black bands are volcanic ash. An eruption dusts the ice cap, snow buries the ash, and the layer travels down the glacier for centuries until it surfaces at the lagoon and calves into the water.",
        "Matching a stripe to a named eruption means sampling the glass shards in the ash and comparing their chemistry with known volcanoes. We collected eleven bands in two days. The work has a deadline: the snout has pulled back by kilometres since the early twentieth century, and every summer a few more pages of the diary float out to sea."],
  spec:"Tephra: shards of volcanic glass, each finer than sand, carrying the chemical fingerprint of their volcano.",read:"Lagoon surface at midday: 1.2 °C."},
 {no:109,date:"2026-10-08",title:"A forest that floats",place:"Monterey Bay, California",lat:36.62,lon:-121.90,topic:"oceans",mins:7,img:"kelp",by:"Tomasz Wren",
  dek:"Giant kelp can grow half a metre in a day, then lets go in the first winter storm. What the urchins do next decides the rest.",
  body:["Giant kelp is not a plant, strictly speaking, but a brown alga, and one of the fastest-growing organisms there is. In good conditions a frond can add around half a metre in a day, held upright by gas-filled bladders at the base of each blade.",
        "Storms tear it out. Whether the forest grows back often depends on the urchins: with too few predators they graze young kelp down to bare rock, a state called an urchin barren. We followed a team counting urchins in one-metre squares, and a sea otter that ate four of them while we watched."],
  spec:"Pneumatocyst: the gas bladder that floats each kelp blade up toward the light.",read:"Visibility at 8 m: about 7 m."},
 {no:108,date:"2026-09-24",title:"Roots that breathe through the mud",place:"Sundarbans, Bangladesh",lat:21.95,lon:89.18,topic:"wetlands",mins:10,img:"mangrove",by:"Ines Arkwright",
  dek:"Breathing roots, tiger tracks and a ranger who reads the mud like a newspaper.",
  body:["Mud in the Sundarbans holds almost no oxygen, so the mangroves send some of their roots up instead of down. At low tide, pencil-like breathing roots stand out of the silt by the thousand, taking in air through tiny pores.",
        "The forest straddles Bangladesh and India and is cut into islands by hundreds of channels. We spent five tides with a ranger who reads the mud the way other people read the news: crab burrows, otter slides, and once the broad pug marks of a tiger, already filling with water."],
  spec:"Keora mangrove, whose breathing roots rise above the mud at every low tide.",read:"Tidal range on the day: 3.1 m."},
 {no:107,date:"2026-09-10",title:"Living in the cloud",place:"Monteverde, Costa Rica",lat:10.30,lon:-84.80,topic:"forests",mins:8,img:"cloudforest",by:"Dr Amaka Ollen",
  dek:"Some of the water here never falls as rain. The moss combs it out of the fog, and we weighed it.",
  body:["Cloud forests drink sideways. When fog drifts through the canopy, droplets collect on moss, ferns and bromeliads and drip to the ground: water that never fell as rain. Researchers call it horizontal precipitation, and in the drier months it can matter as much as the rain does.",
        "We hung a simple fog collector, a mesh screen over a gutter, beside a weighed bundle of moss, and checked both every six hours. The moss soaked up water like a sponge and gave it back slowly, long after the cloud had lifted. Every trunk here is a reservoir in a green coat."],
  spec:"Bromeliad tank: a cup of leaves that holds water and houses tadpoles, larvae and the odd crab.",read:"Fog water caught overnight: 1.9 litres per square metre."},
 {no:106,date:"2026-08-27",title:"The mirror and the brine",place:"Salar de Uyuni, Bolivia",lat:-20.13,lon:-67.49,topic:"drylands",mins:9,img:"saltflat",by:"Ruairi Coyle",
  dek:"The largest salt flat on Earth is flat enough to calibrate satellites, and it sits on a fortune in lithium.",
  body:["Salar de Uyuni covers about ten and a half thousand square kilometres at more than 3,600 metres up. It is the floor of a lake that dried out, and it is remarkably flat: across its whole width the height changes by less than a metre, which is why satellite teams have used it to check their altimeters.",
        "After rain, a few centimetres of water turn it into a mirror. In the dry season the crust cracks into hexagons a metre or two across. Beneath it lies a brine rich in lithium, which is why the quietest place we visited this year is also one of the most argued over."],
  spec:"Halite polygons: salt crust that cracks into hexagons as it dries and recrystallises.",read:"Surface temperature at dawn: −6 °C."},
 {no:105,date:"2026-08-13",title:"Polygons in the permafrost",place:"Adventdalen, Svalbard",lat:78.20,lon:15.80,topic:"ice",mins:8,img:"tundra",by:"Tomasz Wren",
  dek:"Frozen ground sorts itself into honeycombs. A thaw season with the people who measure the cracks.",
  body:["On Svalbard the ground draws its own maps. Each winter, water in the soil freezes and expands. Each summer the top layer thaws above ground that stays frozen all year. Over centuries the cycle sorts stones and mud into polygons and rings, patterned ground you can see from a plane.",
        "We joined a team that measures how deep the summer thaw reaches, pushing a steel probe down until it hits ice, at the same points every year. It is unglamorous work, and it is how anyone knows that this thawed layer is thickening as Arctic summers warm."],
  spec:"Ice wedge: a vertical sheet of ground ice that grows a little each winter along a frost crack.",read:"Thaw depth at point 17: 92 cm."},
 {no:104,date:"2026-07-30",title:"A flood in the dry season",place:"Okavango Delta, Botswana",lat:-19.30,lon:22.90,topic:"wetlands",mins:12,img:"delta",by:"Ines Arkwright",
  dek:"Rain falls in the Angolan highlands early in the year and reaches the delta months later, in the middle of winter.",
  body:["The Okavango is a river that never reaches the sea. It rises in the Angolan highlands, crosses the Caprivi Strip and spreads out into the Kalahari, where nearly all of its water evaporates or is drunk by plants.",
        "Its flood is slow. Rain that falls in the highlands early in the year takes months to push through the papyrus, so the delta is fullest in the dry winter, just when animals from the surrounding sand country come in to drink. We tracked the flood front by canoe, and by the frogs, which start up the night the water arrives."],
  spec:"Papyrus: the sedge whose floating mats steer the delta's channels, and sometimes block them.",read:"Channel depth near Mboma: 1.4 m."},
 {no:103,date:"2026-07-16",title:"Deadwood is the point",place:"Białowieża Forest, Poland",lat:52.70,lon:23.85,topic:"forests",mins:9,img:"oldgrowth",by:"Dr Amaka Ollen",
  dek:"In one of Europe's last old-growth lowland forests, a fallen oak feeds hundreds of species for a century.",
  body:["Białowieża straddles the border of Poland and Belarus and is one of the last large fragments of the lowland forest that once covered much of Europe. Some of its most important trees are dead ones.",
        "A fallen oak here can take a century to disappear. Beetles bore in first, then fungi, then the woodpeckers that hunt both; mosses, slime moulds and seedlings follow. Foresters elsewhere used to tidy deadwood away. We spent a morning with a mycologist on a single trunk and lost count of species after sixty."],
  spec:"Tinder fungus, the hoof-shaped bracket people once carried to start fires.",read:"Oak girth at breast height: 5.8 m."},
 {no:102,date:"2026-07-02",title:"The desert in flower",place:"Atacama, Chile",lat:-27.40,lon:-70.30,topic:"drylands",mins:6,img:"bloom",by:"Ruairi Coyle",
  dek:"Years of almost nothing, then one wet winter and the gravel turns magenta. Notes from a desierto florido.",
  body:["The Atacama is among the driest places on Earth outside the poles. Some of its weather stations have gone years without measurable rain. Its seeds and bulbs simply wait.",
        "In years when winter rain does come, often in El Niño years, the southern Atacama blooms: the desierto florido. We found the gravel plains turned mauve by pata de guanaco, a flower that would be gone, its seeds back in the ground, within weeks."],
  spec:"Pata de guanaco, the magenta flower that leads the bloom.",read:"Winter rain at the nearest station: 23 mm."},
 {no:101,date:"2026-06-18",title:"Reading the ice of Baikal",place:"Lake Baikal, Siberia",lat:53.50,lon:108.00,topic:"ice",mins:10,img:"baikal",by:"Tomasz Wren",
  dek:"The deepest lake on Earth freezes clear enough to read. Bubbles, cracks, and what they record.",
  body:["Lake Baikal is the deepest lake on Earth, more than 1,600 metres, and holds around a fifth of the world's unfrozen surface fresh water. In late winter its ice can be clear enough to see stones on the bottom in the shallows.",
        "The ice keeps notes. Stacked white discs are methane bubbles frozen on their way up from the lakebed. Long glassy cracks open with a boom as the sheet contracts in the cold. We walked out with an ice auger and a tape measure and logged the thickness every kilometre."],
  spec:"Methane bubble stacks: gas from the lakebed, frozen layer by layer as it rises.",read:"Ice thickness at the 3 km mark: 71 cm."}
];
const NEXT = {no:113, lat:-23.5, lon:15.0};
window.FN_DATA = {ISSUES, NEXT, TOPICS};

const $ = (s, r=document) => r.querySelector(s);
const $$ = (s, r=document) => [...r.querySelectorAll(s)];
const RM = document.documentElement.classList.contains('rm');
const fmtDate = (iso, long) => new Date(iso+"T12:00:00Z").toLocaleDateString('en-GB', long?{weekday:'long',day:'numeric',month:'long'}:{day:'numeric',month:'short',year:'numeric'});
const fmtLL = (lat, lon, d=2) => `${Math.abs(lat).toFixed(d)}°${lat>=0?'N':'S'} ${Math.abs(lon).toFixed(d)}°${lon>=0?'E':'W'}`;
const byNo = no => ISSUES.find(i => i.no === +no);

/* ---------------- Next issue / countdown ---------------- */
const ANCHOR = Date.UTC(2026,10,19,7,0,0), FORT = 14*864e5;
function nextIssue(now=Date.now()){ const k = Math.max(1, Math.ceil((now-ANCHOR)/FORT)); return {no:112+k, t:ANCHOR+k*FORT}; }
(function(){
  const n = nextIssue(); NEXT.no = n.no;
  const d = new Date(n.t);
  $('#next-no').textContent = `No. ${n.no}`;
  $('#next-date').textContent = d.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'UTC'}) + '.';
  $$('[data-signup="footer"] .btn').forEach(b => b.textContent = `Get No. ${n.no}`);
  const cd = $('#countdown');
  function tick(){
    const ms = Math.max(0, n.t - Date.now());
    const dd = Math.floor(ms/864e5), hh = Math.floor(ms/36e5)%24, mm = Math.floor(ms/6e4)%60;
    cd.querySelector('[data-u="d"]').textContent = String(dd).padStart(2,'0');
    cd.querySelector('[data-u="h"]').textContent = String(hh).padStart(2,'0');
    cd.querySelector('[data-u="m"]').textContent = String(mm).padStart(2,'0');
  }
  tick(); setInterval(tick, 30000);
  // Calendar: 4 weeks starting on the Monday of this week
  const cal = $('#cal'), now = new Date(); const today = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate()));
  const start = new Date(today); start.setUTCDate(start.getUTCDate() - ((start.getUTCDay()+6)%7));
  const issueDays = [n.t, n.t+FORT].map(t => new Date(t).toISOString().slice(0,10));
  for(let i=0;i<28;i++){ const d2 = new Date(start); d2.setUTCDate(start.getUTCDate()+i); const iso = d2.toISOString().slice(0,10);
    const s = document.createElement('span'); s.textContent = d2.getUTCDate();
    if(i%7>4) s.classList.add('wk'); if(issueDays.includes(iso)) s.classList.add('issue'); if(+d2===+today) s.classList.add('today'); cal.appendChild(s); }
  $('#cal-cap').textContent = `Next: No. ${n.no} on ${fmtDate(issueDays[0])}, then No. ${n.no+1} on ${fmtDate(issueDays[1])}.`;
  // topic tags
  $('#tags').innerHTML = Object.entries(TOPICS).map(([k,v]) => `<li class="c-${k}">${v} <span>${ISSUES.filter(i=>i.topic===k).length} issues</span></li>`).join('');
})();

/* ---------------- Atlas list ---------------- */
(function(){
  const ul = $('#places');
  ul.innerHTML = ISSUES.map(i => `<li><button type="button" data-no="${i.no}"><span class="n">No. ${i.no}</span><span class="t">${i.place}</span><span class="c">${fmtLL(i.lat,i.lon,1)}</span></button></li>`).join('') +
    `<li class="next"><button type="button" data-next><span class="n">No. ${NEXT.no}</span><span class="t">Sealed until it lands</span><span class="c">?° ?°</span></button></li>`;
  ul.addEventListener('click', e => {
    const b = e.target.closest('button'); if(!b) return;
    if(b.hasAttribute('data-next')) return goJoin();
    const no = +b.dataset.no;
    if(window.FN_GLOBE) window.FN_GLOBE.flyTo(no, true, b); else openReader(no, b);
  });
  ['mouseover','focusin'].forEach(ev => ul.addEventListener(ev, e => { const b = e.target.closest('button'); if(b && window.FN_GLOBE) window.FN_GLOBE.highlight(b.dataset.no ? +b.dataset.no : NEXT.no); }));
  ['mouseleave','focusout'].forEach(ev => ul.addEventListener(ev, () => window.FN_GLOBE && window.FN_GLOBE.highlight(null)));
})();
function setHotPlace(no){ $$('#places button').forEach(b => b.classList.toggle('hot', (b.dataset.no ? +b.dataset.no : NEXT.no) === no)); }
function goJoin(){ const el = $('#join'); el.scrollIntoView({behavior: RM?'auto':'smooth', block:'start'}); setTimeout(()=>{ const i = $('#foot-email'); if(i && i.offsetParent) i.focus({preventScroll:true}); }, RM?0:700); }

/* ---------------- Archive ---------------- */
(function(){
  const grid = $('#grid'), chips = $('#chips');
  grid.innerHTML = ISSUES.map(i => `
   <article class="card" data-no="${i.no}" data-topic="${i.topic}">
     <figure><img src="assets/issue-${i.img}.webp" alt="${i.place}: ${altFor(i)}" loading="lazy" decoding="async" width="1000" height="667"><span class="no-tag">No. ${i.no}</span></figure>
     <div class="meta"><span class="topic c-${i.topic}">${TOPICS[i.topic]}</span><time datetime="${i.date}">${fmtDate(i.date)}</time><span>${i.mins} min</span></div>
     <h3><button type="button" class="open" data-no="${i.no}">${i.title}</button></h3>
     <p class="dek">${i.dek}</p>
     <div class="foot"><span>${i.place}</span><button type="button" class="locate" data-no="${i.no}" aria-label="Locate issue ${i.no}, ${i.place}, on the globe"><svg width="12" height="12" viewBox="0 0 12 12" fill="none" stroke="currentColor" stroke-width="1.3" aria-hidden="true"><circle cx="6" cy="6" r="4.5"/><circle cx="6" cy="6" r="1.2" fill="currentColor"/></svg>Locate</button></div>
   </article>`).join('');
  const counts = {all: ISSUES.length}; ISSUES.forEach(i => counts[i.topic] = (counts[i.topic]||0)+1);
  chips.innerHTML = [['all','All'], ...Object.entries(TOPICS)].map(([k,v]) => `<button type="button" class="chip" data-t="${k}" aria-pressed="${k==='all'}">${v}<span class="k">${counts[k]}</span></button>`).join('');
  let topic = 'all', q = '', sort = 'new';
  function apply(){
    const cards = $$('.card', grid);
    const order = [...ISSUES].sort((a,b) => sort==='old' ? a.no-b.no : sort==='short' ? a.mins-b.mins || b.no-a.no : b.no-a.no).map(i=>i.no);
    let shown = 0;
    cards.sort((a,b) => order.indexOf(+a.dataset.no) - order.indexOf(+b.dataset.no)).forEach(c => {
      const i = byNo(c.dataset.no);
      const hay = (i.title+' '+i.place+' '+i.dek+' '+TOPICS[i.topic]+' '+i.by+' '+i.body.join(' ')).toLowerCase();
      const ok = (topic==='all' || i.topic===topic) && (!q || q.split(/\s+/).every(w => hay.includes(w)));
      c.hidden = !ok; if(ok) shown++; grid.appendChild(c);
    });
    $('#count').textContent = `Showing ${shown} of ${ISSUES.length} issues` + (topic!=='all' ? ` · ${TOPICS[topic]}` : '') + (q ? ` · “${q}”` : '');
    $('#empty').classList.toggle('show', shown===0);
  }
  chips.addEventListener('click', e => { const b = e.target.closest('.chip'); if(!b) return; topic = b.dataset.t; $$('.chip', chips).forEach(c => c.setAttribute('aria-pressed', c===b)); apply(); });
  $('#q').addEventListener('input', e => { q = e.target.value.trim().toLowerCase(); apply(); });
  $('#sort').addEventListener('change', e => { sort = e.target.value; apply(); });
  $('#clear').addEventListener('click', () => { topic='all'; q=''; $('#q').value=''; $$('.chip', chips).forEach(c => c.setAttribute('aria-pressed', c.dataset.t==='all')); apply(); });
  grid.addEventListener('click', e => {
    const o = e.target.closest('.open'), l = e.target.closest('.locate');
    if(l){ locateOnGlobe(+l.dataset.no); return; }
    if(o) openReader(+o.dataset.no, o);
  });
  apply();
})();
function altFor(i){ return ({bog:"peat pools, cotton grass and russet moss under a grey sky",reef:"branching and plate corals with small blue fish in shallow water",glacier:"an ash-striped glacier front above a grey lagoon with floating ice",kelp:"tall amber kelp fronds in green water with an orange fish",mangrove:"mangrove stilt roots and breathing roots in tidal mud",cloudforest:"moss-covered trunks in drifting mist",saltflat:"cracked hexagonal salt crust leading to distant mountains at dusk",tundra:"polygon-patterned tundra with a melting snow patch and mountains beyond",delta:"winding channels and lily lagoons through golden floodplain grass",oldgrowth:"a mossy fallen oak among tall forest trees",bloom:"magenta wildflowers scattered across ochre gravel hills",baikal:"clear turquoise lake ice with white cracks and trapped bubbles"})[i.img]; }
function locateOnGlobe(no){
  const top = 0;
  window.scrollTo({top, behavior: RM?'auto':'smooth'});
  const go = () => window.FN_GLOBE && window.FN_GLOBE.flyTo(no, false);
  if(RM) go(); else setTimeout(go, Math.min(1100, 300 + window.scrollY/6));
}

/* ---------------- Reader ---------------- */
const reader = $('#reader'); let rCur = null, rOpener = null;
function openReader(no, opener){
  const i = byNo(no); if(!i) return; rCur = no; if(opener) rOpener = opener;
  $('#r-img').src = `assets/issue-${i.img}.webp`; $('#r-img').alt = `${i.place}: ${altFor(i)}`;
  $('#r-place').textContent = i.place; $('#r-coords').textContent = fmtLL(i.lat, i.lon);
  $('#r-where').textContent = `Field Notes · No. ${i.no} · ${fmtDate(i.date)}`;
  $('#r-kicker').innerHTML = `<span class="topic c-${i.topic}">${TOPICS[i.topic]}</span> · ${i.mins} min read · by ${i.by}`;
  $('#r-title').textContent = i.title; $('#r-dek').textContent = i.dek;
  $('#r-body').innerHTML = i.body.map(p => `<p>${p}</p>`).join('');
  $('#r-spec').textContent = i.spec; $('#r-read').textContent = i.read;
  const idx = ISSUES.indexOf(i);
  $('#r-prev').disabled = idx === ISSUES.length-1; $('#r-next').disabled = idx === 0;
  $('#r-prev').style.opacity = $('#r-prev').disabled ? .35 : 1; $('#r-next').style.opacity = $('#r-next').disabled ? .35 : 1;
  $('#r-scroll').scrollTop = 0;
  if(!reader.open){ reader.showModal(); document.documentElement.style.overflow='hidden'; }
  $('#r-close').focus();
  if(history.replaceState) history.replaceState(null, '', `#issue-${no}`);
}
function closeReader(){ if(reader.open) reader.close(); }
reader.addEventListener('close', () => {
  document.documentElement.style.overflow='';
  if(history.replaceState) history.replaceState(null, '', location.pathname + location.search);
  window.FN_GLOBE && window.FN_GLOBE.release();
  if(rOpener && document.contains(rOpener)) rOpener.focus({preventScroll:true});
});
reader.addEventListener('click', e => { if(e.target === reader) closeReader(); });
$('#r-close').addEventListener('click', closeReader);
$('#r-prev').addEventListener('click', () => { const k = ISSUES.findIndex(i=>i.no===rCur); if(k < ISSUES.length-1) openReader(ISSUES[k+1].no); });
$('#r-next').addEventListener('click', () => { const k = ISSUES.findIndex(i=>i.no===rCur); if(k > 0) openReader(ISSUES[k-1].no); });
$('#r-sub').addEventListener('click', () => { rOpener = null; closeReader(); goJoin(); });
$('#r-globe').addEventListener('click', () => { const no = rCur; rOpener = null; closeReader(); locateOnGlobe(no); });
reader.addEventListener('keydown', e => { if(e.key==='ArrowLeft' && e.target.tagName!=='INPUT') $('#r-prev').click(); if(e.key==='ArrowRight') $('#r-next').click(); });
window.FN_openReader = openReader;
window.addEventListener('load', () => { const m = location.hash.match(/^#issue-(\d+)/); if(m && byNo(m[1])) setTimeout(()=>openReader(+m[1]), 400); });

/* ---------------- Big number ---------------- */
(function(){
  const el = $('#bignum'); const target = 41860;
  if(RM || !('IntersectionObserver' in window)) return;
  el.textContent = '0';
  const io = new IntersectionObserver(es => { if(!es[0].isIntersecting) return; io.disconnect();
    const t0 = performance.now(); (function f(t){ const k = Math.min(1,(t-t0)/1600), e = 1-Math.pow(1-k,4); el.textContent = Math.round(target*e).toLocaleString('en-GB'); if(k<1) requestAnimationFrame(f); })(t0);
  }, {threshold:.4}); io.observe(el);
})();

/* ---------------- Sign-up forms ---------------- */
(function(){
  const P = PROVIDER_ALIAS[CONFIG.provider] || CONFIG.provider;
  const NAMES = {beehiiv:"beehiiv", substack:"Substack", ghost:"Ghost", kit:"Kit", embed:"our newsletter provider", custom:"our server", demo:"demo"};
  const NAME = NAMES[CONFIG.provider] || CONFIG.provider;
  const EMBED = P === 'embed' || P === 'ghost';
  const reEmail = /^[^\s@]+@[^\s@.]+(\.[^\s@.]+)*\.[^\s@.]{2,}$/;

  $$('form[data-signup]').forEach((form, n) => {
    const email = form.querySelector('input[name=email]'), consent = form.querySelector('input[name=consent]'),
          err = form.querySelector('.err'), btn = form.querySelector('button[type=submit]'), slot = form.querySelector('.embed-slot'),
          note = form.querySelector('.note');
    if(P === 'demo') note.insertAdjacentHTML('beforeend', ' <span class="demo-badge">Demo mode · nothing is sent</span>');

    if(EMBED){
      // Provider-hosted forms: load their embed only after the reader consents.
      form.classList.add('is-embed');
      form.querySelector('.consent-text').innerHTML = `Send me Field Notes by email, and load the sign-up form from ${NAME} (it connects to their servers and may set cookies). <a href="#faq-privacy">How we use your address</a>`;
      note.textContent = P === 'ghost'
        ? 'Ghost emails you a link to confirm (double opt-in) and handles validation inside its form.'
        : `The form below comes from ${NAME}, which handles confirmation, validation and spam protection. We keep its double opt-in setting on.`;
      consent.addEventListener('change', () => { if(consent.checked && !slot.childElementCount) mountEmbed(slot, n); if(consent.checked) err.textContent=''; });
      form.addEventListener('submit', e => { e.preventDefault(); if(!consent.checked){ err.textContent = 'Tick the box first: the sign-up form loads once you agree.'; consent.focus(); } });
      return;
    }

    function setErr(msg, el){ err.textContent = msg; [email, consent].forEach(x => x.setAttribute('aria-invalid', x===el)); if(el) el.focus(); }
    [email, consent].forEach(x => x.addEventListener('input', () => { x.removeAttribute('aria-invalid'); if(!email.getAttribute('aria-invalid') && !consent.getAttribute('aria-invalid')) err.textContent=''; }));

    form.addEventListener('submit', async e => {
      e.preventDefault();
      const v = email.value.trim();
      if(!v) return setErr('Add your email address so we know where to send the next issue.', email);
      if(!reEmail.test(v)) return setErr(v.includes('@') ? 'That address looks incomplete. Check the part after the @.' : 'That does not look like an email address yet: it needs an @.', email);
      if(!consent.checked) return setErr('Tick the box to confirm you want Field Notes by email.', consent);
      setErr('', null); [email, consent].forEach(x => x.removeAttribute('aria-invalid'));
      const hp = form.querySelector('input[name=website]').value;
      const name = (form.querySelector('input[name=first_name]')||{}).value || '';
      btn.disabled = true; const label = btn.textContent; btn.textContent = 'Sending…';
      try{
        if(hp){ await wait(600); }                          // honeypot filled: pretend success, send nothing
        else if(P === 'custom') await sendCustom(v, name);
        else await wait(700);                               // demo
        success(form, v);
      }catch(ex){
        setErr(ex && ex.userMessage || 'We could not reach the sign-up service. Check your connection and try again.', null);
      }finally{ btn.disabled = false; btn.textContent = label; }
    });
  });

  function wait(ms){ return new Promise(r => setTimeout(r, ms)); }
  function success(form, v){
    const nx = nextIssue(); const d = new Date(nx.t).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'UTC'});
    const box = document.createElement('div'); box.className = 'success'; box.tabIndex = -1; box.setAttribute('role','status');
    box.innerHTML = `<h3>Nearly there. Check your inbox.</h3><p>We sent a confirmation link to <b></b>. Click it and No. ${nx.no} arrives on ${d}.${P==='demo' ? ' <span class="demo-badge">Demo: nothing was sent</span>' : ''}</p><button type="button" class="again">Use a different address</button>`;
    box.querySelector('b').textContent = v;
    form.hidden = true; form.after(box); box.focus();
    box.querySelector('.again').addEventListener('click', () => { box.remove(); form.hidden = false; form.reset(); form.querySelector('input[name=email]').focus(); });
  }
  async function sendCustom(email, name){
    const c = CONFIG.custom; if(!c.url) throw {userMessage:'Sign-up is not connected yet (CONFIG.custom.url is empty).'};
    const data = {email, first_name:name, consent:true, source:location.href};
    const res = await fetch(c.url, c.format==='form'
      ? {method:'POST', body:new URLSearchParams(data)}
      : {method:'POST', headers:{'Content-Type':'application/json'}, body:JSON.stringify(data)});
    if(!res.ok) throw {userMessage: res.status===409 ? 'That address is already subscribed.' : `The sign-up service answered with an error (${res.status}). Please try again.`};
  }
  // Insert a provider's embed code. Scripts added through innerHTML never run, so each one is re-created.
  function injectEmbed(slot, html){
    const tpl = document.createElement('template'); tpl.innerHTML = html;
    slot.appendChild(tpl.content);
    slot.querySelectorAll('script').forEach(old => {
      const s = document.createElement('script');
      Array.from(old.attributes).forEach(a => s.setAttribute(a.name, a.value));
      if(!old.hasAttribute('async')) s.async = false;      // keep the snippet's own order
      s.text = old.textContent; old.replaceWith(s);
    });
  }
  // Ghost Admin's embed code (Settings → Growth → Signup forms → Embed), rebuilt from CONFIG.ghost.
  function ghostSnippet(g){
    const esc = v => String(v).replace(/&/g,'&amp;').replace(/"/g,'&quot;').replace(/</g,'&lt;');
    const allInOne = !!(g.title || g.description), d = {};
    if(allInOne){
      let h = String(g.backgroundColor||'#ffffff').replace('#',''); if(h.length === 3) h = h.replace(/./g,'$&$&');
      const c = parseInt(h,16), lum = (.299*(c>>16&255) + .587*(c>>8&255) + .114*(c&255)) / 255;
      d['background-color'] = '#'+h; d['text-color'] = lum > .6 ? '#000000' : '#ffffff';
    }
    d['button-color'] = g.buttonColor; d['button-text-color'] = '#ffffff';
    if(allInOne){ d.title = g.title; d.description = g.description; if(g.icon) d.icon = g.icon; }
    d.site = g.site; d.locale = g.locale || 'en';
    (g.labels||[]).forEach((l, i) => d['label-'+(i+1)] = l);
    const style = allInOne ? 'height: 40vmin;min-height: 360px' : 'min-height: 58px;max-width: 440px;margin: 0 auto;width: 100%';
    return `<div style="${style}"><script src="https://cdn.jsdelivr.net/ghost/signup-form@~0.4/umd/signup-form.min.js"${Object.entries(d).map(([k,v]) => ` data-${k}="${esc(v)}"`).join('')} async><\/script></div>`;
  }
  function mountEmbed(slot){
    const gate = msg => slot.innerHTML = `<p class="embed-gate" style="padding:12px">${msg}</p>`;
    if(P === 'embed'){
      if(!String(CONFIG.embedHtml||'').trim()) return gate('Paste your provider’s embed code into CONFIG.embedHtml.');
      injectEmbed(slot, CONFIG.embedHtml);
    } else if(P === 'ghost'){
      if(!/^https:\/\//.test(CONFIG.ghost.site||'')) return gate('Set CONFIG.ghost.site to your Ghost site address.');
      injectEmbed(slot, ghostSnippet(CONFIG.ghost));
    }
  }
})();
</script>

<script type="importmap">
{ "imports": {
  "three": "https://cdn.jsdelivr.net/npm/three@0.170.0/build/three.module.js",
  "three/addons/": "https://cdn.jsdelivr.net/npm/three@0.170.0/examples/jsm/"
} }
</script>
<script type="module">
const H = document.documentElement;
const preLog = document.getElementById('pre-log'), preBar = document.getElementById('pre-bar'), pre = document.getElementById('pre');
const steps = [];
function log(label, val, frac){ let li = steps[label]; if(!li){ li = document.createElement('li'); li.innerHTML = '<span></span><b></b>'; preLog.appendChild(li); steps[label] = li; li.firstChild.textContent = label; } li.lastChild.textContent = val; if(frac!=null) preBar.style.transform = `scaleX(${frac})`; }
function finishPre(){ pre.classList.add('done'); H.classList.remove('loading'); }
const failsafe = setTimeout(finishPre, 9000);
function toFallback(e){ console.warn('[Field Notes] WebGL path unavailable, using poster.', e && e.message); H.classList.remove('gl'); H.classList.add('nogl'); finishPre(); window.FN_GLOBE = null; }

/* Sun position (low-precision solar ephemeris, good to ~0.1°) */
function subsolar(date){
  const n = date/864e5 + 2440587.5 - 2451545.0, rad = Math.PI/180;
  const L = (280.460 + 0.9856474*n) % 360, g = ((357.528 + 0.9856003*n) % 360)*rad;
  const lam = (L + 1.915*Math.sin(g) + 0.020*Math.sin(2*g))*rad, eps = (23.439 - 4e-7*n)*rad;
  const dec = Math.asin(Math.sin(eps)*Math.sin(lam));
  const ra = Math.atan2(Math.cos(eps)*Math.sin(lam), Math.cos(lam))/rad;
  const gmst = (280.46061837 + 360.98564736629*n) % 360;
  let lon = ((ra - gmst) % 360 + 540) % 360 - 180;
  return {lat: dec/rad, lon};
}
const fmtLL = (lat, lon, d=2) => `${Math.abs(lat).toFixed(d)}°${lat>=0?'N':'S'} ${Math.abs(lon).toFixed(d)}°${lon>=0?'E':'W'}`;
const SUN = subsolar(Date.now()), SUN_T = new Date();
document.getElementById('hud-sun').textContent = `${fmtLL(SUN.lat, SUN.lon, 1)} · ${SUN_T.toISOString().slice(11,16)} UTC`;

if(H.classList.contains('gl')) boot().catch(toFallback);

async function boot(){
  log('Modules', 'loading', .05);
  const THREE = await import('three');
  const [{EffectComposer},{RenderPass},{UnrealBloomPass},{ShaderPass}] = await Promise.all([
    import('three/addons/postprocessing/EffectComposer.js'), import('three/addons/postprocessing/RenderPass.js'),
    import('three/addons/postprocessing/UnrealBloomPass.js'), import('three/addons/postprocessing/ShaderPass.js')]);
  log('Modules', 'three r170 · 4 passes', .18);

  const {ISSUES, NEXT} = window.FN_DATA;
  const RM = H.classList.contains('rm');
  const LOW = matchMedia('(max-width: 760px)').matches || (navigator.hardwareConcurrency||8) <= 4;
  const TIER = LOW ? {stars:80000, route:9000, seg:[112,72], pr:1.5, oct:4} : {stars:260000, route:40000, seg:[192,128], pr:1.75, oct:5};
  const D2R = Math.PI/180;
  const POSTER = /[?&]poster\b/.test(location.search);
  const canvas = document.getElementById('gl');
  const renderer = new THREE.WebGLRenderer({canvas, antialias:false, powerPreference:'high-performance'});
  renderer.setPixelRatio(Math.min(devicePixelRatio||1, TIER.pr));
  renderer.toneMapping = THREE.NoToneMapping;
  const scene = new THREE.Scene();
  scene.background = new THREE.Color().setRGB(0.0016, 0.0032, 0.0085, THREE.LinearSRGBColorSpace);
  const camera = new THREE.PerspectiveCamera(32, innerWidth/innerHeight, 0.1, 400);
  camera.position.set(0,0,4);

  const tiltG = new THREE.Group(), spinG = new THREE.Group(); tiltG.add(spinG); scene.add(tiltG);
  const ll = (lat, lon, r=1) => { const la = lat*D2R, ph = (lon+180)*D2R; return new THREE.Vector3(-Math.cos(ph)*Math.cos(la)*r, Math.sin(la)*r, Math.sin(ph)*Math.cos(la)*r); };

  /* ---- Textures ---- */
  log('Earth plates', '0 / 2', .22);
  const tl = new THREE.TextureLoader(); let got = 0;
  const load = (u) => tl.loadAsync(u).then(t => { got++; log('Earth plates', `${got} / 2`, .22 + got*.18); return t; });
  const [dayTex, packTex] = await Promise.all([load('assets/earth-day.webp'), load('assets/earth-pack.webp')]);
  dayTex.colorSpace = THREE.SRGBColorSpace; packTex.colorSpace = THREE.NoColorSpace;
  [dayTex, packTex].forEach(t => { t.anisotropy = Math.min(8, renderer.capabilities.getMaxAnisotropy()); t.wrapS = THREE.RepeatWrapping; });

  /* ---- Shared GLSL ---- */
  const NOISE = `
  vec4 permute(vec4 x){return mod(((x*34.0)+1.0)*x,289.0);} vec4 taylorInvSqrt(vec4 r){return 1.79284291400159-0.85373472095314*r;}
  float snoise(vec3 v){ const vec2 C=vec2(1.0/6.0,1.0/3.0); const vec4 D=vec4(0.0,0.5,1.0,2.0);
    vec3 i=floor(v+dot(v,C.yyy)); vec3 x0=v-i+dot(i,C.xxx); vec3 g=step(x0.yzx,x0.xyz); vec3 l=1.0-g; vec3 i1=min(g.xyz,l.zxy); vec3 i2=max(g.xyz,l.zxy);
    vec3 x1=x0-i1+C.xxx; vec3 x2=x0-i2+2.0*C.xxx; vec3 x3=x0-1.0+3.0*C.xxx; i=mod(i,289.0);
    vec4 p=permute(permute(permute(i.z+vec4(0.0,i1.z,i2.z,1.0))+i.y+vec4(0.0,i1.y,i2.y,1.0))+i.x+vec4(0.0,i1.x,i2.x,1.0));
    float n_=1.0/7.0; vec3 ns=n_*D.wyz-D.xzx; vec4 j=p-49.0*floor(p*ns.z*ns.z); vec4 x_=floor(j*ns.z); vec4 y_=floor(j-7.0*x_);
    vec4 x=x_*ns.x+ns.yyyy; vec4 y=y_*ns.x+ns.yyyy; vec4 h=1.0-abs(x)-abs(y); vec4 b0=vec4(x.xy,y.xy); vec4 b1=vec4(x.zw,y.zw);
    vec4 s0=floor(b0)*2.0+1.0; vec4 s1=floor(b1)*2.0+1.0; vec4 sh=-step(h,vec4(0.0)); vec4 a0=b0.xzyw+s0.xzyw*sh.xxyy; vec4 a1=b1.xzyw+s1.xzyw*sh.zzww;
    vec3 p0=vec3(a0.xy,h.x); vec3 p1=vec3(a0.zw,h.y); vec3 p2=vec3(a1.xy,h.z); vec3 p3=vec3(a1.zw,h.w);
    vec4 norm=taylorInvSqrt(vec4(dot(p0,p0),dot(p1,p1),dot(p2,p2),dot(p3,p3))); p0*=norm.x; p1*=norm.y; p2*=norm.z; p3*=norm.w;
    vec4 m=max(0.6-vec4(dot(x0,x0),dot(x1,x1),dot(x2,x2),dot(x3,x3)),0.0); m=m*m;
    return 42.0*dot(m*m,vec4(dot(p0,x0),dot(p1,x1),dot(p2,x2),dot(p3,x3))); }
  float fbm(vec3 p){ float a=0.5, s=0.0; for(int i=0;i<${TIER.oct};i++){ s+=a*snoise(p); p=p*2.03+vec3(1.7,9.2,3.1); a*=0.5; } return s; }
  float cloudAt(vec3 p, float t){ vec3 q=p*3.1+vec3(t*0.006,0.,t*0.003); q+=0.22*vec3(snoise(q*0.5+11.),snoise(q*0.5+23.),snoise(q*0.5+37.));
    float n=fbm(q); float lat=abs(p.y); float bias=0.07*smoothstep(0.55,0.85,lat)-0.10*smoothstep(0.15,0.3,lat)*(1.-smoothstep(0.38,0.55,lat));
    return smoothstep(0.10-bias,0.50-bias,n); }`;

  const sunW = new THREE.Vector3();   // world-space sun direction (animated)
  const SUN_HERO = new THREE.Vector3(-0.74, 0.30, 0.16).normalize();
  const SUN_FOCUS = new THREE.Vector3(-0.50, 0.32, 0.80).normalize();
  sunW.copy(SUN_HERO);

  /* ---- Globe ---- */
  const U = { uDay:{value:dayTex}, uPack:{value:packTex}, uSun:{value:sunW}, uTexel:{value:new THREE.Vector2(1/2048,1/1024)}, uBump:{value:2.2}, uTime:{value:0}, uCloud:{value:0} };
  const globeMat = new THREE.ShaderMaterial({ uniforms:U,
    vertexShader:`varying vec2 vUv; varying vec3 vN; varying vec3 vE; varying vec3 vNo; varying vec3 vPosW; varying vec3 vObj;
      void main(){ vUv=uv; vObj=position; vec3 n=normalize(position); vec3 e=cross(vec3(0.,1.,0.),n); e = length(e)<1e-4 ? vec3(1.,0.,0.) : normalize(e); vec3 no=cross(n,e);
        mat3 m=mat3(modelMatrix); vN=m*n; vE=m*e; vNo=m*no; vec4 w=modelMatrix*vec4(position,1.); vPosW=w.xyz; gl_Position=projectionMatrix*viewMatrix*w; }`,
    fragmentShader:`uniform sampler2D uDay,uPack; uniform vec3 uSun; uniform vec2 uTexel; uniform float uBump,uTime,uCloud;
      varying vec2 vUv; varying vec3 vN,vE,vNo,vPosW,vObj; ${NOISE}
      void main(){
        vec3 day=texture2D(uDay,vUv).rgb; vec4 pk=texture2D(uPack,vUv); float water=pk.r; float lights=pk.b;
        float hC=pk.g, hE=texture2D(uPack,vUv+vec2(uTexel.x,0.)).g, hN=texture2D(uPack,vUv+vec2(0.,uTexel.y)).g;
        vec3 N=normalize(vN); vec3 Nb=normalize(N-uBump*((hE-hC)*normalize(vE)+(hN-hC)*normalize(vNo)));
        vec3 V=normalize(cameraPosition-vPosW); float ndl=dot(N,uSun);
        float dayAmt=smoothstep(-0.10,0.20,ndl);
        float diff=max(dot(Nb,uSun),0.);
        vec3 col=day*(0.025+diff*1.35);
        col*=mix(vec3(1.),vec3(0.86,0.93,1.05),water*0.6);
        vec3 Hh=normalize(uSun+V); float sp=max(dot(N,Hh),0.);
        col+=vec3(1.,0.84,0.64)*(pow(sp,90.)*1.7+pow(sp,14.)*0.07)*water*dayAmt;
        float tw=exp(-pow(ndl/0.14,2.)); col=mix(col,col*vec3(1.5,0.82,0.52),tw*0.55);
        // soft cloud shadow, same field as the cloud layer, sampled toward the sun
        float cs=0.0; if(uCloud>0.5){ cs=cloudAt(normalize(vObj+uSun*0.0),uTime); }
        col*=1.0-cs*0.35*dayAmt;
        vec3 night=vec3(1.0,0.62,0.30)*pow(lights,1.7)*3.0*(1.0-cs*0.6)+day*0.010;
        col=mix(night,col,dayAmt);
        float fr=pow(1.-max(dot(N,V),0.),3.2);
        vec3 atm=mix(vec3(1.0,0.42,0.16),vec3(0.30,0.56,1.0),smoothstep(-0.05,0.35,ndl));
        col+=atm*fr*smoothstep(-0.28,0.25,ndl)*1.05;
        gl_FragColor=vec4(col,1.);
      }` });
  const globe = new THREE.Mesh(new THREE.SphereGeometry(1, TIER.seg[0], TIER.seg[1]), globeMat);
  spinG.add(globe);

  /* ---- Clouds (procedural, live) ---- */
  const cloudMat = new THREE.ShaderMaterial({ uniforms:{uSun:{value:sunW}, uTime:U.uTime}, transparent:true, depthWrite:false,
    vertexShader:`varying vec3 vN; varying vec3 vObj; varying vec3 vPosW; void main(){ vObj=position; vN=mat3(modelMatrix)*normalize(position); vec4 w=modelMatrix*vec4(position,1.); vPosW=w.xyz; gl_Position=projectionMatrix*viewMatrix*w; }`,
    fragmentShader:`uniform vec3 uSun; uniform float uTime; varying vec3 vN,vObj,vPosW; ${NOISE}
      void main(){ vec3 p=normalize(vObj); float c=cloudAt(p,uTime);
        vec3 N=normalize(vN); float ndl=dot(N,uSun); float lit=smoothstep(-0.18,0.30,ndl);
        vec3 V=normalize(cameraPosition-vPosW); float limb=smoothstep(0.0,0.35,dot(N,V));
        vec3 col=vec3(1.0,0.98,0.95)*(0.02+max(ndl,0.)*1.25);
        float tw=exp(-pow(ndl/0.16,2.)); col=mix(col,col*vec3(1.6,0.75,0.45)+vec3(0.06,0.02,0.),tw*0.6);
        gl_FragColor=vec4(col*lit, c*0.85*limb*mix(0.35,1.,lit)); }` });
  const clouds = new THREE.Mesh(new THREE.SphereGeometry(1.009, TIER.seg[0]*.75|0, TIER.seg[1]*.75|0), cloudMat);
  spinG.add(clouds);
  U.uCloud.value = LOW ? 0 : 1;

  /* ---- Atmosphere shell ---- */
  const atmo = new THREE.Mesh(new THREE.SphereGeometry(1.16, 96, 64), new THREE.ShaderMaterial({ uniforms:{uSun:{value:sunW}}, side:THREE.BackSide, transparent:true, depthWrite:false, blending:THREE.AdditiveBlending,
    vertexShader:`varying vec3 vNV; varying vec3 vNW; void main(){ vNV=normalize(normalMatrix*normal); vNW=normalize(mat3(modelMatrix)*normal); gl_Position=projectionMatrix*modelViewMatrix*vec4(position,1.); }`,
    fragmentShader:`uniform vec3 uSun; varying vec3 vNV,vNW; void main(){ float i=pow(clamp(-dot(vNV,vec3(0.,0.,1.))/0.5,0.,1.),2.6);
      float s=dot(normalize(vNW),uSun); float day=smoothstep(-0.45,0.35,s);
      vec3 c=mix(vec3(1.0,0.45,0.18),vec3(0.32,0.6,1.0),smoothstep(-0.15,0.4,s));
      gl_FragColor=vec4(c*i*day*2.2,1.); }` }));
  scene.add(atmo);

  /* ---- Stars ---- */
  log('Stars', '—', .64);
  { const N = TIER.stars, pos = new Float32Array(N*3), col = new Float32Array(N*3), sz = new Float32Array(N), sd = new Float32Array(N);
    const band = new THREE.Vector3(0.35,0.9,-0.25).normalize(); const tmp = new THREE.Vector3(), c = new THREE.Color();
    for(let i=0;i<N;i++){
      tmp.set(Math.random()*2-1, Math.random()*2-1, Math.random()*2-1).normalize();
      if(Math.random()<0.45){ tmp.addScaledVector(band, -tmp.dot(band)*(0.85+Math.random()*0.15)).normalize(); }
      const r = 60 + Math.random()*90; pos.set([tmp.x*r, tmp.y*r, tmp.z*r], i*3);
      const m = Math.pow(Math.random(), 9.0); sz[i] = 0.55 + m*2.6; sd[i] = Math.random();
      c.setHSL(Math.random()<0.6 ? 0.6 : 0.09, 0.25*Math.random(), 1); const b = 0.10 + m*2.6;
      col.set([c.r*b, c.g*b, c.b*b], i*3);
    }
    const g = new THREE.BufferGeometry(); g.setAttribute('position', new THREE.BufferAttribute(pos,3)); g.setAttribute('aCol', new THREE.BufferAttribute(col,3)); g.setAttribute('aSize', new THREE.BufferAttribute(sz,1)); g.setAttribute('aSeed', new THREE.BufferAttribute(sd,1));
    var stars = new THREE.Points(g, new THREE.ShaderMaterial({ uniforms:{uTime:U.uTime, uPR:{value:renderer.getPixelRatio()}}, transparent:true, depthWrite:false, blending:THREE.AdditiveBlending,
      vertexShader:`attribute vec3 aCol; attribute float aSize,aSeed; uniform float uTime,uPR; varying vec3 vC; void main(){ vec4 mv=modelViewMatrix*vec4(position,1.); gl_Position=projectionMatrix*mv;
        float tw=0.72+0.28*sin(uTime*(0.6+aSeed*2.2)+aSeed*60.); vC=aCol*tw; gl_PointSize=aSize*uPR; }`,
      fragmentShader:`varying vec3 vC; void main(){ float d=length(gl_PointCoord-0.5); float a=smoothstep(0.5,0.0,d); gl_FragColor=vec4(vC*a*a,1.); }` }));
    scene.add(stars);
  }
  log('Stars', (TIER.stars).toLocaleString('en-GB'), .7);

  /* ---- Route: chronological great-circle arcs, as flowing particles ---- */
  const chron = [...ISSUES].sort((a,b)=>a.no-b.no);
  const legs = []; for(let i=0;i<chron.length-1;i++) legs.push([ll(chron[i].lat, chron[i].lon), ll(chron[i+1].lat, chron[i+1].lon)]);
  legs.push([ll(chron[chron.length-1].lat, chron[chron.length-1].lon), ll(NEXT.lat, NEXT.lon)]);
  { const N = TIER.route, A = new Float32Array(N*3), B = new Float32Array(N*3), T = new Float32Array(N), J = new Float32Array(N*3), L = new Float32Array(N);
    for(let i=0;i<N;i++){ const k = i % legs.length; A.set(legs[k][0].toArray(), i*3); B.set(legs[k][1].toArray(), i*3); T[i] = Math.random(); L[i] = k===legs.length-1 ? 1 : 0;
      J.set([(Math.random()-.5), (Math.random()-.5), (Math.random()-.5)], i*3); }
    const g = new THREE.BufferGeometry(); g.setAttribute('position', new THREE.BufferAttribute(A,3)); g.setAttribute('aB', new THREE.BufferAttribute(B,3)); g.setAttribute('aT', new THREE.BufferAttribute(T,1)); g.setAttribute('aJ', new THREE.BufferAttribute(J,3)); g.setAttribute('aLast', new THREE.BufferAttribute(L,1));
    g.boundingSphere = new THREE.Sphere(new THREE.Vector3(), 2);
    var route = new THREE.Points(g, new THREE.ShaderMaterial({ uniforms:{uTime:U.uTime, uPR:{value:renderer.getPixelRatio()}, uSun:{value:sunW}}, transparent:true, depthWrite:false, blending:THREE.AdditiveBlending,
      vertexShader:`attribute vec3 aB,aJ; attribute float aT,aLast; uniform float uTime,uPR; varying float vA; varying float vLast;
        void main(){ vec3 a=normalize(position), b=normalize(aB); float o=acos(clamp(dot(a,b),-1.,1.)); float t=fract(aT+uTime*(0.018+0.02/(o+0.4)));
          vec3 p=(sin((1.-t)*o)*a+sin(t*o)*b)/max(sin(o),1e-3); float h=1.006+(0.012+0.07*o/3.1416)*sin(3.1416*t);
          p=p*h+aJ*0.006*sin(3.1416*t); vec4 mv=modelViewMatrix*vec4(p,1.); gl_Position=projectionMatrix*mv;
          float tail=pow(aT,2.2); vA=sin(3.1416*t)*tail; vLast=aLast; gl_PointSize=(0.9+1.6*vA)*uPR; }`,
      fragmentShader:`varying float vA; varying float vLast; void main(){ float d=length(gl_PointCoord-0.5); float a=smoothstep(0.5,0.,d);
        vec3 c=mix(vec3(1.0,0.66,0.32),vec3(0.75,0.85,1.0),vLast); gl_FragColor=vec4(c*a*vA*mix(0.75,0.5,vLast),1.); }` }));
    spinG.add(route);
  }

  /* ---- Pins ---- */
  const PINS = [...ISSUES.map(i => ({no:i.no, lat:i.lat, lon:i.lon, kind: i.no===ISSUES[0].no ? 2 : 0, issue:i})), {no:NEXT.no, lat:NEXT.lat, lon:NEXT.lon, kind:3}];
  const pinPos = new Float32Array(PINS.length*3), pinKind = new Float32Array(PINS.length), pinHot = new Float32Array(PINS.length), pinSeed = new Float32Array(PINS.length);
  const stemPos = new Float32Array(PINS.length*6);
  PINS.forEach((p,i) => { p.head = ll(p.lat, p.lon, 1.05); p.base = ll(p.lat, p.lon, 1.0); pinPos.set(p.head.toArray(), i*3); pinKind[i] = p.kind; pinSeed[i] = i*0.37;
    stemPos.set([...p.base.toArray(), ...p.head.toArray()], i*6); });
  const pg = new THREE.BufferGeometry(); pg.setAttribute('position', new THREE.BufferAttribute(pinPos,3)); pg.setAttribute('aKind', new THREE.BufferAttribute(pinKind,1)); pg.setAttribute('aHot', new THREE.BufferAttribute(pinHot,1)); pg.setAttribute('aSeed', new THREE.BufferAttribute(pinSeed,1));
  const pinMat = new THREE.ShaderMaterial({ uniforms:{uTime:U.uTime, uPR:{value:renderer.getPixelRatio()}, uScale:{value:1}}, transparent:true, depthWrite:false, blending:THREE.AdditiveBlending,
    vertexShader:`attribute float aKind,aHot,aSeed; uniform float uTime,uPR,uScale; varying float vK; varying float vH; varying float vP;
      void main(){ vec4 mv=modelViewMatrix*vec4(position,1.); gl_Position=projectionMatrix*mv; vK=aKind; vH=aHot; vP=fract(uTime*0.45+aSeed);
        float s=(aKind>1.5&&aKind<2.5?54.:40.)*(1.+aHot*0.6); gl_PointSize=s*uPR*uScale*(3.0/-mv.z); }`,
    fragmentShader:`varying float vK,vH,vP; void main(){ vec2 q=gl_PointCoord-0.5; float d=length(q)*2.;
        bool sealed=vK>2.5; vec3 c=sealed?vec3(0.70,0.82,1.0):vec3(1.0,0.66,0.30);
        float core=smoothstep(0.22,0.0,d)*(sealed?0.:1.);
        float halo=exp(-d*d*9.)*0.55;
        float rr=vP; float ring=smoothstep(0.06,0.0,abs(d-0.25-rr*0.7))*(1.-rr)*(0.7+vK*0.15);
        float dash=sealed? step(0.5,fract(atan(q.y,q.x)*3.0+vP*2.)) : 1.;
        float sring=sealed? smoothstep(0.05,0.0,abs(d-0.42))*dash*1.3 : 0.;
        vec3 col=c*(core*5.0+halo*(1.+vH*1.6)+ring*1.4+sring)+vec3(1.)*core*(1.5+vH*2.);
        float a=max(max(core,halo),max(ring,sring)); if(a<0.004) discard; gl_FragColor=vec4(col,1.); }` });
  const pins = new THREE.Points(pg, pinMat); pins.renderOrder = 3; spinG.add(pins);
  const sg = new THREE.BufferGeometry(); sg.setAttribute('position', new THREE.BufferAttribute(stemPos,3));
  const stems = new THREE.LineSegments(sg, new THREE.LineBasicMaterial({color:new THREE.Color(1.6,1.0,0.5), transparent:true, opacity:0.75, blending:THREE.AdditiveBlending, depthWrite:false}));
  spinG.add(stems);
  log('Field pins', `${PINS.length} plotted`, .76);

  /* ---- Post: bloom + grade (ACES, grain, vignette, CA, sun leak) ---- */
  const composer = new EffectComposer(renderer);
  composer.addPass(new RenderPass(scene, camera));
  const bloom = new UnrealBloomPass(new THREE.Vector2(innerWidth, innerHeight), 0.5, 0.55, 0.93);
  composer.addPass(bloom);
  const grade = new ShaderPass({ uniforms:{ tDiffuse:{value:null}, uTime:{value:0}, uRes:{value:new THREE.Vector2(1,1)}, uSunUv:{value:new THREE.Vector2(-0.12,0.95)}, uSunAmt:{value:0.16}, uCA:{value:0.0016}, uExpo:{value:1.18}, uGrain:{value:0.045} },
    vertexShader:`varying vec2 vUv; void main(){ vUv=uv; gl_Position=projectionMatrix*modelViewMatrix*vec4(position,1.); }`,
    fragmentShader:`uniform sampler2D tDiffuse; uniform float uTime,uSunAmt,uCA,uExpo,uGrain; uniform vec2 uRes,uSunUv; varying vec2 vUv;
      vec3 aces(vec3 x){ return clamp((x*(2.51*x+0.03))/(x*(2.43*x+0.59)+0.14),0.,1.); }
      float hash(vec2 p){ p=fract(p*vec2(443.897,441.423)); p+=dot(p,p.yx+19.19); return fract((p.x+p.y)*p.x); }
      void main(){ vec2 d=vUv-0.5; vec3 c;
        c.r=texture2D(tDiffuse,vUv+d*uCA).r; c.g=texture2D(tDiffuse,vUv).g; c.b=texture2D(tDiffuse,vUv-d*uCA).b;
        vec2 sd=(vUv-uSunUv)*vec2(uRes.x/uRes.y,1.); float sl=exp(-length(sd)*3.6); c+=vec3(1.0,0.66,0.38)*sl*uSunAmt + vec3(1.,0.85,0.6)*pow(sl,5.)*uSunAmt*1.5;
        c=aces(c*uExpo);
        c=pow(c,vec3(1.0/2.2));
        float l=dot(c,vec3(0.299,0.587,0.114)); c=mix(c*vec3(0.92,0.98,1.08),c*vec3(1.04,1.0,0.94),smoothstep(0.15,0.7,l));
        float v=smoothstep(1.05,0.32,length(d*vec2(1.0,1.1))); c*=mix(0.62,1.0,v);
        c+=(hash(vUv*uRes+fract(uTime*7.13)*100.)-0.5)*uGrain;
        gl_FragColor=vec4(c,1.); }` });
  composer.addPass(grade);

  /* ---- Layout: two scroll shots + a focus shot ---- */
  let W = innerWidth, Hh = innerHeight, stacked = false;
  const shots = {A:{}, B:{}, F:{}};
  const tanH = Math.tan(camera.fov*D2R/2);
  const distFor = rPx => Math.sqrt(1 + Math.pow((Hh/2)/(rPx*tanH), 2));
  function layout(){
    W = innerWidth; Hh = innerHeight; stacked = W < 900 || W/Hh < 1.1;
    if(stacked){
      const r = Math.min(0.40*W, 0.22*Hh); shots.A = {cx:0.5*W, cy:Math.max(r+70, 0.27*Hh), r};
      const r2 = Math.min(0.44*W, 0.25*Hh); shots.B = {cx:0.5*W, cy:Math.max(r2+40, 0.27*Hh), r:r2};
      H.style.setProperty('--gb', Math.round(shots.A.cy + r*1.12 + 8) + 'px');
    } else {
      const r = Math.min(0.36*Hh, 0.24*W); shots.A = {cx:Math.max(0.70*W, W - r - 0.08*W), cy:0.52*Hh, r};
      shots.B = {cx:0.69*W, cy:0.5*Hh, r:Math.min(0.46*Hh, 0.28*W)};
    }
    shots.F = {cx:0.5*W, cy:0.5*Hh, r:Math.min(0.85*Hh, 0.7*W)};
    shots.L = {cx:shots.A.cx, cy:shots.A.cy, r:shots.A.r*(stacked?1.12:1.3)};
    if(POSTER){ shots.A = shots.B = {cx:W/2, cy:Hh/2, r:0.40*Math.min(W,Hh)}; }
    camera.aspect = W/Hh; renderer.setSize(W, Hh, false); composer.setSize(W, Hh); bloom.setSize(W, Hh);
    grade.uniforms.uRes.value.set(W, Hh); pinMat.uniforms.uScale.value = stacked ? 0.8 : 1;
    canvas.style.width = W+'px'; canvas.style.height = Hh+'px';
    dirty = true;
  }

  /* ---- State ---- */
  const sunLocal = ll(SUN.lat, SUN.lon);
  const az = v => Math.atan2(v.x, v.z);
  let spin = az(SUN_HERO) - az(sunLocal), tilt = 0.38;
  let yaw = 0, pitch = 0, yawT = 0, pitchT = 0;          // cursor springs
  let focus = 0, fly = null, held = false, fShot = 'F';                // focus 0..1 (fly-to shot)
  let scrollP = 0, intro = RM ? 1 : 0, introStart = 0;
  let dirty = true, running = true, visible = true, t = 0, last = performance.now();
  let hot = null, listHot = null, drag = null;
  const ease = k => k<.5 ? 4*k*k*k : 1-Math.pow(-2*k+2,3)/2;
  const wrap = a => Math.atan2(Math.sin(a), Math.cos(a));

  function camForShot(s){ return {d:distFor(s.r), ox:W/2 - s.cx, oy:Hh/2 - s.cy}; }
  function mix(a,b,k){ return a+(b-a)*k; }
  const _v = new THREE.Vector3(), _w = new THREE.Vector3();

  function flyTo(no, open, opener){
    const p = PINS.find(p => p.no === no); if(!p) return;
    const loc = ll(p.lat, p.lon);
    const s1 = spin + wrap(-az(loc) - spin), t1 = Math.max(-1.2, Math.min(1.2, p.lat*D2R));
    held = true; setHot(no); fShot = open ? 'F' : 'L';
    if(RM){ spin = s1; tilt = t1; focus = 1; dirty = true; kick(); if(open && p.issue) window.FN_openReader(no, opener); return; }
    fly = {t0:performance.now(), dur:1700, s0:spin, s1, t0v:tilt, t1, f0:focus, f1: 1, open, no, opener};
    clearTimeout(relT); if(!open) relT = setTimeout(() => { if(held && !document.getElementById('reader').open) release(); }, 6500);
    dirty = true; kick();
  }
  let relT = 0;
  function release(){ if(!held && !fly) return; held = false; clearTimeout(relT); if(RM){ focus = 0; tilt = 0.38; dirty = true; setHot(null); kick(); return; } fly = {t0:performance.now(), dur:1300, s0:spin, s1:spin+0.25, t0v:tilt, t1:0.38, f0:focus, f1:0}; setHot(null); kick(); }
  function highlight(no){ listHot = no; setHot(held ? hot : hot); kick(); }
  window.FN_GLOBE = {flyTo, release, highlight, pins: () => PINS.map(p => ({no:p.no, ...screenOf(p)}))};

  /* ---- Pointer: hover, drag, click ---- */
  const tip = document.getElementById('tip'), tagL = document.getElementById('tag-latest'), hudCur = document.getElementById('hud-cur');
  const ray = new THREE.Raycaster(), ndc = new THREE.Vector2(); let mouse = null;
  function screenOf(p){ _v.copy(p.head).applyMatrix4(spinG.matrixWorld); const facing = _v.clone().normalize().dot(_w.copy(camera.position).sub(_v).normalize()); _v.project(camera);
    return {x:(_v.x*.5+.5)*W, y:(-_v.y*.5+.5)*Hh, ok: facing > 0.12 && _v.z < 1}; }
  function pick(x,y){ let best=null, bd=26*26; for(const p of PINS){ const s = screenOf(p); if(!s.ok) continue; const d=(s.x-x)**2+(s.y-y)**2; if(d<bd){bd=d; best=p;} } return best; }
  function setHot(no){ hot = no; PINS.forEach((p,i)=> pinHot[i] = (p.no===no || p.no===listHot) ? 1 : 0); pg.attributes.aHot.needsUpdate = true; if(window.setHotPlace) setHotPlace(no ?? listHot); dirty = true; kick(); }
  canvas.addEventListener('pointermove', e => {
    mouse = {x:e.clientX, y:e.clientY};
    if(!RM){ yawT = (e.clientX/W - .5)*0.5; pitchT = (e.clientY/Hh - .5)*0.24; }
    if(drag){ const dx = e.clientX-drag.x, dy = e.clientY-drag.y; if(Math.abs(dx)+Math.abs(dy) > 4) drag.moved = true; spin += dx*0.0055; tilt = Math.max(-1.1, Math.min(1.2, tilt + dy*0.004)); drag.x = e.clientX; drag.y = e.clientY; drag.v = dx*0.0055; dirty = true; return; }
    const p = pick(e.clientX, e.clientY); canvas.classList.toggle('over-pin', !!p);
    if((p && p.no) !== hot && !held) setHot(p ? p.no : null);
    dirty = true; kick();
  });
  canvas.addEventListener('pointerleave', () => { mouse = null; yawT = pitchT = 0; if(!held) setHot(null); hudCur.textContent = '—'; });
  canvas.addEventListener('pointerdown', e => { if(held && !fly) release(); drag = {x:e.clientX, y:e.clientY, moved:false, v:0, id:e.pointerId}; canvas.classList.add('drag'); });
  const endDrag = e => { if(!drag) return; canvas.classList.remove('drag'); const d = drag; drag = null; if(!RM) spinVel = d.v/0.016*0.6;
    if(!d.moved){ const p = pick(e.clientX, e.clientY); if(p){ if(p.kind===3) document.querySelector('#places [data-next]').click(); else flyTo(p.no, true); } } };
  canvas.addEventListener('pointerup', endDrag); canvas.addEventListener('pointercancel', () => { drag = null; canvas.classList.remove('drag'); });
  let spinVel = 0;

  /* ---- Visibility & resize ---- */
  const night = document.getElementById('night');
  new IntersectionObserver(es => { visible = es[0].isIntersecting; if(visible) kick(); else { tip.classList.remove('on'); tagL.classList.remove('on'); } }, {rootMargin:'0px'}).observe(night);
  document.addEventListener('visibilitychange', () => { if(!document.hidden) kick(); });
  addEventListener('resize', () => { layout(); kick(); });
  addEventListener('scroll', () => { dirty = true; kick(); }, {passive:true});
  let raf = 0; function kick(){ if(!raf) { last = performance.now(); raf = requestAnimationFrame(frame); } }

  function updateTip(){
    let p = null; const h = hot ?? listHot; if(h!=null) p = PINS.find(q=>q.no===h);
    if(p){ const s = screenOf(p); if(s.ok && !document.getElementById('reader').open){ tip.style.transform = `translate(${Math.round(s.x)}px,${Math.round(s.y)}px) translate(-50%,calc(-100% - 18px))`;
        if(tip.dataset.no != p.no){ tip.dataset.no = p.no; tip.innerHTML = p.kind===3 ? `<small>No. ${p.no} · next issue</small><strong>Destination sealed</strong>Subscribe to find out` : `<small>No. ${p.issue.no} · ${p.issue.place}</small><strong></strong>${fmtLL(p.lat,p.lon,1)} · ${p.issue.mins} min read`; if(p.issue) tip.querySelector('strong').textContent = p.issue.title; }
        tip.classList.add('on'); } else tip.classList.remove('on'); } else tip.classList.remove('on');
    const L = PINS[0], s = screenOf(L);
    if(s.ok && h == null && focus < 0.3 && scrollP < 0.9){ tagL.style.transform = `translate(${Math.round(s.x)}px,${Math.round(s.y)}px) translate(-50%,calc(-100% - 16px))`; tagL.textContent = `Latest · No. ${L.no}`; tagL.classList.add('on'); } else tagL.classList.remove('on');
    if(mouse && !drag){ ndc.set(mouse.x/W*2-1, -(mouse.y/Hh)*2+1); ray.setFromCamera(ndc, camera); const o = ray.ray.origin, dv = ray.ray.direction;
      const b = o.dot(dv), c = o.dot(o)-1, disc = b*b-c; if(disc>0){ const tt = -b-Math.sqrt(disc); _v.copy(o).addScaledVector(dv, tt); _w.copy(_v).applyMatrix4(_inv.copy(spinG.matrixWorld).invert());
        const lat = Math.asin(Math.max(-1,Math.min(1,_w.y)))/D2R; let lon = Math.atan2(_w.z, -_w.x)/D2R - 180; lon = ((lon+540)%360)-180; hudCur.textContent = fmtLL(lat, lon, 2); } else hudCur.textContent = 'open space'; }
  }
  const _inv = new THREE.Matrix4();

  function frame(now){
    raf = 0;
    const dt = Math.min(0.05, (now-last)/1000); last = now;
    if(!visible || document.hidden) return;
    if(!RM) t += dt;
    // scroll progress between hero shot A and atlas shot B
    const atl = document.getElementById('atlas'); const pS = Math.max(0, Math.min(1, scrollY / Math.max(1, atl.offsetTop)));
    if(Math.abs(pS-scrollP) > 1e-4){ scrollP = pS; dirty = true; }
    // fly tween
    if(fly){ const k = Math.min(1, (now - fly.t0)/fly.dur), e = ease(k);
      spin = mix(fly.s0, fly.s1, e); tilt = mix(fly.t0v, fly.t1, e); focus = mix(fly.f0, fly.f1, e);
      if(k>=1){ const f = fly; fly = null; if(f.open){ const p = PINS.find(q=>q.no===f.no); if(p && p.issue) window.FN_openReader(f.no, f.opener); } }
      dirty = true; }
    else if(!RM && !held && !drag){ spinVel *= Math.exp(-dt*2.2); spin += (0.045 + spinVel)*dt * (hot!=null ? 0.15 : 1); dirty = true; }
    if(!RM){ const k = 1-Math.exp(-dt*3.5); yaw += (yawT*(1-focus) - yaw)*k; pitch += (pitchT*(1-focus) - pitch)*k; }
    if(intro < 1){ intro = Math.min(1, (now-introStart)/2600); dirty = true; }
    if(!dirty && RM) return;
    const ie = 1-Math.pow(1-intro, 3);
    spinG.rotation.y = spin + yaw - (1-ie)*1.1;
    tiltG.rotation.x = tilt + pitch + (1-ie)*0.25;
    // camera
    const sp = scrollP*scrollP*(3-2*scrollP);
    const A = camForShot(shots.A), B = camForShot(shots.B), F = camForShot(shots[fShot]);
    let d = mix(A.d, B.d, sp), ox = mix(A.ox, B.ox, sp), oy = mix(A.oy, B.oy, sp);
    const fe = focus*focus*(3-2*focus); d = mix(d, F.d, fe); ox = mix(ox, F.ox, fe); oy = mix(oy, F.oy, fe);
    d *= 1 + (1-ie)*0.9;
    camera.position.set(0, 0, d); camera.lookAt(0,0,0);
    camera.setViewOffset(W, Hh, ox, oy, W, Hh); camera.updateProjectionMatrix();
    sunW.copy(SUN_HERO).lerp(SUN_FOCUS, fe).normalize();
    grade.uniforms.uSunAmt.value = (0.16 - fe*0.08) * ie; grade.uniforms.uTime.value = t;
    U.uTime.value = t;
    tiltG.updateMatrixWorld(true);
    updateTip();
    composer.render(dt);
    dirty = false;
    if(!RM || fly || intro < 1) raf = requestAnimationFrame(frame);
  }

  layout();
  /* ---- Readiness: compile every program, then warm the full post chain ---- */
  log('Shaders', 'compiling', .8);
  tiltG.updateMatrixWorld(true);
  if(renderer.compileAsync) await renderer.compileAsync(scene, camera); else renderer.compile(scene, camera);
  log('Shaders', `${renderer.info.programs.length} programs`, .9);
  for(let i=0;i<3;i++){ camera.position.set(0,0,4); composer.render(0.016); await new Promise(r => requestAnimationFrame(r)); }
  log('Warm frames', '3 / 3 · bloom + grade', 1);
  clearTimeout(failsafe);
  await new Promise(r => setTimeout(r, RM ? 0 : 250));
  introStart = performance.now(); finishPre();
  dirty = true; kick();
}
</script>
</body>
</html>

````
