/* Materials concept H: E's calm system plus three loud moments made of the real materials
   (the walk: a collage along the route; peel and fly; the category openers). Palette from the home page.

   SPACING SCALE (the only spacing values used for margin, padding and gap):
     --s1  8px   inside components (cell padding, gaps between cells, icon to label)
     --s2 16px   related items (heading to its content, button to button)
     --s3 24px   inside a card (card padding, tray groups)
     --s4 48px   between sheets, between blocks in a column, page gutter at desktop
     --s5 96px   between major sections (intro, workspace, terms, footer), column gap of the workspace

   TYPE (three levels, plus one kicker style):
     display  Cormorant Garamond 500, ink. 64 (h1) / 40 (terms h2) / 28 (tray name, dialog name) / 24 (sheet name)
     body     DM Sans 17px (16 on phone), text colour; buttons and tabs use body at 16px 600 ink
     caption  DM Sans 14px, --muted. Every meta line, count, terms line and note.
     kicker   DM Sans 13px 600, uppercase, .12em, --hand. Intro, terms block, section names in the catalogue.

   COMPONENTS: text tab (orange underline), primary button (ink), secondary button (quiet outline), card (one surface),
   cell (every material, one box per category). */
@font-face { font-family: "DM Sans"; src: url("../assets/fonts/DMSans.ttf") format("truetype"); font-weight: 100 1000; font-display: swap; }
@font-face { font-family: "Cormorant Garamond"; src: url("../assets/fonts/CormorantGaramond.ttf") format("truetype"); font-weight: 300 700; font-display: swap; }
@font-face { font-family: "Caveat"; src: url("../assets/fonts/Caveat.ttf") format("truetype"); font-weight: 400 700; font-display: swap; }

:root {
  --field: #eef0f3;
  --hi: #fbfcfd;
  --lo: #dce0e5;
  --paper: #f4efe6;
  --tp-paper: #f0eadf;   /* the template pages' own paper (sampled), shown while a page loads */
  --text: #424a58;
  --hand: #914430;
  --ink: #172031;
  --muted: #4c5666;
  --route: #d2582f;
  --line: color-mix(in oklab, var(--ink) 12%, transparent);
  --line-2: color-mix(in oklab, var(--ink) 26%, transparent);
  --wash: color-mix(in oklab, var(--ink) 6%, transparent);
  --page-ink: #1f3354;

  --s1: 8px; --s2: 16px; --s3: 24px; --s4: 48px; --s5: 96px;
  --gutter: var(--s4);
  --display: "Cormorant Garamond", Georgia, serif;
  --sans: "DM Sans", system-ui, sans-serif;
  --body: 17px;
  --cap: 14px;
  --radius: 8px;
  --card-shadow: 0 0 0 1px var(--line), 0 1px 2px color-mix(in oklab, var(--ink) 8%, transparent);
  --paper-shadow: 0 22px 40px -22px color-mix(in oklab, var(--ink) 55%, transparent), 0 2px 6px -2px color-mix(in oklab, var(--ink) 16%, transparent);
  /* Die-cut edge on stickers, kept subtle: a 1.5 px white edge and a soft lift. Display only; the files are transparent. */
  --cut: drop-shadow(1.5px 0 0 #fff) drop-shadow(-1.5px 0 0 #fff) drop-shadow(0 1.5px 0 #fff) drop-shadow(0 -1.5px 0 #fff) drop-shadow(0 1px 1.5px rgba(23, 32, 49, .16));
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scrollbar-gutter: stable; }
body { margin: 0; background: var(--field); color: var(--text); overflow-x: clip;
  font: 400 var(--body)/1.55 var(--sans); -webkit-font-smoothing: antialiased; }
img, svg { display: block; max-width: 100%; }
h1, h2, h3, h4, p, figure, ul { margin: 0; }
ul { padding: 0; list-style: none; }
p { text-wrap: pretty; }
a { color: inherit; text-underline-offset: .2em; text-decoration-thickness: 1px; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--route); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.vh { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.wrap { width: min(100% - 2 * var(--gutter), 1344px); margin-inline: auto; }
.skip { position: absolute; left: var(--gutter); top: -60px; z-index: 60; background: var(--ink); color: var(--field); padding: var(--s1) var(--s2); border-radius: 4px; text-decoration: none; font-weight: 600; }
.skip:focus { top: var(--s1); }
.pt-touch { display: none; }

/* ---------------------------------------------------------------- type */
.kicker { font: 600 13px/1.4 var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--hand); }
.caption { font: 400 var(--cap)/1.5 var(--sans); color: var(--muted); }
h1 { font: 500 64px/1.04 var(--display); color: var(--ink); letter-spacing: -.01em; }

/* ---------------------------------------------------------------- header (as on the home page) */
.top { display: flex; align-items: center; gap: 0 var(--s3); padding-block: var(--s1); }
.wordmark { font: 700 32px/1 "Caveat", cursive; color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; min-height: 44px; flex: none; }
.nav { display: flex; margin-left: auto; min-width: 0; }
.nav a { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; padding: 0 var(--s2); font-weight: 600; font-size: 16px; color: var(--ink); text-decoration: none; white-space: nowrap; }
.nav a[aria-current="page"] { box-shadow: inset 0 -2px 0 var(--route); }
@media (hover: hover) and (pointer: fine) { .nav a:not([aria-current]):hover { box-shadow: inset 0 -2px 0 var(--line-2); } }

/* ---------------------------------------------------------------- moment 1: the walk
   A 1440 × 800 design canvas that scales with the width (--u = one design px), never with the window height. */
.hero { position: relative; --u: clamp(.667px, calc(100vw / 1440), 1.2px); height: calc(800 * var(--u)); overflow: clip; }
.spill { position: absolute; inset: 0; pointer-events: none; }   /* the two layers overlap on desktop: only the pieces take clicks */
.hero-centre { position: absolute; left: 50%; top: 50%; translate: -50% -50%; width: calc(600 * var(--u)); text-align: center; z-index: 1; }
.hero h1 { font-size: calc(84 * var(--u)); line-height: 1; text-wrap: balance; }
.lede { margin: var(--s3) auto 0; max-width: 34em; font-size: max(16px, calc(18 * var(--u))); color: var(--text); text-wrap: balance; }
.facts { margin-top: var(--s2); }
.hero + .lib { margin-top: var(--s4); }

/* The route under the pieces: the home page's grammar (right-angle blocks with round corners, start ring, ink end dot, a dotted
   GPS gap), drawn faint so it reads as a thread, not a graphic. Built in the hero's own pixels by main.js. */
.route { position: absolute; left: 0; top: 0; width: 100%; height: 100%; z-index: 0; overflow: visible; pointer-events: none; }
.route .seg { fill: none; stroke: color-mix(in oklab, var(--route) 62%, transparent); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.route .gap { fill: none; stroke: var(--route); stroke-width: 2.5; stroke-linecap: round; stroke-dasharray: .1 9; }
.route .start { fill: var(--field); stroke: var(--ink); stroke-width: 2.5; }
.route .end { fill: var(--ink); }
.route .note { font-family: "Caveat", cursive; font-weight: 600; font-size: max(15px, calc(20 * var(--u))); fill: var(--hand); }   /* scales with the canvas, so it never reaches the headline */
.spill-a, .spill-b { z-index: 1; }

/* A piece of the collage: the real material, at rest on its turn. Hover only lifts it a touch; a click places it. */
.piece { position: absolute; pointer-events: auto; width: calc(var(--w) * var(--u)); padding: 0; border: 0; background: none; cursor: pointer;
  translate: -50% -50%; rotate: var(--r); -webkit-tap-highlight-color: transparent; transition: scale .18s cubic-bezier(.2,.75,.25,1); }
.piece img { position: relative; width: 100%; height: auto; pointer-events: none; }
.piece.p-sq img, .piece.p-wide img { filter: var(--cut) drop-shadow(0 6px 8px rgba(23, 32, 49, .14)); }
.piece.p-tape img { filter: drop-shadow(0 2px 3px rgba(23, 32, 49, .16)); }
.piece.p-frame img, .piece.p-card img { filter: drop-shadow(0 6px 10px rgba(23, 32, 49, .2)); }
.piece .p-photo { position: absolute; background: #ccc url("../assets/sample/sample_photo_square.jpg") center / cover no-repeat; }
.piece.p-corner img { height: calc(var(--h) * var(--u)); object-fit: cover; box-shadow: 0 10px 24px -10px rgba(23, 32, 49, .45); }
.piece.p-tpl .tp-pg { width: 100%; box-shadow: 0 12px 24px -12px rgba(23, 32, 49, .5); }
.piece:focus-visible { outline-offset: 4px; }
/* Thin pieces (tape strips, word art) get a 44 px tall hit area; the art doesn't change. */
.piece::after { content: ""; position: absolute; left: 50%; top: 50%; width: max(100%, 44px); height: max(100%, 44px); translate: -50% -50%; }
@media (hover: hover) and (pointer: fine) { .piece:hover { scale: 1.05; } }
.hero.pre .piece, .hero.pre .route { opacity: 0; }

/* ---------------------------------------------------------------- workspace: sample page (sticky) | catalogue */
.lib { display: grid; grid-template-columns: 368px minmax(0, 1fr); column-gap: var(--s5); align-items: start; }
.stage-col { align-self: stretch; }   /* the column runs the full height so the stage can stick */
.stage { position: sticky; top: var(--s3); }
/* The whole column (page, tray, "More") fits the viewport: page height = 1.25 × width. */
.stage { width: clamp(300px, calc((100svh - 480px) * .8), 368px); }   /* page, tray and More share one width: no ragged edge */
/* Short windows: drop "More" so the page can stay large and the column still fits the viewport. */
@media (min-width: 960px) and (max-height: 859px) {
  .stage { width: clamp(300px, calc((100svh - 330px) * .8), 368px); }
  .more { display: none !important; }
}

.tray { margin-top: var(--s3); }
/* Names can run to two lines; the box always keeps room for two, so choosing a piece never moves the buttons below it. */
.tray-name { font: 500 28px/1.15 var(--display); color: var(--ink); text-wrap: balance; min-height: 2.3em; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.tray-meta { margin-top: var(--s1); }
.tray-act { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1) var(--s2); margin-top: var(--s3); }
#tray-app { order: 2; flex-basis: 100%; min-height: 0; }   /* template: page arrows first, the app note on its own line */
.tray .terms-short, .tray .tp-note { margin-top: var(--s3); }
.tp-nav { display: inline-flex; align-items: center; gap: var(--s1); }
.tp-pos { min-width: 3.2em; text-align: center; font-variant-numeric: tabular-nums; }

.terms-short, .terms-short ul { display: grid; gap: var(--s1); justify-items: start; }
.terms-short li { position: relative; padding-left: var(--s3); }
.terms-short li::before, .ticks li::before, .crosses li::before { position: absolute; left: 0; top: 0; font-weight: 700; }
.terms-short .ok::before, .ticks li::before { content: "✓"; color: var(--ink); }
.terms-short .no::before, .crosses li::before { content: "×"; color: var(--route); }
.terms-short a { color: var(--ink); font-weight: 600; white-space: nowrap; }
.terms-short > a { margin-left: 0; }   /* flush with the ticks, the buttons and the name: the column's one left edge */

.more { margin-top: var(--s4); }
.more-row { margin-top: var(--s2); display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s1); }
.more-row[data-kind="tape"], .more-row[data-kind="wide"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.more-row[data-kind="tape"] .cell.small .cell-box { aspect-ratio: 3.2; }
.more-row[data-kind="wide"] .cell.small .cell-box { aspect-ratio: 2; }

/* ---------------------------------------------------------------- buttons: one primary, one secondary */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s1); min-height: 48px; padding: 0 var(--s3); border-radius: var(--radius);
  font: 600 16px/1 var(--sans); text-decoration: none; border: 1px solid transparent; cursor: pointer; white-space: nowrap; }
.btn-primary { background: var(--ink); color: var(--hi); }
.btn-primary::before { content: ""; width: 18px; height: 18px; flex: none; background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 4v11M7 10l5 5 5-5M5 20h14'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 4v11M7 10l5 5 5-5M5 20h14'/%3E%3C/svg%3E") center / contain no-repeat; }
.btn-secondary { background: transparent; color: var(--ink); border-color: var(--line-2); }
.btn-sq { width: 48px; padding: 0; font-size: 18px; }
.btn-wide { width: 100%; }
@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover { background: color-mix(in oklab, var(--ink) 86%, var(--field)); }
  .btn-secondary:hover { background: var(--wash); }
}
/* "Available in the app": plain text where the button would be, not a control */
.in-app { display: inline-flex; align-items: center; min-height: 48px; font-weight: 600; font-size: 16px; color: var(--ink); white-space: nowrap; }

/* ---------------------------------------------------------------- the sample page (4:5, scales with its width) */
.page { position: relative; width: 100%; aspect-ratio: 4 / 5; container-type: inline-size; overflow: hidden; background: var(--paper);
  box-shadow: var(--paper-shadow); border-radius: 3px; isolation: isolate; }
.pg-ground, .pg-ground img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.pg-title { position: absolute; left: 7%; top: 5.2%; font: 500 9cqw/1 var(--display); color: var(--page-ink); z-index: 3; white-space: nowrap; }
.pg-meta { position: absolute; left: 7.3%; top: 14%; font: 500 3.1cqw/1 var(--sans); color: #5c5650; z-index: 3; white-space: nowrap; }
.pg-photo { position: absolute; z-index: 2; background-color: #ccc; background-repeat: no-repeat; background-position: center; background-size: cover;
  box-shadow: 0 1.4cqw 2.4cqw -1.4cqw rgba(23, 32, 49, .45); }
.pg-photo.a { left: 8%; top: 22%; width: 44cqw; height: 44cqw; transform: rotate(-2deg); background-image: url("../assets/sample/sample_photo_square.jpg"); }
.pg-photo.b { left: 58%; top: 25.5%; width: 34cqw; height: 25.5cqw; transform: rotate(2.6deg); background-image: url("../assets/sample/sample_photo_wide.jpg"); }
.pg-photo.framed { box-shadow: none; }
.pg-cap { position: absolute; z-index: 3; font: 500 4.5cqw/1.15 "Caveat", cursive; color: #2a2a2a; white-space: nowrap; }
.pg-cap.a { left: 8.5%; top: 63.5%; }
.pg-cap.b { left: 58%; top: 49%; }
.pg-time { display: block; font: 500 2.6cqw/1.2 var(--sans); color: #6a645d; margin-bottom: .6cqw; }
.pg-hand { position: absolute; left: 8.5%; top: 75.5%; width: 40%; font: 500 5cqw/1.15 "Caveat", cursive; color: var(--page-ink); z-index: 3; }
/* Printed on the page itself (part of the artwork, sized with the page): marks it as a sample. */
.pg-sample { position: absolute; left: 7%; bottom: 3.2%; font: 600 2.1cqw/1 var(--sans); letter-spacing: .12em; text-transform: uppercase; color: #8a8178; z-index: 3; }
.pg-item { position: absolute; z-index: 4; pointer-events: none; }
.pg-item img { width: 100%; height: 100%; object-fit: contain; }
.pg-item.free { filter: drop-shadow(0 .5cqw .7cqw rgba(23, 32, 49, .22)); }
.pg-item.free.cut img { filter: drop-shadow(.45cqw 0 0 #fff) drop-shadow(-.45cqw 0 0 #fff) drop-shadow(0 .45cqw 0 #fff) drop-shadow(0 -.45cqw 0 #fff); }
.pg-item.tape { z-index: 5; filter: drop-shadow(0 .3cqw .4cqw rgba(23, 32, 49, .18)); }
.pg-item.frame { z-index: 1; filter: drop-shadow(0 1cqw 1.4cqw rgba(23, 32, 49, .3)); }
.pg-item.under { z-index: 2; }
/* Template: its 9:16 sample page stands on the stage, over the 4:5 page */
.pg-tp { position: absolute; inset: 0; z-index: 8; display: none; background: color-mix(in oklab, var(--lo) 70%, var(--field)); }
.has-tp .pg-tp { display: block; }
.pg-tp .tp-pg { position: absolute; top: 3%; left: 50%; translate: -50% 0; height: 94%; width: auto; aspect-ratio: 9 / 16; box-shadow: 0 1cqw 3cqw -1cqw rgba(23, 32, 49, .5); }

/* A template page */
.tp-pg { position: relative; display: block; aspect-ratio: 9 / 16; background: var(--tp-paper); overflow: hidden; }
.tp-pg img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

/* ---------------------------------------------------------------- tabs: text, orange underline for the current one */
.tabs-bar { position: sticky; top: 0; z-index: 10; background: var(--field);
  /* the second shadow paints the field to the window's right edge, so bleeding strips don't show beside the stuck bar */
  box-shadow: inset 0 -1px 0 var(--line-2), calc((100vw - min(100vw - 2 * var(--gutter), 1344px)) / 2) 0 0 var(--field); }
.tabs { display: flex; flex-wrap: nowrap; gap: var(--tab-gap, var(--s3)); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: 0 0 auto; display: inline-flex; align-items: baseline; gap: var(--s1); min-height: 48px; padding: var(--s2) 0 0; border: 0; background: none;
  font: 600 16px/1 var(--sans); color: var(--ink); cursor: pointer; white-space: nowrap; }
.tab .n { font-size: var(--cap); font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }
.tab { text-decoration: none; }
.tab[aria-current="true"] { box-shadow: inset 0 -2px 0 var(--route); }
@media (hover: hover) and (pointer: fine) { .tab:not([aria-current="true"]):hover { box-shadow: inset 0 -2px 0 var(--line-2); } }
.tab:focus-visible { outline-offset: -3px; }
/* Back to top: right end of the tab row, same type and baseline as a tab. Hidden (and out of the tab order) until the bar
   is stuck. The tabs always keep 88 px free on the right for it, so showing it never moves them. */
.tabs { padding-right: 88px; }
.to-top { position: absolute; right: 0; bottom: 1px; min-height: 47px; display: inline-flex; align-items: baseline; gap: 6px; min-width: 64px;
  justify-content: flex-end; padding: var(--s2) 0 0 36px; border: 0; cursor: pointer; font: 600 16px/1 var(--sans); color: var(--ink);
  background: linear-gradient(to right, transparent, var(--field) 30px);
  opacity: 0; transform: translateY(4px); visibility: hidden; transition: opacity .24s ease, transform .24s ease, visibility 0s linear .24s; }
.tabs-bar.stuck .to-top { opacity: 1; transform: none; visibility: visible; transition: opacity .24s ease, transform .24s ease, visibility 0s; }
@media (hover: hover) and (pointer: fine) { .to-top:hover { box-shadow: inset 0 -2px 0 var(--line-2); } }
.to-top:focus-visible { outline-offset: -3px; }
@media (prefers-reduced-motion: reduce) { .to-top, .tabs-bar.stuck .to-top { transition: none; } }

/* ---------------------------------------------------------------- catalogue */
.cat { min-height: 560px; --bleed: calc((100vw - min(100vw - 2 * var(--gutter), 1344px)) / 2); }
.cat:focus { outline: none; }
.cat-block { padding-top: var(--s4); }
.cat-block:first-child { padding-top: var(--s3); }
.rack { display: grid; gap: var(--s3); margin-top: var(--s3); }
.sec { display: flex; flex-wrap: wrap; gap: var(--s3); }
.sec > * { flex: 1 1 100%; min-width: 0; }
@media (min-width: 960px) {
  .sec > .sheet.fit { flex: 0 1 auto; max-width: 100%; }
  .sheet.fit .grid { grid-template-columns: repeat(var(--n), minmax(0, var(--cw))); }
}
.sec > .kicker { margin-bottom: calc(var(--s1) - var(--s3)); }   /* the section name sits 8 px above its first sheet */
.sec + .sec { margin-top: var(--s1); }
.more-sheets { margin-top: var(--s2); display: flex; justify-content: center; gap: var(--s2); flex-wrap: wrap; }
.more-sheets[hidden], .more-sheets button[hidden] { display: none; }

/* ---------------------------------------------------------------- moment 3: the category opener
   A strip: a label column on the left (kicker, name, one line, arrows), the kind's highlights large on the right.
   It starts on the catalogue column's left edge (the sheets' edge) and runs off the window's right edge on purpose:
   the items fade out there. Height follows the content; the label block is centred against the row.
   Grounds are light only, from the product: the app's papers, the soft blue-grey field, the route orange as a tint.
   Grounds follow a rule (main.js TONE: warm materials on cool, cool/white/see-through on warm, mixed on neutral); one palette (PALETTE: stone, grid, paper, mist, slate); every ground keeps ink text and the muted caption at ≥ 5:1. */
.strip { --st-hover: color-mix(in oklab, var(--ink) 6%, transparent);
  display: grid; grid-template-columns: 248px minmax(0, 1fr); column-gap: var(--s3); align-items: center; padding: var(--s3) 0;
  margin-right: calc(-1 * var(--bleed)); border-radius: var(--radius) 0 0 var(--radius); color: var(--ink); background: var(--paper);
  box-shadow: inset 0 0 0 1px var(--line); }
/* Real app papers, washed a little toward the page's paper so they stay a ground */
.strip.g-grid  { background: linear-gradient(rgba(244, 239, 230, .3), rgba(244, 239, 230, .3)), url("preview/paper_citywalk_creamgrid01.jpg") center / cover; }
.strip.g-paper   { background: #f4efe6; }   /* warm 2: the sheets' paper */
.strip.g-mist    { background: #e2e7ee; }   /* cool: the field's blue-grey, one step darker */
.strip.g-slate   { background: #d3dbe6; }   /* cool 2: a clearly deeper blue-grey, for a second cool strip in a row */
.strip.g-stone   { background: #eae9e5; }   /* neutral: neither warm nor cool, for mixed-colour sets */
.strip-head { display: flex; flex-direction: column; align-items: flex-start; padding-left: var(--s3); min-width: 0; }
.strip-n { color: var(--muted); }
.strip-h { margin-top: var(--s1); font: 500 38px/1.05 var(--display); color: var(--ink); letter-spacing: -.005em; }
.strip-h:focus { outline: none; }
.strip-blurb { margin-top: var(--s1); color: var(--muted); font-size: 16px; line-height: 1.45; }
.strip-nav { margin-top: var(--s3); display: flex; gap: var(--s1); }
.btn-sq:disabled { opacity: .35; cursor: default; }
@media (hover: none), (pointer: coarse) { .strip-nav { display: none; } }
.strip.no-scroll .strip-nav { display: none; }
.strip-row { display: flex; align-items: center; gap: var(--s2); overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none;
  scroll-snap-type: x mandatory;
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 120px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 120px), transparent); }
.strip:not(.at-start) .strip-row { -webkit-mask-image: linear-gradient(to right, transparent, #000 40px, #000 calc(100% - 120px), transparent); mask-image: linear-gradient(to right, transparent, #000 40px, #000 calc(100% - 120px), transparent); }
.strip.at-end:not(.at-start) .strip-row { -webkit-mask-image: linear-gradient(to right, transparent, #000 40px); mask-image: linear-gradient(to right, transparent, #000 40px); }
.strip.at-end.at-start .strip-row { -webkit-mask-image: none; mask-image: none; }
.strip-row::-webkit-scrollbar { display: none; }
.strip-row::after { content: ""; flex: 0 0 calc(var(--bleed) - var(--s2)); align-self: stretch; }   /* the last item can scroll back to the column edge */
.strip .cell { flex: 0 0 auto; width: auto; scroll-snap-align: start; }
.strip .cell-box { height: calc(var(--sh) + var(--s2)); width: auto; aspect-ratio: auto; }
.strip .cell-art { height: 100%; width: auto; aspect-ratio: var(--ar); }
.strip .c-sq, .strip .c-frame { --ar: 1; } .strip .c-wide { --ar: 2; } .strip .c-card { --ar: 4 / 3; } .strip .c-tape { --ar: 3.2; } .strip .c-paper { --ar: 4 / 5; } .strip .c-tpl { --ar: 9 / 16; }
.strip .cell-cap { color: var(--st-text); }
.strip .cell.locked:not(.kept) .cell-cap { color: var(--st-cap); }
@media (hover: hover) and (pointer: fine) { .strip .cell:hover .cell-box { background: var(--st-hover); } }
/* lift the flat kinds off their ground */
.strip .c-paper .cell-art img { box-shadow: none; filter: drop-shadow(0 4px 8px rgba(23, 32, 49, .22)); }
.strip .c-card .cell-art img, .strip .c-frame .cell-art img, .strip .c-tape .cell-art img { filter: drop-shadow(0 4px 8px rgba(23, 32, 49, .24)) drop-shadow(0 1px 1px rgba(23, 32, 49, .12)); }
.strip .c-tpl .tp-pg { box-shadow: 0 6px 14px -6px rgba(23, 32, 49, .4); }

/* One surface for every card: sheets, the terms block, the dialog */
.card { background: var(--paper); border-radius: var(--radius); box-shadow: var(--card-shadow); }
.sheet { padding: var(--s2) var(--s3) var(--s1); }
.sheet:focus { outline: none; }
.sheet-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s2); margin-bottom: var(--s1); }
.sheet-head h3 { font: 500 24px/1.2 var(--display); color: var(--ink); }

/* The grid: every material in a category gets the same box (contain), the same padding and the same gap. */
.grid { --cell: 112px; --cw: 112px; --ar: 1; display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--cell), 1fr)); gap: var(--s1); }
.g-frame { --cell: 112px; --ar: 1; }
.g-wide  { --cell: 176px; --cw: 176px; --ar: 2; }
.g-card  { --cell: 128px; --cw: 128px; --ar: 4 / 3; }
.g-tape  { --cell: 192px; --cw: 192px; --ar: 3.2; }
.g-paper { --cell: 112px; --ar: 4 / 5; }
.g-tpl   { --cell: 152px; --ar: 9 / 16; }

/* The cell: one component for every material. Hover only highlights. .kept = it is on the page: faded, "On the page". */
.cell { position: relative; display: flex; flex-direction: column; width: 100%; padding: 0; border: 0; border-radius: var(--radius);
  background: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.cell-box { display: block; width: 100%; aspect-ratio: var(--ar, 1); min-height: 0; overflow: hidden; padding: var(--s1); border-radius: var(--radius); }
.cell-art { display: block; width: 100%; height: 100%; transition: opacity .3s ease; }
.cell-art img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.c-sq .cell-art img, .c-wide .cell-art img { filter: var(--cut); }
.c-paper .cell-art img { object-fit: cover; box-shadow: 0 0 0 1px var(--line); }
.c-frame .cell-art img { filter: drop-shadow(0 1px 2px rgba(23, 32, 49, .18)); }
/* Tapes and cards are paper on paper: a soft lift so they separate from the sheet */
.c-tape .cell-art img, .c-card .cell-art img { filter: drop-shadow(0 2px 3px rgba(23, 32, 49, .2)) drop-shadow(0 0 1px rgba(23, 32, 49, .18)); }
.c-tpl .cell-art { display: flex; justify-content: center; }
.c-tpl .tp-pg { height: 100%; box-shadow: 0 0 0 1px var(--line); }
/* "On the page" sits under the cell, in a 20 px row every cell keeps, so it never covers the art or moves the grid. */
.cell-cap { display: block; height: 20px; text-align: center; font: 600 13px/20px var(--sans); color: var(--ink); visibility: hidden; white-space: nowrap; }
.cell.kept { cursor: zoom-in; }
.cell.kept .cell-art { opacity: .3; }
.cell.kept .cell-cap, .cell.locked .cell-cap { visibility: visible; }
.cell.locked:not(.kept) .cell-cap { color: var(--muted); }
@media (hover: hover) and (pointer: fine) { .cell:hover .cell-box { background: var(--wash); } }
.cell:focus-visible { outline-offset: 0; }
.cell.small .cell-box { aspect-ratio: 1; }
.cell.small.c-tpl .tp-pg { height: 100%; }

/* ---------------------------------------------------------------- the flyer (peel and fly) */
.flyer { position: fixed; left: 0; top: 0; z-index: 50; pointer-events: none; transform-origin: 50% 50%; display: none; }
.flyer.doc { position: absolute; }
.flyer.on { display: block; }
.flyer > img { position: relative; width: 100%; height: 100%; object-fit: contain; }
.flyer.cut > img { filter: var(--cut); }
.flyer.cover > img { object-fit: cover; }
.flyer.tp .tp-pg { width: 100%; height: 100%; }
.flyer-shadow { position: absolute; inset: 8% 6% -6% 8%; border-radius: 12px; background: rgba(23, 32, 49, .4); filter: blur(14px); opacity: 0; }

/* Template card: its pages are in the opener above it; here the facts and one row of the materials it uses */
.tp-facts { max-width: 64ch; }
.tp-mh { margin-top: var(--s3); margin-bottom: var(--s2); }
.tp-more { margin-top: var(--s2); justify-content: flex-start; }

/* ---------------------------------------------------------------- terms */
.terms { margin-top: var(--s5); }
.terms-body { padding: var(--s4); }
.terms-body h2 { font: 500 40px/1.1 var(--display); color: var(--ink); margin-top: var(--s1); }
.terms-body h2:focus { outline: none; }
.terms-cols { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3) var(--s4); margin-top: var(--s3); }
.terms-cols h3 { font: 600 16px/1.4 var(--sans); color: var(--ink); }
.terms-cols ul { margin-top: var(--s1); display: grid; gap: var(--s1); }
.terms-cols li { position: relative; padding-left: var(--s3); }
.terms-small { margin-top: var(--s3); max-width: 80ch; }
.review-note { margin-top: var(--s2); color: var(--hand); }

/* ---------------------------------------------------------------- footer (as on the home page) */
.foot { margin-top: var(--s5); background: var(--hi); box-shadow: inset 0 1px 0 var(--line); padding-block: var(--s3); }
.foot-in { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1) var(--s3); }
.foot .wordmark { font-size: 26px; }
.foot-links { display: flex; flex-wrap: wrap; gap: 0 var(--s3); }
.foot-links a { display: inline-flex; align-items: center; min-height: 44px; font-size: var(--cap); }
.foot-links a { color: var(--ink); }
.copy { margin-left: auto; font-size: var(--cap); color: var(--muted); }

/* ---------------------------------------------------------------- detail: dialog on desktop, bottom sheet on phone. No motion. */
.detail { width: min(960px, 100% - 2 * var(--s4)); max-height: min(860px, 100% - 2 * var(--s4)); padding: 0; border: 0; border-radius: var(--radius);
  background: var(--hi); color: var(--text); box-shadow: 0 40px 80px -30px rgba(23, 32, 49, .55); overscroll-behavior: contain; overflow: auto; }
.detail::backdrop { background: rgba(23, 32, 49, .5); }
.sh-in { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: var(--s4); padding: var(--s4); }
.sh-large-box { position: relative; aspect-ratio: 1; border-radius: var(--radius); background: var(--paper);
  display: grid; place-items: center; padding: var(--s4); overflow: hidden; }
.sh-large-box img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; filter: drop-shadow(0 12px 14px rgba(23,32,49,.18)); }
.sh-large-box.paper { padding: 0; }
.sh-large-box.paper img { width: 100%; height: 100%; object-fit: cover; filter: none; }
.sh-large-box .tp-pg { height: 100%; width: auto; box-shadow: 0 10px 20px -12px rgba(23,32,49,.5); }
.is-tp .sh-large-box { padding: var(--s3); }
.sh-side { display: grid; align-content: start; gap: var(--s3); padding-top: var(--s4); }
.sh-page-wrap .page-shell { width: 160px; }
.sh-info { display: flex; flex-direction: column; align-items: stretch; gap: var(--s2); }
.sh-name { font: 500 28px/1.15 var(--display); color: var(--ink); }
.sh-info .caption + .btn, .sh-info .caption + .in-app { margin-top: var(--s1); }
.sh-edge:empty { display: none; }
.sh-close { position: absolute; top: var(--s2); right: var(--s2); }

/* ---------------------------------------------------------------- phone and narrow tablets */
@media (max-width: 959px) {
  :root { --gutter: var(--s3); --body: 16px; }
  .pt-fine { display: none; }
  .pt-touch { display: inline; }
  .hero { --u: clamp(.8px, calc(100vw / 390), 1.6px); height: auto; }
  .hero + .lib { margin-top: var(--s3); }
  .spill { position: relative; inset: auto; height: calc(196 * var(--u)); }
  .hero-centre { position: static; translate: none; width: auto; padding-inline: var(--gutter); }
  .hero h1 { font-size: 44px; }
  .lede { font-size: 17px; }
  .lib { grid-template-columns: minmax(0, 1fr); }
  .stage { width: auto; position: static; display: grid; grid-template-columns: 44% minmax(0, 1fr); column-gap: var(--s2); align-items: end; }
  .stage { align-items: center; }
  .tray { margin-top: 0; align-self: center; text-align: center; }
  /* Room for three lines always, so tapping a different material never changes the page height */
  .tray-name { font-size: clamp(26px, 6.5vw, 36px); min-height: 3.45em; -webkit-line-clamp: 3; -webkit-box-pack: center; }
  .tray-hint.pt-touch { display: block; margin-top: var(--s1); font-size: 17px; line-height: 1.35; }
  /* Right-edge fade while more tabs wait off-screen (main.js sets .more-right) */
  .tabs.more-right { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 48px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 48px), transparent); }
  .tray-meta, .tray-act, .tray .terms-short, .tray .tp-note, .more { display: none !important; }
  .shop { margin-top: var(--s4); }
  .tabs-bar { margin-inline: calc(-1 * var(--gutter)); }
  .tabs { padding-inline: var(--gutter) 88px; scroll-padding-inline: var(--gutter) 88px; }
  .more-sheets { gap: var(--s1); }
  .to-top { padding-right: var(--gutter); min-width: calc(64px + var(--gutter)); }
  .sheet { padding: var(--s2); }
  .grid { --cell: 88px; }
  .g-wide { --cell: 132px; }
  .g-card { --cell: 120px; }
  .g-tape { --cell: 148px; }
  .g-paper { --cell: 88px; }
  .cat { --bleed: var(--gutter); }
  .strip { margin-inline: calc(-1 * var(--gutter)); border-radius: 0; grid-template-columns: minmax(0, 1fr); row-gap: var(--s2); padding: var(--s3) 0 var(--s1); box-shadow: inset 0 1px 0 var(--line), inset 0 -1px 0 var(--line); }
  .strip-head { padding-inline: var(--gutter); }
  .strip-h { font-size: 34px; }
  .strip-blurb { font-size: 15px; }
  .strip-row { padding-left: var(--gutter); scroll-padding-inline: var(--gutter); min-height: 0;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 48px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 48px), transparent); }
  .strip-row::after { flex-basis: var(--s1); }
  .terms-body { padding: var(--s3); }
  .terms-body h2 { font-size: 36px; }
  .terms-cols { grid-template-columns: 1fr; }

  .detail { width: 100%; max-width: none; max-height: calc(100% - var(--s3)); margin: auto 0 0; border-radius: var(--s2) var(--s2) 0 0; }
  .sh-in { grid-template-columns: minmax(0, 1fr); gap: var(--s2); padding: calc(var(--s4) + var(--s2)) var(--s2) var(--s3); }
  .sh-close { top: var(--s1); right: var(--s1); }
  .sh-side { display: contents; }
  .sh-in { grid-template-columns: minmax(0, 1fr) 38%; grid-template-areas: "large page" "info info"; align-items: end; }
  .sh-large { grid-area: large; }
  .sh-page-wrap { grid-area: page; }
  .sh-page-wrap .page-shell { width: 100%; }
  .sh-info { grid-area: info; gap: var(--s1); }
  .sh-large-box { padding: var(--s3); aspect-ratio: 4 / 5; }
  .sh-info .terms-short { margin-top: var(--s1); }
}
@media (max-width: 520px) {
  :root { --gutter: var(--s2); }
  .hero h1 { font-size: 40px; }
  .copy { margin-left: 0; }
}
@media (max-width: 360px) {
  .tray-name { font-size: 24px; }   /* the longest names (30 characters) still fit three lines in the 145 px column */
}
@media (max-width: 420px) {
  .top { gap: 0 var(--s1); }
  .wordmark { font-size: 27px; }
  .nav a { padding: 0 var(--s1); font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Small inline links get a 44 px tall hit area from a pseudo-element: the text and line height do not move */
a.hit { position: relative; }
a.hit::after { content: ""; position: absolute; left: calc(-1 * var(--s1)); right: calc(-1 * var(--s1)); top: 50%; height: 44px; translate: 0 -50%; }

/* Templates strip: the page sizes the template comes in, drawn as outlines beside the pages */
.tp-sizes { flex: none; margin: 0; display: flex; flex-direction: column; align-items: flex-start; gap: var(--s1); }
.tp-sz-row { display: flex; align-items: flex-end; gap: 12px; }
.tp-sz { display: flex; flex-direction: column; align-items: center; gap: var(--s1); }
.tp-sz-box { display: block; height: calc(var(--tp-sz, 88px)); border: 1.5px solid color-mix(in oklab, var(--ink) 38%, transparent); border-radius: 3px; background: color-mix(in oklab, #fff 55%, transparent); }
.tp-sz:nth-child(1) .tp-sz-box { height: auto; width: calc(var(--tp-sz, 88px) * .8); }
.tp-sz:nth-child(2) .tp-sz-box { height: auto; width: calc(var(--tp-sz, 88px) * .6667); }
.tp-sz:nth-child(3) .tp-sz-box { height: auto; width: calc(var(--tp-sz, 88px) * .5625); }
@media (max-width: 959px) { .tp-sizes { --tp-sz: 72px; } }
/* Papers always show as a sheet with an edge, even when they are on the page (a faded cream square read as an empty box) */
.grid .c-paper .cell-art { box-shadow: 0 0 0 1px color-mix(in oklab, var(--ink) 16%, transparent), 0 2px 4px rgba(23, 32, 49, .12); }
.grid .c-paper .cell-art img { box-shadow: none; }
.cell.kept.c-paper .cell-art { opacity: 1; }
.cell.kept.c-paper .cell-art img { opacity: .75; }

/* Phone header, same on every page: the wordmark on its own row, the four links on the next, aligned to the text edge. */
@media (max-width: 640px) {
  .top { flex-wrap: wrap; gap: 0 12px; padding-block: 6px 0; }
  .nav { order: 3; width: 100%; margin-left: -12px; }
}

/* ---------- Chinese pages (html lang="zh-Hans", the /zh/ copies load this same file). System fonts only, nothing downloaded:
   the brand faces stay first, so Latin letters and digits keep them, and the CJK face that follows draws the Chinese.
   No faux italic, no tracking on label styles (it pulls Chinese apart), no negative tracking on headings (it makes
   Chinese glyphs touch), and a little more line height where Chinese runs as body text or wraps in headings. */
html:lang(zh) :is(body, .kicker, .caption, .btn, .pg-meta, .pg-time, .pg-sample, .tab, .to-top, .cell-cap, .terms-cols h3) { font-family: "DM Sans", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif; }
html:lang(zh) :is(h1, .tray-name, .pg-title, .strip-h, .sheet-head h3, .terms-body h2, .sh-name) { font-family: "Cormorant Garamond", "Songti SC", "Noto Serif SC", serif; }
html:lang(zh) :is(.wordmark, .route .note, .pg-cap, .pg-hand) { font-family: "Caveat", "Kaiti SC", "STKaiti", "KaiTi", cursive; }
html:lang(zh) :is(.kicker, .pg-sample, h1, .strip-h) { letter-spacing: 0; }
html:lang(zh) :is(em, i, cite, dfn, var, address) { font-style: normal; }
html:lang(zh) { --display: "Cormorant Garamond", "Songti SC", "Noto Serif SC", serif; --sans: "DM Sans", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif; }
html:lang(zh) body { line-height: 1.7; }
html:lang(zh) h1 { line-height: 1.15; }
/* Short Chinese footer labels (支持) still get a 44 px wide target. */
html:lang(zh) .foot-links a { min-width: 44px; justify-content: center; }
