/* art.ivolopes.com: an artist's sketchbook on washi paper. Drawings and
   photos are "taped in"; all text is real text. Phone first. */

/* Layout: one centred column of sections; the header is a photo banner with
   a torn bottom edge; step cards wrap 2-up on phones, 5-up on wide screens. */
:root {
  --paper: #f7e9d2; --ink: #2f2620; --ink-soft: #5e5146; --clay: #a5452c; --clay-dark: #7f321f; --seal: #c4222b;
  --display: "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
  --body: "EB Garamond", Georgia, "Times New Roman", serif;
  color-scheme: only light;
}
* { box-sizing: border-box; }
html { background: var(--paper); }
/* Same phone frame as ivolopes.com: iPhone Safari paints a solid band over anything pinned to the
   screen edges, so the window never scrolls and nothing is fixed. The paper (.bg) holds still and
   reaches 160px above the screen (frame.js keeps the window there, so the clock sits on paper) and
   past the bottom bar on phones; only #page scrolls. */
:root { --above: 160px; --below: 0px; }
@media (pointer: coarse) { :root { --below: 120px; } }
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body { margin: 0; color: var(--ink); font: 18px/1.55 var(--body); }
.bg, .page { position: absolute; top: 0; left: 0; right: 0; height: calc(100vh + var(--above) + var(--below)); height: calc(100lvh + var(--above) + var(--below)); }
.bg { z-index: 0; background: var(--paper) url(book/paper-tile.webp) 0 0 / 560px 560px repeat; }
.page { z-index: 1; padding-top: var(--above); padding-bottom: calc(100lvh - 100svh + var(--below)); overflow-x: hidden; overflow-y: auto; overscroll-behavior: none; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { .page { scroll-behavior: auto; } }
img { max-width: 100%; height: auto; }
h1, h2, p { margin: 0; }
h2 { font: 500 clamp(30px, 4vw, 40px)/1.1 var(--display); text-wrap: balance; }
a { color: var(--clay-dark); }
:focus-visible { outline: 2px dashed var(--clay); outline-offset: 3px; }
.skip { position: absolute; left: -999px; top: 8px; background: #fff; padding: 6px 10px; z-index: 9; }
.skip:focus { left: 8px; }
.note { color: var(--ink-soft); font-style: italic; margin-top: 4px; }

/* ---------- Header: photo banner with a torn paper edge ---------- */
.banner {
  position: relative; display: grid; align-content: start;
  padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 70px max(20px, env(safe-area-inset-left));
  --tear: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 24' preserveAspectRatio='none'%3E%3Cpath d='M0 0H120V14L114 17L109 13L103 18L97 15L90 20L84 16L78 19L71 14L65 18L58 15L52 21L46 16L40 19L33 15L27 20L21 16L15 19L8 15L3 18L0 16Z'/%3E%3C/svg%3E");
  -webkit-mask: linear-gradient(#000 0 0) top / 100% calc(100% - 23px) no-repeat, var(--tear) bottom / 520px 24px repeat-x;
          mask: linear-gradient(#000 0 0) top / 100% calc(100% - 23px) no-repeat, var(--tear) bottom / 520px 24px repeat-x;
}
/* The painting: the gourd stands right of centre; the bare paper on the left
   holds the name. The image fades out at its left and bottom edges, so it melts into the page. */
.banner {
  background: url(book/header-900.webp) 76% 100% / cover no-repeat; min-height: 560px;
  -webkit-mask: none; mask: none;
}
.name-row { display: flex; align-items: center; gap: 16px; }
.banner h1 { font: 500 clamp(40px, 8vw, 64px)/1 var(--display); letter-spacing: .01em; }
.seal { width: clamp(62px, 15vw, 96px); height: auto; margin-top: 4px; mix-blend-mode: multiply; transform: rotate(-3deg); }
.tagline { font: italic 400 20px/1.4 var(--display); margin-top: 10px; }
.nav { position: absolute; z-index: 2; top: max(20px, env(safe-area-inset-top)); right: max(20px, env(safe-area-inset-right)); }
.lang {
  font: 500 15px var(--body); letter-spacing: .08em; background: none; color: var(--ink);
  border: 1px solid var(--ink-soft); border-radius: 999px; padding: 2px 12px; cursor: pointer;
}

/* ---------- Sections ---------- */
main { overflow-x: clip; display: grid; gap: 64px; padding: 8px max(16px, env(safe-area-inset-right)) 40px max(16px, env(safe-area-inset-left)); max-width: 1180px; margin: 0 auto; }
section > h2 { margin-bottom: 18px; }
.note + * { margin-top: 30px; }
.note + .prints { margin-top: 52px; }

/* Making: torn-paper cards, taped in and slightly crooked. This is the plain
   list (reduced motion); .moving turns it into the scroll story below. */
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 30px 18px; }
.card { position: relative; transform: rotate(var(--tilt)); }
.drawing { display: block; width: 100%; filter: drop-shadow(1px 3px 3px rgba(80, 55, 30, .28)); }
.card p { margin-top: 8px; font: 500 19px/1.3 var(--display); }
.card p em { font: italic 400 16px var(--body); color: var(--ink-soft); }
.num { color: var(--clay); }
.tape { position: absolute; width: 46%; top: -12px; left: 27%; transform: rotate(-6deg); opacity: .92; filter: drop-shadow(0 1px 1px rgba(0,0,0,.15)); pointer-events: none; z-index: 1; }
.card:nth-child(even) .tape { transform: rotate(5deg); }
.telling { display: none; }

/* The scroll story: a tall section whose stage sticks to the screen. */
.story.moving { height: 460vh; }
.stage > h2 { margin-bottom: 18px; }
.moving .stage { position: sticky; top: 0; height: 100vh; height: 100svh; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; padding-block: 22px 28px; }
.moving .stage > h2 { margin: 0; }
.moving .steps { display: block; position: relative; width: min(88vw, 50svh, 400px); height: 100%; margin: 0 auto; }
.moving .card { position: absolute; left: 0; top: 50%; width: 88%; left: 6%; translate: 0 -50%; will-change: transform, opacity; opacity: 0; }
.moving .card p { display: none; }
.moving .drawing { filter: drop-shadow(calc(2px + var(--lift, 0) * 10px) calc(5px + var(--lift, 0) * 26px) calc(5px + var(--lift, 0) * 18px) rgba(80, 55, 30, calc(.3 - var(--lift, 0) * .12))); }
.moving .telling { display: grid; gap: 16px; }
.lines { list-style: none; margin: 0; padding: 0; display: grid; }
.lines li { grid-area: 1 / 1; opacity: 0; transform: translateY(16px); transition: opacity .45s, transform .45s; display: grid; grid-template-columns: auto 1fr; column-gap: 14px; align-content: start; }
.lines li.on { opacity: 1; transform: none; }
.big-num { grid-row: span 3; font: 500 64px/.9 var(--display); font-variant-numeric: lining-nums; color: var(--clay); }
.lines h3 { margin: 0; font: 500 30px/1.1 var(--display); }
.lines .line { font: italic 400 17px var(--body); color: var(--ink-soft); }
.lines .tale { margin-top: 8px; max-width: 30ch; font-size: 18px; line-height: 1.45; }
.hint { font: italic 400 15px var(--display); color: var(--ink-soft); transition: opacity .4s; }
.hint::after { content: " ↓"; }
.story.started .hint { opacity: 0; }

/* Work: each piece on its own torn sheet, taped in like the drawings */
.prints { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 30px 18px; }
.print { position: relative; transform: rotate(var(--tilt)); }
.print .piece { display: block; width: 100%; filter: drop-shadow(1px 3px 3px rgba(80, 55, 30, .28)); }
.print .caption { display: block; margin-top: 6px; font: italic 400 18px var(--display); text-align: center; }
.print .tape { width: 40%; top: -6px; }
.print .tape.left { left: -8%; transform: rotate(-32deg); }
.print .tape.right { left: auto; right: -8%; transform: rotate(30deg); }

/* Porto */
.porto-art { display: block; width: min(100%, 1100px); margin-left: auto; margin-right: auto; }

/* Order */
.order { text-align: center; display: grid; justify-items: center; gap: 14px; padding-bottom: 20px; }
.order > p:first-of-type { max-width: 34em; color: var(--ink-soft); }
.btn {
  display: inline-block; padding: 10px 28px; background: var(--clay); color: #fff8ef; text-decoration: none;
  font: 500 19px var(--display); letter-spacing: .02em; border-radius: 3px; box-shadow: 0 2px 0 var(--clay-dark);
}
.btn:hover { background: var(--clay-dark); }
.mail { color: var(--ink); }
.foot { display: flex; justify-content: center; align-items: center; gap: 8px; padding: 10px 16px 28px; color: var(--ink-soft); font-size: 15px; }
.foot img { mix-blend-mode: multiply; }

/* ---------- Wider screens ---------- */
@media (min-width: 760px) {
  body { font-size: 19px; }
  .banner { background-image: url(book/header.webp); background-position: right bottom; background-size: auto 100%; min-height: clamp(480px, 44vw, 660px); padding: 30px 6vw 60px; }
  .banner-text { padding-top: clamp(40px, 6vw, 110px); padding-left: 4%; }
  .nav { top: 30px; right: 6vw; }
  .lang { background: rgba(239, 229, 211, .7); }
  main { gap: 84px; padding-top: 18px; }
  .steps { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 24px; }
  .moving .stage { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: 8vh auto auto 1fr; column-gap: 6vw; row-gap: 34px; padding-inline: 4%; padding-block: 0; }
  .moving .stage > h2 { grid-column: 1; grid-row: 2; }
  .moving .telling { grid-column: 1; grid-row: 3; }
  .moving .steps { grid-column: 2; grid-row: 1 / -1; align-self: start; width: min(100%, 80svh, 600px); height: min(76vh, 600px); margin-top: 2vh; }
  .moving .telling { gap: 30px; }
  .big-num { font-size: 96px; }
  .lines h3 { font-size: 42px; }
  .lines .line { font-size: 19px; }
  .lines .tale { font-size: 21px; }
  .prints { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 44px 64px; padding: 0 4%; }
}

/* Scrollbar: thin and quiet, a line of ink on the paper (no arrows, no box). */
html { scrollbar-width: thin; scrollbar-color: rgba(94, 81, 70, .38) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(94, 81, 70, .32); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: rgba(127, 50, 31, .5); }
::-webkit-scrollbar-button { display: none; }

/* Touch screens: a finger-sized hit area around the small controls, without
   changing how they look. */
@media (pointer: coarse) {
  .lang, .back { position: relative; }
  .lang::after, .back::after { content: ""; position: absolute; inset: -10px -6px; }
  .mail { display: inline-block; padding-block: 10px; }
}
