This year, I decided to participate regularly in the weekly CodePen challenges. My goal is simple: firstly, to keep my skills sharp, whilst exploring emerging web technologies; and secondly, to practise AI-augmented learning by utilising AI tools to examine technical topics from different angles.

Turning to this week’s challenge, the theme is "Experimental CSS". For this entry, I set out to explore and combine several modern CSS techniques, including corner-shape and scroll-driven timeline properties.

As this walkthrough covers quite a lot of ground, please feel free to brew yourself a cup of coffee and settle in for a detailed read.

Full disclosure: The initial concept and inspiration - vintage cinema tickets — were my own. From there, I experimented with a variety of AI tools and providers (I plan to cover the specifics of that workflow in a separate article). After several iterations, I arrived at a result I was pleased with, which I then refined and formatted into the final result you can see here.

Each iteration became noticeably faster using the following tools:

  • Claude Code
  • GPT-6.1 Terra and Mai Code 2 Flash via Github Copilot
  • Gemini Neon and modern web guidance via Antigravity

You can explore the completed demo in the CodePen below:

Why a ticket, and why pure CSS

A vintage cinema ticket is a small stress test for modern CSS: concave corners, punched half-moons, a ribbed texture, a hard offset shadow, a card that turns over, and a stack that fans open as you scroll. This article rebuilds all of it from a single combined file, with no JavaScript, no images, no SVG and no external fonts.

Pure CSS earns its keep here for three reasons. The effects stay in the cascade, so a ticket restyles with a custom property. Nothing blocks rendering, because there is no script to load. And every effect can sit behind @supports, so older browsers get a plainer ticket instead of a broken page.

The combined file merges the strongest parts of three drafts: a shared mask system, wrapper shadows, an @property fan, a film-strip progress bar, a :focus-within flip, clip-path stars and a two-layer hard shadow. All content is dummy test data ("Test Venue", "Sample Test Co.", 2099-01-01).

Setup: one wrapper, one ticket

Every ticket uses the same two-element pattern. The outer .ticket-wrap owns width and shadow. The inner .ticket owns paint, shape and masks. Splitting them matters: a mask clips everything inside an element, including its own shadow, so the shadow has to live one level up.

<div class="ticket-wrap"> <article class="ticket t-coral" aria-label="Test voucher, admit one"> <div class="stub"><p class="stub__admit">Admit One</p></div> <div class="chamber"><h3>Ticket</h3><p>Test Venue · No. 000001</p></div> </article> </div> 
.ticket-wrap { width: min(var(--w, 540px), 100%); } .ticket-wrap--kraft { --w: 430px; } /* set where it is read */ 

One bug from the earlier drafts is worth naming: --w was set on .ticket but read on .ticket-wrap. Custom properties inherit downward, never up, so the wrapper silently fell back to 540px. Set the width on the wrapper, or on a modifier class that sits on it.

Before: every ticket rendered at the default width. After: each ticket takes its own width and still shrinks on a phone.

Scooped corners with corner-shape

border-radius normally rounds a corner outward. corner-shape: scoop keeps the same radius but carves the corner inward, which is exactly the concave bite of a die-cut ticket. The radius still sets the size, so the two properties work as a pair.

.ticket { --r: 16px; border-radius: var(--r); /* plain fallback, works everywhere */ } @supports (corner-shape: scoop) { .ticket { corner-shape: scoop; } /* only here */ } 

The rule is strict: corner-shape appears only inside @supports (corner-shape: scoop). Outside it, the ticket keeps a normal border-radius, so layout never depends on the new property.

Browsers without support would show convex corners, which looks wrong for this design. So a second block, @supports not (corner-shape: scoop), adds four corner masks that reproduce the scoop:

@supports not (corner-shape: scoop) { .ticket { --corner-tl: radial-gradient(circle var(--r) at 0 0, #0000 94%, #000 100%); /* tr, bl, br follow the same pattern at 100% 0, 0 100%, 100% 100% */ } } 

Before: rounded, soft-looking corners. After: concave bites in every browser, native where available and masked elsewhere. Note that the native path adds no masks for corners, so you never pay for both.

Perforations and cut-outs: intersected masks

Perforations are holes, and a mask is a stencil: opaque pixels stay, transparent ones vanish. Each hole is a radial-gradient that is transparent at the centre and opaque beyond its radius. Several stencils are stacked and combined with mask-composite: intersect, so a pixel survives only if every layer keeps it.

.ticket { --pr: 5px; --pitch: 22px; --perf-l: radial-gradient(circle var(--pr) at 0 50%, #0000 94%, #000 100%); --perf-r: radial-gradient(circle var(--pr) at 100% 50%, #0000 94%, #000 100%); --solid: linear-gradient(#000 0 0); --cut-a: var(--solid); --cut-b: var(--solid); -webkit-mask-image: var(--perf-l), var(--perf-r), var(--cut-a), var(--cut-b); mask-image: var(--perf-l), var(--perf-r), var(--cut-a), var(--cut-b); -webkit-mask-size: 100% var(--pitch), 100% var(--pitch), 100% 100%, 100% 100%; mask-size: 100% var(--pitch), 100% var(--pitch), 100% 100%, 100% 100%; -webkit-mask-repeat: repeat-y, repeat-y, no-repeat, no-repeat; mask-repeat: repeat-y, repeat-y, no-repeat, no-repeat; -webkit-mask-composite: source-in; mask-composite: intersect; } 

The two side layers are tiles one --pitch tall, repeated down the edges, which gives the row of half-circle bites. The --cut-a and --cut-b slots default to a solid layer that changes nothing. A single ticket overrides them for its own cut-outs: the coral voucher punches half-moons at both ends of its dotted tear line, and the ribbed ticket notches its top edge.

Common mistake: forgetting the -webkit- pair. Older WebKit uses source-in where the standard says intersect; ship both.

Before: a plain rectangle. After: a stamped ticket whose holes are real transparency, so whatever sits behind the page shows through.

Shadows that follow the cut

A box-shadow draws a rectangle, ignoring masks and scooped corners. filter: drop-shadow() shadows the rendered pixels instead, so it hugs every notch. Because the mask lives on .ticket, the filter goes on the wrapper:

.ticket-wrap { filter: drop-shadow(0 14px 12px rgb(0 0 0 / 0.38)) drop-shadow(0 2px 2px rgb(0 0 0 / 0.35)); } 

Two soft layers, one wide and one tight, read as paper resting on a table.

The hard offset shadow. The terracotta banner swaps blur for a solid slab. Chained filters apply in order, so the second shadow wraps the first and creates a rim:

.ticket-wrap--hard { width: min(var(--w), calc(100% - 14px)); margin: 0 14px 14px 0; /* room for the offset */ filter: drop-shadow(11px 11px 0 var(--hard)) drop-shadow(13px 13px 0 var(--brass)); } 

The margin is the detail people miss: a shadow offset past the box can overflow a narrow screen, so reserve its width.

Common mistakes: putting drop-shadow on the masked element, where it is clipped away, and giving the earlier draft's 4px value to a design described as 11px. Keep the spec text and the CSS in step.

Before: a rectangular shadow under a notched ticket. After: a shadow that carries every scoop and punched hole.

Texture and shapes with gradients and clip-path

Every surface is built from gradients, so there are no image requests.

  • Kraft grain: two repeating-radial-gradient layers at different pitches make speckle, a pair of soft radial blotches add stains, and box-shadow: inset 0 0 38px darkens the edges like aged card.
  • Fold crease: a narrow linear-gradient with a dark line and a pale highlight, angled at 260deg on the front and 95deg on the back.
  • Ribs: repeating-linear-gradient(90deg, ...) bands down both edges of the ribbed ticket.
  • Double frames: outline with a negative outline-offset draws a second hairline inside a border, with no extra element.

Stars come from clip-path, not glyphs, so they scale and recolour with ordinary CSS:

.stars i { display: block; width: 22px; aspect-ratio: 1; background: #ffd36b; clip-path: polygon(50% 6%, 62% 36%, 94% 38%, 69% 58%, 78% 92%, 50% 73%, 22% 92%, 31% 58%, 6% 38%, 38% 36%); } .chamber { border: 3px solid currentColor; outline: 1.5px solid rgb(255 242 223 / 0.6); outline-offset: -9px; } 

Put the star polygon on a plain element and wrap the row in role="img" with an aria-label, so a screen reader hears "Five stars" once instead of five empty boxes.

Before: flat colour blocks. After: paper that looks handled.

A pure-CSS flip

The kraft ticket has a blank reverse. Turning it needs no script: a focusable container drives the rotation through :hover and :focus-within.

<div class="flip" tabindex="0" role="group" aria-label="Kraft ticket. Hover or focus to turn it over."> <div class="flip__inner"> <div class="flip__face ticket-wrap"><article class="ticket t-kraft">…front…</article></div> <div class="flip__face flip__face--back ticket-wrap"><article class="ticket t-kraft"></article></div> </div> </div> 
.flip { perspective: 1200px; display: grid; } .flip__inner { display: grid; transform-style: preserve-3d; transition: transform .8s cubic-bezier(.2,.7,.2,1); } .flip__face { grid-area: 1 / 1; backface-visibility: hidden; } .flip__face--back { transform: rotateY(180deg); } .flip:hover .flip__inner, .flip:focus-within .flip__inner { transform: rotateY(180deg); } 

Both faces share one grid cell, so they stack without absolute positioning. Each face keeps its own wrapper, which means the drop-shadow stays on a flat element rather than being flattened out of the 3D context. tabindex="0" makes the card reachable by keyboard, and :focus-within turns it on tap for touch devices.

Common mistake: putting filter on the element that carries preserve-3d. A filter forces flattening and the back face stops hiding. Keep the filter on each face.

Under prefers-reduced-motion: reduce the transition drops to 0.01ms, so the ticket still turns but without the animation.

Scroll-driven motion

Scroll-linked effects now run on the compositor timeline instead of scroll listeners. Three pieces do the work.

1. A film-strip progress bar. A fixed bar scales from 0 to 1 against the root scroller:

@keyframes film-advance { from { transform: scaleX(0); } to { transform: scaleX(1); } } .film__fill { animation: film-advance linear both; animation-timeline: scroll(root block); } 

2. Named view timelines. Each section declares a timeline, and timeline-scope on :root lets distant elements, such as the pill nav, use it:

:root { timeline-scope: --t1, --t2, --t3, --t4, --t5; } #coral { view-timeline: --t1 block; } .hud li:nth-child(1) a { animation-name: hud-pill; animation-timeline: --t1; } 

Each pill lights up while its plate crosses the viewport, with no is-active class and no observer.

3. A registered property for the fan. A custom property cannot animate unless the browser knows its type. @property registers --fan as a number, so it interpolates from 0 to 1 and every ticket derives its own transform from it:

@property --fan { syntax: "<number>"; inherits: true; initial-value: 1; } .deck__ticket { transform: translateX(calc(var(--tx) * var(--fan))) rotate(calc(var(--rot) * var(--fan))); } @keyframes fan-out { from { --fan: 0; } to { --fan: 1; } } .deck__stage { animation: fan-out linear both; animation-timeline: --t5; animation-range: cover 28% cover 62%; } 

One animated variable drives five rotations. The initial-value: 1 is the fallback: without scroll timelines the stack simply appears fanned.

All of this sits inside @media (prefers-reduced-motion: no-preference) and an @supports check, and the tall sticky deck only switches on there. Everywhere else the deck is a normal block.

Browser support and the @supports strategy

corner-shape is new and animation-timeline is still rolling out, so each feature gets a named fallback instead of a hope. Support changes quickly; check current compatibility tables before shipping.

Feature Where it lives If unsupported
corner-shape: scoop @supports (corner-shape: scoop) Four radial-gradient corner masks
mask-composite: intersect .ticket -webkit-mask-composite: source-in pair
animation-timeline @supports + reduced-motion media query Static page, dim full film strip
@property top of the stylesheet --fan: 1 set on :root, deck shows fanned

Three rules keep this honest:

  1. The new property appears only inside its own @supports block, never as a bare declaration.
  2. Every enhanced state has a sensible default state, so the page is complete before any enhancement applies.
  3. The fallback for corners is its own @supports not block, so a browser never runs both paths.

CSS-only feature flags. The hero shows which path the browser took, using no script. A pseudo-element holds the fallback text and @supports overrides it:

.flag--corner::before { content: "Mask fallback"; } @supports (corner-shape: scoop) { .flag--corner::before { content: "Native scoop"; } } 

That is a small, honest diagnostic: the label is true because the same condition that picked the shape picked the text.

Performance and accessibility

Performance.

  • Scroll timelines animate transform and opacity, which the compositor can handle without layout.
  • Masks and filter: drop-shadow repaint when their content changes. Keep filters on static wrappers and avoid animating a masked element's size.
  • Reveal animations on the whole .reveal wrapper are cheap; animating max-width in the HUD labels triggers layout, so keep that element small.
  • Gradients are generated, not downloaded, so the file has zero image requests.

Accessibility.

  • Each ticket is an <article> with an aria-label, and headings use real <h2> and <h3> elements.
  • Decorative parts (ribs, film strip) carry aria-hidden. The star row is one role="img".
  • Serial numbers sit in <data value="...">, so the machine-readable value travels with the text.
  • The flip works from the keyboard via tabindex="0" and shows a visible :focus-visible outline.
  • Colour tokens switch under prefers-color-scheme, and motion respects prefers-reduced-motion.
  • Watch contrast: tiny muted text on dark paper is the weakest spot. Keep captions at 0.8rem or larger and check them against the background.

Takeaways

  • Split shape from shadow: mask the inner element, filter the outer one.
  • Treat masks as stencils and combine them with mask-composite: intersect; leave default slots so one system serves every ticket.
  • Use border-radius plus corner-shape: scoop for the native corner, but only inside @supports, with a mask fallback in the matching @supports not block.
  • Register animated custom properties with @property so one variable can drive many transforms.
  • Give every enhancement a complete default, and let @supports and prefers-reduced-motion opt people in.
  • Put each custom property where it is read: a value set on a child never reaches its parent.