/* PUFF — the book's website.
   One sheet of cream paper with little on it. After the cover, the story is told as a trailer: four moments, one picture
   each, with one or two lines beside it. Nothing is held in place and nothing drifts: the sheet moves when you scroll,
   and while a picture crosses the window your scrolling plays it, forwards when you scroll down and backwards when you
   scroll up. Then the book and the order form. Each moment has one hand-made thing, a lettered noise or a pencil note,
   and no more. The script (js/site.js) works out where everything is; this file says how it looks. */
:root {
  --paper: #f9f3e3;          /* the book's cream paper */
  --lamp: #f4e6c4;           /* its endpapers */
  --ink: #26262a;            /* the book's printed words */
  --pencil: #4b4b57;         /* a soft graphite pencil */
  --night: #1b2a5c;
  --night-deep: #111a3d;
  --cream: #fbf4df;
  --gold: #f6c75a;
  --gold-deep: #d79a2b;
  --line: #e0d4b6;
  --book: Baskerville, "Libre Baskerville", "Baskerville Old Face", "Hoefler Text", Georgia, serif;   /* the book's own type */
  --brush: "Caveat Brush", "Marker Felt", "Comic Sans MS", cursive;                                   /* the noises */
  --hand: "Caveat", "Bradley Hand", "Segoe Print", cursive;                                           /* the pencil notes */
  --sans: Futura, "Jost", "Century Gothic", "Trebuchet MS", sans-serif;
  --gutter: clamp(20px, 5vw, 72px);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--book); font-size: 1.17rem; line-height: 1.55; overflow-x: clip; }
img, video { display: block; max-width: 100%; }
img { height: auto; }
h1, h2, h3, p, figure, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
svg.defs { position: absolute; width: 0; height: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--gold-deep); outline-offset: 4px; border-radius: 4px; }
.multiply { mix-blend-mode: multiply; }
.caps { font-family: var(--sans); font-size: .76rem; letter-spacing: .2em; text-transform: uppercase; }

/* paper grain, and a faint wash of colour that changes with the story */
.grain { position: fixed; inset: 0; z-index: 60; pointer-events: none; background: url(../img/grain.png); opacity: .1; mix-blend-mode: multiply; }
.wash { position: fixed; inset: 0; z-index: 55; pointer-events: none; mix-blend-mode: multiply; background-color: transparent; transition: background-color 1.8s ease;
  -webkit-mask: radial-gradient(95% 75% at 50% 50%, #000, transparent 78%); mask: radial-gradient(95% 75% at 50% 50%, #000, transparent 78%); }

/* ---------------------------------------------------------------- hand-made things */
/* the noises: brush letters, each a little crooked, filled with pencil strokes from the drawings */
.shout { font-family: var(--brush); font-weight: 400; font-size: clamp(3rem, 7.6vw, 8rem); line-height: .92; filter: url(#rough); --tex: url(../img/tex-night.jpg); }
.shout .l { display: inline-block; background-image: var(--tex); background-size: 720px 430px; background-position: calc(var(--i) * -67px) calc(var(--i) * -31px); -webkit-background-clip: text; background-clip: text; color: transparent;
  transform: rotate(calc(var(--r) * 1deg)) translateY(calc(var(--dy) * .012em)); padding: .14em .02em .34em; margin: -.14em 0 -.28em; }   /* a letter is painted only inside its own box: the box reaches below the line for g, y and p, and the margins take the room back */
.shout.fire { --tex: url(../img/tex-fire.jpg); } .shout.water { --tex: url(../img/tex-water.jpg); } .shout.steel { --tex: url(../img/tex-steel.jpg); }
.shout.copper { --tex: url(../img/tex-copper.jpg); } .shout.grass { --tex: url(../img/tex-grass.jpg); } .shout.gold { --tex: url(../img/tex-gold.jpg); }
/* a pencil note, and the arrow that goes with it */
.note { font-family: var(--hand); font-weight: 600; font-size: clamp(1.35rem, 2vw, 2rem); line-height: 1.05; color: var(--pencil); transform: rotate(var(--tilt, -3deg)); }
.doodle { stroke: currentColor; stroke-width: 2.4; fill: none; stroke-linecap: round; stroke-linejoin: round; filter: url(#pencil); overflow: visible; }
.book { font-size: clamp(1.15rem, 1.6vw, 1.5rem); line-height: 1.42; text-wrap: pretty; }
.book.big { font-size: clamp(1.5rem, 2.5vw, 2.5rem); line-height: 1.22; text-wrap: balance; }

.pill { position: fixed; z-index: 50; top: max(16px, env(safe-area-inset-top, 0px)); right: max(16px, env(safe-area-inset-right, 0px)); font-family: var(--sans); font-size: .88rem; font-weight: 500; letter-spacing: .05em; text-decoration: none;
  color: var(--cream); background: var(--night); border-radius: 999px; padding: .55em 1.15em; box-shadow: 0 6px 20px rgba(27, 42, 92, .25); opacity: 0; translate: 0 -12px; pointer-events: none; transition: opacity .35s ease, translate .35s ease; }
.pill.show { opacity: 1; translate: 0 0; pointer-events: auto; }
.button { display: inline-block; font-family: var(--sans); font-size: 1rem; font-weight: 500; letter-spacing: .05em; text-decoration: none; text-align: center; color: var(--night-deep); background: var(--gold);
  border: 0; border-radius: 999px; padding: .85em 1.8em; cursor: pointer; box-shadow: 0 10px 30px rgba(6, 10, 30, .3); transition: transform .2s ease, box-shadow .2s ease, background .2s ease; }
.button:hover { transform: translateY(-2px) rotate(-.6deg); background: #ffd575; }
.button:active { transform: translateY(1px); }
.button[disabled] { opacity: .55; cursor: default; transform: none; }

/* ---------------------------------------------------------------- the opening: the cover, alive.
   The whole picture is on the first screen, train and all. The paper's torn edge begins under the picture, not on it.
   Wide windows: the picture fills the screen and the words stand on its empty sky. Other windows: the whole picture
   first, uncropped, and the words under it. */
.hero { --tear: clamp(34px, 5vw, 70px); position: relative; z-index: 1; overflow: hidden; background: var(--night-deep); color: var(--cream); padding-bottom: var(--tear); }
.hero::after { content: ""; position: absolute; z-index: 3; left: 0; right: 0; bottom: -1px; height: calc(var(--tear) + 5px); background: var(--paper); transform: scaleY(-1);
  -webkit-mask: url(../img/edge-torn.png) center / 100% 100% no-repeat; mask: url(../img/edge-torn.png) center / 100% 100% no-repeat; }
.hero .film { display: block; width: 100%; height: auto; object-fit: cover; }
.hero .film.wide { aspect-ratio: 16 / 9; }
.hero .film.tall { display: none; aspect-ratio: 1200 / 1487; }
.hero .copy { position: relative; z-index: 2; padding: clamp(20px, 4vw, 40px) var(--gutter) clamp(26px, 5vw, 50px); box-shadow: 0 -10px 14px -4px var(--night-deep); }
.hero h1 { font-size: clamp(2.1rem, 6vw, 3.6rem); line-height: 1.04; font-weight: 600; letter-spacing: -.012em; margin-top: .42em; }
.hero .wink { font-family: var(--hand); font-weight: 600; font-size: clamp(1.9rem, 3.3vw, 3.2rem); line-height: 1; color: var(--gold); margin-top: .3em; transform: rotate(-2.5deg); transform-origin: left; }
.hero .what { font-size: clamp(1.08rem, 1.45vw, 1.34rem); max-width: 24em; margin-top: 1.1em; }
.hero .go { margin-top: 1.7em; display: flex; flex-wrap: wrap; align-items: center; gap: 1em 1.4em; }
.hero .down { display: inline-flex; align-items: center; gap: .5em; font-family: var(--hand); font-weight: 600; font-size: 1.55rem; text-decoration: none; color: var(--cream); transform: rotate(-2deg); }
.hero .down svg { width: 34px; height: 44px; animation: nod 1.8s ease-in-out infinite; }
@keyframes nod { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(5px); } }
@media (max-width: 760px) { .hero .film.wide { display: none; } .hero .film.tall { display: block; } }
@media not ((max-aspect-ratio: 3/2) or (max-width: 760px)) {
  /* the strip under the picture has the colours of the picture's bottom edge, so the torn paper seems to lie on the picture */
  .hero { --screen: max(100svh, 500px); height: calc(var(--screen) + var(--tear)); padding-bottom: 0; background: linear-gradient(to right, #7c8b89, #768686, #728387, #838e8b, #79888a); }
  .hero .film.wide { position: absolute; left: 0; top: 0; height: var(--screen); aspect-ratio: auto; object-position: 80% 65%; }
  .hero::before { content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none; background: linear-gradient(to right, rgba(17, 26, 61, .5), rgba(17, 26, 61, 0) 46%); }
  .hero .copy { position: absolute; left: var(--gutter); top: calc(var(--screen) / 2); translate: 0 -54%; width: min(44vw, 620px); padding: 0; box-shadow: none; }
  .hero h1 { font-size: clamp(2.3rem, 4.5vw, 4.4rem); text-shadow: 0 2px 26px rgba(10, 16, 44, .6); }
  .hero .what { text-shadow: 0 1px 14px rgba(10, 16, 44, .7); }
}
@media (min-aspect-ratio: 16/9) and (min-width: 761px) {
  /* a window wider than the picture: the picture keeps its whole height, PUFF to track, and stands at the right;
     the space left of it is filled with the picture's own left edge, drawn out sideways (video/cover-edge.png) */
  .hero { background: url(../video/cover-edge.png) left top / calc(100% - var(--screen) * 16 / 9 + 3px) var(--screen) no-repeat, linear-gradient(to right, #7c8b89, #768686, #728387, #838e8b, #79888a); }
  .hero .film.wide { left: auto; right: 0; width: calc(var(--screen) * 16 / 9); }
}

/* ---------------------------------------------------------------- the story: four moments, one picture each.
   Nothing is held in place and nothing drifts. The page moves when you scroll, and while a picture crosses the window
   your scrolling plays it, forwards or backwards. Keep it sparse: one picture, one or two lines, one hand-made thing.
   Only a lettered noise may reach over a picture's edge; the book's sentences never do. A picture's height is --h. */
.flow { position: relative; z-index: 1; padding-block: clamp(20px, 6vh, 64px) clamp(30px, 8vh, 90px); overflow-x: clip; }
.moment { position: relative; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: clamp(12px, 2vw, 30px); align-items: center;
  width: min(100%, 1440px); margin: clamp(52px, 14vh, 140px) auto 0; padding-inline: var(--gutter); }
.moment:first-child { margin-top: 0; }

/* a picture from the book, playing. Its four sides end in pencil strokes of paper colour. */
.pic { position: relative; justify-self: center; overflow: hidden; border-radius: 18px; background: var(--paper); transform: rotate(var(--tilt, 0deg)); }
.pic.tall { aspect-ratio: 760 / 956; width: min(100%, calc(var(--h, 60vh) * .795)); }
.pic.wide { aspect-ratio: 16 / 9; width: min(100%, calc(var(--h, 56vh) * 1.778)); }
.pic video, .pic img { position: absolute; left: 2px; top: 2px; width: calc(100% - 4px); height: calc(100% - 4px); object-fit: cover; }   /* a hair inside the frame: no dark line where the tilted frame is cut */
.edge { position: absolute; z-index: 5; background: var(--paper); pointer-events: none; }
.edge.t, .edge.b { left: -1px; right: -1px; height: 8.5%; -webkit-mask: url(../img/edge-torn.png) center / 100% 100% no-repeat; mask: url(../img/edge-torn.png) center / 100% 100% no-repeat; }
.edge.t { top: -1px; } .edge.b { bottom: -1px; transform: scaleY(-1); }
.edge.l, .edge.r { top: -1px; bottom: -1px; width: 7%; -webkit-mask: url(../img/edge-torn-v.png) center / 100% 100% no-repeat; mask: url(../img/edge-torn-v.png) center / 100% 100% no-repeat; }
.edge.l { left: -1px; } .edge.r { right: -1px; transform: scaleX(-1); }

/* words stay where they are on the sheet; they only come out of the paper softly as they enter the window (--o) */
.flow .book.big { font-size: clamp(1.5rem, 2.7vw, 2.7rem); }
.rise { opacity: var(--o, 0); transform: translateY(calc((1 - var(--o, 0)) * 10px)); }
.words { position: relative; z-index: 2; }
.words .book { max-width: 15em; }
.words .note { margin-top: 1.1em; display: inline-flex; align-items: flex-end; gap: .45em; font-size: clamp(1.5rem, 2.3vw, 2.3rem); text-wrap: balance; }
.words .note svg { width: 70px; height: 40px; flex: none; }
.step { opacity: var(--s, 0); display: inline-block; }
.pop { position: relative; z-index: 2; line-height: .8; white-space: nowrap; transform: rotate(-6deg); }
.chug { position: relative; z-index: 2; line-height: .86; transform: rotate(-2.5deg); }

@media (min-width: 821px) {
  /* 1. the sleeping train: picture on the left, words on the right */
  .m-asleep .pic { grid-column: 2 / span 5; --h: 66vh; }
  .m-asleep .words { grid-column: 7 / span 5; padding-left: 3%; }

  /* 2. POP! words on the left, the cloud on the right */
  .m-steam .lead { grid-column: 1 / span 4; grid-row: 1; align-self: end; justify-self: end; text-align: right; max-width: 14em; }
  .m-steam .pop { grid-column: 1 / span 5; grid-row: 2; justify-self: end; margin: .12em -5% .1em 0; font-size: clamp(5rem, 13.5vw, 13rem); }
  .m-steam .line { grid-column: 1 / span 4; grid-row: 3; align-self: start; justify-self: end; text-align: right; max-width: 11em; }
  .m-steam .pic { grid-column: 5 / -1; grid-row: 1 / span 3; --h: 56vh; }

  /* 3. the wheel: picture left of the middle, words low on the right */
  .m-wheel .pic { grid-column: 3 / span 5; --h: 60vh; }
  .m-wheel .words { grid-column: 8 / span 5; align-self: end; padding-bottom: 8vh; }
  .m-wheel .words .book { max-width: 12.5em; }

  /* 4. the train goes: everything in the middle */
  .m-go { text-align: center; }
  .m-go .chug { grid-column: 1 / -1; justify-self: center; font-size: clamp(2.6rem, 6.6vw, 6.8rem); margin-bottom: -.26em; }
  .m-go .pic { grid-column: 2 / span 10; --h: 58vh; }
  .m-go .line { grid-column: 3 / span 8; justify-self: center; margin-top: clamp(16px, 3vh, 34px); max-width: 15em; }
}

@media (max-width: 820px) {
  /* a phone: the picture, then its words, one under the other */
  .flow { padding-block: 22px 40px; }
  .moment { grid-template-columns: minmax(0, 1fr); row-gap: 20px; justify-items: center; margin-top: clamp(56px, 9vh, 86px); text-align: center; }
  .pic.tall { --h: min(98vw, 58vh); }
  .flow .book.big { font-size: 1.45rem; }
  .words .book { margin-inline: auto; }
  .words .note { font-size: 1.55rem; margin-top: .7em; }
  .words .note svg { display: none; }
  .m-steam .lead { max-width: 15em; }
  .m-steam .pop { font-size: clamp(4.6rem, 24vw, 9rem); margin: -.06em 0 -.4em; }
  .m-go .chug { font-size: clamp(2rem, 9.6vw, 4rem); margin-bottom: -.6em; }
}

/* ---------------------------------------------------------------- the book and the order form */
.paper { position: relative; z-index: 1; }
.inner { width: min(100%, 1180px); margin-inline: auto; padding-inline: var(--gutter); }
.order { padding-block: clamp(40px, 7vw, 100px) clamp(50px, 7vw, 100px); }
.order .inner { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1fr); column-gap: clamp(30px, 7vw, 100px); row-gap: clamp(36px, 6vw, 76px); align-items: center; }
.order .cover { width: min(100%, 400px); justify-self: center; border-radius: 2px 6px 6px 2px; transform: rotate(-3deg); box-shadow: -1px 0 0 rgba(0, 0, 0, .14), 0 34px 70px rgba(50, 45, 30, .36); }
.order .deal > .note { display: block; }
.order h2 { font-size: clamp(2rem, 4.1vw, 3.7rem); line-height: 1.03; font-weight: 600; letter-spacing: -.02em; text-wrap: balance; margin-top: .15em; }
.order h2 .shout { display: inline-block; font-size: 1.22em; line-height: .8; transform: rotate(-3deg) translateY(.06em); }
.order .pitch { margin-top: 1.1em; max-width: 31em; color: #47443f; text-wrap: pretty; }
.price { display: flex; align-items: baseline; gap: .6em; flex-wrap: wrap; margin-top: 1.1em; }
.price b { font-size: clamp(2.2rem, 4.2vw, 3rem); font-weight: 600; line-height: 1; }
.price span { color: #5d5a55; }
.buy { margin-top: 1.1em; display: grid; gap: 14px; justify-items: start; }
.qty { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.qty .caps { color: #5d5a55; }
.qty .stepper { display: inline-flex; align-items: center; border: 1.5px solid var(--ink); border-radius: 999px; overflow: hidden; }
.qty .stepper button { width: 46px; height: 46px; border: 0; background: transparent; cursor: pointer; font-family: var(--sans); font-size: 1.3rem; line-height: 1; }
.qty .stepper button:hover { background: var(--ink); color: var(--paper); }
.qty .stepper button[disabled] { opacity: .3; background: transparent; color: var(--ink); cursor: default; }
.qty output { min-width: 2.2em; text-align: center; font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.total b { font-weight: 600; font-variant-numeric: tabular-nums; }
.buy .button { font-size: 1.12rem; padding: .95em 2.2em; background: var(--night); color: var(--cream); box-shadow: 0 14px 34px rgba(27, 42, 92, .3); }
.buy .button:hover { background: #26397a; }
.order .small { font-size: 1rem; color: #5d5a55; max-width: 32em; }
.order .small a { color: var(--ink); }
.order .notice { margin-top: 1.3em; padding-left: 18px; border-left: 3px solid var(--gold-deep); max-width: 30em; }
.order .problem { color: #9b2c1a; font-style: italic; }
.order .preorder { margin-top: 1em; padding-left: 16px; border-left: 3px solid var(--gold-deep); max-width: 30em; }
.order .testmode { font-family: var(--sans); font-size: .9rem; padding: .6em .9em; border: 1.5px dashed var(--gold-deep); border-radius: 8px; max-width: 32em; }
.order .spec { margin-top: 1.4em; font-family: var(--sans); font-size: .82rem; letter-spacing: .09em; color: #5d5a55; }
.order .who { grid-column: 1 / -1; justify-self: center; max-width: 35em; text-align: center; color: #47443f; }
.order .who p + p { margin-top: .5em; }
@media (max-width: 860px) {
  .order .inner { grid-template-columns: minmax(0, 1fr); }
  .order .cover { width: min(64%, 280px); }
}

footer { position: relative; z-index: 1; background: var(--night-deep); color: #cdd2e6; padding-block: 44px 60px; font-size: 1rem; }
footer .inner { display: flex; flex-wrap: wrap; gap: 20px 60px; justify-content: space-between; }
footer b { color: var(--cream); font-weight: 600; letter-spacing: .14em; }
footer nav { display: flex; flex-wrap: wrap; gap: 8px 26px; align-content: flex-start; }
footer a { text-underline-offset: 3px; }

/* ---------------------------------------------------------------- the small pages: thank you, delivery and returns, privacy */
.page { background: var(--paper); color: var(--ink); padding-block: clamp(40px, 7vw, 84px); min-height: 70svh; }
.page .wrap, footer .wrap { width: min(100%, 760px); margin-inline: auto; padding-inline: var(--gutter); }
footer .wrap { width: min(100%, 1180px); display: flex; flex-wrap: wrap; gap: 20px 60px; justify-content: space-between; }
.page .home { font-family: var(--sans); font-size: .85rem; letter-spacing: .12em; text-transform: uppercase; text-decoration: none; }
.page h1 { font-size: clamp(2rem, 5vw, 2.9rem); line-height: 1.15; font-weight: 600; margin-top: .7em; }
.page h2 { font-size: 1.45rem; margin-top: 1.7em; font-weight: 600; }
.page p, .page ul { margin-top: .75em; }
.page .lede { font-size: 1.3rem; }
.page li { padding-left: 1.2em; position: relative; margin-top: .35em; }
.page li::before { content: "–"; position: absolute; left: 0; }
.page address { font-style: normal; margin-top: .75em; }
.page .cloud { width: 200px; margin-top: 10px; }
.page .button { background: var(--night); color: var(--cream); }

@media (prefers-reduced-motion: reduce) {
  .hero .down svg, .endpaper.found .puff { animation: none !important; }
  .pill, .wash { transition: none; }
  .rise { opacity: 1; transform: none; } .step { opacity: 1; transform: none; }
}
