scrollcraft.css 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  1. /* ============================================================================
  2. scrollcraft.css: the taste floor
  3. ----------------------------------------------------------------------------
  4. Two layers, and the split matters:
  5. TOKENS what you override per brand. Colour roles, the type ramp, the
  6. spacing scale, elevation, motion. A brand is ~12 values.
  7. DEVICES what the engine drives. Do not restyle these to taste; they are
  8. the mechanism. Style your own markup instead.
  9. Nothing here draws a "component". There are no card, badge, or pill classes,
  10. because a stylesheet that ships those is how every page built on it ends up
  11. with the same shapes. You get a floor and a vocabulary; the composition is
  12. yours.
  13. ========================================================================== */
  14. /* ---------------------------------------------------------------- tokens -- */
  15. :root {
  16. /* --- colour roles. Override these six and the page is rebranded. -------- */
  17. --sc-canvas: #08090b; /* the page ground. Drift interpolates this. */
  18. --sc-surface: #101217; /* anything raised off the ground */
  19. --sc-ink: #f4f2ef; /* primary text */
  20. --sc-ink-soft: #9a9ba1; /* secondary text. Tinted, never flat gray. */
  21. --sc-accent: #d8ff3e; /* ONE accent. It owns a region, not confetti. */
  22. --sc-accent-ink: #08090b; /* text that sits on the accent */
  23. --sc-hairline: color-mix(in oklab, var(--sc-ink) 12%, transparent);
  24. --sc-hairline-strong: color-mix(in oklab, var(--sc-ink) 22%, transparent);
  25. /* --- type. Two families max. Display carries voice, text carries prose. - */
  26. --sc-font-display: "Instrument Sans", "Geist", system-ui, sans-serif;
  27. --sc-font-text: "Geist", system-ui, sans-serif;
  28. --sc-font-mono: "Geist Mono", ui-monospace, monospace;
  29. /* Fluid ramp. Tracking tightens as size grows because a face set at 6rem
  30. with 0 tracking reads loose; this is optical correction, not decoration. */
  31. --sc-t-xs: clamp(0.75rem, 0.72rem + 0.15vw, 0.82rem);
  32. --sc-t-sm: clamp(0.875rem, 0.84rem + 0.18vw, 0.95rem);
  33. --sc-t-base: clamp(1rem, 0.96rem + 0.22vw, 1.125rem);
  34. --sc-t-lg: clamp(1.2rem, 1.1rem + 0.5vw, 1.5rem);
  35. --sc-t-xl: clamp(1.6rem, 1.35rem + 1.2vw, 2.25rem);
  36. --sc-t-2xl: clamp(2.1rem, 1.6rem + 2.4vw, 3.4rem);
  37. --sc-t-3xl: clamp(2.8rem, 1.9rem + 4.2vw, 5rem);
  38. --sc-t-4xl: clamp(3.4rem, 1.9rem + 6.6vw, 7.5rem);
  39. --sc-track-tight: -0.035em;
  40. --sc-track-snug: -0.02em;
  41. --sc-track-normal: -0.005em;
  42. --sc-track-wide: 0.08em;
  43. --sc-leading-none: 0.94;
  44. --sc-leading-tight: 1.06;
  45. --sc-leading-body: 1.62;
  46. --sc-measure: 62ch;
  47. /* --- space. 4px base: the useful middle steps an 8-only scale misses. --- */
  48. --sc-1: 0.25rem; --sc-2: 0.5rem; --sc-3: 0.75rem; --sc-4: 1rem;
  49. --sc-5: 1.5rem; --sc-6: 2rem; --sc-7: 3rem; --sc-8: 4rem;
  50. --sc-9: 6rem; --sc-10: 8rem; --sc-11: 12rem;
  51. /* Section rhythm is fluid so a phone doesn't inherit desktop air. */
  52. --sc-section: clamp(4.5rem, 9vw, 11rem);
  53. --sc-gutter: clamp(1.25rem, 5vw, 5.5rem);
  54. --sc-maxw: 82rem;
  55. /* --- radius. Pick one scale for the page and hold it. ------------------- */
  56. --sc-r-sm: 6px; --sc-r-md: 12px; --sc-r-lg: 20px; --sc-r-pill: 999px;
  57. /* --- elevation. Every shadow has an offset AND a soft blur, and is tinted
  58. to the canvas hue. A zero-offset coloured halo is decoration, not
  59. depth, so there isn't one here. ---------------------------------- */
  60. --sc-shadow-color: 220 40% 2%;
  61. --sc-e1: 0 1px 2px hsl(var(--sc-shadow-color) / 0.28),
  62. 0 2px 6px -1px hsl(var(--sc-shadow-color) / 0.20);
  63. --sc-e2: 0 2px 4px hsl(var(--sc-shadow-color) / 0.24),
  64. 0 8px 18px -4px hsl(var(--sc-shadow-color) / 0.30);
  65. --sc-e3: 0 4px 8px hsl(var(--sc-shadow-color) / 0.22),
  66. 0 18px 40px -8px hsl(var(--sc-shadow-color) / 0.38),
  67. 0 48px 90px -24px hsl(var(--sc-shadow-color) / 0.30);
  68. /* Edge light: a 1px top highlight sells a raised surface better than any
  69. amount of blur, because real raised things catch light on their lip. */
  70. --sc-edge: inset 0 1px 0 color-mix(in oklab, var(--sc-ink) 10%, transparent);
  71. /* --- motion. Built-in CSS easings are too weak for UI. ------------------ */
  72. --sc-ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  73. --sc-ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  74. --sc-ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  75. --sc-d-fast: 160ms; --sc-d-base: 240ms; --sc-d-slow: 420ms;
  76. --sc-z-stage: 1; --sc-z-copy: 20; --sc-z-chrome: 60;
  77. }
  78. /* --------------------------------------------------------------- reset -- */
  79. *, *::before, *::after { box-sizing: border-box; }
  80. html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
  81. @media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
  82. body {
  83. margin: 0;
  84. background: var(--sc-canvas);
  85. color: var(--sc-ink);
  86. font-family: var(--sc-font-text);
  87. font-size: var(--sc-t-base);
  88. line-height: var(--sc-leading-body);
  89. letter-spacing: var(--sc-track-normal);
  90. -webkit-font-smoothing: antialiased;
  91. text-rendering: optimizeLegibility;
  92. font-synthesis-weight: none;
  93. overflow-x: clip;
  94. }
  95. img, video, canvas, svg { display: block; max-width: 100%; }
  96. button, input, select, textarea { font: inherit; color: inherit; }
  97. /* ------------------------------------------------- the browser surfaces --
  98. The parts you did not draw still carry the design. Selection, caret, focus
  99. ring, scrollbar and tabular numerals all ship with defaults that belong to no
  100. design system. Theming them is the cheapest signal that a page was built
  101. rather than assembled, and it is the step that gets skipped most reliably. */
  102. ::selection { background: var(--sc-accent); color: var(--sc-accent-ink); }
  103. :root { caret-color: var(--sc-accent); accent-color: var(--sc-accent); }
  104. :focus-visible {
  105. outline: 2px solid var(--sc-accent);
  106. outline-offset: 3px;
  107. border-radius: var(--sc-r-sm);
  108. }
  109. :where(a) { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.22em; }
  110. @supports (scrollbar-color: auto) {
  111. html { scrollbar-color: color-mix(in oklab, var(--sc-ink) 26%, transparent) transparent; scrollbar-width: thin; }
  112. }
  113. :where(table, .sc-nums, [data-sc-count]) { font-variant-numeric: tabular-nums; }
  114. /* ----------------------------------------------------------- typography -- */
  115. .sc-display {
  116. font-family: var(--sc-font-display);
  117. font-weight: 500;
  118. line-height: var(--sc-leading-none);
  119. letter-spacing: var(--sc-track-tight);
  120. text-wrap: balance;
  121. margin: 0;
  122. }
  123. .sc-display--xl { font-size: var(--sc-t-4xl); }
  124. .sc-display--lg { font-size: var(--sc-t-3xl); }
  125. .sc-display--md { font-size: var(--sc-t-2xl); letter-spacing: var(--sc-track-snug); }
  126. .sc-lede {
  127. font-size: var(--sc-t-lg);
  128. line-height: 1.44;
  129. letter-spacing: var(--sc-track-snug);
  130. color: var(--sc-ink);
  131. max-width: 46ch;
  132. text-wrap: pretty;
  133. margin: 0;
  134. }
  135. .sc-body { max-width: var(--sc-measure); color: var(--sc-ink-soft); text-wrap: pretty; margin: 0; }
  136. .sc-label {
  137. font-family: var(--sc-font-mono);
  138. font-size: var(--sc-t-xs);
  139. letter-spacing: var(--sc-track-wide);
  140. text-transform: uppercase;
  141. color: var(--sc-ink-soft);
  142. }
  143. /* ---------------------------------------------------------------- layout -- */
  144. .sc-wrap { width: 100%; max-width: var(--sc-maxw); margin-inline: auto; padding-inline: var(--sc-gutter); }
  145. .sc-section { padding-block: var(--sc-section); }
  146. /* More space above a heading than below it: the gap belongs to the boundary,
  147. not to the pair. */
  148. .sc-stack > * + * { margin-top: var(--sc-4); }
  149. .sc-stack > :is(h1,h2,h3) { margin-top: var(--sc-7); }
  150. .sc-stack > :is(h1,h2,h3):first-child { margin-top: 0; }
  151. .sc-rule { height: 1px; border: 0; background: var(--sc-hairline); margin: 0; }
  152. /* =============================================================== DEVICES ==
  153. Driven by the engine. Restyle your own markup, not these. */
  154. .sc-act--pinned { position: relative; }
  155. .sc-stage {
  156. position: sticky; top: 0;
  157. height: 100vh; height: 100svh;
  158. overflow: clip;
  159. z-index: var(--sc-z-stage);
  160. }
  161. /* scrub / sequence media */
  162. .sc-stage :is(video[data-sc-scrub], canvas[data-sc-sequence], .sc-stage__poster) {
  163. position: absolute; inset: 0;
  164. width: 100%; height: 100%;
  165. object-fit: cover;
  166. }
  167. video[data-sc-scrub] { opacity: 0; transition: opacity 380ms var(--sc-ease-out); }
  168. .sc-has-clip video[data-sc-scrub] { opacity: 1; }
  169. /* The poster is a live frame-holder, not a placeholder: it stays up until a
  170. real video frame has painted, which is what stops the blank-stage flash. */
  171. .sc-stage__poster { z-index: 0; transition: opacity 380ms var(--sc-ease-out); }
  172. .sc-has-clip .sc-stage__poster { opacity: 0; }
  173. /* A scrim only where text sits. A full-frame darkening layer flattens the
  174. image everywhere to fix contrast in one corner. */
  175. .sc-scrim {
  176. position: absolute; inset: 0; pointer-events: none; z-index: 1;
  177. background: linear-gradient(
  178. var(--sc-scrim-angle, 180deg),
  179. color-mix(in oklab, var(--sc-canvas) var(--sc-scrim-a, 78%), transparent) 0%,
  180. color-mix(in oklab, var(--sc-canvas) 30%, transparent) 42%,
  181. transparent 68%);
  182. }
  183. /* Point the scrim at the copy. A scrim gradient that darkens the top while the
  184. copy sits at the bottom fixes contrast nowhere and flattens the image
  185. everywhere, which is the most common way text-over-video goes wrong. */
  186. .sc-scrim--bottom { --sc-scrim-angle: 0deg; }
  187. .sc-scrim--left { --sc-scrim-angle: 90deg; }
  188. .sc-scrim--right { --sc-scrim-angle: 270deg; }
  189. /* Corner scrims, for copy anchored to a corner. An edge gradient has to darken
  190. a whole band across the frame to cover one corner; a corner gradient puts the
  191. density where the text is and leaves the rest of the image alone. Pair with
  192. .sc-copy--lead / .sc-copy--trail. */
  193. .sc-scrim--lead {
  194. background: linear-gradient(to top right,
  195. color-mix(in oklab, var(--sc-canvas) 94%, transparent) 0%,
  196. color-mix(in oklab, var(--sc-canvas) 72%, transparent) 30%,
  197. color-mix(in oklab, var(--sc-canvas) 30%, transparent) 52%,
  198. transparent 72%);
  199. }
  200. .sc-scrim--trail {
  201. background: linear-gradient(to top left,
  202. color-mix(in oklab, var(--sc-canvas) 94%, transparent) 0%,
  203. color-mix(in oklab, var(--sc-canvas) 72%, transparent) 30%,
  204. color-mix(in oklab, var(--sc-canvas) 30%, transparent) 52%,
  205. transparent 72%);
  206. }
  207. /* A band across the bottom, for copy that spans the full width of the frame.
  208. That is what both corner anchors become below 860px, and it is also the right
  209. shape whenever the copy block is wider than a corner. */
  210. .sc-scrim--band {
  211. background: linear-gradient(to top,
  212. color-mix(in oklab, var(--sc-canvas) 94%, transparent) 0%,
  213. color-mix(in oklab, var(--sc-canvas) 74%, transparent) 22%,
  214. color-mix(in oklab, var(--sc-canvas) 30%, transparent) 42%,
  215. transparent 58%);
  216. }
  217. .sc-scrim--vignette {
  218. background: radial-gradient(120% 90% at 50% 45%, transparent 40%,
  219. color-mix(in oklab, var(--sc-canvas) 70%, transparent) 100%);
  220. }
  221. /* copy over a stage.
  222. max-width is in rem, never ch. A `ch` on this container resolves against the
  223. CONTAINER's font-size (body size), not the display size of the heading inside
  224. it, so `max-width: 20ch` here silently produces a ~180px column and wraps a
  225. hero headline to six lines. Set a ch measure on the text element itself. */
  226. .sc-copy {
  227. position: absolute; z-index: var(--sc-z-copy);
  228. inset-inline: var(--sc-gutter);
  229. max-width: min(46rem, 76vw);
  230. will-change: opacity, transform;
  231. }
  232. .sc-copy--lead { left: var(--sc-gutter); bottom: clamp(3rem, 12vh, 9rem); }
  233. /* inset-inline FIRST. It is the shorthand for left+right, so declaring it after
  234. `left: 50%` resets left to auto and the block drifts off the left edge. */
  235. .sc-copy--center { inset-inline: auto; left: 50%; top: 50%; translate: -50% -50%; text-align: center; }
  236. .sc-copy--trail { inset-inline: auto; right: var(--sc-gutter); bottom: clamp(3rem, 12vh, 9rem); text-align: right; }
  237. /* cue defaults: the engine writes opacity/transform inline, these are the
  238. pre-paint state so nothing flashes before the first read() */
  239. [data-sc-cue] { opacity: 0; will-change: opacity, transform; }
  240. .sc-ready [data-sc-cue] { transition: none; }
  241. /* kinetic split */
  242. .sc-split { display: inline-block; overflow: hidden; vertical-align: top; }
  243. /* Descenders live below the baseline; a line mask clipped to the line box eats
  244. the tails off g, y, p, j. The padding buys them room back. */
  245. .sc-split--line { display: block; padding-bottom: 0.14em; margin-bottom: -0.14em; }
  246. .sc-split__i { display: inline-block; will-change: transform, opacity; }
  247. .sc-is-split { opacity: 1 !important; }
  248. /* horizontal rail */
  249. [data-sc-pan] { display: flex; will-change: transform; }
  250. /* reveal + parallax */
  251. [data-sc-reveal] { will-change: clip-path; }
  252. [data-sc-parallax] { will-change: transform; }
  253. /* flow reveal (fires once) */
  254. [data-sc-in], [data-sc-stagger] > * {
  255. opacity: 0;
  256. transform: translate3d(0, 14px, 0);
  257. transition: opacity 620ms var(--sc-ease-out), transform 620ms var(--sc-ease-out);
  258. }
  259. [data-sc-in].sc-in, [data-sc-stagger] > .sc-in { opacity: 1; transform: none; }
  260. /* pointer devices */
  261. [data-sc-tilt] { transform-style: preserve-3d; will-change: transform; }
  262. [data-sc-magnet] { will-change: transform; }
  263. /* isolation always; position only if nothing more specific already set it.
  264. Written with :where() (zero specificity) on purpose: a plain `position:
  265. relative` here has the same weight as `.sc-stage` and, being later in the
  266. file, silently wins. A stage carrying both attributes then stops being
  267. sticky and the whole act scrolls away instead of pinning. */
  268. [data-sc-spotlight] { isolation: isolate; }
  269. :where([data-sc-spotlight]) { position: relative; }
  270. [data-sc-spotlight]::after {
  271. content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 2;
  272. background: radial-gradient(
  273. 28rem 28rem at calc(var(--sc-mx, 0.5) * 100%) calc(var(--sc-my, 0.5) * 100%),
  274. color-mix(in oklab, var(--sc-accent) 16%, transparent), transparent 70%);
  275. opacity: 0; transition: opacity var(--sc-d-slow) var(--sc-ease-out);
  276. }
  277. [data-sc-spotlight]:hover::after { opacity: 1; }
  278. /* =========================================================== WORLDFLIGHT ==
  279. One fixed stage for the whole page. The only thing in document flow is the
  280. spacer, and it is empty. If you find yourself adding a section here, you want
  281. act mode instead: the moment a real block scrolls past the fixed stage, the
  282. page has a seam again and the whole point is gone. */
  283. [data-sc-mode="worldflight"] { position: relative; }
  284. .sc-world {
  285. position: fixed; inset: 0;
  286. overflow: clip;
  287. z-index: var(--sc-z-stage);
  288. background: var(--sc-canvas);
  289. }
  290. /* Every leg is mounted for the life of the page and stacked in the same box.
  291. The engine owns opacity, visibility and z-index here; do not set them. */
  292. .sc-world__seg {
  293. position: absolute; inset: 0;
  294. opacity: 0;
  295. will-change: opacity;
  296. }
  297. .sc-world__seg > :is(video, img, canvas) {
  298. position: absolute; inset: 0;
  299. width: 100%; height: 100%;
  300. object-fit: cover;
  301. }
  302. /* The poster is the frame-holder AND the first camera move: the engine pushes
  303. it in slowly until a real decoded frame is available to replace it. */
  304. .sc-world__poster {
  305. z-index: 0;
  306. transform-origin: 50% 50%;
  307. transition: opacity 420ms var(--sc-ease-out);
  308. }
  309. .sc-world__seg > video { z-index: 1; }
  310. .sc-world__seg.sc-has-clip .sc-world__poster { opacity: 0; }
  311. /* The act stylesheet lights a clip through its ancestor act. A worldflight leg
  312. has no act, so match the class the engine also writes on the clip itself. */
  313. video[data-sc-scrub].sc-has-clip { opacity: 1; }
  314. /* The copy layer is fixed too, and inert by default: the engine hands
  315. pointer-events back to a block only while it is actually legible. */
  316. .sc-world__copy {
  317. position: fixed; inset: 0;
  318. z-index: var(--sc-z-copy);
  319. pointer-events: none;
  320. }
  321. .sc-world__scrim { position: absolute; inset: 0; pointer-events: none; z-index: 0; }
  322. [data-sc-copy] {
  323. opacity: 0;
  324. pointer-events: none;
  325. will-change: opacity, transform;
  326. }
  327. .sc-ready [data-sc-copy] { transition: none; }
  328. /* The track. Empty on purpose. */
  329. .sc-world__spacer { pointer-events: none; }
  330. /* scroll progress */
  331. [data-sc-progress] {
  332. position: fixed; inset: 0 0 auto 0; height: 2px; z-index: var(--sc-z-chrome);
  333. background: var(--sc-accent); transform-origin: 0 50%; transform: scaleX(0);
  334. will-change: transform;
  335. }
  336. /* ----------------------------------------------------------- atmosphere --
  337. Depth is not only shadow. Grain keeps a flat dark ground from banding, and
  338. it is the difference between "a dark page" and "a lit room". */
  339. .sc-grain { position: fixed; inset: 0; pointer-events: none; z-index: 3; opacity: 0.045; }
  340. .sc-grain::before {
  341. content: ""; position: absolute; inset: -50%;
  342. background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/></filter><rect width='140' height='140' filter='url(%23n)'/></svg>");
  343. }
  344. /* -------------------------------------------------------- reduced motion -- */
  345. @media (prefers-reduced-motion: reduce) {
  346. /* Fewer and gentler, not zero. Opacity still carries the reveal so the page
  347. is comprehensible; every position change is dropped. */
  348. [data-sc-in], [data-sc-stagger] > * { transform: none; transition-duration: 220ms; }
  349. [data-sc-parallax], [data-sc-pan], .sc-split__i { transform: none !important; }
  350. /* A wipe is a position change too. Show reveal content settled. */
  351. [data-sc-reveal] { clip-path: none !important; }
  352. /* A rail's transform IS its navigation, not decoration. Zeroing it the way
  353. parallax and kinetic type are zeroed parks the act on its first screenful
  354. and makes everything past the fold unreachable: a device degrading into
  355. missing content. Hand the travel back to the reader as an ordinary scroll
  356. region instead, so the same items are all still gettable without motion.
  357. A build that would rather re-lay the rail out as a grid can still do that;
  358. this is the floor, not the ceiling. */
  359. [data-sc-act="pan"] .sc-stage,
  360. [data-sc-act="pan"] [data-sc-stage] {
  361. overflow-x: auto; overflow-y: hidden;
  362. overscroll-behavior-x: contain;
  363. scroll-snap-type: x proximity;
  364. }
  365. [data-sc-pan] > * { scroll-snap-align: center; }
  366. [data-sc-spotlight]::after { display: none; }
  367. /* A worldflight keeps its whole story here. No clip is ever fetched, so the
  368. posters are the film, and they cross-dissolve through exactly the same
  369. seams at exactly the same scroll positions. The push-in and the copy drift
  370. are the only things that go. */
  371. .sc-world__poster, [data-sc-copy] { transform: none !important; }
  372. }
  373. /* --------------------------------------------------------------- mobile -- */
  374. @media (max-width: 860px) {
  375. .sc-copy { inset-inline: var(--sc-gutter); max-width: none; }
  376. .sc-copy--trail { text-align: left; }
  377. .sc-stage { height: 100svh; }
  378. /* .sc-copy--trail re-anchors to the left and spans the full width here, so a
  379. bottom-RIGHT corner gradient darkens the one corner the copy just left and
  380. guarantees a contrast failure over any bright clip. Point the density at
  381. the copy: the same band .sc-scrim--band paints. */
  382. .sc-scrim--trail {
  383. background: linear-gradient(to top,
  384. color-mix(in oklab, var(--sc-canvas) 94%, transparent) 0%,
  385. color-mix(in oklab, var(--sc-canvas) 74%, transparent) 22%,
  386. color-mix(in oklab, var(--sc-canvas) 30%, transparent) 42%,
  387. transparent 58%);
  388. }
  389. }