Cook mode app
A recipe screen for messy hands: one big step at a time, swipe or tap to move on, timers that keep running in a pill while you cook the next step.
"use client";
import {
useEffect,
useRef,
useState,
type CSSProperties,
type PointerEvent,
} from "react";
import "./cook-mode.css";
export type Ingredient = { name: string; amount: number; unit: string };
export type Step = { text: string; uses?: string[]; minutes?: number };
type CookModeProps = {
title: string;
photo: string;
serves: number;
totalMinutes: number;
ingredients: Ingredient[];
steps: Step[];
};
type Timer = { step: number; left: number; total: number; running: boolean };
const mmss = (s: number) =>
`${Math.floor(s / 60)}:${String(s % 60).padStart(2, "0")}`;
const qty = (n: number) =>
Number.isInteger(n) ? `${n}` : n.toFixed(n < 10 ? 1 : 0);
/** Digits that roll: only the characters that change slide in, like a kitchen timer. */
function Roll({ text }: { text: string }) {
return (
<span className="gu-cook__roll" aria-hidden="true">
{text.split("").map((ch, i) => (
<span key={`${i}-${ch}`}>{ch}</span>
))}
</span>
);
}
/**
* CookMode: a recipe you can follow with flour on your hands.
* - Steps are a deck of cards: swipe one away (it flies off the side you threw it) and the next lifts up from behind.
* - Steps with a time get a ring timer with rolling digits. It keeps counting in a pill while you move on,
* and when it hits zero the ring turns into a check and the card rings out.
* - Ingredients scale with the number of people (the numbers roll) and tick off with a drawn line.
*/
export function CookMode({
title,
photo,
serves: baseServes,
totalMinutes,
ingredients,
steps,
}: CookModeProps) {
const [tab, setTab] = useState<"steps" | "ingredients">("steps");
const [step, setStep] = useState(1);
const [dir, setDir] = useState<1 | -1 | 0>(0);
const [leaving, setLeaving] = useState<{
step: number;
dir: 1 | -1;
dx: number;
id: number;
} | null>(null);
const [serves, setServes] = useState(baseServes);
const [got, setGot] = useState<Set<number>>(new Set([0, 2]));
const [timer, setTimer] = useState<Timer | null>(null);
const drag = useRef<{ x: number; dx: number } | null>(null);
const card = useRef<HTMLDivElement>(null);
const s = steps[step];
const last = step === steps.length - 1;
useEffect(() => {
if (!timer?.running) return;
const id = window.setInterval(
() =>
setTimer((t) =>
t ? { ...t, left: Math.max(0, t.left - 1), running: t.left > 1 } : t,
),
1000,
);
return () => window.clearInterval(id);
}, [timer?.running]);
const show = (to: number, d: 1 | -1, dx = 0) => {
if (to === step || to < 0 || to >= steps.length) {
card.current?.style.setProperty("--dx", "0px");
return;
}
setLeaving({ step, dir: d, dx, id: Date.now() });
setDir(d);
setStep(to);
};
const go = (d: 1 | -1, dx = 0) => show(step + d, d, dx);
const down = (e: PointerEvent<HTMLDivElement>) => {
if ((e.target as HTMLElement).closest("button")) return;
drag.current = { x: e.clientX, dx: 0 };
e.currentTarget.setPointerCapture(e.pointerId);
e.currentTarget.dataset.dragging = "true";
};
const move = (e: PointerEvent<HTMLDivElement>) => {
if (!drag.current) return;
const raw = e.clientX - drag.current.x;
// At the ends of the recipe the card resists, so you can feel there is nothing more.
const blocked = (raw > 0 && step === 0) || (raw < 0 && last);
drag.current.dx = blocked ? raw * 0.25 : raw;
card.current?.style.setProperty("--dx", `${drag.current.dx}px`);
};
const up = (e: PointerEvent<HTMLDivElement>) => {
const dx = drag.current?.dx ?? 0;
drag.current = null;
e.currentTarget.dataset.dragging = "false";
if (dx < -70 && !last) go(1, dx);
else if (dx > 70 && step > 0) go(-1, dx);
else card.current?.style.setProperty("--dx", "0px");
};
const startTimer = () => {
if (!s.minutes) return;
if (timer?.step === step)
return setTimer({ ...timer, running: !timer.running && timer.left > 0 });
setTimer({
step,
left: s.minutes * 60,
total: s.minutes * 60,
running: true,
});
};
const here = timer?.step === step ? timer : null;
const k = here ? 1 - here.left / here.total : 0;
const done = here?.left === 0;
const face = (i: number) => {
const st = steps[i];
return (
<>
<p className="gu-cook__count" aria-hidden="true">
Step {i + 1} of {steps.length}
</p>
<p className="gu-cook__text">{st.text}</p>
{st.uses && st.uses.length > 0 && (
<ul className="gu-cook__uses" aria-label="You need">
{st.uses.map((u, j) => (
<li key={u} style={{ "--j": j } as CSSProperties}>
{u}
</li>
))}
</ul>
)}
</>
);
};
return (
<div className="gu-cook">
<div className="gu-cook__hero">
<img src={photo} alt="" />
<div className="gu-cook__hero-shade" aria-hidden="true" />
<div className="gu-cook__hero-text">
<h2>{title}</h2>
<p>
{totalMinutes} min · serves <Roll text={String(serves)} />
<span className="gu-cook__sr">{serves}</span>
</p>
</div>
</div>
<div className="gu-cook__body">
<div className="gu-cook__tabs" role="tablist" aria-label="Recipe">
{(["steps", "ingredients"] as const).map((t) => (
<button
key={t}
type="button"
role="tab"
aria-selected={tab === t}
onClick={() => setTab(t)}
>
{t === "steps" ? "Steps" : "Ingredients"}
</button>
))}
<span
className="gu-cook__tab-pill"
data-right={tab === "ingredients"}
aria-hidden="true"
/>
</div>
{tab === "steps" ? (
<section aria-label="Steps" className="gu-cook__steps">
<div className="gu-cook__progress" aria-hidden="true">
{steps.map((_, i) => (
<span
key={i}
data-state={i < step ? "done" : i === step ? "now" : "next"}
/>
))}
</div>
<div className="gu-cook__deck">
{/* The next card waits underneath, so the steps feel like a real stack. */}
{!last && <div className="gu-cook__under" aria-hidden="true" />}
<div
ref={card}
className="gu-cook__card"
key={step}
data-enter={dir === 1 ? "lift" : dir === -1 ? "return" : "none"}
data-done={done}
onPointerDown={down}
onPointerMove={move}
onPointerUp={up}
onPointerCancel={up}
>
<span className="gu-cook__sr" aria-live="polite">
Step {step + 1} of {steps.length}
</span>
{face(step)}
{s.minutes && (
<button
type="button"
className="gu-cook__timer"
style={{ "--gu-cook-k": k } as CSSProperties}
data-running={here?.running ?? false}
data-done={done}
onClick={startTimer}
aria-label={
here
? done
? "Timer done"
: `${here.running ? "Pause" : "Resume"} timer, ${mmss(here.left)} left`
: `Start a ${s.minutes} minute timer`
}
>
<span className="gu-cook__ring" aria-hidden="true">
<svg viewBox="0 0 24 24">
{done ? (
<path
className="gu-cook__tick"
pathLength={1}
d="m6 12.5 4 4 8-9"
/>
) : here?.running ? (
<path d="M8.5 6v12M15.5 6v12" />
) : (
<path d="M8.5 5.5v13l10-6.5-10-6.5Z" />
)}
</svg>
</span>
<span className="gu-cook__timer-text">
<strong>
<Roll
text={here ? mmss(here.left) : `${s.minutes}:00`}
/>
</strong>
<span>
{here
? done
? "Done! Take it off the heat"
: here.running
? "Tap to pause"
: "Paused"
: "Start timer"}
</span>
</span>
</button>
)}
</div>
{/* The card you just left, flying off the side you sent it. */}
{leaving && (
<div
key={leaving.id}
className="gu-cook__card gu-cook__card--leaving"
data-dir={leaving.dir === 1 ? "left" : "right"}
style={{ "--from": `${leaving.dx}px` } as CSSProperties}
onAnimationEnd={(e) =>
e.target === e.currentTarget && setLeaving(null)
}
aria-hidden="true"
>
{face(leaving.step)}
</div>
)}
</div>
<div className="gu-cook__nav">
<button
type="button"
className="gu-cook__back"
onClick={() => go(-1)}
disabled={step === 0}
>
Back
</button>
<button
type="button"
className="gu-cook__next"
onClick={() => (last ? show(0, -1) : go(1))}
>
<span key={String(last)}>
{last ? "Done, cook again" : "Next step"}
</span>
</button>
</div>
</section>
) : (
<section aria-label="Ingredients" className="gu-cook__ingredients">
<div className="gu-cook__serves">
<span>People</span>
<div>
<button
type="button"
aria-label="Fewer people"
onClick={() => setServes((n) => Math.max(1, n - 1))}
>
−
</button>
<output aria-live="polite">
<Roll text={String(serves)} />
<span className="gu-cook__sr">{serves}</span>
</output>
<button
type="button"
aria-label="More people"
onClick={() => setServes((n) => Math.min(12, n + 1))}
>
+
</button>
</div>
</div>
<ul className="gu-cook__list">
{ingredients.map((g, i) => {
const amount = `${qty((g.amount * serves) / baseServes)}${g.unit ? ` ${g.unit}` : ""}`;
return (
<li key={g.name} style={{ "--i": i } as CSSProperties}>
<label data-got={got.has(i)}>
<input
type="checkbox"
checked={got.has(i)}
onChange={() =>
setGot((set) => {
const c = new Set(set);
if (c.has(i)) c.delete(i);
else c.add(i);
return c;
})
}
/>
<span className="gu-cook__check" aria-hidden="true">
<svg viewBox="0 0 24 24">
<path pathLength={1} d="m6 12.5 4 4 8-9" />
</svg>
</span>
<span className="gu-cook__name">{g.name}</span>
<span className="gu-cook__qty">
<Roll text={amount} />
<span className="gu-cook__sr">{amount}</span>
</span>
</label>
</li>
);
})}
</ul>
</section>
)}
</div>
{/* A running timer for another step stays visible as a pill. */}
{timer && timer.step !== step && (
<button
type="button"
className="gu-cook__pill"
data-done={timer.left === 0}
onClick={() => {
setTab("steps");
show(timer.step, timer.step > step ? 1 : -1);
}}
>
<span className="gu-cook__pill-dot" aria-hidden="true" />
Step {timer.step + 1} · {timer.left === 0 ? "done" : mmss(timer.left)}
</button>
)}
</div>
);
}
Paste this into ChatGPT, Claude, Cursor, v0, Lovable or Bolt. It describes the layout, motion, colors and accessibility and includes the code, so the AI can rebuild it in any framework.
# Build this UI piece: Cook mode app
You are a senior front-end engineer. Recreate the piece below in my project. If I don't say which framework I use, ask once, then build it in that framework (React, Vue, Svelte, Angular, Astro, plain HTML/CSS/JS or anything else). Keep the behavior, motion, colors, spacing and accessibility exactly as described. Keep the code clean and commented for beginners.
## What it is
A recipe app "cook mode" screen for phones. It shows one big step at a time so you can read it from a distance, with built-in timers that keep counting while you move to the next step, and an ingredient list that scales with the number of people.
## Layout and look
- Fills its parent; warm linen background #f6f1e8, cards #fffdf8, roast ink #1d1712, muted #7a6f63, one orange accent #ff5a1f for timers and the current step. System font.
- Hero: a 290px food photo (object-fit cover) with a dark gradient top and bottom; the recipe title (30px, weight 750, -0.03em) and "35 min · serves 4" sit at the bottom left in white.
- Body: a linen sheet with 30px top corners that overlaps the photo by 28px.
- Tabs: Steps / Ingredients in a pill track; a white pill slides under the active tab.
- Progress: one thin 4px segment per step; done steps ink, the current one orange.
- Step card: radius 26px, "Step 2 of 6" in orange, the step text at 23px, small chips for the ingredients that step uses.
- Timer: a 56px conic ring that fills clockwise, the time in big tabular numbers and a hint ("Start timer", "Tap to pause", "Paused", "Done!").
- Nav: Back (1 part) and Next step (2 parts, filled ink), both 58px tall with 20px corners.
- Ingredients: a people stepper (− 4 +) and a list of checkable rows with scaled quantities on the right; ticked rows go muted and struck through.
- Timer pill: when a timer runs for a step you are not looking at, a dark frosted pill floats below the status bar with a blinking orange dot and "Step 2 · 4:31". Tap it to jump back.
## Behavior and motion
1. Drag the card sideways: it follows the finger with a slight tilt; past 60px it moves to the next or previous step.
2. Each new card slides in from 24px to the right and fades in (0.5s, cubic-bezier(0.16, 1, 0.3, 1)).
3. Tapping a timer starts it; tapping again pauses or resumes. Only one timer runs at a time.
4. Changing the number of people rescales every quantity.
5. On the last step the Next button says "Done, cook again" and goes back to step 1.
Extra motion that makes it feel finished:
- The hero photo drifts and zooms very slowly (24s, alternate). The body sheet has a soft shadow over the photo.
- The steps are a deck: a second card peeks out underneath. Swiping sends the card off the side you threw it (with a tilt), and the next card lifts up from the stack with a spring; going back, the previous card swings in from the left. At the first and last step the card resists the drag.
- Progress segments fill from the left like a fuse.
- Timer digits roll: only the characters that change drop into place. The ring has play, pause or check icons in the middle and fills smoothly (a registered custom property animated with a 1s linear transition).
- When a timer finishes: the ring turns green with a pop, a check draws itself, rings ripple outward three times, the card wiggles, and the floating pill turns green and rocks.
- Ingredients: rows rise in one by one; the box pops and the check draws itself; a line is drawn across the name; quantities roll when the number of people changes.
## Accessibility
- Tabs use role="tablist" and aria-selected. "Step 2 of 6" is aria-live.
- The timer button label says what it does and how long is left.
- Ingredient rows are real checkboxes inside labels; the stepper buttons are labeled "Fewer people" and "More people".
- prefers-reduced-motion: no slide-ins, no ring pulse, no blinking dot.
## Props
title, photo, serves, totalMinutes, ingredients: { name, amount, unit }[], steps: { text, uses?: string[], minutes?: number }[]
## Reference implementation
The original is written in React with one plain CSS file. Dependencies: none (plain React and CSS). Translate it faithfully; do not add new libraries unless my framework needs them.
### CookMode.tsx
```tsx
"use client";
import {
useEffect,
useRef,
useState,
type CSSProperties,
type PointerEvent,
} from "react";
import "./cook-mode.css";
export type Ingredient = { name: string; amount: number; unit: string };
export type Step = { text: string; uses?: string[]; minutes?: number };
type CookModeProps = {
title: string;
photo: string;
serves: number;
totalMinutes: number;
ingredients: Ingredient[];
steps: Step[];
};
type Timer = { step: number; left: number; total: number; running: boolean };
const mmss = (s: number) =>
`${Math.floor(s / 60)}:${String(s % 60).padStart(2, "0")}`;
const qty = (n: number) =>
Number.isInteger(n) ? `${n}` : n.toFixed(n < 10 ? 1 : 0);
/** Digits that roll: only the characters that change slide in, like a kitchen timer. */
function Roll({ text }: { text: string }) {
return (
<span className="gu-cook__roll" aria-hidden="true">
{text.split("").map((ch, i) => (
<span key={`${i}-${ch}`}>{ch}</span>
))}
</span>
);
}
/**
* CookMode: a recipe you can follow with flour on your hands.
* - Steps are a deck of cards: swipe one away (it flies off the side you threw it) and the next lifts up from behind.
* - Steps with a time get a ring timer with rolling digits. It keeps counting in a pill while you move on,
* and when it hits zero the ring turns into a check and the card rings out.
* - Ingredients scale with the number of people (the numbers roll) and tick off with a drawn line.
*/
export function CookMode({
title,
photo,
serves: baseServes,
totalMinutes,
ingredients,
steps,
}: CookModeProps) {
const [tab, setTab] = useState<"steps" | "ingredients">("steps");
const [step, setStep] = useState(1);
const [dir, setDir] = useState<1 | -1 | 0>(0);
const [leaving, setLeaving] = useState<{
step: number;
dir: 1 | -1;
dx: number;
id: number;
} | null>(null);
const [serves, setServes] = useState(baseServes);
const [got, setGot] = useState<Set<number>>(new Set([0, 2]));
const [timer, setTimer] = useState<Timer | null>(null);
const drag = useRef<{ x: number; dx: number } | null>(null);
const card = useRef<HTMLDivElement>(null);
const s = steps[step];
const last = step === steps.length - 1;
useEffect(() => {
if (!timer?.running) return;
const id = window.setInterval(
() =>
setTimer((t) =>
t ? { ...t, left: Math.max(0, t.left - 1), running: t.left > 1 } : t,
),
1000,
);
return () => window.clearInterval(id);
}, [timer?.running]);
const show = (to: number, d: 1 | -1, dx = 0) => {
if (to === step || to < 0 || to >= steps.length) {
card.current?.style.setProperty("--dx", "0px");
return;
}
setLeaving({ step, dir: d, dx, id: Date.now() });
setDir(d);
setStep(to);
};
const go = (d: 1 | -1, dx = 0) => show(step + d, d, dx);
const down = (e: PointerEvent<HTMLDivElement>) => {
if ((e.target as HTMLElement).closest("button")) return;
drag.current = { x: e.clientX, dx: 0 };
e.currentTarget.setPointerCapture(e.pointerId);
e.currentTarget.dataset.dragging = "true";
};
const move = (e: PointerEvent<HTMLDivElement>) => {
if (!drag.current) return;
const raw = e.clientX - drag.current.x;
// At the ends of the recipe the card resists, so you can feel there is nothing more.
const blocked = (raw > 0 && step === 0) || (raw < 0 && last);
drag.current.dx = blocked ? raw * 0.25 : raw;
card.current?.style.setProperty("--dx", `${drag.current.dx}px`);
};
const up = (e: PointerEvent<HTMLDivElement>) => {
const dx = drag.current?.dx ?? 0;
drag.current = null;
e.currentTarget.dataset.dragging = "false";
if (dx < -70 && !last) go(1, dx);
else if (dx > 70 && step > 0) go(-1, dx);
else card.current?.style.setProperty("--dx", "0px");
};
const startTimer = () => {
if (!s.minutes) return;
if (timer?.step === step)
return setTimer({ ...timer, running: !timer.running && timer.left > 0 });
setTimer({
step,
left: s.minutes * 60,
total: s.minutes * 60,
running: true,
});
};
const here = timer?.step === step ? timer : null;
const k = here ? 1 - here.left / here.total : 0;
const done = here?.left === 0;
const face = (i: number) => {
const st = steps[i];
return (
<>
<p className="gu-cook__count" aria-hidden="true">
Step {i + 1} of {steps.length}
</p>
<p className="gu-cook__text">{st.text}</p>
{st.uses && st.uses.length > 0 && (
<ul className="gu-cook__uses" aria-label="You need">
{st.uses.map((u, j) => (
<li key={u} style={{ "--j": j } as CSSProperties}>
{u}
</li>
))}
</ul>
)}
</>
);
};
return (
<div className="gu-cook">
<div className="gu-cook__hero">
<img src={photo} alt="" />
<div className="gu-cook__hero-shade" aria-hidden="true" />
<div className="gu-cook__hero-text">
<h2>{title}</h2>
<p>
{totalMinutes} min · serves <Roll text={String(serves)} />
<span className="gu-cook__sr">{serves}</span>
</p>
</div>
</div>
<div className="gu-cook__body">
<div className="gu-cook__tabs" role="tablist" aria-label="Recipe">
{(["steps", "ingredients"] as const).map((t) => (
<button
key={t}
type="button"
role="tab"
aria-selected={tab === t}
onClick={() => setTab(t)}
>
{t === "steps" ? "Steps" : "Ingredients"}
</button>
))}
<span
className="gu-cook__tab-pill"
data-right={tab === "ingredients"}
aria-hidden="true"
/>
</div>
{tab === "steps" ? (
<section aria-label="Steps" className="gu-cook__steps">
<div className="gu-cook__progress" aria-hidden="true">
{steps.map((_, i) => (
<span
key={i}
data-state={i < step ? "done" : i === step ? "now" : "next"}
/>
))}
</div>
<div className="gu-cook__deck">
{/* The next card waits underneath, so the steps feel like a real stack. */}
{!last && <div className="gu-cook__under" aria-hidden="true" />}
<div
ref={card}
className="gu-cook__card"
key={step}
data-enter={dir === 1 ? "lift" : dir === -1 ? "return" : "none"}
data-done={done}
onPointerDown={down}
onPointerMove={move}
onPointerUp={up}
onPointerCancel={up}
>
<span className="gu-cook__sr" aria-live="polite">
Step {step + 1} of {steps.length}
</span>
{face(step)}
{s.minutes && (
<button
type="button"
className="gu-cook__timer"
style={{ "--gu-cook-k": k } as CSSProperties}
data-running={here?.running ?? false}
data-done={done}
onClick={startTimer}
aria-label={
here
? done
? "Timer done"
: `${here.running ? "Pause" : "Resume"} timer, ${mmss(here.left)} left`
: `Start a ${s.minutes} minute timer`
}
>
<span className="gu-cook__ring" aria-hidden="true">
<svg viewBox="0 0 24 24">
{done ? (
<path
className="gu-cook__tick"
pathLength={1}
d="m6 12.5 4 4 8-9"
/>
) : here?.running ? (
<path d="M8.5 6v12M15.5 6v12" />
) : (
<path d="M8.5 5.5v13l10-6.5-10-6.5Z" />
)}
</svg>
</span>
<span className="gu-cook__timer-text">
<strong>
<Roll
text={here ? mmss(here.left) : `${s.minutes}:00`}
/>
</strong>
<span>
{here
? done
? "Done! Take it off the heat"
: here.running
? "Tap to pause"
: "Paused"
: "Start timer"}
</span>
</span>
</button>
)}
</div>
{/* The card you just left, flying off the side you sent it. */}
{leaving && (
<div
key={leaving.id}
className="gu-cook__card gu-cook__card--leaving"
data-dir={leaving.dir === 1 ? "left" : "right"}
style={{ "--from": `${leaving.dx}px` } as CSSProperties}
onAnimationEnd={(e) =>
e.target === e.currentTarget && setLeaving(null)
}
aria-hidden="true"
>
{face(leaving.step)}
</div>
)}
</div>
<div className="gu-cook__nav">
<button
type="button"
className="gu-cook__back"
onClick={() => go(-1)}
disabled={step === 0}
>
Back
</button>
<button
type="button"
className="gu-cook__next"
onClick={() => (last ? show(0, -1) : go(1))}
>
<span key={String(last)}>
{last ? "Done, cook again" : "Next step"}
</span>
</button>
</div>
</section>
) : (
<section aria-label="Ingredients" className="gu-cook__ingredients">
<div className="gu-cook__serves">
<span>People</span>
<div>
<button
type="button"
aria-label="Fewer people"
onClick={() => setServes((n) => Math.max(1, n - 1))}
>
−
</button>
<output aria-live="polite">
<Roll text={String(serves)} />
<span className="gu-cook__sr">{serves}</span>
</output>
<button
type="button"
aria-label="More people"
onClick={() => setServes((n) => Math.min(12, n + 1))}
>
+
</button>
</div>
</div>
<ul className="gu-cook__list">
{ingredients.map((g, i) => {
const amount = `${qty((g.amount * serves) / baseServes)}${g.unit ? ` ${g.unit}` : ""}`;
return (
<li key={g.name} style={{ "--i": i } as CSSProperties}>
<label data-got={got.has(i)}>
<input
type="checkbox"
checked={got.has(i)}
onChange={() =>
setGot((set) => {
const c = new Set(set);
if (c.has(i)) c.delete(i);
else c.add(i);
return c;
})
}
/>
<span className="gu-cook__check" aria-hidden="true">
<svg viewBox="0 0 24 24">
<path pathLength={1} d="m6 12.5 4 4 8-9" />
</svg>
</span>
<span className="gu-cook__name">{g.name}</span>
<span className="gu-cook__qty">
<Roll text={amount} />
<span className="gu-cook__sr">{amount}</span>
</span>
</label>
</li>
);
})}
</ul>
</section>
)}
</div>
{/* A running timer for another step stays visible as a pill. */}
{timer && timer.step !== step && (
<button
type="button"
className="gu-cook__pill"
data-done={timer.left === 0}
onClick={() => {
setTab("steps");
show(timer.step, timer.step > step ? 1 : -1);
}}
>
<span className="gu-cook__pill-dot" aria-hidden="true" />
Step {timer.step + 1} · {timer.left === 0 ? "done" : mmss(timer.left)}
</button>
)}
</div>
);
}
```
### cook-mode.css
```css
/* CookMode: warm linen, dark roast ink, one orange for the things you touch. */
@property --gu-cook-k {
syntax: "<number>";
inherits: true;
initial-value: 0;
}
.gu-cook {
--bg: #f6f1e8;
--card: #fffdf8;
--ink: #1d1712;
--muted: #7a6f63;
--line: rgb(29 23 18 / 0.1);
--accent: #ff5a1f;
--ok: #2f9e5b;
--focus: #2b35ff;
--ease: cubic-bezier(0.16, 1, 0.3, 1);
--spring: cubic-bezier(0.34, 1.45, 0.5, 1);
position: relative;
display: flex;
flex-direction: column;
height: 100%;
min-height: 640px;
overflow: hidden;
background: var(--bg);
color: var(--ink);
font-family: -apple-system, "SF Pro Text", system-ui, sans-serif;
-webkit-font-smoothing: antialiased;
}
.gu-cook button {
font: inherit;
color: inherit;
border: 0;
background: none;
cursor: pointer;
-webkit-tap-highlight-color: transparent;
}
.gu-cook :focus-visible {
outline: 2px solid var(--focus);
outline-offset: 2px;
}
.gu-cook__sr {
position: absolute;
width: 1px;
height: 1px;
overflow: hidden;
clip-path: inset(50%);
white-space: nowrap;
}
/* Rolling digits: each changed character drops into place. */
.gu-cook__roll {
display: inline-flex;
overflow: hidden;
vertical-align: bottom;
}
.gu-cook__roll span {
display: inline-block;
white-space: pre;
animation: gu-cook-roll 0.42s var(--ease) both;
}
@keyframes gu-cook-roll {
from {
opacity: 0;
translate: 0 -0.7em;
filter: blur(2px);
}
}
/* Hero: the photo drifts very slowly, like a camera breathing over the plate. */
.gu-cook__hero {
position: relative;
height: 290px;
flex-shrink: 0;
overflow: hidden;
background: #b9a48a;
}
.gu-cook__hero img {
width: 100%;
height: 100%;
object-fit: cover;
display: block;
animation: gu-cook-drift 24s ease-in-out infinite alternate;
}
@keyframes gu-cook-drift {
from {
scale: 1.04;
translate: -1.5% 0;
}
to {
scale: 1.14;
translate: 1.5% -2%;
}
}
.gu-cook__hero-shade {
position: absolute;
inset: 0;
background: linear-gradient(
rgb(0 0 0 / 0.35),
transparent 30%,
transparent 45%,
rgb(20 14 8 / 0.78)
);
}
.gu-cook__hero-text {
position: absolute;
left: 22px;
right: 22px;
bottom: 46px;
color: #fff;
animation: gu-cook-rise 0.9s 0.1s var(--ease) both;
}
@keyframes gu-cook-rise {
from {
opacity: 0;
translate: 0 14px;
}
}
.gu-cook__hero-text h2 {
margin: 0;
font-size: 30px;
font-weight: 750;
letter-spacing: -0.03em;
line-height: 1.02;
max-width: 14ch;
text-shadow: 0 2px 20px rgb(0 0 0 / 0.3);
}
.gu-cook__hero-text p {
margin: 6px 0 0;
font-size: 14px;
opacity: 0.85;
}
.gu-cook__body {
position: relative;
display: flex;
flex: 1;
flex-direction: column;
min-height: 0;
margin-top: -28px;
padding: 20px 20px
calc(var(--gu-safe-bottom, env(safe-area-inset-bottom, 0px)) + 14px);
border-radius: 30px 30px 0 0;
background: var(--bg);
box-shadow: 0 -10px 30px rgb(20 14 8 / 0.18);
}
/* Steps / Ingredients switch with a sliding pill. */
.gu-cook__tabs {
position: relative;
display: grid;
grid-template-columns: 1fr 1fr;
padding: 4px;
border-radius: 999px;
background: rgb(29 23 18 / 0.07);
}
.gu-cook__tabs button {
position: relative;
z-index: 1;
min-height: 40px;
font-size: 15px !important;
font-weight: 650 !important;
color: var(--muted) !important;
transition: color 0.3s;
}
.gu-cook__tabs button[aria-selected="true"] {
color: var(--ink) !important;
}
.gu-cook__tab-pill {
position: absolute;
top: 4px;
bottom: 4px;
left: 4px;
width: calc(50% - 4px);
border-radius: 999px;
background: var(--card);
box-shadow:
0 1px 1px rgb(29 23 18 / 0.06),
0 4px 12px rgb(29 23 18 / 0.12);
transition: translate 0.55s var(--spring);
}
.gu-cook__tab-pill[data-right="true"] {
translate: 100% 0;
}
.gu-cook__steps,
.gu-cook__ingredients {
display: flex;
flex: 1;
flex-direction: column;
min-height: 0;
animation: gu-cook-fade 0.45s var(--ease) both;
}
@keyframes gu-cook-fade {
from {
opacity: 0;
translate: 0 8px;
}
}
/* Progress: the current step's segment fills up like a fuse. */
.gu-cook__progress {
display: flex;
gap: 5px;
margin: 18px 0 14px;
}
.gu-cook__progress span {
position: relative;
flex: 1;
height: 4px;
overflow: hidden;
border-radius: 2px;
background: var(--line);
}
.gu-cook__progress span::after {
content: "";
position: absolute;
inset: 0;
border-radius: inherit;
background: var(--ink);
transform: scaleX(0);
transform-origin: left;
transition:
transform 0.6s var(--ease),
background-color 0.4s;
}
.gu-cook__progress span[data-state="done"]::after {
transform: scaleX(1);
}
.gu-cook__progress span[data-state="now"]::after {
background: var(--accent);
transform: scaleX(1);
transition-duration: 0.9s;
}
/* The deck: every card sits in the same grid cell, so they stack. */
.gu-cook__deck {
position: relative;
display: grid;
flex: 1;
min-height: 0;
padding-bottom: 10px;
}
.gu-cook__deck > * {
grid-area: 1 / 1;
min-height: 0;
}
.gu-cook__under {
border-radius: 26px;
background: var(--card);
box-shadow: 0 1px 0 var(--line);
translate: 0 10px;
scale: 0.93 1;
opacity: 0.6;
}
.gu-cook__card {
--dx: 0px;
position: relative;
z-index: 1;
display: flex;
flex-direction: column;
padding: 22px;
border-radius: 26px;
background: var(--card);
box-shadow:
0 1px 0 var(--line),
0 24px 34px -26px rgb(29 23 18 / 0.45);
touch-action: pan-y;
translate: var(--dx) 0;
rotate: calc(var(--dx) * 0.025deg);
transition:
translate 0.6s var(--spring),
rotate 0.6s var(--spring),
box-shadow 0.4s;
cursor: grab;
}
.gu-cook__card[data-dragging="true"] {
transition: none;
cursor: grabbing;
box-shadow:
0 1px 0 var(--line),
0 34px 44px -26px rgb(29 23 18 / 0.55);
}
/* The next card lifts up from the stack; going back, the old card swings in from the left. */
.gu-cook__card[data-enter="lift"] {
animation: gu-cook-lift 0.6s var(--spring) backwards;
}
.gu-cook__card[data-enter="return"] {
animation: gu-cook-return 0.6s var(--ease) backwards;
}
@keyframes gu-cook-lift {
from {
translate: 0 10px;
scale: 0.93 1;
opacity: 0.6;
}
}
@keyframes gu-cook-return {
from {
translate: -115% 0;
rotate: -8deg;
}
}
.gu-cook__card--leaving {
z-index: 2;
pointer-events: none;
animation: gu-cook-leave-left 0.5s cubic-bezier(0.4, 0, 0.7, 0.5) forwards;
}
.gu-cook__card--leaving[data-dir="right"] {
z-index: 0;
animation-name: gu-cook-leave-right;
animation-timing-function: var(--ease);
}
@keyframes gu-cook-leave-left {
from {
translate: var(--from) 0;
rotate: calc(var(--from) * 0.025deg);
}
to {
translate: -130% 30px;
rotate: -14deg;
opacity: 0;
}
}
@keyframes gu-cook-leave-right {
from {
translate: var(--from) 0;
}
to {
translate: 0 10px;
scale: 0.93 1;
opacity: 0;
}
}
.gu-cook__count {
margin: 0;
font-size: 13px;
font-weight: 700;
color: var(--accent);
}
.gu-cook__text {
margin: 10px 0 0;
font-size: 23px;
font-weight: 600;
letter-spacing: -0.02em;
line-height: 1.28;
text-wrap: pretty;
}
.gu-cook__uses {
display: flex;
flex-wrap: wrap;
gap: 6px;
margin: 16px 0 0;
padding: 0;
list-style: none;
}
.gu-cook__uses li {
padding: 6px 11px;
border-radius: 999px;
background: rgb(29 23 18 / 0.06);
font-size: 13px;
font-weight: 600;
animation: gu-cook-chip 0.5s var(--spring) both;
animation-delay: calc(var(--j) * 60ms + 200ms);
}
@keyframes gu-cook-chip {
from {
opacity: 0;
scale: 0.7;
}
}
/* Timer: a ring that fills clockwise, with play / pause / done in the middle. */
.gu-cook__timer {
position: relative;
display: flex !important;
align-items: center;
gap: 14px;
margin-top: auto !important;
padding: 12px !important;
border-radius: 20px;
background: rgb(255 90 31 / 0.08) !important;
text-align: left;
transition:
background-color 0.5s,
scale 0.2s var(--ease);
}
.gu-cook__timer:active {
scale: 0.97;
}
.gu-cook__ring {
position: relative;
display: grid;
place-items: center;
width: 56px;
height: 56px;
flex-shrink: 0;
border-radius: 50%;
color: var(--accent);
background:
radial-gradient(closest-side, var(--card) 78%, transparent 80%),
conic-gradient(
var(--accent) calc(var(--gu-cook-k) * 360deg),
rgb(255 90 31 / 0.18) 0
);
transition:
--gu-cook-k 1s linear,
color 0.4s;
}
.gu-cook__ring svg {
width: 22px;
height: 22px;
fill: currentColor;
stroke: currentColor;
stroke-width: 2.6;
stroke-linecap: round;
stroke-linejoin: round;
}
.gu-cook__timer[data-running="true"] .gu-cook__ring svg {
fill: none;
}
.gu-cook__timer[data-running="true"] .gu-cook__ring {
animation: gu-cook-tick 1s ease-in-out infinite;
}
@keyframes gu-cook-tick {
50% {
scale: 0.95;
}
}
/* Done: the ring goes green, draws a check and rings out three times. */
.gu-cook__timer[data-done="true"] {
background: rgb(47 158 91 / 0.12) !important;
}
.gu-cook__timer[data-done="true"] .gu-cook__ring {
color: var(--ok);
background:
radial-gradient(closest-side, var(--card) 78%, transparent 80%), var(--ok);
animation: gu-cook-pop 0.6s var(--spring);
}
.gu-cook__timer[data-done="true"] .gu-cook__ring svg {
fill: none;
}
.gu-cook__timer[data-done="true"] .gu-cook__ring::after {
content: "";
position: absolute;
inset: 0;
border-radius: 50%;
border: 3px solid var(--ok);
animation: gu-cook-ripple 1.2s ease-out 3;
opacity: 0;
}
.gu-cook__tick {
stroke-dasharray: 1;
stroke-dashoffset: 1;
animation: gu-cook-draw 0.5s 0.15s var(--ease) forwards;
}
@keyframes gu-cook-draw {
to {
stroke-dashoffset: 0;
}
}
@keyframes gu-cook-pop {
40% {
scale: 1.15;
}
}
@keyframes gu-cook-ripple {
from {
scale: 1;
opacity: 0.8;
}
to {
scale: 1.9;
opacity: 0;
}
}
.gu-cook__card[data-done="true"] {
animation: gu-cook-nudge 0.5s ease-in-out 2;
}
@keyframes gu-cook-nudge {
25% {
rotate: -1.2deg;
}
75% {
rotate: 1.2deg;
}
}
.gu-cook__timer-text {
display: grid;
}
.gu-cook__timer-text strong {
font-size: 26px;
font-weight: 750;
font-variant-numeric: tabular-nums;
letter-spacing: -0.02em;
}
.gu-cook__timer-text > span {
font-size: 13px;
color: var(--muted);
}
.gu-cook__timer[data-done="true"] .gu-cook__timer-text > span {
color: var(--ok);
font-weight: 650;
}
.gu-cook__nav {
display: grid;
grid-template-columns: 1fr 2fr;
gap: 10px;
margin-top: 8px;
}
.gu-cook__nav button {
min-height: 58px;
overflow: hidden;
border-radius: 20px;
font-size: 17px !important;
font-weight: 700 !important;
transition:
scale 0.25s var(--spring),
opacity 0.3s;
}
.gu-cook__nav button:active {
scale: 0.95;
}
.gu-cook__back {
background: rgb(29 23 18 / 0.07) !important;
}
.gu-cook__back:disabled {
opacity: 0.4;
}
.gu-cook__next {
background: var(--ink) !important;
color: var(--bg) !important;
box-shadow: 0 10px 20px -12px rgb(29 23 18 / 0.7);
}
.gu-cook__next span {
display: inline-block;
animation: gu-cook-fade 0.4s var(--ease) both;
}
/* Ingredients */
.gu-cook__serves {
display: flex;
align-items: center;
justify-content: space-between;
margin: 18px 0 10px;
font-weight: 650;
}
.gu-cook__serves div {
display: flex;
align-items: center;
gap: 6px;
}
.gu-cook__serves button {
display: grid;
place-items: center;
width: 44px;
height: 44px;
border-radius: 50%;
background: var(--card) !important;
box-shadow:
0 1px 0 var(--line),
0 4px 10px -6px rgb(29 23 18 / 0.3);
font-size: 22px !important;
transition: scale 0.25s var(--spring);
}
.gu-cook__serves button:active {
scale: 0.88;
}
.gu-cook__serves output {
display: inline-flex;
justify-content: center;
min-width: 30px;
font-size: 20px;
font-weight: 750;
font-variant-numeric: tabular-nums;
}
.gu-cook__list {
flex: 1;
margin: 0;
padding: 4px 16px;
overflow-y: auto;
list-style: none;
border-radius: 24px;
background: var(--card);
scrollbar-width: none;
}
.gu-cook__list li {
animation: gu-cook-fade 0.5s var(--ease) both;
animation-delay: calc(var(--i) * 45ms);
}
.gu-cook__list li + li {
border-top: 1px solid var(--line);
}
.gu-cook__list label {
display: flex;
align-items: center;
gap: 12px;
min-height: 54px;
cursor: pointer;
}
.gu-cook__list input {
position: absolute;
opacity: 0;
pointer-events: none;
}
.gu-cook__check {
display: grid;
place-items: center;
width: 24px;
height: 24px;
flex-shrink: 0;
border-radius: 8px;
box-shadow: inset 0 0 0 2px rgb(29 23 18 / 0.2);
transition:
background-color 0.25s,
box-shadow 0.25s,
scale 0.4s var(--spring);
}
.gu-cook__check svg {
width: 16px;
height: 16px;
fill: none;
stroke: #fff;
stroke-width: 3;
stroke-linecap: round;
stroke-linejoin: round;
stroke-dasharray: 1;
stroke-dashoffset: 1;
transition: stroke-dashoffset 0.35s 0.05s var(--ease);
}
.gu-cook__list input:checked + .gu-cook__check {
background: var(--accent);
box-shadow: none;
scale: 1.08;
}
.gu-cook__list input:checked + .gu-cook__check svg {
stroke-dashoffset: 0;
}
.gu-cook__list label:active .gu-cook__check {
scale: 0.85;
}
.gu-cook__list input:focus-visible + .gu-cook__check {
outline: 2px solid var(--focus);
outline-offset: 2px;
}
/* The name is crossed out by a line that draws across it. */
.gu-cook__name {
position: relative;
flex: 0 1 auto;
margin-right: auto;
font-size: 16px;
transition: color 0.3s;
}
.gu-cook__name::after {
content: "";
position: absolute;
left: -2px;
right: -2px;
top: 52%;
height: 1.5px;
background: rgb(29 23 18 / 0.45);
transform: scaleX(0);
transform-origin: left;
transition: transform 0.4s var(--ease);
}
.gu-cook__list label[data-got="true"] .gu-cook__name {
color: var(--muted);
}
.gu-cook__list label[data-got="true"] .gu-cook__name::after {
transform: scaleX(1);
}
.gu-cook__qty {
font-size: 15px;
font-weight: 650;
font-variant-numeric: tabular-nums;
color: var(--muted);
}
/* Floating timer pill */
.gu-cook__pill {
position: absolute;
top: calc(var(--gu-safe-top, env(safe-area-inset-top, 0px)) + 6px);
left: 50%;
z-index: 20;
display: inline-flex !important;
align-items: center;
gap: 8px;
min-height: 40px;
padding: 0 16px !important;
translate: -50% 0;
border-radius: 999px;
background: rgb(29 23 18 / 0.82) !important;
color: #fff !important;
-webkit-backdrop-filter: blur(12px);
backdrop-filter: blur(12px);
box-shadow: 0 10px 24px -8px rgb(0 0 0 / 0.5);
font-size: 14px !important;
font-weight: 650 !important;
font-variant-numeric: tabular-nums;
animation: gu-cook-pill 0.6s var(--spring);
}
.gu-cook__pill[data-done="true"] {
background: rgb(47 158 91 / 0.92) !important;
animation: gu-cook-pill-ring 0.5s ease-in-out 3;
}
@keyframes gu-cook-pill {
from {
opacity: 0;
translate: -50% -14px;
scale: 0.8;
}
}
@keyframes gu-cook-pill-ring {
25% {
rotate: -3deg;
}
75% {
rotate: 3deg;
}
}
.gu-cook__pill-dot {
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--accent);
animation: gu-cook-blink 1s steps(2) infinite;
}
.gu-cook__pill[data-done="true"] .gu-cook__pill-dot {
background: #fff;
animation: none;
}
@keyframes gu-cook-blink {
50% {
opacity: 0.3;
}
}
@media (prefers-reduced-motion: reduce) {
.gu-cook *,
.gu-cook *::before,
.gu-cook *::after {
animation-duration: 0.01ms !important;
animation-delay: 0ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
.gu-cook__card {
rotate: none;
}
}
```
You might also want
Next piece: Data designer portfolio with a morphing chartPlant care app
Apps, intermediate
Run tracker app
Apps, advanced
Boarding pass app
Apps, intermediate
