#102 ui dark mobile: native-first Navigation & Docks

Floating Bottom Thumb Dock & Morphing Action Pill

Bottom-anchored floating pill dock that morphs smoothly between browsing, search, summarize, and tab switching.

Inspired by Arc ↗

Download .html
Fullscreen ↗

WHY THIS AESTHETIC IS UNIQUE

Replaces rigid top toolbars with a kinetic, thumb-reachable capsule that expands in place for each task mode without obscuring the reading canvas.

BEST FOR

Mobile web browsersAI reading companionsContent-first media appsSingle-hand productivity tools

TAGS

COLOR PALETTE (CLICK TO COPY HEX)

TYPOGRAPHY

Display
Space Grotesk
Body
Inter
Mono
IBM Plex Mono
Scale
Crisp 14px pill controls with high-contrast 20-28px editorial headlines in the reading feed.

Google Fonts Stylesheet ↗

ARCHITECTURE & MOBILE NOTES

LAYOUT

Uncluttered vertical content stream with generous bottom clearance so the floating pill dock never masks the final lines of text.

INTERACTION

Tapping any mode icon morphs the pill width and reveals inline search input, AI summary card, or tab carousel with spring-eased transitions.

MOBILE

Positioned 16px above the bottom safe-area inset within natural thumb arc; every pill control meets >=44x44px touch target sizing.

AI AGENT GUARDRAILS

DO

  • Reserve at least 96px of bottom padding on the scrollable content area so the floating dock never permanently covers content
  • Keep the primary mode switcher limited to 3-5 distinct states so the pill never wraps or clips on 390px screens
  • Animate morph transitions with GPU-friendly transform and opacity properties

DON'T

  • Do not stack multiple floating bars on top of the morphing dock
  • Do not auto-hide the dock completely without a clear tap-to-restore affordance
STANDALONE SOURCE · demos/floating-thumb-dock.html (32.2 KB)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Drift — Floating Thumb Dock &amp; Morphing Action Pill</title>
<style>
  :root {
    --canvas: #0C0E18;
    --surface: #161929;
    --surface-elev: #1E2238;
    --ink: #F4F5FA;
    --muted: #8A90AD;
    --accent: #818CF8;
    --accent-bright: #A5B4FC;
    --accent-glow: rgba(129, 140, 248, 0.24);
    --border: rgba(255, 255, 255, 0.09);
    --border-strong: rgba(129, 140, 248, 0.42);
    --spring: cubic-bezier(0.32, 1.24, 0.46, 1);
  }

  * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
  }

  html, body {
    height: 100%;
    background: var(--canvas);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
    overflow-x: hidden;
  }

  /* Reading Progress Bar */
  .progress-track {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: rgba(255, 255, 255, 0.05);
    z-index: 40;
  }

  .progress-fill {
    height: 100%;
    width: 12%;
    background: linear-gradient(90deg, #6366F1, #818CF8, #C084FC);
    transition: width 0.12s linear;
  }

  /* Top Minimal Chrome */
  .top-chrome {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: linear-gradient(180deg, rgba(12, 14, 24, 0.94) 65%, rgba(12, 14, 24, 0));
    backdrop-filter: blur(8px);
  }

  .brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
  }

  .brand-orb {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #C7D2FE, #6366F1);
    box-shadow: 0 0 12px var(--accent);
  }

  .top-actions {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .top-chip {
    min-height: 36px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(22, 25, 41, 0.8);
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
  }

  .top-chip:hover, .top-chip.active {
    color: var(--ink);
    border-color: var(--border-strong);
    background: rgba(129, 140, 248, 0.14);
  }

  /* Main Reading Workspace */
  .reader-shell {
    max-width: 720px;
    margin: 0 auto;
    padding: 16px 20px 180px;
  }

  .article-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
    font-size: 12.5px;
    color: var(--accent-bright);
    font-weight: 600;
  }

  .meta-pill {
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(129, 140, 248, 0.14);
    border: 1px solid rgba(129, 140, 248, 0.25);
  }

  .meta-muted {
    color: var(--muted);
    font-weight: 500;
  }

  .article-title {
    font-family: Georgia, "Iowan Old Style", "Times New Roman", serif;
    font-size: clamp(27px, 5vw, 40px);
    line-height: 1.18;
    letter-spacing: -0.02em;
    margin-bottom: 14px;
    color: var(--ink);
  }

  .article-dek {
    font-size: 16.5px;
    line-height: 1.55;
    color: #B4B9D2;
    margin-bottom: 24px;
  }

  .hero-visual {
    width: 100%;
    height: 184px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--surface);
    overflow: hidden;
    margin-bottom: 26px;
    position: relative;
  }

  .hero-visual svg {
    width: 100%;
    height: 100%;
    display: block;
  }

  .article-body {
    display: flex;
    flex-direction: column;
    gap: 18px;
    font-size: 16px;
    line-height: 1.72;
    color: #D6D9EB;
  }

  .article-body.large-text {
    font-size: 18.5px;
    line-height: 1.78;
  }

  .article-body p {
    padding: 4px 8px;
    margin: 0 -8px;
    border-radius: 10px;
    transition: background 0.2s ease;
    cursor: pointer;
  }

  .article-body p.highlighted {
    background: rgba(129, 140, 248, 0.16);
    box-shadow: inset 3px 0 0 var(--accent);
  }

  .pull-quote {
    margin: 8px 0;
    padding: 16px 18px;
    border-left: 3px solid var(--accent);
    background: rgba(22, 25, 41, 0.85);
    border-radius: 0 14px 14px 0;
    font-family: Georgia, serif;
    font-style: italic;
    font-size: 17px;
    color: var(--ink);
  }

  /* Quick Actions Swipe-Up Tray */
  .quick-tray {
    position: fixed;
    left: 50%;
    bottom: 92px;
    transform: translate(-50%, 16px) scale(0.94);
    width: min(calc(100vw - 24px), 420px);
    background: rgba(22, 25, 41, 0.94);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 22px;
    padding: 12px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    opacity: 0;
    pointer-events: none;
    transition: transform 0.34s var(--spring), opacity 0.22s ease;
    z-index: 48;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.55);
  }

  .quick-tray.open {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, 0) scale(1);
  }

  .quick-btn {
    min-height: 58px;
    border: 1px solid transparent;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--ink);
    font-size: 11.5px;
    font-weight: 600;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.15s;
  }

  .quick-btn:hover {
    background: rgba(129, 140, 248, 0.16);
    border-color: var(--border-strong);
  }

  .quick-btn:active {
    transform: scale(0.95);
  }

  /* Floating Thumb Dock & Morphing Action Pill */
  .dock-anchor {
    position: fixed;
    left: 0;
    right: 0;
    bottom: max(16px, env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 12px;
    z-index: 50;
    pointer-events: none;
  }

  .morph-pill {
    pointer-events: auto;
    width: min(calc(100vw - 24px), 356px);
    background: rgba(22, 25, 41, 0.92);
    backdrop-filter: blur(22px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 30px;
    box-shadow: 0 16px 46px rgba(0, 0, 0, 0.58), 0 0 0 1px rgba(129, 140, 248, 0.12);
    overflow: hidden;
    transition: width 0.38s var(--spring), border-radius 0.34s ease, box-shadow 0.25s ease;
    touch-action: none;
  }

  .morph-pill[data-mode="search"] {
    width: min(calc(100vw - 24px), 520px);
    border-radius: 24px;
    border-color: var(--border-strong);
    box-shadow: 0 18px 54px rgba(0, 0, 0, 0.65), 0 0 24px var(--accent-glow);
  }

  .morph-pill[data-mode="summarize"] {
    width: min(calc(100vw - 24px), 520px);
    border-radius: 24px;
    border-color: var(--border-strong);
  }

  .morph-pill[data-mode="tabs"] {
    width: min(calc(100vw - 24px), 540px);
    border-radius: 24px;
  }

  /* Expanded Morph Panel (above dock controls) */
  .morph-panel {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height 0.36s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.22s ease;
    border-bottom: 1px solid transparent;
  }

  .morph-pill:not([data-mode="browse"]) .morph-panel {
    max-height: 320px;
    opacity: 1;
    border-bottom-color: var(--border);
  }

  .panel-inner {
    padding: 14px 16px;
  }

  /* Search Mode */
  .search-input-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(12, 14, 24, 0.78);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 0 12px;
    height: 46px;
  }

  .search-input-wrap input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--ink);
    font-size: 14.5px;
    outline: none;
    min-width: 0;
  }

  .search-results {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 196px;
    overflow-y: auto;
  }

  .search-row {
    min-height: 44px;
    padding: 8px 10px;
    border-radius: 11px;
    border: none;
    background: rgba(255, 255, 255, 0.03);
    color: var(--ink);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    cursor: pointer;
    text-align: left;
    font: inherit;
    font-size: 13.5px;
  }

  .search-row:hover {
    background: rgba(129, 140, 248, 0.16);
  }

  .search-row small {
    color: var(--muted);
    font-size: 11.5px;
  }

  /* Summarize Mode */
  .summary-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
  }

  .summary-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 700;
    color: var(--accent-bright);
  }

  .summary-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
  }

  .summary-list li {
    font-size: 13.5px;
    line-height: 1.48;
    color: #DCE0F5;
    padding-left: 14px;
    position: relative;
  }

  .summary-list li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 8px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
  }

  .summary-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }

  .pill-cta {
    min-height: 38px;
    padding: 0 14px;
    border-radius: 10px;
    border: none;
    background: var(--accent);
    color: #0C0E18;
    font-size: 12.5px;
    font-weight: 700;
    cursor: pointer;
  }

  /* Tabs Mode */
  .tabs-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    max-height: 220px;
    overflow-y: auto;
  }

  .tab-card {
    padding: 10px 12px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.03);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: relative;
    transition: border-color 0.15s, background 0.15s;
  }

  .tab-card.active {
    border-color: var(--accent);
    background: rgba(129, 140, 248, 0.14);
  }

  .tab-domain {
    font-size: 11px;
    color: var(--accent-bright);
    font-weight: 600;
  }

  .tab-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  /* Base Thumb Bar */
  .dock-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px;
    gap: 4px;
    position: relative;
  }

  .swipe-hint {
    position: absolute;
    top: 3px;
    left: 50%;
    transform: translateX(-50%);
    width: 28px;
    height: 3px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.18);
    pointer-events: none;
  }

  .dock-btn {
    min-width: 44px;
    min-height: 46px;
    padding: 0 10px;
    border-radius: 22px;
    border: none;
    background: transparent;
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease, transform 0.15s ease;
  }

  .dock-btn:hover {
    color: var(--ink);
    background: rgba(255, 255, 255, 0.06);
  }

  .dock-btn.active {
    color: var(--ink);
    background: rgba(129, 140, 248, 0.22);
    box-shadow: inset 0 0 0 1px rgba(129, 140, 248, 0.4);
  }

  .dock-btn:active {
    transform: scale(0.94);
  }

  .domain-pill {
    flex: 1;
    min-width: 0;
    min-height: 44px;
    border: none;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--ink);
    padding: 0 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    overflow: hidden;
  }

  .domain-pill span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .tab-count {
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 6px;
    border: 1.5px solid currentColor;
    font-size: 11px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .toast {
    position: fixed;
    top: 58px;
    left: 50%;
    transform: translate(-50%, -18px);
    background: var(--surface-elev);
    border: 1px solid var(--border-strong);
    color: var(--ink);
    padding: 9px 16px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 600;
    opacity: 0;
    pointer-events: none;
    transition: transform 0.24s var(--spring), opacity 0.2s ease;
    z-index: 60;
  }

  .toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
  }

  @media (min-width: 900px) {
    .reader-shell {
      padding-top: 28px;
    }
    .morph-pill {
      width: 420px;
    }
  }
</style>
</head>
<body>
<div class="progress-track"><div id="progressFill" class="progress-fill"></div></div>

<header class="top-chrome">
  <div class="brand"><span class="brand-orb"></span>Drift Reader</div>
  <div class="top-actions">
    <button id="fontSizeBtn" class="top-chip" type="button" aria-pressed="false">Aa</button>
    <button id="quickTrayToggle" class="top-chip" type="button" aria-expanded="false">Quick Actions</button>
  </div>
</header>

<main class="reader-shell" id="readerShell">
  <div class="article-meta">
    <span class="meta-pill" id="artCategory"></span>
    <span class="meta-muted" id="artReadTime"></span>
    <span class="meta-muted">&middot; Tap any paragraph to highlight</span>
  </div>
  <h1 class="article-title" id="artTitle"></h1>
  <p class="article-dek" id="artDek"></p>
  <div class="hero-visual" id="artHero"></div>
  <article class="article-body" id="artBody"></article>
</main>

<!-- Swipe-Up Quick Actions Tray -->
<div id="quickTray" class="quick-tray" aria-label="Quick actions">
  <button class="quick-btn" data-quick="bookmark" type="button">
    <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M19 21l-7-5-7 5V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z"/></svg>
    Save
  </button>
  <button class="quick-btn" data-quick="copy" type="button">
    <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>
    Copy Link
  </button>
  <button class="quick-btn" data-quick="size" type="button">
    <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M4 20h16M7 16l5-12 5 12M9 12h6"/></svg>
    Text Size
  </button>
  <button class="quick-btn" data-quick="top" type="button">
    <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 19V5m0 0l-6 6m6-6l6 6"/></svg>
    Top
  </button>
</div>

<!-- Floating Thumb Dock -->
<nav class="dock-anchor" aria-label="Floating thumb workspace dock">
  <div id="morphPill" class="morph-pill" data-mode="browse">
    <div id="morphPanel" class="morph-panel" aria-live="polite"></div>

    <div id="dockBar" class="dock-bar">
      <div class="swipe-hint" aria-hidden="true"></div>
      <button class="dock-btn active" data-mode-btn="browse" type="button" aria-label="Browse mode" title="Browse (Esc)">
        <svg width="19" height="19" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.1" stroke-linecap="round"><circle cx="12" cy="12" r="9"/><polygon points="16.24 7.76 14.12 14.12 7.76 16.24 9.88 9.88 16.24 7.76"/></svg>
      </button>

      <button id="domainPill" class="domain-pill" type="button" aria-label="Search or jump to tab">
        <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="#818CF8" stroke-width="2.2"><circle cx="11" cy="11" r="7"/><path d="M21 21l-4.35-4.35"/></svg>
        <span id="domainLabel">spatial.press</span>
      </button>

      <button class="dock-btn" data-mode-btn="summarize" type="button" aria-label="Summarize article" title="Summarize (S)">
        <svg width="19" height="19" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.1" stroke-linecap="round" stroke-linejoin="round"><path d="M12 3l1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9L12 3z"/></svg>
      </button>

      <button class="dock-btn" data-mode-btn="tabs" type="button" aria-label="Switch tabs" title="Tabs (T)">
        <span class="tab-count" id="tabCountBadge">4</span>
      </button>
    </div>
  </div>
</nav>

<div id="toast" class="toast" role="status" aria-live="polite"></div>

<script>
(() => {
  const ARTICLES = [
    {
      id: 'thumb-ergonomics',
      domain: 'spatial.press',
      category: 'Interaction Design',
      readTime: '4 min read',
      title: 'Why Bottom-Anchored Chrome Changed Mobile Reading',
      dek: 'Moving primary navigation into the natural arc of the thumb reduces reach strain and turns browser controls into an extension of reading rhythm.',
      accent: '#818CF8',
      summary: [
        'One-handed thumb reach covers roughly 49% of a modern 6.3-inch display, concentrated in the lower arc.',
        'Morphing pills replace static toolbars by expanding only when intent shifts to search, synthesis, or tab triage.',
        'Spring physics with slight overshoot preserve spatial continuity so users never lose their reading anchor.'
      ],
      quote: '“The best mobile toolbar disappears into muscle memory until the exact second your thumb asks for it.”',
      paragraphs: [
        'For more than a decade, mobile browsers inherited the desktop habit of stacking address bars, tabs, and extension icons along the top bezel. As screens grew taller, every URL edit or tab switch demanded a two-handed grip shift.',
        'Anchoring a single floating pill inside the lower thumb zone flips that geometry. In Browse mode, the dock stays compact and translucent so editorial typography owns the viewport.',
        'When you tap the domain chip or press slash, the pill smoothly widens into a command surface. Instead of navigating away to a blank search screen, results appear directly above your thumb while the article remains anchored behind it.',
        'Pair that morphing container with an upward swipe gesture and secondary tools—text sizing, bookmarking, link copying—become effortless micro-interactions rather than buried overflow menus.'
      ]
    },
    {
      id: 'tokyo-micro-alleys',
      domain: 'urbanform.jp',
      category: 'Architecture',
      readTime: '5 min read',
      title: 'Acoustic Calm Inside Tokyo’s Two-Meter Roji Alleys',
      dek: 'How narrow pedestrian lanes, potted greenery, and porous timber facades dampen arterial street noise by up to 14 decibels.',
      accent: '#38BDF8',
      summary: [
        'Stepping 18 meters off a six-lane avenue into a roji lane drops ambient sound from 74 dB to ~60 dB.',
        'Staggered eaves, cedar louvers, and dense potted foliage scatter high-frequency tire reflections.',
        'Micro-scale street furniture slows walking cadence and encourages neighborly stewardship.'
      ],
      quote: '“Quiet in a dense metropolis is rarely an accident of distance; it is a byproduct of geometry.”',
      paragraphs: [
        'Walk two turns off Meiji-dori in Yanaka and the low rumble of delivery vans dissolves into wind chimes and bicycle bells. The transition takes fewer than twenty paces, yet feels like crossing into another district.',
        'Acoustic surveys show that irregular building setbacks and overhanging balconies act like architectural baffles. Smooth glass towers bounce sound down canyons; textured timber and ceramics absorb and diffuse it.',
        'Residents reinforce the effect organically by lining doorways with camellia pots, bamboo screens, and rain barrels—turning private thresholds into a shared acoustic buffer.'
      ]
    },
    {
      id: 'ocean-soundscapes',
      domain: 'abyssal.lab',
      category: 'Oceanography',
      readTime: '3 min read',
      title: 'Listening to the Deep Scattering Layer at Dusk',
      dek: 'Hydrophone arrays reveal the largest daily migration on Earth as billions of mesopelagic organisms rise toward sunlit waters.',
      accent: '#34D399',
      summary: [
        'Every sunset, lanternfish and siphonophores ascend 400–800 meters to feed under cover of darkness.',
        'Low-frequency hydrophones detect a distinct 12 kHz biological chorus lasting roughly 90 minutes.',
        'This vertical pump sequesters millions of tons of surface carbon into the deep ocean annually.'
      ],
      quote: '“At twilight, the ocean floor appears to lift upward like a living curtain.”',
      paragraphs: [
        'Early sonar operators mistook the deep scattering layer for a phantom seafloor that mysteriously rose each evening and sank at dawn. In reality, they were watching a synchronized vertical commute spanning every ocean basin.',
        'Modern autonomous gliders drift silently through the migration without startling marine life, capturing crisp acoustic signatures of swim bladders adjusting to falling hydrostatic pressure.',
        'Tracking the timing and density of this dusk chorus now gives climate scientists a real-time indicator of pelagic ecosystem health.'
      ]
    },
    {
      id: 'analog-synths',
      domain: 'waveform.fm',
      category: 'Sound Craft',
      readTime: '4 min read',
      title: 'Tactile Detents and the Return of Physical Controls',
      dek: 'Why musicians and studio engineers still reach for stepped rotary encoders and weighted faders in an era of infinite touchscreens.',
      accent: '#F472B6',
      summary: [
        'Physical resistance lets performers adjust filter cutoffs without looking away from the arrangement.',
        'Notched detents provide reliable zero-points for pan, EQ gain, and pitch-bend recovery.',
        'Hybrid interfaces pair crisp OLED readouts directly beside dedicated mechanical controls.'
      ],
      quote: '“Friction is not the enemy of speed—it is the vocabulary of precision.”',
      paragraphs: [
        'A glass display can morph into any instrument imaginable, yet every parameter feels identical beneath the fingertips. Without tactile landmarks, subtle live adjustments demand constant visual verification.',
        'Instrument designers are responding with hybrid surfaces: compact digital screens paired with magnetic detents and weighted knobs that dynamically change resistance depending on the active parameter.'
      ]
    }
  ];

  const morphPill = document.getElementById('morphPill');
  const morphPanel = document.getElementById('morphPanel');
  const dockBar = document.getElementById('dockBar');
  const domainLabel = document.getElementById('domainLabel');
  const tabCountBadge = document.getElementById('tabCountBadge');
  const quickTray = document.getElementById('quickTray');
  const toast = document.getElementById('toast');
  const progressFill = document.getElementById('progressFill');

  let activeIdx = 0;
  let mode = 'browse';
  let largeText = false;
  let savedIds = new Set();
  let toastTimer = null;

  function showToast(msg) {
    toast.textContent = msg;
    toast.classList.add('show');
    clearTimeout(toastTimer);
    toastTimer = setTimeout(() => toast.classList.remove('show'), 2100);
  }

  function renderHeroSvg(art) {
    return `
      <svg viewBox="0 0 680 184" preserveAspectRatio="xMidYMid slice" aria-hidden="true">
        <defs>
          <linearGradient id="g-${art.id}" x1="0" y1="0" x2="1" y2="1">
            <stop offset="0%" stop-color="${art.accent}" stop-opacity="0.32"/>
            <stop offset="100%" stop-color="#0C0E18" stop-opacity="0.9"/>
          </linearGradient>
        </defs>
        <rect width="680" height="184" fill="url(#g-${art.id})"/>
        <circle cx="560" cy="40" r="110" fill="${art.accent}" opacity="0.16"/>
        <circle cx="130" cy="160" r="90" fill="${art.accent}" opacity="0.12"/>
        <path d="M0 132 Q160 72 340 118 T680 86" fill="none" stroke="${art.accent}" stroke-width="2.5" opacity="0.75"/>
        <path d="M0 152 Q190 96 370 138 T680 112" fill="none" stroke="#F4F5FA" stroke-width="1.2" opacity="0.25"/>
      </svg>
    `;
  }

  function renderArticle() {
    const art = ARTICLES[activeIdx];
    document.getElementById('artCategory').textContent = art.category;
    document.getElementById('artReadTime').textContent = art.readTime;
    document.getElementById('artTitle').textContent = art.title;
    document.getElementById('artDek').textContent = art.dek;
    document.getElementById('artHero').innerHTML = renderHeroSvg(art);
    domainLabel.textContent = art.domain;
    tabCountBadge.textContent = String(ARTICLES.length);

    const bodyEl = document.getElementById('artBody');
    bodyEl.classList.toggle('large-text', largeText);
    bodyEl.innerHTML =
      `<p>${art.paragraphs[0]}</p>` +
      `<blockquote class="pull-quote">${art.quote}</blockquote>` +
      art.paragraphs.slice(1).map(p => `<p>${p}</p>`).join('');

    window.scrollTo({ top: 0, behavior: 'smooth' });
  }

  function setMode(nextMode) {
    mode = nextMode === mode && nextMode !== 'browse' ? 'browse' : nextMode;
    morphPill.dataset.mode = mode;
    if (mode !== 'browse') quickTray.classList.remove('open');

    document.querySelectorAll('[data-mode-btn]').forEach(btn => {
      btn.classList.toggle('active', btn.dataset.modeBtn === mode);
    });
    renderPanel();
  }

  function renderPanel() {
    const art = ARTICLES[activeIdx];
    if (mode === 'browse') {
      morphPanel.innerHTML = '';
      return;
    }

    if (mode === 'search') {
      morphPanel.innerHTML = `
        <div class="panel-inner">
          <div class="search-input-wrap">
            <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#818CF8" stroke-width="2.2"><circle cx="11" cy="11" r="7"/><path d="M21 21l-4.35-4.35"/></svg>
            <input id="dockSearchInput" type="search" placeholder="Search open tabs or commands..." autocomplete="off">
          </div>
          <div id="searchResults" class="search-results"></div>
        </div>
      `;
      const input = document.getElementById('dockSearchInput');
      const renderResults = (q = '') => {
        const term = q.trim().toLowerCase();
        const matches = ARTICLES.map((a, idx) => ({ a, idx })).filter(({ a }) =>
          !term || a.title.toLowerCase().includes(term) || a.domain.includes(term) || a.category.toLowerCase().includes(term)
        );
        const list = document.getElementById('searchResults');
        list.innerHTML = matches.map(({ a, idx }) => `
          <button class="search-row" data-jump-tab="${idx}" type="button">
            <span>${a.title}</span>
            <small>${a.domain}</small>
          </button>
        `).join('') || `<div style="padding:10px;color:#8A90AD;font-size:13px;">No matching tabs</div>`;
      };
      renderResults();
      input.addEventListener('input', (e) => renderResults(e.target.value));
      setTimeout(() => input.focus(), 60);
      return;
    }

    if (mode === 'summarize') {
      morphPanel.innerHTML = `
        <div class="panel-inner">
          <div class="summary-header">
            <span class="summary-badge">✦ Instant Brief · ${art.readTime} -> 20s</span>
            <button class="top-chip" data-close-panel type="button">Done</button>
          </div>
          <ul class="summary-list">
            ${art.summary.map(s => `<li>${s}</li>`).join('')}
          </ul>
          <div class="summary-footer">
            <span style="font-size:12px;color:#8A90AD;">3 key takeaways extracted</span>
            <button class="pill-cta" data-pin-brief type="button">Pin to Notes</button>
          </div>
        </div>
      `;
      return;
    }

    if (mode === 'tabs') {
      morphPanel.innerHTML = `
        <div class="panel-inner">
          <div class="summary-header">
            <span class="summary-badge">Open Tabs (${ARTICLES.length})</span>
            <button class="top-chip" data-close-panel type="button">Close</button>
          </div>
          <div class="tabs-grid">
            ${ARTICLES.map((a, idx) => `
              <div class="tab-card ${idx === activeIdx ? 'active' : ''}" data-jump-tab="${idx}" role="button" tabindex="0">
                <span class="tab-domain">${a.domain}</span>
                <span class="tab-name">${a.title}</span>
              </div>
            `).join('')}
          </div>
        </div>
      `;
    }
  }

  // Dock button clicks
  document.querySelectorAll('[data-mode-btn]').forEach(btn => {
    btn.addEventListener('click', () => setMode(btn.dataset.modeBtn));
  });

  document.getElementById('domainPill').addEventListener('click', () => setMode('search'));

  morphPanel.addEventListener('click', (e) => {
    const jump = e.target.closest('[data-jump-tab]');
    if (jump) {
      activeIdx = Number(jump.dataset.jumpTab);
      renderArticle();
      setMode('browse');
      showToast(`Switched to ${ARTICLES[activeIdx].domain}`);
      return;
    }
    if (e.target.closest('[data-close-panel]')) {
      setMode('browse');
    }
    if (e.target.closest('[data-pin-brief]')) {
      showToast('Brief pinned to reading notes');
      setMode('browse');
    }
  });

  // Paragraph tap-to-highlight
  document.getElementById('artBody').addEventListener('click', (e) => {
    const p = e.target.closest('p');
    if (!p) return;
    const active = p.classList.toggle('highlighted');
    showToast(active ? 'Passage highlighted' : 'Highlight removed');
  });

  // Swipe-up on dock bar to open quick actions tray
  let swipeStartY = null;
  dockBar.addEventListener('pointerdown', (e) => {
    swipeStartY = e.clientY;
  });
  dockBar.addEventListener('pointerup', (e) => {
    if (swipeStartY === null) return;
    const dy = swipeStartY - e.clientY;
    swipeStartY = null;
    if (dy > 28) {
      setMode('browse');
      quickTray.classList.add('open');
      document.getElementById('quickTrayToggle').setAttribute('aria-expanded', 'true');
    } else if (dy < -24) {
      quickTray.classList.remove('open');
      document.getElementById('quickTrayToggle').setAttribute('aria-expanded', 'false');
    }
  });

  document.getElementById('quickTrayToggle').addEventListener('click', () => {
    const open = quickTray.classList.toggle('open');
    document.getElementById('quickTrayToggle').setAttribute('aria-expanded', String(open));
    if (open) setMode('browse');
  });

  document.getElementById('fontSizeBtn').addEventListener('click', (e) => {
    largeText = !largeText;
    e.currentTarget.classList.toggle('active', largeText);
    e.currentTarget.setAttribute('aria-pressed', String(largeText));
    document.getElementById('artBody').classList.toggle('large-text', largeText);
    showToast(largeText ? 'Large reading type enabled' : 'Standard reading type');
  });

  quickTray.addEventListener('click', (e) => {
    const btn = e.target.closest('[data-quick]');
    if (!btn) return;
    const action = btn.dataset.quick;
    const art = ARTICLES[activeIdx];
    if (action === 'bookmark') {
      if (savedIds.has(art.id)) {
        savedIds.delete(art.id);
        showToast('Removed from Saved');
      } else {
        savedIds.add(art.id);
        showToast(`Saved "${art.domain}"`);
      }
    } else if (action === 'copy') {
      showToast(`Copied https://${art.domain}/${art.id}`);
    } else if (action === 'size') {
      document.getElementById('fontSizeBtn').click();
    } else if (action === 'top') {
      window.scrollTo({ top: 0, behavior: 'smooth' });
      showToast('Back to top');
    }
    quickTray.classList.remove('open');
  });

  // Keyboard shortcuts
  window.addEventListener('keydown', (e) => {
    if (e.target.tagName === 'INPUT') {
      if (e.key === 'Escape') setMode('browse');
      return;
    }
    if (e.key === '/' || ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === 'k')) {
      e.preventDefault();
      setMode('search');
    } else if (e.key.toLowerCase() === 's') {
      setMode('summarize');
    } else if (e.key.toLowerCase() === 't') {
      setMode('tabs');
    } else if (e.key === 'Escape') {
      setMode('browse');
      quickTray.classList.remove('open');
    }
  });

  // Reading progress
  window.addEventListener('scroll', () => {
    const max = Math.max(1, document.documentElement.scrollHeight - window.innerHeight);
    const pct = Math.min(100, Math.max(8, (window.scrollY / max) * 100));
    progressFill.style.width = pct.toFixed(1) + '%';
  }, { passive: true });

  renderArticle();
})();
</script>
</body>
</html>