/* Vertical Writing Mode, in full: the narrow road. The strip is one vertical-rl
   block, so its passages, readings, paintings and notes stack right to left by
   themselves; the page's scroll translates it between two rolls, from its right
   end to its left, as a handscroll is read. */

.scroll-stage{position:relative;width:100vw;margin-inline:calc(50% - 50vw);border:0;border-radius:0;color:var(--ink);
  background:radial-gradient(130% 95% at 50% 42%,#231D17,#100D0A 72%)}

/* the scroll's measure: its height, a column's length, 13 characters to a column, the pitch between columns */
.run{--h:clamp(340px,70svh,760px);--pad:calc(var(--h) * .085);--fs:calc((var(--h) - 2 * var(--pad)) / 13.4);--col:calc(var(--fs) * 1.95);
  --inset:clamp(22px,6vw,110px);
  /* the strip's width, roughly: the text's columns, the two paintings, the covers, notes and gaps */
  --w:calc(var(--cols) * var(--col) + var(--h) * 3.55 + var(--col) * 24);
  height:calc((var(--w) - 100vw) / 1.4 + 100svh - var(--bar));
  view-timeline:--unroll block;view-timeline-inset:var(--bar) 0px}
.pin{position:sticky;top:var(--bar);height:calc(100svh - var(--bar));overflow:clip;
  display:flex;align-items:center;justify-content:center}

/* the window between the rolls; the strip passes through it */
.window{position:relative;flex:1;height:var(--h);overflow:clip;container-type:inline-size;
  box-shadow:0 40px 80px -30px rgb(0 0 0 / .75)}
.window::before,.window::after{content:'';position:absolute;inset:0 auto 0 0;width:5%;z-index:2;pointer-events:none;
  background:linear-gradient(90deg,rgb(30 22 14 / .42),rgb(30 22 14 / 0))}
.window::after{inset:0 0 0 auto;background:linear-gradient(270deg,rgb(30 22 14 / .42),rgb(30 22 14 / 0))}

.strip{position:absolute;top:0;left:0;height:100%;width:max-content;box-sizing:border-box;writing-mode:vertical-rl;
  animation:unroll linear both;animation-timeline:--unroll;animation-range:contain 0% contain 100%;
  background-color:#E0D6CC;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .32 0 0 0 0 .26 0 0 0 0 .2 0 0 0 .1 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  font-family:'Noto Serif JP Variable','Source Han Serif SC VF',serif;font-size:var(--fs);line-height:1.95;color:#211912;
  font-weight:430;font-kerning:none}
@keyframes unroll{from{translate:calc(100cqw - 100%) 0}to{translate:0 0}}

/* the rolls: the unread part on the rod at the left thins as the read part gathers at the right */
.roll{position:relative;z-index:3;flex:none;width:var(--inset);height:calc(var(--h) + 4px);border-radius:3px;
  background:linear-gradient(90deg,#5B5044,#A99C8C 14%,#E7DDD0 42%,#F4ECE1 52%,#D5C9BA 70%,#8E8171 90%,#4B4137);
  animation:thin linear both;animation-timeline:--unroll;animation-range:contain 0% contain 100%;transform-origin:100% 50%}
.roll.right{animation-name:gather;transform-origin:0 50%;
  background:linear-gradient(90deg,#4B4137,#8E8171 10%,#D5C9BA 30%,#F4ECE1 48%,#E7DDD0 58%,#A99C8C 86%,#5B5044)}
.roll.left::before,.roll.left::after{content:'';position:absolute;left:12%;right:12%;height:14px;border-radius:3px;
  background:linear-gradient(90deg,#1B130D,#5A4131 45%,#2A1D14)}
.roll.left::before{top:-12px}
.roll.left::after{bottom:-12px}
@keyframes thin{from{scale:1 1}to{scale:.34 1}}
@keyframes gather{from{scale:.3 1}to{scale:1 1}}

/* the scroll's own front: an indigo cover with its title slip, then the gold-flecked endpaper */
.front{block-size:calc(var(--col) * 2.4);background:#1E2A4A;
  background-image:repeating-linear-gradient(0deg,rgb(255 255 255 / .035) 0 1px,transparent 1px 3px),
    repeating-linear-gradient(90deg,rgb(0 0 0 / .12) 0 1px,transparent 1px 4px);
  box-shadow:inset -8px 0 18px -8px rgb(0 0 0 / .6)}
.slip{margin:var(--pad) auto 0;inline-size:calc(var(--h) * .5);block-size:calc(var(--fs) * 1.7);box-sizing:border-box;
  padding-inline:.8em;background:#EEE5D3;color:#1D1610;font-size:calc(var(--fs) * .8);line-height:1.7;letter-spacing:.32em;
  border:1px solid #B9AA92;box-shadow:0 2px 6px rgb(0 0 0 / .35)}
/* the endpaper: gold leaf cut small and scattered (the build scatters it, the same every time) */
.endpaper{block-size:calc(var(--col) * 1.4);box-shadow:inset -6px 0 12px -6px rgb(40 28 12 / .35)}
.endpaper svg{display:block;width:100%;height:100%}

/* the passages: 13 characters to a column, the haiku let down from the top, readings beside */
.passage{margin-block:0 calc(var(--col) * .9);margin-inline:var(--pad);padding-block-start:calc(var(--col) * .9)}
.passage p{margin:0}
.passage p + p{margin-block-start:calc(var(--col) * .5)}
/* a haiku keeps to one column, let down from the top: a size smaller buys the room for the drop */
.passage .ku{font-size:.9em;padding-inline-start:1.5em;white-space:nowrap;margin-block:calc(var(--col) * .55);font-weight:520}
.passage rt{font-size:.42em;letter-spacing:.04em;color:#6E5E4F;font-weight:400}

/* the English on its side, between the passages: Latin keeps its own direction and turns with the column */
.en{margin:var(--pad) 0 0;margin-block:0 calc(var(--col) * .55);max-inline-size:calc(var(--h) - 2 * var(--pad));
  font-family:var(--display);font-style:italic;font-size:calc(var(--fs) * .47);line-height:1.5;letter-spacing:.01em;color:#6A5A4B}
.en.title{margin-block:calc(var(--col) * .7) 0;font-family:var(--mono);font-style:normal;font-size:calc(var(--fs) * .3);
  letter-spacing:.2em;text-transform:uppercase;color:#7C6C5C}

/* the paintings are mounted in the scroll: one on its own paper, the other a fan pasted on ours */
/* in vertical writing a figure's blocks stack right to left like everything else: the picture, then its caption */
.painting,.fan{margin:0}
/* its paper is the scroll's own colour, so only its ends need to melt; the right end is Buson's first column, so barely */
.painting img{display:block;height:var(--h);width:calc(var(--h) * var(--ar));
  -webkit-mask-image:linear-gradient(90deg,transparent,#000 6%,#000 98.5%,transparent);mask-image:linear-gradient(90deg,transparent,#000 6%,#000 98.5%,transparent)}
.painting figcaption,.fan figcaption{margin-block:0;margin-inline:var(--pad);font-size:calc(var(--fs) * .36);color:#7C6C5C}
.fan{margin-block:0 calc(var(--col) * .4);padding-block-start:calc(var(--col) * .8)}
/* the fan is cut from its mount: an annulus about the point its ribs meet, between its two outer ribs (measured on the scan) */
.fan img{display:block;height:calc(var(--h) * .6);width:calc(var(--h) * .6 * var(--ar));margin-inline:auto;filter:drop-shadow(0 6px 10px rgb(60 40 20 / .28));
  -webkit-mask-image:radial-gradient(ellipse 59.04% 106.14% at 50.16% 116.89%,transparent 39.9%,#000 40.3%,#000 98.9%,transparent 99.3%),
    conic-gradient(from -52.9deg at 50.16% 116.89%,#000 0deg 104.9deg,transparent 105.2deg);
  mask-image:radial-gradient(ellipse 59.04% 106.14% at 50.16% 116.89%,transparent 39.9%,#000 40.3%,#000 98.9%,transparent 99.3%),
    conic-gradient(from -52.9deg at 50.16% 116.89%,#000 0deg 104.9deg,transparent 105.2deg);
  -webkit-mask-composite:source-in;mask-composite:intersect}

/* the colophon at the foot of its column, with its figures upright, one square each */
.colophon{margin:0;margin-block:calc(var(--col) * .6);padding-inline-end:var(--pad);text-align:end;font-size:calc(var(--fs) * .62);
  letter-spacing:.08em;color:#3C2F24}
.tcy{text-combine-upright:all}
.tail{block-size:calc(var(--col) * 3)}

/* where to go, before the first turn */
.cue{position:absolute;left:50%;bottom:calc((100svh - var(--bar) - var(--h)) / 4);translate:-50% 50%;margin:0;
  font-family:var(--mono);font-size:9.5px;letter-spacing:.18em;text-transform:uppercase;color:var(--dim);
  animation:cue-out linear forwards;animation-timeline:--unroll;animation-range:contain 0% contain 3%}
@keyframes cue-out{to{opacity:0}}

@media (max-width:760px){
  .run{--h:clamp(320px,62svh,640px);--inset:14px}
}

/* without motion: the scroll lies open, and scrolls itself from its right end */
@media (prefers-reduced-motion:reduce){
  .run{height:auto}
  .pin{position:relative;top:auto;height:auto;padding-block:8svh}
  .window{overflow-x:auto;writing-mode:vertical-rl}
  .strip{position:relative;animation:none}
  .roll{animation:none}
  .cue{display:none}
}
