/* Layout and motion follow ORIGINAL-SPEC.md. Colors/type come from design-system/.
   Each [data-pin] section gets --p (0..1) from site.js; the CSS below turns it into motion. */
*, *::before, *::after { box-sizing: border-box; }
img, video { max-width: 100%; height: auto; display: block; }
a { color: inherit; }
a:focus-visible, button:focus-visible, summary:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap { width: min(1400px, 100% - 2 * var(--space-4)); margin-inline: auto; }
@media (min-width: 768px) { .wrap { width: min(1400px, 100% - 2 * var(--space-8)); } }
.skip { position: fixed; left: -999px; top: 8px; z-index: 100; background: var(--primary); color: var(--on-primary); padding: var(--space-2) var(--space-4); border-radius: var(--radius-sm); }
.skip:focus { left: 8px; }
.btn--lg { min-height: 56px; padding: 0 var(--space-8); font-size: 1.0625rem; }

/* Fixed controls */
/* Header: the original logo only. Slides away on scroll down, returns on scroll up. Colours follow body[data-head]. */
.top { position: fixed; top: 0; left: 0; right: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; padding: 14px var(--space-4); pointer-events: none; transition: transform 360ms var(--ease); }
@media (min-width: 768px) { .top { padding-inline: var(--space-8); } }
.top > * { pointer-events: auto; }
.top.hide { transform: translateY(-110%); }
/* keeps the cream logo legible now that the photo tops are lighter */
body[data-head="dark"] .top::before { content: ""; position: absolute; inset: 0 0 -24px 0; z-index: -1; background: linear-gradient(rgba(10, 10, 11, 0.4), rgba(10, 10, 11, 0)); pointer-events: none; }
.top:focus-within { transform: none; }
.logo { display: block; line-height: 0; }
.logo img { height: 34px; width: auto; }
.logo__light { display: none; }
body[data-head="dark"] .logo__light { display: block; }
body[data-head="dark"] .logo__dark { display: none; }
/* Back to top: deliberately quiet so it never competes with the content */
.totop { position: fixed; right: 16px; bottom: 24px; z-index: 19; display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 50%; background: rgba(10, 10, 11, 0.4); color: #fff; cursor: pointer; opacity: 0; pointer-events: none; transform: translateY(8px); transition: opacity 400ms var(--ease), transform 400ms var(--ease), background var(--dur) var(--ease); }
.totop.on { opacity: 0.5; pointer-events: auto; transform: none; }
.totop.on:hover, .totop.on:focus-visible { opacity: 0.95; background: rgba(10, 10, 11, 0.8); }

.pill { position: fixed; z-index: 20; white-space: nowrap; display: inline-flex; align-items: center; gap: var(--space-3); min-height: 44px; padding: 0 var(--space-4); border-radius: var(--radius-pill); border: 0; font: 600 1rem var(--font-body); text-decoration: none; cursor: pointer; transition: transform var(--dur) var(--ease), background var(--dur) var(--ease); }


.pill--cta { left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--primary); color: var(--on-primary); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3); min-height: 52px; padding-right: 6px; padding-left: var(--space-6); font-size: 1.0625rem; }
.pill--cta:hover { background: var(--primary-hover); transform: translateX(-50%) translateY(-2px); }
/* Near the footer the pill is scrubbed by scroll into the footer's own button (see site.js): no timed transitions, so it is
   always in step with the page. */
.pill--cta.morph { transform: none; transition: none; min-height: 0; justify-content: center; will-change: left, top, width, height; }
.pill--cta.morph .pill__dot { overflow: hidden; flex: none; }
.pill__dot { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--graphite-950); color: var(--primary); }

/* Pinned sections: tall section, sticky full-screen stage */
:root { --video-bg: #e6d7cb; } /* sampled from the product videos (rgb 230,215,203) */
.pin { position: relative; --p: 0; }
.pin--hero { height: 520vh; }
.pin--hear { height: 420vh; }
.pin--ai { height: 440vh; }
.stage { position: sticky; top: 0; height: 100svh; overflow: hidden; display: grid; place-items: center; padding: var(--space-4); }

/* 1+2. One scene. Phases of --p: headline (0), zoom through the left lens (.05-.55), shelf photo takes over (.27-.43),
   "Crafted with Cubitts" fades in (.58), lifts (.7), paragraph arrives (.82). The shelf photo is the same picture all
   the way through, so nothing repeats when the scene ends. */
.hero { --g: clamp(0, calc((var(--p) - 0.05) / 0.5), 1); --z: calc(var(--g) * var(--g));
  --h: clamp(0, calc((var(--p) - 0.58) / 0.08), 1); --q: clamp(0, calc((var(--p) - 0.7) / 0.15), 1); --r: clamp(0, calc((var(--p) - 0.82) / 0.12), 1);
  background: var(--cream-50); color: var(--graphite-950); text-align: center; align-content: start; padding: 15svh var(--space-4) 0; }
.hero h1 { font-size: clamp(2.5rem, 7vw, 6.25rem); line-height: 1; margin-bottom: var(--space-6); }
.hero h1 em { color: var(--gold-700); }
.hero__copy { position: relative; z-index: 2; opacity: calc(1 - var(--p) * 9); transform: translateY(calc(var(--p) * -80px)); }
.hero__copy p { margin: 0 auto var(--space-2); max-width: 44ch; font-size: clamp(1.125rem, 1.6vw, 1.375rem); color: var(--graphite-700); }
.hero__copy .lead { font-size: clamp(1.25rem, 2.2vw, 2rem); font-weight: 500; line-height: 1.25; color: var(--graphite-950); margin-bottom: var(--space-4); }
/* Photo layers: the dimming is a flat overlay (cheap to composite), not a filter on the big image */
.bgwrap { position: absolute; inset: 0; overflow: hidden; }
.bgwrap::after { content: ""; position: absolute; inset: 0; /* light at the top, deeper toward the text at the bottom */ background: linear-gradient(to bottom, rgba(10, 10, 11, 0.18) 0%, rgba(10, 10, 11, 0.28) 45%, rgba(10, 10, 11, 0.72) 100%); }
.bgwrap img { width: 100%; height: 100%; max-width: none; object-fit: cover; will-change: transform; }
.hero__bg { z-index: 0; opacity: clamp(0, calc((var(--g) - 0.45) / 0.3), 1); will-change: opacity; }
.hero__bg img { transform: scale(calc(1.12 - var(--g) * 0.12 + var(--q) * 0.06)); }
.hero__img { will-change: transform, opacity; position: absolute; z-index: 1; left: 50%; bottom: 2%; max-width: none; width: min(130vw, 1500px, 129svh); transform-origin: 27% 50%; transform: translate(calc(var(--cx, -50%) + var(--tx, 0px) * var(--g)), calc(var(--ty, 0px) * var(--g))) scale(calc(1 + var(--z) * 7)); opacity: clamp(0, calc((1 - var(--g)) * 6), 1); }
/* Phones: keep the whole frame in view (never wider than the screen) and sit it right under the copy, not at the foot of the screen */
@media (max-width: 700px) {
  .hero { grid-template-columns: minmax(0, 1fr); align-content: center; padding-top: 12svh; padding-bottom: 12svh; }
  .hero__img { --cx: 0px; position: relative; left: auto; bottom: auto; justify-self: center; width: 96vw; margin-top: var(--space-8); }
}
.hero__copy > *, .hero__img { animation: intro 900ms var(--ease) both; }
.hero__copy h1 { animation-delay: 100ms; } .hero__copy .lead { animation-delay: 280ms; } .hero__copy p:last-child { animation-delay: 400ms; } .hero__img { animation-name: introimg; animation-delay: 550ms; }
@keyframes intro { from { opacity: 0; transform: translateY(28px); } }
@keyframes introimg { from { opacity: 0; } }
/* Text sits bottom-centre so the glasses above stay visible; a soft neutral scrim keeps it readable */
.cub__box { position: absolute; z-index: 2; left: 50%; bottom: 12svh; width: min(92vw, 900px); transform: translateX(-50%); text-align: center; color: var(--cream-50); }
.cub__box::before { content: ""; position: absolute; z-index: -1; left: -50vw; right: -50vw; bottom: -12svh; height: 78svh; background: linear-gradient(to top, rgba(10, 10, 11, 0.5), rgba(10, 10, 11, 0)); opacity: var(--h); pointer-events: none; }
.cub__h { margin: 0 0 var(--space-4); font-size: clamp(2.25rem, 4.6vw, 4.25rem); opacity: var(--h); transform: translateY(calc((1 - var(--h)) * 24px)); }
.cub__h { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0.1em 0.3em; }
/* The brand name is Cubitts own logo, with a round arrow button, all one link to their site */
.cub__brand { display: inline-flex; align-items: center; gap: 0.2em; padding: 0.1em 0.15em; text-decoration: none; color: var(--cream-50); }
.cub__brand img { height: 1.05em; width: auto; }
.cub__go { display: grid; place-items: center; width: 0.6em; height: 0.6em; padding: 0.12em; border: 1.5px solid rgba(249, 245, 240, 0.6); border-radius: 50%; transition: background var(--dur) var(--ease), color var(--dur) var(--ease), transform var(--dur) var(--ease); }
.cub__brand:hover .cub__go, .cub__brand:focus-visible .cub__go { background: var(--cream-50); color: var(--graphite-950); transform: rotate(45deg); }
.cub__p { margin: 0 auto; max-width: 60ch; font-size: clamp(1.125rem, 1.7vw, 1.5rem); line-height: 1.4; opacity: var(--r); transform: translateY(calc((1 - var(--r)) * 24px)); }

/* 3. Hear: full-bleed photo, darkened; one short centred phrase at a time (slow, readable) */
.stage--hear { background: var(--bg); }
.hear__bg img { transform: scale(calc(1.18 - var(--p) * 0.14)); }
/* The whole text is read once: it sits bottom-centre and lights up word by word, never swapped out */
.stage--hear::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 70svh; background: linear-gradient(to top, rgba(10, 10, 11, 0.5), rgba(10, 10, 11, 0)); pointer-events: none; }
.words { position: absolute; z-index: 2; left: 50%; bottom: 12svh; width: min(92vw, 980px); margin: 0; transform: translateX(-50%); text-align: center; color: var(--cream-50); font: 500 clamp(1.25rem, 2.2vw, 2rem)/1.3 var(--font-display); letter-spacing: -0.02em; }
.words span { opacity: 0.18; transition: opacity 200ms linear; }

/* 4. AI tech: headline, video and text all centred on one axis */
.pin--ai { --i: clamp(0, calc(var(--p) / 0.12), 1); }
.stage--ai { background: var(--video-bg); color: var(--graphite-950); grid-template-columns: 1fr; justify-items: center; align-content: center; gap: var(--space-6); text-align: center; padding-bottom: 96px; }
.stage--ai h2 { font-size: clamp(1.75rem, 3.4vw, 3rem); max-width: 26ch; }
.stage--ai h2 em { color: var(--gold-700); }
.vstack { position: relative; margin: 0; width: min(100%, 760px, 76svh); aspect-ratio: 621 / 373; border-radius: var(--radius-md); overflow: hidden; background: var(--video-bg); opacity: var(--i); transform: translateY(calc((1 - var(--i)) * 60px)) scale(calc(0.9 + var(--i) * 0.1)); }
.vstack video { position: absolute; inset: -4px; width: calc(100% + 8px); height: calc(100% + 8px); max-width: none; object-fit: cover; opacity: 0; transition: opacity 500ms var(--ease); }
.vstack video.on { opacity: 1; }
.steps { display: grid; justify-items: center; opacity: var(--i); transform: translateY(calc((1 - var(--i)) * 30px)); }
.steps__text { display: grid; min-height: 3.2em; }
.steps__text p { grid-area: 1 / 1; margin: 0; max-width: 34ch; font-size: clamp(1.25rem, 2vw, 1.75rem); line-height: 1.25; opacity: 0; transform: translateY(14px); transition: opacity 350ms var(--ease), transform 350ms var(--ease); }
.steps__text p.on { opacity: 1; transform: none; }

/* 5. Built by hand: sticky left, big images scroll right */
.built { display: grid; }
@media (min-width: 900px) { .built { grid-template-columns: 1fr 1fr; } .built__text { position: sticky; top: 0; height: 100svh; } }
.built__text { display: grid; align-items: center; padding: var(--space-16) var(--space-4); }
.built__text > div { max-width: 520px; margin-inline: auto; }
.built h2 { font-size: clamp(2rem, 4vw, 3.5rem); margin-bottom: var(--space-6); }
.built .lead { font-size: clamp(1.25rem, 1.8vw, 1.5rem); margin: 0 0 var(--space-6); color: var(--text-muted); }
.built ul { margin: 0; padding: 0; list-style: none; font-size: 1.125rem; display: grid; gap: var(--space-2); }
.built__imgs img { width: 100%; aspect-ratio: 712 / 560; object-fit: cover; background: var(--surface); }

/* 6. Footer: the original's concept. Light page, three columns, the black frame rises from the bottom (--f set by JS) */
.foot { --f: 0; --foot-bg: #f9f5f0; /* the frame image's own background, sampled */ background: var(--foot-bg); color: var(--graphite-950); padding-top: var(--space-16); overflow: hidden; }
/* Divided cells like the original: brand | links, contact, and sign-up | media, separated by fine lines */
.foot__grid { --line: rgba(10, 10, 11, 0.14); display: grid; border-top: 1px solid var(--line); }
.fc { padding: var(--space-8) var(--space-4); border-bottom: 1px solid var(--line); }
.fc--nav { display: grid; gap: var(--space-6); }
@media (min-width: 900px) {
  .foot__grid { grid-template-columns: 1fr 1fr; grid-template-areas: "brand nav" "brand contact" "signup media"; }
  .fc { padding: var(--space-8); }
  .fc--brand { grid-area: brand; border-right: 1px solid var(--line); border-bottom: 0; }
  .fc--nav { grid-area: nav; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-8); }
  .fc--contact { grid-area: contact; border-bottom: 1px solid var(--line); }
  .fc--signup { grid-area: signup; border-right: 1px solid var(--line); border-top: 1px solid var(--line); border-bottom: 0; }
  .fc--media { grid-area: media; border-bottom: 0; border-top: 1px solid var(--line); }
}

.foot a { text-decoration: none; transition: color var(--dur) var(--ease), transform var(--dur) var(--ease); }
.foot a:hover { color: var(--gold-700); }
.foot__logo { display: inline-block; line-height: 0; margin: 0; }
.foot__logo img { height: clamp(56px, 8vw, 96px); width: auto; }
.foot__links { display: grid; gap: var(--space-1); align-content: start; font: 500 1.25rem/1.3 var(--font-display); }
.foot__links .foot__k { margin-bottom: var(--space-2); font: 600 0.8125rem var(--font-body); }
.foot__links a:hover { transform: translateX(6px); }
.foot__lead { margin: 0 0 var(--space-6); font: 600 clamp(1.375rem, 2vw, 1.875rem)/1.2 var(--font-display); letter-spacing: -0.025em; max-width: 22ch; }
.foot__form { display: grid; gap: var(--space-3); max-width: 460px; }
.foot__form input { min-height: 56px; padding: 0 var(--space-6); border: 0; border-radius: var(--radius-pill); background: rgba(10, 10, 11, 0.07); color: var(--graphite-950); font: inherit; }
.foot__form input::placeholder { color: rgba(10, 10, 11, 0.6); }
.foot__form input:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(118, 93, 42, 0.45); }
.foot__form input[aria-invalid="true"] { box-shadow: 0 0 0 2px #b3261e; }
.foot .btn--primary { background: var(--graphite-950); color: var(--cream-50); }
.foot .btn--primary:hover { background: var(--gold-700); }
.foot .error { color: #b3261e; }
.foot .success { color: #3b6b12; }
.foot__k { margin: 0 0 var(--space-1); font-size: 0.8125rem; text-transform: uppercase; letter-spacing: 0.06em; color: rgba(10, 10, 11, 0.62); }
.foot__mail { display: inline-block; margin-bottom: var(--space-6); font: 600 clamp(1.5rem, 2.4vw, 2.125rem)/1.15 var(--font-display); letter-spacing: -0.025em; }
.foot__mail--sm { font-size: 1.25rem; }
.foot__legal { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); font-size: 0.9375rem; }
.foot__legal a { color: rgba(10, 10, 11, 0.7); }
.ffr { margin: var(--space-12) auto 0; width: min(100%, 1700px); overflow: hidden; }
.ffr img { width: 100%; transform: translateY(calc((1 - var(--f)) * 45%)) scale(calc(0.94 + var(--f) * 0.06)); transform-origin: 50% 100%; }
.js .up { opacity: 0; transform: translateY(40px); }
.js .foot.in .up { opacity: 1; transform: none; transition: opacity 1200ms var(--ease) calc(var(--d) * 220ms), transform 1400ms var(--ease) calc(var(--d) * 220ms); }

/* Modal */
dialog { width: min(480px, calc(100% - 32px)); padding: var(--space-8); border: 0; border-radius: var(--radius-md); background: var(--surface); color: var(--text); }
dialog::backdrop { background: rgba(10, 10, 11, 0.7); }
.modal__x { position: absolute; top: 8px; right: 8px; width: 44px; height: 44px; border: 0; background: transparent; color: var(--text); font-size: 1.75rem; cursor: pointer; border-radius: 50%; }
dialog form { display: grid; gap: var(--space-4); }
dialog fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: var(--space-2); }
dialog legend { font: 600 1.5rem var(--font-display); letter-spacing: -0.03em; margin-bottom: var(--space-3); }
.opt { display: flex; align-items: center; gap: var(--space-3); min-height: 44px; cursor: pointer; }
.opt input { accent-color: var(--primary); width: 20px; height: 20px; }
dialog textarea { padding: var(--space-3) var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); color: var(--text); font: inherit; resize: vertical; }
dialog textarea:focus-visible { outline: none; border-color: var(--primary); box-shadow: var(--focus-ring); }
dialog .field input { background: var(--bg); }
dialog .hint { margin: 0; }
.success { color: var(--signal); font-weight: 600; margin: 0; }

/* Entrance for the scrolling images */
.js .reveal { opacity: 0; transform: translateY(40px) scale(0.97); transition: opacity 600ms var(--ease), transform 600ms var(--ease); }
.js .reveal.in { opacity: 1; transform: none; }

/* Reduced motion: no travel, no pinned scrubbing; every phrase is shown as text */
@media (prefers-reduced-motion: reduce) {
  .hero__copy > *, .hero__img { animation: none; }
  .js .reveal, .js .up { opacity: 1; transform: none; transition: none; }
  .ffr img { transform: none; }
  .vstack video, .steps__text p, .words span { transition: none; }
  .words span { opacity: 1; }
}
